Bug 506826 - Make nsLayoutUtils::PaintFrame able to draw all continuations of a frame. r=roc
authorMarkus Stange <mstange@themasta.com>
Fri, 13 Aug 2010 15:32:04 +0200
changeset 50424 4c296b963aa452adb3fa1bb6d10ef91b64f4347a
parent 50423 1bf9a4c8c8b409ecf4b4142b3d3cd341b4dea1b4
child 50425 1b2d8d1344223eb7ddd791a22202ad62260991f1
push idunknown
push userunknown
push dateunknown
reviewersroc
bugs506826
milestone2.0b4pre
Bug 506826 - Make nsLayoutUtils::PaintFrame able to draw all continuations of a frame. r=roc
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -1277,18 +1277,24 @@ nsLayoutUtils::PaintFrame(nsIRenderingCo
   }
   nsresult rv;
 
   nsRect dirtyRect = visibleRegion.GetBounds();
   builder.EnterPresShell(aFrame, dirtyRect);
 
   rv = aFrame->BuildDisplayListForStackingContext(&builder, dirtyRect, &list);
 
+  const PRBool paintAllContinuations = aFlags & PAINT_ALL_CONTINUATIONS;
+  NS_ASSERTION(!paintAllContinuations || !aFrame->GetPrevContinuation(),
+               "If painting all continuations, the frame must be "
+               "first-continuation");
+
   nsIAtom* frameType = aFrame->GetType();
-  if (NS_SUCCEEDED(rv) && frameType == nsGkAtoms::pageContentFrame) {
+  if (NS_SUCCEEDED(rv) && !paintAllContinuations &&
+      frameType == nsGkAtoms::pageContentFrame) {
     NS_ASSERTION(!(aFlags & PAINT_WIDGET_LAYERS),
       "shouldn't be painting with widget layers for page content frames");
     // We may need to paint out-of-flow frames whose placeholders are
     // on other pages. Add those pages to our display list. Note that
     // out-of-flow frames can't be placed after their placeholders so
     // we don't have to process earlier pages. The display lists for
     // these extra pages are pruned so that only display items for the
     // page we currently care about (which we would have reached by
@@ -1298,16 +1304,26 @@ nsLayoutUtils::PaintFrame(nsIRenderingCo
     while ((page = GetNextPage(page)) != nsnull) {
       rv = BuildDisplayListForExtraPage(&builder, page, y, &list);
       if (NS_FAILED(rv))
         break;
       y += page->GetSize().height;
     }
   }
 
+  if (paintAllContinuations) {
+    nsIFrame* currentFrame = aFrame;
+    while (NS_SUCCEEDED(rv) &&
+           (currentFrame = currentFrame->GetNextContinuation()) != nsnull) {
+      nsRect frameDirty = dirtyRect - builder.ToReferenceFrame(currentFrame);
+      rv = currentFrame->BuildDisplayListForStackingContext(&builder,
+                                                            frameDirty, &list);
+    }
+  }
+
   // If we're going to display something different from what we'd normally
   // paint in a window then we will flush out any retained layer trees before
   // *and after* we draw.
   PRBool willFlushLayers = aFlags & (PAINT_IGNORE_SUPPRESSION |
                                      PAINT_IGNORE_VIEWPORT_SCROLLING |
                                      PAINT_HIDE_CARET);
 
   // For the viewport frame in print preview/page layout we want to paint
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -512,17 +512,18 @@ public:
   static nsresult GfxRectToIntRect(const gfxRect& aIn, nsIntRect* aOut);
 
   enum {
     PAINT_IN_TRANSFORM = 0x01,
     PAINT_SYNC_DECODE_IMAGES = 0x02,
     PAINT_WIDGET_LAYERS = 0x04,
     PAINT_IGNORE_SUPPRESSION = 0x08,
     PAINT_IGNORE_VIEWPORT_SCROLLING = 0x10,
-    PAINT_HIDE_CARET = 0x20
+    PAINT_HIDE_CARET = 0x20,
+    PAINT_ALL_CONTINUATIONS = 0x40
   };
 
   /**
    * Given aFrame, the root frame of a stacking context, paint it and its
    * descendants to aRenderingContext.
    * @param aRenderingContext a rendering context translated so that (0,0)
    * is the origin of aFrame; for best results, (0,0) should transform
    * to pixel-aligned coordinates. This can be null, in which case