Changeset 227974 in webkit


Ignore:
Timestamp:
Feb 1, 2018 10:59:38 AM (6 years ago)
Author:
dino@apple.com
Message:

REGRESSION (r219342): Scaled HTML widget is not responding to a clicks outside the body
https://bugs.webkit.org/show_bug.cgi?id=182394
<rdar://problem/34840816>

Reviewed by Simon Fraser.

Source/WebCore:

If a scale < 1 is applied to the page, then the visual viewport will be bigger
than the layout viewport. Our hit testing code would then ignore any hits
that were outside the layout viewport.

The fix is to only apply a hit testing clip if the page is scaling up, not down.

Update the existing fast/dom/elementFromPoint-scaled-scrolled.html test.

  • page/FrameView.cpp:

(WebCore::FrameView::layoutViewportToAbsoluteRect const): Deleted. This helper is
no longer used, and it would have probably been more confusing to have it accept
a flag to ignore the scale if it is less than 1.

  • page/FrameView.h:
  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::hitTest): No need to take the layout rect, remove the origin,
and pass it to a helper that added the origin back. The only thing the helper was
doing for us was applying a scale factor, which we only want to do if it was
scaling up.

LayoutTests:

Add a test for a scaled down page.

  • fast/dom/elementFromPoint-scaled-scrolled-expected.txt:
  • fast/dom/elementFromPoint-scaled-scrolled.html:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r227973 r227974  
     12018-02-01  Dean Jackson  <dino@apple.com>
     2
     3        REGRESSION (r219342): Scaled HTML widget is not responding to a clicks outside the body
     4        https://bugs.webkit.org/show_bug.cgi?id=182394
     5        <rdar://problem/34840816>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Add a test for a scaled down page.
     10
     11        * fast/dom/elementFromPoint-scaled-scrolled-expected.txt:
     12        * fast/dom/elementFromPoint-scaled-scrolled.html:
     13
    1142018-02-01  Commit Queue  <commit-queue@webkit.org>
    215
  • trunk/LayoutTests/fast/dom/elementFromPoint-scaled-scrolled-expected.txt

    r219342 r227974  
    1515PASS document.elementFromPoint(-85, 15) is null
    1616PASS document.elementFromPoint(215, 315) is b2
     17PASS document.elementFromPoint(525, 425) is b2
    1718PASS successfullyParsed is true
    1819
  • trunk/LayoutTests/fast/dom/elementFromPoint-scaled-scrolled.html

    r219342 r227974  
    5353    shouldBe("document.elementFromPoint(215, 315)", "b2");
    5454
     55    window.scrollTo(0, 0);
     56    if (window.internals)
     57        window.internals.setPageScaleFactor(0.5, 0, 0);
     58    // b2 is now technically outside the 800x600 scaled viewport rect,
     59    // but should still be found.
     60
     61    shouldBe("document.elementFromPoint(525, 425)", "b2");
     62
    5563    finishJSTest();
    5664}
  • trunk/Source/WebCore/ChangeLog

    r227969 r227974  
     12018-02-01  Dean Jackson  <dino@apple.com>
     2
     3        REGRESSION (r219342): Scaled HTML widget is not responding to a clicks outside the body
     4        https://bugs.webkit.org/show_bug.cgi?id=182394
     5        <rdar://problem/34840816>
     6
     7        Reviewed by Simon Fraser.
     8
     9        If a scale < 1 is applied to the page, then the visual viewport will be bigger
     10        than the layout viewport. Our hit testing code would then ignore any hits
     11        that were outside the layout viewport.
     12
     13        The fix is to only apply a hit testing clip if the page is scaling up, not down.
     14
     15        Update the existing fast/dom/elementFromPoint-scaled-scrolled.html test.
     16
     17        * page/FrameView.cpp:
     18        (WebCore::FrameView::layoutViewportToAbsoluteRect const): Deleted. This helper is
     19        no longer used, and it would have probably been more confusing to have it accept
     20        a flag to ignore the scale if it is less than 1.
     21        * page/FrameView.h:
     22        * rendering/RenderLayer.cpp:
     23        (WebCore::RenderLayer::hitTest): No need to take the layout rect, remove the origin,
     24        and pass it to a helper that added the origin back. The only thing the helper was
     25        doing for us was applying a scale factor, which we only want to do if it was
     26        scaling up.
     27
    1282018-02-01  Yusuke Suzuki  <utatane.tea@gmail.com>
    229
  • trunk/Source/WebCore/page/FrameView.cpp

    r227954 r227974  
    46094609}
    46104610
    4611 FloatRect FrameView::layoutViewportToAbsoluteRect(FloatRect rect) const
    4612 {
    4613     ASSERT(frame().settings().visualViewportEnabled());
    4614     rect.moveBy(layoutViewportRect().location());
    4615     rect.scale(frame().frameScaleFactor());
    4616     return rect;
    4617 }
    4618 
    46194611FloatPoint FrameView::layoutViewportToAbsolutePoint(FloatPoint p) const
    46204612{
  • trunk/Source/WebCore/page/FrameView.h

    r227664 r227974  
    476476    WEBCORE_EXPORT FloatPoint clientToDocumentPoint(FloatPoint) const;
    477477
    478     FloatRect layoutViewportToAbsoluteRect(FloatRect) const;
    479478    FloatPoint layoutViewportToAbsolutePoint(FloatPoint) const;
    480479
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r226666 r227974  
    49344934        if (renderer().settings().visualViewportEnabled()) {
    49354935            auto& frameView = renderer().view().frameView();
    4936             LayoutRect layoutViewportBounds({ }, frameView.layoutViewportRect().size());
    4937             LayoutRect absoluteLayoutViewportRect = LayoutRect(frameView.layoutViewportToAbsoluteRect(layoutViewportBounds));
     4936            LayoutRect absoluteLayoutViewportRect = frameView.layoutViewportRect();
     4937            auto scaleFactor = frameView.frame().frameScaleFactor();
     4938            if (scaleFactor > 1)
     4939                absoluteLayoutViewportRect.scale(scaleFactor);
    49384940            hitTestArea.intersect(absoluteLayoutViewportRect);
    49394941        } else
Note: See TracChangeset for help on using the changeset viewer.