Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(494)

Unified Diff: Source/core/css/MediaQueryEvaluator.cpp

Issue 22258007: [CSSMQ] Use initial values as base for relative units. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: --no-find-copies upload Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/fast/media/mq-relative-constraints-10-expected.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/MediaQueryEvaluator.cpp
diff --git a/Source/core/css/MediaQueryEvaluator.cpp b/Source/core/css/MediaQueryEvaluator.cpp
index 900a6271c08e1f5992d9d651f9106da4b5b3b172..413c80ea910c3007cd921b8f22239eb7c74a7f44 100644
--- a/Source/core/css/MediaQueryEvaluator.cpp
+++ b/Source/core/css/MediaQueryEvaluator.cpp
@@ -337,7 +337,7 @@ static bool gridMediaFeatureEval(CSSValue* value, RenderStyle*, Frame*, MediaFea
return false;
}
-static bool computeLength(CSSValue* value, bool strict, RenderStyle* style, RenderStyle* rootStyle, int& result)
+static bool computeLength(CSSValue* value, bool strict, RenderStyle* initialStyle, int& result)
{
if (!value->isPrimitiveValue())
return false;
@@ -350,7 +350,9 @@ static bool computeLength(CSSValue* value, bool strict, RenderStyle* style, Rend
}
if (primitiveValue->isLength()) {
- result = primitiveValue->computeLength<int>(style, rootStyle, 1.0 /* multiplier */, true /* computingFontSize */);
+ // Relative (like EM) and root relative (like REM) units are always resolved against the initial values
+ // for media queries, hence the two initialStyle parameters.
+ result = primitiveValue->computeLength<int>(initialStyle, initialStyle, 1.0 /* multiplier */, true /* computingFontSize */);
return true;
}
@@ -361,11 +363,10 @@ static bool deviceHeightMediaFeatureEval(CSSValue* value, RenderStyle* style, Fr
{
if (value) {
FloatRect sg = screenRect(frame->page()->mainFrame()->view());
- RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
int length;
long height = sg.height();
InspectorInstrumentation::applyScreenHeightOverride(frame, &height);
- return computeLength(value, !frame->document()->inQuirksMode(), style, rootStyle, length) && compareValue(static_cast<int>(height), length, op);
+ return computeLength(value, !frame->document()->inQuirksMode(), style, length) && compareValue(static_cast<int>(height), length, op);
}
// ({,min-,max-}device-height)
// assume if we have a device, assume non-zero
@@ -376,11 +377,10 @@ static bool deviceWidthMediaFeatureEval(CSSValue* value, RenderStyle* style, Fra
{
if (value) {
FloatRect sg = screenRect(frame->page()->mainFrame()->view());
- RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
int length;
long width = sg.width();
InspectorInstrumentation::applyScreenWidthOverride(frame, &width);
- return computeLength(value, !frame->document()->inQuirksMode(), style, rootStyle, length) && compareValue(static_cast<int>(width), length, op);
+ return computeLength(value, !frame->document()->inQuirksMode(), style, length) && compareValue(static_cast<int>(width), length, op);
}
// ({,min-,max-}device-width)
// assume if we have a device, assume non-zero
@@ -395,9 +395,8 @@ static bool heightMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* f
if (value) {
if (RenderView* renderView = frame->document()->renderView())
height = adjustForAbsoluteZoom(height, renderView);
- RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
int length;
- return computeLength(value, !frame->document()->inQuirksMode(), style, rootStyle, length) && compareValue(height, length, op);
+ return computeLength(value, !frame->document()->inQuirksMode(), style, length) && compareValue(height, length, op);
}
return height;
@@ -411,9 +410,8 @@ static bool widthMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* fr
if (value) {
if (RenderView* renderView = frame->document()->renderView())
width = adjustForAbsoluteZoom(width, renderView);
- RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
int length;
- return computeLength(value, !frame->document()->inQuirksMode(), style, rootStyle, length) && compareValue(width, length, op);
+ return computeLength(value, !frame->document()->inQuirksMode(), style, length) && compareValue(width, length, op);
}
return width;
« no previous file with comments | « LayoutTests/fast/media/mq-relative-constraints-10-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698