Web Inspector: provide a way to hide user agent styles
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Aug 2011 14:24:15 +0000 (14:24 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Aug 2011 14:24:15 +0000 (14:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=37766

Reviewed by Yury Semikhatsky.

Source/WebCore:

Test: inspector/styles/show-user-agent-styles.html

* English.lproj/localizedStrings.js:
* inspector/front-end/Settings.js:
(WebInspector.Settings):
* inspector/front-end/SettingsScreen.js:
(WebInspector.SettingsScreen):
* inspector/front-end/StylesSidebarPane.js:
(WebInspector.StylesSidebarPane):
(WebInspector.StylesSidebarPane.prototype._rebuildStyleRules.get continue):
(WebInspector.StylesSidebarPane.prototype._rebuildStyleRules):
(WebInspector.StylesSidebarPane.prototype._createElementStatePane):
(WebInspector.StylesSidebarPane.prototype._showUserAgentStylesSettingChanged):

LayoutTests:

* inspector/styles/show-user-agent-styles-expected.txt: Added.
* inspector/styles/show-user-agent-styles.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/inspector/styles/show-user-agent-styles-expected.txt [new file with mode: 0644]
LayoutTests/inspector/styles/show-user-agent-styles.html [new file with mode: 0755]
Source/WebCore/ChangeLog
Source/WebCore/English.lproj/localizedStrings.js
Source/WebCore/inspector/front-end/SettingsScreen.js
Source/WebCore/inspector/front-end/StylesSidebarPane.js

index 138d84a..48584d1 100644 (file)
@@ -1,3 +1,13 @@
+2011-08-09  Pavel Feldman  <pfeldman@google.com>
+
+        Web Inspector: provide a way to hide user agent styles
+        https://bugs.webkit.org/show_bug.cgi?id=37766
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/styles/show-user-agent-styles-expected.txt: Added.
+        * inspector/styles/show-user-agent-styles.html: Added.
+
 2011-08-09  Vsevolod Vlasov  <vsevik@chromium.org>
 
         Web Inspector: REGRESSION (r92672): http/tests/inspector/resource-main-cookies.php failing on Qt Linux Release
diff --git a/LayoutTests/inspector/styles/show-user-agent-styles-expected.txt b/LayoutTests/inspector/styles/show-user-agent-styles-expected.txt
new file mode 100644 (file)
index 0000000..27da530
--- /dev/null
@@ -0,0 +1,36 @@
+Tests that user agent styles are shown based on the setting: https://bugs.webkit.org/show_bug.cgi?id=37766.
+
+I'm red.
+
+I'm also red.
+
+
+Running: testShowUserAgentStyles
+WebInspector.settings.showUserAgentStyles = true
+[expanded] element.style { ()
+
+======== Matched CSS Rules ========
+[expanded] h1 { (show-user-agent-styles.html:5)
+background-color: red;
+
+[expanded] h1 { (user agent stylesheet)
+display: block;
+font-size: 2em;
+-webkit-margin-before: 0.67em;
+-webkit-margin-after: 0.67em;
+-webkit-margin-start: 0px;
+-webkit-margin-end: 0px;
+font-weight: bold;
+
+
+
+Running: testShowUserAgentStyles
+WebInspector.settings.showUserAgentStyles = false
+[expanded] element.style { ()
+
+======== Matched CSS Rules ========
+[expanded] h1 { (show-user-agent-styles.html:5)
+background-color: red;
+
+
+
diff --git a/LayoutTests/inspector/styles/show-user-agent-styles.html b/LayoutTests/inspector/styles/show-user-agent-styles.html
new file mode 100755 (executable)
index 0000000..e32c7a9
--- /dev/null
@@ -0,0 +1,57 @@
+<html>
+<head>
+
+<style>
+h1 {
+    background-color: red;
+}
+</style>
+
+<script src="../../http/tests/inspector/inspector-test.js"></script>
+<script src="../../http/tests/inspector/elements-test.js"></script>
+<script>
+
+function test()
+{
+    InspectorTest.runTestSuite([
+        function testShowUserAgentStyles(next)
+        {
+            WebInspector.settings.showUserAgentStyles.set(true);
+            selectNodeAndDumpStyles("inspected", next);
+        },
+
+        function testShowUserAgentStyles(next)
+        {
+            WebInspector.settings.showUserAgentStyles.set(false);
+            selectNodeAndDumpStyles("other", next);
+        }
+    ]);
+
+    function selectNodeAndDumpStyles(nodeId, next)
+    {
+        InspectorTest.addResult("WebInspector.settings.showUserAgentStyles = " + WebInspector.settings.showUserAgentStyles.get());
+        InspectorTest.selectNodeAndWaitForStyles(nodeId, step1);
+
+        function step1()
+        {
+            InspectorTest.dumpSelectedElementStyles(true, false, true);
+            next();
+        }
+    }
+}
+
+</script>
+</head>
+
+<body onload="runTest()">
+<p>
+Tests that user agent styles are shown based on the setting: https://bugs.webkit.org/show_bug.cgi?id=37766.
+</p>
+<h1 id="inspected">
+I'm red.
+</h1>
+<h1 id="other">
+I'm also red.
+</h1>
+</body>
+</html>
index c486a82..54e8859 100644 (file)
@@ -1,3 +1,24 @@
+2011-08-09  Pavel Feldman  <pfeldman@google.com>
+
+        Web Inspector: provide a way to hide user agent styles
+        https://bugs.webkit.org/show_bug.cgi?id=37766
+
+        Reviewed by Yury Semikhatsky.
+
+        Test: inspector/styles/show-user-agent-styles.html
+
+        * English.lproj/localizedStrings.js:
+        * inspector/front-end/Settings.js:
+        (WebInspector.Settings):
+        * inspector/front-end/SettingsScreen.js:
+        (WebInspector.SettingsScreen):
+        * inspector/front-end/StylesSidebarPane.js:
+        (WebInspector.StylesSidebarPane):
+        (WebInspector.StylesSidebarPane.prototype._rebuildStyleRules.get continue):
+        (WebInspector.StylesSidebarPane.prototype._rebuildStyleRules):
+        (WebInspector.StylesSidebarPane.prototype._createElementStatePane):
+        (WebInspector.StylesSidebarPane.prototype._showUserAgentStylesSettingChanged):
+
 2011-08-09  Steve Block  <steveblock@google.com>
 
         JavaMethodJobject is no longer needed by V8
index 93dcb47..d2a2bac 100644 (file)
Binary files a/Source/WebCore/English.lproj/localizedStrings.js and b/Source/WebCore/English.lproj/localizedStrings.js differ
index 992bf8a..f14a30b 100644 (file)
@@ -44,6 +44,7 @@ WebInspector.SettingsScreen = function()
         [ WebInspector.StylesSidebarPane.ColorFormat.HEX, "HEX: #DAC0DE" ],
         [ WebInspector.StylesSidebarPane.ColorFormat.RGB, "RGB: rgb(128, 255, 255)" ],
         [ WebInspector.StylesSidebarPane.ColorFormat.HSL, "HSL: hsl(300, 80%, 90%)" ] ], WebInspector.settings.colorFormat));
+    p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show user agent styles"), WebInspector.settings.showUserAgentStyles));
 
     if (Preferences.canDisableCache) {
         p = this._appendSection(WebInspector.UIString("Network"));
index 004289e..f378ff9 100644 (file)
@@ -87,6 +87,7 @@ WebInspector.StylesSidebarPane = function(computedStylePane)
 
     WebInspector.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheetChanged, this._styleSheetChanged, this);
     WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.AttrModified, this._attributesUpdated, this);
+    WebInspector.settings.showUserAgentStyles.addChangeListener(this._showUserAgentStylesSettingChanged.bind(this));
 }
 
 WebInspector.StylesSidebarPane.ColorFormat = {
@@ -377,6 +378,8 @@ WebInspector.StylesSidebarPane.prototype = {
             styleRules.push({ isStyleSeparator: true, text: WebInspector.UIString("Matched CSS Rules") });
         for (var i = styles.matchedCSSRules.length - 1; i >= 0; --i) {
             var rule = styles.matchedCSSRules[i];
+            if (!WebInspector.settings.showUserAgentStyles.get() && (rule.isUser || rule.isUserAgent))
+                continue;
             styleRules.push({ style: rule.style, selectorText: rule.selectorText, sourceURL: rule.sourceURL, rule: rule, editable: !!(rule.style && rule.style.id) });
         }
 
@@ -420,6 +423,9 @@ WebInspector.StylesSidebarPane.prototype = {
                 if (!this._containsInherited(rulePayload.style))
                     continue;
                 var rule = rulePayload;
+                if (!WebInspector.settings.showUserAgentStyles.get() && (rule.isUser || rule.isUserAgent))
+                    continue;
+
                 if (!separatorInserted) {
                     insertInheritedNodeSeparator(parentNode);
                     separatorInserted = true;
@@ -763,6 +769,11 @@ WebInspector.StylesSidebarPane.prototype = {
         table.appendChild(tr);
 
         this._elementStatePane.appendChild(table);
+    },
+
+    _showUserAgentStylesSettingChanged: function()
+    {
+        this._innerUpdate(false);
     }
 }