Changeset 211379 in webkit
- Timestamp:
- Jan 30, 2017 11:46:40 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r211375 r211379 1 2017-01-30 Simon Fraser <simon.fraser@apple.com> 2 3 Fixed elements should not rubber-band in WK2, nor remain at negative offsets 4 https://bugs.webkit.org/show_bug.cgi?id=167484 5 rdar://problem/29453068 6 7 Reviewed by Dean Jackson. 8 9 Add two tests that use internals.settings.setAllowUnclampedScrollPosition(true) and then 10 over-scroll to simulator rubber-banding, dumping viewport rects. 11 12 setAllowUnclampedScrollPosition() only works in WebKit2, so skip the tests elsewhere. 13 14 * TestExpectations: 15 * fast/visual-viewport/rubberbanding-viewport-rects-expected.txt: Added. 16 * fast/visual-viewport/rubberbanding-viewport-rects-header-footer-expected.txt: Added. 17 * fast/visual-viewport/rubberbanding-viewport-rects-header-footer.html: Added. 18 * fast/visual-viewport/rubberbanding-viewport-rects.html: Added. 19 * platform/ios-simulator-wk2/TestExpectations: 20 * platform/ios-simulator-wk2/fast/visual-viewport/rubberbanding-viewport-rects-expected.txt: Added. 21 * platform/ios-simulator-wk2/fast/visual-viewport/rubberbanding-viewport-rects-header-footer-expected.txt: Added. 22 * platform/mac-wk2/TestExpectations: 23 1 24 2017-01-30 Ryan Haddad <ryanhaddad@apple.com> 2 25 -
trunk/LayoutTests/TestExpectations
r211349 r211379 89 89 # ApplePay is only available on iOS (greater than iOS 10) and macOS (greater than macOS 10.12) and only for WebKit2. 90 90 http/tests/ssl/applepay/ [ Skip ] 91 92 # Only WK2 allows unconstrained scrolling 93 fast/visual-viewport/rubberbanding-viewport-rects.html [ Skip ] 94 fast/visual-viewport/rubberbanding-viewport-rects-header-footer.html [ Skip ] 91 95 92 96 #////////////////////////////////////////////////////////////////////////////////////////// -
trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations
r210989 r211379 17 17 fast/media/mq-monochrome-live-update.html [ Pass ] 18 18 fast/media/mq-prefers-reduced-motion-live-update.html [ Pass ] 19 20 fast/visual-viewport/rubberbanding-viewport-rects.html [ Pass ] 21 fast/visual-viewport/rubberbanding-viewport-rects-header-footer.html [ Pass ] 19 22 20 23 #////////////////////////////////////////////////////////////////////////////////////////// -
trunk/LayoutTests/platform/mac-wk2/TestExpectations
r211234 r211379 23 23 24 24 [ Sierra+ ] http/tests/ssl/applepay/ [ Pass ] 25 26 fast/visual-viewport/rubberbanding-viewport-rects.html [ Pass ] 27 fast/visual-viewport/rubberbanding-viewport-rects-header-footer.html [ Pass ] 25 28 26 29 #////////////////////////////////////////////////////////////////////////////////////////// -
trunk/Source/WebCore/ChangeLog
r211377 r211379 1 2017-01-30 Simon Fraser <simon.fraser@apple.com> 2 3 Fixed elements should not rubber-band in WK2, nor remain at negative offsets 4 https://bugs.webkit.org/show_bug.cgi?id=167484 5 rdar://problem/29453068 6 7 Reviewed by Dean Jackson. 8 9 There were various problems with the layout rect computation: 10 1. It ignored the scrollBehaviorForFixedElements() which we use to avoid rubber-banding fixed 11 elements in WK2, but allow in WK1, so make use of that. 12 2. Sometimes layouts/paints of fixed elements would be triggered when coalesced calls to 13 AsyncScrollingCoordinator::scheduleUpdateScrollPositionAfterAsyncScroll() failed to 14 copy the layoutViewportOrigin to the scheduled update. 15 3. The layout viewport could be left with a negative top/left after rubber-banding. 16 17 Also add a way to do unconstrained scrollTo(), so that a test can call window.scrollTo(-10, -10) to 18 simulate rubberbanding. 19 20 Tests: fast/visual-viewport/rubberbanding-viewport-rects-header-footer.html 21 fast/visual-viewport/rubberbanding-viewport-rects.html 22 23 * page/FrameView.cpp: 24 (WebCore::FrameView::computeLayoutViewportOrigin): Handle ScrollBehaviorForFixedElements, incorporating it 25 into logic that clamps layoutViewportOrigin between min/max when rubberbanding is not allowed, or not in progress. 26 (WebCore::FrameView::updateLayoutViewport): Pass in scrollBehaviorForFixedElements(). 27 (WebCore::FrameView::visibleDocumentRect): The clamping here was preventing the visible rect from 28 escaping the document bounds, which caused fixed elements to bounce with rubber-banding, so remove the clamping, 29 and fix the logic to allow rubber-banding while taking headers and footers into account. 30 * page/FrameView.h: 31 * page/scrolling/AsyncScrollingCoordinator.cpp: 32 (WebCore::AsyncScrollingCoordinator::scheduleUpdateScrollPositionAfterAsyncScroll): layoutViewportOrigin has to 33 be pushed onto the scheduled update, just like scroll position. 34 * page/scrolling/ScrollingTreeFrameScrollingNode.cpp: 35 (WebCore::ScrollingTreeFrameScrollingNode::layoutViewportForScrollPosition): Pass in m_behaviorForFixed. 36 * platform/ScrollView.cpp: 37 (WebCore::ScrollView::ScrollView): 38 (WebCore::ScrollView::adjustScrollPositionWithinRange): 39 (WebCore::ScrollView::setScrollOffset): 40 * platform/ScrollView.h: 41 (WebCore::ScrollView::setAllowsUnclampedScrollPositionForTesting): 42 (WebCore::ScrollView::allowsUnclampedScrollPosition): 43 * testing/InternalSettings.cpp: 44 (WebCore::InternalSettings::setAllowUnclampedScrollPosition): 45 * testing/InternalSettings.h: 46 * testing/InternalSettings.idl: 47 1 48 2017-01-30 Wenson Hsieh <wenson_hsieh@apple.com> 2 49 -
trunk/Source/WebCore/page/FrameView.cpp
r211082 r211379 1807 1807 1808 1808 // visualViewport and layoutViewport are both in content coordinates (unzoomed). 1809 LayoutPoint FrameView::computeLayoutViewportOrigin(const LayoutRect& visualViewport, const LayoutPoint& stableLayoutViewportOriginMin, const LayoutPoint& stableLayoutViewportOriginMax, const LayoutRect& layoutViewport )1809 LayoutPoint FrameView::computeLayoutViewportOrigin(const LayoutRect& visualViewport, const LayoutPoint& stableLayoutViewportOriginMin, const LayoutPoint& stableLayoutViewportOriginMax, const LayoutRect& layoutViewport, ScrollBehaviorForFixedElements fixedBehavior) 1810 1810 { 1811 1811 LayoutPoint layoutViewportOrigin = layoutViewport.location(); 1812 bool allowRubberBanding = fixedBehavior == StickToViewportBounds; 1812 1813 1813 1814 if (visualViewport.width() > layoutViewport.width()) 1814 1815 layoutViewportOrigin.setX(visualViewport.x()); 1815 1816 else { 1816 if (visualViewport.x() < layoutViewport.x() || visualViewport.x() < stableLayoutViewportOriginMin.x()) 1817 bool rubberbandingAtLeft = allowRubberBanding && visualViewport.x() < stableLayoutViewportOriginMin.x(); 1818 bool rubberbandingAtRight = allowRubberBanding && (visualViewport.maxX() - layoutViewport.width()) > stableLayoutViewportOriginMax.x(); 1819 1820 if (visualViewport.x() < layoutViewport.x() || rubberbandingAtLeft) 1817 1821 layoutViewportOrigin.setX(visualViewport.x()); 1818 1822 1819 if (visualViewport.maxX() > layoutViewport.maxX() || (visualViewport.maxX() - layoutViewport.width()) > stableLayoutViewportOriginMax.x())1823 if (visualViewport.maxX() > layoutViewport.maxX() || rubberbandingAtRight) 1820 1824 layoutViewportOrigin.setX(visualViewport.maxX() - layoutViewport.width()); 1825 1826 if (!rubberbandingAtLeft && layoutViewportOrigin.x() < stableLayoutViewportOriginMin.x()) 1827 layoutViewportOrigin.setX(stableLayoutViewportOriginMin.x()); 1828 1829 if (!rubberbandingAtRight && layoutViewportOrigin.x() > stableLayoutViewportOriginMax.x()) 1830 layoutViewportOrigin.setX(stableLayoutViewportOriginMax.x()); 1821 1831 } 1822 1832 … … 1824 1834 layoutViewportOrigin.setY(visualViewport.y()); 1825 1835 else { 1826 if (visualViewport.y() < layoutViewport.y() || visualViewport.y() < stableLayoutViewportOriginMin.y()) 1836 bool rubberbandingAtTop = allowRubberBanding && visualViewport.y() < stableLayoutViewportOriginMin.y(); 1837 bool rubberbandingAtBottom = allowRubberBanding && (visualViewport.maxY() - layoutViewport.height()) > stableLayoutViewportOriginMax.y(); 1838 1839 if (visualViewport.y() < layoutViewport.y() || rubberbandingAtTop) 1827 1840 layoutViewportOrigin.setY(visualViewport.y()); 1828 1841 1829 if (visualViewport.maxY() > layoutViewport.maxY() || (visualViewport.maxY() - layoutViewport.height()) > stableLayoutViewportOriginMax.y())1842 if (visualViewport.maxY() > layoutViewport.maxY() || rubberbandingAtBottom) 1830 1843 layoutViewportOrigin.setY(visualViewport.maxY() - layoutViewport.height()); 1844 1845 if (!rubberbandingAtTop && layoutViewportOrigin.y() < stableLayoutViewportOriginMin.y()) 1846 layoutViewportOrigin.setY(stableLayoutViewportOriginMin.y()); 1847 1848 if (!rubberbandingAtBottom && layoutViewportOrigin.y() > stableLayoutViewportOriginMax.y()) 1849 layoutViewportOrigin.setY(stableLayoutViewportOriginMax.y()); 1831 1850 } 1832 1851 … … 1893 1912 LOG_WITH_STREAM(Scrolling, stream << "scroll positions: min: " << unscaledMinimumScrollPosition() << " max: "<< unscaledMaximumScrollPosition()); 1894 1913 1895 LayoutPoint newLayoutViewportOrigin = computeLayoutViewportOrigin(visualViewportRect(), minStableLayoutViewportOrigin(), maxStableLayoutViewportOrigin(), layoutViewport );1914 LayoutPoint newLayoutViewportOrigin = computeLayoutViewportOrigin(visualViewportRect(), minStableLayoutViewportOrigin(), maxStableLayoutViewportOrigin(), layoutViewport, scrollBehaviorForFixedElements()); 1896 1915 if (newLayoutViewportOrigin != m_layoutViewportOrigin) { 1897 1916 setBaseLayoutViewportOrigin(newLayoutViewportOrigin); … … 1935 1954 LayoutRect FrameView::visibleDocumentRect(const FloatRect& visibleContentRect, float headerHeight, float footerHeight, const FloatSize& totalContentsSize, float pageScaleFactor) 1936 1955 { 1956 float contentsHeight = totalContentsSize.height() - headerHeight - footerHeight; 1957 1958 float rubberBandTop = std::min<float>(visibleContentRect.y(), 0); 1959 float visibleScaledDocumentTop = std::max<float>(visibleContentRect.y() - headerHeight, 0) + rubberBandTop; 1960 1961 float rubberBandBottom = std::min<float>((totalContentsSize.height() - visibleContentRect.y()) - visibleContentRect.height(), 0); 1962 float visibleScaledDocumentBottom = std::min<float>(visibleContentRect.maxY() - headerHeight, contentsHeight) + rubberBandBottom; 1963 1937 1964 FloatRect visibleDocumentRect = visibleContentRect; 1938 1939 float contentsHeight = totalContentsSize.height() - headerHeight - footerHeight;1940 1941 float visibleScaledDocumentTop = std::max<float>(visibleContentRect.y() - headerHeight, 0);1942 float visibleScaledDocumentBottom = std::min<float>(visibleContentRect.maxY() - headerHeight, contentsHeight);1943 1944 1965 visibleDocumentRect.setY(visibleScaledDocumentTop); 1945 1966 visibleDocumentRect.setHeight(std::max<float>(visibleScaledDocumentBottom - visibleScaledDocumentTop, 0)); 1946 1967 visibleDocumentRect.scale(1 / pageScaleFactor); 1968 1947 1969 return LayoutRect(visibleDocumentRect); 1948 1970 } -
trunk/Source/WebCore/page/FrameView.h
r210797 r211379 305 305 static LayoutPoint scrollPositionForFixedPosition(const LayoutRect& visibleContentRect, const LayoutSize& totalContentsSize, const LayoutPoint& scrollPosition, const LayoutPoint& scrollOrigin, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame, ScrollBehaviorForFixedElements, int headerHeight, int footerHeight); 306 306 307 WEBCORE_EXPORT static LayoutPoint computeLayoutViewportOrigin(const LayoutRect& visualViewport, const LayoutPoint& stableLayoutViewportOriginMin, const LayoutPoint& stableLayoutViewportOriginMax, const LayoutRect& layoutViewport );307 WEBCORE_EXPORT static LayoutPoint computeLayoutViewportOrigin(const LayoutRect& visualViewport, const LayoutPoint& stableLayoutViewportOriginMin, const LayoutPoint& stableLayoutViewportOriginMax, const LayoutRect& layoutViewport, ScrollBehaviorForFixedElements fixedBehavior); 308 308 309 309 // These layers are positioned differently when there is a topContentInset, a header, or a footer. These value need to be computed -
trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp
r210560 r211379 270 270 if (m_scheduledScrollUpdate.matchesUpdateType(scrollUpdate)) { 271 271 m_scheduledScrollUpdate.scrollPosition = scrollPosition; 272 m_scheduledScrollUpdate.layoutViewportOrigin = layoutViewportOrigin; 272 273 return; 273 274 } -
trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp
r210059 r211379 112 112 LOG_WITH_STREAM(Scrolling, stream << " scroll positions: min: " << minLayoutViewportOrigin() << " max: "<< maxLayoutViewportOrigin()); 113 113 114 LayoutPoint newLocation = FrameView::computeLayoutViewportOrigin(LayoutRect(visualViewport), LayoutPoint(minLayoutViewportOrigin()), LayoutPoint(maxLayoutViewportOrigin()), layoutViewport );114 LayoutPoint newLocation = FrameView::computeLayoutViewportOrigin(LayoutRect(visualViewport), LayoutPoint(minLayoutViewportOrigin()), LayoutPoint(maxLayoutViewportOrigin()), layoutViewport, m_behaviorForFixed); 115 115 116 116 if (layoutViewport.location() != newLocation) { -
trunk/Source/WebCore/platform/ScrollView.cpp
r210758 r211379 42 42 43 43 ScrollView::ScrollView() 44 : m_horizontalScrollbarMode(ScrollbarAuto)45 , m_verticalScrollbarMode(ScrollbarAuto)46 , m_horizontalScrollbarLock(false)47 , m_verticalScrollbarLock(false)48 , m_prohibitsScrolling(false)49 , m_canBlitOnScroll(true)50 , m_scrollbarsSuppressed(false)51 , m_inUpdateScrollbars(false)52 , m_updateScrollbarsPass(0)53 , m_drawPanScrollIcon(false)54 , m_useFixedLayout(false)55 , m_paintsEntireContents(false)56 , m_clipsRepaints(true)57 , m_delegatesScrolling(false)58 44 { 59 45 } … … 382 368 ScrollPosition ScrollView::adjustScrollPositionWithinRange(const ScrollPosition& scrollPoint) const 383 369 { 384 if (!constrainsScrollingToContentEdge() )370 if (!constrainsScrollingToContentEdge() || m_allowsUnclampedScrollPosition) 385 371 return scrollPoint; 386 372 … … 419 405 void ScrollView::setScrollOffset(const ScrollOffset& offset) 420 406 { 421 LOG_WITH_STREAM(Scrolling, stream << "\nScrollView::setScrollOffset " << offset );407 LOG_WITH_STREAM(Scrolling, stream << "\nScrollView::setScrollOffset " << offset << " constrains " << constrainsScrollingToContentEdge()); 422 408 423 409 IntPoint constrainedOffset = offset; -
trunk/Source/WebCore/platform/ScrollView.h
r210758 r211379 374 374 WEBCORE_EXPORT void scrollOffsetChangedViaPlatformWidget(const ScrollOffset& oldOffset, const ScrollOffset& newOffset); 375 375 376 void setAllowsUnclampedScrollPositionForTesting(bool allowsUnclampedScrollPosition) { m_allowsUnclampedScrollPosition = allowsUnclampedScrollPosition; } 377 bool allowsUnclampedScrollPosition() const { return m_allowsUnclampedScrollPosition; } 378 376 379 protected: 377 380 ScrollView(); … … 434 437 bool isScrollView() const final { return true; } 435 438 439 HashSet<Ref<Widget>> m_children; 440 436 441 RefPtr<Scrollbar> m_horizontalScrollbar; 437 442 RefPtr<Scrollbar> m_verticalScrollbar; 438 ScrollbarMode m_horizontalScrollbarMode; 439 ScrollbarMode m_verticalScrollbarMode; 440 441 bool m_horizontalScrollbarLock; 442 bool m_verticalScrollbarLock; 443 444 bool m_prohibitsScrolling; 445 446 HashSet<Ref<Widget>> m_children; 447 448 // This bool is unused on Mac OS because we directly ask the platform widget 449 // whether it is safe to blit on scroll. 450 bool m_canBlitOnScroll; 443 ScrollbarMode m_horizontalScrollbarMode { ScrollbarAuto }; 444 ScrollbarMode m_verticalScrollbarMode { ScrollbarAuto }; 451 445 452 446 #if PLATFORM(IOS) … … 467 461 std::optional<std::pair<ScrollOffset, ScrollOffset>> m_deferredScrollOffsets; // Needed for platform widget scrolling 468 462 469 bool m_scrollbarsSuppressed;470 471 bool m_inUpdateScrollbars;472 unsigned m_updateScrollbarsPass;473 474 463 IntPoint m_panScrollIconPoint; 475 bool m_drawPanScrollIcon; 476 bool m_useFixedLayout; 477 478 bool m_paintsEntireContents; 479 bool m_clipsRepaints; 480 bool m_delegatesScrolling; 464 465 bool m_horizontalScrollbarLock { false }; 466 bool m_verticalScrollbarLock { false }; 467 468 bool m_prohibitsScrolling { false }; 469 bool m_allowsUnclampedScrollPosition { false }; 470 471 // This bool is unused on Mac OS because we directly ask the platform widget 472 // whether it is safe to blit on scroll. 473 bool m_canBlitOnScroll { true }; 474 475 bool m_scrollbarsSuppressed { false }; 476 477 bool m_inUpdateScrollbars { false }; 478 unsigned m_updateScrollbarsPass { 0 }; 479 480 bool m_drawPanScrollIcon { false }; 481 bool m_useFixedLayout { false }; 482 483 bool m_paintsEntireContents { false }; 484 bool m_clipsRepaints { true }; 485 bool m_delegatesScrolling { false }; 486 481 487 482 488 void init(); -
trunk/Source/WebCore/testing/InternalSettings.cpp
r211341 r211379 641 641 } 642 642 643 ExceptionOr<void> InternalSettings::setAllowUnclampedScrollPosition(bool allowUnclamped) 644 { 645 if (!m_page || !m_page->mainFrame().view()) 646 return Exception { INVALID_ACCESS_ERR }; 647 648 m_page->mainFrame().view()->setAllowsUnclampedScrollPositionForTesting(allowUnclamped); 649 return { }; 650 } 651 643 652 ExceptionOr<void> InternalSettings::setAllowsInlineMediaPlayback(bool allows) 644 653 { -
trunk/Source/WebCore/testing/InternalSettings.h
r211341 r211379 88 88 ExceptionOr<void> setShouldConvertPositionStyleOnCopy(bool); 89 89 ExceptionOr<void> setScrollingTreeIncludesFrames(bool); 90 ExceptionOr<void> setAllowUnclampedScrollPosition(bool); 90 91 ExceptionOr<void> setAllowsInlineMediaPlayback(bool); 91 92 ExceptionOr<void> setAllowsInlineMediaPlaybackAfterFullscreen(bool); -
trunk/Source/WebCore/testing/InternalSettings.idl
r211341 r211379 76 76 [MayThrowException] void setBackgroundShouldExtendBeyondPage(boolean hasExtendedBackground); 77 77 [MayThrowException] void setScrollingTreeIncludesFrames(boolean enabled); 78 [MayThrowException] void setAllowUnclampedScrollPosition(boolean allowUnclamped); 78 79 79 80 [MayThrowException] void setMinimumTimerInterval(unrestricted double intervalInSeconds); -
trunk/Source/WebKit2/ChangeLog
r211376 r211379 1 2017-01-30 Simon Fraser <simon.fraser@apple.com> 2 3 Fixed elements should not rubber-band in WK2, nor remain at negative offsets 4 https://bugs.webkit.org/show_bug.cgi?id=167484 5 rdar://problem/29453068 6 7 Reviewed by Dean Jackson. 8 9 Pass in StickToViewportBounds as we did before visual viewports. 10 11 * UIProcess/ios/WebPageProxyIOS.mm: 12 (WebKit::WebPageProxy::computeCustomFixedPositionRect): 13 1 14 2017-01-30 Chris Dumez <cdumez@apple.com> 2 15 -
trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm
r211356 r211379 269 269 LayoutPoint layoutViewportOrigin; 270 270 if (isBelowMinimumScale) 271 layoutViewportOrigin = FrameView::computeLayoutViewportOrigin(enclosingLayoutRect(constrainedUnobscuredRect), m_minStableLayoutViewportOrigin, m_maxStableLayoutViewportOrigin, enclosingLayoutRect(layoutViewportRect) );271 layoutViewportOrigin = FrameView::computeLayoutViewportOrigin(enclosingLayoutRect(constrainedUnobscuredRect), m_minStableLayoutViewportOrigin, m_maxStableLayoutViewportOrigin, enclosingLayoutRect(layoutViewportRect), StickToViewportBounds); 272 272 else 273 layoutViewportOrigin = FrameView::computeLayoutViewportOrigin(enclosingLayoutRect(unobscuredContentRectRespectingInputViewBounds), m_minStableLayoutViewportOrigin, m_maxStableLayoutViewportOrigin, enclosingLayoutRect(layoutViewportRect) );273 layoutViewportOrigin = FrameView::computeLayoutViewportOrigin(enclosingLayoutRect(unobscuredContentRectRespectingInputViewBounds), m_minStableLayoutViewportOrigin, m_maxStableLayoutViewportOrigin, enclosingLayoutRect(layoutViewportRect), StickToViewportBounds); 274 274 275 275 if (constraint == UnobscuredRectConstraint::ConstrainedToDocumentRect) {
Note: See TracChangeset
for help on using the changeset viewer.