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

Side by Side Diff: Source/core/dom/Element.cpp

Issue 405923002: Introduce DEFINE_ELEMENT_DATA_TYPE_CASTS, and use it (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 5 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
« no previous file with comments | « Source/core/dom/Element.h ('k') | Source/core/dom/ElementData.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3099 matching lines...) Expand 10 before | Expand all | Expand 10 after
3110 // if the idForStyleResolution and the className need different casing. 3110 // if the idForStyleResolution and the className need different casing.
3111 bool ownerDocumentsHaveDifferentCaseSensitivity = false; 3111 bool ownerDocumentsHaveDifferentCaseSensitivity = false;
3112 if (other.hasClass() || other.hasID()) 3112 if (other.hasClass() || other.hasID())
3113 ownerDocumentsHaveDifferentCaseSensitivity = other.document().inQuirksMo de() != document().inQuirksMode(); 3113 ownerDocumentsHaveDifferentCaseSensitivity = other.document().inQuirksMo de() != document().inQuirksMode();
3114 3114
3115 // If 'other' has a mutable ElementData, convert it to an immutable one so w e can share it between both elements. 3115 // If 'other' has a mutable ElementData, convert it to an immutable one so w e can share it between both elements.
3116 // We can only do this if there are no presentation attributes and sharing t he data won't result in different case sensitivity of class or id. 3116 // We can only do this if there are no presentation attributes and sharing t he data won't result in different case sensitivity of class or id.
3117 if (other.m_elementData->isUnique() 3117 if (other.m_elementData->isUnique()
3118 && !ownerDocumentsHaveDifferentCaseSensitivity 3118 && !ownerDocumentsHaveDifferentCaseSensitivity
3119 && !other.m_elementData->presentationAttributeStyle()) 3119 && !other.m_elementData->presentationAttributeStyle())
3120 const_cast<Element&>(other).m_elementData = static_cast<const UniqueElem entData*>(other.m_elementData.get())->makeShareableCopy(); 3120 const_cast<Element&>(other).m_elementData = toUniqueElementData(other.m_ elementData)->makeShareableCopy();
3121 3121
3122 if (!other.m_elementData->isUnique() && !ownerDocumentsHaveDifferentCaseSens itivity && !needsURLResolutionForInlineStyle(other, other.document(), document() )) 3122 if (!other.m_elementData->isUnique() && !ownerDocumentsHaveDifferentCaseSens itivity && !needsURLResolutionForInlineStyle(other, other.document(), document() ))
3123 m_elementData = other.m_elementData; 3123 m_elementData = other.m_elementData;
3124 else 3124 else
3125 m_elementData = other.m_elementData->makeUniqueCopy(); 3125 m_elementData = other.m_elementData->makeUniqueCopy();
3126 3126
3127 AttributeCollection attributes = m_elementData->attributes(); 3127 AttributeCollection attributes = m_elementData->attributes();
3128 AttributeCollection::const_iterator end = attributes.end(); 3128 AttributeCollection::const_iterator end = attributes.end();
3129 for (AttributeCollection::const_iterator it = attributes.begin(); it != end; ++it) 3129 for (AttributeCollection::const_iterator it = attributes.begin(); it != end; ++it)
3130 attributeChangedFromParserOrByCloning(it->name(), it->value(), ModifiedB yCloning); 3130 attributeChangedFromParserOrByCloning(it->name(), it->value(), ModifiedB yCloning);
3131 } 3131 }
3132 3132
3133 void Element::cloneDataFromElement(const Element& other) 3133 void Element::cloneDataFromElement(const Element& other)
3134 { 3134 {
3135 cloneAttributesFromElement(other); 3135 cloneAttributesFromElement(other);
3136 copyNonAttributePropertiesFromElement(other); 3136 copyNonAttributePropertiesFromElement(other);
3137 } 3137 }
3138 3138
3139 void Element::createUniqueElementData() 3139 void Element::createUniqueElementData()
3140 { 3140 {
3141 if (!m_elementData) 3141 if (!m_elementData)
3142 m_elementData = UniqueElementData::create(); 3142 m_elementData = UniqueElementData::create();
3143 else { 3143 else {
3144 ASSERT(!m_elementData->isUnique()); 3144 ASSERT(!m_elementData->isUnique());
3145 m_elementData = static_cast<ShareableElementData*>(m_elementData.get())- >makeUniqueCopy(); 3145 m_elementData = toShareableElementData(m_elementData)->makeUniqueCopy();
3146 } 3146 }
3147 } 3147 }
3148 3148
3149 InputMethodContext& Element::inputMethodContext() 3149 InputMethodContext& Element::inputMethodContext()
3150 { 3150 {
3151 return ensureElementRareData().ensureInputMethodContext(toHTMLElement(this)) ; 3151 return ensureElementRareData().ensureInputMethodContext(toHTMLElement(this)) ;
3152 } 3152 }
3153 3153
3154 bool Element::hasInputMethodContext() const 3154 bool Element::hasInputMethodContext() const
3155 { 3155 {
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
3367 { 3367 {
3368 #if ENABLE(OILPAN) 3368 #if ENABLE(OILPAN)
3369 if (hasRareData()) 3369 if (hasRareData())
3370 visitor->trace(elementRareData()); 3370 visitor->trace(elementRareData());
3371 visitor->trace(m_elementData); 3371 visitor->trace(m_elementData);
3372 #endif 3372 #endif
3373 ContainerNode::trace(visitor); 3373 ContainerNode::trace(visitor);
3374 } 3374 }
3375 3375
3376 } // namespace blink 3376 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/dom/Element.h ('k') | Source/core/dom/ElementData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698