Title: [139972] trunk/Source/WebCore
Revision
139972
Author
aand...@chromium.org
Date
2013-01-17 01:07:04 -0800 (Thu, 17 Jan 2013)

Log Message

Web Inspector: add createOption method to WebInspector.StatusBarComboBox
https://bugs.webkit.org/show_bug.cgi?id=107102

Reviewed by Vsevolod Vlasov.

* inspector/front-end/CPUProfileView.js:
* inspector/front-end/ConsoleView.js:
(WebInspector.ConsoleView.prototype._addFrame):
(WebInspector.ConsoleView.prototype._appendContextOption):
* inspector/front-end/StatusBarButton.js:
(WebInspector.StatusBarButton.prototype.set state):
(WebInspector.StatusBarButton.prototype.set visible):
(WebInspector.StatusBarComboBox.prototype.createOption):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (139971 => 139972)


--- trunk/Source/WebCore/ChangeLog	2013-01-17 08:25:56 UTC (rev 139971)
+++ trunk/Source/WebCore/ChangeLog	2013-01-17 09:07:04 UTC (rev 139972)
@@ -1,3 +1,19 @@
+2013-01-17  Andrey Adaikin  <aand...@chromium.org>
+
+        Web Inspector: add createOption method to WebInspector.StatusBarComboBox
+        https://bugs.webkit.org/show_bug.cgi?id=107102
+
+        Reviewed by Vsevolod Vlasov.
+
+        * inspector/front-end/CPUProfileView.js:
+        * inspector/front-end/ConsoleView.js:
+        (WebInspector.ConsoleView.prototype._addFrame):
+        (WebInspector.ConsoleView.prototype._appendContextOption):
+        * inspector/front-end/StatusBarButton.js:
+        (WebInspector.StatusBarButton.prototype.set state):
+        (WebInspector.StatusBarButton.prototype.set visible):
+        (WebInspector.StatusBarComboBox.prototype.createOption):
+
 2013-01-16  Grzegorz Czajkowski  <g.czajkow...@samsung.com>
 
         [EFL][GTK] checkSpellingOfString treats the multiple words as spelled correctly

Modified: trunk/Source/WebCore/inspector/front-end/CPUProfileView.js (139971 => 139972)


--- trunk/Source/WebCore/inspector/front-end/CPUProfileView.js	2013-01-17 08:25:56 UTC (rev 139971)
+++ trunk/Source/WebCore/inspector/front-end/CPUProfileView.js	2013-01-17 09:07:04 UTC (rev 139972)
@@ -56,15 +56,8 @@
 
     this.viewSelectComboBox = new WebInspector.StatusBarComboBox(this._changeView.bind(this));
 
-    var heavyViewOption = document.createElement("option");
-    heavyViewOption.label = WebInspector.UIString("Heavy (Bottom Up)");
-    heavyViewOption.value = WebInspector.CPUProfileView._TypeHeavy;
-    var treeViewOption = document.createElement("option");
-    treeViewOption.label = WebInspector.UIString("Tree (Top Down)");
-    treeViewOption.value = WebInspector.CPUProfileView._TypeTree;
-
-    this.viewSelectComboBox.addOption(heavyViewOption);
-    this.viewSelectComboBox.addOption(treeViewOption);
+    var heavyViewOption = this.viewSelectComboBox.createOption(WebInspector.UIString("Heavy (Bottom Up)"), "", WebInspector.CPUProfileView._TypeHeavy);
+    var treeViewOption = this.viewSelectComboBox.createOption(WebInspector.UIString("Tree (Top Down)"), "", WebInspector.CPUProfileView._TypeTree);
     this.viewSelectComboBox.select(this._viewType.get() === WebInspector.CPUProfileView._TypeHeavy ? heavyViewOption : treeViewOption);
 
     this.percentButton = new WebInspector.StatusBarButton("", "percent-time-status-bar-item");

Modified: trunk/Source/WebCore/inspector/front-end/ConsoleView.js (139971 => 139972)


--- trunk/Source/WebCore/inspector/front-end/ConsoleView.js	2013-01-17 08:25:56 UTC (rev 139971)
+++ trunk/Source/WebCore/inspector/front-end/ConsoleView.js	2013-01-17 09:07:04 UTC (rev 139972)
@@ -150,12 +150,9 @@
      */
     _addFrame: function(contextList)
     {
-        var option = document.createElement("option");
-        option.text = contextList.displayName;
-        option.title = contextList.url;
+        var option = this._frameSelector.createOption(contextList.displayName, contextList.url);
         option._contextList = contextList;
         contextList._consoleOption = option;
-        this._frameSelector.addOption(option);
         contextList.addEventListener(WebInspector.FrameExecutionContextList.EventTypes.ContextsUpdated, this._frameUpdated, this);
         contextList.addEventListener(WebInspector.FrameExecutionContextList.EventTypes.ContextAdded, this._contextAdded, this);
         this._frameChanged();
@@ -201,11 +198,8 @@
     {
         if (!WebInspector.runtimeModel.currentExecutionContext())
             WebInspector.runtimeModel.setCurrentExecutionContext(executionContext);
-        var option = document.createElement("option");
-        option.text = executionContext.name;
-        option.title = executionContext.id;
+        var option = this._contextSelector.createOption(executionContext.name, executionContext.id);
         option._executionContext = executionContext;
-        this._contextSelector.addOption(option);
     },
 
     /**

Modified: trunk/Source/WebCore/inspector/front-end/StatusBarButton.js (139971 => 139972)


--- trunk/Source/WebCore/inspector/front-end/StatusBarButton.js	2013-01-17 08:25:56 UTC (rev 139971)
+++ trunk/Source/WebCore/inspector/front-end/StatusBarButton.js	2013-01-17 09:07:04 UTC (rev 139972)
@@ -65,6 +65,8 @@
 /**
  * @constructor
  * @extends {WebInspector.StatusBarItem}
+ * @param {string} title
+ * @param {string} className
  * @param {number=} states
  */
 WebInspector.StatusBarButton = function(title, className, states)
@@ -134,17 +136,12 @@
         if (this._state === x)
             return;
 
-        if (this.states === 2) {
-            if (x)
-                this.element.addStyleClass("toggled-on");
-            else
-                this.element.removeStyleClass("toggled-on");
-        } else {
-            if (x !== 0) {
-                this.element.removeStyleClass("toggled-" + this._state);
+        if (this.states === 2)
+            this.element.enableStyleClass("toggled-on", x);
+        else {
+            this.element.removeStyleClass("toggled-" + this._state);
+            if (x !== 0)
                 this.element.addStyleClass("toggled-" + x);
-            } else
-                this.element.removeStyleClass("toggled-" + this._state);
         }
         this._state = x;
     },
@@ -173,10 +170,7 @@
         if (this._visible === x)
             return;
 
-        if (x)
-            this.element.removeStyleClass("hidden");
-        else
-            this.element.addStyleClass("hidden");
+        this.element.enableStyleClass("hidden", !x);
         this._visible = x;
     },
 
@@ -303,6 +297,23 @@
     },
 
     /**
+     * @param {string} label
+     * @param {string=} title
+     * @param {string=} value
+     * @return {!Element}
+     */
+    createOption: function(label, title, value)
+    {
+        var option = this._selectElement.createChild("option");
+        option.text = label;
+        if (title)
+            option.title = title;
+        if (typeof value !== "undefined")
+            option.value = value;
+        return option;
+    },
+
+    /**
      * @override
      */
     _applyEnabledState: function()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to