Remove iOS #ifdefs around unobscuredContentSize
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Dec 2019 07:00:28 +0000 (07:00 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Dec 2019 07:00:28 +0000 (07:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=205372

Reviewed by Tim Horton.

Long-term, all of the ScrollView geometry data related to delegated scrolling
will move to Optional<DelegatedScrollingGeometry> m_delegatedScrollingGeometry
and not be wrapped in platform #ifdefs.

Take the first step of moving unobscuredContentSize into that struct.

I added platformUnobscuredContentRect() to handle the iOS WK1 case, called
when there is a platform widget.

m_fixedVisibleContentRect is only used by co√∂rdinated graphics.

* page/FrameView.cpp:
(WebCore::FrameView::unobscuredContentSizeChanged):
* page/FrameView.h:
* platform/ScrollView.cpp:
(WebCore::ScrollView::unobscuredContentSize const):
(WebCore::ScrollView::setUnobscuredContentSize):
(WebCore::ScrollView::unobscuredContentRect const):
(WebCore::ScrollView::platformVisibleContentRect const):
(WebCore::ScrollView::platformVisibleContentSize const):
(WebCore::ScrollView::platformVisibleContentRectIncludingObscuredArea const):
(WebCore::ScrollView::platformVisibleContentSizeIncludingObscuredArea const):
(WebCore::ScrollView::platformUnobscuredContentRect const):
* platform/ScrollView.h:
(WebCore::ScrollView::unobscuredContentSize const): Deleted.
* platform/ios/ScrollViewIOS.mm:
(WebCore::ScrollView::platformUnobscuredContentRect const):
(WebCore::ScrollView::unobscuredContentRect const): Deleted.
(WebCore::ScrollView::setUnobscuredContentSize): Deleted.
* platform/mac/ScrollViewMac.mm:
(WebCore::ScrollView::platformUnobscuredContentRect const):

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

Source/WebCore/ChangeLog
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/FrameView.h
Source/WebCore/platform/ScrollView.cpp
Source/WebCore/platform/ScrollView.h
Source/WebCore/platform/ios/ScrollViewIOS.mm
Source/WebCore/platform/mac/ScrollViewMac.mm

index 3707c13..22da106 100644 (file)
@@ -1,3 +1,42 @@
+2019-12-17  Simon Fraser  <simon.fraser@apple.com>
+
+        Remove iOS #ifdefs around unobscuredContentSize
+        https://bugs.webkit.org/show_bug.cgi?id=205372
+
+        Reviewed by Tim Horton.
+
+        Long-term, all of the ScrollView geometry data related to delegated scrolling
+        will move to Optional<DelegatedScrollingGeometry> m_delegatedScrollingGeometry
+        and not be wrapped in platform #ifdefs.
+
+        Take the first step of moving unobscuredContentSize into that struct.
+
+        I added platformUnobscuredContentRect() to handle the iOS WK1 case, called 
+        when there is a platform widget.
+        
+        m_fixedVisibleContentRect is only used by co√∂rdinated graphics.
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::unobscuredContentSizeChanged):
+        * page/FrameView.h:
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::unobscuredContentSize const):
+        (WebCore::ScrollView::setUnobscuredContentSize):
+        (WebCore::ScrollView::unobscuredContentRect const):
+        (WebCore::ScrollView::platformVisibleContentRect const):
+        (WebCore::ScrollView::platformVisibleContentSize const):
+        (WebCore::ScrollView::platformVisibleContentRectIncludingObscuredArea const):
+        (WebCore::ScrollView::platformVisibleContentSizeIncludingObscuredArea const):
+        (WebCore::ScrollView::platformUnobscuredContentRect const):
+        * platform/ScrollView.h:
+        (WebCore::ScrollView::unobscuredContentSize const): Deleted.
+        * platform/ios/ScrollViewIOS.mm:
+        (WebCore::ScrollView::platformUnobscuredContentRect const):
+        (WebCore::ScrollView::unobscuredContentRect const): Deleted.
+        (WebCore::ScrollView::setUnobscuredContentSize): Deleted.
+        * platform/mac/ScrollViewMac.mm:
+        (WebCore::ScrollView::platformUnobscuredContentRect const):
+
 2019-12-17  Chris Dumez  <cdumez@apple.com>
 
         Port service worker code to the HTML5 event loop
index ea7511b..9229d55 100644 (file)
@@ -2807,14 +2807,12 @@ void FrameView::layoutOrVisualViewportChanged()
     }
 }
 
-#if PLATFORM(IOS_FAMILY)
-
 void FrameView::unobscuredContentSizeChanged()
 {
+#if PLATFORM(IOS_FAMILY)
     updateTiledBackingAdaptiveSizing();
-}
-
 #endif
