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

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

Issue 2652313004: Implement color-gamut media query (Closed)
Patch Set: fix windows build Created 3 years, 11 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
Index: third_party/WebKit/Source/core/css/MediaQueryEvaluator.cpp
diff --git a/third_party/WebKit/Source/core/css/MediaQueryEvaluator.cpp b/third_party/WebKit/Source/core/css/MediaQueryEvaluator.cpp
index 5d3f0b3b2bca3c57326b5f36635abce626f18d0a..ce9cbea0b3d53a888102153eb9e83ebc3a755aee 100644
--- a/third_party/WebKit/Source/core/css/MediaQueryEvaluator.cpp
+++ b/third_party/WebKit/Source/core/css/MediaQueryEvaluator.cpp
@@ -51,6 +51,7 @@
#include "core/style/ComputedStyle.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/geometry/FloatRect.h"
+#include "platform/graphics/ColorSpace.h"
#include "public/platform/PointerProperties.h"
#include "public/platform/ShapeProperties.h"
#include "public/platform/WebDisplayMode.h"
@@ -753,6 +754,48 @@ static bool scanMediaFeatureEval(const MediaQueryExpValue& value,
return (value.id == CSSValueProgressive);
}
+static bool colorGamutMediaFeatureEval(const MediaQueryExpValue& value,
+ MediaFeaturePrefix,
+ const MediaValues& mediaValues) {
+ // isValid() is false if there is no parameter. Without parameter we should
+ // return true to indicate that colorGamutMediaFeature is enabled in the
+ // browser.
+ if (!value.isValid())
+ return true;
+
+ if (!value.isID)
+ return false;
+
+ DCHECK(value.id == CSSValueSRGB || value.id == CSSValueP3 ||
+ value.id == CSSValueRec2020);
+
+ ColorSpaceGamut gamut = mediaValues.colorGamut();
+ switch (gamut) {
+ case ColorSpaceGamut::Unknown:
+ case ColorSpaceGamut::LessThanNTSC:
+ case ColorSpaceGamut::NTSC:
+ case ColorSpaceGamut::SRGB:
+ return value.id == CSSValueSRGB;
+ case ColorSpaceGamut::AlmostP3:
+ case ColorSpaceGamut::P3:
+ case ColorSpaceGamut::AdobeRGB:
+ case ColorSpaceGamut::Wide:
+ return value.id == CSSValueSRGB || value.id == CSSValueP3;
+ case ColorSpaceGamut::BT2020:
+ case ColorSpaceGamut::ProPhoto:
+ case ColorSpaceGamut::UltraWide:
+ return value.id == CSSValueSRGB || value.id == CSSValueP3 ||
+ value.id == CSSValueRec2020;
+ case ColorSpaceGamut::End:
+ NOTREACHED();
+ return false;
+ }
+
+ // This is for some compilers that do not understand that it can't be reached.
+ NOTREACHED();
+ return false;
+}
+
void MediaQueryEvaluator::init() {
// Create the table.
gFunctionMap = new FunctionMap;

Powered by Google App Engine
This is Rietveld 408576698