Title: [98393] trunk/Source
Revision
98393
Author
commit-qu...@webkit.org
Date
2011-10-25 14:10:12 -0700 (Tue, 25 Oct 2011)

Log Message

Fix teardown in Web*LayerImpl, and add tests for Web*Layer
https://bugs.webkit.org/show_bug.cgi?id=70431

Patch by Antoine Labour <pi...@chromium.org> on 2011-10-25
Reviewed by James Robinson.

* src/WebContentLayerImpl.cpp:
(WebKit::WebContentLayerImpl::~WebContentLayerImpl):
* src/WebExternalTextureLayerImpl.cpp:
(WebKit::WebExternalTextureLayerImpl::~WebExternalTextureLayerImpl):
* src/WebLayerImpl.cpp:
(WebKit::WebLayerImpl::~WebLayerImpl):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h (98392 => 98393)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h	2011-10-25 20:59:15 UTC (rev 98392)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h	2011-10-25 21:10:12 UTC (rev 98393)
@@ -96,13 +96,13 @@
     const IntSize& bounds() const { return m_bounds; }
     virtual IntSize contentBounds() const { return bounds(); }
 
-    void setMasksToBounds(bool masksToBounds) { m_masksToBounds = masksToBounds; }
+    void setMasksToBounds(bool masksToBounds) { m_masksToBounds = masksToBounds; setNeedsCommit(); }
     bool masksToBounds() const { return m_masksToBounds; }
 
     void setName(const String&);
     const String& name() const { return m_name; }
 
-    void setMaskLayer(LayerChromium* maskLayer) { m_maskLayer = maskLayer; }
+    void setMaskLayer(LayerChromium* maskLayer) { m_maskLayer = maskLayer; setNeedsCommit(); }
     LayerChromium* maskLayer() const { return m_maskLayer.get(); }
 
     void setNeedsDisplay(const FloatRect& dirtyRect);

Modified: trunk/Source/WebKit/chromium/ChangeLog (98392 => 98393)


--- trunk/Source/WebKit/chromium/ChangeLog	2011-10-25 20:59:15 UTC (rev 98392)
+++ trunk/Source/WebKit/chromium/ChangeLog	2011-10-25 21:10:12 UTC (rev 98393)
@@ -1,3 +1,17 @@
+2011-10-25  Antoine Labour  <pi...@chromium.org>
+
+        Fix teardown in Web*LayerImpl, and add tests for Web*Layer
+        https://bugs.webkit.org/show_bug.cgi?id=70431
+
+        Reviewed by James Robinson.
+
+        * src/WebContentLayerImpl.cpp:
+        (WebKit::WebContentLayerImpl::~WebContentLayerImpl):
+        * src/WebExternalTextureLayerImpl.cpp:
+        (WebKit::WebExternalTextureLayerImpl::~WebExternalTextureLayerImpl):
+        * src/WebLayerImpl.cpp:
+        (WebKit::WebLayerImpl::~WebLayerImpl):
+
 2011-10-25  Adam Barth  <aba...@webkit.org>
 
         EventTarget.h shouldn't need to know about every feature and ifdef

Modified: trunk/Source/WebKit/chromium/WebKit.gypi (98392 => 98393)


--- trunk/Source/WebKit/chromium/WebKit.gypi	2011-10-25 20:59:15 UTC (rev 98392)
+++ trunk/Source/WebKit/chromium/WebKit.gypi	2011-10-25 21:10:12 UTC (rev 98393)
@@ -81,6 +81,7 @@
             'tests/TreeTestHelpers.h',
             'tests/WebCompositorImplTest.cpp',
             'tests/WebFrameTest.cpp',
+            'tests/WebLayerTest.cpp',
             'tests/WebURLRequestTest.cpp',
             'tests/WebViewTest.cpp',
         ],

Modified: trunk/Source/WebKit/chromium/src/WebContentLayerImpl.cpp (98392 => 98393)


--- trunk/Source/WebKit/chromium/src/WebContentLayerImpl.cpp	2011-10-25 20:59:15 UTC (rev 98392)
+++ trunk/Source/WebKit/chromium/src/WebContentLayerImpl.cpp	2011-10-25 21:10:12 UTC (rev 98393)
@@ -54,11 +54,13 @@
 
 WebContentLayerImpl::~WebContentLayerImpl()
 {
+    setDelegate(0);
 }
 
 void WebContentLayerImpl::setDrawsContent(bool drawsContent)
 {
     m_drawsContent = drawsContent;
+    setNeedsCommit();
 }
 
 bool WebContentLayerImpl::drawsContent() const

Modified: trunk/Source/WebKit/chromium/src/WebExternalTextureLayerImpl.cpp (98392 => 98393)


--- trunk/Source/WebKit/chromium/src/WebExternalTextureLayerImpl.cpp	2011-10-25 20:59:15 UTC (rev 98392)
+++ trunk/Source/WebKit/chromium/src/WebExternalTextureLayerImpl.cpp	2011-10-25 21:10:12 UTC (rev 98393)
@@ -48,6 +48,7 @@
 
 WebExternalTextureLayerImpl::~WebExternalTextureLayerImpl()
 {
+    setDelegate(0);
 }
 
 bool WebExternalTextureLayerImpl::drawsContent() const

Modified: trunk/Source/WebKit/chromium/src/WebLayerImpl.cpp (98392 => 98393)


--- trunk/Source/WebKit/chromium/src/WebLayerImpl.cpp	2011-10-25 20:59:15 UTC (rev 98392)
+++ trunk/Source/WebKit/chromium/src/WebLayerImpl.cpp	2011-10-25 21:10:12 UTC (rev 98393)
@@ -43,6 +43,7 @@
 
 WebLayerImpl::~WebLayerImpl()
 {
+    setDelegate(0);
 }
 
 bool WebLayerImpl::drawsContent() const

Modified: trunk/Source/WebKit/chromium/tests/LayerChromiumTest.cpp (98392 => 98393)


--- trunk/Source/WebKit/chromium/tests/LayerChromiumTest.cpp	2011-10-25 20:59:15 UTC (rev 98392)
+++ trunk/Source/WebKit/chromium/tests/LayerChromiumTest.cpp	2011-10-25 21:10:12 UTC (rev 98393)
@@ -619,9 +619,7 @@
     // notifySyncRequired should not be called, and the dirtyRect should remain still empty.
     EXPECT_CALL(initialDelegate, notifySyncRequired()).Times(0); // old delegate should not be used when setDelegate gives a new delegate.
     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setDelegate(&mockDelegate));
-    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setMasksToBounds(true));
     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setName("Test Layer"));
-    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setMaskLayer(dummyLayer.get()));
     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setVisibleLayerRect(IntRect(0, 0, 40, 50)));
     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setScrollPosition(IntPoint(10, 10)));
     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setUsesLayerScissor(true));
@@ -642,6 +640,8 @@
     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setAnchorPoint(FloatPoint(1.23f, 4.56f)));
     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setAnchorPointZ(0.7f));
     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setBackgroundColor(Color(0.4f, 0.4f, 0.4f)));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setMasksToBounds(true));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setMaskLayer(dummyLayer.get()));
     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setOpacity(0.5f));
     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setOpaque(false));
     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setPosition(FloatPoint(4.0f, 9.0f)));

Added: trunk/Source/WebKit/chromium/tests/WebLayerTest.cpp (0 => 98393)


--- trunk/Source/WebKit/chromium/tests/WebLayerTest.cpp	                        (rev 0)
+++ trunk/Source/WebKit/chromium/tests/WebLayerTest.cpp	2011-10-25 21:10:12 UTC (rev 98393)
@@ -0,0 +1,183 @@
+/*
+ * Copyright (C) 2011 Google 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 "WebLayer.h"
+
+#include "WebContentLayer.h"
+#include "WebContentLayerClient.h"
+#include "WebExternalTextureLayer.h"
+#include "WebFloatPoint.h"
+#include "WebLayerClient.h"
+#include "WebRect.h"
+#include "WebSize.h"
+
+#include <gmock/gmock.h>
+
+using namespace WebKit;
+using namespace testing;
+
+namespace {
+
+class MockWebLayerClient : public WebLayerClient {
+public:
+    MOCK_METHOD0(notifyNeedsComposite, void());
+};
+
+class MockWebContentLayerClient : public WebContentLayerClient {
+public:
+    MOCK_METHOD2(paintContents, void(WebCanvas*, const WebRect& clip));
+};
+
+class WebLayerTest : public Test {
+public:
+    WebLayerTest() { }
+};
+
+// Tests that the client gets called to ask for a composite if we change the
+// fields.
+TEST_F(WebLayerTest, Client)
+{
+    // Base layer.
+    MockWebLayerClient client;
+    EXPECT_CALL(client, notifyNeedsComposite()).Times(AnyNumber());
+    WebLayer layer = WebLayer::create(&client);
+    Mock::VerifyAndClearExpectations(&client);
+
+    WebFloatPoint point(3, 4);
+    EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
+    layer.setAnchorPoint(point);
+    Mock::VerifyAndClearExpectations(&client);
+    EXPECT_EQ(point, layer.anchorPoint());
+
+    EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
+    float anchorZ = 5;
+    layer.setAnchorPointZ(anchorZ);
+    Mock::VerifyAndClearExpectations(&client);
+    EXPECT_EQ(anchorZ, layer.anchorPointZ());
+
+    WebSize size(7, 8);
+    EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
+    layer.setBounds(size);
+    Mock::VerifyAndClearExpectations(&client);
+    EXPECT_EQ(size, layer.bounds());
+
+    EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
+    layer.setMasksToBounds(true);
+    Mock::VerifyAndClearExpectations(&client);
+    EXPECT_TRUE(layer.masksToBounds());
+
+    MockWebLayerClient otherClient;
+    EXPECT_CALL(otherClient, notifyNeedsComposite()).Times(AnyNumber());
+    WebLayer otherLayer = WebLayer::create(&otherClient);
+    EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
+    layer.setMaskLayer(otherLayer);
+    Mock::VerifyAndClearExpectations(&client);
+    EXPECT_EQ(otherLayer, layer.maskLayer());
+
+    EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
+    float opacity = 0.123;
+    layer.setOpacity(opacity);
+    Mock::VerifyAndClearExpectations(&client);
+    EXPECT_EQ(opacity, layer.opacity());
+
+    EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
+    layer.setOpaque(true);
+    Mock::VerifyAndClearExpectations(&client);
+    EXPECT_TRUE(layer.opaque());
+
+    EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
+    layer.setPosition(point);
+    Mock::VerifyAndClearExpectations(&client);
+    EXPECT_EQ(point, layer.position());
+
+    // Texture layer.
+    EXPECT_CALL(client, notifyNeedsComposite()).Times(AnyNumber());
+    WebExternalTextureLayer textureLayer = WebExternalTextureLayer::create(&client);
+    Mock::VerifyAndClearExpectations(&client);
+
+    EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
+    textureLayer.setTextureId(3);
+    Mock::VerifyAndClearExpectations(&client);
+    EXPECT_EQ(3u, textureLayer.textureId());
+
+    EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
+    textureLayer.setFlipped(true);
+    Mock::VerifyAndClearExpectations(&client);
+    EXPECT_TRUE(textureLayer.flipped());
+
+
+    // Content layer.
+    MockWebContentLayerClient contentClient;
+    EXPECT_CALL(contentClient, paintContents(_, _)).Times(AnyNumber());
+    EXPECT_CALL(client, notifyNeedsComposite()).Times(AnyNumber());
+    WebContentLayer contentLayer = WebContentLayer::create(&client, &contentClient);
+    Mock::VerifyAndClearExpectations(&client);
+
+    EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
+    contentLayer.setDrawsContent(false);
+    Mock::VerifyAndClearExpectations(&client);
+    EXPECT_FALSE(contentLayer.drawsContent());
+}
+
+TEST_F(WebLayerTest, Hierarchy)
+{
+    MockWebLayerClient client;
+    EXPECT_CALL(client, notifyNeedsComposite()).Times(AnyNumber());
+    WebLayer layer1 = WebLayer::create(&client);
+    WebLayer layer2 = WebLayer::create(&client);
+
+    EXPECT_TRUE(layer1.parent().isNull());
+    EXPECT_TRUE(layer2.parent().isNull());
+
+    layer1.addChild(layer2);
+    EXPECT_TRUE(layer1.parent().isNull());
+    EXPECT_EQ(layer1, layer2.parent());
+
+    layer2.removeFromParent();
+    EXPECT_TRUE(layer2.parent().isNull());
+
+    layer1.addChild(layer2);
+    EXPECT_EQ(layer1, layer2.parent());
+    layer1.removeAllChildren();
+    EXPECT_TRUE(layer2.parent().isNull());
+
+    MockWebContentLayerClient contentClient;
+    EXPECT_CALL(contentClient, paintContents(_, _)).Times(AnyNumber());
+    WebContentLayer contentLayer = WebContentLayer::create(&client, &contentClient);
+    WebExternalTextureLayer textureLayer = WebExternalTextureLayer::create(&client);
+
+    textureLayer.addChild(contentLayer);
+    contentLayer.addChild(layer1);
+    layer1.addChild(layer2);
+
+    // Release reference on all layers, checking that destruction (which may
+    // generate calls to the client) doesn't crash.
+    layer2.reset();
+    layer1.reset();
+    contentLayer.reset();
+    textureLayer.reset();
+}
+
+}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to