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

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

Issue 203313002: Measure how often Attr needs its associated Element (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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/Attr.h ('k') | Source/core/dom/Attr.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
}
« no previous file with comments | « Source/core/dom/Attr.h ('k') | Source/core/dom/Attr.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698