| OLD | NEW |
| 1 /* | 1 /* |
| 2 * (C) 1999 Lars Knoll (knoll@kde.org) | 2 * (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2000 Gunnstein Lye (gunnstein@netcom.no) | 3 * (C) 2000 Gunnstein Lye (gunnstein@netcom.no) |
| 4 * (C) 2000 Frederik Holljen (frederik.holljen@hig.no) | 4 * (C) 2000 Frederik Holljen (frederik.holljen@hig.no) |
| 5 * (C) 2001 Peter Kelly (pmk@post.com) | 5 * (C) 2001 Peter Kelly (pmk@post.com) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All |
| 7 * rights reserved. | 7 * rights reserved. |
| 8 * Copyright (C) 2011 Motorola Mobility. All rights reserved. | 8 * Copyright (C) 2011 Motorola Mobility. All rights reserved. |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| (...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 | 583 |
| 584 // Now add leftContents, stuff in between, and rightContents to the fragment | 584 // Now add leftContents, stuff in between, and rightContents to the fragment |
| 585 // (or just delete the stuff in between) | 585 // (or just delete the stuff in between) |
| 586 | 586 |
| 587 if ((action == EXTRACT_CONTENTS || action == CLONE_CONTENTS) && leftContents) | 587 if ((action == EXTRACT_CONTENTS || action == CLONE_CONTENTS) && leftContents) |
| 588 fragment->appendChild(leftContents, exceptionState); | 588 fragment->appendChild(leftContents, exceptionState); |
| 589 | 589 |
| 590 if (processStart) { | 590 if (processStart) { |
| 591 NodeVector nodes; | 591 NodeVector nodes; |
| 592 for (Node* n = processStart; n && n != processEnd; n = n->nextSibling()) | 592 for (Node* n = processStart; n && n != processEnd; n = n->nextSibling()) |
| 593 nodes.append(n); | 593 nodes.push_back(n); |
| 594 processNodes(action, nodes, commonRoot, fragment, exceptionState); | 594 processNodes(action, nodes, commonRoot, fragment, exceptionState); |
| 595 } | 595 } |
| 596 | 596 |
| 597 if ((action == EXTRACT_CONTENTS || action == CLONE_CONTENTS) && rightContents) | 597 if ((action == EXTRACT_CONTENTS || action == CLONE_CONTENTS) && rightContents) |
| 598 fragment->appendChild(rightContents, exceptionState); | 598 fragment->appendChild(rightContents, exceptionState); |
| 599 | 599 |
| 600 return fragment; | 600 return fragment; |
| 601 } | 601 } |
| 602 | 602 |
| 603 static inline void deleteCharacterData(CharacterData* data, | 603 static inline void deleteCharacterData(CharacterData* data, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 else | 655 else |
| 656 result = container->cloneNode(false); | 656 result = container->cloneNode(false); |
| 657 } | 657 } |
| 658 | 658 |
| 659 Node* n = container->firstChild(); | 659 Node* n = container->firstChild(); |
| 660 HeapVector<Member<Node>> nodes; | 660 HeapVector<Member<Node>> nodes; |
| 661 for (unsigned i = startOffset; n && i; i--) | 661 for (unsigned i = startOffset; n && i; i--) |
| 662 n = n->nextSibling(); | 662 n = n->nextSibling(); |
| 663 for (unsigned i = startOffset; n && i < endOffset; | 663 for (unsigned i = startOffset; n && i < endOffset; |
| 664 i++, n = n->nextSibling()) | 664 i++, n = n->nextSibling()) |
| 665 nodes.append(n); | 665 nodes.push_back(n); |
| 666 | 666 |
| 667 processNodes(action, nodes, container, result, exceptionState); | 667 processNodes(action, nodes, container, result, exceptionState); |
| 668 break; | 668 break; |
| 669 } | 669 } |
| 670 | 670 |
| 671 return result; | 671 return result; |
| 672 } | 672 } |
| 673 | 673 |
| 674 void Range::processNodes(ActionType action, | 674 void Range::processNodes(ActionType action, |
| 675 HeapVector<Member<Node>>& nodes, | 675 HeapVector<Member<Node>>& nodes, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 698 ContentsProcessDirection direction, | 698 ContentsProcessDirection direction, |
| 699 Node* clonedContainer, | 699 Node* clonedContainer, |
| 700 Node* commonRoot, | 700 Node* commonRoot, |
| 701 ExceptionState& exceptionState) { | 701 ExceptionState& exceptionState) { |
| 702 typedef HeapVector<Member<Node>> NodeVector; | 702 typedef HeapVector<Member<Node>> NodeVector; |
| 703 | 703 |
| 704 NodeVector ancestors; | 704 NodeVector ancestors; |
| 705 for (Node& runner : NodeTraversal::ancestorsOf(*container)) { | 705 for (Node& runner : NodeTraversal::ancestorsOf(*container)) { |
| 706 if (runner == commonRoot) | 706 if (runner == commonRoot) |
| 707 break; | 707 break; |
| 708 ancestors.append(runner); | 708 ancestors.push_back(runner); |
| 709 } | 709 } |
| 710 | 710 |
| 711 Node* firstChildInAncestorToProcess = direction == ProcessContentsForward | 711 Node* firstChildInAncestorToProcess = direction == ProcessContentsForward |
| 712 ? container->nextSibling() | 712 ? container->nextSibling() |
| 713 : container->previousSibling(); | 713 : container->previousSibling(); |
| 714 for (const auto& ancestor : ancestors) { | 714 for (const auto& ancestor : ancestors) { |
| 715 if (action == EXTRACT_CONTENTS || action == CLONE_CONTENTS) { | 715 if (action == EXTRACT_CONTENTS || action == CLONE_CONTENTS) { |
| 716 // Might have been removed already during mutation event. | 716 // Might have been removed already during mutation event. |
| 717 if (Node* clonedAncestor = ancestor->cloneNode(false)) { | 717 if (Node* clonedAncestor = ancestor->cloneNode(false)) { |
| 718 clonedAncestor->appendChild(clonedContainer, exceptionState); | 718 clonedAncestor->appendChild(clonedContainer, exceptionState); |
| 719 clonedContainer = clonedAncestor; | 719 clonedContainer = clonedAncestor; |
| 720 } | 720 } |
| 721 } | 721 } |
| 722 | 722 |
| 723 // Copy siblings of an ancestor of start/end containers | 723 // Copy siblings of an ancestor of start/end containers |
| 724 // FIXME: This assertion may fail if DOM is modified during mutation event | 724 // FIXME: This assertion may fail if DOM is modified during mutation event |
| 725 // FIXME: Share code with Range::processNodes | 725 // FIXME: Share code with Range::processNodes |
| 726 DCHECK(!firstChildInAncestorToProcess || | 726 DCHECK(!firstChildInAncestorToProcess || |
| 727 firstChildInAncestorToProcess->parentNode() == ancestor); | 727 firstChildInAncestorToProcess->parentNode() == ancestor); |
| 728 | 728 |
| 729 NodeVector nodes; | 729 NodeVector nodes; |
| 730 for (Node* child = firstChildInAncestorToProcess; child; | 730 for (Node* child = firstChildInAncestorToProcess; child; |
| 731 child = (direction == ProcessContentsForward) | 731 child = (direction == ProcessContentsForward) |
| 732 ? child->nextSibling() | 732 ? child->nextSibling() |
| 733 : child->previousSibling()) | 733 : child->previousSibling()) |
| 734 nodes.append(child); | 734 nodes.push_back(child); |
| 735 | 735 |
| 736 for (const auto& node : nodes) { | 736 for (const auto& node : nodes) { |
| 737 Node* child = node.get(); | 737 Node* child = node.get(); |
| 738 switch (action) { | 738 switch (action) { |
| 739 case DELETE_CONTENTS: | 739 case DELETE_CONTENTS: |
| 740 // Prior call of ancestor->removeChild() may cause a tree change due | 740 // Prior call of ancestor->removeChild() may cause a tree change due |
| 741 // to DOMSubtreeModified event. Therefore, we need to make sure | 741 // to DOMSubtreeModified event. Therefore, we need to make sure |
| 742 // |ancestor| is still |child|'s parent. | 742 // |ancestor| is still |child|'s parent. |
| 743 if (ancestor == child->parentNode()) | 743 if (ancestor == child->parentNode()) |
| 744 ancestor->removeChild(child, exceptionState); | 744 ancestor->removeChild(child, exceptionState); |
| (...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1712 .data() | 1712 .data() |
| 1713 << "start offset: " << range->startOffset() | 1713 << "start offset: " << range->startOffset() |
| 1714 << ", end offset: " << range->endOffset(); | 1714 << ", end offset: " << range->endOffset(); |
| 1715 } else { | 1715 } else { |
| 1716 LOG(INFO) << "Cannot show tree if range is null, or if boundary points are " | 1716 LOG(INFO) << "Cannot show tree if range is null, or if boundary points are " |
| 1717 "invalid."; | 1717 "invalid."; |
| 1718 } | 1718 } |
| 1719 } | 1719 } |
| 1720 | 1720 |
| 1721 #endif | 1721 #endif |
| OLD | NEW |