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

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

Issue 203193010: Add UseCounters for the Attr.value getter and setter (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/Attr.h ('k') | Source/core/dom/Attr.idl » ('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 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2012 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2012 Apple Inc. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 10 matching lines...) Expand all
21 * Boston, MA 02110-1301, USA. 21 * Boston, MA 02110-1301, USA.
22 */ 22 */
23 #include "config.h" 23 #include "config.h"
24 #include "core/dom/Attr.h" 24 #include "core/dom/Attr.h"
25 25
26 #include "bindings/v8/ExceptionState.h" 26 #include "bindings/v8/ExceptionState.h"
27 #include "bindings/v8/ExceptionStatePlaceholder.h" 27 #include "bindings/v8/ExceptionStatePlaceholder.h"
28 #include "core/dom/Element.h" 28 #include "core/dom/Element.h"
29 #include "core/dom/Text.h" 29 #include "core/dom/Text.h"
30 #include "core/events/ScopedEventQueue.h" 30 #include "core/events/ScopedEventQueue.h"
31 #include "core/frame/UseCounter.h"
31 #include "wtf/text/AtomicString.h" 32 #include "wtf/text/AtomicString.h"
32 #include "wtf/text/StringBuilder.h" 33 #include "wtf/text/StringBuilder.h"
33 34
34 namespace WebCore { 35 namespace WebCore {
35 36
36 using namespace HTMLNames; 37 using namespace HTMLNames;
37 38
38 Attr::Attr(Element& element, const QualifiedName& name) 39 Attr::Attr(Element& element, const QualifiedName& name)
39 : ContainerNode(&element.document()) 40 : ContainerNode(&element.document())
40 , m_element(&element) 41 , m_element(&element)
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 if (m_element) 96 if (m_element)
96 elementAttribute().setValue(value); 97 elementAttribute().setValue(value);
97 else 98 else
98 m_standaloneValue = value; 99 m_standaloneValue = value;
99 createTextChild(); 100 createTextChild();
100 m_ignoreChildrenChanged--; 101 m_ignoreChildrenChanged--;
101 102
102 invalidateNodeListCachesInAncestors(&m_name, m_element); 103 invalidateNodeListCachesInAncestors(&m_name, m_element);
103 } 104 }
104 105
105 void Attr::setValue(const AtomicString& value, ExceptionState&) 106 void Attr::setValueInternal(const AtomicString& value)
106 { 107 {
107 if (m_element) 108 if (m_element)
108 m_element->willModifyAttribute(qualifiedName(), this->value(), value); 109 m_element->willModifyAttribute(qualifiedName(), this->value(), value);
109 110
110 setValue(value); 111 setValue(value);
111 112
112 if (m_element) 113 if (m_element)
113 m_element->didModifyAttribute(qualifiedName(), value); 114 m_element->didModifyAttribute(qualifiedName(), value);
114 } 115 }
115 116
117 const AtomicString& Attr::valueForBindings() const
118 {
119 UseCounter::count(document(), UseCounter::AttrGetValue);
120 return value();
121 }
122
123 void Attr::setValueForBindings(const AtomicString& value)
124 {
125 UseCounter::count(document(), UseCounter::AttrSetValue);
126 setValueInternal(value);
127 }
128
116 void Attr::setNodeValue(const String& v) 129 void Attr::setNodeValue(const String& v)
117 { 130 {
118 // Attr uses AtomicString type for its value to save memory as there 131 // Attr uses AtomicString type for its value to save memory as there
119 // is duplication among Elements' attributes values. 132 // is duplication among Elements' attributes values.
120 setValue(AtomicString(v), IGNORE_EXCEPTION); 133 setValueInternal(AtomicString(v));
121 } 134 }
122 135
123 PassRefPtr<Node> Attr::cloneNode(bool /*deep*/) 136 PassRefPtr<Node> Attr::cloneNode(bool /*deep*/)
124 { 137 {
125 RefPtr<Attr> clone = adoptRef(new Attr(document(), qualifiedName(), value()) ); 138 RefPtr<Attr> clone = adoptRef(new Attr(document(), qualifiedName(), value()) );
126 cloneChildNodes(clone.get()); 139 cloneChildNodes(clone.get());
127 return clone.release(); 140 return clone.release();
128 } 141 }
129 142
130 // DOM Section 1.1.1 143 // DOM Section 1.1.1
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 195 }
183 196
184 void Attr::attachToElement(Element* element) 197 void Attr::attachToElement(Element* element)
185 { 198 {
186 ASSERT(!m_element); 199 ASSERT(!m_element);
187 m_element = element; 200 m_element = element;
188 m_standaloneValue = nullAtom; 201 m_standaloneValue = nullAtom;
189 } 202 }
190 203
191 } 204 }
OLDNEW
« 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