OLD | NEW |
---|---|
(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" | |
sashab
2017/01/06 05:17:32
Even though it's compiling without it, add CSSIden
| |
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(); | |
sashab
2017/01/06 05:17:32
Thanks for updating these
| |
59 } | |
60 | |
61 return paintOrderList; | |
62 } | |
63 | |
64 } // namespace blink | |
OLD | NEW |