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

Unified Diff: Source/core/dom/Element.cpp

Issue 176883005: Have Element::ensureUniqueElementData() return a reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/Element.h ('k') | Source/core/html/HTMLSelectElement.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Element.cpp
diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp
index b2e15a9932dd665006270c105e07fef4d5d01e81..b95f76a86a7836088cd4b203fb41b6fa78732076 100644
--- a/Source/core/dom/Element.cpp
+++ b/Source/core/dom/Element.cpp
@@ -977,7 +977,7 @@ ALWAYS_INLINE void Element::setAttributeInternal(size_t index, const QualifiedNa
if (RefPtr<Attr> attrNode = inSynchronizationOfLazyAttribute ? nullptr : attrIfExists(existingAttributeName))
attrNode->setValue(newValue);
else
- ensureUniqueElementData()->attributeItem(index)->setValue(newValue);
+ ensureUniqueElementData().attributeItem(index)->setValue(newValue);
}
if (!inSynchronizationOfLazyAttribute)
@@ -1963,14 +1963,14 @@ PassRefPtr<Attr> Element::setAttributeNode(Attr* attrNode, ExceptionState& excep
}
synchronizeAllAttributes();
- UniqueElementData* elementData = ensureUniqueElementData();
+ UniqueElementData& elementData = ensureUniqueElementData();
- size_t index = elementData->getAttributeItemIndex(attrNode->qualifiedName(), shouldIgnoreAttributeCase());
+ size_t index = elementData.getAttributeItemIndex(attrNode->qualifiedName(), shouldIgnoreAttributeCase());
if (index != kNotFound) {
if (oldAttrNode)
- detachAttrNodeFromElementWithValue(oldAttrNode.get(), elementData->attributeItem(index)->value());
+ detachAttrNodeFromElementWithValue(oldAttrNode.get(), elementData.attributeItem(index)->value());
else
- oldAttrNode = Attr::create(document(), attrNode->qualifiedName(), elementData->attributeItem(index)->value());
+ oldAttrNode = Attr::create(document(), attrNode->qualifiedName(), elementData.attributeItem(index)->value());
}
setAttributeInternal(index, attrNode->qualifiedName(), attrNode->value(), NotInSynchronizationOfLazyAttribute);
@@ -2038,10 +2038,10 @@ void Element::removeAttributeInternal(size_t index, SynchronizationOfLazyAttribu
{
ASSERT_WITH_SECURITY_IMPLICATION(index < attributeCount());
- UniqueElementData* elementData = ensureUniqueElementData();
+ UniqueElementData& elementData = ensureUniqueElementData();
- QualifiedName name = elementData->attributeItem(index)->name();
- AtomicString valueBeingRemoved = elementData->attributeItem(index)->value();
+ QualifiedName name = elementData.attributeItem(index)->name();
+ AtomicString valueBeingRemoved = elementData.attributeItem(index)->value();
if (!inSynchronizationOfLazyAttribute) {
if (!valueBeingRemoved.isNull())
@@ -2049,9 +2049,9 @@ void Element::removeAttributeInternal(size_t index, SynchronizationOfLazyAttribu
}
if (RefPtr<Attr> attrNode = attrIfExists(name))
- detachAttrNodeFromElementWithValue(attrNode.get(), elementData->attributeItem(index)->value());
+ detachAttrNodeFromElementWithValue(attrNode.get(), elementData.attributeItem(index)->value());
- elementData->removeAttribute(index);
+ elementData.removeAttribute(index);
if (!inSynchronizationOfLazyAttribute)
didRemoveAttribute(name);
@@ -2061,7 +2061,7 @@ void Element::addAttributeInternal(const QualifiedName& name, const AtomicString
{
if (!inSynchronizationOfLazyAttribute)
willModifyAttribute(name, nullAtom, value);
- ensureUniqueElementData()->addAttribute(name, value);
+ ensureUniqueElementData().addAttribute(name, value);
if (!inSynchronizationOfLazyAttribute)
didAddAttribute(name, value);
}
@@ -3320,7 +3320,7 @@ CSSStyleDeclaration* Element::style()
MutableStylePropertySet* Element::ensureMutableInlineStyle()
{
ASSERT(isStyledElement());
- RefPtr<StylePropertySet>& inlineStyle = ensureUniqueElementData()->m_inlineStyle;
+ RefPtr<StylePropertySet>& inlineStyle = ensureUniqueElementData().m_inlineStyle;
if (!inlineStyle) {
CSSParserMode mode = (!isHTMLElement() || document().inQuirksMode()) ? HTMLQuirksMode : HTMLStandardMode;
inlineStyle = MutableStylePropertySet::create(mode);
@@ -3333,7 +3333,7 @@ MutableStylePropertySet* Element::ensureMutableInlineStyle()
void Element::clearMutableInlineStyleIfEmpty()
{
if (ensureMutableInlineStyle()->isEmpty()) {
- ensureUniqueElementData()->m_inlineStyle.clear();
+ ensureUniqueElementData().m_inlineStyle.clear();
}
}
@@ -3367,7 +3367,7 @@ void Element::styleAttributeChanged(const AtomicString& newStyleString, Attribut
startLineNumber = document().scriptableDocumentParser()->lineNumber();
if (newStyleString.isNull()) {
- ensureUniqueElementData()->m_inlineStyle.clear();
+ ensureUniqueElementData().m_inlineStyle.clear();
} else if (modificationReason == ModifiedByCloning || document().contentSecurityPolicy()->allowInlineStyle(document().url(), startLineNumber)) {
setInlineStyleFromString(newStyleString);
}
@@ -3443,9 +3443,9 @@ void Element::removeAllInlineStyleProperties()
void Element::updatePresentationAttributeStyle()
{
// ShareableElementData doesn't store presentation attribute style, so make sure we have a UniqueElementData.
- UniqueElementData* elementData = ensureUniqueElementData();
- elementData->m_presentationAttributeStyleIsDirty = false;
- elementData->m_presentationAttributeStyle = computePresentationAttributeStyle(*this);
+ UniqueElementData& elementData = ensureUniqueElementData();
+ elementData.m_presentationAttributeStyleIsDirty = false;
+ elementData.m_presentationAttributeStyle = computePresentationAttributeStyle(*this);
}
void Element::addPropertyToPresentationAttributeStyle(MutableStylePropertySet* style, CSSPropertyID propertyID, CSSValueID identifier)
« no previous file with comments | « Source/core/dom/Element.h ('k') | Source/core/html/HTMLSelectElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698