[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198

andersca at apple.com andersca at apple.com
Mon Feb 21 00:33:43 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit 3fd79996a72f231883371f0bf965d6360a508c36
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Feb 1 21:57:49 2011 +0000

    2011-02-01  Anders Carlsson  <andersca at apple.com>
    
            Reviewed by Adam Roben.
    
            Make LayerTreeHost ref counted
            https://bugs.webkit.org/show_bug.cgi?id=53530
    
            LayerTreeHostMac will soon be able to trigger layout, which could cause
            the page to leave accelerated compositing mode and free the LayerTreeHostMac object.
    
            Making LayerTreeHost ref counted will let LayerTreeHostMac protect itself while triggering layout.
    
            * WebProcess/WebPage/DrawingAreaImpl.cpp:
            (WebKit::DrawingAreaImpl::setRootCompositingLayer):
            * WebProcess/WebPage/DrawingAreaImpl.h:
            * WebProcess/WebPage/LayerTreeHost.cpp:
            (WebKit::LayerTreeHost::create):
            * WebProcess/WebPage/LayerTreeHost.h:
            * WebProcess/WebPage/mac/LayerTreeHostMac.h:
            * WebProcess/WebPage/mac/LayerTreeHostMac.mm:
            (WebKit::LayerTreeHostMac::create):
            (WebKit::LayerTreeHostMac::LayerTreeHostMac):
            (WebKit::LayerTreeHostMac::~LayerTreeHostMac):
            (WebKit::LayerTreeHostMac::invalidate):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@77293 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog
index 0f2cf39..f5f7976 100644
--- a/Source/WebKit2/ChangeLog
+++ b/Source/WebKit2/ChangeLog
@@ -1,3 +1,28 @@
+2011-02-01  Anders Carlsson  <andersca at apple.com>
+
+        Reviewed by Adam Roben.
+
+        Make LayerTreeHost ref counted
+        https://bugs.webkit.org/show_bug.cgi?id=53530
+
+        LayerTreeHostMac will soon be able to trigger layout, which could cause
+        the page to leave accelerated compositing mode and free the LayerTreeHostMac object.
+
+        Making LayerTreeHost ref counted will let LayerTreeHostMac protect itself while triggering layout.
+
+        * WebProcess/WebPage/DrawingAreaImpl.cpp:
+        (WebKit::DrawingAreaImpl::setRootCompositingLayer):
+        * WebProcess/WebPage/DrawingAreaImpl.h:
+        * WebProcess/WebPage/LayerTreeHost.cpp:
+        (WebKit::LayerTreeHost::create):
+        * WebProcess/WebPage/LayerTreeHost.h:
+        * WebProcess/WebPage/mac/LayerTreeHostMac.h:
+        * WebProcess/WebPage/mac/LayerTreeHostMac.mm:
+        (WebKit::LayerTreeHostMac::create):
+        (WebKit::LayerTreeHostMac::LayerTreeHostMac):
+        (WebKit::LayerTreeHostMac::~LayerTreeHostMac):
+        (WebKit::LayerTreeHostMac::invalidate):
+
 2011-02-01  Sam Weinig  <sam at webkit.org>
 
         Reviewed by Beth Dakin.
diff --git a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp
index 0986352..41478a1 100644
--- a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp
+++ b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp
@@ -128,8 +128,10 @@ void DrawingAreaImpl::setRootCompositingLayer(GraphicsLayer* graphicsLayer)
 {
     if (graphicsLayer)
         m_layerTreeHost = LayerTreeHost::create(m_webPage, graphicsLayer);
-    else
+    else {
+        m_layerTreeHost->invalidate();
         m_layerTreeHost = nullptr;
+    }
 }
 
 void DrawingAreaImpl::scheduleCompositingLayerSync()
diff --git a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h
index 659bf21..2bd5562 100644
--- a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h
+++ b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h
@@ -79,7 +79,7 @@ private:
     RunLoop::Timer<DrawingAreaImpl> m_displayTimer;
 
     // The layer tree host that handles accelerated compositing.
-    OwnPtr<LayerTreeHost> m_layerTreeHost;
+    RefPtr<LayerTreeHost> m_layerTreeHost;
 };
 
 } // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.cpp b/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.cpp
