Changeset 214808 in webkit
- Timestamp:
- Apr 3, 2017 10:09:21 AM (7 years ago)
- Location:
- releases/WebKitGTK/webkit-2.16
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
releases/WebKitGTK/webkit-2.16/LayoutTests/ChangeLog
r214804 r214808 1 2017-03-27 Brent Fulgham <bfulgham@apple.com> 2 3 Only attach Attributes to a given element one time 4 https://bugs.webkit.org/show_bug.cgi?id=170125 5 <rdar://problem/31279676> 6 7 Reviewed by Chris Dumez. 8 9 * fast/dom/Attr/make-unique-element-data-while-replacing-attr-expected.txt: Rebaselined. 10 * fast/dom/Attr/make-unique-element-data-while-replacing-attr.html: Add check before setting new value. 11 * fast/dom/Attr/only-attach-attr-once-expected.txt: Added. 12 * fast/dom/Attr/only-attach-attr-once.html: Added. 13 1 14 2017-03-28 Antti Koivisto <antti@apple.com> 2 15 -
releases/WebKitGTK/webkit-2.16/LayoutTests/fast/dom/Attr/make-unique-element-data-while-replacing-attr-expected.txt
r212214 r214808 4 4 5 5 6 PASS element.getAttribute("width") is "a" 6 7 PASS element.getAttribute("width") is "b" 7 8 PASS successfullyParsed is true -
releases/WebKitGTK/webkit-2.16/LayoutTests/fast/dom/Attr/make-unique-element-data-while-replacing-attr.html
r212214 r214808 14 14 element.setAttributeNode(oldAttr); 15 15 16 shouldBeEqualToString('element.getAttribute("width")', 'a'); 17 16 18 element.addEventListener('DOMSubtreeModified', () => { element.cloneNode(); }, true); 17 19 -
releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog
r214804 r214808 1 2017-03-27 Brent Fulgham <bfulgham@apple.com> 2 3 Only attach Attributes to a given element one time 4 https://bugs.webkit.org/show_bug.cgi?id=170125 5 <rdar://problem/31279676> 6 7 Reviewed by Chris Dumez. 8 9 Attach the attribute node to the Element before calling 'setAttributeInternal', since that method may cause 10 arbitrary JavaScript events to fire. 11 12 Test: fast/dom/Attr/only-attach-attr-once.html 13 14 * dom/Element.cpp: 15 (WebCore::Element::attachAttributeNodeIfNeeded): Added. 16 (WebCore::Element::setAttributeNode): Use new method. Revise to attach attribute before calling 'setAttributeInternal'. 17 (WebCore::Element::setAttributeNodeNS): Ditto. 18 * dom/Element.h: 19 1 20 2017-03-28 Antti Koivisto <antti@apple.com> 2 21 -
releases/WebKitGTK/webkit-2.16/Source/WebCore/dom/Element.cpp
r214788 r214808 2122 2122 } 2123 2123 2124 void Element::attachAttributeNodeIfNeeded(Attr& attrNode) 2125 { 2126 ASSERT(!attrNode.ownerElement() || attrNode.ownerElement() == this); 2127 if (attrNode.ownerElement() == this) 2128 return; 2129 2130 NoEventDispatchAssertion assertNoEventDispatch; 2131 2132 attrNode.attachToElement(*this); 2133 treeScope().adoptIfNeeded(attrNode); 2134 ensureAttrNodeListForElement(*this).append(&attrNode); 2135 } 2136 2124 2137 ExceptionOr<RefPtr<Attr>> Element::setAttributeNode(Attr& attrNode) 2125 2138 { … … 2133 2146 return Exception { INUSE_ATTRIBUTE_ERR }; 2134 2147 2148 { 2149 NoEventDispatchAssertion assertNoEventDispatch; 2135 2150 synchronizeAllAttributes(); 2151 } 2152 2136 2153 auto& elementData = ensureUniqueElementData(); 2137 2154 2138 2155 auto existingAttributeIndex = elementData.findAttributeIndexByName(attrNode.localName(), shouldIgnoreAttributeCase(*this)); 2139 if (existingAttributeIndex == ElementData::attributeNotFound) 2140 setAttributeInternal(elementData.findAttributeIndexByName(attrNode.qualifiedName()), attrNode.qualifiedName(), attrNode.value(), NotInSynchronizationOfLazyAttribute); 2141 else { 2156 2157 // Attr::value() will return its 'm_standaloneValue' member any time its Element is set to nullptr. We need to cache this value 2158 // before making changes to attrNode's Element connections. 2159 auto attrNodeValue = attrNode.value(); 2160 2161 if (existingAttributeIndex == ElementData::attributeNotFound) { 2162 attachAttributeNodeIfNeeded(attrNode); 2163 setAttributeInternal(elementData.findAttributeIndexByName(attrNode.qualifiedName()), attrNode.qualifiedName(), attrNodeValue, NotInSynchronizationOfLazyAttribute); 2164 } else { 2142 2165 const Attribute& attribute = attributeAt(existingAttributeIndex); 2143 2166 if (oldAttrNode) … … 2146 2169 oldAttrNode = Attr::create(document(), attrNode.qualifiedName(), attribute.value()); 2147 2170 2171 attachAttributeNodeIfNeeded(attrNode); 2172 2148 2173 if (attribute.name().matches(attrNode.qualifiedName())) 2149 setAttributeInternal(existingAttributeIndex, attrNode.qualifiedName(), attrNode .value(), NotInSynchronizationOfLazyAttribute);2174 setAttributeInternal(existingAttributeIndex, attrNode.qualifiedName(), attrNodeValue, NotInSynchronizationOfLazyAttribute); 2150 2175 else { 2151 2176 removeAttributeInternal(existingAttributeIndex, NotInSynchronizationOfLazyAttribute); 2152 setAttributeInternal(ensureUniqueElementData().findAttributeIndexByName(attrNode.qualifiedName()), attrNode.qualifiedName(), attrNode .value(), NotInSynchronizationOfLazyAttribute);2177 setAttributeInternal(ensureUniqueElementData().findAttributeIndexByName(attrNode.qualifiedName()), attrNode.qualifiedName(), attrNodeValue, NotInSynchronizationOfLazyAttribute); 2153 2178 } 2154 2179 } 2155 if (attrNode.ownerElement() != this) { 2156 attrNode.attachToElement(*this); 2157 treeScope().adoptIfNeeded(attrNode); 2158 ensureAttrNodeListForElement(*this).append(&attrNode); 2159 } 2180 2160 2181 return WTFMove(oldAttrNode); 2161 2182 } … … 2172 2193 return Exception { INUSE_ATTRIBUTE_ERR }; 2173 2194 2195 unsigned index = 0; 2196 2197 // Attr::value() will return its 'm_standaloneValue' member any time its Element is set to nullptr. We need to cache this value 2198 // before making changes to attrNode's Element connections. 2199 auto attrNodeValue = attrNode.value(); 2200 2201 { 2202 NoEventDispatchAssertion assertNoEventDispatch; 2174 2203 synchronizeAllAttributes(); 2175 2204 auto& elementData = ensureUniqueElementData(); 2176 2205 2177 auto index = elementData.findAttributeIndexByName(attrNode.qualifiedName()); 2206 index = elementData.findAttributeIndexByName(attrNode.qualifiedName()); 2207 2178 2208 if (index != ElementData::attributeNotFound) { 2179 2209 if (oldAttrNode) … … 2182 2212 oldAttrNode = Attr::create(document(), attrNode.qualifiedName(), elementData.attributeAt(index).value()); 2183 2213 } 2184 2185 setAttributeInternal(index, attrNode.qualifiedName(), attrNode.value(), NotInSynchronizationOfLazyAttribute); 2186 2187 attrNode.attachToElement(*this); 2188 treeScope().adoptIfNeeded(attrNode); 2189 ensureAttrNodeListForElement(*this).append(&attrNode); 2214 } 2215 2216 attachAttributeNodeIfNeeded(attrNode); 2217 setAttributeInternal(index, attrNode.qualifiedName(), attrNodeValue, NotInSynchronizationOfLazyAttribute); 2190 2218 2191 2219 return WTFMove(oldAttrNode); -
releases/WebKitGTK/webkit-2.16/Source/WebCore/dom/Element.h
r214788 r214808 4 4 * (C) 2001 Peter Kelly (pmk@post.com) 5 5 * (C) 2001 Dirk Mueller (mueller@kde.org) 6 * Copyright (C) 2003-201 6Apple Inc. All rights reserved.6 * Copyright (C) 2003-2017 Apple Inc. All rights reserved. 7 7 * 8 8 * This library is free software; you can redistribute it and/or … … 680 680 // Anyone thinking of using this should call document instead of ownerDocument. 681 681 void ownerDocument() const = delete; 682 683 void attachAttributeNodeIfNeeded(Attr&); 682 684 683 685 QualifiedName m_tagName;
Note: See TracChangeset
for help on using the changeset viewer.