Title: [106609] trunk/Source/WebCore
Revision
106609
Author
[email protected]
Date
2012-02-02 18:04:51 -0800 (Thu, 02 Feb 2012)

Log Message

Add ScrollingTree class
https://bugs.webkit.org/show_bug.cgi?id=77695

Reviewed by Andreas Kling.

* WebCore.xcodeproj/project.pbxproj:
Add new files.

* page/scrolling/ScrollingCoordinator.cpp:
(WebCore::ScrollingCoordinator::ScrollingCoordinator):
Create a scrolling tree.

(WebCore::ScrollingCoordinator::~ScrollingCoordinator):
Assert that the scrolling tree is null.

(WebCore::ScrollingCoordinator::pageDestroyed):
Null out the scrolling tree member variable and tell it to invalidate itself.

* page/scrolling/ScrollingTree.cpp: Added.

(WebCore::ScrollingTree::invalidate):
Null out the scrolling coordinator, breaking the reference cycle between the scrolling
coordinator and the scrolling tree.

* page/scrolling/ScrollingTree.h: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (106608 => 106609)


--- trunk/Source/WebCore/ChangeLog	2012-02-03 01:49:28 UTC (rev 106608)
+++ trunk/Source/WebCore/ChangeLog	2012-02-03 02:04:51 UTC (rev 106609)
@@ -1,3 +1,31 @@
+2012-02-02  Anders Carlsson  <[email protected]>
+
+        Add ScrollingTree class
+        https://bugs.webkit.org/show_bug.cgi?id=77695
+
+        Reviewed by Andreas Kling.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        Add new files.
+
+        * page/scrolling/ScrollingCoordinator.cpp:
+        (WebCore::ScrollingCoordinator::ScrollingCoordinator):
+        Create a scrolling tree.
+
+        (WebCore::ScrollingCoordinator::~ScrollingCoordinator):
+        Assert that the scrolling tree is null.
+
+        (WebCore::ScrollingCoordinator::pageDestroyed):
+        Null out the scrolling tree member variable and tell it to invalidate itself.
+
+        * page/scrolling/ScrollingTree.cpp: Added.
+
+        (WebCore::ScrollingTree::invalidate):
+        Null out the scrolling coordinator, breaking the reference cycle between the scrolling
+        coordinator and the scrolling tree.
+    
+        * page/scrolling/ScrollingTree.h: Added.
+
 2012-02-02  Tim Dresser  <[email protected]>
 
         Refactor plugin drawing to be more data driven

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (106608 => 106609)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2012-02-03 01:49:28 UTC (rev 106608)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2012-02-03 02:04:51 UTC (rev 106609)
@@ -488,6 +488,8 @@
 		1AA84F04143BA7BD0051D153 /* ScrollElasticityController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AA84F02143BA7BD0051D153 /* ScrollElasticityController.mm */; };
 		1AA84F05143BA7BD0051D153 /* ScrollElasticityController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA84F03143BA7BD0051D153 /* ScrollElasticityController.h */; };
 		1AA8799011CBE846003C664F /* PluginStrategy.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA8798F11CBE846003C664F /* PluginStrategy.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		1AAADDA314DB409F00AF64B3 /* ScrollingTree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAADDA114DB409F00AF64B3 /* ScrollingTree.cpp */; };
+		1AAADDA414DB409F00AF64B3 /* ScrollingTree.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAADDA214DB409F00AF64B3 /* ScrollingTree.h */; };
 		1AB1AE7A0C051FDE00139F4F /* zoomInCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AB1AE780C051FDE00139F4F /* zoomInCursor.png */; };
 		1AB1AE7B0C051FDE00139F4F /* zoomOutCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AB1AE790C051FDE00139F4F /* zoomOutCursor.png */; };
 		1AB33DA512551E320024457A /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AB33DA412551E320024457A /* IOKit.framework */; };
@@ -7204,6 +7206,8 @@
 		1AA84F02143BA7BD0051D153 /* ScrollElasticityController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollElasticityController.mm; sourceTree = "<group>"; };
 		1AA84F03143BA7BD0051D153 /* ScrollElasticityController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollElasticityController.h; sourceTree = "<group>"; };
 		1AA8798F11CBE846003C664F /* PluginStrategy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginStrategy.h; sourceTree = "<group>"; };
+		1AAADDA114DB409F00AF64B3 /* ScrollingTree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollingTree.cpp; sourceTree = "<group>"; };
+		1AAADDA214DB409F00AF64B3 /* ScrollingTree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollingTree.h; sourceTree = "<group>"; };
 		1AB1AE780C051FDE00139F4F /* zoomInCursor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = zoomInCursor.png; sourceTree = "<group>"; };
 		1AB1AE790C051FDE00139F4F /* zoomOutCursor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = zoomOutCursor.png; sourceTree = "<group>"; };
 		1AB33DA412551E320024457A /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = /System/Library/Frameworks/IOKit.framework; sourceTree = "<absolute>"; };
@@ -13919,6 +13923,8 @@
 				1AF62EE514DA22A70041556C /* ScrollingCoordinator.h */,
 				1AF62F2014DAFE790041556C /* ScrollingThread.cpp */,
 				1AF62F2114DAFE790041556C /* ScrollingThread.h */,
+				1AAADDA114DB409F00AF64B3 /* ScrollingTree.cpp */,
+				1AAADDA214DB409F00AF64B3 /* ScrollingTree.h */,
 			);
 			path = scrolling;
 			sourceTree = "<group>";
