| Index: Source/core/css/MediaQueryEvaluator.cpp
|
| diff --git a/Source/core/css/MediaQueryEvaluator.cpp b/Source/core/css/MediaQueryEvaluator.cpp
|
| index c44036ff8060f63c5377ff19a55505e6630220a6..d7aa3d9905b005a375469077d7bedfb78b095891 100644
|
| --- a/Source/core/css/MediaQueryEvaluator.cpp
|
| +++ b/Source/core/css/MediaQueryEvaluator.cpp
|
| @@ -331,28 +331,7 @@ static bool gridMediaFeatureEval(CSSValue* value, MediaFeaturePrefix op, const M
|
| return false;
|
| }
|
|
|
| -static bool computeLengthWithoutStyle(CSSPrimitiveValue* primitiveValue, int defaultFontSize, int& result)
|
| -{
|
| - // We're running in a background thread, so RenderStyle is not available.
|
| - // Nevertheless, we can evaluate length MQs with em, rem or px units.
|
| - // FIXME: Learn to support more units here, or teach CSSPrimitiveValue about MediaValues.
|
| - unsigned short type = primitiveValue->primitiveType();
|
| - int factor = 0;
|
| - if (type == CSSPrimitiveValue::CSS_EMS || type == CSSPrimitiveValue::CSS_REMS) {
|
| - if (defaultFontSize > 0)
|
| - factor = defaultFontSize;
|
| - else
|
| - return false;
|
| - } else if (type == CSSPrimitiveValue::CSS_PX) {
|
| - factor = 1;
|
| - } else {
|
| - return false;
|
| - }
|
| - result = roundForImpreciseConversion<int>(primitiveValue->getDoubleValue()*factor);
|
| - return true;
|
| -}
|
| -
|
| -static bool computeLength(CSSValue* value, bool strict, RenderStyle* initialStyle, int defaultFontSize, int& result)
|
| +static bool computeLength(CSSValue* value, const MediaValues& mediaValues, int& result)
|
| {
|
| if (!value->isPrimitiveValue())
|
| return false;
|
| @@ -361,17 +340,17 @@ static bool computeLength(CSSValue* value, bool strict, RenderStyle* initialStyl
|
|
|
| if (primitiveValue->isNumber()) {
|
| result = primitiveValue->getIntValue();
|
| - return !strict || !result;
|
| + return !mediaValues.strictMode() || !result;
|
| }
|
|
|
| if (primitiveValue->isLength()) {
|
| - if (initialStyle) {
|
| + if (mediaValues.style()) {
|
| // Relative (like EM) and root relative (like REM) units are always resolved against
|
| // the initial values for media queries, hence the two initialStyle parameters.
|
| // FIXME: We need to plumb viewport unit support down to here.
|
| - result = primitiveValue->computeLength<int>(CSSToLengthConversionData(initialStyle, initialStyle, 0, 1.0 /* zoom */, true /* computingFontSize */));
|
| + result = primitiveValue->computeLength<int>(CSSToLengthConversionData(mediaValues.style(), mediaValues.style(), 0, 1.0 /* zoom */, true /* computingFontSize */));
|
| } else {
|
| - return computeLengthWithoutStyle(primitiveValue, defaultFontSize, result);
|
| + result = primitiveValue->computeLength<int>(mediaValues);
|
| }
|
| return true;
|
| }
|
| @@ -383,7 +362,7 @@ static bool deviceHeightMediaFeatureEval(CSSValue* value, MediaFeaturePrefix op,
|
| {
|
| if (value) {
|
| int length;
|
| - return computeLength(value, mediaValues.strictMode(), mediaValues.style(), mediaValues.defaultFontSize(), length)
|
| + return computeLength(value, mediaValues, length)
|
| && compareValue(static_cast<int>(mediaValues.deviceHeight()), length, op);
|
| }
|
| // ({,min-,max-}device-height)
|
| @@ -395,7 +374,7 @@ static bool deviceWidthMediaFeatureEval(CSSValue* value, MediaFeaturePrefix op,
|
| {
|
| if (value) {
|
| int length;
|
| - return computeLength(value, mediaValues.strictMode(), mediaValues.style(), mediaValues.defaultFontSize(), length)
|
| + return computeLength(value, mediaValues, length)
|
| && compareValue(static_cast<int>(mediaValues.deviceWidth()), length, op);
|
| }
|
| // ({,min-,max-}device-width)
|
| @@ -408,7 +387,7 @@ static bool heightMediaFeatureEval(CSSValue* value, MediaFeaturePrefix op, const
|
| int height = mediaValues.viewportHeight();
|
| if (value) {
|
| int length;
|
| - return computeLength(value, mediaValues.strictMode(), mediaValues.style(), mediaValues.defaultFontSize(), length)
|
| + return computeLength(value, mediaValues, length)
|
| && compareValue(height, length, op);
|
| }
|
|
|
| @@ -420,7 +399,7 @@ static bool widthMediaFeatureEval(CSSValue* value, MediaFeaturePrefix op, const
|
| int width = mediaValues.viewportWidth();
|
| if (value) {
|
| int length;
|
| - return computeLength(value, mediaValues.strictMode(), mediaValues.style(), mediaValues.defaultFontSize(), length)
|
| + return computeLength(value, mediaValues, length)
|
| && compareValue(width, length, op);
|
| }
|
|
|
|
|