Index: Source/core/dom/Attr.cpp |
diff --git a/Source/core/dom/Attr.cpp b/Source/core/dom/Attr.cpp |
index c6454fa4d863a4b31b85635fc15e37d60db963f3..08127695886e99964c2c08463ea3093b33ee069c 100644 |
--- a/Source/core/dom/Attr.cpp |
+++ b/Source/core/dom/Attr.cpp |
@@ -28,6 +28,7 @@ |
#include "core/dom/Element.h" |
#include "core/dom/Text.h" |
#include "core/events/ScopedEventQueue.h" |
+#include "core/frame/UseCounter.h" |
#include "wtf/text/AtomicString.h" |
#include "wtf/text/StringBuilder.h" |
@@ -42,6 +43,7 @@ Attr::Attr(Element& element, const QualifiedName& name) |
, m_ignoreChildrenChanged(0) |
{ |
ScriptWrappable::init(this); |
+ m_standaloneValue = value(); |
} |
Attr::Attr(Document& document, const QualifiedName& name, const AtomicString& standaloneValue) |
@@ -94,8 +96,7 @@ void Attr::setValue(const AtomicString& value) |
removeChildren(); |
if (m_element) |
elementAttribute().setValue(value); |
- else |
- m_standaloneValue = value; |
+ m_standaloneValue = value; |
createTextChild(); |
m_ignoreChildrenChanged--; |
@@ -113,6 +114,20 @@ void Attr::setValue(const AtomicString& value, ExceptionState&) |
m_element->didModifyAttribute(qualifiedName(), value); |
} |
+const AtomicString& Attr::valueForBindings() const |
+{ |
+ if (m_element && m_standaloneValue != value()) |
+ UseCounter::count(document(), UseCounter::AttrGetValueNeedsElement); |
+ return value(); |
+} |
+ |
+void Attr::setValueForBindings(const AtomicString& value) |
+{ |
+ if (m_element && value != this->value()) |
+ UseCounter::count(document(), UseCounter::AttrSetValueNeedsElement); |
+ setValue(value, IGNORE_EXCEPTION); |
+} |
+ |
void Attr::setNodeValue(const String& v) |
{ |
// Attr uses AtomicString type for its value to save memory as there |
@@ -138,6 +153,8 @@ void Attr::childrenChanged(bool, Node*, Node*, int) |
if (m_ignoreChildrenChanged > 0) |
return; |
+ UseCounter::count(document(), UseCounter::AttrChildrenChanged); |
+ |
invalidateNodeListCachesInAncestors(&qualifiedName(), m_element); |
StringBuilder valueBuilder; |
@@ -152,8 +169,7 @@ void Attr::childrenChanged(bool, Node*, Node*, int) |
if (m_element) |
elementAttribute().setValue(newValue); |
- else |
- m_standaloneValue = newValue; |
+ m_standaloneValue = newValue; |
if (m_element) |
m_element->attributeChanged(qualifiedName(), newValue); |
@@ -176,7 +192,6 @@ Attribute& Attr::elementAttribute() |
void Attr::detachFromElementWithValue(const AtomicString& value) |
{ |
ASSERT(m_element); |
- ASSERT(m_standaloneValue.isNull()); |
m_standaloneValue = value; |
m_element = 0; |
} |
@@ -185,7 +200,7 @@ void Attr::attachToElement(Element* element) |
{ |
ASSERT(!m_element); |
m_element = element; |
- m_standaloneValue = nullAtom; |
+ m_standaloneValue = value(); |
} |
} |