OLD | NEW |
---|---|
1 /* | 1 /* |
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
14 * | 14 * |
15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
19 */ | 19 */ |
20 | 20 |
21 #ifndef CSSValue_h | 21 #ifndef CSSValue_h |
22 #define CSSValue_h | 22 #define CSSValue_h |
23 | 23 |
24 #include "core/CoreExport.h" | 24 #include "core/CoreExport.h" |
25 #include "platform/heap/Handle.h" | 25 #include "platform/heap/Handle.h" |
26 #include "wtf/RefPtr.h" | 26 #include "wtf/RefPtr.h" |
27 | 27 |
28 namespace blink { | 28 namespace blink { |
29 | 29 |
30 class Length; | |
31 | |
32 // CSSValue stores parsed representations of values on the RHS of a CSS declarat ion. | |
33 // For example: | |
34 // width: 30px; | |
35 // Would create a CSSValue to represent '30px'. | |
36 // | |
37 // CSSValues are property-independent; they can be created for any property, but | |
Timothy Loh
2016/09/30 05:44:35
This sounds contradictory (and is probably wrong b
sashab
2016/09/30 06:45:48
Done, removed entire header comment in this file.
| |
38 // not all CSSValues are valid for all properties. | |
39 // | |
40 // All CSSValues should be immutable. | |
30 class CORE_EXPORT CSSValue : public GarbageCollectedFinalized<CSSValue> { | 41 class CORE_EXPORT CSSValue : public GarbageCollectedFinalized<CSSValue> { |
31 public: | 42 public: |
32 // Override operator new to allocate CSSValue subtype objects onto | 43 // Override operator new to allocate CSSValue subtype objects onto |
33 // a dedicated heap. | 44 // a dedicated heap. |
34 GC_PLUGIN_IGNORE("crbug.com/443854") | 45 GC_PLUGIN_IGNORE("crbug.com/443854") |
35 void* operator new(size_t size) | 46 void* operator new(size_t size) |
36 { | 47 { |
37 return allocateObject(size, false); | 48 return allocateObject(size, false); |
38 } | 49 } |
39 static void* allocateObject(size_t size, bool isEager) | 50 static void* allocateObject(size_t size, bool isEager) |
40 { | 51 { |
41 ThreadState* state = ThreadStateFor<ThreadingTrait<CSSValue>::Affinity>: :state(); | 52 ThreadState* state = ThreadStateFor<ThreadingTrait<CSSValue>::Affinity>: :state(); |
42 const char typeName[] = "blink::CSSValue"; | 53 const char typeName[] = "blink::CSSValue"; |
43 return ThreadHeap::allocateOnArenaIndex(state, size, isEager ? BlinkGC:: EagerSweepArenaIndex : BlinkGC::CSSValueArenaIndex, GCInfoTrait<CSSValue>::index (), typeName); | 54 return ThreadHeap::allocateOnArenaIndex(state, size, isEager ? BlinkGC:: EagerSweepArenaIndex : BlinkGC::CSSValueArenaIndex, GCInfoTrait<CSSValue>::index (), typeName); |
44 } | 55 } |
45 | 56 |
57 // TODO(sashab): Remove this method and move logic to the caller. | |
58 static CSSValue* create(const Length& value, float zoom); | |
59 | |
46 String cssText() const; | 60 String cssText() const; |
47 | 61 |
48 bool isPrimitiveValue() const { return m_classType == PrimitiveClass; } | 62 bool isPrimitiveValue() const { return m_classType == PrimitiveClass; } |
63 bool isIdentifierValue() const { return m_classType == IdentifierClass; } | |
49 bool isValuePair() const { return m_classType == ValuePairClass; } | 64 bool isValuePair() const { return m_classType == ValuePairClass; } |
50 bool isValueList() const { return m_classType >= ValueListClass; } | 65 bool isValueList() const { return m_classType >= ValueListClass; } |
51 | 66 |
52 bool isBaseValueList() const { return m_classType == ValueListClass; } | 67 bool isBaseValueList() const { return m_classType == ValueListClass; } |
53 | 68 |
54 bool isBasicShapeValue() const { return m_classType >= BasicShapeCircleClass && m_classType <= BasicShapeInsetClass; } | 69 bool isBasicShapeValue() const { return m_classType >= BasicShapeCircleClass && m_classType <= BasicShapeInsetClass; } |
55 bool isBasicShapeCircleValue() const { return m_classType == BasicShapeCircl eClass; } | 70 bool isBasicShapeCircleValue() const { return m_classType == BasicShapeCircl eClass; } |
56 bool isBasicShapeEllipseValue() const { return m_classType == BasicShapeElli pseClass; } | 71 bool isBasicShapeEllipseValue() const { return m_classType == BasicShapeElli pseClass; } |
57 bool isBasicShapePolygonValue() const { return m_classType == BasicShapePoly gonClass; } | 72 bool isBasicShapePolygonValue() const { return m_classType == BasicShapePoly gonClass; } |
58 bool isBasicShapeInsetValue() const { return m_classType == BasicShapeInsetC lass; } | 73 bool isBasicShapeInsetValue() const { return m_classType == BasicShapeInsetC lass; } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 // ~CSSValue should be public, because non-public ~CSSValue causes C2248 | 122 // ~CSSValue should be public, because non-public ~CSSValue causes C2248 |
108 // error: 'blink::CSSValue::~CSSValue' : cannot access protected member | 123 // error: 'blink::CSSValue::~CSSValue' : cannot access protected member |
109 // declared in class 'blink::CSSValue' when compiling | 124 // declared in class 'blink::CSSValue' when compiling |
110 // 'source\wtf\refcounted.h' by using msvc. | 125 // 'source\wtf\refcounted.h' by using msvc. |
111 ~CSSValue() { } | 126 ~CSSValue() { } |
112 | 127 |
113 protected: | 128 protected: |
114 static const size_t ClassTypeBits = 6; | 129 static const size_t ClassTypeBits = 6; |
115 enum ClassType { | 130 enum ClassType { |
116 PrimitiveClass, | 131 PrimitiveClass, |
132 IdentifierClass, | |
117 ColorClass, | 133 ColorClass, |
118 CounterClass, | 134 CounterClass, |
119 QuadClass, | 135 QuadClass, |
120 CustomIdentClass, | 136 CustomIdentClass, |
121 StringClass, | 137 StringClass, |
122 URIClass, | 138 URIClass, |
123 ValuePairClass, | 139 ValuePairClass, |
124 | 140 |
125 // Basic shape classes. | 141 // Basic shape classes. |
126 // TODO(sashab): Represent these as a single subclass, BasicShapeClass. | 142 // TODO(sashab): Represent these as a single subclass, BasicShapeClass. |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
253 return false; | 269 return false; |
254 return first->equals(*second); | 270 return first->equals(*second); |
255 } | 271 } |
256 | 272 |
257 #define DEFINE_CSS_VALUE_TYPE_CASTS(thisType, predicate) \ | 273 #define DEFINE_CSS_VALUE_TYPE_CASTS(thisType, predicate) \ |
258 DEFINE_TYPE_CASTS(thisType, CSSValue, value, value->predicate, value.predica te) | 274 DEFINE_TYPE_CASTS(thisType, CSSValue, value, value->predicate, value.predica te) |
259 | 275 |
260 } // namespace blink | 276 } // namespace blink |
261 | 277 |
262 #endif // CSSValue_h | 278 #endif // CSSValue_h |
OLD | NEW |