Closed Bug 836329 Opened 12 years ago Closed 12 years ago

Rem Media Query Condition Bug

Categories

(Core :: CSS Parsing and Computation, defect, P2)

18 Branch
defect

Tracking

()

VERIFIED FIXED
mozilla21
Tracking Status
firefox18 --- affected
firefox19 --- affected
firefox20 --- verified
firefox21 --- verified

People

(Reporter: grayghost, Assigned: dbaron)

References

()

Details

(Keywords: regression)

Attachments

(1 file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.56 Safari/537.17 Steps to reproduce: Preface: This worked in previous versions < 18.0.1 but not as of 1/30/13. Demo of Firefox Bug: http://cdpn.io/AFjDK Actual results: The demo's media query condition for the column count should convert to 1 column below 50rem but doesn't as of Firefox 18.0.1. This bug was also reported for webkit but has been resolved as of 1/30/13. It seems Firefox is playing browser ping pong. Expected results: The media query should snap the column count to 1 w/conditions < 50 rem. However, this condition does switch to 2 columns as it should for conditions >= 50rem.
Component: Untriaged → Style System (CSS)
Product: Firefox → Core
Looks like the behavior changed in http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=5ecff3e46ed5&tochange=f9acc2e4d4e3 Given that, possibly a regression from bug 804970...
Blocks: 804970
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: regression
So we get into nsRuleNode::CalcLengthWithInitialFont, called from nsMediaExpression::Matches. This calls: 434 return CalcLengthWith(aValue, -1, &defaultFont, 435 nullptr, aPresContext, 436 true, false, canStoreInRuleTree); which is passing -1 for aFontSize and true for aUseProvidedRootEmSize. Which means we end up setting rootFontSize to -1 and then returning "-50" as the value to compare to the actual viewport width, which is clearly broken. What I don't understand is how this could have possibly worked...
Flags: needinfo?(dbaron)
(In reply to Boris Zbarsky (:bz) from comment #2) > So we get into nsRuleNode::CalcLengthWithInitialFont, called from > nsMediaExpression::Matches. This calls: > > 434 return CalcLengthWith(aValue, -1, &defaultFont, > 435 nullptr, aPresContext, > 436 true, false, canStoreInRuleTree); > > which is passing -1 for aFontSize and true for aUseProvidedRootEmSize. > Which means we end up setting rootFontSize to -1 and then returning "-50" as > the value to compare to the actual viewport width, which is clearly broken. > > What I don't understand is how this could have possibly worked... Probably because the fixup for aFontSize == -1 moved across to after the 'rem' code in https://hg.mozilla.org/releases/mozilla-aurora/rev/1f9ef298ceeb because I didn't want the broader aStyleContext dependency in code where aCanStoreInRuleTree was set to false.
Flags: needinfo?(dbaron)
I confirmed that the added tests fail without the patch and pass with the patch.
Attachment #712736 - Flags: review?(bzbarsky)
Assignee: nobody → dbaron
Comment on attachment 712736 [details] [diff] [review] Fix regression handling 'rem' units in media queries. r=me
Attachment #712736 - Flags: review?(bzbarsky) → review+
Comment on attachment 712736 [details] [diff] [review] Fix regression handling 'rem' units in media queries. [Approval Request Comment] Bug caused by (feature/regressing bug #): bug 804970 User impact if declined: media queries using 'rem' units produce incorrect results Testing completed (on m-c, etc.): on m-c (shortly), mochitests in patch Risk to taking this patch (and alternatives if risky): very low; patch targeted to the specific case that broke String or UUID changes made by this patch: none
Attachment #712736 - Flags: approval-mozilla-aurora?
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla21
Comment on attachment 712736 [details] [diff] [review] Fix regression handling 'rem' units in media queries. Low risk fix for a regression found in FF18, this is appropriate for landing to Aurora 20.
Attachment #712736 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
http://cdpn.io/AFjDK The 2 columns become 1 column when reducing the browser's size. Verified fixed FF 20.0a2, 21.0a1 (2013-02-17) Win 7
Status: RESOLVED → VERIFIED
But the testcase (http://fvsch.com/code/bugs/rem-mediaquery/) from https://bugs.webkit.org/show_bug.cgi?id=78295 seems to not be completely fixed in FF 20, 21. The background is not changing right when hitting the colored bars.
That testcase is just wrong. It even says so itself, if you read carefully enough, though it's pretty obfuscated.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: