[Webkit-unassigned] [Bug 59597] New: wrong page height is assumed during (regular HTML page) printing (concerning page breaks) when page is scaled down

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Apr 27 04:32:20 PDT 2011


https://bugs.webkit.org/show_bug.cgi?id=59597

           Summary: wrong page height is assumed during (regular HTML
                    page) printing (concerning page breaks) when page is
                    scaled down
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: PC
        OS/Version: Linux
            Status: UNCONFIRMED
          Severity: Normal
          Priority: P2
         Component: Printing
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: christophe at saout.de


When the document width is larger than the page logical width and the page is scaled down (see FrameView::forceLayoutForPagination), the printing still uses the old unscaled page height (which is now too small) and page breaks are occuring in the wrong place.

The page height is actually recomputed using the scale (using "root->setPageLogicalHeight(flooredPageLogicalWidth / pageSize.width() * pageSize.height()"), but the following call to "forceLayout();" fails to recompute the positions.

I traced it down to root->setNeedsLayoutAndPrefWidthsRecalc() not dirtying the whole tree. It just dirties the width of the root element, which, when its ::layout() is called, notices that the width is identical to its width from before and then does not relayout its children.

This is probably correct, as far as prefererred layout widths as such are concerned, but misses the fact that the page height has changed (and e.g. adjustForUnsplittableChild is never called to take the new page height into account).

I "fixed" it for our needs by applying this crude hack to make setNeedsLayoutAndPrefWidthsRecalc dirty the whole tree, so that the second forceLayout() goes through the hole tree (this should be like a forcePageHeightRecalc or sth.). I'd be happy to hear about suggestions how this should be done in a proper way. (I did not find any function to dirty the whole tree to force a full relayout, so I guess there might be some functionalty missing or at least I am missing something):


--- a/Source/WebCore/rendering/RenderObject.cpp
+++ b/Source/WebCore/rendering/RenderObject.cpp
@@ -2601,6 +2601,15 @@ void RenderObject::setNeedsBoundariesUpdate()
         renderer->setNeedsBoundariesUpdate();
 }

+void RenderObject::setNeedsLayoutAndPrefWidthsRecalc()
+{
+    setNeedsLayout(true);
+    setPreferredLogicalWidthsDirty(true);
+
+    for (RenderObject* child = firstChild(); child; child = child->nextSibling())
+        child->setNeedsLayoutAndPrefWidthsRecalc();
+}
+
 FloatRect RenderObject::objectBoundingBox() const
 {
     ASSERT_NOT_REACHED();
diff --git a/Source/WebCore/rendering/RenderObject.h b/Source/WebCore/rendering/RenderObject.h
index 75cc8a8..b1d4e9d 100644
--- a/Source/WebCore/rendering/RenderObject.h
+++ b/Source/WebCore/rendering/RenderObject.h
@@ -492,11 +492,7 @@ public:
     void setPreferredLogicalWidthsDirty(bool, bool markParents = true);
     void invalidateContainerPreferredLogicalWidths();

-    void setNeedsLayoutAndPrefWidthsRecalc()
-    {
-        setNeedsLayout(true);
-        setPreferredLogicalWidthsDirty(true);
-    }
+    void setNeedsLayoutAndPrefWidthsRecalc();

     void setPositioned(bool b = true)  { m_positioned = b;  }
     void setRelPositioned(bool b = true) { m_relPositioned = b; }

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list