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

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

Issue 1481383002: [Experimental] CSSSerializer Proof-of-concept Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: snapshot: top_25 sites ser/dser now works Created 4 years, 11 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 /* 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,
(...skipping 13 matching lines...) Expand all
24 #include "core/CoreExport.h" 24 #include "core/CoreExport.h"
25 #include "platform/heap/Handle.h" 25 #include "platform/heap/Handle.h"
26 #include "platform/weborigin/KURL.h" 26 #include "platform/weborigin/KURL.h"
27 #include "wtf/HashMap.h" 27 #include "wtf/HashMap.h"
28 #include "wtf/ListHashSet.h" 28 #include "wtf/ListHashSet.h"
29 #include "wtf/RefCounted.h" 29 #include "wtf/RefCounted.h"
30 #include "wtf/RefPtr.h" 30 #include "wtf/RefPtr.h"
31 31
32 namespace blink { 32 namespace blink {
33 33
34 class CSSDeserializeStream;
35 class CSSSerializeStream;
36
34 class CORE_EXPORT CSSValue : public RefCountedWillBeGarbageCollectedFinalized<CS SValue> { 37 class CORE_EXPORT CSSValue : public RefCountedWillBeGarbageCollectedFinalized<CS SValue> {
35 #if ENABLE(OILPAN) 38 #if ENABLE(OILPAN)
36 public: 39 public:
37 // Override operator new to allocate CSSValue subtype objects onto 40 // Override operator new to allocate CSSValue subtype objects onto
38 // a dedicated heap. 41 // a dedicated heap.
39 GC_PLUGIN_IGNORE("crbug.com/443854") 42 GC_PLUGIN_IGNORE("crbug.com/443854")
40 void* operator new(size_t size) 43 void* operator new(size_t size)
41 { 44 {
42 return allocateObject(size, false); 45 return allocateObject(size, false);
43 } 46 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 bool isContentDistributionValue() const { return m_classType == CSSContentDi stributionClass; } 108 bool isContentDistributionValue() const { return m_classType == CSSContentDi stributionClass; }
106 bool isUnicodeRangeValue() const { return m_classType == UnicodeRangeClass; } 109 bool isUnicodeRangeValue() const { return m_classType == UnicodeRangeClass; }
107 bool isGridLineNamesValue() const { return m_classType == GridLineNamesClass ; } 110 bool isGridLineNamesValue() const { return m_classType == GridLineNamesClass ; }
108 bool isCustomPropertyDeclaration() const { return m_classType == CustomPrope rtyDeclarationClass; } 111 bool isCustomPropertyDeclaration() const { return m_classType == CustomPrope rtyDeclarationClass; }
109 bool isVariableReferenceValue() const { return m_classType == VariableRefere nceClass; } 112 bool isVariableReferenceValue() const { return m_classType == VariableRefere nceClass; }
110 113
111 bool hasFailedOrCanceledSubresources() const; 114 bool hasFailedOrCanceledSubresources() const;
112 115
113 bool equals(const CSSValue&) const; 116 bool equals(const CSSValue&) const;
114 117
118 static PassRefPtrWillBeRawPtr<CSSValue> deserialize(CSSDeserializeStream*);
119 void serialize(CSSSerializeStream*) const;
120
115 void finalizeGarbageCollectedObject(); 121 void finalizeGarbageCollectedObject();
116 DEFINE_INLINE_TRACE_AFTER_DISPATCH() { } 122 DEFINE_INLINE_TRACE_AFTER_DISPATCH() { }
117 DECLARE_TRACE(); 123 DECLARE_TRACE();
118 124
119 // ~CSSValue should be public, because non-public ~CSSValue causes C2248 125 // ~CSSValue should be public, because non-public ~CSSValue causes C2248
120 // error: 'blink::CSSValue::~CSSValue' : cannot access protected member 126 // error: 'blink::CSSValue::~CSSValue' : cannot access protected member
121 // declared in class 'blink::CSSValue' when compiling 127 // declared in class 'blink::CSSValue' when compiling
122 // 'source\wtf\refcounted.h' by using msvc. 128 // 'source\wtf\refcounted.h' by using msvc.
123 ~CSSValue() { } 129 ~CSSValue() { }
124 130
125 protected: 131 // protected:
132 public:
126 static const size_t ClassTypeBits = 6; 133 static const size_t ClassTypeBits = 6;
127 enum ClassType { 134 enum ClassType {
128 PrimitiveClass, 135 PrimitiveClass,
129 ColorClass, 136 ColorClass,
130 CounterClass, 137 CounterClass,
131 QuadClass, 138 QuadClass,
132 CustomIdentClass, 139 CustomIdentClass,
133 StringClass, 140 StringClass,
134 URIClass, 141 URIClass,
135 ValuePairClass, 142 ValuePairClass,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 // Don't go making it virtual again unless you know exactly what you're doin g! 212 // Don't go making it virtual again unless you know exactly what you're doin g!
206 213
207 private: 214 private:
208 void destroy(); 215 void destroy();
209 216
210 protected: 217 protected:
211 // The bits in this section are only used by specific subclasses but kept he re 218 // The bits in this section are only used by specific subclasses but kept he re
212 // to maximize struct packing. 219 // to maximize struct packing.
213 220
214 // CSSPrimitiveValue bits: 221 // CSSPrimitiveValue bits:
215 unsigned m_primitiveUnitType : 7; // CSSPrimitiveValue::UnitType 222 union {
216 mutable unsigned m_hasCachedCSSText : 1; 223 struct {
224 unsigned m_primitiveUnitType : 7; // CSSPrimitiveValue::UnitType
225 mutable unsigned m_hasCachedCSSText : 1;
217 226
218 unsigned m_valueListSeparator : ValueListSeparatorBits; 227 unsigned m_valueListSeparator : ValueListSeparatorBits;
219 228
220 private: 229 // private:
221 unsigned m_classType : ClassTypeBits; // ClassType 230 unsigned m_classType : ClassTypeBits; // ClassType
231 };
232 unsigned m_bitfields;
233 };
234
235 union aaaa {
236 struct {
237 unsigned m_primitiveUnitType : 7; // CSSPrimitiveValue::UnitType
238 mutable unsigned m_hasCachedCSSText : 1;
239
240 unsigned m_valueListSeparator : ValueListSeparatorBits;
241
242 // private:
243 unsigned m_classType : ClassTypeBits; // ClassType
244 };
245 unsigned m_bitfields;
246 };
222 }; 247 };
223 248
224 template<typename CSSValueType, size_t inlineCapacity> 249 template<typename CSSValueType, size_t inlineCapacity>
225 inline bool compareCSSValueVector(const WillBeHeapVector<RefPtrWillBeMember<CSSV alueType>, inlineCapacity>& firstVector, const WillBeHeapVector<RefPtrWillBeMemb er<CSSValueType>, inlineCapacity>& secondVector) 250 inline bool compareCSSValueVector(const WillBeHeapVector<RefPtrWillBeMember<CSSV alueType>, inlineCapacity>& firstVector, const WillBeHeapVector<RefPtrWillBeMemb er<CSSValueType>, inlineCapacity>& secondVector)
226 { 251 {
227 size_t size = firstVector.size(); 252 size_t size = firstVector.size();
228 if (size != secondVector.size()) 253 if (size != secondVector.size())
229 return false; 254 return false;
230 255
231 for (size_t i = 0; i < size; i++) { 256 for (size_t i = 0; i < size; i++) {
(...skipping 29 matching lines...) Expand all
261 template<typename CSSValueType> 286 template<typename CSSValueType>
262 inline bool compareCSSValuePtr(const Member<CSSValueType>& first, const Member<C SSValueType>& second) 287 inline bool compareCSSValuePtr(const Member<CSSValueType>& first, const Member<C SSValueType>& second)
263 { 288 {
264 if (first == second) 289 if (first == second)
265 return true; 290 return true;
266 if (!first || !second) 291 if (!first || !second)
267 return false; 292 return false;
268 return first->equals(*second); 293 return first->equals(*second);
269 } 294 }
270 295
296 template<typename T> class CSSSerializeTrait;
297 template<> class CSSSerializeTrait<CSSValue> {
298 public:
299 static void serializeNull(CSSSerializeStream*);
300 static void serializeNonNullHeader(CSSSerializeStream*) { }
301 };
302
303 template<typename T> class CSSDeserializeTrait;
304 template<> class CSSDeserializeTrait<CSSValue> {
305 public:
306 static bool deserializeNonNullHeader(CSSDeserializeStream*)
307 {
308 // CSSValue::deserialize will return nullptr if needed.
309 return true;
310 }
311 };
312
271 #define DEFINE_CSS_VALUE_TYPE_CASTS(thisType, predicate) \ 313 #define DEFINE_CSS_VALUE_TYPE_CASTS(thisType, predicate) \
272 DEFINE_TYPE_CASTS(thisType, CSSValue, value, value->predicate, value.predica te) 314 DEFINE_TYPE_CASTS(thisType, CSSValue, value, value->predicate, value.predica te)
273 315
274 } // namespace blink 316 } // namespace blink
275 317
276 #endif // CSSValue_h 318 #endif // CSSValue_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSUnicodeRangeValue.cpp ('k') | third_party/WebKit/Source/core/css/CSSValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698