[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.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235806
268f45cc-cd09-0410-ab3c-
d52691b4dbfc