Source/WebCore: Web Inspector: dispatch styleSheetChanged event synchronously.
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Mar 2012 12:56:47 +0000 (12:56 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Mar 2012 12:56:47 +0000 (12:56 +0000)
https://bugs.webkit.org/show_bug.cgi?id=81892

Reviewed by Vsevolod Vlasov.

Today, backend generates stylesheet change event synchronously from within set* command.
But CSSStyleModel defers its dispatching until the stylesheet content is available. This
prevents us from ignoring update events from within commands that initiated those updates.

This change makes stylesheet change event dispatch synchronously and delegates stylesheet
content fetching to the event client.

* inspector/front-end/CSSStyleModel.js:
(WebInspector.CSSStyleModel.prototype._fireStyleSheetChanged):
(WebInspector.CSSStyleDeclaration.prototype.insertPropertyAt):
(WebInspector.CSSStyleModelResourceBinding.prototype.setContent):
(WebInspector.CSSStyleModelResourceBinding.prototype._innerSetContent.callbackWrapper):
(WebInspector.CSSStyleModelResourceBinding.prototype._innerSetContent):
(WebInspector.CSSStyleModelResourceBinding.prototype._styleSheetChanged.callback):
(WebInspector.CSSStyleModelResourceBinding.prototype._styleSheetChanged):
(WebInspector.CSSStyleModelResourceBinding.prototype._innerStyleSheetChanged):

Source/WebKit/chromium: [chromium] timing functions are getting incorrectly applied for accelerated css transitions
https://bugs.webkit.org/show_bug.cgi?id=81692

Patch by Ian Vollick <vollick@chromium.org> on 2012-03-21
Reviewed by Adrienne Walker.

* tests/CCAnimationTestCommon.cpp:
(WebCore::addOpacityTransition):
(WebKitTests::addOpacityTransitionToController):
(WebKitTests::addOpacityTransitionToLayer):
* tests/CCAnimationTestCommon.h:
(WebKitTests):
* tests/CCLayerAnimationControllerTest.cpp:
(WebKitTests::TEST):
* tests/CCLayerTreeHostTest.cpp:
(WTF::CCLayerTreeHostTest::dispatchAddInstantAnimation):
(WTF::CCLayerTreeHostTest::dispatchAddAnimation):
(WTF::TEST_F):
(WTF):
(CCLayerTreeHostTestAddAnimationWithTimingFunction):
(WTF::CCLayerTreeHostTestAddAnimationWithTimingFunction::CCLayerTreeHostTestAddAnimationWithTimingFunction):
(WTF::CCLayerTreeHostTestAddAnimationWithTimingFunction::beginTest):
(WTF::CCLayerTreeHostTestAddAnimationWithTimingFunction::animateLayers):
(WTF::CCLayerTreeHostTestAddAnimationWithTimingFunction::afterTest):

LayoutTests: Web Inspector: dispatch styleSheetChanged event synchronously.
https://bugs.webkit.org/show_bug.cgi?id=81892

Reviewed by Vsevolod Vlasov.

* http/tests/inspector/resources-test.js:
(initialize_ResourceTest.InspectorTest.showResource.callbackWrapper):
(initialize_ResourceTest.InspectorTest.showResource.showResourceCallback.visit):
(initialize_ResourceTest.InspectorTest.showResource.showResourceCallback):
(initialize_ResourceTest.InspectorTest.showResource):
(initialize_ResourceTest):
* inspector/styles/styles-history.html:

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

LayoutTests/ChangeLog
LayoutTests/http/tests/inspector/resources-test.js
LayoutTests/inspector/styles/styles-history-expected.txt
LayoutTests/inspector/styles/styles-history.html
Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/CSSStyleModel.js
Source/WebKit/chromium/ChangeLog

index f41f653c48d4541b819999b653f2d4a207dccc85..0935c9dc75c5a6db2d0d0b4c1e580ecaeb0ac1e9 100644 (file)
@@ -1,3 +1,18 @@
+2012-03-22  Pavel Feldman  <pfeldman@chromium.org>
+
+        Web Inspector: dispatch styleSheetChanged event synchronously.
+        https://bugs.webkit.org/show_bug.cgi?id=81892
+
+        Reviewed by Vsevolod Vlasov.
+
+        * http/tests/inspector/resources-test.js:
+        (initialize_ResourceTest.InspectorTest.showResource.callbackWrapper):
+        (initialize_ResourceTest.InspectorTest.showResource.showResourceCallback.visit):
+        (initialize_ResourceTest.InspectorTest.showResource.showResourceCallback):
+        (initialize_ResourceTest.InspectorTest.showResource):
+        (initialize_ResourceTest):
+        * inspector/styles/styles-history.html:
+
 2012-03-22  Kaustubh Atrawalkar  <kaustubh@motorola.com>
 
         blur() on shadow host should work when a shadow host contains a focused element in its shadow DOM subtrees
index 3a9ad255893a2ab16eb07d1a553d9b4a01fdd990..41f9bcaf94301ba7e5b63a0566d11ccd528f6693 100644 (file)
@@ -61,6 +61,15 @@ InspectorTest.runAfterResourcesAreFinished = function(resourceURLs, callback)
 
 InspectorTest.showResource = function(resourceURL, callback)
 {
+    var reported = false;
+    function callbackWrapper(sourceFrame)
+    {
+        if (reported)
+            return;
+        callback(sourceFrame);
+        reported = true;
+    }
+
     function showResourceCallback()
     {
         WebInspector.resourceTreeModel.forAllResources(visit);
@@ -70,9 +79,9 @@ InspectorTest.showResource = function(resourceURL, callback)
                 WebInspector.panels.resources.showResource(resource, 1);
                 var sourceFrame = WebInspector.panels.resources._resourceViewForResource(resource);
                 if (sourceFrame.loaded)
-                    callback(sourceFrame);
+                    callbackWrapper(sourceFrame);
                 else
-                    sourceFrame.addEventListener(WebInspector.SourceFrame.Events.Loaded, callback.bind(null, sourceFrame));
+                    sourceFrame.addEventListener(WebInspector.SourceFrame.Events.Loaded, callbackWrapper.bind(null, sourceFrame));
                 return true;
             }
         }
index ce37845d9c3b145a2796dc24071658f4cc915c92..688e4b231c79368f66092dcda81edd5160d3ee1e 100644 (file)
@@ -5,14 +5,14 @@ Running: testSetUp
 
 Running: testSetResourceContentMinor
 History length: 0
-
-Running: testSetResourceContentMajor
 Item <tip>:
 body {
   margin: 10px;
   padding: 10px;
 }
 
+
+Running: testSetResourceContentMajor
 History length: 1
 Item 0:
 body {
index 4689532582943f8c7bf1b635383a3b488ac5c495..cbe7626c3d1970b8ad28c23d8a8fb31cb7b92ffd 100644 (file)
@@ -26,7 +26,6 @@ function test()
                     if (resource.url.indexOf("styles-history.css") === -1)
                         return;
                     styleResource = resource;
-                    styleResource.addEventListener(WebInspector.Resource.Events.RevisionAdded, dumpHistory);
                     next();
                 }
                 WebInspector.resourceTreeModel.forAllResources(visitResource);
@@ -34,18 +33,12 @@ function test()
 
             function testSetResourceContentMinor(next)
             {
-                function callback()
-                {
-                    dumpHistory();
-                    next();
-                }
-                styleResource.setContent("body {\n  margin: 15px;\n  padding: 10px;\n}", false, callback);
+                styleResource.setContent("body {\n  margin: 15px;\n  padding: 10px;\n}", false, dumpHistory(next));
             },
 
             function testSetResourceContentMajor(next)
             {
-                waitForRevision(next);
-                styleResource.setContent("body {\n  margin: 20px;\n  padding: 10px;\n}", true);
+                styleResource.setContent("body {\n  margin: 20px;\n  padding: 10px;\n}", true, dumpHistory(next));
             },
 
             function testSetContentViaModelMinor(next)
@@ -56,13 +49,7 @@ function test()
                 {
                     var style = styleSheet.rules[0].style;
                     var property = style.getLiveProperty("margin");
-                    property.setText("margin:25px;", false, true, step2);
-                }
-
-                function step2()
-                {
-                    dumpHistory();
-                    next();
+                    property.setText("margin:25px;", false, true, dumpHistory(next));
                 }
             },
 
