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

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: Fix mac build 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 3088 matching lines...) Expand 10 before | Expand all | Expand 10 after
3099 CSSStyleDeclaration* Element::style() 3099 CSSStyleDeclaration* Element::style()
3100 { 3100 {
3101 if (!isStyledElement()) 3101 if (!isStyledElement())
3102 return 0; 3102 return 0;
3103 return &ensureElementRareData().ensureInlineCSSStyleDeclaration(this); 3103 return &ensureElementRareData().ensureInlineCSSStyleDeclaration(this);
3104 } 3104 }
3105 3105
3106 MutableStylePropertySet& Element::ensureMutableInlineStyle() 3106 MutableStylePropertySet& Element::ensureMutableInlineStyle()
3107 { 3107 {
3108 ASSERT(isStyledElement()); 3108 ASSERT(isStyledElement());
3109 RefPtr<StylePropertySet>& inlineStyle = ensureUniqueElementData().m_inlineSt yle; 3109 RefPtrWillBeMember<StylePropertySet>& inlineStyle = ensureUniqueElementData( ).m_inlineStyle;
3110 if (!inlineStyle) { 3110 if (!inlineStyle) {
3111 CSSParserMode mode = (!isHTMLElement() || document().inQuirksMode()) ? H TMLQuirksMode : HTMLStandardMode; 3111 CSSParserMode mode = (!isHTMLElement() || document().inQuirksMode()) ? H TMLQuirksMode : HTMLStandardMode;
3112 inlineStyle = MutableStylePropertySet::create(mode); 3112 inlineStyle = MutableStylePropertySet::create(mode);
3113 } else if (!inlineStyle->isMutable()) { 3113 } else if (!inlineStyle->isMutable()) {
3114 inlineStyle = inlineStyle->mutableCopy(); 3114 inlineStyle = inlineStyle->mutableCopy();
3115 } 3115 }
3116 return *toMutableStylePropertySet(inlineStyle); 3116 return *toMutableStylePropertySet(inlineStyle);
3117 } 3117 }
3118 3118
3119 void Element::clearMutableInlineStyleIfEmpty() 3119 void Element::clearMutableInlineStyleIfEmpty()
3120 { 3120 {
3121 if (ensureMutableInlineStyle().isEmpty()) { 3121 if (ensureMutableInlineStyle().isEmpty()) {
3122 ensureUniqueElementData().m_inlineStyle.clear(); 3122 ensureUniqueElementData().m_inlineStyle.clear();
3123 } 3123 }
3124 } 3124 }
3125 3125
3126 inline void Element::setInlineStyleFromString(const AtomicString& newStyleString ) 3126 inline void Element::setInlineStyleFromString(const AtomicString& newStyleString )
3127 { 3127 {
3128 ASSERT(isStyledElement()); 3128 ASSERT(isStyledElement());
3129 RefPtr<StylePropertySet>& inlineStyle = elementData()->m_inlineStyle; 3129 RefPtrWillBeMember<StylePropertySet>& inlineStyle = elementData()->m_inlineS tyle;
3130 3130
3131 // Avoid redundant work if we're using shared attribute data with already pa rsed inline style. 3131 // Avoid redundant work if we're using shared attribute data with already pa rsed inline style.
3132 if (inlineStyle && !elementData()->isUnique()) 3132 if (inlineStyle && !elementData()->isUnique())
3133 return; 3133 return;
3134 3134
3135 // We reconstruct the property set instead of mutating if there is no CSSOM wrapper. 3135 // We reconstruct the property set instead of mutating if there is no CSSOM wrapper.
3136 // This makes wrapperless property sets immutable and so cacheable. 3136 // This makes wrapperless property sets immutable and so cacheable.
3137 if (inlineStyle && !inlineStyle->isMutable()) 3137 if (inlineStyle && !inlineStyle->isMutable())
3138 inlineStyle.clear(); 3138 inlineStyle.clear();
3139 3139
3140 if (!inlineStyle) { 3140 if (!inlineStyle) {
3141 inlineStyle = BisonCSSParser::parseInlineStyleDeclaration(newStyleString , this); 3141 inlineStyle = BisonCSSParser::parseInlineStyleDeclaration(newStyleString , this);
3142 } else { 3142 } else {
3143 ASSERT(inlineStyle->isMutable()); 3143 ASSERT(inlineStyle->isMutable());
3144 static_pointer_cast<MutableStylePropertySet>(inlineStyle)->parseDeclarat ion(newStyleString, document().elementSheet().contents()); 3144 static_cast<MutableStylePropertySet*>(inlineStyle.get())->parseDeclarati on(newStyleString, document().elementSheet().contents());
3145 } 3145 }
3146 } 3146 }
3147 3147
3148 void Element::styleAttributeChanged(const AtomicString& newStyleString, Attribut eModificationReason modificationReason) 3148 void Element::styleAttributeChanged(const AtomicString& newStyleString, Attribut eModificationReason modificationReason)
3149 { 3149 {
3150 ASSERT(isStyledElement()); 3150 ASSERT(isStyledElement());
3151 WTF::OrdinalNumber startLineNumber = WTF::OrdinalNumber::beforeFirst(); 3151 WTF::OrdinalNumber startLineNumber = WTF::OrdinalNumber::beforeFirst();
3152 if (document().scriptableDocumentParser() && !document().isInDocumentWrite() ) 3152 if (document().scriptableDocumentParser() && !document().isInDocumentWrite() )
3153 startLineNumber = document().scriptableDocumentParser()->lineNumber(); 3153 startLineNumber = document().scriptableDocumentParser()->lineNumber();
3154 3154
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
3293 return false; 3293 return false;
3294 return true; 3294 return true;
3295 } 3295 }
3296 3296
3297 void Element::trace(Visitor* visitor) 3297 void Element::trace(Visitor* visitor)
3298 { 3298 {
3299 // FIXME: Oilpan: Perform this tracing directly on the element 3299 // FIXME: Oilpan: Perform this tracing directly on the element
3300 // rare data once that is in the heap. 3300 // rare data once that is in the heap.
3301 if (hasRareData()) 3301 if (hasRareData())
3302 elementRareData()->trace(visitor); 3302 elementRareData()->trace(visitor);
3303 visitor->trace(m_elementData);
3303 ContainerNode::trace(visitor); 3304 ContainerNode::trace(visitor);
3304 } 3305 }
3305 3306
3306 } // namespace WebCore 3307 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698