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, 2013 Apple Inc.
All rights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
All rights reserved. |
4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. | 4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. |
5 * Copyright (C) 2013 Intel Corporation. All rights reserved. | 5 * Copyright (C) 2013 Intel Corporation. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 } | 87 } |
88 } | 88 } |
89 | 89 |
90 ImmutableStylePropertySet::~ImmutableStylePropertySet() | 90 ImmutableStylePropertySet::~ImmutableStylePropertySet() |
91 { | 91 { |
92 CSSValue** valueArray = const_cast<CSSValue**>(this->valueArray()); | 92 CSSValue** valueArray = const_cast<CSSValue**>(this->valueArray()); |
93 for (unsigned i = 0; i < m_arraySize; ++i) | 93 for (unsigned i = 0; i < m_arraySize; ++i) |
94 valueArray[i]->deref(); | 94 valueArray[i]->deref(); |
95 } | 95 } |
96 | 96 |
| 97 int ImmutableStylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const |
| 98 { |
| 99 // Convert here propertyID into an uint16_t to compare it with the metadata'
s m_propertyID to avoid |
| 100 // the compiler converting it to an int multiple times in the loop. |
| 101 uint16_t id = static_cast<uint16_t>(propertyID); |
| 102 for (int n = m_arraySize - 1 ; n >= 0; --n) { |
| 103 if (metadataArray()[n].m_propertyID == id) { |
| 104 // Only enabled or internal properties should be part of the style. |
| 105 ASSERT(RuntimeCSSEnabled::isCSSPropertyEnabled(propertyID) || isInte
rnalProperty(propertyID)); |
| 106 return n; |
| 107 } |
| 108 } |
| 109 |
| 110 return -1; |
| 111 } |
| 112 |
97 MutableStylePropertySet::MutableStylePropertySet(const StylePropertySet& other) | 113 MutableStylePropertySet::MutableStylePropertySet(const StylePropertySet& other) |
98 : StylePropertySet(other.cssParserMode()) | 114 : StylePropertySet(other.cssParserMode()) |
99 { | 115 { |
100 if (other.isMutable()) { | 116 if (other.isMutable()) { |
101 m_propertyVector = toMutableStylePropertySet(other).m_propertyVector; | 117 m_propertyVector = toMutableStylePropertySet(other).m_propertyVector; |
102 } else { | 118 } else { |
103 m_propertyVector.reserveInitialCapacity(other.propertyCount()); | 119 m_propertyVector.reserveInitialCapacity(other.propertyCount()); |
104 for (unsigned i = 0; i < other.propertyCount(); ++i) | 120 for (unsigned i = 0; i < other.propertyCount(); ++i) |
105 m_propertyVector.uncheckedAppend(other.propertyAt(i).toCSSProperty()
); | 121 m_propertyVector.uncheckedAppend(other.propertyAt(i).toCSSProperty()
); |
106 } | 122 } |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 continue; | 431 continue; |
416 } | 432 } |
417 newProperties.append(property); | 433 newProperties.append(property); |
418 } | 434 } |
419 | 435 |
420 bool changed = newProperties.size() != m_propertyVector.size(); | 436 bool changed = newProperties.size() != m_propertyVector.size(); |
421 m_propertyVector = newProperties; | 437 m_propertyVector = newProperties; |
422 return changed; | 438 return changed; |
423 } | 439 } |
424 | 440 |
425 int StylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const | |
426 { | |
427 // Convert here propertyID into an uint16_t to compare it with the metadata'
s m_propertyID to avoid | |
428 // the compiler converting it to an int multiple times in the loop. | |
429 uint16_t id = static_cast<uint16_t>(propertyID); | |
430 for (int n = propertyCount() - 1 ; n >= 0; --n) { | |
431 if (id == propertyAt(n).propertyMetadata().m_propertyID) { | |
432 // Only enabled or internal properties should be part of the style. | |
433 ASSERT(RuntimeCSSEnabled::isCSSPropertyEnabled(propertyID) || isInte
rnalProperty(propertyID)); | |
434 return n; | |
435 } | |
436 } | |
437 return -1; | |
438 } | |
439 | |
440 CSSProperty* MutableStylePropertySet::findCSSPropertyWithID(CSSPropertyID proper
tyID) | 441 CSSProperty* MutableStylePropertySet::findCSSPropertyWithID(CSSPropertyID proper
tyID) |
441 { | 442 { |
442 int foundPropertyIndex = findPropertyIndex(propertyID); | 443 int foundPropertyIndex = findPropertyIndex(propertyID); |
443 if (foundPropertyIndex == -1) | 444 if (foundPropertyIndex == -1) |
444 return 0; | 445 return 0; |
445 return &m_propertyVector.at(foundPropertyIndex); | 446 return &m_propertyVector.at(foundPropertyIndex); |
446 } | 447 } |
447 | 448 |
448 bool StylePropertySet::propertyMatches(CSSPropertyID propertyID, const CSSValue*
propertyValue) const | 449 bool StylePropertySet::propertyMatches(CSSPropertyID propertyID, const CSSValue*
propertyValue) const |
449 { | 450 { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 // style property set. | 505 // style property set. |
505 if (m_cssomWrapper) { | 506 if (m_cssomWrapper) { |
506 ASSERT(!static_cast<CSSStyleDeclaration*>(m_cssomWrapper.get())->parentR
ule()); | 507 ASSERT(!static_cast<CSSStyleDeclaration*>(m_cssomWrapper.get())->parentR
ule()); |
507 ASSERT(!m_cssomWrapper->parentElement()); | 508 ASSERT(!m_cssomWrapper->parentElement()); |
508 return m_cssomWrapper.get(); | 509 return m_cssomWrapper.get(); |
509 } | 510 } |
510 m_cssomWrapper = adoptPtr(new PropertySetCSSStyleDeclaration(this)); | 511 m_cssomWrapper = adoptPtr(new PropertySetCSSStyleDeclaration(this)); |
511 return m_cssomWrapper.get(); | 512 return m_cssomWrapper.get(); |
512 } | 513 } |
513 | 514 |
| 515 int MutableStylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const |
| 516 { |
| 517 // Convert here propertyID into an uint16_t to compare it with the metadata'
s m_propertyID to avoid |
| 518 // the compiler converting it to an int multiple times in the loop. |
| 519 uint16_t id = static_cast<uint16_t>(propertyID); |
| 520 for (int n = m_propertyVector.size() - 1 ; n >= 0; --n) { |
| 521 if (m_propertyVector.at(n).metadata().m_propertyID == id) { |
| 522 // Only enabled or internal properties should be part of the style. |
| 523 ASSERT(RuntimeCSSEnabled::isCSSPropertyEnabled(propertyID) || isInte
rnalProperty(propertyID)); |
| 524 return n; |
| 525 } |
| 526 } |
| 527 |
| 528 return -1; |
| 529 } |
| 530 |
514 unsigned StylePropertySet::averageSizeInBytes() | 531 unsigned StylePropertySet::averageSizeInBytes() |
515 { | 532 { |
516 // Please update this if the storage scheme changes so that this longer refl
ects the actual size. | 533 // Please update this if the storage scheme changes so that this longer refl
ects the actual size. |
517 return sizeForImmutableStylePropertySetWithPropertyCount(4); | 534 return sizeForImmutableStylePropertySetWithPropertyCount(4); |
518 } | 535 } |
519 | 536 |
520 // See the function above if you need to update this. | 537 // See the function above if you need to update this. |
521 struct SameSizeAsStylePropertySet : public RefCounted<SameSizeAsStylePropertySet
> { | 538 struct SameSizeAsStylePropertySet : public RefCounted<SameSizeAsStylePropertySet
> { |
522 unsigned bitfield; | 539 unsigned bitfield; |
523 }; | 540 }; |
(...skipping 28 matching lines...) Expand all Loading... |
552 result.appendLiteral(": "); | 569 result.appendLiteral(": "); |
553 result.append(propertyValue()->cssText()); | 570 result.append(propertyValue()->cssText()); |
554 if (isImportant()) | 571 if (isImportant()) |
555 result.appendLiteral(" !important"); | 572 result.appendLiteral(" !important"); |
556 result.append(';'); | 573 result.append(';'); |
557 return result.toString(); | 574 return result.toString(); |
558 } | 575 } |
559 | 576 |
560 | 577 |
561 } // namespace WebCore | 578 } // namespace WebCore |
OLD | NEW |