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

Side by Side Diff: Source/core/dom/Element.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 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Peter Kelly (pmk@post.com) 4 * (C) 2001 Peter Kelly (pmk@post.com)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * (C) 2007 David Smith (catfish.man@gmail.com) 6 * (C) 2007 David Smith (catfish.man@gmail.com)
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
8 * (C) 2007 Eric Seidel (eric@webkit.org) 8 * (C) 2007 Eric Seidel (eric@webkit.org)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 3089 matching lines...) Expand 10 before | Expand all | Expand 10 after
3100 CSSStyleDeclaration* Element::style() 3100 CSSStyleDeclaration* Element::style()
3101 { 3101 {
3102 if (!isStyledElement()) 3102 if (!isStyledElement())
3103 return 0; 3103 return 0;
3104 return &ensureElementRareData().ensureInlineCSSStyleDeclaration(this); 3104 return &ensureElementRareData().ensureInlineCSSStyleDeclaration(this);
3105 } 3105 }
3106 3106
3107 MutableStylePropertySet& Element::ensureMutableInlineStyle() 3107 MutableStylePropertySet& Element::ensureMutableInlineStyle()
3108 { 3108 {
3109 ASSERT(isStyledElement()); 3109 ASSERT(isStyledElement());
3110 RefPtr<StylePropertySet>& inlineStyle = ensureUniqueElementData().m_inlineSt yle; 3110 RefPtrWillBeMember<StylePropertySet>& inlineStyle = ensureUniqueElementData( ).m_inlineStyle;
3111 if (!inlineStyle) { 3111 if (!inlineStyle) {
3112 CSSParserMode mode = (!isHTMLElement() || document().inQuirksMode()) ? H TMLQuirksMode : HTMLStandardMode; 3112 CSSParserMode mode = (!isHTMLElement() || document().inQuirksMode()) ? H TMLQuirksMode : HTMLStandardMode;
3113 inlineStyle = MutableStylePropertySet::create(mode); 3113 inlineStyle = MutableStylePropertySet::create(mode);
3114 } else if (!inlineStyle->isMutable()) { 3114 } else if (!inlineStyle->isMutable()) {
3115 inlineStyle = inlineStyle->mutableCopy(); 3115 inlineStyle = inlineStyle->mutableCopy();
3116 } 3116 }
3117 return *toMutableStylePropertySet(inlineStyle); 3117 return *toMutableStylePropertySet(inlineStyle);
3118 } 3118 }
3119 3119
3120 void Element::clearMutableInlineStyleIfEmpty() 3120 void Element::clearMutableInlineStyleIfEmpty()
3121 { 3121 {
3122 if (ensureMutableInlineStyle().isEmpty()) { 3122 if (ensureMutableInlineStyle().isEmpty()) {
3123 ensureUniqueElementData().m_inlineStyle.clear(); 3123 ensureUniqueElementData().m_inlineStyle.clear();
3124 } 3124 }
3125 } 3125 }
3126 3126
3127 inline void Element::setInlineStyleFromString(const AtomicString& newStyleString ) 3127 inline void Element::setInlineStyleFromString(const AtomicString& newStyleString )
3128 { 3128 {
3129 ASSERT(isStyledElement()); 3129 ASSERT(isStyledElement());
3130 RefPtr<StylePropertySet>& inlineStyle = elementData()->m_inlineStyle; 3130 RefPtrWillBeMember<StylePropertySet>& inlineStyle = elementData()->m_inlineS tyle;
3131 3131
3132 // Avoid redundant work if we're using shared attribute data with already pa rsed inline style. 3132 // Avoid redundant work if we're using shared attribute data with already pa rsed inline style.
3133 if (inlineStyle && !elementData()->isUnique()) 3133 if (inlineStyle && !elementData()->isUnique())
3134 return; 3134 return;
3135 3135
3136 // We reconstruct the property set instead of mutating if there is no CSSOM wrapper. 3136 // We reconstruct the property set instead of mutating if there is no CSSOM wrapper.
3137 // This makes wrapperless property sets immutable and so cacheable. 3137 // This makes wrapperless property sets immutable and so cacheable.
3138 if (inlineStyle && !inlineStyle->isMutable()) 3138 if (inlineStyle && !inlineStyle->isMutable())
3139 inlineStyle.clear(); 3139 inlineStyle.clear();
3140 3140
3141 if (!inlineStyle) { 3141 if (!inlineStyle) {
3142 inlineStyle = BisonCSSParser::parseInlineStyleDeclaration(newStyleString , this); 3142 inlineStyle = BisonCSSParser::parseInlineStyleDeclaration(newStyleString , this);
3143 } else { 3143 } else {
3144 ASSERT(inlineStyle->isMutable()); 3144 ASSERT(inlineStyle->isMutable());
3145 static_pointer_cast<MutableStylePropertySet>(inlineStyle)->parseDeclarat ion(newStyleString, document().elementSheet().contents()); 3145 static_cast<MutableStylePropertySet*>(inlineStyle.get())->parseDeclarati on(newStyleString, document().elementSheet().contents());
3146 } 3146 }
3147 } 3147 }
3148 3148
3149 void Element::styleAttributeChanged(const AtomicString& newStyleString, Attribut eModificationReason modificationReason) 3149 void Element::styleAttributeChanged(const AtomicString& newStyleString, Attribut eModificationReason modificationReason)
3150 { 3150 {
3151 ASSERT(isStyledElement()); 3151 ASSERT(isStyledElement());
3152 WTF::OrdinalNumber startLineNumber = WTF::OrdinalNumber::beforeFirst(); 3152 WTF::OrdinalNumber startLineNumber = WTF::OrdinalNumber::beforeFirst();
3153 if (document().scriptableDocumentParser() && !document().isInDocumentWrite() ) 3153 if (document().scriptableDocumentParser() && !document().isInDocumentWrite() )
3154 startLineNumber = document().scriptableDocumentParser()->lineNumber(); 3154 startLineNumber = document().scriptableDocumentParser()->lineNumber();
3155 3155
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
3294 return false; 3294 return false;
3295 return true; 3295 return true;
3296 } 3296 }
3297 3297
3298 void Element::trace(Visitor* visitor) 3298 void Element::trace(Visitor* visitor)
3299 { 3299 {
3300 // FIXME: Oilpan: Perform this tracing directly on the element 3300 // FIXME: Oilpan: Perform this tracing directly on the element
3301 // rare data once that is in the heap. 3301 // rare data once that is in the heap.
3302 if (hasRareData()) 3302 if (hasRareData())
3303 elementRareData()->trace(visitor); 3303 elementRareData()->trace(visitor);
3304 visitor->trace(m_elementData);
3304 ContainerNode::trace(visitor); 3305 ContainerNode::trace(visitor);
3305 } 3306 }
3306 3307
3307 } // namespace WebCore 3308 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698