Changeset 121982 in webkit
- Timestamp:
- Jul 6, 2012 10:05:39 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r121981 r121982 1 2012-07-06 Andreas Kling <kling@webkit.org> 2 3 Separate mutating CSSStyleDeclaration operations. 4 <http://webkit.org/b/89945> 5 6 Reviewed by Antti Koivisto. 7 8 Use separate paths for mutating the StylePropertySet wrapped by a CSSStyleDeclaration. 9 PropertySetCSSStyleDeclaration now has: 10 11 - propertySet() const 12 - ensureMutablePropertySet() 13 14 This is prep work for supporting immutable ElementAttributeData objects, the idea being 15 that calling ensureMutablePropertySet() may cause the element to convert its internal 16 attribute storage (which also holds the inline StylePropertySet.) 17 18 * css/PropertySetCSSStyleDeclaration.cpp: 19 (WebCore::PropertySetCSSStyleDeclaration::length): 20 (WebCore::PropertySetCSSStyleDeclaration::item): 21 (WebCore::PropertySetCSSStyleDeclaration::cssText): 22 (WebCore::PropertySetCSSStyleDeclaration::setCssText): 23 (WebCore::PropertySetCSSStyleDeclaration::getPropertyCSSValue): 24 (WebCore::PropertySetCSSStyleDeclaration::getPropertyValue): 25 (WebCore::PropertySetCSSStyleDeclaration::getPropertyPriority): 26 (WebCore::PropertySetCSSStyleDeclaration::getPropertyShorthand): 27 (WebCore::PropertySetCSSStyleDeclaration::isPropertyImplicit): 28 (WebCore::PropertySetCSSStyleDeclaration::setProperty): 29 (WebCore::PropertySetCSSStyleDeclaration::removeProperty): 30 (WebCore::PropertySetCSSStyleDeclaration::getPropertyCSSValueInternal): 31 (WebCore::PropertySetCSSStyleDeclaration::getPropertyValueInternal): 32 (WebCore::PropertySetCSSStyleDeclaration::setPropertyInternal): 33 (WebCore::PropertySetCSSStyleDeclaration::copy): 34 (WebCore::PropertySetCSSStyleDeclaration::makeMutable): 35 (WebCore::PropertySetCSSStyleDeclaration::cssPropertyMatches): 36 (WebCore::InlineCSSStyleDeclaration::didMutate): 37 (WebCore::InlineCSSStyleDeclaration::ensureMutablePropertySet): 38 * css/PropertySetCSSStyleDeclaration.h: 39 (PropertySetCSSStyleDeclaration): 40 (WebCore::PropertySetCSSStyleDeclaration::propertySet): 41 (WebCore::PropertySetCSSStyleDeclaration::ensureMutablePropertySet): 42 1 43 2012-07-06 Pavel Feldman <pfeldman@chromium.org> 2 44 -
trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp
r121874 r121982 133 133 unsigned PropertySetCSSStyleDeclaration::length() const 134 134 { 135 return m_propertySet->propertyCount();135 return propertySet()->propertyCount(); 136 136 } 137 137 138 138 String PropertySetCSSStyleDeclaration::item(unsigned i) const 139 139 { 140 if (i >= m_propertySet->propertyCount())140 if (i >= propertySet()->propertyCount()) 141 141 return ""; 142 return m_propertySet->propertyAt(i).cssName();142 return getPropertyName(propertySet()->propertyAt(i).id()); 143 143 } 144 144 145 145 String PropertySetCSSStyleDeclaration::cssText() const 146 146 { 147 return m_propertySet->asText();147 return propertySet()->asText(); 148 148 } 149 149 … … 157 157 ec = 0; 158 158 // FIXME: Detect syntax errors and set ec. 159 m_propertySet->parseDeclaration(text, contextStyleSheet());159 ensureMutablePropertySet()->parseDeclaration(text, contextStyleSheet()); 160 160 161 161 didMutate(PropertyChanged); … … 171 171 if (!propertyID) 172 172 return 0; 173 return cloneAndCacheForCSSOM( m_propertySet->getPropertyCSSValue(propertyID).get());173 return cloneAndCacheForCSSOM(propertySet()->getPropertyCSSValue(propertyID).get()); 174 174 } 175 175 … … 179 179 if (!propertyID) 180 180 return String(); 181 return m_propertySet->getPropertyValue(propertyID);181 return propertySet()->getPropertyValue(propertyID); 182 182 } 183 183 … … 187 187 if (!propertyID) 188 188 return String(); 189 return m_propertySet->propertyIsImportant(propertyID) ? "important" : "";189 return propertySet()->propertyIsImportant(propertyID) ? "important" : ""; 190 190 } 191 191 … … 195 195 if (!propertyID) 196 196 return String(); 197 CSSPropertyID shorthandID = m_propertySet->getPropertyShorthand(propertyID);197 CSSPropertyID shorthandID = propertySet()->getPropertyShorthand(propertyID); 198 198 if (!shorthandID) 199 199 return String(); … … 206 206 if (!propertyID) 207 207 return false; 208 return m_propertySet->isPropertyImplicit(propertyID);208 return propertySet()->isPropertyImplicit(propertyID); 209 209 } 210 210 … … 223 223 224 224 ec = 0; 225 bool changed = m_propertySet->setProperty(propertyID, value, important, contextStyleSheet());225 bool changed = ensureMutablePropertySet()->setProperty(propertyID, value, important, contextStyleSheet()); 226 226 227 227 didMutate(changed ? PropertyChanged : NoChanges); … … 249 249 ec = 0; 250 250 String result; 251 bool changed = m_propertySet->removeProperty(propertyID, &result);251 bool changed = ensureMutablePropertySet()->removeProperty(propertyID, &result); 252 252 253 253 didMutate(changed ? PropertyChanged : NoChanges); … … 263 263 PassRefPtr<CSSValue> PropertySetCSSStyleDeclaration::getPropertyCSSValueInternal(CSSPropertyID propertyID) 264 264 { 265 return m_propertySet->getPropertyCSSValue(propertyID);265 return propertySet()->getPropertyCSSValue(propertyID); 266 266 } 267 267 268 268 String PropertySetCSSStyleDeclaration::getPropertyValueInternal(CSSPropertyID propertyID) 269 269 { 270 return m_propertySet->getPropertyValue(propertyID);270 return propertySet()->getPropertyValue(propertyID); 271 271 } 272 272 … … 279 279 280 280 ec = 0; 281 bool changed = m_propertySet->setProperty(propertyID, value, important, contextStyleSheet());281 bool changed = ensureMutablePropertySet()->setProperty(propertyID, value, important, contextStyleSheet()); 282 282 283 283 didMutate(changed ? PropertyChanged : NoChanges); … … 314 314 PassRefPtr<StylePropertySet> PropertySetCSSStyleDeclaration::copy() const 315 315 { 316 return m_propertySet->copy();316 return propertySet()->copy(); 317 317 } 318 318 319 319 PassRefPtr<StylePropertySet> PropertySetCSSStyleDeclaration::makeMutable() 320 320 { 321 return m_propertySet;321 return ensureMutablePropertySet(); 322 322 } 323 323 324 324 bool PropertySetCSSStyleDeclaration::cssPropertyMatches(const CSSProperty* property) const 325 325 { 326 return m_propertySet->propertyMatches(property);326 return propertySet()->propertyMatches(property); 327 327 } 328 328 … … 390 390 if (!m_parentElement) 391 391 return; 392 392 393 m_parentElement->setNeedsStyleRecalc(InlineStyleChange); 393 394 m_parentElement->invalidateStyleAttribute(); … … 400 401 } 401 402 403 StylePropertySet* InlineCSSStyleDeclaration::ensureMutablePropertySet() 404 { 405 ASSERT(m_propertySet); 406 return m_propertySet; 407 } 408 402 409 } // namespace WebCore -
trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.h
r121570 r121982 48 48 virtual void ref() OVERRIDE; 49 49 virtual void deref() OVERRIDE; 50 51 protected: 52 const StylePropertySet* propertySet() const { return m_propertySet; } 53 virtual StylePropertySet* ensureMutablePropertySet() { return m_propertySet; } 50 54 51 55 private: … … 107 111 virtual void didMutate(MutationType) OVERRIDE; 108 112 113 virtual StylePropertySet* ensureMutablePropertySet() OVERRIDE { return m_propertySet; } 114 109 115 unsigned m_refCount; 110 116 CSSRule* m_parentRule; … … 126 132 127 133 virtual void didMutate(MutationType) OVERRIDE; 134 135 virtual StylePropertySet* ensureMutablePropertySet() OVERRIDE; 128 136 129 137 StyledElement* m_parentElement;
Note: See TracChangeset
for help on using the changeset viewer.