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

Side by Side Diff: third_party/WebKit/Source/core/css/cssom/CSSStyleValue.h

Issue 2903413002: Restructure type tracking in StyleValues to work better with new numeric types (Closed)
Patch Set: rebase Created 3 years, 6 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CSSStyleValue_h 5 #ifndef CSSStyleValue_h
6 #define CSSStyleValue_h 6 #define CSSStyleValue_h
7 7
8 #include "core/CSSPropertyNames.h" 8 #include "core/CSSPropertyNames.h"
9 #include "core/CoreExport.h" 9 #include "core/CoreExport.h"
10 #include "core/css/CSSValue.h" 10 #include "core/css/CSSValue.h"
11 #include "platform/bindings/ScriptWrappable.h" 11 #include "platform/bindings/ScriptWrappable.h"
12 #include "platform/wtf/text/WTFString.h" 12 #include "platform/wtf/text/WTFString.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 class ExceptionState; 16 class ExceptionState;
17 class ScriptState; 17 class ScriptState;
18 class ScriptValue; 18 class ScriptValue;
19 19
20 // The base class for all CSS values returned by the Typed OM. 20 // The base class for all CSS values returned by the Typed OM.
21 // See CSSStyleValue.idl for additional documentation about this class. 21 // See CSSStyleValue.idl for additional documentation about this class.
22 class CORE_EXPORT CSSStyleValue 22 class CORE_EXPORT CSSStyleValue
23 : public GarbageCollectedFinalized<CSSStyleValue>, 23 : public GarbageCollectedFinalized<CSSStyleValue>,
24 public ScriptWrappable { 24 public ScriptWrappable {
25 WTF_MAKE_NONCOPYABLE(CSSStyleValue); 25 WTF_MAKE_NONCOPYABLE(CSSStyleValue);
26 DEFINE_WRAPPERTYPEINFO(); 26 DEFINE_WRAPPERTYPEINFO();
27 27
28 public: 28 public:
29 enum StyleValueType { 29 enum StyleValueType {
30 // This list corresponds to each non-abstract subclass. 30 kUnknownType,
31 kUnknown,
32 kAngleType, 31 kAngleType,
33 kCalcLengthType, 32 kFlexType,
33 kFrequencyType,
34 kKeywordType, 34 kKeywordType,
35 kLengthType,
35 kNumberType, 36 kNumberType,
37 kPercentType,
36 kPositionType, 38 kPositionType,
37 kSimpleLengthType, 39 kResolutionType,
40 kTimeType,
38 kTransformType, 41 kTransformType,
39 kUnitType,
40 kUnparsedType, 42 kUnparsedType,
41 kURLImageType, 43 kURLImageType,
44 kInvalidType,
42 }; 45 };
43 46
44 virtual ~CSSStyleValue() {}
45
46 virtual StyleValueType GetType() const = 0;
47
48 static ScriptValue parse(ScriptState*, 47 static ScriptValue parse(ScriptState*,
49 const String& property_name, 48 const String& property_name,
50 const String& value, 49 const String& value,
51 ExceptionState&); 50 ExceptionState&);
52 51
52 virtual ~CSSStyleValue() {}
53
54 virtual StyleValueType GetType() const = 0;
55 virtual bool ContainsPercent() const { return false; }
56
53 virtual const CSSValue* ToCSSValue() const = 0; 57 virtual const CSSValue* ToCSSValue() const = 0;
54 virtual const CSSValue* ToCSSValueWithProperty(CSSPropertyID) const { 58 virtual const CSSValue* ToCSSValueWithProperty(CSSPropertyID) const {
55 return ToCSSValue(); 59 return ToCSSValue();
56 } 60 }
57 virtual String toString() const { 61 virtual String toString() const {
58 const CSSValue* result = ToCSSValue(); 62 const CSSValue* result = ToCSSValue();
59 // TODO(meade): Remove this once all the number and length types are 63 // TODO(meade): Remove this once all the number and length types are
60 // rewritten. 64 // rewritten.
61 return result ? result->CssText() : ""; 65 return result ? result->CssText() : "";
62 } 66 }
63 67
64 DEFINE_INLINE_VIRTUAL_TRACE() {} 68 DEFINE_INLINE_VIRTUAL_TRACE() {}
65 69
66 protected: 70 protected:
71 static String StyleValueTypeToString(StyleValueType);
72
67 CSSStyleValue() {} 73 CSSStyleValue() {}
68 }; 74 };
69 75
70 typedef HeapVector<Member<CSSStyleValue>> CSSStyleValueVector; 76 typedef HeapVector<Member<CSSStyleValue>> CSSStyleValueVector;
71 77
72 } // namespace blink 78 } // namespace blink
73 79
74 #endif 80 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698