Changeset 143834 in webkit
- Timestamp:
- Feb 22, 2013 8:47:20 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r143832 r143834 1 2013-02-22 Andreas Kling <akling@apple.com> 2 3 Attr: Simplify modification callbacks. 4 <http://webkit.org/b/110598> 5 6 Reviewed by Antti Koivisto. 7 8 Instead of Attr being a friend of Element and grabbing at various internal storage and callbacks, 9 let Attr simply call Element::setAttribute() when its value is changed, and do all that business 10 from Element. 11 12 * dom/Element.h: 13 * dom/Element.cpp: 14 (WebCore::Element::setAttributeInternal): 15 16 Call Attr::recreateTextChildAfterAttributeValueChanged() after modifying an attribute value instead 17 of doing the modification through the Attr node. 18 19 * dom/Attr.h: 20 * dom/Attr.cpp: 21 (WebCore::Attr::Attr): 22 (WebCore::Attr::childrenChanged): 23 24 Added an m_inChildrenChanged flag so we can prevent infinite callback recursion in childrenChanged(). 25 26 (WebCore::Attr::setValue): 27 28 Call Element::setAttribute() instead of modifying the attribute storage directly. 29 30 (WebCore::Attr::recreateTextChildAfterAttributeValueChanged): 31 32 Factored out the "remove all children / create a new text child with attribute value" logic into 33 a separate function. 34 1 35 2013-02-22 Gyuyoung Kim <gyuyoung.kim@samsung.com> 2 36 -
trunk/Source/WebCore/dom/Attr.cpp
r142827 r143834 4 4 * (C) 2001 Peter Kelly (pmk@post.com) 5 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, 2013 Apple Inc. All rights reserved. 7 7 * 8 8 * This library is free software; you can redistribute it and/or … … 30 30 #include "Text.h" 31 31 #include "XMLNSNames.h" 32 #include <wtf/TemporaryChange.h> 32 33 #include <wtf/text/AtomicString.h> 33 34 #include <wtf/text/StringBuilder.h> … … 42 43 , m_name(name) 43 44 , m_ignoreChildrenChanged(0) 45 , m_inChildrenChanged(false) 44 46 , m_specified(true) 45 47 { … … 52 54 , m_standaloneValue(standaloneValue) 53 55 , m_ignoreChildrenChanged(0) 56 , m_inChildrenChanged(false) 54 57 , m_specified(true) 55 58 { … … 108 111 } 109 112 110 void Attr::setValue(const AtomicString& value) 111 { 113 void Attr::recreateTextChildAfterAttributeValueChanged() 114 { 115 if (m_inChildrenChanged) 116 return; 112 117 EventQueueScope scope; 113 118 m_ignoreChildrenChanged++; 114 119 removeChildren(); 115 if (m_element)116 elementAttribute().setValue(value);117 else118 m_standaloneValue = value;119 120 createTextChild(); 120 121 m_ignoreChildrenChanged--; 121 122 } 123 124 void Attr::setValue(const AtomicString& value) 125 { 122 126 invalidateNodeListCachesInAncestors(&m_name, m_element); 127 128 if (m_element) { 129 m_element->setAttribute(m_name, value); 130 return; 131 } 132 m_standaloneValue = value; 133 recreateTextChildAfterAttributeValueChanged(); 123 134 } 124 135 125 136 void Attr::setValue(const AtomicString& value, ExceptionCode&) 126 137 { 127 if (m_element)128 m_element->willModifyAttribute(qualifiedName(), this->value(), value);129 130 138 setValue(value); 131 132 if (m_element)133 m_element->didModifyAttribute(qualifiedName(), value);134 139 } 135 140 … … 163 168 return; 164 169 165 invalidateNodeListCachesInAncestors(&qualifiedName(), m_element);170 TemporaryChange<bool> changeInChildrenChanged(m_inChildrenChanged, true); 166 171 167 172 // FIXME: We should include entity references in the value … … 173 178 } 174 179 175 AtomicString newValue = valueBuilder.toAtomicString(); 176 if (m_element) 177 m_element->willModifyAttribute(qualifiedName(), value(), newValue); 178 179 if (m_element) 180 elementAttribute().setValue(newValue); 181 else 182 m_standaloneValue = newValue; 183 184 if (m_element) 185 m_element->attributeChanged(qualifiedName(), newValue); 180 setValue(valueBuilder.toAtomicString()); 186 181 } 187 182 -
trunk/Source/WebCore/dom/Attr.h
r127228 r143834 65 65 void detachFromElementWithValue(const AtomicString&); 66 66 67 void recreateTextChildAfterAttributeValueChanged(); 68 67 69 private: 68 70 Attr(Element*, const QualifiedName&); … … 102 104 103 105 RefPtr<StylePropertySet> m_style; 104 unsigned m_ignoreChildrenChanged : 31; 105 bool m_specified : 1; 106 unsigned short m_ignoreChildrenChanged; 107 bool m_inChildrenChanged; 108 bool m_specified; 106 109 }; 107 110 -
trunk/Source/WebCore/dom/Element.cpp
r143743 r143834 809 809 810 810 if (newValue != attributeItem(index)->value()) { 811 // If there is an Attr node hooked to this attribute, the Attr::setValue() call below 812 // will write into the ElementData. 813 // FIXME: Refactor this so it makes some sense. 811 ensureUniqueElementData()->attributeItem(index)->setValue(newValue); 812 814 813 if (RefPtr<Attr> attrNode = inSynchronizationOfLazyAttribute ? 0 : attrIfExists(name)) 815 attrNode->setValue(newValue); 816 else 817 ensureUniqueElementData()->attributeItem(index)->setValue(newValue); 814 attrNode->recreateTextChildAfterAttributeValueChanged(); 818 815 } 819 816 -
trunk/Source/WebCore/dom/Element.h
r143743 r143834 638 638 virtual bool alwaysCreateUserAgentShadowRoot() const { return false; } 639 639 640 // FIXME: Remove the need for Attr to call willModifyAttribute/didModifyAttribute.641 friend class Attr;642 643 640 enum SynchronizationOfLazyAttribute { NotInSynchronizationOfLazyAttribute = 0, InSynchronizationOfLazyAttribute }; 644 641
Note: See TracChangeset
for help on using the changeset viewer.