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

Side by Side Diff: Source/core/css/StylePropertySet.h

Issue 273843003: [Oilpan]: Make StylePropertySet fully garbage collected. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: review feedback Created 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/css/CSSKeyframeRule.cpp ('k') | Source/core/css/StylePropertySet.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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, 2008, 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2008, 2012 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 23 matching lines...) Expand all
34 34
35 class CSSRule; 35 class CSSRule;
36 class CSSStyleDeclaration; 36 class CSSStyleDeclaration;
37 class Element; 37 class Element;
38 class ImmutableStylePropertySet; 38 class ImmutableStylePropertySet;
39 class KURL; 39 class KURL;
40 class MutableStylePropertySet; 40 class MutableStylePropertySet;
41 class StylePropertyShorthand; 41 class StylePropertyShorthand;
42 class StyleSheetContents; 42 class StyleSheetContents;
43 43
44 class StylePropertySet : public RefCountedWillBeRefCountedGarbageCollected<Style PropertySet> { 44 class StylePropertySet : public RefCountedWillBeGarbageCollectedFinalized<StyleP ropertySet> {
45 friend class PropertyReference; 45 friend class PropertyReference;
46 public: 46 public:
47 47
48 #if ENABLE(OILPAN) 48 #if ENABLE(OILPAN)
49 // When oilpan is enabled override the finalize method to dispatch to the su bclasses' 49 // When oilpan is enabled override the finalize method to dispatch to the su bclasses'
50 // destructor. This can be removed once the MutableStylePropertySet's OwnPtr is moved 50 // destructor. This can be removed once the MutableStylePropertySet's OwnPtr is moved
51 // to the heap. 51 // to the heap.
52 void finalizeGarbageCollectedObject(); 52 void finalizeGarbageCollectedObject();
53 #else 53 #else
54 // Override RefCounted's deref() to ensure operator delete is called on 54 // Override RefCounted's deref() to ensure operator delete is called on
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 100
101 bool propertyIsImportant(CSSPropertyID) const; 101 bool propertyIsImportant(CSSPropertyID) const;
102 CSSPropertyID getPropertyShorthand(CSSPropertyID) const; 102 CSSPropertyID getPropertyShorthand(CSSPropertyID) const;
103 bool isPropertyImplicit(CSSPropertyID) const; 103 bool isPropertyImplicit(CSSPropertyID) const;
104 104
105 PassRefPtrWillBeRawPtr<MutableStylePropertySet> copyBlockProperties() const; 105 PassRefPtrWillBeRawPtr<MutableStylePropertySet> copyBlockProperties() const;
106 106
107 CSSParserMode cssParserMode() const { return static_cast<CSSParserMode>(m_cs sParserMode); } 107 CSSParserMode cssParserMode() const { return static_cast<CSSParserMode>(m_cs sParserMode); }
108 108
109 PassRefPtrWillBeRawPtr<MutableStylePropertySet> mutableCopy() const; 109 PassRefPtrWillBeRawPtr<MutableStylePropertySet> mutableCopy() const;
110 PassRefPtr<ImmutableStylePropertySet> immutableCopyIfNeeded() const; 110 PassRefPtrWillBeRawPtr<ImmutableStylePropertySet> immutableCopyIfNeeded() co nst;
111 111
112 PassRefPtrWillBeRawPtr<MutableStylePropertySet> copyPropertiesInSet(const Ve ctor<CSSPropertyID>&) const; 112 PassRefPtrWillBeRawPtr<MutableStylePropertySet> copyPropertiesInSet(const Ve ctor<CSSPropertyID>&) const;
113 113
114 String asText() const; 114 String asText() const;
115 115
116 bool isMutable() const { return m_isMutable; } 116 bool isMutable() const { return m_isMutable; }
117 117
118 bool hasFailedOrCanceledSubresources() const; 118 bool hasFailedOrCanceledSubresources() const;
119 119
120 static unsigned averageSizeInBytes(); 120 static unsigned averageSizeInBytes();
(...skipping 26 matching lines...) Expand all
147 unsigned m_cssParserMode : 3; 147 unsigned m_cssParserMode : 3;
148 mutable unsigned m_isMutable : 1; 148 mutable unsigned m_isMutable : 1;
149 unsigned m_arraySize : 28; 149 unsigned m_arraySize : 28;
150 150
151 friend class PropertySetCSSStyleDeclaration; 151 friend class PropertySetCSSStyleDeclaration;
152 }; 152 };
153 153
154 class ImmutableStylePropertySet : public StylePropertySet { 154 class ImmutableStylePropertySet : public StylePropertySet {
155 public: 155 public:
156 ~ImmutableStylePropertySet(); 156 ~ImmutableStylePropertySet();
157 static PassRefPtr<ImmutableStylePropertySet> create(const CSSProperty* prope rties, unsigned count, CSSParserMode); 157 static PassRefPtrWillBeRawPtr<ImmutableStylePropertySet> create(const CSSPro perty* properties, unsigned count, CSSParserMode);
158 158
159 unsigned propertyCount() const { return m_arraySize; } 159 unsigned propertyCount() const { return m_arraySize; }
160 160
161 const RawPtrWillBeMember<CSSValue>* valueArray() const; 161 const RawPtrWillBeMember<CSSValue>* valueArray() const;
162 const StylePropertyMetadata* metadataArray() const; 162 const StylePropertyMetadata* metadataArray() const;
163 int findPropertyIndex(CSSPropertyID) const; 163 int findPropertyIndex(CSSPropertyID) const;
164 164
165 void traceAfterDispatch(Visitor*); 165 void traceAfterDispatch(Visitor*);
166 166
167 void* operator new(std::size_t, void* location) 167 void* operator new(std::size_t, void* location)
(...skipping 12 matching lines...) Expand all
180 return reinterpret_cast<const RawPtrWillBeMember<CSSValue>*>(const_cast<cons t void**>(&(this->m_storage))); 180 return reinterpret_cast<const RawPtrWillBeMember<CSSValue>*>(const_cast<cons t void**>(&(this->m_storage)));
181 } 181 }
182 182
183 inline const StylePropertyMetadata* ImmutableStylePropertySet::metadataArray() c onst 183 inline const StylePropertyMetadata* ImmutableStylePropertySet::metadataArray() c onst
184 { 184 {
185 return reinterpret_cast<const StylePropertyMetadata*>(&reinterpret_cast<cons t char*>(&(this->m_storage))[m_arraySize * sizeof(RawPtrWillBeMember<CSSValue>)] ); 185 return reinterpret_cast<const StylePropertyMetadata*>(&reinterpret_cast<cons t char*>(&(this->m_storage))[m_arraySize * sizeof(RawPtrWillBeMember<CSSValue>)] );
186 } 186 }
187 187
188 DEFINE_TYPE_CASTS(ImmutableStylePropertySet, StylePropertySet, set, !set->isMuta ble(), !set.isMutable()); 188 DEFINE_TYPE_CASTS(ImmutableStylePropertySet, StylePropertySet, set, !set->isMuta ble(), !set.isMutable());
189 189
190 inline ImmutableStylePropertySet* toImmutableStylePropertySet(const RefPtr<Style PropertySet>& set)
191 {
192 return toImmutableStylePropertySet(set.get());
193 }
194
195 class MutableStylePropertySet : public StylePropertySet { 190 class MutableStylePropertySet : public StylePropertySet {
196 public: 191 public:
197 ~MutableStylePropertySet() { } 192 ~MutableStylePropertySet() { }
198 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> create(CSSParserMode = HTMLQuirksMode); 193 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> create(CSSParserMode = HTMLQuirksMode);
199 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> create(const CSSPrope rty* properties, unsigned count); 194 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> create(const CSSPrope rty* properties, unsigned count);
200 195
201 unsigned propertyCount() const { return m_propertyVector.size(); } 196 unsigned propertyCount() const { return m_propertyVector.size(); }
202 197
203 void addParsedProperties(const WillBeHeapVector<CSSProperty, 256>&); 198 void addParsedProperties(const WillBeHeapVector<CSSProperty, 256>&);
204 void addParsedProperty(const CSSProperty&); 199 void addParsedProperty(const CSSProperty&);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 CSSProperty* findCSSPropertyWithID(CSSPropertyID); 235 CSSProperty* findCSSPropertyWithID(CSSPropertyID);
241 OwnPtrWillBeMember<PropertySetCSSStyleDeclaration> m_cssomWrapper; 236 OwnPtrWillBeMember<PropertySetCSSStyleDeclaration> m_cssomWrapper;
242 237
243 friend class StylePropertySet; 238 friend class StylePropertySet;
244 239
245 WillBeHeapVector<CSSProperty, 4> m_propertyVector; 240 WillBeHeapVector<CSSProperty, 4> m_propertyVector;
246 }; 241 };
247 242
248 DEFINE_TYPE_CASTS(MutableStylePropertySet, StylePropertySet, set, set->isMutable (), set.isMutable()); 243 DEFINE_TYPE_CASTS(MutableStylePropertySet, StylePropertySet, set, set->isMutable (), set.isMutable());
249 244
250 inline MutableStylePropertySet* toMutableStylePropertySet(const RefPtr<StyleProp ertySet>& set) 245 inline MutableStylePropertySet* toMutableStylePropertySet(const RefPtrWillBeRawP tr<StylePropertySet>& set)
251 { 246 {
252 return toMutableStylePropertySet(set.get()); 247 return toMutableStylePropertySet(set.get());
253 } 248 }
249
250 inline MutableStylePropertySet* toMutableStylePropertySet(const Persistent<Style PropertySet>& set)
251 {
252 return toMutableStylePropertySet(set.get());
253 }
254
255 inline MutableStylePropertySet* toMutableStylePropertySet(const Member<StyleProp ertySet>& set)
256 {
257 return toMutableStylePropertySet(set.get());
258 }
254 259
255 inline const StylePropertyMetadata& StylePropertySet::PropertyReference::propert yMetadata() const 260 inline const StylePropertyMetadata& StylePropertySet::PropertyReference::propert yMetadata() const
256 { 261 {
257 if (m_propertySet.isMutable()) 262 if (m_propertySet.isMutable())
258 return toMutableStylePropertySet(m_propertySet).m_propertyVector.at(m_in dex).metadata(); 263 return toMutableStylePropertySet(m_propertySet).m_propertyVector.at(m_in dex).metadata();
259 return toImmutableStylePropertySet(m_propertySet).metadataArray()[m_index]; 264 return toImmutableStylePropertySet(m_propertySet).metadataArray()[m_index];
260 } 265 }
261 266
262 inline const CSSValue* StylePropertySet::PropertyReference::propertyValue() cons t 267 inline const CSSValue* StylePropertySet::PropertyReference::propertyValue() cons t
263 { 268 {
(...skipping 30 matching lines...) Expand all
294 inline int StylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const 299 inline int StylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const
295 { 300 {
296 if (m_isMutable) 301 if (m_isMutable)
297 return toMutableStylePropertySet(this)->findPropertyIndex(propertyID); 302 return toMutableStylePropertySet(this)->findPropertyIndex(propertyID);
298 return toImmutableStylePropertySet(this)->findPropertyIndex(propertyID); 303 return toImmutableStylePropertySet(this)->findPropertyIndex(propertyID);
299 } 304 }
300 305
301 } // namespace WebCore 306 } // namespace WebCore
302 307
303 #endif // StylePropertySet_h 308 #endif // StylePropertySet_h
OLDNEW
« no previous file with comments | « Source/core/css/CSSKeyframeRule.cpp ('k') | Source/core/css/StylePropertySet.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698