| 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 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 // include the inserted nodes. | 910 // include the inserted nodes. |
| 911 Node* firstChild = (newNodeType == Node::kDocumentFragmentNode) | 911 Node* firstChild = (newNodeType == Node::kDocumentFragmentNode) |
| 912 ? toDocumentFragment(newNode)->firstChild() | 912 ? toDocumentFragment(newNode)->firstChild() |
| 913 : newNode; | 913 : newNode; |
| 914 DCHECK(firstChild); | 914 DCHECK(firstChild); |
| 915 m_start.setToBeforeChild(*firstChild); | 915 m_start.setToBeforeChild(*firstChild); |
| 916 return; | 916 return; |
| 917 } | 917 } |
| 918 | 918 |
| 919 container = m_start.container(); | 919 container = m_start.container(); |
| 920 container->insertBefore( | 920 Node* referenceNode = NodeTraversal::childAt(*container, m_start.offset()); |
| 921 newNode, NodeTraversal::childAt(*container, m_start.offset()), | 921 // TODO(tkent): The following check must be unnecessary if we follow the |
| 922 exceptionState); | 922 // algorithm defined in the specification. |
| 923 if (exceptionState.hadException()) | 923 // https://dom.spec.whatwg.org/#concept-range-insert |
| 924 return; | 924 if (newNode != referenceNode) { |
| 925 container->insertBefore(newNode, referenceNode, exceptionState); |
| 926 if (exceptionState.hadException()) |
| 927 return; |
| 928 } |
| 925 | 929 |
| 926 // Note that m_start.offset() may have changed as a result of | 930 // Note that m_start.offset() may have changed as a result of |
| 927 // container->insertBefore, when the node we are inserting comes before the | 931 // container->insertBefore, when the node we are inserting comes before the |
| 928 // range in the same container. | 932 // range in the same container. |
| 929 if (collapsed && numNewChildren) | 933 if (collapsed && numNewChildren) |
| 930 m_end.set(m_start.container(), m_start.offset() + numNewChildren, | 934 m_end.set(m_start.container(), m_start.offset() + numNewChildren, |
| 931 lastChild); | 935 lastChild); |
| 932 } | 936 } |
| 933 } | 937 } |
| 934 | 938 |
| (...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1716 .data() | 1720 .data() |
| 1717 << "start offset: " << range->startOffset() | 1721 << "start offset: " << range->startOffset() |
| 1718 << ", end offset: " << range->endOffset(); | 1722 << ", end offset: " << range->endOffset(); |
| 1719 } else { | 1723 } else { |
| 1720 LOG(INFO) << "Cannot show tree if range is null, or if boundary points are " | 1724 LOG(INFO) << "Cannot show tree if range is null, or if boundary points are " |
| 1721 "invalid."; | 1725 "invalid."; |
| 1722 } | 1726 } |
| 1723 } | 1727 } |
| 1724 | 1728 |
| 1725 #endif | 1729 #endif |
| OLD | NEW |