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

Unified Diff: third_party/WebKit/Source/core/css/properties/CSSPropertyAPITouchAction.cpp

Issue 2647883002: Implements CSSPropertyAPI for the touch-action property (Closed)
Patch Set: 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
« no previous file with comments | « third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/css/properties/CSSPropertyAPITouchAction.cpp
diff --git a/third_party/WebKit/Source/core/css/properties/CSSPropertyAPITouchAction.cpp b/third_party/WebKit/Source/core/css/properties/CSSPropertyAPITouchAction.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2b075c5817a15042c26efc4b6c07f189cdf67424
--- /dev/null
+++ b/third_party/WebKit/Source/core/css/properties/CSSPropertyAPITouchAction.cpp
@@ -0,0 +1,73 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/css/properties/CSSPropertyAPITouchAction.h"
+
+#include "core/css/CSSValueList.h"
+#include "core/css/parser/CSSPropertyParserHelpers.h"
+#include "platform/RuntimeEnabledFeatures.h"
+
+namespace blink {
+
+namespace {
+
+static bool consumePan(CSSParserTokenRange& range,
+ CSSValue*& panX,
+ CSSValue*& panY,
+ CSSValue*& pinchZoom) {
+ CSSValueID id = range.peek().id();
+ if ((id == CSSValuePanX || id == CSSValuePanRight || id == CSSValuePanLeft) &&
+ !panX) {
+ if (id != CSSValuePanX &&
+ !RuntimeEnabledFeatures::cssTouchActionPanDirectionsEnabled())
+ return false;
+ panX = CSSPropertyParserHelpers::consumeIdent(range);
+ } else if ((id == CSSValuePanY || id == CSSValuePanDown ||
+ id == CSSValuePanUp) &&
+ !panY) {
+ if (id != CSSValuePanY &&
+ !RuntimeEnabledFeatures::cssTouchActionPanDirectionsEnabled())
+ return false;
+ panY = CSSPropertyParserHelpers::consumeIdent(range);
+ } else if (id == CSSValuePinchZoom && !pinchZoom &&
+ RuntimeEnabledFeatures::cssTouchActionPinchZoomEnabled()) {
+ pinchZoom = CSSPropertyParserHelpers::consumeIdent(range);
+ } else {
+ return false;
+ }
+ return true;
+}
+
+} // namespace
+
+const CSSValue* CSSPropertyAPITouchAction::parseSingleValue(
+ CSSParserTokenRange& range,
+ const CSSParserContext* context) {
+ CSSValueList* list = CSSValueList::createSpaceSeparated();
+ CSSValueID id = range.peek().id();
+ if (id == CSSValueAuto || id == CSSValueNone || id == CSSValueManipulation) {
+ list->append(*CSSPropertyParserHelpers::consumeIdent(range));
+ return list;
+ }
+
+ CSSValue* panX = nullptr;
+ CSSValue* panY = nullptr;
+ CSSValue* pinchZoom = nullptr;
+ if (!consumePan(range, panX, panY, pinchZoom))
+ return nullptr;
+ if (!range.atEnd() && !consumePan(range, panX, panY, pinchZoom))
+ return nullptr;
+ if (!range.atEnd() && !consumePan(range, panX, panY, pinchZoom))
+ return nullptr;
+
+ if (panX)
+ list->append(*panX);
+ if (panY)
+ list->append(*panY);
+ if (pinchZoom)
+ list->append(*pinchZoom);
+ return list;
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698