Changeset 118569 in webkit


Ignore:
Timestamp:
May 25, 2012 2:48:51 PM (12 years ago)
Author:
jknotten@chromium.org
Message:

Body scrollWidth() and scrollHeight() should be page scale-invariant
https://bugs.webkit.org/show_bug.cgi?id=87494

RenderView::documentRect() is calculating the "scaled" document rect by applying
the current transformation matrix to the unscaledDocumentRect() and then
returning the rounded-out IntRect result.

This rounding out is incorrect because it allows the scaled rectangle to
represent an area that is not actually covered by the document.

We fix this by applying the current transform to the document rect
as a FloatRect and then explicitly converting to IntRect, which
takes the floor of the resulting rectangle coordinates instead of
rounding them out.

This is evidenced by the document.body.scrollWidth() and
document.body.scrollHeight() changing under page scale factor when
they are expected to remain invariant.

Reviewed by James Robinson.

Source/WebCore:

Test: fast/dom/window-scroll-scaling.html

  • rendering/RenderView.cpp:

(WebCore::RenderView::documentRect):

LayoutTests:

  • fast/dom/window-scroll-scaling-expected.txt: Added.
  • fast/dom/window-scroll-scaling.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r118567 r118569  
     12012-05-25  John Knottenbelt  <jknotten@chromium.org>
     2
     3        Body scrollWidth() and scrollHeight() should be page scale-invariant
     4        https://bugs.webkit.org/show_bug.cgi?id=87494
     5
     6        RenderView::documentRect() is calculating the "scaled" document rect by applying
     7        the current transformation matrix to the unscaledDocumentRect() and then
     8        returning the rounded-out IntRect result.
     9
     10        This rounding out is incorrect because it allows the scaled rectangle to
     11        represent an area that is not actually covered by the document.
     12
     13        We fix this by applying the current transform to the document rect
     14        as a FloatRect and then explicitly converting to IntRect, which
     15        takes the floor of the resulting rectangle coordinates instead of
     16        rounding them out.
     17
     18        This is evidenced by the document.body.scrollWidth() and
     19        document.body.scrollHeight() changing under page scale factor when
     20        they are expected to remain invariant.
     21
     22        Reviewed by James Robinson.
     23
     24        * fast/dom/window-scroll-scaling-expected.txt: Added.
     25        * fast/dom/window-scroll-scaling.html: Added.
     26
    1272012-05-25  Simon Fraser  <simon.fraser@apple.com>
    228
  • trunk/Source/WebCore/ChangeLog

    r118568 r118569  
     12012-05-25  John Knottenbelt  <jknotten@chromium.org>
     2
     3        Body scrollWidth() and scrollHeight() should be page scale-invariant
     4        https://bugs.webkit.org/show_bug.cgi?id=87494
     5
     6        RenderView::documentRect() is calculating the "scaled" document rect by applying
     7        the current transformation matrix to the unscaledDocumentRect() and then
     8        returning the rounded-out IntRect result.
     9
     10        This rounding out is incorrect because it allows the scaled rectangle to
     11        represent an area that is not actually covered by the document.
     12
     13        We fix this by applying the current transform to the document rect
     14        as a FloatRect and then explicitly converting to IntRect, which
     15        takes the floor of the resulting rectangle coordinates instead of
     16        rounding them out.
     17
     18        This is evidenced by the document.body.scrollWidth() and
     19        document.body.scrollHeight() changing under page scale factor when
     20        they are expected to remain invariant.
     21
     22        Reviewed by James Robinson.
     23
     24        Test: fast/dom/window-scroll-scaling.html
     25
     26        * rendering/RenderView.cpp:
     27        (WebCore::RenderView::documentRect):
     28
    1292012-05-25  Dan Bernstein  <mitz@apple.com>
    230
  • trunk/Source/WebCore/rendering/RenderView.cpp

    r118567 r118569  
    756756IntRect RenderView::documentRect() const
    757757{
    758     IntRect overflowRect(unscaledDocumentRect());
     758    FloatRect overflowRect(unscaledDocumentRect());
    759759    if (hasTransform())
    760760        overflowRect = layer()->currentTransform().mapRect(overflowRect);
    761     return overflowRect;
     761    return IntRect(overflowRect);
    762762}
    763763
Note: See TracChangeset for help on using the changeset viewer.