- Revision
- 261876
- Author
- [email protected]
- Date
- 2020-05-19 11:41:14 -0700 (Tue, 19 May 2020)
Log Message
Push a PlatformDisplayID to scrolling trees, and allow the scrolling thread to get displayDidRefresh notifications
https://bugs.webkit.org/show_bug.cgi?id=211034
Reviewed by Sam Weinig.
Source/WebCore:
As work towards scrolling thread synchronization with main thread (webkit.org/b210884), allow
ScrollingTree to get a displayDidRefresh() call on the scrolling thread. Each
tree is associated with a Page which is associated with a display, so the ScrollingTree
needs to have a PlatformDisplayID to know which notifications to respond to.
Eventually, displayDidRefresh() will be used to trigger layer updates on the scrolling
thread if the main thread is periodically unresponsive.
* page/Page.cpp:
(WebCore::Page::scrollingCoordinator):
(WebCore::Page::windowScreenDidChange):
* page/scrolling/AsyncScrollingCoordinator.cpp:
(WebCore::AsyncScrollingCoordinator::windowScreenDidChange):
* page/scrolling/AsyncScrollingCoordinator.h:
* page/scrolling/ScrollingCoordinator.h:
(WebCore::ScrollingCoordinator::windowScreenDidChange):
* page/scrolling/ScrollingTree.cpp:
(WebCore::ScrollingTree::windowScreenDidChange):
(WebCore::ScrollingTree::displayID):
* page/scrolling/ScrollingTree.h:
(WebCore::ScrollingTree::displayDidRefresh):
* page/scrolling/ThreadedScrollingTree.cpp:
(WebCore::ThreadedScrollingTree::displayDidRefresh):
* page/scrolling/ThreadedScrollingTree.h:
Source/WebKit:
Prep work for webkit.org/b210884.
Have EventDispatcher call displayDidRefresh() on each scrolling tree it knows about. It calls this
on the EventDispatcher thread; the scrolling tree is responsible for bouncing that to the scrolling thread.
* WebProcess/WebPage/EventDispatcher.cpp:
(WebKit::EventDispatcher::displayDidRefreshOnScrollingThread):
(WebKit::EventDispatcher::displayWasRefreshed):
* WebProcess/WebPage/EventDispatcher.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (261875 => 261876)
--- trunk/Source/WebCore/ChangeLog 2020-05-19 18:40:23 UTC (rev 261875)
+++ trunk/Source/WebCore/ChangeLog 2020-05-19 18:41:14 UTC (rev 261876)
@@ -1,5 +1,37 @@
2020-05-19 Simon Fraser <[email protected]>
+ Push a PlatformDisplayID to scrolling trees, and allow the scrolling thread to get displayDidRefresh notifications
+ https://bugs.webkit.org/show_bug.cgi?id=211034
+
+ Reviewed by Sam Weinig.
+
+ As work towards scrolling thread synchronization with main thread (webkit.org/b210884), allow
+ ScrollingTree to get a displayDidRefresh() call on the scrolling thread. Each
+ tree is associated with a Page which is associated with a display, so the ScrollingTree
+ needs to have a PlatformDisplayID to know which notifications to respond to.
+
+ Eventually, displayDidRefresh() will be used to trigger layer updates on the scrolling
+ thread if the main thread is periodically unresponsive.
+
+ * page/Page.cpp:
+ (WebCore::Page::scrollingCoordinator):
+ (WebCore::Page::windowScreenDidChange):
+ * page/scrolling/AsyncScrollingCoordinator.cpp:
+ (WebCore::AsyncScrollingCoordinator::windowScreenDidChange):
+ * page/scrolling/AsyncScrollingCoordinator.h:
+ * page/scrolling/ScrollingCoordinator.h:
+ (WebCore::ScrollingCoordinator::windowScreenDidChange):
+ * page/scrolling/ScrollingTree.cpp:
+ (WebCore::ScrollingTree::windowScreenDidChange):
+ (WebCore::ScrollingTree::displayID):
+ * page/scrolling/ScrollingTree.h:
+ (WebCore::ScrollingTree::displayDidRefresh):
+ * page/scrolling/ThreadedScrollingTree.cpp:
+ (WebCore::ThreadedScrollingTree::displayDidRefresh):
+ * page/scrolling/ThreadedScrollingTree.h:
+
+2020-05-19 Simon Fraser <[email protected]>
+
[iOS] Programmaic scroll of "scrolling=no" iframe fails
https://bugs.webkit.org/show_bug.cgi?id=212063
<rdar://problem/57049514>
Modified: trunk/Source/WebCore/page/Page.cpp (261875 => 261876)
--- trunk/Source/WebCore/page/Page.cpp 2020-05-19 18:40:23 UTC (rev 261875)
+++ trunk/Source/WebCore/page/Page.cpp 2020-05-19 18:41:14 UTC (rev 261876)
@@ -434,6 +434,8 @@
m_scrollingCoordinator = chrome().client().createScrollingCoordinator(*this);
if (!m_scrollingCoordinator)
m_scrollingCoordinator = ScrollingCoordinator::create(this);
+
+ m_scrollingCoordinator->windowScreenDidChange(m_displayID);
}
return m_scrollingCoordinator.get();
@@ -1120,6 +1122,9 @@
frame->document()->windowScreenDidChange(displayID);
}
+ if (m_scrollingCoordinator)
+ m_scrollingCoordinator->windowScreenDidChange(displayID);
+
renderingUpdateScheduler().windowScreenDidChange(displayID);
setNeedsRecalcStyleInAllFrames();
Modified: trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp (261875 => 261876)
--- trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp 2020-05-19 18:40:23 UTC (rev 261875)
+++ trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp 2020-05-19 18:41:14 UTC (rev 261876)
@@ -816,6 +816,12 @@
#endif
}
+void AsyncScrollingCoordinator::windowScreenDidChange(PlatformDisplayID displayID)
+{
+ if (m_scrollingTree)
+ m_scrollingTree->windowScreenDidChange(displayID);
+}
+
bool AsyncScrollingCoordinator::isRubberBandInProgress() const
{
return scrollingTree()->isRubberBandInProgress();
Modified: trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h (261875 => 261876)
--- trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h 2020-05-19 18:40:23 UTC (rev 261875)
+++ trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h 2020-05-19 18:41:14 UTC (rev 261876)
@@ -138,6 +138,8 @@
WEBCORE_EXPORT void setSynchronousScrollingReasons(ScrollingNodeID, OptionSet<SynchronousScrollingReason>) final;
WEBCORE_EXPORT bool hasSynchronousScrollingReasons(ScrollingNodeID) const final;
+ WEBCORE_EXPORT void windowScreenDidChange(PlatformDisplayID) final;
+
virtual void scheduleTreeStateCommit() = 0;
void ensureRootStateNodeForFrameView(FrameView&);
Modified: trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h (261875 => 261876)
--- trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h 2020-05-19 18:40:23 UTC (rev 261875)
+++ trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h 2020-05-19 18:41:14 UTC (rev 261876)
@@ -68,6 +68,8 @@
class ScrollingTree;
#endif
+using PlatformDisplayID = uint32_t;
+
class ScrollingCoordinator : public ThreadSafeRefCounted<ScrollingCoordinator> {
public:
static Ref<ScrollingCoordinator> create(Page*);
@@ -179,6 +181,8 @@
virtual void willDestroyScrollableArea(ScrollableArea&) { }
virtual void scrollableAreaScrollbarLayerDidChange(ScrollableArea&, ScrollbarOrientation) { }
+ virtual void windowScreenDidChange(PlatformDisplayID) { }
+
static String synchronousScrollingReasonsAsText(OptionSet<SynchronousScrollingReason>);
String synchronousScrollingReasonsAsText() const;
Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp (261875 => 261876)
--- trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp 2020-05-19 18:40:23 UTC (rev 261875)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp 2020-05-19 18:41:14 UTC (rev 261876)
@@ -527,6 +527,18 @@
return false;
}
+void ScrollingTree::windowScreenDidChange(PlatformDisplayID displayID)
+{
+ LockHolder locker(m_treeStateMutex);
+ m_treeState.displayID = displayID;
+}
+
+PlatformDisplayID ScrollingTree::displayID()
+{
+ LockHolder locker(m_treeStateMutex);
+ return m_treeState.displayID;
+}
+
void ScrollingTree::setScrollingPerformanceLoggingEnabled(bool flag)
{
m_scrollingPerformanceLoggingEnabled = flag;
Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.h (261875 => 261876)
--- trunk/Source/WebCore/page/scrolling/ScrollingTree.h 2020-05-19 18:40:23 UTC (rev 261875)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.h 2020-05-19 18:41:14 UTC (rev 261876)
@@ -54,6 +54,7 @@
class ScrollingTreePositionedNode;
class ScrollingTreeScrollingNode;
enum class EventListenerRegionType : uint8_t;
+using PlatformDisplayID = uint32_t;
class ScrollingTree : public ThreadSafeRefCounted<ScrollingTree> {
friend class ScrollingTreeLatchingController;
@@ -178,6 +179,9 @@
virtual void lockLayersForHitTesting() { }
virtual void unlockLayersForHitTesting() { }
+ void windowScreenDidChange(PlatformDisplayID);
+ PlatformDisplayID displayID();
+
protected:
FloatPoint mainFrameScrollPosition() const;
void setMainFrameScrollPosition(FloatPoint);
@@ -216,6 +220,7 @@
struct TreeState {
EventTrackingRegions eventTrackingRegions;
FloatPoint mainFrameScrollPosition;
+ PlatformDisplayID displayID { 0 };
bool mainFrameIsRubberBanding { false };
bool mainFrameIsScrollSnapping { false };
};
Modified: trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp (261875 => 261876)
--- trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp 2020-05-19 18:40:23 UTC (rev 261875)
+++ trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp 2020-05-19 18:41:14 UTC (rev 261876)
@@ -202,6 +202,25 @@
}
#endif
+void ThreadedScrollingTree::displayDidRefresh(PlatformDisplayID displayID)
+{
+ if (displayID != this->displayID())
+ return;
+
+ // We're on the EventDispatcher thread here.
+
+#if ENABLE(SCROLLING_THREAD)
+ ScrollingThread::dispatch([protectedThis = makeRef(*this)]() {
+ protectedThis->displayDidRefreshOnScrollingThread();
+ });
+#endif
+}
+
+void ThreadedScrollingTree::displayDidRefreshOnScrollingThread()
+{
+ ASSERT(ScrollingThread::isCurrentThread());
+}
+
} // namespace WebCore
#endif // ENABLE(ASYNC_SCROLLING) && ENABLE(SCROLLING_THREAD)
Modified: trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.h (261875 => 261876)
--- trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.h 2020-05-19 18:40:23 UTC (rev 261875)
+++ trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.h 2020-05-19 18:41:14 UTC (rev 261876)
@@ -55,6 +55,8 @@
void invalidate() override;
+ WEBCORE_EXPORT void displayDidRefresh(PlatformDisplayID);
+
protected:
explicit ThreadedScrollingTree(AsyncScrollingCoordinator&);
@@ -76,6 +78,8 @@
bool isThreadedScrollingTree() const override { return true; }
void propagateSynchronousScrollingReasons(const HashSet<ScrollingNodeID>&) override;
+ void displayDidRefreshOnScrollingThread();
+
RefPtr<AsyncScrollingCoordinator> m_scrollingCoordinator;
};
Modified: trunk/Source/WebKit/ChangeLog (261875 => 261876)
--- trunk/Source/WebKit/ChangeLog 2020-05-19 18:40:23 UTC (rev 261875)
+++ trunk/Source/WebKit/ChangeLog 2020-05-19 18:41:14 UTC (rev 261876)
@@ -1,3 +1,20 @@
+2020-05-19 Simon Fraser <[email protected]>
+
+ Push a PlatformDisplayID to scrolling trees, and allow the scrolling thread to get displayDidRefresh notifications
+ https://bugs.webkit.org/show_bug.cgi?id=211034
+
+ Reviewed by Sam Weinig.
+
+ Prep work for webkit.org/b210884.
+
+ Have EventDispatcher call displayDidRefresh() on each scrolling tree it knows about. It calls this
+ on the EventDispatcher thread; the scrolling tree is responsible for bouncing that to the scrolling thread.
+
+ * WebProcess/WebPage/EventDispatcher.cpp:
+ (WebKit::EventDispatcher::displayDidRefreshOnScrollingThread):
+ (WebKit::EventDispatcher::displayWasRefreshed):
+ * WebProcess/WebPage/EventDispatcher.h:
+
2020-05-19 Wenson Hsieh <[email protected]>
[macOS] Drag and drop within a contenteditable area duplicates attachment-backed images
Modified: trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp (261875 => 261876)
--- trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp 2020-05-19 18:40:23 UTC (rev 261875)
+++ trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp 2020-05-19 18:41:14 UTC (rev 261876)
@@ -265,6 +265,12 @@
#if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
void EventDispatcher::displayWasRefreshed(PlatformDisplayID displayID)
{
+#if ENABLE(SCROLLING_THREAD)
+ LockHolder locker(m_scrollingTreesMutex);
+ for (auto keyValuePair : m_scrollingTrees)
+ keyValuePair.value->displayDidRefresh(displayID);
+#endif
+
RunLoop::main().dispatch([displayID]() {
DisplayRefreshMonitorManager::sharedManager().displayWasUpdated(displayID);
});
Modified: trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.h (261875 => 261876)
--- trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.h 2020-05-19 18:40:23 UTC (rev 261875)
+++ trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.h 2020-05-19 18:41:14 UTC (rev 261876)
@@ -102,6 +102,10 @@
void displayWasRefreshed(WebCore::PlatformDisplayID);
#endif
+#if ENABLE(SCROLLING_THREAD)
+ void displayDidRefreshOnScrollingThread(WebCore::PlatformDisplayID);
+#endif
+
Ref<WorkQueue> m_queue;
#if ENABLE(SCROLLING_THREAD)