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

Side by Side Diff: third_party/WebKit/Source/core/css/properties/CSSPropertyAPIPaintOrder.cpp

Issue 2612103003: Implements CSSPropertyAPI for the paint-order property. (Closed)
Patch Set: rebase 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/CSSPropertyAPIPaintOrder.h"
6
7 #include "core/css/CSSValueList.h"
8 #include "core/css/parser/CSSPropertyParserHelpers.h"
9
10 namespace blink {
11
12 const CSSValue* CSSPropertyAPIPaintOrder::parseSingleValue(
13 CSSParserTokenRange& range,
14 const CSSParserContext& context) {
15 if (range.peek().id() == CSSValueNormal)
16 return CSSPropertyParserHelpers::consumeIdent(range);
17
18 Vector<CSSValueID, 3> paintTypeList;
19 CSSIdentifierValue* fill = nullptr;
20 CSSIdentifierValue* stroke = nullptr;
21 CSSIdentifierValue* markers = nullptr;
22 do {
23 CSSValueID id = range.peek().id();
24 if (id == CSSValueFill && !fill)
25 fill = CSSPropertyParserHelpers::consumeIdent(range);
26 else if (id == CSSValueStroke && !stroke)
27 stroke = CSSPropertyParserHelpers::consumeIdent(range);
28 else if (id == CSSValueMarkers && !markers)
29 markers = CSSPropertyParserHelpers::consumeIdent(range);
30 else
31 return nullptr;
32 paintTypeList.push_back(id);
33 } while (!range.atEnd());
34
35 // After parsing we serialize the paint-order list. Since it is not possible
36 // to pop a last list items from CSSValueList without bigger cost, we create
37 // the list after parsing.
38 CSSValueID firstPaintOrderType = paintTypeList.at(0);
39 CSSValueList* paintOrderList = CSSValueList::createSpaceSeparated();
40 switch (firstPaintOrderType) {
41 case CSSValueFill:
42 case CSSValueStroke:
43 paintOrderList->append(firstPaintOrderType == CSSValueFill ? *fill
44 : *stroke);
45 if (paintTypeList.size() > 1) {
46 if (paintTypeList.at(1) == CSSValueMarkers)
47 paintOrderList->append(*markers);
48 }
49 break;
50 case CSSValueMarkers:
51 paintOrderList->append(*markers);
52 if (paintTypeList.size() > 1) {
53 if (paintTypeList.at(1) == CSSValueStroke)
54 paintOrderList->append(*stroke);
55 }
56 break;
57 default:
58 NOTREACHED();
59 }
60
61 return paintOrderList;
62 }
63
64 } // 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