| 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 Apple Inc. All rights reserv
ed. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
| 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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 prev->setNextSibling(&newChild); | 264 prev->setNextSibling(&newChild); |
| 265 } else { | 265 } else { |
| 266 ASSERT(firstChild() == nextChild); | 266 ASSERT(firstChild() == nextChild); |
| 267 m_firstChild = &newChild; | 267 m_firstChild = &newChild; |
| 268 } | 268 } |
| 269 newChild.setParentOrShadowHostNode(this); | 269 newChild.setParentOrShadowHostNode(this); |
| 270 newChild.setPreviousSibling(prev); | 270 newChild.setPreviousSibling(prev); |
| 271 newChild.setNextSibling(&nextChild); | 271 newChild.setNextSibling(&nextChild); |
| 272 } | 272 } |
| 273 | 273 |
| 274 void ContainerNode::appendChildCommon(Node& child) |
| 275 { |
| 276 child.setParentOrShadowHostNode(this); |
| 277 |
| 278 if (m_lastChild) { |
| 279 child.setPreviousSibling(m_lastChild); |
| 280 m_lastChild->setNextSibling(&child); |
| 281 } else { |
| 282 setFirstChild(&child); |
| 283 } |
| 284 |
| 285 setLastChild(&child); |
| 286 } |
| 287 |
| 274 void ContainerNode::parserInsertBefore(PassRefPtrWillBeRawPtr<Node> newChild, No
de& nextChild) | 288 void ContainerNode::parserInsertBefore(PassRefPtrWillBeRawPtr<Node> newChild, No
de& nextChild) |
| 275 { | 289 { |
| 276 ASSERT(newChild); | 290 ASSERT(newChild); |
| 277 ASSERT(nextChild.parentNode() == this); | 291 ASSERT(nextChild.parentNode() == this); |
| 278 ASSERT(!newChild->isDocumentFragment()); | 292 ASSERT(!newChild->isDocumentFragment()); |
| 279 ASSERT(!isHTMLTemplateElement(this)); | 293 ASSERT(!isHTMLTemplateElement(this)); |
| 280 | 294 |
| 281 if (nextChild.previousSibling() == newChild || &nextChild == newChild) // no
thing to do | 295 if (nextChild.previousSibling() == newChild || &nextChild == newChild) // no
thing to do |
| 282 return; | 296 return; |
| 283 | 297 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 break; | 381 break; |
| 368 | 382 |
| 369 treeScope().adoptIfNeeded(child); | 383 treeScope().adoptIfNeeded(child); |
| 370 | 384 |
| 371 // Add child before "next". | 385 // Add child before "next". |
| 372 { | 386 { |
| 373 NoEventDispatchAssertion assertNoEventDispatch; | 387 NoEventDispatchAssertion assertNoEventDispatch; |
| 374 if (next) | 388 if (next) |
| 375 insertBeforeCommon(*next, child); | 389 insertBeforeCommon(*next, child); |
| 376 else | 390 else |
| 377 appendChildToContainer(child, *this); | 391 appendChildCommon(child); |
| 378 } | 392 } |
| 379 | 393 |
| 380 updateTreeAfterInsertion(child); | 394 updateTreeAfterInsertion(child); |
| 381 } | 395 } |
| 382 | 396 |
| 383 dispatchSubtreeModifiedEvent(); | 397 dispatchSubtreeModifiedEvent(); |
| 384 } | 398 } |
| 385 | 399 |
| 386 void ContainerNode::willRemoveChild(Node& child) | 400 void ContainerNode::willRemoveChild(Node& child) |
| 387 { | 401 { |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 // that means someone is doing something with DOM mutation -- can't re-p
arent | 629 // that means someone is doing something with DOM mutation -- can't re-p
arent |
| 616 // a child that already has a parent. | 630 // a child that already has a parent. |
| 617 if (child.parentNode()) | 631 if (child.parentNode()) |
| 618 break; | 632 break; |
| 619 | 633 |
| 620 { | 634 { |
| 621 NoEventDispatchAssertion assertNoEventDispatch; | 635 NoEventDispatchAssertion assertNoEventDispatch; |
| 622 ScriptForbiddenScope forbidScript; | 636 ScriptForbiddenScope forbidScript; |
| 623 | 637 |
| 624 treeScope().adoptIfNeeded(child); | 638 treeScope().adoptIfNeeded(child); |
| 625 appendChildToContainer(child, *this); | 639 appendChildCommon(child); |
| 626 } | 640 } |
| 627 | 641 |
| 628 updateTreeAfterInsertion(child); | 642 updateTreeAfterInsertion(child); |
| 629 } | 643 } |
| 630 | 644 |
| 631 dispatchSubtreeModifiedEvent(); | 645 dispatchSubtreeModifiedEvent(); |
| 632 } | 646 } |
| 633 | 647 |
| 634 void ContainerNode::parserAppendChild(PassRefPtrWillBeRawPtr<Node> newChild) | 648 void ContainerNode::parserAppendChild(PassRefPtrWillBeRawPtr<Node> newChild) |
| 635 { | 649 { |
| 636 ASSERT(newChild); | 650 ASSERT(newChild); |
| 637 ASSERT(!newChild->parentNode()); // Use appendChild if you need to handle re
parenting (and want DOM mutation events). | 651 ASSERT(!newChild->parentNode()); // Use appendChild if you need to handle re
parenting (and want DOM mutation events). |
| 638 ASSERT(!newChild->isDocumentFragment()); | 652 ASSERT(!newChild->isDocumentFragment()); |
| 639 ASSERT(!isHTMLTemplateElement(this)); | 653 ASSERT(!isHTMLTemplateElement(this)); |
| 640 | 654 |
| 641 if (document() != newChild->document()) | 655 if (document() != newChild->document()) |
| 642 document().adoptNode(newChild.get(), ASSERT_NO_EXCEPTION); | 656 document().adoptNode(newChild.get(), ASSERT_NO_EXCEPTION); |
| 643 | 657 |
| 644 Node* last = m_lastChild; | 658 Node* last = m_lastChild; |
| 645 | 659 |
| 646 { | 660 { |
| 647 NoEventDispatchAssertion assertNoEventDispatch; | 661 NoEventDispatchAssertion assertNoEventDispatch; |
| 648 ScriptForbiddenScope forbidScript; | 662 ScriptForbiddenScope forbidScript; |
| 649 | 663 |
| 650 treeScope().adoptIfNeeded(*newChild); | 664 treeScope().adoptIfNeeded(*newChild); |
| 651 // FIXME: This method should take a PassRefPtr. | 665 appendChildCommon(*newChild); |
| 652 appendChildToContainer(*newChild, *this); | |
| 653 newChild->updateAncestorConnectedSubframeCountForInsertion(); | 666 newChild->updateAncestorConnectedSubframeCountForInsertion(); |
| 654 ChildListMutationScope(*this).childAdded(*newChild); | 667 ChildListMutationScope(*this).childAdded(*newChild); |
| 655 } | 668 } |
| 656 | 669 |
| 657 childrenChanged(true, last, 0, 1); | 670 childrenChanged(true, last, 0, 1); |
| 658 notifyNodeInserted(*newChild); | 671 notifyNodeInserted(*newChild); |
| 659 } | 672 } |
| 660 | 673 |
| 661 void ContainerNode::notifyNodeInserted(Node& root) | 674 void ContainerNode::notifyNodeInserted(Node& root) |
| 662 { | 675 { |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1274 return true; | 1287 return true; |
| 1275 | 1288 |
| 1276 if (node->isElementNode() && toElement(node)->shadow()) | 1289 if (node->isElementNode() && toElement(node)->shadow()) |
| 1277 return true; | 1290 return true; |
| 1278 | 1291 |
| 1279 return false; | 1292 return false; |
| 1280 } | 1293 } |
| 1281 #endif | 1294 #endif |
| 1282 | 1295 |
| 1283 } // namespace WebCore | 1296 } // namespace WebCore |
| OLD | NEW |