| OLD | NEW |
| 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 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights
reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights
reserved. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 // In either of those cases, we'll just stop. | 224 // In either of those cases, we'll just stop. |
| 225 if (next->parentNode() != this) | 225 if (next->parentNode() != this) |
| 226 break; | 226 break; |
| 227 if (child.parentNode()) | 227 if (child.parentNode()) |
| 228 break; | 228 break; |
| 229 | 229 |
| 230 { | 230 { |
| 231 EventDispatchForbiddenScope assertNoEventDispatch; | 231 EventDispatchForbiddenScope assertNoEventDispatch; |
| 232 ScriptForbiddenScope forbidScript; | 232 ScriptForbiddenScope forbidScript; |
| 233 | 233 |
| 234 treeScope().adoptIfNeeded(child); | 234 treeScopeOrDocument().adoptIfNeeded(child); |
| 235 insertBeforeCommon(*next, child); | 235 insertBeforeCommon(*next, child); |
| 236 } | 236 } |
| 237 | 237 |
| 238 updateTreeAfterInsertion(child); | 238 updateTreeAfterInsertion(child); |
| 239 } | 239 } |
| 240 | 240 |
| 241 dispatchSubtreeModifiedEvent(); | 241 dispatchSubtreeModifiedEvent(); |
| 242 | 242 |
| 243 return newChild; | 243 return newChild; |
| 244 } | 244 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 if (nextChild.parentNode() != this) | 314 if (nextChild.parentNode() != this) |
| 315 return; | 315 return; |
| 316 | 316 |
| 317 if (document() != newChild->document()) | 317 if (document() != newChild->document()) |
| 318 document().adoptNode(newChild, ASSERT_NO_EXCEPTION); | 318 document().adoptNode(newChild, ASSERT_NO_EXCEPTION); |
| 319 | 319 |
| 320 { | 320 { |
| 321 EventDispatchForbiddenScope assertNoEventDispatch; | 321 EventDispatchForbiddenScope assertNoEventDispatch; |
| 322 ScriptForbiddenScope forbidScript; | 322 ScriptForbiddenScope forbidScript; |
| 323 | 323 |
| 324 treeScope().adoptIfNeeded(*newChild); | 324 treeScopeOrDocument().adoptIfNeeded(*newChild); |
| 325 insertBeforeCommon(nextChild, *newChild); | 325 insertBeforeCommon(nextChild, *newChild); |
| 326 DCHECK_EQ(newChild->connectedSubframeCount(), 0u); | 326 DCHECK_EQ(newChild->connectedSubframeCount(), 0u); |
| 327 ChildListMutationScope(*this).childAdded(*newChild); | 327 ChildListMutationScope(*this).childAdded(*newChild); |
| 328 } | 328 } |
| 329 | 329 |
| 330 notifyNodeInserted(*newChild, ChildrenChangeSourceParser); | 330 notifyNodeInserted(*newChild, ChildrenChangeSourceParser); |
| 331 } | 331 } |
| 332 | 332 |
| 333 Node* ContainerNode::replaceChild(Node* newChild, Node* oldChild, ExceptionState
& exceptionState) | 333 Node* ContainerNode::replaceChild(Node* newChild, Node* oldChild, ExceptionState
& exceptionState) |
| 334 { | 334 { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 | 401 |
| 402 // Due to arbitrary code running in response to a DOM mutation event it'
s | 402 // Due to arbitrary code running in response to a DOM mutation event it'
s |
| 403 // possible that "next" is no longer a child of "this". | 403 // possible that "next" is no longer a child of "this". |
| 404 // It's also possible that "child" has been inserted elsewhere. | 404 // It's also possible that "child" has been inserted elsewhere. |
| 405 // In either of those cases, we'll just stop. | 405 // In either of those cases, we'll just stop. |
| 406 if (next && next->parentNode() != this) | 406 if (next && next->parentNode() != this) |
| 407 break; | 407 break; |
| 408 if (child.parentNode()) | 408 if (child.parentNode()) |
| 409 break; | 409 break; |
| 410 | 410 |
| 411 treeScope().adoptIfNeeded(child); | 411 treeScopeOrDocument().adoptIfNeeded(child); |
| 412 | 412 |
| 413 // Add child before "next". | 413 // Add child before "next". |
| 414 { | 414 { |
| 415 EventDispatchForbiddenScope assertNoEventDispatch; | 415 EventDispatchForbiddenScope assertNoEventDispatch; |
| 416 if (next) | 416 if (next) |
| 417 insertBeforeCommon(*next, child); | 417 insertBeforeCommon(*next, child); |
| 418 else | 418 else |
| 419 appendChildCommon(child); | 419 appendChildCommon(child); |
| 420 } | 420 } |
| 421 | 421 |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 // If the child has a parent again, just stop what we're doing, because | 750 // If the child has a parent again, just stop what we're doing, because |
| 751 // that means someone is doing something with DOM mutation -- can't re-p
arent | 751 // that means someone is doing something with DOM mutation -- can't re-p
arent |
| 752 // a child that already has a parent. | 752 // a child that already has a parent. |
| 753 if (child.parentNode()) | 753 if (child.parentNode()) |
| 754 break; | 754 break; |
| 755 | 755 |
| 756 { | 756 { |
| 757 EventDispatchForbiddenScope assertNoEventDispatch; | 757 EventDispatchForbiddenScope assertNoEventDispatch; |
| 758 ScriptForbiddenScope forbidScript; | 758 ScriptForbiddenScope forbidScript; |
| 759 | 759 |
| 760 treeScope().adoptIfNeeded(child); | 760 treeScopeOrDocument().adoptIfNeeded(child); |
| 761 appendChildCommon(child); | 761 appendChildCommon(child); |
| 762 } | 762 } |
| 763 | 763 |
| 764 updateTreeAfterInsertion(child); | 764 updateTreeAfterInsertion(child); |
| 765 } | 765 } |
| 766 | 766 |
| 767 dispatchSubtreeModifiedEvent(); | 767 dispatchSubtreeModifiedEvent(); |
| 768 return newChild; | 768 return newChild; |
| 769 } | 769 } |
| 770 | 770 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 783 while (ContainerNode* parent = newChild->parentNode()) | 783 while (ContainerNode* parent = newChild->parentNode()) |
| 784 parent->parserRemoveChild(*newChild); | 784 parent->parserRemoveChild(*newChild); |
| 785 | 785 |
| 786 if (document() != newChild->document()) | 786 if (document() != newChild->document()) |
| 787 document().adoptNode(newChild, ASSERT_NO_EXCEPTION); | 787 document().adoptNode(newChild, ASSERT_NO_EXCEPTION); |
| 788 | 788 |
| 789 { | 789 { |
| 790 EventDispatchForbiddenScope assertNoEventDispatch; | 790 EventDispatchForbiddenScope assertNoEventDispatch; |
| 791 ScriptForbiddenScope forbidScript; | 791 ScriptForbiddenScope forbidScript; |
| 792 | 792 |
| 793 treeScope().adoptIfNeeded(*newChild); | 793 treeScopeOrDocument().adoptIfNeeded(*newChild); |
| 794 appendChildCommon(*newChild); | 794 appendChildCommon(*newChild); |
| 795 DCHECK_EQ(newChild->connectedSubframeCount(), 0u); | 795 DCHECK_EQ(newChild->connectedSubframeCount(), 0u); |
| 796 ChildListMutationScope(*this).childAdded(*newChild); | 796 ChildListMutationScope(*this).childAdded(*newChild); |
| 797 } | 797 } |
| 798 | 798 |
| 799 notifyNodeInserted(*newChild, ChildrenChangeSourceParser); | 799 notifyNodeInserted(*newChild, ChildrenChangeSourceParser); |
| 800 } | 800 } |
| 801 | 801 |
| 802 void ContainerNode::notifyNodeInserted(Node& root, ChildrenChangeSource source) | 802 void ContainerNode::notifyNodeInserted(Node& root, ChildrenChangeSource source) |
| 803 { | 803 { |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1459 DCHECK(isHTMLFormElement(this) || isHTMLFieldSetElement(this)); | 1459 DCHECK(isHTMLFormElement(this) || isHTMLFieldSetElement(this)); |
| 1460 CollectionType type = onlyMatchImgElements ? RadioImgNodeListType : RadioNod
eListType; | 1460 CollectionType type = onlyMatchImgElements ? RadioImgNodeListType : RadioNod
eListType; |
| 1461 return ensureCachedCollection<RadioNodeList>(type, name); | 1461 return ensureCachedCollection<RadioNodeList>(type, name); |
| 1462 } | 1462 } |
| 1463 | 1463 |
| 1464 Element* ContainerNode::getElementById(const AtomicString& id) const | 1464 Element* ContainerNode::getElementById(const AtomicString& id) const |
| 1465 { | 1465 { |
| 1466 if (isInTreeScope()) { | 1466 if (isInTreeScope()) { |
| 1467 // Fast path if we are in a tree scope: call getElementById() on tree sc
ope | 1467 // Fast path if we are in a tree scope: call getElementById() on tree sc
ope |
| 1468 // and check if the matching element is in our subtree. | 1468 // and check if the matching element is in our subtree. |
| 1469 Element* element = treeScope().getElementById(id); | 1469 Element* element = treeScopeOrDocument().getElementById(id); |
| 1470 if (!element) | 1470 if (!element) |
| 1471 return nullptr; | 1471 return nullptr; |
| 1472 if (element->isDescendantOf(this)) | 1472 if (element->isDescendantOf(this)) |
| 1473 return element; | 1473 return element; |
| 1474 } | 1474 } |
| 1475 | 1475 |
| 1476 // Fall back to traversing our subtree. In case of duplicate ids, the first
element found will be returned. | 1476 // Fall back to traversing our subtree. In case of duplicate ids, the first
element found will be returned. |
| 1477 for (Element& element : ElementTraversal::descendantsOf(*this)) { | 1477 for (Element& element : ElementTraversal::descendantsOf(*this)) { |
| 1478 if (element.getIdAttribute() == id) | 1478 if (element.getIdAttribute() == id) |
| 1479 return &element; | 1479 return &element; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1499 return true; | 1499 return true; |
| 1500 | 1500 |
| 1501 if (node->isElementNode() && toElement(node)->shadow()) | 1501 if (node->isElementNode() && toElement(node)->shadow()) |
| 1502 return true; | 1502 return true; |
| 1503 | 1503 |
| 1504 return false; | 1504 return false; |
| 1505 } | 1505 } |
| 1506 #endif | 1506 #endif |
| 1507 | 1507 |
| 1508 } // namespace blink | 1508 } // namespace blink |
| OLD | NEW |