@@ -74,8 +61,8 @@ function test()
                 {
                     var style = styleSheet.rules[0].style;
                     var property = style.getLiveProperty("margin");
-                    waitForRevision(next);
                     property.setText("margin:30px;", true, true);
+                    InspectorTest.runAfterPendingDispatches(dumpHistory(next));
                 }
             }
         ]);
@@ -104,28 +91,24 @@ function test()
         }
     }
 
-    function dumpHistory()
+    function dumpHistory(next)
     {
-        InspectorTest.addResult("History length: " + styleResource.history.length);
-        for (var i = 0; i < styleResource.history.length; ++i)
-            styleResource.history[i].requestContent(dumpRevision.bind(this, i));
-        styleResource.requestContent(dumpRevision.bind(this, "<tip>"));
-
-        var copy = pendingCallbacks.slice();
-        pendingCallbacks = [];
-        for (var i = 0; i < copy.length; ++i)
-            copy[i]();
+        function result()
+        {
+            InspectorTest.addResult("History length: " + styleResource.history.length);
+            for (var i = 0; i < styleResource.history.length; ++i)
+                styleResource.history[i].requestContent(dumpRevision.bind(this, i, null));
+            styleResource.requestContent(dumpRevision.bind(this, "<tip>", next));
+        }
+        return result;
     }
 
