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

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

Issue 2346193002: Split CSSPrimitiveValue into CSSPrimitiveValue and CSSIdentifierValue (Closed)
Patch Set: Rebase please work 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 {
17 DCHECK_GE(valueID, 0);
18 DCHECK_LT(valueID, numCSSValueKeywords);
19
20 if (valueID < 0)
21 return nullAtom;
22
23 static AtomicString* keywordStrings = 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 {
32 CSSIdentifierValue* cssValue = cssValuePool().identifierCacheValue(valueID);
33 if (!cssValue)
34 cssValue = cssValuePool().setIdentifierCacheValue(valueID, new CSSIdenti fierValue(valueID));
35 return cssValue;
36 }
37
38 String CSSIdentifierValue::customCSSText() const
39 {
40 return valueName(m_valueID);
41 }
42
43 CSSIdentifierValue::CSSIdentifierValue(CSSValueID valueID)
44 : CSSValue(IdentifierClass)
45 , m_valueID(valueID)
46 {
47 // TODO(sashab): Add a DCHECK_NE(valueID, CSSValueInvalid) once no code path s
48 // cause this to happen.
49 }
50
51 CSSIdentifierValue::CSSIdentifierValue(const Length& length)
52 : CSSValue(IdentifierClass)
53 {
54 switch (length.type()) {
55 case Auto:
56 m_valueID = CSSValueAuto;
57 break;
58 case MinContent:
59 m_valueID = CSSValueMinContent;
60 break;
61 case MaxContent:
62 m_valueID = CSSValueMaxContent;
63 break;
64 case FillAvailable:
65 m_valueID = CSSValueWebkitFillAvailable;
66 break;
67 case FitContent:
68 m_valueID = CSSValueFitContent;
69 break;
70 case ExtendToZoom:
71 m_valueID = CSSValueInternalExtendToZoom;
72 case Percent:
73 case Fixed:
74 case Calculated:
75 case DeviceWidth:
76 case DeviceHeight:
77 case MaxSizeNone:
78 NOTREACHED();
79 break;
80 }
81 }
82
83 DEFINE_TRACE_AFTER_DISPATCH(CSSIdentifierValue)
84 {
85 CSSValue::traceAfterDispatch(visitor);
86 }
87
88 } // 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