Title: [90397] trunk/Source/WebCore
Revision
90397
Author
[email protected]
Date
2011-07-05 08:35:19 -0700 (Tue, 05 Jul 2011)

Log Message

2011-07-05  Pavel Feldman  <[email protected]>

        Web Inspector: add "element state" setting to the styles section title.
        https://bugs.webkit.org/show_bug.cgi?id=63932

        Reviewed by Yury Semikhatsky.

        * English.lproj/localizedStrings.js:
        * WebCore.gypi:
        * inspector/front-end/Images/paneElementStateButtons.png: Added.
        * inspector/front-end/StylesSidebarPane.js:
        (WebInspector.StylesSidebarPane.muteEventListener):
        (WebInspector.StylesSidebarPane):
        (WebInspector.StylesSidebarPane.prototype.update):
        (WebInspector.StylesSidebarPane.prototype._rebuildUpdate):
        (WebInspector.StylesSidebarPane.prototype._rebuildSectionsForStyleRules):
        (WebInspector.StylesSidebarPane.prototype.addBlankSection):
        (WebInspector.StylesSidebarPane.prototype.registerShortcuts):
        (WebInspector.StylesSidebarPane.prototype._toggleElementStatePane):
        (WebInspector.StylesSidebarPane.prototype._createElementStatePane.clickListener):
        (WebInspector.StylesSidebarPane.prototype._createElementStatePane.createCheckbox):
        (WebInspector.StylesSidebarPane.prototype._createElementStatePane):
        * inspector/front-end/WebKit.qrc:
        * inspector/front-end/inspector.css:
        (.pane > .title > .pane-title-button:active, .pane > .title > .pane-title-button.toggled):
        (.pane > .title > .pane-title-button.element-state):
        (.styles-element-state-pane):
        (.styles-element-state-pane.expanded):
        (.styles-element-state-pane > table):
        (.styles-element-state-pane input):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (90396 => 90397)


--- trunk/Source/WebCore/ChangeLog	2011-07-05 13:41:50 UTC (rev 90396)
+++ trunk/Source/WebCore/ChangeLog	2011-07-05 15:35:19 UTC (rev 90397)
@@ -1,3 +1,34 @@
+2011-07-05  Pavel Feldman  <[email protected]>
+
+        Web Inspector: add "element state" setting to the styles section title.
+        https://bugs.webkit.org/show_bug.cgi?id=63932
+
+        Reviewed by Yury Semikhatsky.
+
+        * English.lproj/localizedStrings.js:
+        * WebCore.gypi:
+        * inspector/front-end/Images/paneElementStateButtons.png: Added.
+        * inspector/front-end/StylesSidebarPane.js:
+        (WebInspector.StylesSidebarPane.muteEventListener):
+        (WebInspector.StylesSidebarPane):
+        (WebInspector.StylesSidebarPane.prototype.update):
+        (WebInspector.StylesSidebarPane.prototype._rebuildUpdate):
+        (WebInspector.StylesSidebarPane.prototype._rebuildSectionsForStyleRules):
+        (WebInspector.StylesSidebarPane.prototype.addBlankSection):
+        (WebInspector.StylesSidebarPane.prototype.registerShortcuts):
+        (WebInspector.StylesSidebarPane.prototype._toggleElementStatePane):
+        (WebInspector.StylesSidebarPane.prototype._createElementStatePane.clickListener):
+        (WebInspector.StylesSidebarPane.prototype._createElementStatePane.createCheckbox):
+        (WebInspector.StylesSidebarPane.prototype._createElementStatePane):
+        * inspector/front-end/WebKit.qrc:
+        * inspector/front-end/inspector.css:
+        (.pane > .title > .pane-title-button:active, .pane > .title > .pane-title-button.toggled):
+        (.pane > .title > .pane-title-button.element-state):
+        (.styles-element-state-pane):
+        (.styles-element-state-pane.expanded):
+        (.styles-element-state-pane > table):
+        (.styles-element-state-pane input):
+
 2011-06-22  Pavel Podivilov  <[email protected]>
 
         Reviewed by Yury Semikhatsky.

