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

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

Issue 23192002: Let page zoom affect resolution and -webkit-device-pixel-ratio MQs. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Review issue: renamed variable 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/css/zoom-media-queries-resolution-expected.txt ('k') | Source/core/page/DOMWindow.cpp » ('j') | 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 413c80ea910c3007cd921b8f22239eb7c74a7f44..42e71e531f9ef4957b1b877e93ea79e3ed48f40c 100644
--- a/Source/core/css/MediaQueryEvaluator.cpp
+++ b/Source/core/css/MediaQueryEvaluator.cpp
@@ -272,8 +272,8 @@ static bool deviceAspectRatioMediaFeatureEval(CSSValue* value, RenderStyle*, Fra
static bool evalResolution(CSSValue* value, Frame* frame, MediaFeaturePrefix op)
{
- // FIXME: Possible handle other media types than 'screen' and 'print'.
- float deviceScaleFactor = 0;
+ // FIXME: Possibly handle other media types than 'screen' and 'print'.
+ float actualResolution = 0;
// This checks the actual media type applied to the document, and we know
// this method only got called if this media type matches the one defined
@@ -281,16 +281,16 @@ static bool evalResolution(CSSValue* value, Frame* frame, MediaFeaturePrefix op)
// media type of the query will either be "print" or "all".
String mediaType = frame->view()->mediaType();
if (equalIgnoringCase(mediaType, "screen"))
- deviceScaleFactor = frame->page()->deviceScaleFactor();
+ actualResolution = clampTo<float>(frame->devicePixelRatio());
else if (equalIgnoringCase(mediaType, "print")) {
// The resolution of images while printing should not depend on the DPI
// of the screen. Until we support proper ways of querying this info
// we use 300px which is considered minimum for current printers.
- deviceScaleFactor = 300 / cssPixelsPerInch;
+ actualResolution = 300 / cssPixelsPerInch;
}
if (!value)
- return !!deviceScaleFactor;
+ return !!actualResolution;
if (!value->isPrimitiveValue())
return false;
@@ -298,7 +298,7 @@ static bool evalResolution(CSSValue* value, Frame* frame, MediaFeaturePrefix op)
CSSPrimitiveValue* resolution = toCSSPrimitiveValue(value);
if (resolution->isNumber())
- return compareValue(deviceScaleFactor, resolution->getFloatValue(), op);
+ return compareValue(actualResolution, resolution->getFloatValue(), op);
if (!resolution->isResolution())
return false;
@@ -310,11 +310,11 @@ static bool evalResolution(CSSValue* value, Frame* frame, MediaFeaturePrefix op)
// approximates the reference pixel". With that in mind, allowing 2 decimal
// point precision seems appropriate.
return compareValue(
- floorf(0.5 + 100 * deviceScaleFactor) / 100,
+ floorf(0.5 + 100 * actualResolution) / 100,
floorf(0.5 + 100 * resolution->getFloatValue(CSSPrimitiveValue::CSS_DPPX)) / 100, op);
}
- return compareValue(deviceScaleFactor, resolution->getFloatValue(CSSPrimitiveValue::CSS_DPPX), op);
+ return compareValue(actualResolution, resolution->getFloatValue(CSSPrimitiveValue::CSS_DPPX), op);
}
static bool devicePixelRatioMediaFeatureEval(CSSValue *value, RenderStyle*, Frame* frame, MediaFeaturePrefix op)
« no previous file with comments | « LayoutTests/fast/css/zoom-media-queries-resolution-expected.txt ('k') | Source/core/page/DOMWindow.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698