Title: [117755] trunk/Source/WebCore
Revision
117755
Author
[email protected]
Date
2012-05-21 03:44:10 -0700 (Mon, 21 May 2012)

Log Message

Web Inspector: Annotate CSSStyleModel.js for the closure compiler
https://bugs.webkit.org/show_bug.cgi?id=86858

Reviewed by Yury Semikhatsky.

* inspector/front-end/CSSStyleModel.js:
(WebInspector.CSSStyleDeclaration.parseComputedStylePayload):
(WebInspector.CSSStyleDeclaration.prototype.newBlankProperty):
(WebInspector.CSSStyleDeclaration.prototype.insertPropertyAt):
(WebInspector.CSSProperty.parsePayload):
(WebInspector.CSSProperty.prototype.setText):
(WebInspector.CSSProperty.prototype.setDisabled):
(WebInspector.CSSStyleSheet.prototype.setText):
(WebInspector.CSSStyleModelResourceBinding.prototype._innerSetContent.callbackWrapper):
(WebInspector.CSSStyleModelResourceBinding.prototype._innerSetContent):
(WebInspector.CSSStyleModelResourceBinding.prototype._loadStyleSheetHeaders):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (117754 => 117755)


--- trunk/Source/WebCore/ChangeLog	2012-05-21 10:29:37 UTC (rev 117754)
+++ trunk/Source/WebCore/ChangeLog	2012-05-21 10:44:10 UTC (rev 117755)
@@ -1,3 +1,22 @@
+2012-05-21  Alexander Pavlov  <[email protected]>
+
+        Web Inspector: Annotate CSSStyleModel.js for the closure compiler
+        https://bugs.webkit.org/show_bug.cgi?id=86858
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/front-end/CSSStyleModel.js:
+        (WebInspector.CSSStyleDeclaration.parseComputedStylePayload):
+        (WebInspector.CSSStyleDeclaration.prototype.newBlankProperty):
+        (WebInspector.CSSStyleDeclaration.prototype.insertPropertyAt):
+        (WebInspector.CSSProperty.parsePayload):
+        (WebInspector.CSSProperty.prototype.setText):
+        (WebInspector.CSSProperty.prototype.setDisabled):
+        (WebInspector.CSSStyleSheet.prototype.setText):
+        (WebInspector.CSSStyleModelResourceBinding.prototype._innerSetContent.callbackWrapper):
+        (WebInspector.CSSStyleModelResourceBinding.prototype._innerSetContent):
+        (WebInspector.CSSStyleModelResourceBinding.prototype._loadStyleSheetHeaders):
+
 2012-05-21  Rakesh KN  <[email protected]>
 
         [Forms] Refactor HTMLFormCollection

Modified: trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js (117754 => 117755)


--- trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js	2012-05-21 10:29:37 UTC (rev 117754)
+++ trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js	2012-05-21 10:44:10 UTC (rev 117755)
@@ -42,6 +42,9 @@
     CSSAgent.enable();
 }
 
