New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 604289 link

Starred by 5 users

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Apr 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug



Sign in to add a comment

@media (min-width: 100vw) doesn't always match

Reported by cvreb...@gmail.com, Apr 18 2016

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36

Steps to reproduce the problem:
1. Open the attached testcase in Chrome
2. While looking at the green bar, horizontally resize the window back and forth.

What is the expected behavior?
@media (min-width: 100vw) is a tautology (the viewport's width is always at least 100% of the viewport's width), and thus should always match, thus always making the bar green.

What went wrong?
At certain widths, the media query doesn't match for some reason, causing the bar to turn red.

Did this work before? N/A 

Chrome version: 52.0.2710.0  Channel: canary
OS Version: OS X 10.11.4
Flash Version: Shockwave Flash 21.0 r0

Firefox and Safari behave as expected and don't suffer from this bug.
 
testcase-100vw.html
333 bytes View Download
Components: Blink
Components: -Blink Blink>CSS
confirmed; I'm not sure if this is a CSS issue or a painting issue, though.

Comment 3 by nainar@chromium.org, Apr 19 2016

Status: Available (was: Unconfirmed)

Comment 4 by r...@opera.com, Apr 19 2016

Cc: y...@yoav.ws
This is a double precision issue in MediaValues::computeLengthImpl().

One example is when the width is 821. We first divide the viewport width by 100.0 to find a factor to multiply the value in the media query with. We divide 821/100.0, but 8.21 does not have an accurate representation for double precision. We end up with a min-width value of 821,00000000000011 which is greater than 821. Multiplying before dividing would have worked better in this case.

Comment 5 by y...@yoav.ws, Apr 20 2016

Cc: -y...@yoav.ws
Owner: y...@yoav.ws
Status: Started (was: Available)
Thanks for analyzing this issue! :) Patch to fix it is at https://codereview.chromium.org/1904523002/
Project Member

Comment 6 by bugdroid1@chromium.org, Apr 20 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/ee8bfd6290293a1b5dbf0813b6b3987f0e1ca545

commit ee8bfd6290293a1b5dbf0813b6b3987f0e1ca545
Author: yoav <yoav@yoav.ws>
Date: Wed Apr 20 11:18:31 2016

Fix double comparisons for Media Queries

Media queries that require double-based length comparisons weren't handled correctly.
As a result, some media queries weren't matching when they should have.

This CL fixes this issue by:
* Performing the length calculation in a more double-friendly way, by multiplying before dividing rather than the other way around.
* Apply a certain precision to length calculations, so that we could compare double equality.

BUG= 604289 

Review URL: https://codereview.chromium.org/1904523002

Cr-Commit-Position: refs/heads/master@{#388464}

[modify] https://crrev.com/ee8bfd6290293a1b5dbf0813b6b3987f0e1ca545/third_party/WebKit/Source/core/css/MediaQueryEvaluator.cpp
[modify] https://crrev.com/ee8bfd6290293a1b5dbf0813b6b3987f0e1ca545/third_party/WebKit/Source/core/css/MediaQueryEvaluatorTest.cpp
[modify] https://crrev.com/ee8bfd6290293a1b5dbf0813b6b3987f0e1ca545/third_party/WebKit/Source/core/css/MediaValues.cpp
[modify] https://crrev.com/ee8bfd6290293a1b5dbf0813b6b3987f0e1ca545/third_party/WebKit/Source/core/css/MediaValuesTest.cpp

Comment 7 by y...@yoav.ws, Apr 20 2016

Status: Fixed (was: Started)

Sign in to add a comment