ASSERT(m_children.isEmpty()) in PlatformCALayerRemote::removeAllSublayers() on time.com
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Apr 2014 23:28:42 +0000 (23:28 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Apr 2014 23:28:42 +0000 (23:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=131187

Reviewed by Maciej Stachowiak.

After a call to PlatformCALayerRemote::adoptSublayers() when a layer
toggles between tiled and non-tiled, we'd assert in PlatformCALayerRemote::removeAllSublayers()
that not all sublayers had been removed (there was one with a null superlayer).

Fix by ensuring that we don't copy over custom subviews when adoptSublayers()
is called; they'll get added as we update children anyway.

* WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
(WebKit::PlatformCALayerRemote::adoptSublayers):

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

Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp

index 6f1caf0..9b8c0b8 100644 (file)
@@ -1,3 +1,20 @@
+2014-04-03  Simon Fraser  <simon.fraser@apple.com>
+
+        ASSERT(m_children.isEmpty()) in PlatformCALayerRemote::removeAllSublayers() on time.com
+        https://bugs.webkit.org/show_bug.cgi?id=131187
+
+        Reviewed by Maciej Stachowiak.
+        
+        After a call to PlatformCALayerRemote::adoptSublayers() when a layer
+        toggles between tiled and non-tiled, we'd assert in PlatformCALayerRemote::removeAllSublayers()
+        that not all sublayers had been removed (there was one with a null superlayer).
+        
+        Fix by ensuring that we don't copy over custom subviews when adoptSublayers()
+        is called; they'll get added as we update children anyway.
+
+        * WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
+        (WebKit::PlatformCALayerRemote::adoptSublayers):
+
 2014-04-03  Benjamin Poulain  <bpoulain@apple.com>
 
         [iOS][WK2] Add SPI to handle animated resize
index 923e18d..271604f 100644 (file)
@@ -264,7 +264,17 @@ void PlatformCALayerRemote::replaceSublayer(PlatformCALayer* reference, Platform
 
 void PlatformCALayerRemote::adoptSublayers(PlatformCALayer* source)
 {
-    setSublayers(toPlatformCALayerRemote(source)->m_children);
+    PlatformCALayerList layersToMove = toPlatformCALayerRemote(source)->m_children;
+
+    if (const PlatformCALayerList* customLayers = source->customSublayers()) {
+        for (const auto& layer : *customLayers) {
+            size_t layerIndex = layersToMove.find(layer);
+            if (layerIndex != notFound)
+                layersToMove.remove(layerIndex);
+        }
+    }
+
+    setSublayers(layersToMove);
 }
 
 void PlatformCALayerRemote::addAnimationForKey(const String& key, PlatformCAAnimation* animation)