Changeset 138036 in webkit


Ignore:
Timestamp:
Dec 18, 2012, 10:07:56 AM (12 years ago)
Author:
Simon Fraser
Message:

Fix position:-webkit-sticky behavior when zoomed
https://bugs.webkit.org/show_bug.cgi?id=105251

Reviewed by Dean Jackson.

Source/WebCore:

Position sticky elements were misplaced when stickily-constrained, under zooming.
The cause was that some of the functions used to compute sticky position
took page scale into account, and some did not.

Fix by using localToContainerQuad(..., view()) to compute RenderView-relative
quads, which avoids page scale, so all the constraints math is done ignoring
page scale. This also requires that we compute a scale-free viewport rect
in stickyPositionOffset().

Test: fast/css/sticky/sticky-top-zoomed.html

  • rendering/RenderBoxModelObject.cpp:

(WebCore::RenderBoxModelObject::computeStickyPositionConstraints):
(WebCore::RenderBoxModelObject::stickyPositionOffset):

LayoutTests:

Ref test for sticky elements in a zoomed page.

This test is marked as failing for WK1, because scrollbars always show on
zoomed pages and cannot be hidden there.

  • fast/css/sticky/sticky-top-zoomed-expected.html: Added.
  • fast/css/sticky/sticky-top-zoomed.html: Added.
  • platform/mac-wk2/TestExpectations:
  • platform/mac/TestExpectations:
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r138027 r138036  
     12012-12-17  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Fix position:-webkit-sticky behavior when zoomed
     4        https://bugs.webkit.org/show_bug.cgi?id=105251
     5
     6        Reviewed by Dean Jackson.
     7
     8        Ref test for sticky elements in a zoomed page.
     9       
     10        This test is marked as failing for WK1, because scrollbars always show on
     11        zoomed pages and cannot be hidden there.
     12
     13        * fast/css/sticky/sticky-top-zoomed-expected.html: Added.
     14        * fast/css/sticky/sticky-top-zoomed.html: Added.
     15        * platform/mac-wk2/TestExpectations:
     16        * platform/mac/TestExpectations:
     17
    1182012-12-18  Thiago Marcos P. Santos  <thiago.santos@intel.com>
    219
  • trunk/LayoutTests/platform/mac-wk2/TestExpectations

    r137391 r138036  
    363363
    364364platform/mac/tiled-drawing/ [ Pass ]
     365fast/css/sticky/sticky-top-zoomed.html [ Pass ]
    365366
    366367### END OF (5) Features that are not supported in WebKit1, so skipped in mac/TestExpectations then re-enabled here
  • trunk/LayoutTests/platform/mac/TestExpectations

    r138017 r138036  
    12171217platform/mac/tiled-drawing/ [ Skip ]
    12181218
     1219# Can't hide scrollbars in WK1
     1220fast/css/sticky/sticky-top-zoomed.html [ ImageOnlyFailure ]
     1221
    12191222webkit.org/b/100846 inspector-protocol/debugger-pause-dedicated-worker.html [ Skip ]
    12201223webkit.org/b/100846 inspector-protocol/debugger-terminate-dedicated-worker-while-paused.html [ Skip ]
  • trunk/Source/WebCore/ChangeLog

    r138035 r138036  
     12012-12-17  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Fix position:-webkit-sticky behavior when zoomed
     4        https://bugs.webkit.org/show_bug.cgi?id=105251
     5
     6        Reviewed by Dean Jackson.
     7
     8        Position sticky elements were misplaced when stickily-constrained, under zooming.
     9        The cause was that some of the functions used to compute sticky position
     10        took page scale into account, and some did not.
     11       
     12        Fix by using localToContainerQuad(..., view()) to compute RenderView-relative
     13        quads, which avoids page scale, so all the constraints math is done ignoring
     14        page scale. This also requires that we compute a scale-free viewport rect
     15        in stickyPositionOffset().
     16
     17        Test: fast/css/sticky/sticky-top-zoomed.html
     18
     19        * rendering/RenderBoxModelObject.cpp:
     20        (WebCore::RenderBoxModelObject::computeStickyPositionConstraints):
     21        (WebCore::RenderBoxModelObject::stickyPositionOffset):
     22
    1232012-12-18  Eugene Klyuchnikov  <eustas@chromium.org>
    224
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r137847 r138036  
    472472    containerContentRect.move(minLeftMargin, minTopMargin);
    473473    containerContentRect.contract(minLeftMargin + minRightMargin, minTopMargin + minBottomMargin);
    474     constraints.setAbsoluteContainingBlockRect(containingBlock->localToAbsoluteQuad(FloatRect(containerContentRect)).boundingBox());
     474    // Map to the view to avoid including page scale factor.
     475    constraints.setAbsoluteContainingBlockRect(containingBlock->localToContainerQuad(FloatRect(containerContentRect), view()).boundingBox());
    475476
    476477    LayoutRect stickyBoxRect = frameRectForStickyPositioning();
     
    480481
    481482    // FIXME: sucks to call localToAbsolute again, but we can't just offset from the previously computed rect if there are transforms.
    482     FloatRect absContainerFrame = containingBlock->localToAbsoluteQuad(FloatRect(FloatPoint(), containingBlock->size())).boundingBox();
     483    // Map to the view to avoid including page scale factor.
     484    FloatRect absContainerFrame = containingBlock->localToContainerQuad(FloatRect(FloatPoint(), containingBlock->size()), view()).boundingBox();
     485
    483486    // We can't call localToAbsolute on |this| because that will recur. FIXME: For now, assume that |this| is not transformed.
    484487    FloatRect absoluteStickyBoxRect(absContainerFrame.location() + stickyLocation, flippedStickyBoxRect.size());
     
    509512{
    510513    LayoutRect viewportRect = view()->frameView()->visibleContentRect();
    511 
     514    float scale = 1;
     515    if (Frame* frame = view()->frameView()->frame())
     516        scale = frame->frameScaleFactor();
     517   
     518    viewportRect.scale(1 / scale);
     519   
    512520    StickyPositionViewportConstraints constraints;
    513521    computeStickyPositionConstraints(constraints, viewportRect);
Note: See TracChangeset for help on using the changeset viewer.