-    function dumpRevision(index, content)
+    function dumpRevision(index, next, content)
     {
         InspectorTest.addResult("Item " + index + ":");
         InspectorTest.addResult(content);
-    }
-
-    function waitForRevision(callback)
-    {
-        pendingCallbacks.push(callback);
+        if (next)
+            next();
     }
 }
 
index 0479342fc34efe1045977e4a42c1011f7effa23d..ca101fd3840d3455fbbcb44c6329bc077d7e6e30 100644 (file)
@@ -1,3 +1,38 @@
+2012-03-22  Pavel Feldman  <pfeldman@chromium.org>
+
+        Web Inspector: dispatch styleSheetChanged event synchronously.
+        https://bugs.webkit.org/show_bug.cgi?id=81892
+
+        Reviewed by Vsevolod Vlasov.
+
+        Today, backend generates stylesheet change event synchronously from within set* command.
+        But CSSStyleModel defers its dispatching until the stylesheet content is available. This
+        prevents us from ignoring update events from within commands that initiated those updates.
+
+        This change makes stylesheet change event dispatch synchronously and delegates stylesheet
+        content fetching to the event client.
+
+        * inspector/front-end/CSSStyleModel.js:
+        (WebInspector.CSSStyleModel.prototype._fireStyleSheetChanged):
+        (WebInspector.CSSStyleDeclaration.prototype.insertPropertyAt):
+        (WebInspector.CSSStyleModelResourceBinding.prototype.setContent):
+        (WebInspector.CSSStyleModelResourceBinding.prototype._innerSetContent.callbackWrapper):
+        (WebInspector.CSSStyleModelResourceBinding.prototype._innerSetContent):
+        (WebInspector.CSSStyleModelResourceBinding.prototype._styleSheetChanged.callback):
+        (WebInspector.CSSStyleModelResourceBinding.prototype._styleSheetChanged):
+        (WebInspector.CSSStyleModelResourceBinding.prototype._innerStyleSheetChanged):
+
+2012-03-21  Ian Vollick  <vollick@chromium.org>
+
+        [chromium] timing functions are getting incorrectly applied for accelerated css transitions
+        https://bugs.webkit.org/show_bug.cgi?id=81692
+
+        Reviewed by Adrienne Walker.
+
+        Tested in CCLayerTreeHostTestAddAnimationWithTimingFunction
+
+        * platform/graphics/chromium/cc/CCLayerAnimationController.cpp:
+
 2012-03-22  Pavel Feldman  <pfeldman@chromium.org>
 
         Web Inspector: allow on-hover popover while in edit mode.
index b277bbe615e382607171ab8fb61730ce15051343..bcee01d57e3df5da963b4d7ecca1385a3f1fc8c7 100644 (file)
@@ -268,17 +268,11 @@ WebInspector.CSSStyleModel.prototype = {
             return;
 
         var majorChange = this._pendingCommandsMajorState[this._pendingCommandsMajorState.length - 1];
-        
+
         if (!majorChange || !styleSheetId || !this.hasEventListeners(WebInspector.CSSStyleModel.Events.StyleSheetChanged))
             return;
 
-        function callback(error, content)
-        {
-            if (!error)
-                this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.StyleSheetChanged, { styleSheetId: styleSheetId, content: content, majorChange: majorChange });
-        }
-
-        CSSAgent.getStyleSheetText(styleSheetId, callback.bind(this));
+        this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.StyleSheetChanged, { styleSheetId: styleSheetId, majorChange: majorChange });
     },
 
     setStyleSheetText: function(styleSheetId, newText, majorChange, userCallback)
