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

Side by Side Diff: Source/core/editing/InsertLineBreakCommand.cpp

Issue 188033005: Have Position deal with more references (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/editing/IndentOutdentCommand.cpp ('k') | Source/core/editing/InsertListCommand.cpp » ('j') | 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 * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // FIXME: Need to merge text nodes when inserting just after or before text. 90 // FIXME: Need to merge text nodes when inserting just after or before text.
91 91
92 if (isEndOfParagraph(caret) && !lineBreakExistsAtVisiblePosition(caret)) { 92 if (isEndOfParagraph(caret) && !lineBreakExistsAtVisiblePosition(caret)) {
93 bool needExtraLineBreak = !pos.deprecatedNode()->hasTagName(hrTag) && !p os.deprecatedNode()->hasTagName(tableTag); 93 bool needExtraLineBreak = !pos.deprecatedNode()->hasTagName(hrTag) && !p os.deprecatedNode()->hasTagName(tableTag);
94 94
95 insertNodeAt(nodeToInsert.get(), pos); 95 insertNodeAt(nodeToInsert.get(), pos);
96 96
97 if (needExtraLineBreak) 97 if (needExtraLineBreak)
98 insertNodeBefore(nodeToInsert->cloneNode(false), nodeToInsert); 98 insertNodeBefore(nodeToInsert->cloneNode(false), nodeToInsert);
99 99
100 VisiblePosition endingPosition(positionBeforeNode(nodeToInsert.get())); 100 VisiblePosition endingPosition(positionBeforeNode(*nodeToInsert));
101 setEndingSelection(VisibleSelection(endingPosition, endingSelection().is Directional())); 101 setEndingSelection(VisibleSelection(endingPosition, endingSelection().is Directional()));
102 } else if (pos.deprecatedEditingOffset() <= caretMinOffset(pos.deprecatedNod e())) { 102 } else if (pos.deprecatedEditingOffset() <= caretMinOffset(pos.deprecatedNod e())) {
103 insertNodeAt(nodeToInsert.get(), pos); 103 insertNodeAt(nodeToInsert.get(), pos);
104 104
105 // Insert an extra br or '\n' if the just inserted one collapsed. 105 // Insert an extra br or '\n' if the just inserted one collapsed.
106 if (!isStartOfParagraph(VisiblePosition(positionBeforeNode(nodeToInsert. get())))) 106 if (!isStartOfParagraph(VisiblePosition(positionBeforeNode(*nodeToInsert ))))
107 insertNodeBefore(nodeToInsert->cloneNode(false).get(), nodeToInsert. get()); 107 insertNodeBefore(nodeToInsert->cloneNode(false).get(), nodeToInsert. get());
108 108
109 setEndingSelection(VisibleSelection(positionInParentAfterNode(*nodeToIns ert), DOWNSTREAM, endingSelection().isDirectional())); 109 setEndingSelection(VisibleSelection(positionInParentAfterNode(*nodeToIns ert), DOWNSTREAM, endingSelection().isDirectional()));
110 // If we're inserting after all of the rendered text in a text node, or into a non-text node, 110 // If we're inserting after all of the rendered text in a text node, or into a non-text node,
111 // a simple insertion is sufficient. 111 // a simple insertion is sufficient.
112 } else if (pos.deprecatedEditingOffset() >= caretMaxOffset(pos.deprecatedNod e()) || !pos.deprecatedNode()->isTextNode()) { 112 } else if (pos.deprecatedEditingOffset() >= caretMaxOffset(pos.deprecatedNod e()) || !pos.deprecatedNode()->isTextNode()) {
113 insertNodeAt(nodeToInsert.get(), pos); 113 insertNodeAt(nodeToInsert.get(), pos);
114 setEndingSelection(VisibleSelection(positionInParentAfterNode(*nodeToIns ert), DOWNSTREAM, endingSelection().isDirectional())); 114 setEndingSelection(VisibleSelection(positionInParentAfterNode(*nodeToIns ert), DOWNSTREAM, endingSelection().isDirectional()));
115 } else if (pos.deprecatedNode()->isTextNode()) { 115 } else if (pos.deprecatedNode()->isTextNode()) {
116 // Split a text node 116 // Split a text node
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 // before the line break (if the line break is at the end of a block it isn't selectable). 155 // before the line break (if the line break is at the end of a block it isn't selectable).
156 // So, this next call sets the endingSelection() to a caret just after t he line break 156 // So, this next call sets the endingSelection() to a caret just after t he line break
157 // that we inserted, or just before it if it's at the end of a block. 157 // that we inserted, or just before it if it's at the end of a block.
158 setEndingSelection(endingSelection().visibleEnd()); 158 setEndingSelection(endingSelection().visibleEnd());
159 } 159 }
160 160
161 rebalanceWhitespace(); 161 rebalanceWhitespace();
162 } 162 }
163 163
164 } 164 }
OLDNEW
« no previous file with comments | « Source/core/editing/IndentOutdentCommand.cpp ('k') | Source/core/editing/InsertListCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698