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

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

Issue 13896036: [CSSMQ] Implemented support for the scan media feature. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: another static_cast removed. Created 7 years, 7 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 | « Source/core/css/MediaQueryEvaluator.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/MediaQueryExp.cpp
diff --git a/Source/core/css/MediaQueryExp.cpp b/Source/core/css/MediaQueryExp.cpp
index fdfe564875fdf819d858c7eee7cdd65012d790cd..0ddd33f6ffdf3e6aadd57110283803aa807ec615 100644
--- a/Source/core/css/MediaQueryExp.cpp
+++ b/Source/core/css/MediaQueryExp.cpp
@@ -30,6 +30,7 @@
#include "config.h"
#include "core/css/MediaQueryExp.h"
+#include "CSSValueKeywords.h"
#include "core/css/CSSAspectRatioValue.h"
#include "core/css/CSSParser.h"
#include "core/css/CSSPrimitiveValue.h"
@@ -46,7 +47,36 @@ static inline bool featureWithCSSValueID(const AtomicString& mediaFeature, const
return mediaFeature == MediaFeatureNames::orientationMediaFeature
|| mediaFeature == MediaFeatureNames::viewModeMediaFeature
- || mediaFeature == MediaFeatureNames::pointerMediaFeature;
+ || mediaFeature == MediaFeatureNames::pointerMediaFeature
+ || mediaFeature == MediaFeatureNames::scanMediaFeature;
+}
+
+static inline bool featureWithValidIdent(const AtomicString& mediaFeature, int ident)
+{
+ if (mediaFeature == MediaFeatureNames::orientationMediaFeature)
+ return ident == CSSValuePortrait || ident == CSSValueLandscape;
+
+ if (mediaFeature == MediaFeatureNames::viewModeMediaFeature) {
+ switch (ident) {
+ case CSSValueWindowed:
+ case CSSValueFloating:
+ case CSSValueFullscreen:
+ case CSSValueMaximized:
+ case CSSValueMinimized:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ if (mediaFeature == MediaFeatureNames::pointerMediaFeature)
+ return ident == CSSValueNone || ident == CSSValueCoarse || ident == CSSValueFine;
+
+ if (mediaFeature == MediaFeatureNames::scanMediaFeature)
+ return ident == CSSValueInterlace || ident == CSSValueProgressive;
+
+ ASSERT_NOT_REACHED();
+ return false;
}
static inline bool featureWithValidPositiveLenghtOrNumber(const AtomicString& mediaFeature, const CSSParserValue* value)
@@ -148,7 +178,8 @@ static inline bool featureWithoutValue(const AtomicString& mediaFeature)
|| mediaFeature == MediaFeatureNames::viewModeMediaFeature
|| mediaFeature == MediaFeatureNames::pointerMediaFeature
|| mediaFeature == MediaFeatureNames::devicePixelRatioMediaFeature
- || mediaFeature == MediaFeatureNames::resolutionMediaFeature;
+ || mediaFeature == MediaFeatureNames::resolutionMediaFeature
+ || mediaFeature == MediaFeatureNames::scanMediaFeature;
}
bool MediaQueryExp::isViewportDependent() const
@@ -176,8 +207,11 @@ inline MediaQueryExp::MediaQueryExp(const AtomicString& mediaFeature, CSSParserV
CSSParserValue* value = valueList->current();
// Media features that use CSSValueIDs.
- if (featureWithCSSValueID(mediaFeature, value))
+ if (featureWithCSSValueID(mediaFeature, value)) {
m_value = CSSPrimitiveValue::createIdentifier(value->id);
+ if (!featureWithValidIdent(mediaFeature, toCSSPrimitiveValue(m_value.get())->getIdent()))
+ m_value.clear();
+ }
// Media features that must have non-negative <density>, ie. dppx, dpi or dpcm.
else if (featureWithValidDensity(mediaFeature, value))
« no previous file with comments | « Source/core/css/MediaQueryEvaluator.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698