Commit 9c14eacb authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Commit Bot

Don't use @media with feature expressions in UA style.

We don't support MediaValues based feature evaluation in UA stylesheet,
only matching media types. There was an instance of
(-webkit-min-device-pixel-ratio: 2) in mediaControls.css which would
always evaluate to true in the UA sheet, but not in the context of the
evaluator in the StyleEngine for dpr=1. That caused us to constantly
update active stylesheets for frame resizes because we thought the media
result would change.

This also contributed to hide a bug on tweetdeck.twitter.com before we
optimized the ruleset invalidation for media query changes.

This should not be a behavior change for the mediaControls stylesheet
since the removed query would always evaluate to true so that we would
always use the high resolution image.

Bug: 1088340
Change-Id: I23f582893b21db6f14903836d58608caa82e5577
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2228848Reviewed-by: default avatarAnders Hartvoll Ruud <andruud@chromium.org>
Reviewed-by: default avatarTommy Steimel <steimel@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#775144}
parent 2a247e5e
......@@ -910,8 +910,13 @@ void MediaQueryEvaluator::Init() {
}
bool MediaQueryEvaluator::Eval(const MediaQueryExp& expr) const {
if (!media_values_ || !media_values_->HasValues())
return true;
if (!media_values_ || !media_values_->HasValues()) {
// media_values_ should only be nullptr when parsing UA stylesheets. The
// only media queries we support in UA stylesheets are media type queries.
// If HasValues() return false, it means the document frame is nullptr.
NOTREACHED();
return false;
}
DCHECK(g_function_map);
......
......@@ -62,9 +62,9 @@ class CORE_EXPORT MediaQueryEvaluator final
MediaQueryEvaluator() = delete;
// Creates evaluator which evaluates only simple media queries
// Evaluator returns true for acceptedMediaType and returns true for any media
// features.
// Creates evaluator to evaluate media types only. Evaluator returns true for
// accepted_media_type and triggers a NOTREACHED returning false for any media
// features. Should only be used for UA stylesheets.
MediaQueryEvaluator(const char* accepted_media_type);
// Creates evaluator which evaluates full media queries.
......
......@@ -2732,6 +2732,12 @@ TEST_F(StyleEngineTest, AtPropertyUseCount) {
EXPECT_TRUE(GetDocument().IsUseCounted(WebFeature::kCSSAtRuleProperty));
}
TEST_F(StyleEngineTest, MediaQueryAffectedByViewportSanityCheck) {
GetDocument().body()->setInnerHTML("<audio controls>");
UpdateAllLifecyclePhases();
EXPECT_FALSE(GetStyleEngine().MediaQueryAffectedByViewportChange());
}
class ParameterizedStyleEngineTest
: public testing::WithParamInterface<bool>,
private ScopedCSSReducedFontLoadingInvalidationsForTest,
......
......@@ -1365,8 +1365,8 @@ video::-webkit-media-controls.immersive-mode div[pseudo="-webkit-media-controls-
/* Taller scrim. */
background:
-webkit-image-set(url('default_100_percent/vr_gradient_bg.png') 1x)
repeat-x bottom left;
-webkit-image-set(url('default_200_percent/vr_gradient_bg.png') 1x)
repeat-x bottom left auto 198px;
}
video::-webkit-media-controls.immersive-mode input[pseudo="-webkit-media-controls-timeline" i]::-internal-track-segment-highlight-before,
......@@ -1446,14 +1446,6 @@ video::-webkit-media-controls.immersive-mode input[pseudo="-internal-media-contr
display: none;
}
@media (-webkit-min-device-pixel-ratio: 2) {
video::-webkit-media-controls.immersive-mode div[pseudo="-webkit-media-controls-panel" i] {
background:
-webkit-image-set(url('default_200_percent/vr_gradient_bg.png') 1x)
repeat-x bottom left auto 198px;
}
}
/**
* Test mode styles to remove animations/transitions to make web tests
* simpler.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment