Changeset 235806 in webkit
- Timestamp:
- Sep 7, 2018 2:12:41 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 1 deleted
- 41 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r235783 r235806 1 2018-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 1 37 2018-09-07 Zalan Bujtas <zalan@apple.com> 2 38 -
trunk/LayoutTests/TestExpectations
r235772 r235806 1892 1892 # Test only works on iOS WK2. webkit.org/b/165535 1893 1893 fast/forms/range/range-remove-on-drag.html [ Skip ] 1894 1895 # CSSOM View module1896 webkit.org/b/5991 imported/w3c/web-platform-tests/css/cssom-view/scrollingElement.html [ Skip ]1897 1894 1898 1895 # FileAPI -
trunk/LayoutTests/fast/dom/Document/scrollingElement-quirks-mode.html
r235539 r235806 6 6 <body> 7 7 <script> 8 if (window.internals)9 internals.settings.setCSSOMViewScrollingAPIEnabled(true);10 8 11 9 description("Tests the behavior of document.scrollingElement in quirks mode."); -
trunk/LayoutTests/fast/dom/Document/scrollingElement-standards-mode.html
r235539 r235806 7 7 <body> 8 8 <script> 9 if (window.internals)10 internals.settings.setCSSOMViewScrollingAPIEnabled(true);11 9 12 10 description("Tests the behavior of document.scrollingElement in standards mode."); -
trunk/LayoutTests/fast/dom/Element/body-scrollLeft-expected.txt
r167539 r235806 7 7 8 8 TEST COMPLETE 9 PASS document.body.scrollLeft is 5009 PASS document.body.scrollLeft is 0 10 10 PASS successfullyParsed is true 11 11 -
trunk/LayoutTests/fast/dom/Element/body-scrollLeft.html
r167539 r235806 13 13 description('Tests that for non-standard mode document.body.scrollLeft returns the scroll left value as 0'); 14 14 15 document.body.scrollLeft = 500;16 shouldBe("document.body.scrollLeft"," 500");15 document.body.scrollLeft = 0; 16 shouldBe("document.body.scrollLeft","0"); 17 17 isSuccessfullyParsed(); 18 18 } -
trunk/LayoutTests/fast/dom/Element/body-scrollTop-expected.txt
r167539 r235806 7 7 8 8 TEST COMPLETE 9 PASS document.body.scrollTop is 5009 PASS document.body.scrollTop is 0 10 10 PASS successfullyParsed is true 11 11 -
trunk/LayoutTests/fast/dom/Element/body-scrollTop.html
r167539 r235806 14 14 15 15 document.body.scrollTop = 500; 16 shouldBe("document.body.scrollTop"," 500");16 shouldBe("document.body.scrollTop","0"); 17 17 isSuccessfullyParsed(); 18 18 } -
trunk/LayoutTests/fast/dom/Element/documentElement-scrollLeft-expected.txt
r167539 r235806 7 7 8 8 TEST COMPLETE 9 PASS document.documentElement.scrollLeft is 09 PASS document.documentElement.scrollLeft is 500 10 10 PASS successfullyParsed is true 11 11 -
trunk/LayoutTests/fast/dom/Element/documentElement-scrollLeft.html
r167539 r235806 14 14 15 15 document.documentElement.scrollLeft = 500; 16 shouldBe("document.documentElement.scrollLeft"," 0");16 shouldBe("document.documentElement.scrollLeft","500"); 17 17 isSuccessfullyParsed(); 18 18 } -
trunk/LayoutTests/fast/dom/Element/documentElement-scrollTop-expected.txt
r167539 r235806 4 4 5 5 6 PASS document.documentElement.scrollTop is 06 PASS document.documentElement.scrollTop is 500 7 7 PASS successfullyParsed is true 8 8 -
trunk/LayoutTests/fast/dom/Element/documentElement-scrollTop.html
r167539 r235806 14 14 15 15 document.documentElement.scrollTop = 500; 16 shouldBe("document.documentElement.scrollTop"," 0");16 shouldBe("document.documentElement.scrollTop","500"); 17 17 isSuccessfullyParsed(); 18 18 } -
trunk/LayoutTests/fast/dom/Element/scrollLeft-expected.txt
r167539 r235806 5 5 6 6 PASS window.pageXOffset is 500 7 PASS document.body.scrollLeft is 5008 PASS document.documentElement.scrollLeft is 07 PASS document.body.scrollLeft is 0 8 PASS document.documentElement.scrollLeft is 500 9 9 PASS successfullyParsed is true 10 10 -
trunk/LayoutTests/fast/dom/Element/scrollLeft.html
r167539 r235806 16 16 window.scrollTo(500,0); 17 17 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"); 20 20 finishJSTest(); 21 21 }, 0); -
trunk/LayoutTests/fast/dom/Element/scrollTop-expected.txt
r167539 r235806 5 5 6 6 PASS window.pageYOffset is 500 7 PASS document.body.scrollTop is 5008 PASS document.documentElement.scrollTop is 07 PASS document.body.scrollTop is 0 8 PASS document.documentElement.scrollTop is 500 9 9 PASS successfullyParsed is true 10 10 -
trunk/LayoutTests/fast/dom/Element/scrollTop.html
r167539 r235806 16 16 window.scrollTo(0,500); 17 17 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"); 20 20 finishJSTest(); 21 21 }, 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.1 Tests scrollTo/By(x,y) and scrollTo/By(scrollOptions) on the body in standard mode. 2 2 3 3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". 4 4 5 5 6 PASS scroller.scrollLeft is 207 PASS scroller.scrollTop is 5008 PASS window.scrollX is 209 PASS window.scrollY is 50010 PASS scroller.scrollLeft is 7011 PASS scroller.scrollTop is 56012 PASS window.scrollX is 7013 PASS window.scrollY is 56014 PASS scroller.scrollLeft is 10015 PASS scroller.scrollTop is 40016 PASS window.scrollX is 10017 PASS window.scrollY is 4006 PASS scroller.scrollLeft is 0 7 PASS scroller.scrollTop is 0 8 PASS window.scrollX is 0 9 PASS window.scrollY is 0 10 PASS scroller.scrollLeft is 0 11 PASS scroller.scrollTop is 0 12 PASS window.scrollX is 0 13 PASS window.scrollY is 0 14 PASS scroller.scrollLeft is 0 15 PASS scroller.scrollTop is 0 16 PASS window.scrollX is 0 17 PASS window.scrollY is 0 18 18 PASS successfullyParsed is true 19 19 -
trunk/LayoutTests/fast/dom/Element/scrolling-funtions-on-body.html
r205505 r235806 12 12 var scroller; 13 13 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.'); 15 15 16 16 scroller = document.body; 17 17 setTimeout(function() { 18 18 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"); 23 23 24 24 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"); 29 29 30 30 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"); 35 35 36 36 scroller.scrollTo(0, 0); -
trunk/LayoutTests/imported/w3c/ChangeLog
r235714 r235806 1 2018-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 1 15 2018-09-05 Youenn Fablet <youenn@apple.com> 2 16 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/HTMLBody-ScrollArea_quirksmode-expected.txt
r232903 r235806 4 4 PASS document.compatMode should be BackCompat in quirks. 5 5 PASS 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 ... 6 PASS scrollingElement in quirks should be null when body is potentially scrollable. 8 7 PASS 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 8 PASS When body potentially scrollable, document.body.scrollHeight changes when changing the height of the body content in quirks. 10 9 PASS When body not potentially scrollable, document.body.scrollHeight always equals window.innerHeight in quirks. (cond. visible, scroll) 11 10 PASS 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 17 17 PASS scrollWidth/scrollHeight of the content in quirks mode 18 18 PASS 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 19 PASS scrollingElement in non-quirks mode 20 PASS scroll() on the root element in non-quirks mode 21 PASS scrollBy() on the root element in non-quirks mode 22 PASS scrollLeft/scrollTop on the root element in non-quirks mode 23 23 PASS scrollWidth/scrollHeight on the root element in non-quirks mode 24 24 PASS 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 25 PASS scroll() on the HTML body element in non-quirks mode 26 PASS scrollBy() on the HTML body element in non-quirks mode 27 PASS scrollLeft/scrollTop on the HTML body element in non-quirks mode 28 PASS scrollWidth/scrollHeight on the HTML body element in non-quirks mode 29 29 PASS clientWidth/clientHeight on the HTML body element in non-quirks mode 30 30 PASS scrollLeft/scrollRight of the content in non-quirks mode -
trunk/LayoutTests/platform/ios/TestExpectations
r235783 r235806 2649 2649 webkit.org/b/163755 imported/w3c/web-platform-tests/css/css-shapes [ Skip ] 2650 2650 2651 webkit.org/b/5991 imported/w3c/web-platform-tests/css/cssom-view/scrolling-quirks-vs-nonquirks.html [ Failure ] 2652 2651 2653 # Variation fonts are not implemented earlier than iOS 11. 2652 2654 fast/text/variations [ Pass Failure ImageOnlyFailure ] -
trunk/LayoutTests/platform/ios/ios/fast/coordinates/page-offsets-expected.txt
r178197 r235806 4 4 PASS window.scrollX is 0 5 5 PASS window.pageXOffset is 0 6 PASS document. body.scrollLeft is 06 PASS document.documentElement.scrollLeft is 0 7 7 PASS window.scrollY is 0 8 8 PASS window.pageYOffset is 0 9 PASS document. body.scrollTop is 09 PASS document.documentElement.scrollTop is 0 10 10 11 11 scaled and panned 12 12 PASS window.scrollX is 10 13 13 PASS window.pageXOffset is 10 14 PASS document. body.scrollLeft is 1014 PASS document.documentElement.scrollLeft is 10 15 15 PASS window.scrollY is 10 16 16 PASS window.pageYOffset is 10 17 PASS document. body.scrollTop is 1017 PASS document.documentElement.scrollTop is 10 18 18 PASS successfullyParsed is true 19 19 -
trunk/LayoutTests/platform/ios/ios/fast/coordinates/resources/helpers.js
r178197 r235806 52 52 shouldBe('window.scrollX', expectedScrollX.toString()); 53 53 shouldBe('window.pageXOffset', expectedScrollX.toString()); 54 shouldBe('document. body.scrollLeft', expectedScrollX.toString());54 shouldBe('document.documentElement.scrollLeft', expectedScrollX.toString()); 55 55 shouldBe('window.scrollY', expectedScrollY.toString()); 56 56 shouldBe('window.pageYOffset', expectedScrollY.toString()); 57 shouldBe('document. body.scrollTop', expectedScrollY.toString());57 shouldBe('document.documentElement.scrollTop', expectedScrollY.toString()); 58 58 } 59 59 -
trunk/LayoutTests/tiled-drawing/scrolling/fast-scroll-div-latched-mainframe.html
r188793 r235806 44 44 function onPageScroll() 45 45 { 46 if (document. body.scrollTop >= 70)46 if (document.scrollingElement.scrollTop >= 70) 47 47 checkForScroll(); 48 48 } … … 51 51 { 52 52 // The div should not have scrolled at all. 53 var pageScrollPositionAfter = document. body.scrollTop;53 var pageScrollPositionAfter = document.scrollingElement.scrollTop; 54 54 var divScrollPositionAfter = divTarget.scrollTop; 55 55 … … 69 69 function scrollTest() 70 70 { 71 pageScrollPositionBefore = document. body.scrollTop;71 pageScrollPositionBefore = document.scrollingElement.scrollTop; 72 72 73 73 divTarget = document.getElementById('target'); -
trunk/Source/WebCore/ChangeLog
r235804 r235806 1 2018-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 1 44 2018-09-07 Don Olmstead <don.olmstead@sony.com> 2 45 -
trunk/Source/WebCore/dom/Document.cpp
r235736 r235806 1462 1462 } 1463 1463 1464 Element* Document::scrollingElementForAPI() 1465 { 1466 if (inQuirksMode() && settings().CSSOMViewScrollingAPIEnabled()) 1467 updateLayoutIgnorePendingStylesheets(); 1468 return scrollingElement(); 1469 } 1470 1464 1471 Element* Document::scrollingElement() 1465 1472 { … … 1469 1476 // 1. If the Document is in quirks mode, follow these substeps: 1470 1477 if (inQuirksMode()) { 1471 updateLayoutIgnorePendingStylesheets();1472 1478 auto* firstBody = body(); 1473 1479 // 1. If the HTML body element exists, and it is not potentially scrollable, return the -
trunk/Source/WebCore/dom/Document.h
r235736 r235806 449 449 RefPtr<Range> caretRangeFromPoint(const LayoutPoint& clientPoint); 450 450 451 WEBCORE_EXPORT Element* scrollingElement(); 451 WEBCORE_EXPORT Element* scrollingElementForAPI(); 452 Element* scrollingElement(); 452 453 453 454 enum ReadyState { -
trunk/Source/WebCore/dom/Document.idl
r235271 r235806 133 133 134 134 // 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; 136 136 137 137 // Extensions from Selection API (https://www.w3.org/TR/selection-api/#extensions-to-document-interface). -
trunk/Source/WebCore/dom/Element.cpp
r235749 r235806 42 42 #include "DOMRectList.h" 43 43 #include "DOMTokenList.h" 44 #include "DOMWindow.h" 44 45 #include "DocumentSharedObjectPool.h" 45 46 #include "DocumentTimeline.h" … … 757 758 void Element::scrollTo(const ScrollToOptions& options, ScrollClamping clamping) 758 759 { 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 } 763 766 764 767 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 } 765 780 766 781 // If the element does not have any associated CSS layout box, the element has no associated scrolling box, … … 844 859 } 845 860 861 static 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 846 873 enum LegacyCSSOMElementMetricsRoundingStrategy { Round, Floor }; 847 874 … … 985 1012 } 986 1013 1014 ALWAYS_INLINE Frame* Element::documentFrameWithNonNullView() const 1015 { 1016 auto* frame = document().frame(); 1017 return frame && frame->view() ? frame : nullptr; 1018 } 1019 987 1020 int Element::scrollLeft() 988 1021 { 989 1022 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 } 990 1029 991 1030 if (auto* renderer = renderBox()) … … 998 1037 document().updateLayoutIgnorePendingStylesheets(); 999 1038 1039 if (document().scrollingElement() == this) { 1040 if (auto* frame = documentFrameWithNonNullView()) 1041 return adjustContentsScrollPositionOrSizeForZoom(frame->view()->contentsScrollPosition().y(), *frame); 1042 return 0; 1043 } 1044 1000 1045 if (RenderBox* renderer = renderBox()) 1001 1046 return adjustForAbsoluteZoom(renderer->scrollTop(), *renderer); … … 1006 1051 { 1007 1052 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 } 1008 1059 1009 1060 if (auto* renderer = renderBox()) { … … 1018 1069 document().updateLayoutIgnorePendingStylesheets(); 1019 1070 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 1020 1077 if (auto* renderer = renderBox()) { 1021 1078 renderer->setScrollTop(static_cast<int>(newTop * renderer->style().effectiveZoom())); … … 1028 1085 { 1029 1086 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 1030 1096 if (auto* renderer = renderBox()) 1031 1097 return adjustForAbsoluteZoom(renderer->scrollWidth(), *renderer); … … 1036 1102 { 1037 1103 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 1038 1113 if (auto* renderer = renderBox()) 1039 1114 return adjustForAbsoluteZoom(renderer->scrollHeight(), *renderer); -
trunk/Source/WebCore/dom/Element.h
r235659 r235806 44 44 class DOMTokenList; 45 45 class ElementRareData; 46 class Frame; 46 47 class HTMLDocument; 47 48 class IntSize; … … 606 607 607 608 private: 609 Frame* documentFrameWithNonNullView() const; 610 608 611 bool isTextNode() const; 609 612 -
trunk/Source/WebCore/html/HTMLBodyElement.cpp
r229694 r235806 31 31 #include "DOMWrapperWorld.h" 32 32 #include "EventNames.h" 33 #include "Frame.h"34 #include "FrameView.h"35 33 #include "HTMLFrameElement.h" 36 34 #include "HTMLIFrameElement.h" … … 51 49 { 52 50 ASSERT(hasTagName(bodyTag)); 53 }54 55 bool HTMLBodyElement::isFirstBodyElementOfDocument() const56 {57 // By spec http://dev.w3.org/csswg/cssom-view/#the-html-body-element58 // "The HTML body element is the first body HTML element child of the root HTML element html."59 return document().body() == this;60 51 } 61 52 … … 232 223 } 233 224 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 354 225 void HTMLBodyElement::addSubresourceAttributeURLs(ListHashSet<URL>& urls) const 355 226 { -
trunk/Source/WebCore/html/HTMLBodyElement.h
r229694 r235806 40 40 HTMLBodyElement(const QualifiedName&, Document&); 41 41 42 bool isFirstBodyElementOfDocument() const;43 44 42 void parseAttribute(const QualifiedName&, const AtomicString&) final; 45 43 bool isPresentationAttribute(const QualifiedName&) const final; … … 53 51 bool supportsFocus() const final; 54 52 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 66 53 void addSubresourceAttributeURLs(ListHashSet<URL>&) const final; 67 54 -
trunk/Source/WebKit/ChangeLog
r235791 r235806 1 2018-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 1 11 2018-09-07 Brent Fulgham <bfulgham@apple.com> 2 12 -
trunk/Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocumentGtk.cpp
r234586 r235806 1930 1930 g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0); 1931 1931 WebCore::Document* item = WebKit::core(self); 1932 RefPtr<WebCore::Element> gobjectResult = WTF::getPtr(item->scrollingElement ());1932 RefPtr<WebCore::Element> gobjectResult = WTF::getPtr(item->scrollingElementForAPI()); 1933 1933 return WebKit::kit(gobjectResult.get()); 1934 1934 } -
trunk/Source/WebKitLegacy/mac/ChangeLog
r235775 r235806 1 2018-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 1 11 2018-09-06 Wenson Hsieh <wenson_hsieh@apple.com> 2 12 -
trunk/Source/WebKitLegacy/mac/DOM/DOMDocument.mm
r234586 r235806 419 419 { 420 420 WebCore::JSMainThreadNullState state; 421 return kit(WTF::getPtr(IMPL->scrollingElement ()));421 return kit(WTF::getPtr(IMPL->scrollingElementForAPI())); 422 422 } 423 423 -
trunk/Tools/ChangeLog
r235805 r235806 1 2018-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 1 18 2018-09-07 Simon Fraser <simon.fraser@apple.com> 2 19 -
trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm
r235539 r235806 870 870 [preferences setIntersectionObserverEnabled:YES]; 871 871 preferences.sourceBufferChangeTypeEnabled = YES; 872 // FIXME: CSSOMViewScrollingAPIEnabled872 [preferences setCSSOMViewScrollingAPIEnabled:YES]; 873 873 } 874 874 … … 923 923 [preferences setFrameFlattening:WebKitFrameFlatteningDisabled]; 924 924 [preferences setAsyncFrameScrollingEnabled:NO]; 925 [preferences setCSSOMViewScrollingAPIEnabled:NO];926 925 [preferences setSpatialNavigationEnabled:NO]; 927 926 [preferences setMetaRefreshEnabled:YES]; -
trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp
r235539 r235806 786 786 // FIXME: SubtleCrypto 787 787 prefsPrivate->setVisualViewportAPIEnabled(TRUE); 788 // FIXME: CSSOMViewScrollingAPI788 prefsPrivate->setCSSOMViewScrollingAPIEnabled(TRUE); 789 789 prefsPrivate->setWebAnimationsEnabled(TRUE); 790 790 prefsPrivate->setServerTimingEnabled(TRUE); -
trunk/Tools/WebKitTestRunner/TestController.cpp
r235690 r235806 792 792 WKPreferencesSetAccessibilityObjectModelEnabled(preferences, true); 793 793 WKPreferencesSetAriaReflectionEnabled(preferences, true); 794 WKPreferencesSetCSSOMViewScrollingAPIEnabled(preferences, false);794 WKPreferencesSetCSSOMViewScrollingAPIEnabled(preferences, true); 795 795 WKPreferencesSetMediaCapabilitiesEnabled(preferences, true); 796 796
Note: See TracChangeset
for help on using the changeset viewer.