Closed Bug 979574 Opened 10 years ago Closed 9 years ago

[rule-view] important CSS property inherited from parent causes property with the same name on the element to incorrectly be marked as overridden

Categories

(DevTools :: Inspector, defect)

defect
Not set
normal

Tracking

(firefox44 fixed)

RESOLVED FIXED
Firefox 44
Tracking Status
firefox44 --- fixed

People

(Reporter: efpies, Assigned: tromey)

References

()

Details

(Whiteboard: [polish-backlog][difficulty=easy][rule-view-correctness])

Attachments

(2 files, 3 obsolete files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:27.0) Gecko/20100101 Firefox/27.0 (Beta/Release)
Build ID: 20140212131424

Steps to reproduce:

Container have the line-height property set with the !important modifier.
The child have the line-height property set without modifiers.

http://jsfiddle.net/cWLF7/


Actual results:

Firebug strikes child's line-height property as overriden. Parent's property is not striked.
However, child's line-height is actually used, and changing parent's property in the Firebug don't affect on text positioning.


Expected results:

Parent's !important property is used as having the highest priority.
Unfortunately, your expected result doesn't match what the CSS spec says to do, or the behavior of any browser.  !important only affects what the specified value is, and hence the computed value.  That's what gets inherited if the child inherits at all, but if the child has a different specified value it doesn't matter what was specified on the parent.

> Firebug strikes child's line-height property as overriden.

Sounds like a bug in Firebug...
Status: UNCONFIRMED → RESOLVED
Closed: 10 years ago
Resolution: --- → INVALID
Though I just checked, and Firebug does not in fact strike out the "line-height: 3px;" bit, or in fact anything in its style view that I can see...
This is an issue in which the built in developer tools (not Firebug) are showing the wrong property as being active in the rule view.
Component: CSS Parsing and Computation → Developer Tools: Inspector
Product: Core → Firefox
Version: 27 Branch → Trunk
I believe this is happening due to the markOverridden function being too aggressive: https://mxr.mozilla.org/mozilla-central/source/browser/devtools/styleinspector/rule-view.js#328.  It should be checking to make sure the property is not inherited before marking the earlier as overridden.  Even nicer would be if the getApplied() call from the style actor knew which properties would be overridden.
Status: RESOLVED → REOPENED
Ever confirmed: true
Resolution: INVALID → ---
Summary: line-height with !important modifier can be overriden in children → [rule-view] important CSS property inherited from parent causes property with the same name on the element to incorrectly be marked as overridden
Status: REOPENED → NEW
OS: Mac OS X → All
Hardware: x86 → All
Priority: -- → P2
Easy test case - inspect the span on this page:

data:text/html,<style type="text/css">div{line-height: 1.25!important; } span {line-height: 1}</style><div><span>hi</span></div>
Whiteboard: [rule-view-correctness]
Priority: P2 → --
Whiteboard: [rule-view-correctness] → [polish-backlog][difficulty=easy][rule-view-correctness]
Assignee: nobody → ttromey
Status: NEW → ASSIGNED
The test likely depends on the as-authored series.
Depends on: 984880
Attachment #8667533 - Flags: review?(bgrinstead)
Comment on attachment 8667533 [details] [diff] [review]
don't let inherited properties override with !important

Review of attachment 8667533 [details] [diff] [review]:
-----------------------------------------------------------------

Took me a while to step through all the conditions in markOverridden.. Feel like that's some information that we should be able to fetch from the platform  more reliably than computing it all ourselves.  r+ though assuming all other tests are green, and I'd say let's ship it ASAP

::: devtools/client/styleinspector/test/browser_ruleview_mark_overridden_07.js
@@ +9,5 @@
> +
> +const TEST_URI = `
> +  <style type='text/css'>
> +    #testid {
> +      background-color: #f0c;

If you use margin instead of background-color this patch could be landed now, independently from the as-authored series
Attachment #8667533 - Flags: review?(bgrinstead) → review+
(In reply to Brian Grinstead [:bgrins] from comment #9)

> If you use margin instead of background-color this patch could be landed
> now, independently from the as-authored series

Excellent idea.
No longer depends on: 984880
Updated to use margin properties instead.
Attachment #8667533 - Attachment is obsolete: true
This time, a clean patch against fx-team.
Attachment #8668445 - Attachment is obsolete: true
Attachment #8668446 - Flags: review+
The expected results are different before as-authored.
Attachment #8668446 - Attachment is obsolete: true
Attachment #8668508 - Flags: review+
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/178f1ddd2f6a
Status: ASSIGNED → RESOLVED
Closed: 10 years ago9 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 44
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: