Don't restyle slow selectors for changes to native anonymous content. (Bug 436453) r+sr=bzbarsky
authorL. David Baron <dbaron@dbaron.org>
Tue, 10 Jun 2008 17:26:59 -0700
changeset 15302 4cf8d09a71cfaba37cc1b99e90875b86b6de5851
parent 15301 4ca62a5cfec7c458f4d835bf03e6f60c6d33fe66
child 15303 b220fe3a520b349c1fcf2b11dbd8bee9e69d13ed
push id116
push userdbaron@mozilla.com
push dateWed, 11 Jun 2008 00:27:32 +0000
treeherdermozilla-central@7c4bcbed53f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs436453
milestone1.9.1a1pre
Don't restyle slow selectors for changes to native anonymous content. (Bug 436453) r+sr=bzbarsky
layout/base/nsCSSFrameConstructor.cpp
layout/base/nsPresShell.cpp
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -13137,16 +13137,29 @@ nsresult nsCSSFrameConstructor::RemoveFi
   return rv;
 }
 
 void
 nsCSSFrameConstructor::RestyleForAppend(nsIContent* aContainer,
                                         PRInt32 aNewIndexInContainer)
 {
   NS_ASSERTION(aContainer, "must have container for append");
+#ifdef DEBUG
+  {
+    for (PRInt32 index = aNewIndexInContainer;; ++index) {
+      nsIContent *content = aContainer->GetChildAt(index);
+      if (!content) {
+        NS_ASSERTION(index != aNewIndexInContainer, "yikes, nothing appended");
+        break;
+      }
+      NS_ASSERTION(!content->IsNativeAnonymous(),
+                   "native anonymous nodes should not be in child lists");
+    }
+  }
+#endif
   PRUint32 selectorFlags =
     aContainer->GetFlags() & (NODE_ALL_SELECTOR_FLAGS &
                               ~NODE_HAS_SLOW_SELECTOR_NOAPPEND);
   if (selectorFlags == 0)
     return;
 
   if (selectorFlags & NODE_HAS_SLOW_SELECTOR) {
     PostRestyleEvent(aContainer, eReStyle_Self, NS_STYLE_HINT_NONE);
@@ -13191,16 +13204,18 @@ nsCSSFrameConstructor::RestyleForAppend(
 // notification before the removal happened (and sometimes
 // CharacterDataChanged is more like a removal than an addition).
 // The comments are written and variables are named in terms of it being
 // a ContentInserted notification.
 void
 nsCSSFrameConstructor::RestyleForInsertOrChange(nsIContent* aContainer,
                                                 nsIContent* aChild)
 {
+  NS_ASSERTION(!aChild->IsNativeAnonymous(),
+               "native anonymous nodes should not be in child lists");
   PRUint32 selectorFlags =
     aContainer ? (aContainer->GetFlags() & NODE_ALL_SELECTOR_FLAGS) : 0;
   if (selectorFlags == 0)
     return;
 
   if (selectorFlags & (NODE_HAS_SLOW_SELECTOR |
                        NODE_HAS_SLOW_SELECTOR_NOAPPEND)) {
     PostRestyleEvent(aContainer, eReStyle_Self, NS_STYLE_HINT_NONE);
@@ -13270,16 +13285,18 @@ nsCSSFrameConstructor::RestyleForInsertO
   }
 }
 
 void
 nsCSSFrameConstructor::RestyleForRemove(nsIContent* aContainer,
                                         nsIContent* aOldChild,
                                         PRInt32 aIndexInContainer)
 {
+  NS_ASSERTION(!aOldChild->IsNativeAnonymous(),
+               "native anonymous nodes should not be in child lists");
   PRUint32 selectorFlags =
     aContainer ? (aContainer->GetFlags() & NODE_ALL_SELECTOR_FLAGS) : 0;
   if (selectorFlags == 0)
     return;
 
   if (selectorFlags & (NODE_HAS_SLOW_SELECTOR |
                        NODE_HAS_SLOW_SELECTOR_NOAPPEND)) {
     PostRestyleEvent(aContainer, eReStyle_Self, NS_STYLE_HINT_NONE);
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -4620,17 +4620,17 @@ PresShell::CharacterDataChanged(nsIDocum
   }
 
   // Call this here so it only happens for real content mutations and
   // not cases when the frame constructor calls its own methods to force
   // frame reconstruction.
   nsIContent *container = aContent->GetParent();
   PRUint32 selectorFlags =
     container ? (container->GetFlags() & NODE_ALL_SELECTOR_FLAGS) : 0;
-  if (selectorFlags != 0) {
+  if (selectorFlags != 0 && !aContent->IsNativeAnonymous()) {
     PRUint32 index;
     if (aInfo->mAppend &&
         container->GetChildAt((index = container->GetChildCount() - 1)) ==
           aContent)
       mFrameConstructor->RestyleForAppend(container, index);
     else
       mFrameConstructor->RestyleForInsertOrChange(container, aContent);
   }