Move delegatesScrolling() tests to lower level conversion function in ScrollView
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Jan 2019 12:27:53 +0000 (12:27 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Jan 2019 12:27:53 +0000 (12:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=193649

Reviewed by Frédéric Wang.

This reduces places where these tests are needed and helps avoid mistakes.

* dom/Document.cpp:
(WebCore::computeIntersectionState):
* page/FrameView.cpp:
(WebCore::FrameView::convertFromRendererToContainingView const):
(WebCore::FrameView::convertFromContainingViewToRenderer const):
* platform/ScrollView.cpp:
(WebCore::ScrollView::viewToContents const):
(WebCore::ScrollView::contentsToView const):
(WebCore::ScrollView::contentsToContainingViewContents const):
(WebCore::ScrollView::rootViewToContents const):
(WebCore::ScrollView::contentsToRootView const):
(WebCore::ScrollView::windowToContents const):
(WebCore::ScrollView::contentsToWindow const):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240232 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/page/FrameView.cpp
Source/WebCore/platform/ScrollView.cpp

index e9f0c95..f7e01e8 100644 (file)
@@ -1,3 +1,26 @@
+2019-01-21  Antti Koivisto  <antti@apple.com>
+
+        Move delegatesScrolling() tests to lower level conversion function in ScrollView
+        https://bugs.webkit.org/show_bug.cgi?id=193649
+
+        Reviewed by Frédéric Wang.
+
+        This reduces places where these tests are needed and helps avoid mistakes.
+
+        * dom/Document.cpp:
+        (WebCore::computeIntersectionState):
+        * page/FrameView.cpp:
+        (WebCore::FrameView::convertFromRendererToContainingView const):
+        (WebCore::FrameView::convertFromContainingViewToRenderer const):
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::viewToContents const):
+        (WebCore::ScrollView::contentsToView const):
+        (WebCore::ScrollView::contentsToContainingViewContents const):
+        (WebCore::ScrollView::rootViewToContents const):
+        (WebCore::ScrollView::contentsToRootView const):
+        (WebCore::ScrollView::windowToContents const):
+        (WebCore::ScrollView::contentsToWindow const):
+
 2019-01-21  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         REGRESSION(r239915): about 130 test failures on WPE
index 67eb1a1..1ce9e0b 100644 (file)
@@ -7919,7 +7919,7 @@ static Optional<IntersectionObservationState> computeIntersectionState(FrameView
         if (&targetRenderer->frame() == &rootRenderer->frame())
             intersectionState.absoluteIntersectionRect = rootAbsoluteIntersectionRect;
         else {
-            FloatRect rootViewIntersectionRect = frameView.delegatesScrolling() ? rootAbsoluteIntersectionRect : frameView.contentsToView(rootAbsoluteIntersectionRect);
+            FloatRect rootViewIntersectionRect = frameView.contentsToView(rootAbsoluteIntersectionRect);
             intersectionState.absoluteIntersectionRect = targetRenderer->view().frameView().rootViewToContents(rootViewIntersectionRect);
         }
     }
index e4714aa..0f9fea1 100644 (file)
@@ -4654,19 +4654,12 @@ IntRect FrameView::convertFromRendererToContainingView(const RenderElement* rend
 {
     IntRect rect = snappedIntRect(enclosingLayoutRect(renderer->localToAbsoluteQuad(FloatRect(rendererRect)).boundingBox()));
 
-    if (!delegatesScrolling())
-        rect = contentsToView(rect);
-
-    return rect;
+    return contentsToView(rect);
 }
 
 IntRect FrameView::convertFromContainingViewToRenderer(const RenderElement* renderer, const IntRect& viewRect) const
 {
-    IntRect rect = viewRect;
-    
-    // Convert from FrameView coords into page ("absolute") coordinates.
-    if (!delegatesScrolling())
-        rect = viewToContents(rect);
+    IntRect rect = viewToContents(viewRect);
 
     // FIXME: we don't have a way to map an absolute rect down to a local quad, so just
     // move the rect for now.
@@ -4676,11 +4669,7 @@ IntRect FrameView::convertFromContainingViewToRenderer(const RenderElement* rend
 
 FloatRect FrameView::convertFromContainingViewToRenderer(const RenderElement* renderer, const FloatRect& viewRect) const
 {
-    FloatRect rect = viewRect;
-
-    // Convert from FrameView coords into page ("absolute") coordinates.
-    if (!delegatesScrolling())
-        rect = viewToContents(rect);
+    FloatRect rect = viewToContents(viewRect);
 
     return (renderer->absoluteToLocalQuad(rect)).boundingBox();
 }
@@ -4689,11 +4678,7 @@ IntPoint FrameView::convertFromRendererToContainingView(const RenderElement* ren
 {
     IntPoint point = roundedIntPoint(renderer->localToAbsolute(rendererPoint, UseTransforms));
 
-    // Convert from page ("absolute") to FrameView coordinates.
-    if (!delegatesScrolling())
-        point = contentsToView(point);
-
-    return point;
+    return contentsToView(point);
 }
 
 IntPoint FrameView::convertFromContainingViewToRenderer(const RenderElement* renderer, const IntPoint& viewPoint) const
index b19806f..b4d9820 100644 (file)
@@ -815,34 +815,52 @@ void ScrollView::scrollContentsSlowPath(const IntRect& updateRect)
 
 IntPoint ScrollView::viewToContents(const IntPoint& point) const
 {
+    if (delegatesScrolling())
+        return point;
+
     return point + toIntSize(documentScrollPositionRelativeToViewOrigin());
 }
 
 IntPoint ScrollView::contentsToView(const IntPoint& point) const
 {
+    if (delegatesScrolling())
+        return point;
+
     return point - toIntSize(documentScrollPositionRelativeToViewOrigin());
 }
 
 IntRect ScrollView::viewToContents(IntRect rect) const
 {
+    if (delegatesScrolling())
+        return rect;
+
     rect.moveBy(documentScrollPositionRelativeToViewOrigin());
     return rect;
 }
 
 FloatRect ScrollView::viewToContents(FloatRect rect) const
 {
+    if (delegatesScrolling())
+        return rect;
+
     rect.moveBy(documentScrollPositionRelativeToViewOrigin());
     return rect;
 }
 
 IntRect ScrollView::contentsToView(IntRect rect) const
 {
+    if (delegatesScrolling())
+        return rect;
+
     rect.moveBy(-documentScrollPositionRelativeToViewOrigin());
     return rect;
 }
 
 FloatRect ScrollView::contentsToView(FloatRect rect) const
 {
+    if (delegatesScrolling())
+        return rect;
+
     rect.moveBy(-documentScrollPositionRelativeToViewOrigin());
     return rect;
 }
@@ -859,9 +877,6 @@ IntPoint ScrollView::contentsToContainingViewContents(const IntPoint& point) con
 
 IntRect ScrollView::contentsToContainingViewContents(IntRect rect) const
 {
-    if (delegatesScrolling())
-        return convertToContainingView(contentsToView(rect));
-    
     if (const ScrollView* parentScrollView = parent()) {
         IntRect rectInContainingView = convertToContainingView(contentsToView(rect));
         return parentScrollView->viewToContents(rectInContainingView);
@@ -872,33 +887,21 @@ IntRect ScrollView::contentsToContainingViewContents(IntRect rect) const
 
 IntPoint ScrollView::rootViewToContents(const IntPoint& rootViewPoint) const
 {
-    if (delegatesScrolling())
-        return convertFromRootView(rootViewPoint);
-
     return viewToContents(convertFromRootView(rootViewPoint));
 }
 
 IntPoint ScrollView::contentsToRootView(const IntPoint& contentsPoint) const
 {
-    if (delegatesScrolling())
-        return convertToRootView(contentsPoint);
-
     return convertToRootView(contentsToView(contentsPoint));
 }
 
 IntRect ScrollView::rootViewToContents(const IntRect& rootViewRect) const
 {
-    if (delegatesScrolling())
-        return convertFromRootView(rootViewRect);
-
     return viewToContents(convertFromRootView(rootViewRect));
 }
 
 FloatRect ScrollView::rootViewToContents(const FloatRect& rootViewRect) const
 {
-    if (delegatesScrolling())
-        return convertFromRootView(rootViewRect);
-
     return viewToContents(convertFromRootView(rootViewRect));
 }
 
@@ -914,41 +917,26 @@ IntPoint ScrollView::rootViewToTotalContents(const IntPoint& rootViewPoint) cons
 
 IntRect ScrollView::contentsToRootView(const IntRect& contentsRect) const
 {
-    if (delegatesScrolling())
-        return convertToRootView(contentsRect);
-
     return convertToRootView(contentsToView(contentsRect));
 }
 
 IntPoint ScrollView::windowToContents(const IntPoint& windowPoint) const
 {
-    if (delegatesScrolling())
-        return convertFromContainingWindow(windowPoint);
-
     return viewToContents(convertFromContainingWindow(windowPoint));
 }
 
 IntPoint ScrollView::contentsToWindow(const IntPoint& contentsPoint) const
 {
-    if (delegatesScrolling())
-        return convertToContainingWindow(contentsPoint);
-
     return convertToContainingWindow(contentsToView(contentsPoint));
 }
 
 IntRect ScrollView::windowToContents(const IntRect& windowRect) const
 {
-    if (delegatesScrolling())
-        return convertFromContainingWindow(windowRect);
-
     return viewToContents(convertFromContainingWindow(windowRect));
 }
 
 IntRect ScrollView::contentsToWindow(const IntRect& contentsRect) const
 {
-    if (delegatesScrolling())
-        return convertToContainingWindow(contentsRect);
-
     return convertToContainingWindow(contentsToView(contentsRect));
 }