Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Side by Side Diff: Source/WebCore/dom/Range.cpp

Issue 9948001: Merge 110487 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1025/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « LayoutTests/fast/text/split-text-crash-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 case Node::NOTATION_NODE: 1029 case Node::NOTATION_NODE:
1030 case Node::DOCUMENT_NODE: 1030 case Node::DOCUMENT_NODE:
1031 case Node::SHADOW_ROOT_NODE: 1031 case Node::SHADOW_ROOT_NODE:
1032 ec = RangeException::INVALID_NODE_TYPE_ERR; 1032 ec = RangeException::INVALID_NODE_TYPE_ERR;
1033 return; 1033 return;
1034 default: 1034 default:
1035 break; 1035 break;
1036 } 1036 }
1037 1037
1038 bool collapsed = m_start == m_end; 1038 bool collapsed = m_start == m_end;
1039 RefPtr<Node> container;
1039 if (startIsText) { 1040 if (startIsText) {
1040 RefPtr<Text> newText = static_cast<Text*>(m_start.container())->splitTex t(m_start.offset(), ec); 1041 container = m_start.container();
1042 RefPtr<Text> newText = static_cast<Text*>(container.get())->splitText(m_ start.offset(), ec);
1041 if (ec) 1043 if (ec)
1042 return; 1044 return;
1043 m_start.container()->parentNode()->insertBefore(newNode.release(), newTe xt.get(), ec); 1045
1046 container = m_start.container();
1047 container->parentNode()->insertBefore(newNode.release(), newText.get(), ec);
1044 if (ec) 1048 if (ec)
1045 return; 1049 return;
1046 1050
1047 // This special case doesn't seem to match the DOM specification, but it 's currently required 1051 // This special case doesn't seem to match the DOM specification, but it 's currently required
1048 // to pass Acid3. We might later decide to remove this. 1052 // to pass Acid3. We might later decide to remove this.
1049 if (collapsed) 1053 if (collapsed)
1050 m_end.setToBeforeChild(newText.get()); 1054 m_end.setToBeforeChild(newText.get());
1051 } else { 1055 } else {
1052 RefPtr<Node> lastChild; 1056 RefPtr<Node> lastChild;
1053 if (collapsed) 1057 if (collapsed)
1054 lastChild = (newNodeType == Node::DOCUMENT_FRAGMENT_NODE) ? newNode- >lastChild() : newNode; 1058 lastChild = (newNodeType == Node::DOCUMENT_FRAGMENT_NODE) ? newNode- >lastChild() : newNode;
1055 1059
1056 int startOffset = m_start.offset(); 1060 int startOffset = m_start.offset();
1057 m_start.container()->insertBefore(newNode.release(), m_start.container() ->childNode(startOffset), ec); 1061 container = m_start.container();
1062 container->insertBefore(newNode.release(), container->childNode(startOff set), ec);
1058 if (ec) 1063 if (ec)
1059 return; 1064 return;
1060 1065
1061 // This special case doesn't seem to match the DOM specification, but it 's currently required 1066 // This special case doesn't seem to match the DOM specification, but it 's currently required
1062 // to pass Acid3. We might later decide to remove this. 1067 // to pass Acid3. We might later decide to remove this.
1063 if (collapsed && numNewChildren) 1068 if (collapsed && numNewChildren)
1064 m_end.set(m_start.container(), startOffset + numNewChildren, lastChi ld.get()); 1069 m_end.set(m_start.container(), startOffset + numNewChildren, lastChi ld.get());
1065 } 1070 }
1066 } 1071 }
1067 1072
(...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after
2081 2086
2082 void showTree(const WebCore::Range* range) 2087 void showTree(const WebCore::Range* range)
2083 { 2088 {
2084 if (range && range->boundaryPointsValid()) { 2089 if (range && range->boundaryPointsValid()) {
2085 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r ange->endContainer(), "E"); 2090 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r ange->endContainer(), "E");
2086 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset (), range->endOffset()); 2091 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset (), range->endOffset());
2087 } 2092 }
2088 } 2093 }
2089 2094
2090 #endif 2095 #endif
OLDNEW
« no previous file with comments | « LayoutTests/fast/text/split-text-crash-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698