| OLD | NEW |
| 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, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r
ights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r
ights reserved. |
| 4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. | 4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * 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. |
| 10 * | 10 * |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 m_propertySet->ref(); | 130 m_propertySet->ref(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void PropertySetCSSStyleDeclaration::deref() | 133 void PropertySetCSSStyleDeclaration::deref() |
| 134 { | 134 { |
| 135 m_propertySet->deref(); | 135 m_propertySet->deref(); |
| 136 } | 136 } |
| 137 | 137 |
| 138 unsigned AbstractPropertySetCSSStyleDeclaration::length() const | 138 unsigned AbstractPropertySetCSSStyleDeclaration::length() const |
| 139 { | 139 { |
| 140 return propertySet()->propertyCount(); | 140 return propertySet().propertyCount(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 String AbstractPropertySetCSSStyleDeclaration::item(unsigned i) const | 143 String AbstractPropertySetCSSStyleDeclaration::item(unsigned i) const |
| 144 { | 144 { |
| 145 if (i >= propertySet()->propertyCount()) | 145 if (i >= propertySet().propertyCount()) |
| 146 return ""; | 146 return ""; |
| 147 return propertySet()->propertyAt(i).cssName(); | 147 return propertySet().propertyAt(i).cssName(); |
| 148 } | 148 } |
| 149 | 149 |
| 150 String AbstractPropertySetCSSStyleDeclaration::cssText() const | 150 String AbstractPropertySetCSSStyleDeclaration::cssText() const |
| 151 { | 151 { |
| 152 return propertySet()->asText(); | 152 return propertySet().asText(); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void AbstractPropertySetCSSStyleDeclaration::setCSSText(const String& text, Exce
ptionState& exceptionState) | 155 void AbstractPropertySetCSSStyleDeclaration::setCSSText(const String& text, Exce
ptionState& exceptionState) |
| 156 { | 156 { |
| 157 StyleAttributeMutationScope mutationScope(this); | 157 StyleAttributeMutationScope mutationScope(this); |
| 158 willMutate(); | 158 willMutate(); |
| 159 | 159 |
| 160 // FIXME: Detect syntax errors and set exceptionState. | 160 // FIXME: Detect syntax errors and set exceptionState. |
| 161 propertySet()->parseDeclaration(text, contextStyleSheet()); | 161 propertySet().parseDeclaration(text, contextStyleSheet()); |
| 162 | 162 |
| 163 didMutate(PropertyChanged); | 163 didMutate(PropertyChanged); |
| 164 | 164 |
| 165 mutationScope.enqueueMutationRecord(); | 165 mutationScope.enqueueMutationRecord(); |
| 166 } | 166 } |
| 167 | 167 |
| 168 PassRefPtrWillBeRawPtr<CSSValue> AbstractPropertySetCSSStyleDeclaration::getProp
ertyCSSValue(const String& propertyName) | 168 PassRefPtrWillBeRawPtr<CSSValue> AbstractPropertySetCSSStyleDeclaration::getProp
ertyCSSValue(const String& propertyName) |
| 169 { | 169 { |
| 170 CSSPropertyID propertyID = cssPropertyID(propertyName); | 170 CSSPropertyID propertyID = cssPropertyID(propertyName); |
| 171 if (!propertyID) | 171 if (!propertyID) |
| 172 return nullptr; | 172 return nullptr; |
| 173 return cloneAndCacheForCSSOM(propertySet()->getPropertyCSSValue(propertyID).
get()); | 173 return cloneAndCacheForCSSOM(propertySet().getPropertyCSSValue(propertyID).g
et()); |
| 174 } | 174 } |
| 175 | 175 |
| 176 String AbstractPropertySetCSSStyleDeclaration::getPropertyValue(const String &pr
opertyName) | 176 String AbstractPropertySetCSSStyleDeclaration::getPropertyValue(const String &pr
opertyName) |
| 177 { | 177 { |
| 178 CSSPropertyID propertyID = cssPropertyID(propertyName); | 178 CSSPropertyID propertyID = cssPropertyID(propertyName); |
| 179 if (!propertyID) | 179 if (!propertyID) |
| 180 return String(); | 180 return String(); |
| 181 return propertySet()->getPropertyValue(propertyID); | 181 return propertySet().getPropertyValue(propertyID); |
| 182 } | 182 } |
| 183 | 183 |
| 184 String AbstractPropertySetCSSStyleDeclaration::getPropertyPriority(const String&
propertyName) | 184 String AbstractPropertySetCSSStyleDeclaration::getPropertyPriority(const String&
propertyName) |
| 185 { | 185 { |
| 186 CSSPropertyID propertyID = cssPropertyID(propertyName); | 186 CSSPropertyID propertyID = cssPropertyID(propertyName); |
| 187 if (!propertyID) | 187 if (!propertyID) |
| 188 return String(); | 188 return String(); |
| 189 return propertySet()->propertyIsImportant(propertyID) ? "important" : ""; | 189 return propertySet().propertyIsImportant(propertyID) ? "important" : ""; |
| 190 } | 190 } |
| 191 | 191 |
| 192 String AbstractPropertySetCSSStyleDeclaration::getPropertyShorthand(const String
& propertyName) | 192 String AbstractPropertySetCSSStyleDeclaration::getPropertyShorthand(const String
& propertyName) |
| 193 { | 193 { |
| 194 CSSPropertyID propertyID = cssPropertyID(propertyName); | 194 CSSPropertyID propertyID = cssPropertyID(propertyName); |
| 195 if (!propertyID) | 195 if (!propertyID) |
| 196 return String(); | 196 return String(); |
| 197 CSSPropertyID shorthandID = propertySet()->getPropertyShorthand(propertyID); | 197 CSSPropertyID shorthandID = propertySet().getPropertyShorthand(propertyID); |
| 198 if (!shorthandID) | 198 if (!shorthandID) |
| 199 return String(); | 199 return String(); |
| 200 return getPropertyNameString(shorthandID); | 200 return getPropertyNameString(shorthandID); |
| 201 } | 201 } |
| 202 | 202 |
| 203 bool AbstractPropertySetCSSStyleDeclaration::isPropertyImplicit(const String& pr
opertyName) | 203 bool AbstractPropertySetCSSStyleDeclaration::isPropertyImplicit(const String& pr
opertyName) |
| 204 { | 204 { |
| 205 CSSPropertyID propertyID = cssPropertyID(propertyName); | 205 CSSPropertyID propertyID = cssPropertyID(propertyName); |
| 206 if (!propertyID) | 206 if (!propertyID) |
| 207 return false; | 207 return false; |
| 208 return propertySet()->isPropertyImplicit(propertyID); | 208 return propertySet().isPropertyImplicit(propertyID); |
| 209 } | 209 } |
| 210 | 210 |
| 211 void AbstractPropertySetCSSStyleDeclaration::setProperty(const String& propertyN
ame, const String& value, const String& priority, ExceptionState& exceptionState
) | 211 void AbstractPropertySetCSSStyleDeclaration::setProperty(const String& propertyN
ame, const String& value, const String& priority, ExceptionState& exceptionState
) |
| 212 { | 212 { |
| 213 StyleAttributeMutationScope mutationScope(this); | 213 StyleAttributeMutationScope mutationScope(this); |
| 214 CSSPropertyID propertyID = cssPropertyID(propertyName); | 214 CSSPropertyID propertyID = cssPropertyID(propertyName); |
| 215 if (!propertyID) | 215 if (!propertyID) |
| 216 return; | 216 return; |
| 217 | 217 |
| 218 bool important = equalIgnoringCase(priority, "important"); | 218 bool important = equalIgnoringCase(priority, "important"); |
| 219 if (!important && !priority.isEmpty()) | 219 if (!important && !priority.isEmpty()) |
| 220 return; | 220 return; |
| 221 | 221 |
| 222 willMutate(); | 222 willMutate(); |
| 223 | 223 |
| 224 bool changed = propertySet()->setProperty(propertyID, value, important, cont
extStyleSheet()); | 224 bool changed = propertySet().setProperty(propertyID, value, important, conte
xtStyleSheet()); |
| 225 | 225 |
| 226 didMutate(changed ? PropertyChanged : NoChanges); | 226 didMutate(changed ? PropertyChanged : NoChanges); |
| 227 | 227 |
| 228 if (changed) { | 228 if (changed) { |
| 229 // CSS DOM requires raising SyntaxError of parsing failed, but this is t
oo dangerous for compatibility, | 229 // CSS DOM requires raising SyntaxError of parsing failed, but this is t
oo dangerous for compatibility, |
| 230 // see <http://bugs.webkit.org/show_bug.cgi?id=7296>. | 230 // see <http://bugs.webkit.org/show_bug.cgi?id=7296>. |
| 231 mutationScope.enqueueMutationRecord(); | 231 mutationScope.enqueueMutationRecord(); |
| 232 } | 232 } |
| 233 } | 233 } |
| 234 | 234 |
| 235 String AbstractPropertySetCSSStyleDeclaration::removeProperty(const String& prop
ertyName, ExceptionState& exceptionState) | 235 String AbstractPropertySetCSSStyleDeclaration::removeProperty(const String& prop
ertyName, ExceptionState& exceptionState) |
| 236 { | 236 { |
| 237 StyleAttributeMutationScope mutationScope(this); | 237 StyleAttributeMutationScope mutationScope(this); |
| 238 CSSPropertyID propertyID = cssPropertyID(propertyName); | 238 CSSPropertyID propertyID = cssPropertyID(propertyName); |
| 239 if (!propertyID) | 239 if (!propertyID) |
| 240 return String(); | 240 return String(); |
| 241 | 241 |
| 242 willMutate(); | 242 willMutate(); |
| 243 | 243 |
| 244 String result; | 244 String result; |
| 245 bool changed = propertySet()->removeProperty(propertyID, &result); | 245 bool changed = propertySet().removeProperty(propertyID, &result); |
| 246 | 246 |
| 247 didMutate(changed ? PropertyChanged : NoChanges); | 247 didMutate(changed ? PropertyChanged : NoChanges); |
| 248 | 248 |
| 249 if (changed) | 249 if (changed) |
| 250 mutationScope.enqueueMutationRecord(); | 250 mutationScope.enqueueMutationRecord(); |
| 251 return result; | 251 return result; |
| 252 } | 252 } |
| 253 | 253 |
| 254 PassRefPtrWillBeRawPtr<CSSValue> AbstractPropertySetCSSStyleDeclaration::getProp
ertyCSSValueInternal(CSSPropertyID propertyID) | 254 PassRefPtrWillBeRawPtr<CSSValue> AbstractPropertySetCSSStyleDeclaration::getProp
ertyCSSValueInternal(CSSPropertyID propertyID) |
| 255 { | 255 { |
| 256 return propertySet()->getPropertyCSSValue(propertyID); | 256 return propertySet().getPropertyCSSValue(propertyID); |
| 257 } | 257 } |
| 258 | 258 |
| 259 String AbstractPropertySetCSSStyleDeclaration::getPropertyValueInternal(CSSPrope
rtyID propertyID) | 259 String AbstractPropertySetCSSStyleDeclaration::getPropertyValueInternal(CSSPrope
rtyID propertyID) |
| 260 { | 260 { |
| 261 return propertySet()->getPropertyValue(propertyID); | 261 return propertySet().getPropertyValue(propertyID); |
| 262 } | 262 } |
| 263 | 263 |
| 264 void AbstractPropertySetCSSStyleDeclaration::setPropertyInternal(CSSPropertyID p
ropertyID, const String& value, bool important, ExceptionState&) | 264 void AbstractPropertySetCSSStyleDeclaration::setPropertyInternal(CSSPropertyID p
ropertyID, const String& value, bool important, ExceptionState&) |
| 265 { | 265 { |
| 266 StyleAttributeMutationScope mutationScope(this); | 266 StyleAttributeMutationScope mutationScope(this); |
| 267 willMutate(); | 267 willMutate(); |
| 268 | 268 |
| 269 bool changed = propertySet()->setProperty(propertyID, value, important, cont
extStyleSheet()); | 269 bool changed = propertySet().setProperty(propertyID, value, important, conte
xtStyleSheet()); |
| 270 | 270 |
| 271 didMutate(changed ? PropertyChanged : NoChanges); | 271 didMutate(changed ? PropertyChanged : NoChanges); |
| 272 | 272 |
| 273 if (changed) | 273 if (changed) |
| 274 mutationScope.enqueueMutationRecord(); | 274 mutationScope.enqueueMutationRecord(); |
| 275 } | 275 } |
| 276 | 276 |
| 277 CSSValue* AbstractPropertySetCSSStyleDeclaration::cloneAndCacheForCSSOM(CSSValue
* internalValue) | 277 CSSValue* AbstractPropertySetCSSStyleDeclaration::cloneAndCacheForCSSOM(CSSValue
* internalValue) |
| 278 { | 278 { |
| 279 if (!internalValue) | 279 if (!internalValue) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 291 } | 291 } |
| 292 | 292 |
| 293 StyleSheetContents* AbstractPropertySetCSSStyleDeclaration::contextStyleSheet()
const | 293 StyleSheetContents* AbstractPropertySetCSSStyleDeclaration::contextStyleSheet()
const |
| 294 { | 294 { |
| 295 CSSStyleSheet* cssStyleSheet = parentStyleSheet(); | 295 CSSStyleSheet* cssStyleSheet = parentStyleSheet(); |
| 296 return cssStyleSheet ? cssStyleSheet->contents() : 0; | 296 return cssStyleSheet ? cssStyleSheet->contents() : 0; |
| 297 } | 297 } |
| 298 | 298 |
| 299 PassRefPtr<MutableStylePropertySet> AbstractPropertySetCSSStyleDeclaration::copy
Properties() const | 299 PassRefPtr<MutableStylePropertySet> AbstractPropertySetCSSStyleDeclaration::copy
Properties() const |
| 300 { | 300 { |
| 301 return propertySet()->mutableCopy(); | 301 return propertySet().mutableCopy(); |
| 302 } | 302 } |
| 303 | 303 |
| 304 bool AbstractPropertySetCSSStyleDeclaration::cssPropertyMatches(CSSPropertyID pr
opertyID, const CSSValue* propertyValue) const | 304 bool AbstractPropertySetCSSStyleDeclaration::cssPropertyMatches(CSSPropertyID pr
opertyID, const CSSValue* propertyValue) const |
| 305 { | 305 { |
| 306 return propertySet()->propertyMatches(propertyID, propertyValue); | 306 return propertySet().propertyMatches(propertyID, propertyValue); |
| 307 } | 307 } |
| 308 | 308 |
| 309 StyleRuleCSSStyleDeclaration::StyleRuleCSSStyleDeclaration(MutableStylePropertyS
et* propertySetArg, CSSRule* parentRule) | 309 StyleRuleCSSStyleDeclaration::StyleRuleCSSStyleDeclaration(MutableStylePropertyS
et& propertySetArg, CSSRule* parentRule) |
| 310 : PropertySetCSSStyleDeclaration(propertySetArg) | 310 : PropertySetCSSStyleDeclaration(propertySetArg) |
| 311 , m_refCount(1) | 311 , m_refCount(1) |
| 312 , m_parentRule(parentRule) | 312 , m_parentRule(parentRule) |
| 313 { | 313 { |
| 314 m_propertySet->ref(); | 314 m_propertySet->ref(); |
| 315 } | 315 } |
| 316 | 316 |
| 317 StyleRuleCSSStyleDeclaration::~StyleRuleCSSStyleDeclaration() | 317 StyleRuleCSSStyleDeclaration::~StyleRuleCSSStyleDeclaration() |
| 318 { | 318 { |
| 319 m_propertySet->deref(); | 319 m_propertySet->deref(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 345 // Style sheet mutation needs to be signaled even if the change failed. will
MutateRules/didMutateRules must pair. | 345 // Style sheet mutation needs to be signaled even if the change failed. will
MutateRules/didMutateRules must pair. |
| 346 if (m_parentRule && m_parentRule->parentStyleSheet()) | 346 if (m_parentRule && m_parentRule->parentStyleSheet()) |
| 347 m_parentRule->parentStyleSheet()->didMutateRules(); | 347 m_parentRule->parentStyleSheet()->didMutateRules(); |
| 348 } | 348 } |
| 349 | 349 |
| 350 CSSStyleSheet* StyleRuleCSSStyleDeclaration::parentStyleSheet() const | 350 CSSStyleSheet* StyleRuleCSSStyleDeclaration::parentStyleSheet() const |
| 351 { | 351 { |
| 352 return m_parentRule ? m_parentRule->parentStyleSheet() : 0; | 352 return m_parentRule ? m_parentRule->parentStyleSheet() : 0; |
| 353 } | 353 } |
| 354 | 354 |
| 355 void StyleRuleCSSStyleDeclaration::reattach(MutableStylePropertySet* propertySet
) | 355 void StyleRuleCSSStyleDeclaration::reattach(MutableStylePropertySet& propertySet
) |
| 356 { | 356 { |
| 357 ASSERT(propertySet); | |
| 358 m_propertySet->deref(); | 357 m_propertySet->deref(); |
| 359 m_propertySet = propertySet; | 358 m_propertySet = &propertySet; |
| 360 m_propertySet->ref(); | 359 m_propertySet->ref(); |
| 361 } | 360 } |
| 362 | 361 |
| 363 MutableStylePropertySet* InlineCSSStyleDeclaration::propertySet() const | 362 MutableStylePropertySet& InlineCSSStyleDeclaration::propertySet() const |
| 364 { | 363 { |
| 365 return m_parentElement->ensureMutableInlineStyle(); | 364 return m_parentElement->ensureMutableInlineStyle(); |
| 366 } | 365 } |
| 367 | 366 |
| 368 void InlineCSSStyleDeclaration::didMutate(MutationType type) | 367 void InlineCSSStyleDeclaration::didMutate(MutationType type) |
| 369 { | 368 { |
| 370 if (type == NoChanges) | 369 if (type == NoChanges) |
| 371 return; | 370 return; |
| 372 | 371 |
| 373 m_cssomCSSValueClones.clear(); | 372 m_cssomCSSValueClones.clear(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 390 { | 389 { |
| 391 m_parentElement->ref(); | 390 m_parentElement->ref(); |
| 392 } | 391 } |
| 393 | 392 |
| 394 void InlineCSSStyleDeclaration::deref() | 393 void InlineCSSStyleDeclaration::deref() |
| 395 { | 394 { |
| 396 m_parentElement->deref(); | 395 m_parentElement->deref(); |
| 397 } | 396 } |
| 398 | 397 |
| 399 } // namespace WebCore | 398 } // namespace WebCore |
| OLD | NEW |