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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "core/css/properties/CSSPropertyAPITouchAction.h"
6
7 #include "core/css/CSSValueList.h"
8 #include "core/css/parser/CSSPropertyParserHelpers.h"
9 #include "platform/RuntimeEnabledFeatures.h"
10
11 namespace blink {
12
13 namespace {
14
15 static bool consumePan(CSSParserTokenRange& range,
16 CSSValue*& panX,
17 CSSValue*& panY,
18 CSSValue*& pinchZoom) {
19 CSSValueID id = range.peek().id();
20 if ((id == CSSValuePanX || id == CSSValuePanRight || id == CSSValuePanLeft) &&
21 !panX) {
22 if (id != CSSValuePanX &&
23 !RuntimeEnabledFeatures::cssTouchActionPanDirectionsEnabled())
24 return false;
25 panX = CSSPropertyParserHelpers::consumeIdent(range);
26 } else if ((id == CSSValuePanY || id == CSSValuePanDown ||
27 id == CSSValuePanUp) &&
28 !panY) {
29 if (id != CSSValuePanY &&
30 !RuntimeEnabledFeatures::cssTouchActionPanDirectionsEnabled())
31 return false;
32 panY = CSSPropertyParserHelpers::consumeIdent(range);
33 } else if (id == CSSValuePinchZoom && !pinchZoom &&
34 RuntimeEnabledFeatures::cssTouchActionPinchZoomEnabled()) {
35 pinchZoom = CSSPropertyParserHelpers::consumeIdent(range);
36 } else {
37 return false;
38 }
39 return true;
40 }
41
42 } // namespace
43
44 const CSSValue* CSSPropertyAPITouchAction::parseSingleValue(
45 CSSParserTokenRange& range,
46 const CSSParserContext* context) {
47 CSSValueList* list = CSSValueList::createSpaceSeparated();
48 CSSValueID id = range.peek().id();
49 if (id == CSSValueAuto || id == CSSValueNone || id == CSSValueManipulation) {
50 list->append(*CSSPropertyParserHelpers::consumeIdent(range));
51 return list;
52 }
53
54 CSSValue* panX = nullptr;
55 CSSValue* panY = nullptr;
56 CSSValue* pinchZoom = nullptr;
57 if (!consumePan(range, panX, panY, pinchZoom))
58 return nullptr;
59 if (!range.atEnd() && !consumePan(range, panX, panY, pinchZoom))
60 return nullptr;
61 if (!range.atEnd() && !consumePan(range, panX, panY, pinchZoom))
62 return nullptr;
63
64 if (panX)
65 list->append(*panX);
66 if (panY)
67 list->append(*panY);
68 if (pinchZoom)
69 list->append(*pinchZoom);
70 return list;
71 }
72
73 } // namespace blink
OLDNEW
« 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