@@ -24098,6 +24104,7 @@
 				2CF6878A14D32EFF00340F39 /* ElementAttributeData.h in Headers */,
 				1AF62EE814DA22A70041556C /* ScrollingCoordinator.h in Headers */,
 				1AF62F2614DAFEA10041556C /* ScrollingThread.h in Headers */,
+				1AAADDA414DB409F00AF64B3 /* ScrollingTree.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -27026,6 +27033,7 @@
 				1AF62EE714DA22A70041556C /* ScrollingCoordinator.cpp in Sources */,
 				1AF62F2414DAFE910041556C /* ScrollingThreadMac.mm in Sources */,
 				1AF62F2514DAFE9E0041556C /* ScrollingThread.cpp in Sources */,
+				1AAADDA314DB409F00AF64B3 /* ScrollingTree.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp (106608 => 106609)


--- trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp	2012-02-03 01:49:28 UTC (rev 106608)
+++ trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp	2012-02-03 02:04:51 UTC (rev 106609)
@@ -36,6 +36,7 @@
 #include "PlatformWheelEvent.h"
 #include "ScrollAnimator.h"
 #include "ScrollingThread.h"
+#include "ScrollingTree.h"
 #include <wtf/Functional.h>
 #include <wtf/MainThread.h>
 #include <wtf/PassRefPtr.h>
@@ -49,6 +50,7 @@
 
 ScrollingCoordinator::ScrollingCoordinator(Page* page)
     : m_page(page)
+    , m_scrollingTree(ScrollingTree::create(this))
     , m_didDispatchDidUpdateMainFrameScrollPosition(false)
 {
 }
@@ -56,12 +58,16 @@
 ScrollingCoordinator::~ScrollingCoordinator()
 {
     ASSERT(!m_page);
+    ASSERT(!m_scrollingTree);
 }
 
 void ScrollingCoordinator::pageDestroyed()
 {
     ASSERT(m_page);
     m_page = 0;
+
+    // Invalidating the scrolling tree will break the reference cycle between the ScrollingCoordinator and ScrollingTree objects.
+    ScrollingThread::dispatch(bind(&ScrollingTree::invalidate, m_scrollingTree.release()));
 }
 
 bool ScrollingCoordinator::coordinatesScrollingForFrameView(FrameView* frameView) const

Modified: trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h (106608 => 106609)


--- trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h	2012-02-03 01:49:28 UTC (rev 106608)
+++ trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h	2012-02-03 02:04:51 UTC (rev 106609)
@@ -44,6 +44,7 @@
 class GraphicsLayer;
 class Page;
 class PlatformWheelEvent;
+class ScrollingTree;
 
 #if ENABLE(GESTURE_EVENTS)
 class PlatformGestureEvent;
@@ -96,6 +97,7 @@
 
 private:
     Page* m_page;
+    RefPtr<ScrollingTree> m_scrollingTree;
 
     Mutex m_mainFrameGeometryMutex;
     IntRect m_mainFrameVisibleContentRect;

Added: trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp (0 => 106609)


--- trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp	                        (rev 0)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp	2012-02-03 02:04:51 UTC (rev 106609)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ScrollingTree.h"
+
+#if ENABLE(THREADED_SCROLLING)
+
+#include "ScrollingCoordinator.h"
+#include "ScrollingThread.h"
+
+namespace WebCore {
+
+PassRefPtr<ScrollingTree> ScrollingTree::create(ScrollingCoordinator* scrollingCoordinator)
+{
+    return adoptRef(new ScrollingTree(scrollingCoordinator));
+}
+
+ScrollingTree::ScrollingTree(ScrollingCoordinator* scrollingCoordinator)
+    : m_scrollingCoordinator(scrollingCoordinator)
+{
+}
+
+ScrollingTree::~ScrollingTree()
+{
+    ASSERT(!m_scrollingCoordinator);
+}
+
+void ScrollingTree::invalidate()
+{
+    // Invalidate is dispatched by the ScrollingCoordinator class on the ScrollingThread
+    // to break the reference cycle between ScrollingTree and ScrollingCoordinator when the
+    // ScrollingCoordinator's page is destroyed.
+    ASSERT(ScrollingThread::isCurrentThread());
+    m_scrollingCoordinator = nullptr;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(THREADED_SCROLLING)

Added: trunk/Source/WebCore/page/scrolling/ScrollingTree.h (0 => 106609)


--- trunk/Source/WebCore/page/scrolling/ScrollingTree.h	                        (rev 0)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.h	2012-02-03 02:04:51 UTC (rev 106609)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ScrollingTree_h
+#define ScrollingTree_h
+
+#if ENABLE(THREADED_SCROLLING)
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+#include <wtf/ThreadSafeRefCounted.h>
+
+namespace WebCore {
+
+class ScrollingCoordinator;
+
+// The ScrollingTree class lives almost exclusively on the scrolling thread and manages the
+// hierarchy of scrollable regions on the page. It's also responsible for dispatching events
+// to the correct scrolling tree nodes or dispatching events back to the ScrollingCoordinator
+// object on the main thread if they can't be handled on the scrolling thread for various reasons.
+class ScrollingTree : public ThreadSafeRefCounted<ScrollingTree> {
+public:
+    static PassRefPtr<ScrollingTree> create(ScrollingCoordinator*);
+    ~ScrollingTree();
+
+    void invalidate();
+
+private:
+    explicit ScrollingTree(ScrollingCoordinator*);
+
+    RefPtr<ScrollingCoordinator> m_scrollingCoordinator;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(THREADED_SCROLLING)
+
+#endif // ScrollingTree_h
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to