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

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

Issue 18360007: MediaQueryEvaluator should use default style for evaluating "rem". Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Added layout test for seamless iframe Created 7 years, 5 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/frames/seamless/media-query-basing-rem-unit-expected.txt ('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 68d654cd7fa72a469e092c845cb5a53f694e08da..fcb499febef624e54b253054675b88992a6edd6a 100644
--- a/Source/core/css/MediaQueryEvaluator.cpp
+++ b/Source/core/css/MediaQueryEvaluator.cpp
@@ -334,7 +334,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(Document* document, CSSValue* value, RenderStyle* style, RenderStyle* rootStyle, int& result)
{
if (!value->isPrimitiveValue())
return false;
@@ -343,9 +343,17 @@ static bool computeLength(CSSValue* value, bool strict, RenderStyle* style, Rend
if (primitiveValue->isNumber()) {
result = primitiveValue->getIntValue();
+ bool strict = !document->inQuirksMode();
return !strict || !result;
}
+ if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_REMS) {
+ // Use the initial font size instead of <html> font size.
+ RefPtr<RenderStyle> defaultStyle = StyleResolver::styleForDocument(document);
+ result = primitiveValue->computeLength<int>(style, defaultStyle.get(), 1.0 /* multiplier */, true /* computingFontSize */);
+ return true;
+ }
+
if (primitiveValue->isLength()) {
result = primitiveValue->computeLength<int>(style, rootStyle, 1.0 /* multiplier */, true /* computingFontSize */);
return true;
@@ -362,7 +370,7 @@ static bool deviceHeightMediaFeatureEval(CSSValue* value, RenderStyle* style, Fr
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(frame->document(), value, style, rootStyle, length) && compareValue(static_cast<int>(height), length, op);
}
// ({,min-,max-}device-height)
// assume if we have a device, assume non-zero
@@ -377,7 +385,7 @@ static bool deviceWidthMediaFeatureEval(CSSValue* value, RenderStyle* style, Fra
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(frame->document(), value, style, rootStyle, length) && compareValue(static_cast<int>(width), length, op);
}
// ({,min-,max-}device-width)
// assume if we have a device, assume non-zero
@@ -394,7 +402,7 @@ static bool heightMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* f
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(frame->document(), value, style, rootStyle, length) && compareValue(height, length, op);
}
return height;
@@ -410,7 +418,7 @@ static bool widthMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* fr
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(frame->document(), value, style, rootStyle, length) && compareValue(width, length, op);
}
return width;
« no previous file with comments | « LayoutTests/fast/frames/seamless/media-query-basing-rem-unit-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698