| 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 27 matching lines...) Expand all Loading... |
| 38 #include <stdio.h> | 38 #include <stdio.h> |
| 39 #endif | 39 #endif |
| 40 | 40 |
| 41 namespace WebCore { | 41 namespace WebCore { |
| 42 | 42 |
| 43 static size_t sizeForImmutableStylePropertySetWithPropertyCount(unsigned count) | 43 static size_t sizeForImmutableStylePropertySetWithPropertyCount(unsigned count) |
| 44 { | 44 { |
| 45 return sizeof(ImmutableStylePropertySet) - sizeof(void*) + sizeof(CSSValue*)
* count + sizeof(StylePropertyMetadata) * count; | 45 return sizeof(ImmutableStylePropertySet) - sizeof(void*) + sizeof(CSSValue*)
* count + sizeof(StylePropertyMetadata) * count; |
| 46 } | 46 } |
| 47 | 47 |
| 48 PassRefPtr<ImmutableStylePropertySet> ImmutableStylePropertySet::create(const CS
SProperty* properties, unsigned count, CSSParserMode cssParserMode) | 48 PassRefPtrWillBeRawPtr<ImmutableStylePropertySet> ImmutableStylePropertySet::cre
ate(const CSSProperty* properties, unsigned count, CSSParserMode cssParserMode) |
| 49 { | 49 { |
| 50 ASSERT(count <= MaxArraySize); | 50 ASSERT(count <= MaxArraySize); |
| 51 #if ENABLE(OILPAN) | 51 #if ENABLE(OILPAN) |
| 52 void* slot = Heap::allocate<StylePropertySet>(sizeForImmutableStylePropertyS
etWithPropertyCount(count)); | 52 void* slot = Heap::allocate<StylePropertySet>(sizeForImmutableStylePropertyS
etWithPropertyCount(count)); |
| 53 #else | 53 #else |
| 54 void* slot = WTF::fastMalloc(sizeForImmutableStylePropertySetWithPropertyCou
nt(count)); | 54 void* slot = WTF::fastMalloc(sizeForImmutableStylePropertySetWithPropertyCou
nt(count)); |
| 55 #endif // ENABLE(OILPAN) | 55 #endif // ENABLE(OILPAN) |
| 56 return adoptRefWillBeRefCountedGarbageCollected(new (slot) ImmutableStylePro
pertySet(properties, count, cssParserMode)); | 56 return adoptRefWillBeNoop(new (slot) ImmutableStylePropertySet(properties, c
ount, cssParserMode)); |
| 57 } | 57 } |
| 58 | 58 |
| 59 PassRefPtr<ImmutableStylePropertySet> StylePropertySet::immutableCopyIfNeeded()
const | 59 PassRefPtrWillBeRawPtr<ImmutableStylePropertySet> StylePropertySet::immutableCop
yIfNeeded() const |
| 60 { | 60 { |
| 61 if (!isMutable()) | 61 if (!isMutable()) |
| 62 return toImmutableStylePropertySet(const_cast<StylePropertySet*>(this)); | 62 return toImmutableStylePropertySet(const_cast<StylePropertySet*>(this)); |
| 63 const MutableStylePropertySet* mutableThis = toMutableStylePropertySet(this)
; | 63 const MutableStylePropertySet* mutableThis = toMutableStylePropertySet(this)
; |
| 64 return ImmutableStylePropertySet::create(mutableThis->m_propertyVector.data(
), mutableThis->m_propertyVector.size(), cssParserMode()); | 64 return ImmutableStylePropertySet::create(mutableThis->m_propertyVector.data(
), mutableThis->m_propertyVector.size(), cssParserMode()); |
| 65 } | 65 } |
| 66 | 66 |
| 67 MutableStylePropertySet::MutableStylePropertySet(CSSParserMode cssParserMode) | 67 MutableStylePropertySet::MutableStylePropertySet(CSSParserMode cssParserMode) |
| 68 : StylePropertySet(cssParserMode) | 68 : StylePropertySet(cssParserMode) |
| 69 { | 69 { |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 if (style->cssPropertyMatches(property.id(), property.value())) | 511 if (style->cssPropertyMatches(property.id(), property.value())) |
| 512 propertiesToRemove.append(property.id()); | 512 propertiesToRemove.append(property.id()); |
| 513 } | 513 } |
| 514 // FIXME: This should use mass removal. | 514 // FIXME: This should use mass removal. |
| 515 for (unsigned i = 0; i < propertiesToRemove.size(); ++i) | 515 for (unsigned i = 0; i < propertiesToRemove.size(); ++i) |
| 516 removeProperty(propertiesToRemove[i]); | 516 removeProperty(propertiesToRemove[i]); |
| 517 } | 517 } |
| 518 | 518 |
| 519 PassRefPtrWillBeRawPtr<MutableStylePropertySet> StylePropertySet::mutableCopy()
const | 519 PassRefPtrWillBeRawPtr<MutableStylePropertySet> StylePropertySet::mutableCopy()
const |
| 520 { | 520 { |
| 521 return adoptRefWillBeRefCountedGarbageCollected(new MutableStylePropertySet(
*this)); | 521 return adoptRefWillBeNoop(new MutableStylePropertySet(*this)); |
| 522 } | 522 } |
| 523 | 523 |
| 524 PassRefPtrWillBeRawPtr<MutableStylePropertySet> StylePropertySet::copyProperties
InSet(const Vector<CSSPropertyID>& properties) const | 524 PassRefPtrWillBeRawPtr<MutableStylePropertySet> StylePropertySet::copyProperties
InSet(const Vector<CSSPropertyID>& properties) const |
| 525 { | 525 { |
| 526 WillBeHeapVector<CSSProperty, 256> list; | 526 WillBeHeapVector<CSSProperty, 256> list; |
| 527 list.reserveInitialCapacity(properties.size()); | 527 list.reserveInitialCapacity(properties.size()); |
| 528 for (unsigned i = 0; i < properties.size(); ++i) { | 528 for (unsigned i = 0; i < properties.size(); ++i) { |
| 529 RefPtrWillBeRawPtr<CSSValue> value = getPropertyCSSValue(properties[i]); | 529 RefPtrWillBeRawPtr<CSSValue> value = getPropertyCSSValue(properties[i]); |
| 530 if (value) | 530 if (value) |
| 531 list.append(CSSProperty(properties[i], value.release(), false)); | 531 list.append(CSSProperty(properties[i], value.release(), false)); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 StylePropertySet::traceAfterDispatch(visitor); | 570 StylePropertySet::traceAfterDispatch(visitor); |
| 571 } | 571 } |
| 572 | 572 |
| 573 unsigned StylePropertySet::averageSizeInBytes() | 573 unsigned StylePropertySet::averageSizeInBytes() |
| 574 { | 574 { |
| 575 // Please update this if the storage scheme changes so that this longer refl
ects the actual size. | 575 // Please update this if the storage scheme changes so that this longer refl
ects the actual size. |
| 576 return sizeForImmutableStylePropertySetWithPropertyCount(4); | 576 return sizeForImmutableStylePropertySetWithPropertyCount(4); |
| 577 } | 577 } |
| 578 | 578 |
| 579 // See the function above if you need to update this. | 579 // See the function above if you need to update this. |
| 580 struct SameSizeAsStylePropertySet : public RefCountedWillBeRefCountedGarbageColl
ected<SameSizeAsStylePropertySet> { | 580 struct SameSizeAsStylePropertySet : public RefCountedWillBeGarbageCollectedFinal
ized<SameSizeAsStylePropertySet> { |
| 581 unsigned bitfield; | 581 unsigned bitfield; |
| 582 }; | 582 }; |
| 583 COMPILE_ASSERT(sizeof(StylePropertySet) == sizeof(SameSizeAsStylePropertySet), s
tyle_property_set_should_stay_small); | 583 COMPILE_ASSERT(sizeof(StylePropertySet) == sizeof(SameSizeAsStylePropertySet), s
tyle_property_set_should_stay_small); |
| 584 | 584 |
| 585 #ifndef NDEBUG | 585 #ifndef NDEBUG |
| 586 void StylePropertySet::showStyle() | 586 void StylePropertySet::showStyle() |
| 587 { | 587 { |
| 588 fprintf(stderr, "%s\n", asText().ascii().data()); | 588 fprintf(stderr, "%s\n", asText().ascii().data()); |
| 589 } | 589 } |
| 590 #endif | 590 #endif |
| 591 | 591 |
| 592 PassRefPtrWillBeRawPtr<MutableStylePropertySet> MutableStylePropertySet::create(
CSSParserMode cssParserMode) | 592 PassRefPtrWillBeRawPtr<MutableStylePropertySet> MutableStylePropertySet::create(
CSSParserMode cssParserMode) |
| 593 { | 593 { |
| 594 return adoptRefWillBeRefCountedGarbageCollected(new MutableStylePropertySet(
cssParserMode)); | 594 return adoptRefWillBeNoop(new MutableStylePropertySet(cssParserMode)); |
| 595 } | 595 } |
| 596 | 596 |
| 597 PassRefPtrWillBeRawPtr<MutableStylePropertySet> MutableStylePropertySet::create(
const CSSProperty* properties, unsigned count) | 597 PassRefPtrWillBeRawPtr<MutableStylePropertySet> MutableStylePropertySet::create(
const CSSProperty* properties, unsigned count) |
| 598 { | 598 { |
| 599 return adoptRefWillBeRefCountedGarbageCollected(new MutableStylePropertySet(
properties, count)); | 599 return adoptRefWillBeNoop(new MutableStylePropertySet(properties, count)); |
| 600 } | 600 } |
| 601 | 601 |
| 602 String StylePropertySet::PropertyReference::cssName() const | 602 String StylePropertySet::PropertyReference::cssName() const |
| 603 { | 603 { |
| 604 return getPropertyNameString(id()); | 604 return getPropertyNameString(id()); |
| 605 } | 605 } |
| 606 | 606 |
| 607 String StylePropertySet::PropertyReference::cssText() const | 607 String StylePropertySet::PropertyReference::cssText() const |
| 608 { | 608 { |
| 609 StringBuilder result; | 609 StringBuilder result; |
| 610 result.append(cssName()); | 610 result.append(cssName()); |
| 611 result.appendLiteral(": "); | 611 result.appendLiteral(": "); |
| 612 result.append(propertyValue()->cssText()); | 612 result.append(propertyValue()->cssText()); |
| 613 if (isImportant()) | 613 if (isImportant()) |
| 614 result.appendLiteral(" !important"); | 614 result.appendLiteral(" !important"); |
| 615 result.append(';'); | 615 result.append(';'); |
| 616 return result.toString(); | 616 return result.toString(); |
| 617 } | 617 } |
| 618 | 618 |
| 619 | 619 |
| 620 } // namespace WebCore | 620 } // namespace WebCore |
| OLD | NEW |