#include "core/MediaFeatureNames.h"
#include "core/MediaFeatures.h"
#include "core/MediaTypeNames.h"
-#include "core/css/CSSAspectRatioValue.h"
#include "core/css/CSSHelper.h"
#include "core/css/CSSPrimitiveValue.h"
#include "core/css/CSSToLengthConversionData.h"
return false;
}
-static bool computeLength(const MediaQueryExpValue& value, const MediaValues& mediaValues, int& result)
+static bool computeLength(const MediaQueryExpValue& value, const MediaValues& mediaValues, double& result)
{
if (!value.isValue)
return false;
return false;
}
+static bool computeLengthAndCompare(const MediaQueryExpValue& value, MediaFeaturePrefix op, const MediaValues& mediaValues, double compareToValue)
+{
+ double length;
+ return computeLength(value, mediaValues, length) && compareValue(compareToValue, length, op);
+}
+
static bool deviceHeightMediaFeatureEval(const MediaQueryExpValue& value, MediaFeaturePrefix op, const MediaValues& mediaValues)
{
- if (value.isValid()) {
- int length;
- return computeLength(value, mediaValues, length) && compareValue(static_cast<int>(mediaValues.deviceHeight()), length, op);
- }
+ if (value.isValid())
+ return computeLengthAndCompare(value, op, mediaValues, mediaValues.deviceHeight());
+
// ({,min-,max-}device-height)
// assume if we have a device, assume non-zero
return true;
static bool deviceWidthMediaFeatureEval(const MediaQueryExpValue& value, MediaFeaturePrefix op, const MediaValues& mediaValues)
{
- if (value.isValid()) {
- int length;
- return computeLength(value, mediaValues, length) && compareValue(static_cast<int>(mediaValues.deviceWidth()), length, op);
- }
+ if (value.isValid())
+ return computeLengthAndCompare(value, op, mediaValues, mediaValues.deviceWidth());
+
// ({,min-,max-}device-width)
// assume if we have a device, assume non-zero
return true;
static bool heightMediaFeatureEval(const MediaQueryExpValue& value, MediaFeaturePrefix op, const MediaValues& mediaValues)
{
int height = mediaValues.viewportHeight();
- if (value.isValid()) {
- int length;
- return computeLength(value, mediaValues, length) && compareValue(height, length, op);
- }
+ if (value.isValid())
+ return computeLengthAndCompare(value, op, mediaValues, height);
return height;
}
static bool widthMediaFeatureEval(const MediaQueryExpValue& value, MediaFeaturePrefix op, const MediaValues& mediaValues)
{
int width = mediaValues.viewportWidth();
- if (value.isValid()) {
- int length;
- return computeLength(value, mediaValues, length) && compareValue(width, length, op);
- }
+ if (value.isValid())
+ return computeLengthAndCompare(value, op, mediaValues, width);
return width;
}