Reviewed by Anders.
authorthatcher <thatcher@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Oct 2006 03:00:37 +0000 (03:00 +0000)
committerthatcher <thatcher@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Oct 2006 03:00:37 +0000 (03:00 +0000)
        Bug 11366: Web Inspector should show user agent style rules
        http://bugs.webkit.org/show_bug.cgi?id=11366

        * WebInspector/WebInspector.m:
        (-[WebInspector init]):
        (-[WebInspector showOptionsMenu]):
        (-[WebInspector _toggleShowUserAgentStyles:]):
        * WebInspector/WebInspectorInternal.h:
        * WebInspector/webInspector/inspector.js:

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

WebKit/ChangeLog
WebKit/WebInspector/WebInspector.m
WebKit/WebInspector/WebInspectorInternal.h
WebKit/WebInspector/webInspector/inspector.js

index 0faad2652da3a8df884ab23349ec22bfe3746347..365d5ba6ed534f7f90816bad36f1ad6fda32902f 100644 (file)
@@ -1,3 +1,17 @@
+2006-10-19  Timothy Hatcher  <timothy@apple.com>
+
+        Reviewed by Anders.
+
+        Bug 11366: Web Inspector should show user agent style rules
+        http://bugs.webkit.org/show_bug.cgi?id=11366
+
+        * WebInspector/WebInspector.m:
+        (-[WebInspector init]):
+        (-[WebInspector showOptionsMenu]):
+        (-[WebInspector _toggleShowUserAgentStyles:]):
+        * WebInspector/WebInspectorInternal.h:
+        * WebInspector/webInspector/inspector.js:
+
 2006-10-19  Brady Eidson <beidson@apple.com>
 
         Build fix - 2gig is on that pesky signed/unsigned limit...
index 431ec28edc6360bee3443ab150c9f71e5fec2171..0775467a8bfa1a5f79d63f3ff30ae2d199ee9f44 100644 (file)
@@ -82,6 +82,7 @@ static NSMapTable *lastChildIgnoringWhitespaceCache = NULL;
 
     _private = [[WebInspectorPrivate alloc] init];
     _private->ignoreWhitespace = YES;
+    _private->showUserAgentStyles = YES;
 
     return self;
 }
@@ -326,6 +327,13 @@ static NSMapTable *lastChildIgnoringWhitespaceCache = NULL;
     [item setState:_private->ignoreWhitespace];
     [menu addItem:item];
 
+    item = [[[NSMenuItem alloc] init] autorelease];
+    [item setTitle:@"Show User Agent Styles"];
+    [item setTarget:self];
+    [item setAction:@selector(_toggleShowUserAgentStyles:)];
+    [item setState:_private->showUserAgentStyles];
+    [menu addItem:item];
+
     [NSMenu popUpContextMenu:menu withEvent:[[self window] currentEvent] forView:_private->webView];
     [menu release];
 
@@ -530,6 +538,13 @@ static NSMapTable *lastChildIgnoringWhitespaceCache = NULL;
     [self _updateTreeScrollbar];
 }
 
+- (IBAction)_toggleShowUserAgentStyles:(id)sender
+{
+    _private->showUserAgentStyles = !_private->showUserAgentStyles;
+    if (_private->webViewLoaded)
+        [[_private->webView windowScriptObject] evaluateWebScript:@"toggleShowUserAgentStyles()"];
+}
+
 - (void)_highlightNode:(DOMNode *)node
 {
     if (_private->currentHighlight) {
index 498e5d581897a2feba2d19c8d4ebb8883d9e581b..c82e6c161ff2d96e835ca710e9a39e2bdf00f077 100644 (file)
@@ -55,6 +55,7 @@
     NSImage *rightArrowImage;
     NSImage *downArrowImage;
     BOOL ignoreWhitespace;
+    BOOL showUserAgentStyles;
     BOOL webViewLoaded;
     BOOL searchResultsVisible;
     BOOL preventHighlight;
index d51054da318ba5c2aa324e8bb073b0b281edd0b5..54ccb46e6612fe6ee0c098c7c18e4b1715c61073 100644 (file)
@@ -27,6 +27,7 @@
  */
 
 var Inspector = null;
+var showUserAgentStyles = true;
 
 // Property values to omit in the computed style list.
 // If a property has this value, it will be omitted.
@@ -520,7 +521,7 @@ function updateStylePane()
             }
         }
 
-        var matchedStyleRules = focusedNode.ownerDocument.defaultView.getMatchedCSSRules(focusedNode, "");
+        var matchedStyleRules = focusedNode.ownerDocument.defaultView.getMatchedCSSRules(focusedNode, "", !showUserAgentStyles);
         if (matchedStyleRules) {
             for (var i = 0; i < matchedStyleRules.length; i++) {
                 styleRules.push(matchedStyleRules[i]);
@@ -564,6 +565,8 @@ function updateStylePane()
                 sheet = styleRules[i].subtitle;
             else if (styleRules[i].parentStyleSheet && styleRules[i].parentStyleSheet.href)
                 sheet = styleRules[i].parentStyleSheet.href;
+            else if (styleRules[i].parentStyleSheet && !styleRules[i].parentStyleSheet.ownerNode)
+                sheet = "user agent stylesheet";
             else
                 sheet = "inline stylesheet";
             cell.textContent = sheet;
@@ -796,6 +799,12 @@ function toggleStyleShorthand(event)
     stylePropertiesScrollArea.refresh();
 }
 
+function toggleShowUserAgentStyles()
+{
+    showUserAgentStyles = !showUserAgentStyles;
+    updateStylePane();
+}
+
 function selectMappedStyleRule(attrName)
 {
     if (!paneUpdateState["style"])