+/**
+ * @param {Array.<CSSAgent.CSSRule>} ruleArray
+ */
 WebInspector.CSSStyleModel.parseRuleArrayPayload = function(ruleArray)
 {
     var result = [];
@@ -168,7 +171,7 @@
         /**
          * @param {DOMAgent.NodeId} nodeId
          * @param {function(WebInspector.CSSRule, boolean)} successCallback
-         * @param {*} rulePayload
+         * @param {CSSAgent.CSSRule} rulePayload
          * @param {?Array.<DOMAgent.NodeId>} selectedNodeIds
          */
         function checkAffectsCallback(nodeId, successCallback, rulePayload, selectedNodeIds)
@@ -186,7 +189,7 @@
          * @param {function()} failureCallback
          * @param {?Protocol.Error} error
          * @param {string} newSelector
-         * @param {*=} rulePayload
+         * @param {?CSSAgent.CSSRule} rulePayload
          */
         function callback(nodeId, successCallback, failureCallback, newSelector, error, rulePayload)
         {
@@ -215,6 +218,12 @@
      */
     addRule: function(nodeId, selector, successCallback, failureCallback)
     {
+        /**
+         * @param {DOMAgent.NodeId} nodeId
+         * @param {function(WebInspector.CSSRule, boolean)} successCallback
+         * @param {CSSAgent.CSSRule} rulePayload
+         * @param {?Array.<DOMAgent.NodeId>} selectedNodeIds
+         */
         function checkAffectsCallback(nodeId, successCallback, rulePayload, selectedNodeIds)
         {
             if (!selectedNodeIds)
@@ -257,6 +266,9 @@
         this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.MediaQueryResultChanged);
     },
 
+    /**
+     * @param {DOMAgent.NodeId} nodeId
+     */
     _ownerDocumentId: function(nodeId)
     {
         var node = WebInspector.domAgent.nodeForId(nodeId);
@@ -265,6 +277,9 @@
         return node.ownerDocument ? node.ownerDocument.id : null;
     },
 
+    /**
+     * @param {CSSAgent.StyleSheetId} styleSheetId
+     */
     _fireStyleSheetChanged: function(styleSheetId)
     {
         if (!this._pendingCommandsMajorState.length)
@@ -278,6 +293,12 @@
         this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.StyleSheetChanged, { styleSheetId: styleSheetId, majorChange: majorChange });
     },
 
+    /**
+     * @param {CSSAgent.StyleSheetId} styleSheetId
+     * @param {string} newText
+     * @param {boolean} majorChange
+     * @param {function(?string)} userCallback
+     */
     setStyleSheetText: function(styleSheetId, newText, majorChange, userCallback)
     {
         function callback(error)
@@ -308,7 +329,7 @@
 
 /**
  * @constructor
- * @param {*} payload
+ * @param {CSSAgent.CSSStyle} payload
  */
 WebInspector.CSSStyleDeclaration = function(payload)
 {
@@ -351,6 +372,10 @@
         this.cssText = payload.cssText;
 }
 
+/**
+ * @param {Array.<CSSAgent.ShorthandEntry>} shorthandEntries
+ * @return {Object}
+ */
 WebInspector.CSSStyleDeclaration.buildShorthandValueMap = function(shorthandEntries)
 {
     var result = {};
@@ -359,14 +384,22 @@
     return result;
 }
 
+/**
+ * @param {CSSAgent.CSSStyle} payload
+ * @return {WebInspector.CSSStyleDeclaration}
+ */
 WebInspector.CSSStyleDeclaration.parsePayload = function(payload)
 {
     return new WebInspector.CSSStyleDeclaration(payload);
 }
 
+/**
+ * @param {Array.<CSSAgent.CSSComputedStyleProperty>} payload
+ * @return {WebInspector.CSSStyleDeclaration}
+ */
 WebInspector.CSSStyleDeclaration.parseComputedStylePayload = function(payload)
 {
-    var newPayload = { cssProperties: [], shorthandEntries: [], width: "", height: "" };
+    var newPayload = /** @type {CSSAgent.CSSStyle} */ { cssProperties: [], shorthandEntries: [], width: "", height: "" };
     if (payload)
         newPayload.cssProperties = payload;
 
@@ -379,35 +412,58 @@
         return this._allProperties;
     },
 
+    /**
+     * @param {string} name
+     * @return {WebInspector.CSSProperty|undefined}
+     */
     getLiveProperty: function(name)
     {
         return this._livePropertyMap[name];
     },
 
+    /**
+     * @param {string} name
+     * @return {string}
+     */
     getPropertyValue: function(name)
     {
         var property = this._livePropertyMap[name];
         return property ? property.value : "";
     },
 
+    /**
+     * @param {string} name
+     * @return {string}
+     */
     getPropertyPriority: function(name)
     {
         var property = this._livePropertyMap[name];
         return property ? property.priority : "";
     },
 
+    /**
+     * @param {string} name
+     * @return {string}
+     */
     getPropertyShorthand: function(name)
     {
         var property = this._livePropertyMap[name];
         return property ? property.shorthand : "";
     },
 
+    /**
+     * @param {string} name
+     * @return {boolean}
+     */
     isPropertyImplicit: function(name)
     {
         var property = this._livePropertyMap[name];
         return property ? property.implicit : "";
     },
 
+    /**
+     * @return {string}
+     */
     styleTextWithShorthands: function()
     {
         var cssText = "";
@@ -439,17 +495,29 @@
         return cssText;
     },
 
+    /**
+     * @param {string} name
+     * @return {Array.<WebInspector.CSSProperty>}
+     */
     getLonghandProperties: function(name)
     {
         return this._longhandProperties[name] || [];
     },
 
+    /**
+     * @param {string} shorthandProperty
+     * @return {string}
+     */
     getShorthandValue: function(shorthandProperty)
     {
         var property = this.getLiveProperty(shorthandProperty);
         return property ? property.value : this._shorthandValues[shorthandProperty];
     },
 
+    /**
+     * @param {string} shorthandProperty
+     * @return {?string}
+     */
     getShorthandPriority: function(shorthandProperty)
     {
         var priority = this.getPropertyPriority(shorthandProperty);
@@ -460,11 +528,18 @@
         return longhands ? this.getPropertyPriority(longhands[0]) : null;
     },
 
+    /**
+     * @param {number} index
+     * @return {?WebInspector.CSSProperty}
+     */
     propertyAt: function(index)
     {
         return (index < this.allProperties.length) ? this.allProperties[index] : null;
     },
 
+    /**
+     * @return {number}
+     */
     pastLastSourcePropertyIndex: function()
     {
         for (var i = this.allProperties.length - 1; i >= 0; --i) {
@@ -481,11 +556,22 @@
     newBlankProperty: function(index)
     {
         index = (typeof index === "undefined") ? this.pastLastSourcePropertyIndex() : index;
-        return new WebInspector.CSSProperty(this, index, "", "", "", "active", true, false, false, "");
+        return new WebInspector.CSSProperty(this, index, "", "", "", "active", true, false, "", "");
     },
 
+    /**
+     * @param {number} index
+     * @param {string} name
+     * @param {string} value
+     * @param {function(?WebInspector.CSSStyleDeclaration)} userCallback
+     */
     insertPropertyAt: function(index, name, value, userCallback)
     {
+        /**
+         * @param {function(?WebInspector.CSSStyleDeclaration)} userCallback
+         * @param {?string} error
+         * @param {CSSAgent.CSSStyle} payload
+         */
         function callback(userCallback, error, payload)
         {
             WebInspector.cssModel._pendingCommandsMajorState.pop();
@@ -500,10 +586,18 @@
             }
         }
 
+        if (!this.id)
+            throw "No style id";
+
         WebInspector.cssModel._pendingCommandsMajorState.push(true);
         CSSAgent.setPropertyText(this.id, index, name + ": " + value + ";", false, callback.bind(this, userCallback));
     },
 
+    /**
+     * @param {string} name
+     * @param {string} value
+     * @param {function(?WebInspector.CSSStyleDeclaration)} userCallback
+     */
     appendProperty: function(name, value, userCallback)
     {
         this.insertPropertyAt(this.allProperties.length, name, value, userCallback);
@@ -512,6 +606,7 @@
 
 /**
  * @constructor
+ * @param {CSSAgent.CSSRule} payload
  */
 WebInspector.CSSRule = function(payload)
 {
@@ -527,6 +622,10 @@
         this.media = WebInspector.CSSMedia.parseMediaArrayPayload(payload.media);
 }
 
+/**
+ * @param {CSSAgent.CSSRule} payload
+ * @return {WebInspector.CSSRule}
+ */
 WebInspector.CSSRule.parsePayload = function(payload)
 {
     return new WebInspector.CSSRule(payload);
@@ -556,6 +655,16 @@
 
 /**
  * @constructor
+ * @param {?WebInspector.CSSStyleDeclaration} ownerStyle
+ * @param {number} index
+ * @param {string} name
+ * @param {string} value
+ * @param {?string} priority
+ * @param {string} status
+ * @param {boolean} parsedOk
+ * @param {boolean} implicit
+ * @param {string} shorthand
+ * @param {?string=} text
  */
 WebInspector.CSSProperty = function(ownerStyle, index, name, value, priority, status, parsedOk, implicit, shorthand, text)
 {
@@ -571,6 +680,12 @@
     this.text = text;
 }
 
+/**
+ * @param {?WebInspector.CSSStyleDeclaration} ownerStyle
+ * @param {number} index
+ * @param {CSSAgent.CSSProperty} payload
+ * @return {WebInspector.CSSProperty}
+ */
 WebInspector.CSSProperty.parsePayload = function(ownerStyle, index, payload)
 {
     // The following default field values are used in the payload:
@@ -580,7 +695,7 @@
     // status: "style"
     // shorthandName: ""
     var result = new WebInspector.CSSProperty(
-        ownerStyle, index, payload.name, payload.value, payload.priority || "", payload.status || "style", ("parsedOk" in payload) ? payload.parsedOk : true, !!payload.implicit, payload.shorthandName || "", payload.text);
+        ownerStyle, index, payload.name, payload.value, payload.priority || "", payload.status || "style", ("parsedOk" in payload) ? !!payload.parsedOk : true, !!payload.implicit, payload.shorthandName || "", payload.text);
     return result;
 }
 
@@ -626,16 +741,23 @@
      * @param {string} propertyText
      * @param {boolean} majorChange
      * @param {boolean} overwrite
-     * @param {Function=} userCallback
+     * @param {function(?WebInspector.CSSStyleDeclaration)=} userCallback
      */
     setText: function(propertyText, majorChange, overwrite, userCallback)
     {
+        /**
+         * @param {?WebInspector.CSSStyleDeclaration} style
+         */
         function enabledCallback(style)
         {
             if (userCallback)
                 userCallback(style);
         }
 
+        /**
+         * @param {?string} error
+         * @param {?CSSAgent.CSSStyle} stylePayload
+         */
         function callback(error, stylePayload)
         {
             WebInspector.cssModel._pendingCommandsMajorState.pop();
@@ -662,6 +784,9 @@
         if (!this.ownerStyle)
             throw "No ownerStyle for property";
 
+        if (!this.ownerStyle.id)
+            throw "No owner style id";
+
         // An index past all the properties adds a new property to the style.
         WebInspector.cssModel._pendingCommandsMajorState.push(majorChange);
         CSSAgent.setPropertyText(this.ownerStyle.id, this.index, propertyText, overwrite, callback.bind(this));
@@ -671,7 +796,7 @@
      * @param {string} newValue
      * @param {boolean} majorChange
      * @param {boolean} overwrite
-     * @param {Function=} userCallback
+     * @param {function(?WebInspector.CSSStyleDeclaration)=} userCallback
      */
     setValue: function(newValue, majorChange, overwrite, userCallback)
     {
@@ -679,6 +804,10 @@
         this.setText(text, majorChange, overwrite, userCallback);
     },
 
+    /**
+     * @param {boolean} disabled
+     * @param {function(?WebInspector.CSSStyleDeclaration)=} userCallback
+     */
     setDisabled: function(disabled, userCallback)
     {
         if (!this.ownerStyle && userCallback)
@@ -686,6 +815,10 @@
         if (disabled === this.disabled && userCallback)
             userCallback(this.ownerStyle);
 
+        /**
+         * @param {?string} error
+         * @param {CSSAgent.CSSStyle} stylePayload
+         */
         function callback(error, stylePayload)
         {
             WebInspector.cssModel._pendingCommandsMajorState.pop();
@@ -701,6 +834,9 @@
             }
         }
 
+        if (!this.ownerStyle.id)
+            throw "No owner style id";
+
         WebInspector.cssModel._pendingCommandsMajorState.push(false);
         CSSAgent.toggleProperty(this.ownerStyle.id, this.index, disabled, callback.bind(this));
     }
@@ -708,7 +844,7 @@
 
 /**
  * @constructor
- * @param {*} payload
+ * @param {CSSAgent.CSSMedia} payload
  */
 WebInspector.CSSMedia = function(payload)
 {
@@ -725,11 +861,19 @@
     IMPORT_RULE: "importRule"
 };
 
+/**
+ * @param {CSSAgent.CSSMedia} payload
+ * @return {WebInspector.CSSMedia}
+ */
 WebInspector.CSSMedia.parsePayload = function(payload)
 {
     return new WebInspector.CSSMedia(payload);
 }
 
+/**
+ * @param {Array.<CSSAgent.CSSMedia>} payload
+ * @return {Array.<WebInspector.CSSMedia>}
+ */
 WebInspector.CSSMedia.parseMediaArrayPayload = function(payload)
 {
     var result = [];
@@ -740,6 +884,7 @@
 
 /**
  * @constructor
+ * @param {CSSAgent.CSSStyleSheetBody} payload
  */
 WebInspector.CSSStyleSheet = function(payload)
 {
@@ -756,8 +901,16 @@
         this._text = payload.text;
 }
 
+/**
+ * @param {CSSAgent.StyleSheetId} styleSheetId
+ * @param {function(?WebInspector.CSSStyleSheet)} userCallback
+ */
 WebInspector.CSSStyleSheet.createForId = function(styleSheetId, userCallback)
 {
+    /**
+     * @param {?string} error
+     * @param {CSSAgent.CSSStyleSheetBody} styleSheetPayload
+     */
     function callback(error, styleSheetPayload)
     {
         if (error)
@@ -769,13 +922,24 @@
 }
 
 WebInspector.CSSStyleSheet.prototype = {
+    /**
+     * @return {string|undefined}
+     */
     getText: function()
     {
         return this._text;
     },
 
+    /**
+     * @param {string} newText
+     * @param {boolean} majorChange
+     * @param {function(?string)=} userCallback
+     */
     setText: function(newText, majorChange, userCallback)
     {
+        /**
+         * @param {?string} error
+         */
         function callback(error)
         {
             if (!error)
@@ -806,6 +970,12 @@
 }
 
 WebInspector.CSSStyleModelResourceBinding.prototype = {
+    /**
+     * @param {WebInspector.Resource} resource
+     * @param {string} content
+     * @param {boolean} majorChange
+     * @param {function(?string)} userCallback
+     */
     setContent: function(resource, content, majorChange, userCallback)
     {
         if (majorChange && resource.type === WebInspector.resourceTypes.Stylesheet)
@@ -818,11 +988,17 @@
         this._loadStyleSheetHeaders(this._innerSetContent.bind(this, resource.url, content, majorChange, userCallback));
     },
 
+    /**
+     * @return {boolean}
+     */
     canSetContent: function()
     {
         return true;
     },
 
+    /**
+     * @param {WebInspector.Event} event
+     */
     _inspectedURLChanged: function(event)
     {
         // Main frame navigation - clear history.
@@ -830,6 +1006,13 @@
         this._styleSheetIdToURL = {};
     },
 
+    /**
+     * @param {string} url
+     * @param {string} content
+     * @param {boolean} majorChange
+     * @param {function(?string)} userCallback
+     * @param {?string} error
+     */
     _innerSetContent: function(url, content, majorChange, userCallback, error)
     {
         if (error) {
@@ -839,23 +1022,28 @@
 
         var styleSheetId = this._urlToStyleSheetId[url];
         if (!styleSheetId) {
-            if (userCallback)
-                userCallback("No stylesheet found: " + url);
+            userCallback("No stylesheet found: " + url);
             return;
         }
 
         this._isSettingContent = true;
         function callbackWrapper(error)
         {
-            if (userCallback)
-                userCallback(error);
+            userCallback(error);
             delete this._isSettingContent;
         }
         this._cssModel.setStyleSheetText(styleSheetId, content, majorChange, callbackWrapper.bind(this));
     },
 
+    /**
+     * @param {function(?string)} callback
+     */
     _loadStyleSheetHeaders: function(callback)
     {
+        /**
+         * @param {?string} error
+         * @param {Array.<CSSAgent.CSSStyleSheetHeader>} infos
+         */
         function didGetAllStyleSheets(error, infos)
         {
             if (error) {
@@ -868,11 +1056,14 @@
                 this._urlToStyleSheetId[info.sourceURL] = info.styleSheetId;
                 this._styleSheetIdToURL[info.styleSheetId] = info.sourceURL;
             }
-            callback();
+            callback(null);
         }
         CSSAgent.getAllStyleSheets(didGetAllStyleSheets.bind(this));
     },
 
+    /**
+     * @param {WebInspector.Event} event
+     */
     _styleSheetChanged: function(event)
     {
         if (this._isSettingContent)
@@ -881,6 +1072,10 @@
         if (!event.data.majorChange)
             return;
 
+        /**
+         * @param {?string} error
+         * @param {string} content
+         */
         function callback(error, content)
         {
             if (!error)
@@ -889,6 +1084,10 @@
         CSSAgent.getStyleSheetText(event.data.styleSheetId, callback.bind(this));
     },
 
+    /**
+     * @param {CSSAgent.StyleSheetId} styleSheetId
+     * @param {string} content
+     */
     _innerStyleSheetChanged: function(styleSheetId, content)
     {
         function setContent()
@@ -928,6 +1127,9 @@
         this._cssModel.mediaQueryResultChanged();
     },
 
+    /**
+     * @param {CSSAgent.StyleSheetId} styleSheetId
+     */
     styleSheetChanged: function(styleSheetId)
     {
         this._cssModel._fireStyleSheetChanged(styleSheetId);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to