Modified: trunk/Source/WebCore/English.lproj/localizedStrings.js


(Binary files differ)

Modified: trunk/Source/WebCore/WebCore.gypi (90396 => 90397)


--- trunk/Source/WebCore/WebCore.gypi	2011-07-05 13:41:50 UTC (rev 90396)
+++ trunk/Source/WebCore/WebCore.gypi	2011-07-05 15:35:19 UTC (rev 90397)
@@ -6424,6 +6424,7 @@
             'inspector/front-end/Images/paneAddButtons.png',
             'inspector/front-end/Images/paneBottomGrow.png',
             'inspector/front-end/Images/paneBottomGrowActive.png',
+            'inspector/front-end/Images/paneElementStateButtons.png',
             'inspector/front-end/Images/paneFilterButtons.png',
             'inspector/front-end/Images/paneGrowHandleLine.png',
             'inspector/front-end/Images/paneRefreshButtons.png',

Added: trunk/Source/WebCore/inspector/front-end/Images/paneElementStateButtons.png


(Binary files differ)
Property changes on: trunk/Source/WebCore/inspector/front-end/Images/paneElementStateButtons.png ___________________________________________________________________

Added: svn:mime-type

Modified: trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js (90396 => 90397)


--- trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js	2011-07-05 13:41:50 UTC (rev 90396)
+++ trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js	2011-07-05 15:35:19 UTC (rev 90397)
@@ -55,13 +55,20 @@
     this.settingsSelectElement.appendChild(option);
 
     // Prevent section from collapsing.
-    this.settingsSelectElement.addEventListener("click", function(event) { event.stopPropagation() }, false);
+    var muteEventListener = function(event) { event.stopPropagation(); event.preventDefault(); };
 
+    this.settingsSelectElement.addEventListener("click", muteEventListener, true);
     this.settingsSelectElement.addEventListener("change", this._changeSetting.bind(this), false);
     this._updateColorFormatFilter();
 
     this.titleElement.appendChild(this.settingsSelectElement);
 
+    this._elementStateButton = document.createElement("button");
+    this._elementStateButton.className = "pane-title-button element-state";
+    this._elementStateButton.title = WebInspector.UIString("Toggle Element State");
+    this._elementStateButton.addEventListener("click", this._toggleElementStatePane.bind(this), false);
+    this.titleElement.appendChild(this._elementStateButton);
+
     var addButton = document.createElement("button");
     addButton.className = "pane-title-button add";
     addButton.title = WebInspector.UIString("New Style Rule");
@@ -71,6 +78,11 @@
     this._computedStylePane = computedStylePane;
     this.element.addEventListener("contextmenu", this._contextMenuEventFired.bind(this), true);
     WebInspector.settings.colorFormat.addChangeListener(this._colorFormatSettingChanged.bind(this));
+
+    this._createElementStatePane();
+    this.bodyElement.appendChild(this._elementStatePane);
+    this._sectionsContainer = document.createElement("div");
+    this.bodyElement.appendChild(this._sectionsContainer);
 }
 
 WebInspector.StylesSidebarPane.ColorFormat = {
@@ -220,7 +232,7 @@
             node = this.node;
 
         if (!node) {
-            this.bodyElement.removeChildren();
+            this._sectionsContainer.removeChildren();
             this._computedStylePane.bodyElement.removeChildren();
             this.sections = {};
             if (callback)
@@ -247,7 +259,7 @@
         if (refresh)
             WebInspector.cssModel.getComputedStyleAsync(node.id, computedStyleCallback.bind(this));
         else
-            WebInspector.cssModel.getStylesAsync(node.id, undefined, stylesCallback.bind(this));
+            WebInspector.cssModel.getStylesAsync(node.id, this._forcedPseudoClasses, stylesCallback.bind(this));
     },
 
     _refreshUpdate: function(node, computedStyle, editedSection)
@@ -265,7 +277,7 @@
 
     _rebuildUpdate: function(node, styles)
     {
-        this.bodyElement.removeChildren();
+        this._sectionsContainer.removeChildren();
         this._computedStylePane.bodyElement.removeChildren();
 
         var styleRules = this._rebuildStyleRules(node, styles);
@@ -506,7 +518,7 @@
                         separatorElement.textContent = WebInspector.UIString("Pseudo element");
                 } else
                     separatorElement.textContent = styleRule.text;
-                this.bodyElement.insertBefore(separatorElement, anchorElement);
+                this._sectionsContainer.insertBefore(separatorElement, anchorElement);
                 lastWasSeparator = true;
                 continue;
             }
