| 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 r
ights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. |
| 7 * Copyright (C) 2011 Motorola Mobility. All rights reserved. | 7 * Copyright (C) 2011 Motorola Mobility. All rights reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 887 container = m_start.container(); | 887 container = m_start.container(); |
| 888 RefPtrWillBeRawPtr<Text> newText = toText(container)->splitText(m_start.
offset(), exceptionState); | 888 RefPtrWillBeRawPtr<Text> newText = toText(container)->splitText(m_start.
offset(), exceptionState); |
| 889 if (exceptionState.hadException()) | 889 if (exceptionState.hadException()) |
| 890 return; | 890 return; |
| 891 | 891 |
| 892 container = m_start.container(); | 892 container = m_start.container(); |
| 893 container->parentNode()->insertBefore(newNode.release(), newText.get(),
exceptionState); | 893 container->parentNode()->insertBefore(newNode.release(), newText.get(),
exceptionState); |
| 894 if (exceptionState.hadException()) | 894 if (exceptionState.hadException()) |
| 895 return; | 895 return; |
| 896 | 896 |
| 897 if (collapsed) | 897 if (collapsed) { |
| 898 // The load event would be fired regardless of EventQueueScope; |
| 899 // e.g. by ContainerNode::updateTreeAfterInsertion |
| 900 // Given circumstance may mutate the tree so newText->parentNode() m
ay become null |
| 901 if (!newText->parentNode()) { |
| 902 exceptionState.throwDOMException(HierarchyRequestError, "This op
eration would set range's end to parent with new offset, but there's no parent i
nto which to continue."); |
| 903 return; |
| 904 } |
| 898 m_end.setToBeforeChild(*newText); | 905 m_end.setToBeforeChild(*newText); |
| 906 } |
| 899 } else { | 907 } else { |
| 900 RefPtrWillBeRawPtr<Node> lastChild = (newNodeType == Node::DOCUMENT_FRAG
MENT_NODE) ? toDocumentFragment(newNode)->lastChild() : newNode.get(); | 908 RefPtrWillBeRawPtr<Node> lastChild = (newNodeType == Node::DOCUMENT_FRAG
MENT_NODE) ? toDocumentFragment(newNode)->lastChild() : newNode.get(); |
| 901 if (lastChild && lastChild == m_start.childBefore()) { | 909 if (lastChild && lastChild == m_start.childBefore()) { |
| 902 // The insertion will do nothing, but we need to extend the range to
include | 910 // The insertion will do nothing, but we need to extend the range to
include |
| 903 // the inserted nodes. | 911 // the inserted nodes. |
| 904 Node* firstChild = (newNodeType == Node::DOCUMENT_FRAGMENT_NODE) ? t
oDocumentFragment(newNode)->firstChild() : newNode.get(); | 912 Node* firstChild = (newNodeType == Node::DOCUMENT_FRAGMENT_NODE) ? t
oDocumentFragment(newNode)->firstChild() : newNode.get(); |
| 905 ASSERT(firstChild); | 913 ASSERT(firstChild); |
| 906 m_start.setToBeforeChild(*firstChild); | 914 m_start.setToBeforeChild(*firstChild); |
| 907 return; | 915 return; |
| 908 } | 916 } |
| (...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1702 | 1710 |
| 1703 void showTree(const blink::Range* range) | 1711 void showTree(const blink::Range* range) |
| 1704 { | 1712 { |
| 1705 if (range && range->boundaryPointsValid()) { | 1713 if (range && range->boundaryPointsValid()) { |
| 1706 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); | 1714 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); |
| 1707 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); | 1715 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); |
| 1708 } | 1716 } |
| 1709 } | 1717 } |
| 1710 | 1718 |
| 1711 #endif | 1719 #endif |
| OLD | NEW |