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

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

Issue 2346193002: Split CSSPrimitiveValue into CSSPrimitiveValue and CSSIdentifierValue (Closed)
Patch Set: Replaced ASSERTs with DCHECKS in presubmit warnings Created 4 years, 3 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::createIdentifier(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).
rjwright 2016/09/22 06:12:50 Want to add this now?
sashab 2016/09/23 01:01:10 It makes some tests fail :( clarified the todo :)
48 }
49
50 CSSIdentifierValue::CSSIdentifierValue(const Length& length)
51 : CSSValue(IdentifierClass)
52 {
53 switch (length.type()) {
54 case Auto:
55 m_valueID = CSSValueAuto;
56 break;
57 case MinContent:
58 m_valueID = CSSValueMinContent;
59 break;
60 case MaxContent:
61 m_valueID = CSSValueMaxContent;
62 break;
63 case FillAvailable:
64 m_valueID = CSSValueWebkitFillAvailable;
65 break;
66 case FitContent:
67 m_valueID = CSSValueFitContent;
68 break;
69 case ExtendToZoom:
70 m_valueID = CSSValueInternalExtendToZoom;
71 case Percent:
72 case Fixed:
73 case Calculated:
74 case DeviceWidth:
75 case DeviceHeight:
76 case MaxSizeNone:
77 NOTREACHED();
78 break;
79 }
80 }
81
82 DEFINE_TRACE_AFTER_DISPATCH(CSSIdentifierValue)
83 {
84 CSSValue::traceAfterDispatch(visitor);
85 }
86
87 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698