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

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

Issue 17448021: Make sure ImmutableStylePropertySet uses the new 16 bits size of StylePropertyMetadata. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 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
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 * Copyright (C) 2013 Intel Corporation. All rights reserved.
4 * 5 *
5 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
9 * 10 *
10 * This library is distributed in the hope that it will be useful, 11 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details. 14 * Library General Public License for more details.
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 // ImmutableStylePropertySet plus following properties, as a performance 148 // ImmutableStylePropertySet plus following properties, as a performance
148 // tweak. 149 // tweak.
149 NEW_DELETE_SAME_AS_MALLOC_FREE; 150 NEW_DELETE_SAME_AS_MALLOC_FREE;
150 public: 151 public:
151 ~ImmutableStylePropertySet(); 152 ~ImmutableStylePropertySet();
152 static PassRefPtr<ImmutableStylePropertySet> create(const CSSProperty* prope rties, unsigned count, CSSParserMode); 153 static PassRefPtr<ImmutableStylePropertySet> create(const CSSProperty* prope rties, unsigned count, CSSParserMode);
153 154
154 unsigned propertyCount() const { return m_arraySize; } 155 unsigned propertyCount() const { return m_arraySize; }
155 156
156 const CSSValue** valueArray() const; 157 const CSSValue** valueArray() const;
157 const StylePropertyMetadata* metadataArray() const; 158 const uint16_t* metadataArray() const;
158 159
159 void* m_storage; 160 void* m_storage;
160 161
161 private: 162 private:
162 ImmutableStylePropertySet(const CSSProperty*, unsigned count, CSSParserMode) ; 163 ImmutableStylePropertySet(const CSSProperty*, unsigned count, CSSParserMode) ;
163 }; 164 };
164 165
165 inline const CSSValue** ImmutableStylePropertySet::valueArray() const 166 inline const CSSValue** ImmutableStylePropertySet::valueArray() const
166 { 167 {
167 return reinterpret_cast<const CSSValue**>(const_cast<const void**>((&static_ cast<const ImmutableStylePropertySet*>(this)->m_storage))); 168 return reinterpret_cast<const CSSValue**>(const_cast<const void**>((&static_ cast<const ImmutableStylePropertySet*>(this)->m_storage)));
168 } 169 }
169 170
170 inline const StylePropertyMetadata* ImmutableStylePropertySet::metadataArray() c onst 171 inline const uint16_t* ImmutableStylePropertySet::metadataArray() const
171 { 172 {
172 return reinterpret_cast<const StylePropertyMetadata*>(&reinterpret_cast<cons t char*>((&static_cast<const ImmutableStylePropertySet*>(this)->m_storage))[m_ar raySize * sizeof(CSSValue*)]); 173 return reinterpret_cast<const uint16_t*>(&reinterpret_cast<const char*>((&st atic_cast<const ImmutableStylePropertySet*>(this)->m_storage))[m_arraySize * siz eof(CSSValue*)]);
Jeffrey Yasskin 2013/06/21 19:56:27 Do you actually need all these casts? 'this' shoul
173 } 174 }
174 175
175 class MutableStylePropertySet : public StylePropertySet { 176 class MutableStylePropertySet : public StylePropertySet {
176 public: 177 public:
177 ~MutableStylePropertySet(); 178 ~MutableStylePropertySet();
178 179
179 static PassRefPtr<MutableStylePropertySet> create(CSSParserMode = CSSQuirksM ode); 180 static PassRefPtr<MutableStylePropertySet> create(CSSParserMode = CSSQuirksM ode);
180 static PassRefPtr<MutableStylePropertySet> create(const CSSProperty* propert ies, unsigned count); 181 static PassRefPtr<MutableStylePropertySet> create(const CSSProperty* propert ies, unsigned count);
181 182
182 MutableStylePropertySet(const StylePropertySet&); 183 MutableStylePropertySet(const StylePropertySet&);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 MutableStylePropertySet(const CSSProperty* properties, unsigned count); 224 MutableStylePropertySet(const CSSProperty* properties, unsigned count);
224 225
225 bool removeShorthandProperty(CSSPropertyID); 226 bool removeShorthandProperty(CSSPropertyID);
226 CSSProperty* findCSSPropertyWithID(CSSPropertyID); 227 CSSProperty* findCSSPropertyWithID(CSSPropertyID);
227 }; 228 };
228 229
229 inline StylePropertyMetadata StylePropertySet::PropertyReference::propertyMetada ta() const 230 inline StylePropertyMetadata StylePropertySet::PropertyReference::propertyMetada ta() const
230 { 231 {
231 if (m_propertySet.isMutable()) 232 if (m_propertySet.isMutable())
232 return static_cast<const MutableStylePropertySet&>(m_propertySet).m_prop ertyVector.at(m_index).metadata(); 233 return static_cast<const MutableStylePropertySet&>(m_propertySet).m_prop ertyVector.at(m_index).metadata();
233 return static_cast<const ImmutableStylePropertySet&>(m_propertySet).metadata Array()[m_index]; 234 return StylePropertyMetadata(static_cast<const ImmutableStylePropertySet&>(m _propertySet).metadataArray()[m_index]);
234 } 235 }
235 236
236 inline const CSSValue* StylePropertySet::PropertyReference::propertyValue() cons t 237 inline const CSSValue* StylePropertySet::PropertyReference::propertyValue() cons t
237 { 238 {
238 if (m_propertySet.isMutable()) 239 if (m_propertySet.isMutable())
239 return static_cast<const MutableStylePropertySet&>(m_propertySet).m_prop ertyVector.at(m_index).value(); 240 return static_cast<const MutableStylePropertySet&>(m_propertySet).m_prop ertyVector.at(m_index).value();
240 return static_cast<const ImmutableStylePropertySet&>(m_propertySet).valueArr ay()[m_index]; 241 return static_cast<const ImmutableStylePropertySet&>(m_propertySet).valueArr ay()[m_index];
241 } 242 }
242 243
243 inline unsigned StylePropertySet::propertyCount() const 244 inline unsigned StylePropertySet::propertyCount() const
(...skipping 15 matching lines...) Expand all
259 260
260 if (m_isMutable) 261 if (m_isMutable)
261 delete static_cast<MutableStylePropertySet*>(this); 262 delete static_cast<MutableStylePropertySet*>(this);
262 else 263 else
263 delete static_cast<ImmutableStylePropertySet*>(this); 264 delete static_cast<ImmutableStylePropertySet*>(this);
264 } 265 }
265 266
266 } // namespace WebCore 267 } // namespace WebCore
267 268
268 #endif // StylePropertySet_h 269 #endif // StylePropertySet_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698