+}
 
 static LayerFlushThrottleState::Flags determineLayerFlushThrottleState(Page& page)
 {
index e36f996..f34940d 100644 (file)
@@ -722,6 +722,8 @@ private:
 
     void delegatesScrollingDidChange() final;
 
+    void unobscuredContentSizeChanged() final;
+
     // ScrollableArea interface
     void invalidateScrollbarRect(Scrollbar&, const IntRect&) final;
     void scrollTo(const ScrollPosition&) final;
@@ -735,10 +737,6 @@ private:
 #endif
     void contentsResized() final;
 
-#if PLATFORM(IOS_FAMILY)
-    void unobscuredContentSizeChanged() final;
-#endif
-
 #if ENABLE(DARK_MODE_CSS)
     RenderObject* rendererForColorScheme() const;
 #endif
index 7d2d2e1..178523a 100644 (file)
@@ -220,12 +220,37 @@ void ScrollView::setContentsScrollPosition(const IntPoint& position)
     setScrollPosition(position);
 }
 
-#if !PLATFORM(IOS_FAMILY)
+FloatSize ScrollView::unobscuredContentSize() const
+{
+    ASSERT(m_delegatedScrollingGeometry);
+    if (m_delegatedScrollingGeometry)
+        return m_delegatedScrollingGeometry->unobscuredContentSize;
+    return { };
+}
+
+void ScrollView::setUnobscuredContentSize(const FloatSize& size)
+{
+    ASSERT(!platformWidget());
+    if (m_delegatedScrollingGeometry && size == m_delegatedScrollingGeometry->unobscuredContentSize)
+        return;
+
+    if (!m_delegatedScrollingGeometry)
+        m_delegatedScrollingGeometry = DelegatedScrollingGeometry();
+
+    m_delegatedScrollingGeometry->unobscuredContentSize = size;
+    unobscuredContentSizeChanged();
+}
+
 IntRect ScrollView::unobscuredContentRect(VisibleContentRectIncludesScrollbars scrollbarInclusion) const
 {
+    if (platformWidget())
+        return platformUnobscuredContentRect(scrollbarInclusion);
+
+    if (m_delegatedScrollingGeometry)
+        return IntRect(m_scrollPosition, roundedIntSize(m_delegatedScrollingGeometry->unobscuredContentSize));
+
     return unobscuredContentRectInternal(scrollbarInclusion);
 }
