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

Issue 710878 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
NOT IN USE
Closed: Apr 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug



Sign in to add a comment

Chrome ignores all external stylesheets with media queries if none of the media queries is true when the page loads

Reported by priyamca...@gmail.com, Apr 12 2017

Issue description

UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36

Example URL:

Steps to reproduce the problem:
1. When the screen is 640px or wider, apply an external stylesheet which changes the color of the text 
2. Load the page when the browser is at least 640 px wide it changes the color of the text 
3. Then resize the browser width to 639 px or smaller it uses the CSS default text color which is right
4. Reload the page when the browser width is smaller than 640 px it uses the CSS default text color but when you resize the browser width to 640 px or wider, it doesn't read the color from external stylesheet

What is the expected behavior?
When the browser is 640px or wider, apply an external stylesheet which changes the color of the text. Keep your browser width less than 640 px and reload the page. Now when you resize the browser width to 640 px or wider, it should change the color of the text but it is not doing so.

What went wrong?
Chrome ignores all the external stylesheet with media queries if none of the media query conditions is true when the page loads. Later when you resize the page to meet the media query condition, it won't read the styles from the external stylesheets.  

Does it occur on multiple sites: Yes

Is it a problem with a plugin? No 

Did this work before? N/A 

Does this work in other browsers? Yes

Chrome version: 57.0.2987.133  Channel: stable
OS Version: 6.1 (Windows 7, Windows Server 2008 R2)
Flash Version:
 
chromeresponsivetest.html
257 bytes View Download
min-640px.css
23 bytes View Download
Cc: r...@opera.com
Components: -Blink Blink>CSS
Labels: -OS-Windows OS-All
Status: Untriaged (was: Unconfirmed)
Labels: Needs-Bisect
Able to repro on 60.0.3073.0 (Official Build) canary (32-bit) (cohort: 32-Bit) on Windows 10.

Comment 4 by r...@opera.com, Apr 18 2017

Cc: -r...@opera.com
Owner: r...@opera.com
Status: Started (was: Untriaged)

Comment 5 by sashab@chromium.org, Apr 19 2017

Labels: Hotlist-Interop Hotlist

Comment 6 by r...@opera.com, Apr 19 2017

Labels: -Needs-Bisect
https://codereview.chromium.org/2829873002/

Comment 7 by shans@chromium.org, Apr 20 2017

Labels: Update-Quarterly
Project Member

Comment 8 by bugdroid1@chromium.org, Apr 20 2017

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

commit 7a7892d7272ce168b1db7f4da87ae70d5e23cecc
Author: rune <rune@opera.com>
Date: Thu Apr 20 06:12:38 2017

Collect media query results for non-matching stylesheets.

Viewport and device dependent media query results are collected after
an active stylesheet update happen. The results are collected on the
ScopedStyleResolvers and propagated to the CSSGlobalRuleSet. It's
necessary that the active stylesheet update causes these media query
results to be up-to-date so that e.g. a viewport resize checks these
results to detect that we need an active stylesheet update for a given
resize.

That did not happen when we only added sheets for which the media
attrbute did not match, because adding a sheet with a null RuleSet does
not affect the computed style and the changed_rule_sets set was empty.

Now, if we add or remove a sheet which does not apply, and that sheet
has a viewport or device dependent media query, still return
kActiveSheetsAppended or kActiveSheetsChanged to trigger the re-
collection of those media query results.

BUG= 710878 

Review-Url: https://codereview.chromium.org/2829873002
Cr-Commit-Position: refs/heads/master@{#465912}

[add] https://crrev.com/7a7892d7272ce168b1db7f4da87ae70d5e23cecc/third_party/WebKit/LayoutTests/fast/css/media-attr-non-matching-dynamic.html
[modify] https://crrev.com/7a7892d7272ce168b1db7f4da87ae70d5e23cecc/third_party/WebKit/Source/core/css/ActiveStyleSheets.cpp
[modify] https://crrev.com/7a7892d7272ce168b1db7f4da87ae70d5e23cecc/third_party/WebKit/Source/core/css/ActiveStyleSheetsTest.cpp
[modify] https://crrev.com/7a7892d7272ce168b1db7f4da87ae70d5e23cecc/third_party/WebKit/Source/core/css/CSSStyleSheet.h
[modify] https://crrev.com/7a7892d7272ce168b1db7f4da87ae70d5e23cecc/third_party/WebKit/Source/core/dom/StyleEngine.cpp

Comment 9 by r...@opera.com, Apr 20 2017

Status: Fixed (was: Started)

Sign in to add a comment