Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Side by Side Diff: Source/core/css/StylePropertySet.cpp

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

Powered by Google App Engine
This is Rietveld 408576698