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

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

Issue 2382653006: Split CSSPrimitiveValue into CSSPrimitiveValue and CSSIdentifierValue (Closed)
Patch Set: Make check-webkit-style happy Created 4 years, 2 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
OLDNEW
(Empty)
1 // Copyright 2016 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/CSSIdentifierValue.h"
6
7 #include "core/css/CSSMarkup.h"
8 #include "core/css/CSSValuePool.h"
9 #include "platform/Length.h"
10 #include "wtf/text/StringBuilder.h"
11 #include "wtf/text/WTFString.h"
12
13 namespace blink {
14
15 static const AtomicString& valueName(CSSValueID valueID) {
16 DCHECK_GE(valueID, 0);
17 DCHECK_LT(valueID, numCSSValueKeywords);
18
19 if (valueID < 0)
20 return nullAtom;
21
22 static AtomicString* keywordStrings =
23 new AtomicString[numCSSValueKeywords]; // Leaked intentionally.
24 AtomicString& keywordString = keywordStrings[valueID];
25 if (keywordString.isNull())
26 keywordString = getValueName(valueID);
27 return keywordString;
28 }
29
30 CSSIdentifierValue* CSSIdentifierValue::create(CSSValueID valueID) {
31 CSSIdentifierValue* cssValue = cssValuePool().identifierCacheValue(valueID);
32 if (!cssValue) {
33 cssValue = cssValuePool().setIdentifierCacheValue(
34 valueID, new CSSIdentifierValue(valueID));
35 }
36 return cssValue;
37 }
38
39 String CSSIdentifierValue::customCSSText() const {
40 return valueName(m_valueID);
41 }
42
43 CSSIdentifierValue::CSSIdentifierValue(CSSValueID valueID)
44 : CSSValue(IdentifierClass), m_valueID(valueID) {
45 // TODO(sashab): Add a DCHECK_NE(valueID, CSSValueInvalid) once no code paths
46 // cause this to happen.
47 }
48
49 CSSIdentifierValue::CSSIdentifierValue(const Length& length)
50 : CSSValue(IdentifierClass) {
51 switch (length.type()) {
52 case Auto:
53 m_valueID = CSSValueAuto;
54 break;
55 case MinContent:
56 m_valueID = CSSValueMinContent;
57 break;
58 case MaxContent:
59 m_valueID = CSSValueMaxContent;
60 break;
61 case FillAvailable:
62 m_valueID = CSSValueWebkitFillAvailable;
63 break;
64 case FitContent:
65 m_valueID = CSSValueFitContent;
66 break;
67 case ExtendToZoom:
68 m_valueID = CSSValueInternalExtendToZoom;
69 case Percent:
70 case Fixed:
71 case Calculated:
72 case DeviceWidth:
73 case DeviceHeight:
74 case MaxSizeNone:
75 NOTREACHED();
76 break;
77 }
78 }
79
80 DEFINE_TRACE_AFTER_DISPATCH(CSSIdentifierValue) {
81 CSSValue::traceAfterDispatch(visitor);
82 }
83
84 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSIdentifierValue.h ('k') | third_party/WebKit/Source/core/css/CSSMatrix.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698