Changeset 235806 in webkit


Ignore:
Timestamp:
Sep 7, 2018 2:12:41 PM (6 years ago)
Author:
commit-queue@webkit.org
Message:

[CSSOM View] Handle the scrollingElement in Element::scroll(Left/Top/Width/Height/To)
https://bugs.webkit.org/show_bug.cgi?id=182230

Patch by Frederic Wang <fwang@igalia.com> on 2018-09-07
Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

This commit updates expectations for some WPT tests so that they have only PASS results.
Note that css/cssom-view/scrollingElement-quirks-dynamic-*.html still fail for now (bug 182292).

  • web-platform-tests/css/cssom-view/HTMLBody-ScrollArea_quirksmode-expected.txt:
  • web-platform-tests/css/cssom-view/scrolling-quirks-vs-nonquirks-expected.txt:
  • web-platform-tests/css/cssom-view/scrollingElement-expected.txt: Added.

Source/WebCore:

This commit moves the special logic for "scrolling element" body from the
HtmlBodyElement::scroll(Left/Top/Width/Height/To) functions to the Element class. The code
is executed when the element is the scrolling element which includes the case of body
in Quirks mode and of documentElement in standard mode. This makes the behavior closer to
the CSSOM View spec (bug 5991) while not deviating too much from the current implementation.
Finally, CSSOMViewScrollingAPI is now enabled for running tests and some adjustments are made
to existing tests. Further improvements will be performed in dependencies of bug 5991.

No new tests, already covered by existing tests.

  • dom/Document.cpp: Split scrollingElement into two functions so that one can be called

internally without updating the layout.
(WebCore::Document::scrollingElement):
(WebCore::Document::scrollingElementForAPI):

  • dom/Document.h: Ditto.
  • dom/Document.idl: Use the version updating the layout for API calls.
  • dom/Element.cpp: Add include to call DOMWindow::ScrollTo

(WebCore::Element::scrollTo): Moved some logic from HtmlBodyElement to handle the case of
the scrolling element. Also skip special handling of documentElement() when
CSSOMViewScrollingAPI is disabled.
(WebCore::adjustContentsScrollPositionOrSizeForZoom): Moved some logic from HtmlBodyElement
to handle the case of the scrolling element. Also add a FIXME for improving these kinds of
helper functions. Renamed to make more explicit the semantic of the value argument.
(WebCore::Element::scrollLeft): Moved some logic from HtmlBodyElement to handle the case of
the scrolling element. Use the new documentFrameWithNonNullView() helper function.
(WebCore::Element::scrollTop): Ditto.
(WebCore::Element::setScrollLeft): Ditto
(WebCore::Element::setScrollTop): Ditto.
(WebCore::Element::scrollWidth): Ditto.
(WebCore::Element::scrollHeight): Ditto.

  • dom/Element.h:

(WebCore::Document::documentFrameWithNonNullView): New helper function to retrieve the
frame and ensure a view is available.

  • html/HTMLBodyElement.cpp: Remove code that is now in Element.
  • html/HTMLBodyElement.h: Ditto.

Source/WebKit:

  • WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocumentGtk.cpp:

(webkit_dom_document_get_scrolling_element): Use the new name.

Source/WebKitLegacy/mac:

  • DOM/DOMDocument.mm:

(-[DOMDocument scrollingElement]): Use the new name.

Tools:

This patch enables CSSOMViewScrollingAPI during test execution.

  • DumpRenderTree/mac/DumpRenderTree.mm:

(enableExperimentalFeatures):
(resetWebPreferencesToConsistentValues):

  • DumpRenderTree/win/DumpRenderTree.cpp:

(enableExperimentalFeatures):

  • WebKitTestRunner/TestController.cpp:

(WTR::TestController::resetPreferencesToConsistentValues):

LayoutTests:

This commit updates some tests to work when CSSOMViewScrollingAPI is enabled.

  • TestExpectations: Enable web-platform-tests/cssom-view/scrollingElement.html.
  • fast/dom/Document/scrollingElement-quirks-mode.html: Do not enable explictly enable

CSSOMViewScrollingAPI.

  • fast/dom/Document/scrollingElement-standards-mode.html: Ditto.
  • fast/dom/Element/body-scrollLeft-expected.txt: Updated to follow the CSSOMView spec.
  • fast/dom/Element/body-scrollLeft.html: Ditto.
  • fast/dom/Element/body-scrollTop-expected.txt: Ditto.
  • fast/dom/Element/body-scrollTop.html: Ditto.
  • fast/dom/Element/documentElement-scrollLeft-expected.txt: Ditto.
  • fast/dom/Element/documentElement-scrollLeft.html: Ditto.
  • fast/dom/Element/documentElement-scrollTop-expected.txt: Ditto.
  • fast/dom/Element/documentElement-scrollTop.html: Ditto.
  • fast/dom/Element/scrollLeft-expected.txt: Ditto.
  • fast/dom/Element/scrollLeft.html: Ditto.
  • fast/dom/Element/scrollTop-expected.txt: Ditto.
  • fast/dom/Element/scrollTop.html: Ditto.
  • fast/dom/Element/scrolling-funtions-on-body-expected.txt: Ditto.
  • fast/dom/Element/scrolling-funtions-on-body.html: Ditto.
  • platform/ios/TestExpectations: Add expectation for one WPT test that was already failing

on iOS.

  • platform/ios/ios/fast/coordinates/page-offsets-expected.txt: Use documentElement instead

of body for this test when running in standard mode.

  • platform/ios/ios/fast/coordinates/resources/helpers.js: Ditto.

(verifyScrollOffsets):

  • tiled-drawing/scrolling/fast-scroll-div-latched-mainframe.html: Use

document.scrollingElement instead of document.body to access viewport scroll offset.

