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

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

Issue 119533003: Clear mutable inline style when it is empty. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed typo. Created 7 years 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
Index: Source/core/dom/Element.cpp
diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp
index ced2bd06440792fe0a24dbe5deac5b25b4f45e55..01d87205c9b8b28160d0ae03ceb5bd78816560e8 100644
--- a/Source/core/dom/Element.cpp
+++ b/Source/core/dom/Element.cpp
@@ -924,6 +924,14 @@ void Element::setSynchronizedLazyAttribute(const QualifiedName& name, const Atom
setAttributeInternal(index, name, value, InSynchronizationOfLazyAttribute);
}
+void Element::removeSynchronizedLazyAttribute(const QualifiedName& name)
+{
+ size_t index = elementData() ? elementData()->getAttributeItemIndex(name) : kNotFound;
+ if (index == kNotFound)
+ return;
+ removeAttributeInternal(index, InSynchronizationOfLazyAttribute);
+}
+
ALWAYS_INLINE void Element::setAttributeInternal(size_t index, const QualifiedName& name, const AtomicString& newValue, SynchronizationOfLazyAttribute inSynchronizationOfLazyAttribute)
{
if (newValue.isNull()) {
@@ -3434,6 +3442,8 @@ void Element::synchronizeStyleAttributeInternal() const
elementData()->m_styleAttributeIsDirty = false;
if (const StylePropertySet* inlineStyle = this->inlineStyle())
const_cast<Element*>(this)->setSynchronizedLazyAttribute(styleAttr, inlineStyle->asText());
+ else
+ const_cast<Element*>(this)->removeSynchronizedLazyAttribute(styleAttr);
eseidel 2013/12/23 21:30:23 I remember being in this code for the hasAttribute
chrishtr 2013/12/23 22:06:46 Will adjust this method to use setSynchronizedLazy
}
CSSStyleDeclaration* Element::style()
@@ -3456,6 +3466,13 @@ MutableStylePropertySet* Element::ensureMutableInlineStyle()
return toMutableStylePropertySet(inlineStyle);
}
+void Element::clearMutableInlineStyleIfEmpty()
+{
+ if (ensureMutableInlineStyle()->isEmpty()) {
+ ensureUniqueElementData()->m_inlineStyle.clear();
+ }
+}
+
PropertySetCSSStyleDeclaration* Element::inlineStyleCSSOMWrapper()
{
if (!inlineStyle() || !inlineStyle()->hasCSSOMWrapper())
@@ -3564,7 +3581,7 @@ bool Element::removeInlineStyleProperty(CSSPropertyID propertyID)
void Element::removeAllInlineStyleProperties()
{
ASSERT(isStyledElement());
- if (!inlineStyle() || inlineStyle()->isEmpty())
+ if (!inlineStyle())
return;
ensureMutableInlineStyle()->clear();
inlineStyleChanged();

Powered by Google App Engine
This is Rietveld 408576698