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

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

Issue 1233363002: CSSValue Immediates: Replace CSSPrimitiveValue usage with const references (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@cssvalue_patch_4_attempt_2
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.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 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 95 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 void setProperty(CSSPropertyID, CSSPrimitiveValue, bool important = false); 198 void setProperty(CSSPropertyID, CSSPrimitiveValue, bool important = false);
201 199
202 // These do not. FIXME: This is too messy, we can do better. 200 // These do not. FIXME: This is too messy, we can do better.
203 bool setProperty(CSSPropertyID, CSSValueID identifier, bool important = fals e); 201 bool setProperty(CSSPropertyID, CSSValueID identifier, bool important = fals e);
204 bool setProperty(const CSSProperty&, CSSProperty* slot = 0); 202 bool setProperty(const CSSProperty&, CSSProperty* slot = 0);
205 203
206 bool removeProperty(CSSPropertyID, String* returnText = 0); 204 bool removeProperty(CSSPropertyID, String* returnText = 0);
207 bool removePropertiesInSet(const CSSPropertyID* set, unsigned length); 205 bool removePropertiesInSet(const CSSPropertyID* set, unsigned length);
208 void removeEquivalentProperties(const StylePropertySet*); 206 void removeEquivalentProperties(const StylePropertySet*);
209 void removeEquivalentProperties(const CSSStyleDeclaration*); 207 void removeEquivalentProperties(const CSSStyleDeclaration*);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 return toMutableStylePropertySet(set.get()); 247 return toMutableStylePropertySet(set.get());
250 } 248 }
251 249
252 inline const StylePropertyMetadata& StylePropertySet::PropertyReference::propert yMetadata() const 250 inline const StylePropertyMetadata& StylePropertySet::PropertyReference::propert yMetadata() const
253 { 251 {
254 if (m_propertySet.isMutable()) 252 if (m_propertySet.isMutable())
255 return toMutableStylePropertySet(m_propertySet).m_propertyVector.at(m_in dex).metadata(); 253 return toMutableStylePropertySet(m_propertySet).m_propertyVector.at(m_in dex).metadata();
256 return toImmutableStylePropertySet(m_propertySet).metadataArray()[m_index]; 254 return toImmutableStylePropertySet(m_propertySet).metadataArray()[m_index];
257 } 255 }
258 256
259 inline const CSSValue StylePropertySet::PropertyReference::propertyValue() const 257 inline const CSSValue& StylePropertySet::PropertyReference::propertyValue() cons t
260 { 258 {
261 if (m_propertySet.isMutable()) 259 if (m_propertySet.isMutable())
262 return toMutableStylePropertySet(m_propertySet).m_propertyVector.at(m_in dex).value(); 260 return toMutableStylePropertySet(m_propertySet).m_propertyVector.at(m_in dex).value();
263 return toImmutableStylePropertySet(m_propertySet).valueArray()[m_index]; 261 return toImmutableStylePropertySet(m_propertySet).valueArray()[m_index];
264 } 262 }
265 263
266 inline unsigned StylePropertySet::propertyCount() const 264 inline unsigned StylePropertySet::propertyCount() const
267 { 265 {
268 if (m_isMutable) 266 if (m_isMutable)
269 return toMutableStylePropertySet(this)->m_propertyVector.size(); 267 return toMutableStylePropertySet(this)->m_propertyVector.size();
(...skipping 21 matching lines...) Expand all
291 inline int StylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const 289 inline int StylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const
292 { 290 {
293 if (m_isMutable) 291 if (m_isMutable)
294 return toMutableStylePropertySet(this)->findPropertyIndex(propertyID); 292 return toMutableStylePropertySet(this)->findPropertyIndex(propertyID);
295 return toImmutableStylePropertySet(this)->findPropertyIndex(propertyID); 293 return toImmutableStylePropertySet(this)->findPropertyIndex(propertyID);
296 } 294 }
297 295
298 } // namespace blink 296 } // namespace blink
299 297
300 #endif // StylePropertySet_h 298 #endif // StylePropertySet_h
OLDNEW
« no previous file with comments | « Source/core/css/StylePropertySerializer.cpp ('k') | Source/core/css/StylePropertySet.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698