@@ -496,7 +490,7 @@ WebInspector.CSSStyleDeclaration.prototype = {
                 return;
 
             if (error) {
-                console.error(JSON.stringify(error));
+                console.error(error);
                 userCallback(null);
             } else {
                 userCallback(WebInspector.CSSStyleDeclaration.parsePayload(payload));
@@ -811,6 +805,9 @@ WebInspector.CSSStyleModelResourceBinding = function(cssModel)
 WebInspector.CSSStyleModelResourceBinding.prototype = {
     setContent: function(resource, content, majorChange, userCallback)
     {
+        if (majorChange && resource.type === WebInspector.Resource.Type.Stylesheet)
+            resource.addRevision(content);
+
         if (this._urlToStyleSheetId[resource.url]) {
             this._innerSetContent(resource.url, content, majorChange, userCallback, null);
             return;
@@ -843,7 +840,15 @@ WebInspector.CSSStyleModelResourceBinding.prototype = {
                 userCallback("No stylesheet found: " + url);
             return;
         }
-        this._cssModel.setStyleSheetText(styleSheetId, content, majorChange, userCallback);
+
+        this._isSettingContent = true;
+        function callbackWrapper(error)
+        {
+            if (userCallback)
+                userCallback(error);
+            delete this._isSettingContent;
+        }
+        this._cssModel.setStyleSheetText(styleSheetId, content, majorChange, callbackWrapper.bind(this));
     },
 
     _loadStyleSheetHeaders: function(callback)
@@ -867,7 +872,22 @@ WebInspector.CSSStyleModelResourceBinding.prototype = {
 
     _styleSheetChanged: function(event)
     {
-        var styleSheetId = event.data.styleSheetId;
+        if (this._isSettingContent)
+            return;
+
+        if (!event.data.majorChange)
+            return;
+
+        function callback(error, content)
+        {
+            if (!error)
+                this._innerStyleSheetChanged(event.data.styleSheetId, content);
+        }
+        CSSAgent.getStyleSheetText(event.data.styleSheetId, callback.bind(this));
+    },
+
+    _innerStyleSheetChanged: function(styleSheetId, content)
+    {
         function setContent()
         {
             var url = this._styleSheetIdToURL[styleSheetId];
@@ -875,12 +895,8 @@ WebInspector.CSSStyleModelResourceBinding.prototype = {
                 return;
 
             var resource = WebInspector.resourceForURL(url);
-            if (!resource || resource.type !== WebInspector.Resource.Type.Stylesheet)
-                return;
-
-            var majorChange = event.data.majorChange;
-            if (majorChange)
-                resource.addRevision(event.data.content);
+            if (resource && resource.type === WebInspector.Resource.Type.Stylesheet)
+                resource.addRevision(content);
         }
 
         if (!this._styleSheetIdToURL[styleSheetId]) {
index 9417e1378f055de3e15c86fb7201818210534fd5..8f1844a9ddb71a9aa1a3f033fb8d9c4b8e009e24 100644 (file)
@@ -1,3 +1,29 @@
+2012-03-21  Ian Vollick  <vollick@chromium.org>
+
+        [chromium] timing functions are getting incorrectly applied for accelerated css transitions
+        https://bugs.webkit.org/show_bug.cgi?id=81692
+
+        Reviewed by Adrienne Walker.
+
+        * tests/CCAnimationTestCommon.cpp:
+        (WebCore::addOpacityTransition):
+        (WebKitTests::addOpacityTransitionToController):
+        (WebKitTests::addOpacityTransitionToLayer):
+        * tests/CCAnimationTestCommon.h:
+        (WebKitTests):
+        * tests/CCLayerAnimationControllerTest.cpp:
+        (WebKitTests::TEST):
+        * tests/CCLayerTreeHostTest.cpp:
+        (WTF::CCLayerTreeHostTest::dispatchAddInstantAnimation):
+        (WTF::CCLayerTreeHostTest::dispatchAddAnimation):
+        (WTF::TEST_F):
+        (WTF):
+        (CCLayerTreeHostTestAddAnimationWithTimingFunction):
+        (WTF::CCLayerTreeHostTestAddAnimationWithTimingFunction::CCLayerTreeHostTestAddAnimationWithTimingFunction):
+        (WTF::CCLayerTreeHostTestAddAnimationWithTimingFunction::beginTest):
+        (WTF::CCLayerTreeHostTestAddAnimationWithTimingFunction::animateLayers):
+        (WTF::CCLayerTreeHostTestAddAnimationWithTimingFunction::afterTest):
+
 2012-03-22  Kenichi Ishibashi  <bashi@chromium.org>
 
         [Chromium] Should check m_socket in SocketStreamHandleInternal::close()