@@ -528,7 +540,7 @@
                 this._computedStylePane.bodyElement.appendChild(section.element);
                 lastWasSeparator = true;
             } else {
-                this.bodyElement.insertBefore(section.element, anchorElement);
+                this._sectionsContainer.insertBefore(section.element, anchorElement);
                 lastWasSeparator = false;
             }
             sections.push(section);
@@ -596,7 +608,7 @@
         blankSection.pane = this;
 
         var elementStyleSection = this.sections[0][1];
-        this.bodyElement.insertBefore(blankSection.element, elementStyleSection.element.nextSibling);
+        this._sectionsContainer.insertBefore(blankSection.element, elementStyleSection.element.nextSibling);
 
         this.sections[0].splice(2, 0, blankSection);
 
@@ -650,6 +662,74 @@
             shortcut.shortcutToString(shortcut.Keys.PageDown, shortcut.Modifiers.Alt)
         ];
         section.addRelatedKeys(keys, WebInspector.UIString("Increment/decrement by %f", 0.1));
+    },
+
+    _toggleElementStatePane: function(event)
+    {
+        event.stopPropagation();
+        if (!this._elementStateButton.hasStyleClass("toggled")) {
+            this.expand();
+            this._elementStateButton.addStyleClass("toggled");
+            this._elementStatePane.addStyleClass("expanded");
+        } else {
+            this._elementStateButton.removeStyleClass("toggled");
+            this._elementStatePane.removeStyleClass("expanded");
+            // Clear flags on hide.
+            if (this._forcedPseudoClasses) {
+                for (var i = 0; i < this._elementStatePane.inputs.length; ++i)
+                    this._elementStatePane.inputs[i].checked = false;
+                delete this._forcedPseudoClasses;
+                this.update(WebInspector.panels.elements.focusedDOMNode, null, true);
+            }
+        }
+    },
+
+    _createElementStatePane: function()
+    {
+        this._elementStatePane = document.createElement("div");
+        this._elementStatePane.className = "styles-element-state-pane source-code";
+        var table = document.createElement("table");
+
+        var inputs = [];
+        this._elementStatePane.inputs = inputs;
+
+        function clickListener(event)
+        {
+            var pseudoClasses = [];
+            for (var i = 0; i < inputs.length; ++i) {
+                if (inputs[i].checked)
+                    pseudoClasses.push(inputs[i].state);
+            }
+            this._forcedPseudoClasses = pseudoClasses.length ? pseudoClasses : undefined;
+            this.update(WebInspector.panels.elements.focusedDOMNode, null, true);
+        }
+
+        function createCheckbox(state)
+        {
+            var td = document.createElement("td");
+            var label = document.createElement("label");
+            var input = document.createElement("input");
+            input.type = "checkbox";
+            input.state = state;
+            input.addEventListener("click", clickListener.bind(this), false);
+            inputs.push(input);
+            label.appendChild(input);
+            label.appendChild(document.createTextNode(":" + state));
+            td.appendChild(label);
+            return td;
+        }
+
+        var tr = document.createElement("tr");
+        tr.appendChild(createCheckbox.call(this, "active"));
+        tr.appendChild(createCheckbox.call(this, "hover"));
+        table.appendChild(tr);
+
+        tr = document.createElement("tr");
+        tr.appendChild(createCheckbox.call(this, "focus"));
+        tr.appendChild(createCheckbox.call(this, "visited"));
+        table.appendChild(tr);
+
+        this._elementStatePane.appendChild(table);
     }
 }
 