-#endif
 
 IntRect ScrollView::unobscuredContentRectInternal(VisibleContentRectIncludesScrollbars scrollbarInclusion) const
 {
@@ -1533,7 +1558,7 @@ bool ScrollView::platformCanBlitOnScroll() const
 
 IntRect ScrollView::platformVisibleContentRect(bool) const
 {
-    return IntRect();
+    return { };
 }
 
 float ScrollView::platformTopContentInset() const
@@ -1547,17 +1572,22 @@ void ScrollView::platformSetTopContentInset(float)
 
 IntSize ScrollView::platformVisibleContentSize(bool) const
 {
-    return IntSize();
+    return { };
 }
 
 IntRect ScrollView::platformVisibleContentRectIncludingObscuredArea(bool) const
 {
-    return IntRect();
+    return { };
 }
 
 IntSize ScrollView::platformVisibleContentSizeIncludingObscuredArea(bool) const
 {
-    return IntSize();
+    return { };
+}
+
+IntRect ScrollView::platformUnobscuredContentRect(VisibleContentRectIncludesScrollbars) const
+{
+    return { };
 }
 
 void ScrollView::platformSetContentsSize()
index 2ff26d7..0842859 100644 (file)
@@ -179,21 +179,23 @@ public:
     // contribute to painting but not to the scrollable area.
     // The unobscuredContentRect is the area that is not covered by UI elements.
     WEBCORE_EXPORT IntRect unobscuredContentRect(VisibleContentRectIncludesScrollbars = ExcludeScrollbars) const;
+
 #if PLATFORM(IOS_FAMILY)
     IntRect unobscuredContentRectIncludingScrollbars() const { return unobscuredContentRect(IncludeScrollbars); }
 #else
     IntRect unobscuredContentRectIncludingScrollbars() const { return visibleContentRectIncludingScrollbars(); }
 #endif
 
-#if PLATFORM(IOS_FAMILY)
     // This is the area that is partially or fully exposed, and may extend under overlapping UI elements.
     WEBCORE_EXPORT FloatRect exposedContentRect() const;
 
     // The given rects are only used if there is no platform widget.
     WEBCORE_EXPORT void setExposedContentRect(const FloatRect&);
-    const FloatSize& unobscuredContentSize() const { return m_unobscuredContentSize; }
+
+    WEBCORE_EXPORT FloatSize unobscuredContentSize() const;
     WEBCORE_EXPORT void setUnobscuredContentSize(const FloatSize&);
 
+#if PLATFORM(IOS_FAMILY)
     void setActualScrollPosition(const IntPoint&);
     LegacyTileCache* legacyTileCache();
 #endif
@@ -428,9 +430,7 @@ protected:
 
     virtual void scrollOffsetChangedViaPlatformWidgetImpl(const ScrollOffset&, const ScrollOffset&) = 0;
 
-#if PLATFORM(IOS_FAMILY)
     virtual void unobscuredContentSizeChanged() = 0;
-#endif
 
 #if PLATFORM(COCOA) && defined __OBJC__
 public:
@@ -468,13 +468,19 @@ private:
     void platformScrollbarModes(ScrollbarMode& horizontal, ScrollbarMode& vertical) const;
     void platformSetCanBlitOnScroll(bool);
     bool platformCanBlitOnScroll() const;
+    
     IntRect platformVisibleContentRect(bool includeScrollbars) const;
     IntSize platformVisibleContentSize(bool includeScrollbars) const;
     IntRect platformVisibleContentRectIncludingObscuredArea(bool includeScrollbars) const;
     IntSize platformVisibleContentSizeIncludingObscuredArea(bool includeScrollbars) const;
+
+    IntRect platformUnobscuredContentRect(VisibleContentRectIncludesScrollbars) const;
+
     void platformSetContentsSize();
+
     IntRect platformContentsToScreen(const IntRect&) const;
     IntPoint platformScreenToContents(const IntPoint&) const;
+
     void platformSetScrollPosition(const IntPoint&);
     bool platformScroll(ScrollDirection, ScrollGranularity);
     void platformSetScrollbarsSuppressed(bool repaintOnUnsuppress);
@@ -493,13 +499,17 @@ private:
     ScrollbarMode m_horizontalScrollbarMode { ScrollbarAuto };
     ScrollbarMode m_verticalScrollbarMode { ScrollbarAuto };
 
-#if PLATFORM(IOS_FAMILY)
+    FloatRect m_exposedContentRect;
+
+    // FIXME: More things will move into here.
+    struct DelegatedScrollingGeometry {
+        FloatSize unobscuredContentSize;
+    };
+    Optional<DelegatedScrollingGeometry> m_delegatedScrollingGeometry;
+
+#if USE(COORDINATED_GRAPHICS)
     // FIXME: exposedContentRect is a very similar concept to fixedVisibleContentRect except it does not differentiate
     // between exposed and unobscured areas. The two attributes should eventually be merged.
-    FloatRect m_exposedContentRect;
-    FloatSize m_unobscuredContentSize;
-    // This is only used for history scroll position restoration.
-#else
     IntRect m_fixedVisibleContentRect;
 #endif
     ScrollPosition m_scrollPosition;
index 85cce2e..c81da64 100644 (file)
@@ -102,30 +102,15 @@ bool ScrollView::platformCanBlitOnScroll() const
     ALLOW_DEPRECATED_DECLARATIONS_END
 }
 
-IntRect ScrollView::unobscuredContentRect(VisibleContentRectIncludesScrollbars) const
+IntRect ScrollView::platformUnobscuredContentRect(VisibleContentRectIncludesScrollbars) const
 {
-    if (WAKScrollView *view = static_cast<WAKScrollView *>(platformWidget())) {
-        CGRect r = CGRectZero;
-        BEGIN_BLOCK_OBJC_EXCEPTIONS;
-        r = [view unobscuredContentRect];
-        END_BLOCK_OBJC_EXCEPTIONS;
-        return enclosingIntRect(r);
-    }
-
-    if (!m_unobscuredContentSize.isEmpty())
-        return IntRect(m_scrollPosition, roundedIntSize(m_unobscuredContentSize));
-
-    return unobscuredContentRectInternal();
-}
-
-void ScrollView::setUnobscuredContentSize(const FloatSize& size)
-{
-    ASSERT(!platformWidget());
-    if (size == m_unobscuredContentSize)
-        return;
-
-    m_unobscuredContentSize = size;
-    unobscuredContentSizeChanged();
+    ASSERT(platformWidget());
+    WAKScrollView *view = static_cast<WAKScrollView *>(platformWidget());
+    CGRect r = CGRectZero;
+    BEGIN_BLOCK_OBJC_EXCEPTIONS;
+    r = [view unobscuredContentRect];
+    END_BLOCK_OBJC_EXCEPTIONS;
+    return enclosingIntRect(r);
 }
 
 FloatRect ScrollView::exposedContentRect() const
index b8b5331..3341d4d 100644 (file)
@@ -177,6 +177,11 @@ IntSize ScrollView::platformVisibleContentSizeIncludingObscuredArea(bool include
     return platformVisibleContentRectIncludingObscuredArea(includeScrollbars).size();
 }
 
+IntRect ScrollView::platformUnobscuredContentRect(VisibleContentRectIncludesScrollbars scrollbarInclusion) const
+{
+    return unobscuredContentRectInternal(scrollbarInclusion);
+}
+
 void ScrollView::platformSetContentsSize()
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;