index 7c1a12f..975b59d 100644
--- a/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.cpp
+++ b/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.cpp
@@ -36,10 +36,10 @@ using namespace WebCore;
 
 namespace WebKit {
 
-PassOwnPtr<LayerTreeHost> LayerTreeHost::create(WebPage* webPage, GraphicsLayer* graphicsLayer)
+PassRefPtr<LayerTreeHost> LayerTreeHost::create(WebPage* webPage, GraphicsLayer* graphicsLayer)
 {
 #if PLATFORM(MAC)
-    return adoptPtr(static_cast<LayerTreeHost*>(new LayerTreeHostMac(webPage, graphicsLayer)));
+    return LayerTreeHostMac::create(webPage, graphicsLayer);
 #endif
 
     return 0;
diff --git a/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h b/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h
index 9a2b544..f410f87 100644
--- a/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h
+++ b/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h
@@ -26,12 +26,8 @@
 #ifndef LayerTreeHost_h
 #define LayerTreeHost_h
 
-#include <wtf/Noncopyable.h>
-#include <wtf/PassOwnPtr.h>
-
-#if PLATFORM(MAC)
-#include <wtf/RetainPtr.h>
-#endif
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
 
 namespace WebCore {
     class GraphicsLayer;
@@ -41,14 +37,13 @@ namespace WebKit {
 
 class WebPage;
 
-class LayerTreeHost {
-    WTF_MAKE_NONCOPYABLE(LayerTreeHost);
-
+class LayerTreeHost : public RefCounted<LayerTreeHost> {
 public:
-    static PassOwnPtr<LayerTreeHost> create(WebPage*, WebCore::GraphicsLayer*);
+    static PassRefPtr<LayerTreeHost> create(WebPage*, WebCore::GraphicsLayer*);
     virtual ~LayerTreeHost();
 
     virtual void scheduleLayerFlush() = 0;
+    virtual void invalidate() = 0;
 
 protected:
     explicit LayerTreeHost(WebPage*);
diff --git a/Source/WebKit2/WebProcess/WebPage/mac/LayerTreeHostMac.h b/Source/WebKit2/WebProcess/WebPage/mac/LayerTreeHostMac.h
index 96623c8..4e5ecba 100644
--- a/Source/WebKit2/WebProcess/WebPage/mac/LayerTreeHostMac.h
+++ b/Source/WebKit2/WebProcess/WebPage/mac/LayerTreeHostMac.h
@@ -32,19 +32,22 @@
 namespace WebKit {
 
 class LayerTreeHostMac : public LayerTreeHost {
-private:
-    friend class LayerTreeHost;
+public:
+    static PassRefPtr<LayerTreeHostMac> create(WebPage*, WebCore::GraphicsLayer*);
+    ~LayerTreeHostMac();
     
+private:
     explicit LayerTreeHostMac(WebPage*, WebCore::GraphicsLayer*);
-    ~LayerTreeHostMac();
 
     // LayerTreeHost.
     virtual void scheduleLayerFlush();
+    virtual void invalidate();
 
     static void flushPendingLayerChangesRunLoopObserverCallback(CFRunLoopObserverRef, CFRunLoopActivity, void*);
     void flushPendingLayerChangesRunLoopObserverCallback();
     bool flushPendingLayerChanges();
 
+    bool m_isValid;
     RetainPtr<CFRunLoopObserverRef> m_flushPendingLayerChangesRunLoopObserver;
 };
 
diff --git a/Source/WebKit2/WebProcess/WebPage/mac/LayerTreeHostMac.mm b/Source/WebKit2/WebProcess/WebPage/mac/LayerTreeHostMac.mm
index 9a34673..47093a9 100644
--- a/Source/WebKit2/WebProcess/WebPage/mac/LayerTreeHostMac.mm
+++ b/Source/WebKit2/WebProcess/WebPage/mac/LayerTreeHostMac.mm
@@ -35,15 +35,21 @@ using namespace WebCore;
 
 namespace WebKit {
 
+PassRefPtr<LayerTreeHostMac> LayerTreeHostMac::create(WebPage* webPage, GraphicsLayer* graphicsLayer)
+{
+    return adoptRef(new LayerTreeHostMac(webPage, graphicsLayer));
+}
+
 LayerTreeHostMac::LayerTreeHostMac(WebPage* webPage, GraphicsLayer* graphicsLayer)
     : LayerTreeHost(webPage)
+    , m_isValid(true)
 {
 }
 
 LayerTreeHostMac::~LayerTreeHostMac()
 {
-    if (m_flushPendingLayerChangesRunLoopObserver)
-        CFRunLoopObserverInvalidate(m_flushPendingLayerChangesRunLoopObserver.get());
+    ASSERT(!m_isValid);
+    ASSERT(!m_flushPendingLayerChangesRunLoopObserver);
 }
 
 void LayerTreeHostMac::scheduleLayerFlush()
@@ -64,6 +70,18 @@ void LayerTreeHostMac::scheduleLayerFlush()
     CFRunLoopAddObserver(currentRunLoop, m_flushPendingLayerChangesRunLoopObserver.get(), kCFRunLoopCommonModes);
 }
 
+void LayerTreeHostMac::invalidate()
+{
+    ASSERT(m_isValid);
+
+    if (m_flushPendingLayerChangesRunLoopObserver) {
+        CFRunLoopObserverInvalidate(m_flushPendingLayerChangesRunLoopObserver.get());
+        m_flushPendingLayerChangesRunLoopObserver = nullptr;
+    }
+
+    m_isValid = false;
+}
+
 void LayerTreeHostMac::flushPendingLayerChangesRunLoopObserverCallback(CFRunLoopObserverRef, CFRunLoopActivity, void* context)
 {
     static_cast<LayerTreeHostMac*>(context)->flushPendingLayerChangesRunLoopObserverCallback();

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list