Location:
trunk
Files:
1 added
1 deleted
41 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r235783 r235806  
     12018-09-07  Frederic Wang  <fwang@igalia.com>
     2
     3        [CSSOM View] Handle the scrollingElement in Element::scroll(Left/Top/Width/Height/To)
     4        https://bugs.webkit.org/show_bug.cgi?id=182230
     5
     6        Reviewed by Simon Fraser.
     7
     8        This commit updates some tests to work when CSSOMViewScrollingAPI is enabled.
     9
     10        * TestExpectations: Enable web-platform-tests/cssom-view/scrollingElement.html.
     11        * fast/dom/Document/scrollingElement-quirks-mode.html: Do not enable explictly enable
     12        CSSOMViewScrollingAPI.
     13        * fast/dom/Document/scrollingElement-standards-mode.html: Ditto.
     14        * fast/dom/Element/body-scrollLeft-expected.txt: Updated to follow the CSSOMView spec.
     15        * fast/dom/Element/body-scrollLeft.html: Ditto.
     16        * fast/dom/Element/body-scrollTop-expected.txt: Ditto.
     17        * fast/dom/Element/body-scrollTop.html: Ditto.
     18        * fast/dom/Element/documentElement-scrollLeft-expected.txt: Ditto.
     19        * fast/dom/Element/documentElement-scrollLeft.html: Ditto.
     20        * fast/dom/Element/documentElement-scrollTop-expected.txt: Ditto.
     21        * fast/dom/Element/documentElement-scrollTop.html: Ditto.
     22        * fast/dom/Element/scrollLeft-expected.txt: Ditto.
     23        * fast/dom/Element/scrollLeft.html: Ditto.
     24        * fast/dom/Element/scrollTop-expected.txt: Ditto.
     25        * fast/dom/Element/scrollTop.html: Ditto.
     26        * fast/dom/Element/scrolling-funtions-on-body-expected.txt: Ditto.
     27        * fast/dom/Element/scrolling-funtions-on-body.html: Ditto.
     28        * platform/ios/TestExpectations: Add expectation for one WPT test that was already failing
     29        on iOS.
     30        * platform/ios/ios/fast/coordinates/page-offsets-expected.txt: Use documentElement instead
     31        of body for this test when running in standard mode.
     32        * platform/ios/ios/fast/coordinates/resources/helpers.js: Ditto.
     33        (verifyScrollOffsets):
     34        * tiled-drawing/scrolling/fast-scroll-div-latched-mainframe.html: Use
     35        document.scrollingElement instead of document.body to access viewport scroll offset.
     36
    1372018-09-07  Zalan Bujtas  <zalan@apple.com>
    238
  • trunk/LayoutTests/TestExpectations

    r235772 r235806  
    18921892# Test only works on iOS WK2. webkit.org/b/165535
    18931893fast/forms/range/range-remove-on-drag.html [ Skip ]
    1894 
    1895 # CSSOM View module
    1896 webkit.org/b/5991 imported/w3c/web-platform-tests/css/cssom-view/scrollingElement.html [ Skip ]
    18971894
    18981895# FileAPI
  • trunk/LayoutTests/fast/dom/Document/scrollingElement-quirks-mode.html

    r235539 r235806  
    66<body>
    77<script>
    8 if (window.internals)
    9     internals.settings.setCSSOMViewScrollingAPIEnabled(true);
    108
    119description("Tests the behavior of document.scrollingElement in quirks mode.");
  • trunk/LayoutTests/fast/dom/Document/scrollingElement-standards-mode.html

    r235539 r235806  
    77<body>
    88<script>
    9 if (window.internals)
    10     internals.settings.setCSSOMViewScrollingAPIEnabled(true);
    119
    1210description("Tests the behavior of document.scrollingElement in standards mode.");
  • trunk/LayoutTests/fast/dom/Element/body-scrollLeft-expected.txt

    r167539 r235806  
    77
    88TEST COMPLETE
    9 PASS document.body.scrollLeft is 500
     9PASS document.body.scrollLeft is 0
    1010PASS successfullyParsed is true
    1111
  • trunk/LayoutTests/fast/dom/Element/body-scrollLeft.html

    r167539 r235806  
    1313                description('Tests that for non-standard mode document.body.scrollLeft returns the scroll left value as 0');
    1414
    15                 document.body.scrollLeft = 500;
    16                 shouldBe("document.body.scrollLeft","500");
     15                document.body.scrollLeft = 0;
     16                shouldBe("document.body.scrollLeft","0");
    1717                isSuccessfullyParsed();
    1818                        }
  • trunk/LayoutTests/fast/dom/Element/body-scrollTop-expected.txt

    r167539 r235806  
    77
    88TEST COMPLETE
    9 PASS document.body.scrollTop is 500
     9PASS document.body.scrollTop is 0
    1010PASS successfullyParsed is true
    1111
  • trunk/LayoutTests/fast/dom/Element/body-scrollTop.html

    r167539 r235806  
    1414
    1515                document.body.scrollTop = 500;
    16                 shouldBe("document.body.scrollTop","500");
     16                shouldBe("document.body.scrollTop","0");
    1717                                isSuccessfullyParsed();
    1818            }
  • trunk/LayoutTests/fast/dom/Element/documentElement-scrollLeft-expected.txt

    r167539 r235806  
    77
    88TEST COMPLETE
    9 PASS document.documentElement.scrollLeft is 0
     9PASS document.documentElement.scrollLeft is 500
    1010PASS successfullyParsed is true
    1111
  • trunk/LayoutTests/fast/dom/Element/documentElement-scrollLeft.html

    r167539 r235806  
    1414
    1515                document.documentElement.scrollLeft = 500;
    16                 shouldBe("document.documentElement.scrollLeft","0");
     16                shouldBe("document.documentElement.scrollLeft","500");
    1717                isSuccessfullyParsed();
    1818            }
  • trunk/LayoutTests/fast/dom/Element/documentElement-scrollTop-expected.txt

    r167539 r235806  
    44
    55
    6 PASS document.documentElement.scrollTop is 0
     6PASS document.documentElement.scrollTop is 500
    77PASS successfullyParsed is true
    88
  • trunk/LayoutTests/fast/dom/Element/documentElement-scrollTop.html

    r167539 r235806  
    1414
    1515                document.documentElement.scrollTop = 500;
    16                 shouldBe("document.documentElement.scrollTop","0");
     16                shouldBe("document.documentElement.scrollTop","500");
    1717                isSuccessfullyParsed();
    1818            }
  • trunk/LayoutTests/fast/dom/Element/scrollLeft-expected.txt

    r167539 r235806  
    55
    66PASS window.pageXOffset is 500
    7 PASS document.body.scrollLeft is 500
    8 PASS document.documentElement.scrollLeft is 0
     7PASS document.body.scrollLeft is 0
     8PASS document.documentElement.scrollLeft is 500
    99PASS successfullyParsed is true
    1010
  • trunk/LayoutTests/fast/dom/Element/scrollLeft.html

    r167539 r235806  
    1616                    window.scrollTo(500,0);
    1717                    shouldBe("window.pageXOffset","500");
    18                     shouldBe("document.body.scrollLeft","500");
    19                     shouldBe("document.documentElement.scrollLeft","0");
     18                    shouldBe("document.body.scrollLeft","0");
     19                    shouldBe("document.documentElement.scrollLeft","500");
    2020                    finishJSTest();
    2121                }, 0);
  • trunk/LayoutTests/fast/dom/Element/scrollTop-expected.txt

    r167539 r235806  
    55
    66PASS window.pageYOffset is 500
    7 PASS document.body.scrollTop is 500
    8 PASS document.documentElement.scrollTop is 0
     7PASS document.body.scrollTop is 0
     8PASS document.documentElement.scrollTop is 500
    99PASS successfullyParsed is true
    1010
  • trunk/LayoutTests/fast/dom/Element/scrollTop.html

    r167539 r235806  
    1616                    window.scrollTo(0,500);
    1717                    shouldBe("window.pageYOffset","500");
    18                     shouldBe("document.body.scrollTop","500");
    19                     shouldBe("document.documentElement.scrollTop","0");
     18                    shouldBe("document.body.scrollTop","0");
     19                    shouldBe("document.documentElement.scrollTop","500");
    2020                    finishJSTest();
    2121                }, 0);
  • trunk/LayoutTests/fast/dom/Element/scrolling-funtions-on-body-expected.txt

    r205505 r235806  
    1 Tests scrollTo/By(x,y) and scrollTo/By(scrollOptions) on the body. WebKit always uses quirks mode for body scrolling behavior, so this scrolls the window.
     1Tests scrollTo/By(x,y) and scrollTo/By(scrollOptions) on the body in standard mode.
    22
    33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
    44
    55
    6 PASS scroller.scrollLeft is 20
    7 PASS scroller.scrollTop is 500
    8 PASS window.scrollX is 20
    9 PASS window.scrollY is 500
    10 PASS scroller.scrollLeft is 70
    11 PASS scroller.scrollTop is 560
    12 PASS window.scrollX is 70
    13 PASS window.scrollY is 560
    14 PASS scroller.scrollLeft is 100
    15 PASS scroller.scrollTop is 400
    16 PASS window.scrollX is 100
    17 PASS window.scrollY is 400
     6PASS scroller.scrollLeft is 0
     7PASS scroller.scrollTop is 0
     8PASS window.scrollX is 0
     9PASS window.scrollY is 0
     10PASS scroller.scrollLeft is 0
     11PASS scroller.scrollTop is 0
     12PASS window.scrollX is 0
     13PASS window.scrollY is 0
     14PASS scroller.scrollLeft is 0
     15PASS scroller.scrollTop is 0
     16PASS window.scrollX is 0
     17PASS window.scrollY is 0
    1818PASS successfullyParsed is true
    1919
  • trunk/LayoutTests/fast/dom/Element/scrolling-funtions-on-body.html

    r205505 r235806  
    1212            var scroller;
    1313            function runTest() {
    14                 description('Tests scrollTo/By(x,y) and scrollTo/By(scrollOptions) on the body. WebKit always uses quirks mode for body scrolling behavior, so this scrolls the window.');
     14                description('Tests scrollTo/By(x,y) and scrollTo/By(scrollOptions) on the body in standard mode.');
    1515               
    1616                scroller = document.body;
    1717                setTimeout(function() {
    1818                    scroller.scrollTo(20, 500);
    19                     shouldBe("scroller.scrollLeft", "20");
    20                     shouldBe("scroller.scrollTop", "500");
    21                     shouldBe("window.scrollX", "20");
    22                     shouldBe("window.scrollY", "500");
     19                    shouldBe("scroller.scrollLeft", "0");
     20                    shouldBe("scroller.scrollTop", "0");
     21                    shouldBe("window.scrollX", "0");
     22                    shouldBe("window.scrollY", "0");
    2323
    2424                    scroller.scrollBy(50, 60);
    25                     shouldBe("scroller.scrollLeft", "70");
    26                     shouldBe("scroller.scrollTop", "560");
    27                     shouldBe("window.scrollX", "70");
    28                     shouldBe("window.scrollY", "560");
     25                    shouldBe("scroller.scrollLeft", "0");
     26                    shouldBe("scroller.scrollTop", "0");
     27                    shouldBe("window.scrollX", "0");
     28                    shouldBe("window.scrollY", "0");
    2929
    3030                    scroller.scrollTo({ 'left' : 100, 'top' : 400 });
    31                     shouldBe("scroller.scrollLeft", "100");
    32                     shouldBe("scroller.scrollTop", "400");
    33                     shouldBe("window.scrollX", "100");
    34                     shouldBe("window.scrollY", "400");
     31                    shouldBe("scroller.scrollLeft", "0");
     32                    shouldBe("scroller.scrollTop", "0");
     33                    shouldBe("window.scrollX", "0");
     34                    shouldBe("window.scrollY", "0");
    3535
    3636                    scroller.scrollTo(0, 0);
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r235714 r235806  
     12018-09-07  Frederic Wang  <fwang@igalia.com>
     2
     3        [CSSOM View] Handle the scrollingElement in Element::scroll(Left/Top/Width/Height/To)
     4        https://bugs.webkit.org/show_bug.cgi?id=182230
     5
     6        Reviewed by Simon Fraser.
     7
     8        This commit updates expectations for some WPT tests so that they have only PASS results.
     9        Note that css/cssom-view/scrollingElement-quirks-dynamic-*.html still fail for now (bug 182292).
     10
     11        * web-platform-tests/css/cssom-view/HTMLBody-ScrollArea_quirksmode-expected.txt:
     12        * web-platform-tests/css/cssom-view/scrolling-quirks-vs-nonquirks-expected.txt:
     13        * web-platform-tests/css/cssom-view/scrollingElement-expected.txt: Added.
     14
    1152018-09-05  Youenn Fablet  <youenn@apple.com>
    216
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/HTMLBody-ScrollArea_quirksmode-expected.txt

    r232903 r235806  
    44PASS document.compatMode should be BackCompat in quirks.
    55PASS document.scrollingElement should be body element in quirks.
    6 FAIL scrollingElement in quirks should be null when body is potentially scrollable. assert_equals: In quirks, we would expect null here (because of potentially scrollable body) expected null but got Element node <body id="thebody" style="overflow-y: scroll;">
    7     <div ...
     6PASS scrollingElement in quirks should be null when body is potentially scrollable.
    87PASS scrollingElement in quirks should be body if any of document and body has a visible overflow.
    9 FAIL When body potentially scrollable, document.body.scrollHeight changes when changing the height of the body content in quirks. assert_not_equals: got disallowed value 600
     8PASS When body potentially scrollable, document.body.scrollHeight changes when changing the height of the body content in quirks.
    109PASS When body not potentially scrollable, document.body.scrollHeight always equals window.innerHeight in quirks. (cond. visible, scroll)
    1110PASS When body not potentially scrollable, document.body.scrollHeight always equals window.innerHeight in quirks. (cond. scroll, visible)
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scrolling-quirks-vs-nonquirks-expected.txt

    r232903 r235806  
    1717PASS scrollWidth/scrollHeight of the content in quirks mode
    1818PASS clientWidth/clientHeight of the content in quirks mode
    19 FAIL scrollingElement in non-quirks mode assert_equals: scrollingElement should be documentElement expected Element node <html><head></head><body style="overflow: hidden; margin:... but got Element node <body style="overflow: hidden; margin: 0px; border-width:...
    20 FAIL scroll() on the root element in non-quirks mode assert_equals: scrollLeft should be 50 expected 50 but got 0
    21 FAIL scrollBy() on the root element in non-quirks mode assert_equals: scrollLeft should be 60 expected 60 but got 0
    22 FAIL scrollLeft/scrollTop on the root element in non-quirks mode assert_equals: scrollLeft should be 70 expected 70 but got 0
     19PASS scrollingElement in non-quirks mode
     20PASS scroll() on the root element in non-quirks mode
     21PASS scrollBy() on the root element in non-quirks mode
     22PASS scrollLeft/scrollTop on the root element in non-quirks mode
    2323PASS scrollWidth/scrollHeight on the root element in non-quirks mode
    2424PASS clientWidth/clientHeight on the root element in non-quirks mode
    25 FAIL scroll() on the HTML body element in non-quirks mode assert_equals: scrollLeft should be 0 expected 0 but got 90
    26 FAIL scrollBy() on the HTML body element in non-quirks mode assert_equals: scrollLeft should be 0 expected 0 but got 100
    27 FAIL scrollLeft/scrollTop on the HTML body element in non-quirks mode assert_equals: scrollLeft should be 0 expected 0 but got 120
    28 FAIL scrollWidth/scrollHeight on the HTML body element in non-quirks mode assert_equals: scrollWidth should be 700 expected 700 but got 720
     25PASS scroll() on the HTML body element in non-quirks mode
     26PASS scrollBy() on the HTML body element in non-quirks mode
     27PASS scrollLeft/scrollTop on the HTML body element in non-quirks mode
     28PASS scrollWidth/scrollHeight on the HTML body element in non-quirks mode
    2929PASS clientWidth/clientHeight on the HTML body element in non-quirks mode
    3030PASS scrollLeft/scrollRight of the content in non-quirks mode
  • trunk/LayoutTests/platform/ios/TestExpectations

    r235783 r235806  
    26492649webkit.org/b/163755 imported/w3c/web-platform-tests/css/css-shapes [ Skip ]
    26502650
     2651webkit.org/b/5991 imported/w3c/web-platform-tests/css/cssom-view/scrolling-quirks-vs-nonquirks.html [ Failure ]
     2652
    26512653# Variation fonts are not implemented earlier than iOS 11.
    26522654fast/text/variations [ Pass Failure ImageOnlyFailure ]
  • trunk/LayoutTests/platform/ios/ios/fast/coordinates/page-offsets-expected.txt

    r178197 r235806  
    44PASS window.scrollX is 0
    55PASS window.pageXOffset is 0
    6 PASS document.body.scrollLeft is 0
     6PASS document.documentElement.scrollLeft is 0
    77PASS window.scrollY is 0
    88PASS window.pageYOffset is 0
    9 PASS document.body.scrollTop is 0
     9PASS document.documentElement.scrollTop is 0
    1010
    1111scaled and panned
    1212PASS window.scrollX is 10
    1313PASS window.pageXOffset is 10
    14 PASS document.body.scrollLeft is 10
     14PASS document.documentElement.scrollLeft is 10
    1515PASS window.scrollY is 10
    1616PASS window.pageYOffset is 10
    17 PASS document.body.scrollTop is 10
     17PASS document.documentElement.scrollTop is 10
    1818PASS successfullyParsed is true
    1919
  • trunk/LayoutTests/platform/ios/ios/fast/coordinates/resources/helpers.js

    r178197 r235806  
    5252    shouldBe('window.scrollX', expectedScrollX.toString());
    5353    shouldBe('window.pageXOffset', expectedScrollX.toString());
    54     shouldBe('document.body.scrollLeft', expectedScrollX.toString());
     54    shouldBe('document.documentElement.scrollLeft', expectedScrollX.toString());
    5555    shouldBe('window.scrollY', expectedScrollY.toString());
    5656    shouldBe('window.pageYOffset', expectedScrollY.toString());
    57     shouldBe('document.body.scrollTop', expectedScrollY.toString());
     57    shouldBe('document.documentElement.scrollTop', expectedScrollY.toString());
    5858}
    5959
  • trunk/LayoutTests/tiled-drawing/scrolling/fast-scroll-div-latched-mainframe.html

    r188793 r235806  
    4444function onPageScroll()
    4545{
    46     if (document.body.scrollTop >= 70)
     46    if (document.scrollingElement.scrollTop >= 70)
    4747        checkForScroll();
    4848}
     
    5151{
    5252    // The div should not have scrolled at all.
    53     var pageScrollPositionAfter = document.body.scrollTop;
     53    var pageScrollPositionAfter = document.scrollingElement.scrollTop;
    5454    var divScrollPositionAfter = divTarget.scrollTop;
    5555
     
    6969function scrollTest()
    7070{
    71     pageScrollPositionBefore = document.body.scrollTop;
     71    pageScrollPositionBefore = document.scrollingElement.scrollTop;
    7272
    7373    divTarget = document.getElementById('target');
  • trunk/Source/WebCore/ChangeLog

    r235804 r235806  
     12018-09-07  Frederic Wang  <fwang@igalia.com>
     2
     3        [CSSOM View] Handle the scrollingElement in Element::scroll(Left/Top/Width/Height/To)
     4        https://bugs.webkit.org/show_bug.cgi?id=182230
     5
     6        Reviewed by Simon Fraser.
     7
     8        This commit moves the special logic for "scrolling element" body from the
     9        HtmlBodyElement::scroll(Left/Top/Width/Height/To) functions to the Element class. The code
     10        is executed when the element is the scrolling element which includes the case of body
     11        in Quirks mode and of documentElement in standard mode. This makes the behavior closer to
     12        the CSSOM View spec (bug 5991) while not deviating too much from the current implementation.
     13        Finally, CSSOMViewScrollingAPI is now enabled for running tests and some adjustments are made
     14        to existing tests. Further improvements will be performed in dependencies of bug 5991.
     15
     16        No new tests, already covered by existing tests.
     17
     18        * dom/Document.cpp: Split scrollingElement into two functions so that one can be called
     19        internally without updating the layout.
     20        (WebCore::Document::scrollingElement):
     21        (WebCore::Document::scrollingElementForAPI):
     22        * dom/Document.h: Ditto.
     23        * dom/Document.idl: Use the version updating the layout for API calls.
     24        * dom/Element.cpp: Add include to call DOMWindow::ScrollTo
     25        (WebCore::Element::scrollTo): Moved some logic from HtmlBodyElement to handle the case of
     26        the scrolling element. Also skip special handling of documentElement() when
     27        CSSOMViewScrollingAPI is disabled.
     28        (WebCore::adjustContentsScrollPositionOrSizeForZoom): Moved some logic from HtmlBodyElement
     29        to handle the case of the scrolling element. Also add a FIXME for improving these kinds of
     30        helper functions. Renamed to make more explicit the semantic of the value argument.
     31        (WebCore::Element::scrollLeft): Moved some logic from HtmlBodyElement to handle the case of
     32        the scrolling element. Use the new documentFrameWithNonNullView() helper function.
     33        (WebCore::Element::scrollTop): Ditto.
     34        (WebCore::Element::setScrollLeft): Ditto
     35        (WebCore::Element::setScrollTop): Ditto.
     36        (WebCore::Element::scrollWidth): Ditto.
     37        (WebCore::Element::scrollHeight): Ditto.
     38        * dom/Element.h:
     39        (WebCore::Document::documentFrameWithNonNullView): New helper function to retrieve the
     40        frame and ensure a view is available.
     41        * html/HTMLBodyElement.cpp: Remove code that is now in Element.
     42        * html/HTMLBodyElement.h: Ditto.
     43
    1442018-09-07  Don Olmstead  <don.olmstead@sony.com>
    245
  • trunk/Source/WebCore/dom/Document.cpp

    r235736 r235806  
    14621462}
    14631463
     1464Element* Document::scrollingElementForAPI()
     1465{
     1466    if (inQuirksMode() && settings().CSSOMViewScrollingAPIEnabled())
     1467        updateLayoutIgnorePendingStylesheets();
     1468    return scrollingElement();
     1469}
     1470
    14641471Element* Document::scrollingElement()
    14651472{
     
    14691476        // 1. If the Document is in quirks mode, follow these substeps:
    14701477        if (inQuirksMode()) {
    1471             updateLayoutIgnorePendingStylesheets();
    14721478            auto* firstBody = body();
    14731479            // 1. If the HTML body element exists, and it is not potentially scrollable, return the
  • trunk/Source/WebCore/dom/Document.h

    r235736 r235806  
    449449    RefPtr<Range> caretRangeFromPoint(const LayoutPoint& clientPoint);
    450450
    451     WEBCORE_EXPORT Element* scrollingElement();
     451    WEBCORE_EXPORT Element* scrollingElementForAPI();
     452    Element* scrollingElement();
    452453
    453454    enum ReadyState {
  • trunk/Source/WebCore/dom/Document.idl

    r235271 r235806  
    133133
    134134    // Extensions from the CSSOM-View specification (https://drafts.csswg.org/cssom-view/#extensions-to-the-document-interface).
    135     readonly attribute Element? scrollingElement;
     135    [ImplementedAs=scrollingElementForAPI] readonly attribute Element? scrollingElement;
    136136
    137137    // Extensions from Selection API (https://www.w3.org/TR/selection-api/#extensions-to-document-interface).
  • trunk/Source/WebCore/dom/Element.cpp

    r235749 r235806  
    4242#include "DOMRectList.h"
    4343#include "DOMTokenList.h"
     44#include "DOMWindow.h"
    4445#include "DocumentSharedObjectPool.h"
    4546#include "DocumentTimeline.h"
     
    757758void Element::scrollTo(const ScrollToOptions& options, ScrollClamping clamping)
    758759{
    759     // If the element is the root element and document is in quirks mode, terminate these steps.
    760     // Note that WebKit always uses quirks mode document scrolling behavior. See Document::scrollingElement().
    761     if (this == document().documentElement())
    762         return;
     760    if (!document().settings().CSSOMViewScrollingAPIEnabled()) {
     761        // If the element is the root element and document is in quirks mode, terminate these steps.
     762        // Note that WebKit always uses quirks mode document scrolling behavior. See Document::scrollingElement().
     763        if (this == document().documentElement())
     764            return;
     765    }
    763766
    764767    document().updateLayoutIgnorePendingStylesheets();
     768
     769    if (document().scrollingElement() == this) {
     770        // If the element is the scrolling element and is not potentially scrollable,
     771        // invoke scroll() on window with options as the only argument, and terminate these steps.
     772        // FIXME: Scrolling an independently scrollable body is broken: webkit.org/b/161612.
     773        auto window = makeRefPtr(document().domWindow());
     774        if (!window)
     775            return;
     776
     777        window->scrollTo(options);
     778        return;
     779    }
    765780
    766781    // If the element does not have any associated CSS layout box, the element has no associated scrolling box,
     
    844859}
    845860
     861static int adjustContentsScrollPositionOrSizeForZoom(int value, const Frame& frame)
     862{
     863    double zoomFactor = frame.pageZoomFactor() * frame.frameScaleFactor();
     864    if (zoomFactor == 1)
     865        return value;
     866    // FIXME (webkit.org/b/189397): Why can't we just ceil/floor?
     867    // Needed because of truncation (rather than rounding) when scaling up.
     868    if (zoomFactor > 1)
     869        value++;
     870    return static_cast<int>(value / zoomFactor);
     871}
     872
    846873enum LegacyCSSOMElementMetricsRoundingStrategy { Round, Floor };
    847874
     
    9851012}
    9861013
     1014ALWAYS_INLINE Frame* Element::documentFrameWithNonNullView() const
     1015{
     1016    auto* frame = document().frame();
     1017    return frame && frame->view() ? frame : nullptr;
     1018}
     1019
    9871020int Element::scrollLeft()
    9881021{
    9891022    document().updateLayoutIgnorePendingStylesheets();
     1023
     1024    if (document().scrollingElement() == this) {
     1025        if (auto* frame = documentFrameWithNonNullView())
     1026            return adjustContentsScrollPositionOrSizeForZoom(frame->view()->contentsScrollPosition().x(), *frame);
     1027        return 0;
     1028    }
    9901029
    9911030    if (auto* renderer = renderBox())
     
    9981037    document().updateLayoutIgnorePendingStylesheets();
    9991038
     1039    if (document().scrollingElement() == this) {
     1040        if (auto* frame = documentFrameWithNonNullView())
     1041            return adjustContentsScrollPositionOrSizeForZoom(frame->view()->contentsScrollPosition().y(), *frame);
     1042        return 0;
     1043    }
     1044
    10001045    if (RenderBox* renderer = renderBox())
    10011046        return adjustForAbsoluteZoom(renderer->scrollTop(), *renderer);
     
    10061051{
    10071052    document().updateLayoutIgnorePendingStylesheets();
     1053
     1054    if (document().scrollingElement() == this) {
     1055        if (auto* frame = documentFrameWithNonNullView())
     1056            frame->view()->setScrollPosition(IntPoint(static_cast<int>(newLeft * frame->pageZoomFactor() * frame->frameScaleFactor()), frame->view()->scrollY()));
     1057        return;
     1058    }
    10081059
    10091060    if (auto* renderer = renderBox()) {
     
    10181069    document().updateLayoutIgnorePendingStylesheets();
    10191070
     1071    if (document().scrollingElement() == this) {
     1072        if (auto* frame = documentFrameWithNonNullView())
     1073            frame->view()->setScrollPosition(IntPoint(frame->view()->scrollX(), static_cast<int>(newTop * frame->pageZoomFactor() * frame->frameScaleFactor())));
     1074        return;
     1075    }
     1076
    10201077    if (auto* renderer = renderBox()) {
    10211078        renderer->setScrollTop(static_cast<int>(newTop * renderer->style().effectiveZoom()));
     
    10281085{
    10291086    document().updateLayoutIfDimensionsOutOfDate(*this, WidthDimensionsCheck);
     1087
     1088    if (document().scrollingElement() == this) {
     1089        // FIXME (webkit.org/b/182289): updateLayoutIfDimensionsOutOfDate seems to ignore zoom level change.
     1090        document().updateLayoutIgnorePendingStylesheets();
     1091        if (auto* frame = documentFrameWithNonNullView())
     1092            return adjustContentsScrollPositionOrSizeForZoom(frame->view()->contentsWidth(), *frame);
     1093        return 0;
     1094    }
     1095
    10301096    if (auto* renderer = renderBox())
    10311097        return adjustForAbsoluteZoom(renderer->scrollWidth(), *renderer);
     
    10361102{
    10371103    document().updateLayoutIfDimensionsOutOfDate(*this, HeightDimensionsCheck);
     1104
     1105    if (document().scrollingElement() == this) {
     1106        // FIXME (webkit.org/b/182289): updateLayoutIfDimensionsOutOfDate seems to ignore zoom level change.
     1107        document().updateLayoutIgnorePendingStylesheets();
     1108        if (auto* frame = documentFrameWithNonNullView())
     1109            return adjustContentsScrollPositionOrSizeForZoom(frame->view()->contentsHeight(), *frame);
     1110        return 0;
     1111    }
     1112
    10381113    if (auto* renderer = renderBox())
    10391114        return adjustForAbsoluteZoom(renderer->scrollHeight(), *renderer);
  • trunk/Source/WebCore/dom/Element.h

    r235659 r235806  
    4444class DOMTokenList;
    4545class ElementRareData;
     46class Frame;
    4647class HTMLDocument;
    4748class IntSize;
     
    606607
    607608private:
     609    Frame* documentFrameWithNonNullView() const;
     610
    608611    bool isTextNode() const;
    609612
  • trunk/Source/WebCore/html/HTMLBodyElement.cpp

    r229694 r235806  
    3131#include "DOMWrapperWorld.h"
    3232#include "EventNames.h"
    33 #include "Frame.h"
    34 #include "FrameView.h"
    3533#include "HTMLFrameElement.h"
    3634#include "HTMLIFrameElement.h"
     
    5149{
    5250    ASSERT(hasTagName(bodyTag));
    53 }
    54 
    55 bool HTMLBodyElement::isFirstBodyElementOfDocument() const
    56 {
    57     // By spec http://dev.w3.org/csswg/cssom-view/#the-html-body-element
    58     // "The HTML body element is the first body HTML element child of the root HTML element html."
    59     return document().body() == this;
    6051}
    6152
     
    232223}
    233224
    234 static int adjustForZoom(int value, const Frame& frame)
    235 {
    236     double zoomFactor = frame.pageZoomFactor() * frame.frameScaleFactor();
    237     if (zoomFactor == 1)
    238         return value;
    239     // Needed because of truncation (rather than rounding) when scaling up.
    240     if (zoomFactor > 1)
    241         value++;
    242     return static_cast<int>(value / zoomFactor);
    243 }
    244 
    245 int HTMLBodyElement::scrollLeft()
    246 {
    247     if (isFirstBodyElementOfDocument()) {
    248         document().updateLayoutIgnorePendingStylesheets();
    249         RefPtr<Frame> frame = document().frame();
    250         if (!frame)
    251             return 0;
    252         RefPtr<FrameView> view = frame->view();
    253         if (!view)
    254             return 0;
    255         return adjustForZoom(view->contentsScrollPosition().x(), *frame);
    256     }
    257     return HTMLElement::scrollLeft();
    258 }
    259 
    260 void HTMLBodyElement::setScrollLeft(int scrollLeft)
    261 {
    262     if (isFirstBodyElementOfDocument()) {
    263         document().updateLayoutIgnorePendingStylesheets();
    264         RefPtr<Frame> frame = document().frame();
    265         if (!frame)
    266             return;
    267         RefPtr<FrameView> view = frame->view();
    268         if (!view)
    269             return;
    270         view->setScrollPosition(IntPoint(static_cast<int>(scrollLeft * frame->pageZoomFactor() * frame->frameScaleFactor()), view->scrollY()));
    271     }
    272     HTMLElement::setScrollLeft(scrollLeft);
    273 }
    274 
    275 int HTMLBodyElement::scrollTop()
    276 {
    277     if (isFirstBodyElementOfDocument()) {
    278         document().updateLayoutIgnorePendingStylesheets();
    279         RefPtr<Frame> frame = document().frame();
    280         if (!frame)
    281             return 0;
    282         RefPtr<FrameView> view = frame->view();
    283         if (!view)
    284             return 0;
    285         return adjustForZoom(view->contentsScrollPosition().y(), *frame);
    286     }
    287     return HTMLElement::scrollTop();
    288 }
    289 
    290 void HTMLBodyElement::setScrollTop(int scrollTop)
    291 {
    292     if (isFirstBodyElementOfDocument()) {
    293         document().updateLayoutIgnorePendingStylesheets();
    294         RefPtr<Frame> frame = document().frame();
    295         if (!frame)
    296             return;
    297         RefPtr<FrameView> view = frame->view();
    298         if (!view)
    299             return;
    300         view->setScrollPosition(IntPoint(view->scrollX(), static_cast<int>(scrollTop * frame->pageZoomFactor() * frame->frameScaleFactor())));
    301     }
    302     return HTMLElement::setScrollTop(scrollTop);
    303 }
    304 
    305 void HTMLBodyElement::scrollTo(const ScrollToOptions& options, ScrollClamping clamping)
    306 {
    307     if (isFirstBodyElementOfDocument()) {
    308         // If the element is the HTML body element, document is in quirks mode, and the element is not potentially scrollable,
    309         // invoke scroll() on window with options as the only argument, and terminate these steps.
    310         // Note that WebKit always uses quirks mode document scrolling behavior. See Document::scrollingElement().
    311         // FIXME: Scrolling an independently scrollable body is broken: webkit.org/b/161612.
    312         auto window = makeRefPtr(document().domWindow());
    313         if (!window)
    314             return;
    315 
    316         window->scrollTo(options);
    317         return;
    318     }
    319     return HTMLElement::scrollTo(options, clamping);
    320 }
    321 
    322 int HTMLBodyElement::scrollHeight()
    323 {
    324     if (isFirstBodyElementOfDocument()) {
    325         // Update the document's layout.
    326         document().updateLayoutIgnorePendingStylesheets();
    327         RefPtr<Frame> frame = document().frame();
    328         if (!frame)
    329             return 0;
    330         RefPtr<FrameView> view = frame->view();
    331         if (!view)
    332             return 0;
    333         return adjustForZoom(view->contentsHeight(), *frame);
    334     }
    335     return HTMLElement::scrollHeight();
    336 }
    337 
    338 int HTMLBodyElement::scrollWidth()
    339 {
    340     if (isFirstBodyElementOfDocument()) {
    341         // Update the document's layout.
    342         document().updateLayoutIgnorePendingStylesheets();
    343         RefPtr<Frame> frame = document().frame();
    344         if (!frame)
    345             return 0;
    346         RefPtr<FrameView> view = frame->view();
    347         if (!view)
    348             return 0;
    349         return adjustForZoom(view->contentsWidth(), *frame);
    350     }
    351     return HTMLElement::scrollWidth();
    352 }
    353 
    354225void HTMLBodyElement::addSubresourceAttributeURLs(ListHashSet<URL>& urls) const
    355226{
  • trunk/Source/WebCore/html/HTMLBodyElement.h

    r229694 r235806  
    4040    HTMLBodyElement(const QualifiedName&, Document&);
    4141
    42     bool isFirstBodyElementOfDocument() const;
    43 
    4442    void parseAttribute(const QualifiedName&, const AtomicString&) final;
    4543    bool isPresentationAttribute(const QualifiedName&) const final;
     
    5351    bool supportsFocus() const final;
    5452
    55     int scrollLeft() final;
    56     void setScrollLeft(int) final;
    57    
    58     int scrollTop() final;
    59     void setScrollTop(int) final;
    60 
    61     void scrollTo(const ScrollToOptions&, ScrollClamping) final;
    62    
    63     int scrollHeight() final;
    64     int scrollWidth() final;
    65    
    6653    void addSubresourceAttributeURLs(ListHashSet<URL>&) const final;
    6754
  • trunk/Source/WebKit/ChangeLog

    r235791 r235806  
     12018-09-07  Frederic Wang  <fwang@igalia.com>
     2
     3        [CSSOM View] Handle the scrollingElement in Element::scroll(Left/Top/Width/Height/To)
     4        https://bugs.webkit.org/show_bug.cgi?id=182230
     5
     6        Reviewed by Simon Fraser.
     7
     8        * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocumentGtk.cpp:
     9        (webkit_dom_document_get_scrolling_element): Use the new name.
     10
    1112018-09-07  Brent Fulgham  <bfulgham@apple.com>
    212
  • trunk/Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocumentGtk.cpp

    r234586 r235806  
    19301930    g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
    19311931    WebCore::Document* item = WebKit::core(self);
    1932     RefPtr<WebCore::Element> gobjectResult = WTF::getPtr(item->scrollingElement());
     1932    RefPtr<WebCore::Element> gobjectResult = WTF::getPtr(item->scrollingElementForAPI());
    19331933    return WebKit::kit(gobjectResult.get());
    19341934}
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r235775 r235806  
     12018-09-07  Frederic Wang  <fwang@igalia.com>
     2
     3        [CSSOM View] Handle the scrollingElement in Element::scroll(Left/Top/Width/Height/To)
     4        https://bugs.webkit.org/show_bug.cgi?id=182230
     5
     6        Reviewed by Simon Fraser.
     7
     8        * DOM/DOMDocument.mm:
     9        (-[DOMDocument scrollingElement]): Use the new name.
     10
    1112018-09-06  Wenson Hsieh  <wenson_hsieh@apple.com>
    212
  • trunk/Source/WebKitLegacy/mac/DOM/DOMDocument.mm

    r234586 r235806  
    419419{
    420420    WebCore::JSMainThreadNullState state;
    421     return kit(WTF::getPtr(IMPL->scrollingElement()));
     421    return kit(WTF::getPtr(IMPL->scrollingElementForAPI()));
    422422}
    423423
  • trunk/Tools/ChangeLog

    r235805 r235806  
     12018-09-07  Frederic Wang  <fwang@igalia.com>
     2
     3        [CSSOM View] Handle the scrollingElement in Element::scroll(Left/Top/Width/Height/To)
     4        https://bugs.webkit.org/show_bug.cgi?id=182230
     5
     6        Reviewed by Simon Fraser.
     7
     8        This patch enables CSSOMViewScrollingAPI during test execution.
     9
     10        * DumpRenderTree/mac/DumpRenderTree.mm:
     11        (enableExperimentalFeatures):
     12        (resetWebPreferencesToConsistentValues):
     13        * DumpRenderTree/win/DumpRenderTree.cpp:
     14        (enableExperimentalFeatures):
     15        * WebKitTestRunner/TestController.cpp:
     16        (WTR::TestController::resetPreferencesToConsistentValues):
     17
    1182018-09-07  Simon Fraser  <simon.fraser@apple.com>
    219
  • trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm

    r235539 r235806  
    870870    [preferences setIntersectionObserverEnabled:YES];
    871871    preferences.sourceBufferChangeTypeEnabled = YES;
    872     // FIXME: CSSOMViewScrollingAPIEnabled
     872    [preferences setCSSOMViewScrollingAPIEnabled:YES];
    873873}
    874874
     
    923923    [preferences setFrameFlattening:WebKitFrameFlatteningDisabled];
    924924    [preferences setAsyncFrameScrollingEnabled:NO];
    925     [preferences setCSSOMViewScrollingAPIEnabled:NO];
    926925    [preferences setSpatialNavigationEnabled:NO];
    927926    [preferences setMetaRefreshEnabled:YES];
  • trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp

    r235539 r235806  
    786786    // FIXME: SubtleCrypto
    787787    prefsPrivate->setVisualViewportAPIEnabled(TRUE);
    788     // FIXME: CSSOMViewScrollingAPI
     788    prefsPrivate->setCSSOMViewScrollingAPIEnabled(TRUE);
    789789    prefsPrivate->setWebAnimationsEnabled(TRUE);
    790790    prefsPrivate->setServerTimingEnabled(TRUE);
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r235690 r235806  
    792792    WKPreferencesSetAccessibilityObjectModelEnabled(preferences, true);
    793793    WKPreferencesSetAriaReflectionEnabled(preferences, true);
    794     WKPreferencesSetCSSOMViewScrollingAPIEnabled(preferences, false);
     794    WKPreferencesSetCSSOMViewScrollingAPIEnabled(preferences, true);
    795795    WKPreferencesSetMediaCapabilitiesEnabled(preferences, true);
    796796
Note: See TracChangeset for help on using the changeset viewer.