Bug 684574 - InternalInvalidateThebesLayersInSubtree should recurse on the subdocument root frame. r=roc
authorMats Palmgren <matspal@gmail.com>
Tue, 06 Sep 2011 14:56:45 +0200
changeset 76598 29a2fbfd83699eaf6ed1afc4752cfbd8abe2b6e6
parent 76597 458686d886a5d522f32f71f46dbdb2fb3fc99edc
child 76599 47e7f8b690a5077cc91661590bd678ab4eb189a3
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersroc
bugs684574
milestone9.0a1
Bug 684574 - InternalInvalidateThebesLayersInSubtree should recurse on the subdocument root frame. r=roc
layout/base/FrameLayerBuilder.cpp
--- a/layout/base/FrameLayerBuilder.cpp
+++ b/layout/base/FrameLayerBuilder.cpp
@@ -1898,36 +1898,39 @@ InternalInvalidateThebesLayersInSubtree(
   PRBool foundContainerLayer = PR_FALSE;
   if (aFrame->GetStateBits() & NS_FRAME_HAS_CONTAINER_LAYER) {
     // Delete the invalid region to indicate that all Thebes contents
     // need to be invalidated
     aFrame->Properties().Delete(ThebesLayerInvalidRegionProperty());
     foundContainerLayer = PR_TRUE;
   }
 
-  nsIFrame* frame = aFrame;
-  while (frame) {
-    nsIFrame::ChildListIterator lists(frame);
-    for (; !lists.IsDone(); lists.Next()) {
-      nsFrameList::Enumerator childFrames(lists.CurrentList());
-      for (; !childFrames.AtEnd(); childFrames.Next()) {
-        if (InternalInvalidateThebesLayersInSubtree(childFrames.get())) {
-          foundContainerLayer = PR_TRUE;
-        }
+  nsAutoTArray<nsIFrame::ChildList,4> childListArray;
+  if (!aFrame->GetFirstPrincipalChild()) {
+    nsSubDocumentFrame* subdocumentFrame = do_QueryFrame(aFrame);
+    if (subdocumentFrame) {
+      // Descend into the subdocument
+      nsIFrame* root = subdocumentFrame->GetSubdocumentRootFrame();
+      if (root) {
+        childListArray.AppendElement(nsIFrame::ChildList(
+          nsFrameList(root, nsLayoutUtils::GetLastSibling(root)),
+          nsIFrame::kPrincipalList));
       }
     }
-    if (frame == aFrame && !frame->GetFirstPrincipalChild()) {
-      nsSubDocumentFrame* subdocumentFrame = do_QueryFrame(frame);
-      if (subdocumentFrame) {
-        // Descend into the subdocument
-        frame = subdocumentFrame->GetSubdocumentRootFrame();
-        continue;
+  }
+
+  aFrame->GetChildLists(&childListArray);
+  nsIFrame::ChildListArrayIterator lists(childListArray);
+  for (; !lists.IsDone(); lists.Next()) {
+    nsFrameList::Enumerator childFrames(lists.CurrentList());
+    for (; !childFrames.AtEnd(); childFrames.Next()) {
+      if (InternalInvalidateThebesLayersInSubtree(childFrames.get())) {
+        foundContainerLayer = PR_TRUE;
       }
     }
-    break;
   }
 
   if (!foundContainerLayer) {
     aFrame->RemoveStateBits(NS_FRAME_HAS_CONTAINER_LAYER_DESCENDANT);
   }
   return foundContainerLayer;
 }