@@ -662,7 +742,7 @@
     this.titleElement.appendChild(showInheritedCheckbox.element);
 
     if (WebInspector.settings.showInheritedComputedStyleProperties.get()) {
-        this.bodyElement.addStyleClass("show-inherited");
+        this._sectionsContainer.addStyleClass("show-inherited");
         showInheritedCheckbox.checked = true;
     }
 
@@ -670,9 +750,9 @@
     {
         WebInspector.settings.showInheritedComputedStyleProperties.set(showInheritedCheckbox.checked);
         if (WebInspector.settings.showInheritedComputedStyleProperties.get())
-            this.bodyElement.addStyleClass("show-inherited");
+            this._sectionsContainer.addStyleClass("show-inherited");
         else
-            this.bodyElement.removeStyleClass("show-inherited");
+            this._sectionsContainer.removeStyleClass("show-inherited");
     }
 
     showInheritedCheckbox.addEventListener(showInheritedToggleFunction.bind(this));

Modified: trunk/Source/WebCore/inspector/front-end/WebKit.qrc (90396 => 90397)


--- trunk/Source/WebCore/inspector/front-end/WebKit.qrc	2011-07-05 13:41:50 UTC (rev 90396)
+++ trunk/Source/WebCore/inspector/front-end/WebKit.qrc	2011-07-05 15:35:19 UTC (rev 90397)
@@ -184,6 +184,7 @@
     <file>Images/paneAddButtons.png</file>
     <file>Images/paneBottomGrow.png</file>
     <file>Images/paneBottomGrowActive.png</file>
+    <file>Images/paneElementStateButtons.png</file>
     <file>Images/paneGrowHandleLine.png</file>
     <file>Images/paneRefreshButtons.png</file>
     <file>Images/paneSettingsButtons.png</file>

Modified: trunk/Source/WebCore/inspector/front-end/inspector.css (90396 => 90397)


--- trunk/Source/WebCore/inspector/front-end/inspector.css	2011-07-05 13:41:50 UTC (rev 90396)
+++ trunk/Source/WebCore/inspector/front-end/inspector.css	2011-07-05 15:35:19 UTC (rev 90397)
@@ -1798,7 +1798,7 @@
     background-position: -23px 0px;
 }
 
-.pane > .title > .pane-title-button:active {
+.pane > .title > .pane-title-button:active, .pane > .title > .pane-title-button.toggled {
     background-position: -46px 0px;
 }
 
@@ -1806,6 +1806,10 @@
     background-image: url(Images/paneAddButtons.png);
 }
 
+.pane > .title > .pane-title-button.element-state {
+    background-image: url(Images/paneElementStateButtons.png);
+}
+
 .pane > .title > .pane-title-button.refresh {
     background-image: url(Images/paneRefreshButtons.png);
 }
@@ -4546,7 +4550,29 @@
     opacity: 0.5;
 }
 
+.styles-element-state-pane {
+    background-color: rgb(240, 240, 240);
+    overflow: hidden;
+    margin-top: -38px;
+    -webkit-transition: margin-top 0.1s ease-in-out;
+    padding-left: 2px;
+}
 
+.styles-element-state-pane.expanded {
+    border-bottom: 1px solid rgb(189, 189, 189);
+    margin-top: 0;
+}
+
+.styles-element-state-pane > table {
+    width: 100%;
+    border-spacing: 0;
+}
+
+.styles-element-state-pane input {
+    margin: 2px;
+    vertical-align: -2px;
+}
+
 .body .styles-section .properties .inherited {
     display: none;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to