Changeset 109362 in webkit
- Timestamp:
- Mar 1, 2012, 10:19:03 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 10 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/dom/document-set-title-mutation-crash-expected.txt (added)
-
LayoutTests/fast/dom/document-set-title-mutation-crash.html (added)
-
LayoutTests/fast/dom/option-text-mutation-crash-expected.txt (added)
-
LayoutTests/fast/dom/option-text-mutation-crash.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/dom/Node.cpp (modified) (1 diff)
-
Source/WebCore/dom/Text.cpp (modified) (1 diff)
-
Source/WebCore/editing/markup.cpp (modified) (6 diffs)
-
Source/WebCore/html/HTMLOptionElement.cpp (modified) (1 diff)
-
Source/WebCore/html/HTMLScriptElement.cpp (modified) (1 diff)
-
Source/WebCore/html/HTMLTableElement.cpp (modified) (3 diffs)
-
Source/WebCore/html/HTMLTextAreaElement.cpp (modified) (1 diff)
-
Source/WebCore/html/HTMLTitleElement.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r109359 r109362 1 2012-03-01 Abhishek Arya <inferno@chromium.org> 2 3 Protect functions using two container node function, each of which can fire mutation events. 4 https://bugs.webkit.org/show_bug.cgi?id=78397 5 6 Reviewed by Ryosuke Niwa. 7 8 * fast/dom/document-set-title-mutation-crash-expected.txt: Added. 9 * fast/dom/document-set-title-mutation-crash.html: Added. 10 * fast/dom/option-text-mutation-crash-expected.txt: Added. 11 * fast/dom/option-text-mutation-crash.html: Added. 12 1 13 2012-03-01 Shinya Kawanaka <shinyak@chromium.org> 2 14 -
trunk/Source/WebCore/ChangeLog
r109360 r109362 1 2012-03-01 Abhishek Arya <inferno@chromium.org> 2 3 Protect functions using two container node function, each of which can fire mutation events. 4 https://bugs.webkit.org/show_bug.cgi?id=78397 5 6 Reviewed by Ryosuke Niwa. 7 8 Tests: fast/dom/document-set-title-mutation-crash.html 9 fast/dom/option-text-mutation-crash.html 10 11 * dom/Node.cpp: 12 (WebCore::Node::setTextContent): 13 * dom/Text.cpp: 14 (WebCore::Text::replaceWholeText): 15 * editing/markup.cpp: 16 (WebCore::trimFragment): 17 (WebCore::replaceChildrenWithFragment): 18 (WebCore::replaceChildrenWithText): 19 * html/HTMLOptionElement.cpp: 20 (WebCore::HTMLOptionElement::setText): 21 * html/HTMLScriptElement.cpp: 22 (WebCore::HTMLScriptElement::setText): 23 * html/HTMLTableElement.cpp: 24 (WebCore::HTMLTableElement::insertRow): 25 * html/HTMLTextAreaElement.cpp: 26 (WebCore::HTMLTextAreaElement::setDefaultValue): 27 * html/HTMLTitleElement.cpp: 28 (WebCore::HTMLTitleElement::setText): 29 1 30 2012-03-01 Alexey Proskuryakov <ap@apple.com> 2 31 -
trunk/Source/WebCore/dom/Node.cpp
r109097 r109362 2060 2060 case ENTITY_REFERENCE_NODE: 2061 2061 case DOCUMENT_FRAGMENT_NODE: { 2062 ContainerNode*container = toContainerNode(this);2062 RefPtr<ContainerNode> container = toContainerNode(this); 2063 2063 #if ENABLE(MUTATION_OBSERVERS) 2064 2064 ChildListMutationScope mutation(this); -
trunk/Source/WebCore/dom/Text.cpp
r99128 r109362 148 148 149 149 RefPtr<Text> protectedThis(this); // Mutation event handlers could cause our last ref to go away 150 ContainerNode*parent = parentNode(); // Protect against mutation handlers moving this node during traversal150 RefPtr<ContainerNode> parent = parentNode(); // Protect against mutation handlers moving this node during traversal 151 151 ExceptionCode ignored = 0; 152 152 for (RefPtr<Node> n = startText; n && n != this && n->isTextNode() && n->parentNode() == parent;) { -
trunk/Source/WebCore/editing/markup.cpp
r109251 r109362 694 694 { 695 695 ExceptionCode ec = 0; 696 Node*next;696 RefPtr<Node> next; 697 697 for (RefPtr<Node> node = fragment->firstChild(); node; node = next) { 698 698 if (nodeBeforeContext->isDescendantOf(node.get())) { … … 708 708 709 709 ASSERT(nodeAfterContext->parentNode()); 710 for ( Node*node = nodeAfterContext; node; node = next) {710 for (RefPtr<Node> node = nodeAfterContext; node; node = next) { 711 711 next = node->traverseNextSibling(); 712 node->parentNode()->removeChild(node , ec);712 node->parentNode()->removeChild(node.get(), ec); 713 713 ASSERT(!ec); 714 714 } … … 1022 1022 } 1023 1023 1024 void replaceChildrenWithFragment(ContainerNode* containerNode, PassRefPtr<DocumentFragment> fragment, ExceptionCode& ec) 1025 { 1024 void replaceChildrenWithFragment(ContainerNode* container, PassRefPtr<DocumentFragment> fragment, ExceptionCode& ec) 1025 { 1026 RefPtr<ContainerNode> containerNode(container); 1027 1026 1028 #if ENABLE(MUTATION_OBSERVERS) 1027 ChildListMutationScope mutation(containerNode );1029 ChildListMutationScope mutation(containerNode.get()); 1028 1030 #endif 1029 1031 … … 1033 1035 } 1034 1036 1035 if (hasOneTextChild(containerNode ) && hasOneTextChild(fragment.get())) {1037 if (hasOneTextChild(containerNode.get()) && hasOneTextChild(fragment.get())) { 1036 1038 toText(containerNode->firstChild())->setData(toText(fragment->firstChild())->data(), ec); 1037 1039 return; 1038 1040 } 1039 1041 1040 if (hasOneChild(containerNode )) {1042 if (hasOneChild(containerNode.get())) { 1041 1043 containerNode->replaceChild(fragment, containerNode->firstChild(), ec); 1042 1044 return; … … 1047 1049 } 1048 1050 1049 void replaceChildrenWithText(ContainerNode* containerNode, const String& text, ExceptionCode& ec) 1050 { 1051 void replaceChildrenWithText(ContainerNode* container, const String& text, ExceptionCode& ec) 1052 { 1053 RefPtr<ContainerNode> containerNode(container); 1054 1051 1055 #if ENABLE(MUTATION_OBSERVERS) 1052 ChildListMutationScope mutation(containerNode );1056 ChildListMutationScope mutation(containerNode.get()); 1053 1057 #endif 1054 1058 1055 if (hasOneTextChild(containerNode )) {1059 if (hasOneTextChild(containerNode.get())) { 1056 1060 toText(containerNode->firstChild())->setData(text, ec); 1057 1061 return; … … 1060 1064 RefPtr<Text> textNode = Text::create(containerNode->document(), text); 1061 1065 1062 if (hasOneChild(containerNode )) {1066 if (hasOneChild(containerNode.get())) { 1063 1067 containerNode->replaceChild(textNode.release(), containerNode->firstChild(), ec); 1064 1068 return; -
trunk/Source/WebCore/html/HTMLOptionElement.cpp
r107509 r109362 138 138 void HTMLOptionElement::setText(const String &text, ExceptionCode& ec) 139 139 { 140 RefPtr<Node> protectFromMutationEvents(this); 141 140 142 // Changing the text causes a recalc of a select's items, which will reset the selected 141 143 // index to the first item if the select is single selection with a menu list. We attempt to 142 144 // preserve the selected item. 143 HTMLSelectElement*select = ownerSelectElement();145 RefPtr<HTMLSelectElement> select = ownerSelectElement(); 144 146 bool selectIsMenuList = select && select->usesMenuList(); 145 147 int oldSelectedIndex = selectIsMenuList ? select->selectedIndex() : -1; -
trunk/Source/WebCore/html/HTMLScriptElement.cpp
r108165 r109362 83 83 void HTMLScriptElement::setText(const String &value) 84 84 { 85 RefPtr<Node> protectFromMutationEvents(this); 86 85 87 ExceptionCode ec = 0; 86 88 int numChildren = childNodeCount(); -
trunk/Source/WebCore/html/HTMLTableElement.cpp
r109149 r109362 188 188 } 189 189 190 HTMLTableRowElement* lastRow = 0; 191 HTMLTableRowElement* row = 0; 190 RefPtr<Node> protectFromMutationEvents(this); 191 192 RefPtr<HTMLTableRowElement> lastRow = 0; 193 RefPtr<HTMLTableRowElement> row = 0; 192 194 if (index == -1) 193 195 lastRow = HTMLTableRowsCollection::lastRow(this); 194 196 else { 195 197 for (int i = 0; i <= index; ++i) { 196 row = HTMLTableRowsCollection::rowAfter(this, lastRow );198 row = HTMLTableRowsCollection::rowAfter(this, lastRow.get()); 197 199 if (!row) { 198 200 if (i != index) { … … 206 208 } 207 209 208 ContainerNode*parent;210 RefPtr<ContainerNode> parent; 209 211 if (lastRow) 210 212 parent = row ? row->parentNode() : lastRow->parentNode(); … … 221 223 222 224 RefPtr<HTMLTableRowElement> newRow = HTMLTableRowElement::create(document()); 223 parent->insertBefore(newRow, row , ec);225 parent->insertBefore(newRow, row.get(), ec); 224 226 return newRow.release(); 225 227 } -
trunk/Source/WebCore/html/HTMLTextAreaElement.cpp
r109149 r109362 385 385 void HTMLTextAreaElement::setDefaultValue(const String& defaultValue) 386 386 { 387 RefPtr<Node> protectFromMutationEvents(this); 388 387 389 // To preserve comments, remove only the text nodes, then add a single text node. 388 389 390 Vector<RefPtr<Node> > textNodes; 390 391 for (Node* n = firstChild(); n; n = n->nextSibling()) { -
trunk/Source/WebCore/html/HTMLTitleElement.cpp
r107509 r109362 89 89 void HTMLTitleElement::setText(const String &value) 90 90 { 91 RefPtr<Node> protectFromMutationEvents(this); 92 91 93 ExceptionCode ec = 0; 92 94 int numChildren = childNodeCount(); … … 94 96 if (numChildren == 1 && firstChild()->isTextNode()) 95 97 toText(firstChild())->setData(value, ec); 96 else { 98 else { 97 99 // We make a copy here because entity of "value" argument can be Document::m_title, 98 100 // which goes empty during removeChildren() invocation below,
Note:
See TracChangeset
for help on using the changeset viewer.