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

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

Issue 1238943004: CSSValue Immediates: Replace CSSValue usage with const references (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@cssvalue_patch_1
Patch Set: Rebase Created 5 years, 4 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
« no previous file with comments | « Source/core/css/StylePropertySerializer.h ('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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 { 63 {
64 } 64 }
65 65
66 CSSPropertyID id() const { return static_cast<CSSPropertyID>(propertyMet adata().m_propertyID); } 66 CSSPropertyID id() const { return static_cast<CSSPropertyID>(propertyMet adata().m_propertyID); }
67 CSSPropertyID shorthandID() const { return propertyMetadata().shorthandI D(); } 67 CSSPropertyID shorthandID() const { return propertyMetadata().shorthandI D(); }
68 68
69 bool isImportant() const { return propertyMetadata().m_important; } 69 bool isImportant() const { return propertyMetadata().m_important; }
70 bool isInherited() const { return propertyMetadata().m_inherited; } 70 bool isInherited() const { return propertyMetadata().m_inherited; }
71 bool isImplicit() const { return propertyMetadata().m_implicit; } 71 bool isImplicit() const { return propertyMetadata().m_implicit; }
72 72
73 const CSSValue value() const { return propertyValue(); } 73 const CSSValue& value() const { return propertyValue(); }
74 // FIXME: We should try to remove this mutable overload.
75 CSSValue value() { return propertyValue(); }
76 74
77 // FIXME: Remove this. 75 // FIXME: Remove this.
78 CSSProperty toCSSProperty() const { return CSSProperty(propertyMetadata( ), propertyValue()); } 76 CSSProperty toCSSProperty() const { return CSSProperty(propertyMetadata( ), propertyValue()); }
79 77
80 const StylePropertyMetadata& propertyMetadata() const; 78 const StylePropertyMetadata& propertyMetadata() const;
81 79
82 private: 80 private:
83 const CSSValue propertyValue() const; 81 const CSSValue& propertyValue() const;
84 82
85 const StylePropertySet& m_propertySet; 83 const StylePropertySet& m_propertySet;
86 unsigned m_index; 84 unsigned m_index;
87 }; 85 };
88 86
89 unsigned propertyCount() const; 87 unsigned propertyCount() const;
90 bool isEmpty() const; 88 bool isEmpty() const;
91 PropertyReference propertyAt(unsigned index) const { return PropertyReferenc e(*this, index); } 89 PropertyReference propertyAt(unsigned index) const { return PropertyReferenc e(*this, index); }
92 int findPropertyIndex(CSSPropertyID) const; 90 int findPropertyIndex(CSSPropertyID) const;
93 bool hasProperty(CSSPropertyID property) const { return findPropertyIndex(pr operty) != -1; } 91 bool hasProperty(CSSPropertyID property) const { return findPropertyIndex(pr operty) != -1; }
(...skipping 17 matching lines...) Expand all
111 bool isMutable() const { return m_isMutable; } 109 bool isMutable() const { return m_isMutable; }
112 110
113 bool hasFailedOrCanceledSubresources() const; 111 bool hasFailedOrCanceledSubresources() const;
114 112
115 static unsigned averageSizeInBytes(); 113 static unsigned averageSizeInBytes();
116 114
117 #ifndef NDEBUG 115 #ifndef NDEBUG
118 void showStyle(); 116 void showStyle();
119 #endif 117 #endif
120 118
121 bool propertyMatches(CSSPropertyID, const CSSValue) const; 119 bool propertyMatches(CSSPropertyID, const CSSValue&) const;
122 120
123 DECLARE_TRACE(); 121 DECLARE_TRACE();
124 DEFINE_INLINE_TRACE_AFTER_DISPATCH() { } 122 DEFINE_INLINE_TRACE_AFTER_DISPATCH() { }
125 123
126 protected: 124 protected:
127 125
128 enum { MaxArraySize = (1 << 28) - 1 }; 126 enum { MaxArraySize = (1 << 28) - 1 };
129 127
130 StylePropertySet(CSSParserMode cssParserMode) 128 StylePropertySet(CSSParserMode cssParserMode)
131 : m_cssParserMode(cssParserMode) 129 : m_cssParserMode(cssParserMode)
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> create(const CSSPrope rty* properties, unsigned count); 187 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> create(const CSSPrope rty* properties, unsigned count);
190 188
191 unsigned propertyCount() const { return m_propertyVector.size(); } 189 unsigned propertyCount() const { return m_propertyVector.size(); }
192 190
193 // Returns whether this style set was changed. 191 // Returns whether this style set was changed.
194 bool addParsedProperties(const WillBeHeapVector<CSSProperty, 256>&); 192 bool addParsedProperties(const WillBeHeapVector<CSSProperty, 256>&);
195 bool addRespectingCascade(const CSSProperty&); 193 bool addRespectingCascade(const CSSProperty&);
196 194
197 // These expand shorthand properties into multiple properties. 195 // These expand shorthand properties into multiple properties.
198 bool setProperty(CSSPropertyID unresolvedProperty, const String& value, bool important = false, StyleSheetContents* contextStyleSheet = 0); 196 bool setProperty(CSSPropertyID unresolvedProperty, const String& value, bool important = false, StyleSheetContents* contextStyleSheet = 0);
199 void setProperty(CSSPropertyID, CSSValue, bool important = false); 197 void setProperty(CSSPropertyID, const CSSValue&, bool important = false);
200 198
201 // These do not. FIXME: This is too messy, we can do better. 199 // These do not. FIXME: This is too messy, we can do better.
202 bool setProperty(CSSPropertyID, CSSValueID identifier, bool important = fals e); 200 bool setProperty(CSSPropertyID, CSSValueID identifier, bool important = fals e);
203 bool setProperty(const CSSProperty&, CSSProperty* slot = 0); 201 bool setProperty(const CSSProperty&, CSSProperty* slot = 0);
204 202
205 bool removeProperty(CSSPropertyID, String* returnText = 0); 203 bool removeProperty(CSSPropertyID, String* returnText = 0);
206 bool removePropertiesInSet(const CSSPropertyID* set, unsigned length); 204 bool removePropertiesInSet(const CSSPropertyID* set, unsigned length);
207 void removeEquivalentProperties(const StylePropertySet*); 205 void removeEquivalentProperties(const StylePropertySet*);
208 void removeEquivalentProperties(const CSSStyleDeclaration*); 206 void removeEquivalentProperties(const CSSStyleDeclaration*);
209 207
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 return toMutableStylePropertySet(set.get()); 246 return toMutableStylePropertySet(set.get());
249 } 247 }
250 248
251 inline const StylePropertyMetadata& StylePropertySet::PropertyReference::propert yMetadata() const 249 inline const StylePropertyMetadata& StylePropertySet::PropertyReference::propert yMetadata() const
252 { 250 {
253 if (m_propertySet.isMutable()) 251 if (m_propertySet.isMutable())
254 return toMutableStylePropertySet(m_propertySet).m_propertyVector.at(m_in dex).metadata(); 252 return toMutableStylePropertySet(m_propertySet).m_propertyVector.at(m_in dex).metadata();
255 return toImmutableStylePropertySet(m_propertySet).metadataArray()[m_index]; 253 return toImmutableStylePropertySet(m_propertySet).metadataArray()[m_index];
256 } 254 }
257 255
258 inline const CSSValue StylePropertySet::PropertyReference::propertyValue() const 256 inline const CSSValue& StylePropertySet::PropertyReference::propertyValue() cons t
259 { 257 {
260 if (m_propertySet.isMutable()) 258 if (m_propertySet.isMutable())
261 return toMutableStylePropertySet(m_propertySet).m_propertyVector.at(m_in dex).value(); 259 return toMutableStylePropertySet(m_propertySet).m_propertyVector.at(m_in dex).value();
262 return toImmutableStylePropertySet(m_propertySet).valueArray()[m_index]; 260 return toImmutableStylePropertySet(m_propertySet).valueArray()[m_index];
263 } 261 }
264 262
265 inline unsigned StylePropertySet::propertyCount() const 263 inline unsigned StylePropertySet::propertyCount() const
266 { 264 {
267 if (m_isMutable) 265 if (m_isMutable)
268 return toMutableStylePropertySet(this)->m_propertyVector.size(); 266 return toMutableStylePropertySet(this)->m_propertyVector.size();
(...skipping 21 matching lines...) Expand all
290 inline int StylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const 288 inline int StylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const
291 { 289 {
292 if (m_isMutable) 290 if (m_isMutable)
293 return toMutableStylePropertySet(this)->findPropertyIndex(propertyID); 291 return toMutableStylePropertySet(this)->findPropertyIndex(propertyID);
294 return toImmutableStylePropertySet(this)->findPropertyIndex(propertyID); 292 return toImmutableStylePropertySet(this)->findPropertyIndex(propertyID);
295 } 293 }
296 294
297 } // namespace blink 295 } // namespace blink
298 296
299 #endif // StylePropertySet_h 297 #endif // StylePropertySet_h
OLDNEW
« no previous file with comments | « Source/core/css/StylePropertySerializer.h ('k') | Source/core/css/StylePropertySet.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698