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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 RefPtr<MutationRecord> m_mutation; | 118 RefPtr<MutationRecord> m_mutation; |
119 }; | 119 }; |
120 | 120 |
121 unsigned StyleAttributeMutationScope::s_scopeCount = 0; | 121 unsigned StyleAttributeMutationScope::s_scopeCount = 0; |
122 AbstractPropertySetCSSStyleDeclaration* StyleAttributeMutationScope::s_currentDe
cl = 0; | 122 AbstractPropertySetCSSStyleDeclaration* StyleAttributeMutationScope::s_currentDe
cl = 0; |
123 bool StyleAttributeMutationScope::s_shouldNotifyInspector = false; | 123 bool StyleAttributeMutationScope::s_shouldNotifyInspector = false; |
124 bool StyleAttributeMutationScope::s_shouldDeliver = false; | 124 bool StyleAttributeMutationScope::s_shouldDeliver = false; |
125 | 125 |
126 } // namespace | 126 } // namespace |
127 | 127 |
128 #if !ENABLE(OILPAN) | |
129 void PropertySetCSSStyleDeclaration::ref() | 128 void PropertySetCSSStyleDeclaration::ref() |
130 { | 129 { |
131 m_propertySet->ref(); | 130 m_propertySet->ref(); |
132 } | 131 } |
133 | 132 |
134 void PropertySetCSSStyleDeclaration::deref() | 133 void PropertySetCSSStyleDeclaration::deref() |
135 { | 134 { |
136 m_propertySet->deref(); | 135 m_propertySet->deref(); |
137 } | 136 } |
138 #endif | |
139 | |
140 void PropertySetCSSStyleDeclaration::trace(Visitor* visitor) | |
141 { | |
142 visitor->trace(m_propertySet); | |
143 AbstractPropertySetCSSStyleDeclaration::trace(visitor); | |
144 } | |
145 | 137 |
146 unsigned AbstractPropertySetCSSStyleDeclaration::length() const | 138 unsigned AbstractPropertySetCSSStyleDeclaration::length() const |
147 { | 139 { |
148 return propertySet().propertyCount(); | 140 return propertySet().propertyCount(); |
149 } | 141 } |
150 | 142 |
151 String AbstractPropertySetCSSStyleDeclaration::item(unsigned i) const | 143 String AbstractPropertySetCSSStyleDeclaration::item(unsigned i) const |
152 { | 144 { |
153 if (i >= propertySet().propertyCount()) | 145 if (i >= propertySet().propertyCount()) |
154 return ""; | 146 return ""; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 } | 275 } |
284 | 276 |
285 CSSValue* AbstractPropertySetCSSStyleDeclaration::cloneAndCacheForCSSOM(CSSValue
* internalValue) | 277 CSSValue* AbstractPropertySetCSSStyleDeclaration::cloneAndCacheForCSSOM(CSSValue
* internalValue) |
286 { | 278 { |
287 if (!internalValue) | 279 if (!internalValue) |
288 return 0; | 280 return 0; |
289 | 281 |
290 // The map is here to maintain the object identity of the CSSValues over mul
tiple invocations. | 282 // The map is here to maintain the object identity of the CSSValues over mul
tiple invocations. |
291 // FIXME: It is likely that the identity is not important for web compatibil
ity and this code should be removed. | 283 // FIXME: It is likely that the identity is not important for web compatibil
ity and this code should be removed. |
292 if (!m_cssomCSSValueClones) | 284 if (!m_cssomCSSValueClones) |
293 m_cssomCSSValueClones = adoptPtrWillBeNoop(new WillBeHeapHashMap<RawPtrW
illBeMember<CSSValue>, RefPtrWillBeMember<CSSValue> >); | 285 m_cssomCSSValueClones = adoptPtrWillBeNoop(new WillBeHeapHashMap<CSSValu
e*, RefPtrWillBeMember<CSSValue> >); |
294 | 286 |
295 RefPtrWillBeMember<CSSValue>& clonedValue = m_cssomCSSValueClones->add(inter
nalValue, RefPtrWillBeMember<CSSValue>()).storedValue->value; | 287 RefPtrWillBeMember<CSSValue>& clonedValue = m_cssomCSSValueClones->add(inter
nalValue, RefPtrWillBeMember<CSSValue>()).storedValue->value; |
296 if (!clonedValue) | 288 if (!clonedValue) |
297 clonedValue = internalValue->cloneForCSSOM(); | 289 clonedValue = internalValue->cloneForCSSOM(); |
298 return clonedValue.get(); | 290 return clonedValue.get(); |
299 } | 291 } |
300 | 292 |
301 StyleSheetContents* AbstractPropertySetCSSStyleDeclaration::contextStyleSheet()
const | 293 StyleSheetContents* AbstractPropertySetCSSStyleDeclaration::contextStyleSheet()
const |
302 { | 294 { |
303 CSSStyleSheet* cssStyleSheet = parentStyleSheet(); | 295 CSSStyleSheet* cssStyleSheet = parentStyleSheet(); |
304 return cssStyleSheet ? cssStyleSheet->contents() : 0; | 296 return cssStyleSheet ? cssStyleSheet->contents() : 0; |
305 } | 297 } |
306 | 298 |
307 PassRefPtrWillBeRawPtr<MutableStylePropertySet> AbstractPropertySetCSSStyleDecla
ration::copyProperties() const | 299 PassRefPtrWillBeRawPtr<MutableStylePropertySet> AbstractPropertySetCSSStyleDecla
ration::copyProperties() const |
308 { | 300 { |
309 return propertySet().mutableCopy(); | 301 return propertySet().mutableCopy(); |
310 } | 302 } |
311 | 303 |
312 bool AbstractPropertySetCSSStyleDeclaration::cssPropertyMatches(CSSPropertyID pr
opertyID, const CSSValue* propertyValue) const | 304 bool AbstractPropertySetCSSStyleDeclaration::cssPropertyMatches(CSSPropertyID pr
opertyID, const CSSValue* propertyValue) const |
313 { | 305 { |
314 return propertySet().propertyMatches(propertyID, propertyValue); | 306 return propertySet().propertyMatches(propertyID, propertyValue); |
315 } | 307 } |
316 | 308 |
317 void AbstractPropertySetCSSStyleDeclaration::trace(Visitor* visitor) | |
318 { | |
319 #if ENABLE(OILPAN) | |
320 visitor->trace(m_cssomCSSValueClones); | |
321 #endif | |
322 } | |
323 | |
324 StyleRuleCSSStyleDeclaration::StyleRuleCSSStyleDeclaration(MutableStylePropertyS
et& propertySetArg, CSSRule* parentRule) | 309 StyleRuleCSSStyleDeclaration::StyleRuleCSSStyleDeclaration(MutableStylePropertyS
et& propertySetArg, CSSRule* parentRule) |
325 : PropertySetCSSStyleDeclaration(propertySetArg) | 310 : PropertySetCSSStyleDeclaration(propertySetArg) |
326 #if !ENABLE(OILPAN) | |
327 , m_refCount(1) | 311 , m_refCount(1) |
328 #endif | |
329 , m_parentRule(parentRule) | 312 , m_parentRule(parentRule) |
330 { | 313 { |
331 #if !ENABLE(OILPAN) | |
332 m_propertySet->ref(); | 314 m_propertySet->ref(); |
333 #endif | |
334 } | 315 } |
335 | 316 |
336 StyleRuleCSSStyleDeclaration::~StyleRuleCSSStyleDeclaration() | 317 StyleRuleCSSStyleDeclaration::~StyleRuleCSSStyleDeclaration() |
337 { | 318 { |
338 #if !ENABLE(OILPAN) | |
339 m_propertySet->deref(); | 319 m_propertySet->deref(); |
340 #endif | |
341 } | 320 } |
342 | 321 |
343 #if !ENABLE(OILPAN) | |
344 void StyleRuleCSSStyleDeclaration::ref() | 322 void StyleRuleCSSStyleDeclaration::ref() |
345 { | 323 { |
346 ++m_refCount; | 324 ++m_refCount; |
347 } | 325 } |
348 | 326 |
349 void StyleRuleCSSStyleDeclaration::deref() | 327 void StyleRuleCSSStyleDeclaration::deref() |
350 { | 328 { |
351 ASSERT(m_refCount); | 329 ASSERT(m_refCount); |
352 if (!--m_refCount) | 330 if (!--m_refCount) |
353 delete this; | 331 delete this; |
354 } | 332 } |
355 #endif | |
356 | 333 |
357 void StyleRuleCSSStyleDeclaration::willMutate() | 334 void StyleRuleCSSStyleDeclaration::willMutate() |
358 { | 335 { |
359 if (m_parentRule && m_parentRule->parentStyleSheet()) | 336 if (m_parentRule && m_parentRule->parentStyleSheet()) |
360 m_parentRule->parentStyleSheet()->willMutateRules(); | 337 m_parentRule->parentStyleSheet()->willMutateRules(); |
361 } | 338 } |
362 | 339 |
363 void StyleRuleCSSStyleDeclaration::didMutate(MutationType type) | 340 void StyleRuleCSSStyleDeclaration::didMutate(MutationType type) |
364 { | 341 { |
365 if (type == PropertyChanged) | 342 if (type == PropertyChanged) |
366 m_cssomCSSValueClones.clear(); | 343 m_cssomCSSValueClones.clear(); |
367 | 344 |
368 // 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. |
369 if (m_parentRule && m_parentRule->parentStyleSheet()) | 346 if (m_parentRule && m_parentRule->parentStyleSheet()) |
370 m_parentRule->parentStyleSheet()->didMutateRules(); | 347 m_parentRule->parentStyleSheet()->didMutateRules(); |
371 } | 348 } |
372 | 349 |
373 CSSStyleSheet* StyleRuleCSSStyleDeclaration::parentStyleSheet() const | 350 CSSStyleSheet* StyleRuleCSSStyleDeclaration::parentStyleSheet() const |
374 { | 351 { |
375 return m_parentRule ? m_parentRule->parentStyleSheet() : 0; | 352 return m_parentRule ? m_parentRule->parentStyleSheet() : 0; |
376 } | 353 } |
377 | 354 |
378 void StyleRuleCSSStyleDeclaration::reattach(MutableStylePropertySet& propertySet
) | 355 void StyleRuleCSSStyleDeclaration::reattach(MutableStylePropertySet& propertySet
) |
379 { | 356 { |
380 #if !ENABLE(OILPAN) | |
381 m_propertySet->deref(); | 357 m_propertySet->deref(); |
382 #endif | |
383 m_propertySet = &propertySet; | 358 m_propertySet = &propertySet; |
384 #if !ENABLE(OILPAN) | |
385 m_propertySet->ref(); | 359 m_propertySet->ref(); |
386 #endif | |
387 } | |
388 | |
389 void StyleRuleCSSStyleDeclaration::trace(Visitor* visitor) | |
390 { | |
391 visitor->trace(m_parentRule); | |
392 PropertySetCSSStyleDeclaration::trace(visitor); | |
393 } | 360 } |
394 | 361 |
395 MutableStylePropertySet& InlineCSSStyleDeclaration::propertySet() const | 362 MutableStylePropertySet& InlineCSSStyleDeclaration::propertySet() const |
396 { | 363 { |
397 return m_parentElement->ensureMutableInlineStyle(); | 364 return m_parentElement->ensureMutableInlineStyle(); |
398 } | 365 } |
399 | 366 |
400 void InlineCSSStyleDeclaration::didMutate(MutationType type) | 367 void InlineCSSStyleDeclaration::didMutate(MutationType type) |
401 { | 368 { |
402 if (type == NoChanges) | 369 if (type == NoChanges) |
403 return; | 370 return; |
404 | 371 |
405 m_cssomCSSValueClones.clear(); | 372 m_cssomCSSValueClones.clear(); |
406 | 373 |
407 if (!m_parentElement) | 374 if (!m_parentElement) |
408 return; | 375 return; |
409 | 376 |
410 m_parentElement->clearMutableInlineStyleIfEmpty(); | 377 m_parentElement->clearMutableInlineStyleIfEmpty(); |
411 m_parentElement->setNeedsStyleRecalc(LocalStyleChange); | 378 m_parentElement->setNeedsStyleRecalc(LocalStyleChange); |
412 m_parentElement->invalidateStyleAttribute(); | 379 m_parentElement->invalidateStyleAttribute(); |
413 StyleAttributeMutationScope(this).didInvalidateStyleAttr(); | 380 StyleAttributeMutationScope(this).didInvalidateStyleAttr(); |
414 } | 381 } |
415 | 382 |
416 CSSStyleSheet* InlineCSSStyleDeclaration::parentStyleSheet() const | 383 CSSStyleSheet* InlineCSSStyleDeclaration::parentStyleSheet() const |
417 { | 384 { |
418 return m_parentElement ? &m_parentElement->document().elementSheet() : 0; | 385 return m_parentElement ? &m_parentElement->document().elementSheet() : 0; |
419 } | 386 } |
420 | 387 |
421 #if !ENABLE(OILPAN) | |
422 void InlineCSSStyleDeclaration::ref() | 388 void InlineCSSStyleDeclaration::ref() |
423 { | 389 { |
424 m_parentElement->ref(); | 390 m_parentElement->ref(); |
425 } | 391 } |
426 | 392 |
427 void InlineCSSStyleDeclaration::deref() | 393 void InlineCSSStyleDeclaration::deref() |
428 { | 394 { |
429 m_parentElement->deref(); | 395 m_parentElement->deref(); |
430 } | 396 } |
431 #endif | |
432 | |
433 void InlineCSSStyleDeclaration::trace(Visitor* visitor) | |
434 { | |
435 AbstractPropertySetCSSStyleDeclaration::trace(visitor); | |
436 } | |
437 | 397 |
438 } // namespace WebCore | 398 } // namespace WebCore |
OLD | NEW |