What steps will reproduce the problem? 1. Have an element with an !important css rule and a conflicting inline style 2. Inspect element What is the expected result? I'm expecting the element style to be crossed out as it is not the active style What happens instead? The element style is not crossed out. This can make it very hard to figure out what is going on, as the !important rule can be much farther down in the list of styles. Test case: <html> <head><style type="text/css"> p.foo { display: block !important } </style><body> <p class="foo bar" style="display:none">Hello, world!</p> </body></html> Upstreaming http://code.google.com/p/chromium/issues/detail?id=144209
Created attachment 160421 [details] Patch
Created attachment 160429 [details] Patch
Comment on attachment 160429 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=160429&action=review > Source/WebCore/inspector/front-end/StylesSidebarPane.js:521 > + styleRule.importantProperties = {}; This could be a local variable, see below. > Source/WebCore/inspector/front-end/StylesSidebarPane.js:535 > + if (!isImportant && usedProperties.hasOwnProperty(canonicalName)) I would add || foundImportantProperties.hasOwnProperty(canonicalName) to the condition so that we don't need to store styleRule.importantProperties for the next loop iterations. > Source/WebCore/inspector/front-end/StylesSidebarPane.js:549 > + for (var j = 0; j < i; ++j) { As discussed we can avoid inner loop by using a map to remember the only rule from which this particular property is used.
Please update bug title with a more generic description of this bug.
Comment on attachment 160429 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=160429&action=review >> Source/WebCore/inspector/front-end/StylesSidebarPane.js:535 >> + if (!isImportant && usedProperties.hasOwnProperty(canonicalName)) > > I would add || foundImportantProperties.hasOwnProperty(canonicalName) to the condition so that we don't need to store styleRule.importantProperties for the next loop iterations. This check is done a lot earlier, on the line 529 above. We still need to store importantProperties unless we get a map in, as discussed. >> Source/WebCore/inspector/front-end/StylesSidebarPane.js:549 >> + for (var j = 0; j < i; ++j) { > > As discussed we can avoid inner loop by using a map to remember the only rule from which this particular property is used. Yes, will fix.
Created attachment 160670 [details] Patch
Comment on attachment 160670 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=160670&action=review > Source/WebCore/inspector/front-end/StylesSidebarPane.js:528 > + // No need to check any further if we know an !important value has already been seen. I don't think this comment is needed. > Source/WebCore/inspector/front-end/StylesSidebarPane.js:534 > + // Property is not important in this rule and has encountered earlier - do nothing. I don't think this comment is needed.
Committed r126737: <http://trac.webkit.org/changeset/126737>