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

Side by Side Diff: WebCore/editing/InsertLineBreakCommand.cpp

Issue 3027024: Merge 63773 - 2010-07-20 Abhishek Arya <inferno@chromium.org>... (Closed) Base URL: svn://chrome-svn/chrome/branches/WebKit/472/
Patch Set: Created 10 years, 4 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
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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 // Insert an extra br or '\n' if the just inserted one collapsed. 129 // Insert an extra br or '\n' if the just inserted one collapsed.
130 if (!isStartOfParagraph(VisiblePosition(Position(nodeToInsert.get(), 0)) )) 130 if (!isStartOfParagraph(VisiblePosition(Position(nodeToInsert.get(), 0)) ))
131 insertNodeBefore(nodeToInsert->cloneNode(false).get(), nodeToInsert. get()); 131 insertNodeBefore(nodeToInsert->cloneNode(false).get(), nodeToInsert. get());
132 132
133 setEndingSelection(VisibleSelection(positionInParentAfterNode(nodeToInse rt.get()), DOWNSTREAM)); 133 setEndingSelection(VisibleSelection(positionInParentAfterNode(nodeToInse rt.get()), DOWNSTREAM));
134 // If we're inserting after all of the rendered text in a text node, or into a non-text node, 134 // If we're inserting after all of the rendered text in a text node, or into a non-text node,
135 // a simple insertion is sufficient. 135 // a simple insertion is sufficient.
136 } else if (pos.deprecatedEditingOffset() >= caretMaxOffset(pos.node()) || !p os.node()->isTextNode()) { 136 } else if (pos.deprecatedEditingOffset() >= caretMaxOffset(pos.node()) || !p os.node()->isTextNode()) {
137 insertNodeAt(nodeToInsert.get(), pos); 137 insertNodeAt(nodeToInsert.get(), pos);
138 setEndingSelection(VisibleSelection(positionInParentAfterNode(nodeToInse rt.get()), DOWNSTREAM)); 138 setEndingSelection(VisibleSelection(positionInParentAfterNode(nodeToInse rt.get()), DOWNSTREAM));
139 } else { 139 } else if (pos.node()->isTextNode()) {
140 // Split a text node 140 // Split a text node
141 ASSERT(pos.node()->isTextNode());
142
143 // Do the split
144 Text* textNode = static_cast<Text*>(pos.node()); 141 Text* textNode = static_cast<Text*>(pos.node());
145 splitTextNode(textNode, pos.deprecatedEditingOffset()); 142 splitTextNode(textNode, pos.deprecatedEditingOffset());
146 insertNodeBefore(nodeToInsert, textNode); 143 insertNodeBefore(nodeToInsert, textNode);
147 Position endingPosition = Position(textNode, 0); 144 Position endingPosition = Position(textNode, 0);
148 145
149 // Handle whitespace that occurs after the split 146 // Handle whitespace that occurs after the split
150 updateLayout(); 147 updateLayout();
151 if (!endingPosition.isRenderedCharacter()) { 148 if (!endingPosition.isRenderedCharacter()) {
152 Position positionBeforeTextNode(positionInParentBeforeNode(textNode) ); 149 Position positionBeforeTextNode(positionInParentBeforeNode(textNode) );
153 // Clear out all whitespace and insert one non-breaking space 150 // Clear out all whitespace and insert one non-breaking space
(...skipping 28 matching lines...) Expand all
182 // before the line break (if the line break is at the end of a block it isn't selectable). 179 // before the line break (if the line break is at the end of a block it isn't selectable).
183 // So, this next call sets the endingSelection() to a caret just after t he line break 180 // So, this next call sets the endingSelection() to a caret just after t he line break
184 // that we inserted, or just before it if it's at the end of a block. 181 // that we inserted, or just before it if it's at the end of a block.
185 setEndingSelection(endingSelection().visibleEnd()); 182 setEndingSelection(endingSelection().visibleEnd());
186 } 183 }
187 184
188 rebalanceWhitespace(); 185 rebalanceWhitespace();
189 } 186 }
190 187
191 } 188 }
OLDNEW
« no previous file with comments | « WebCore/editing/DeleteSelectionCommand.cpp ('k') | WebCore/editing/InsertParagraphSeparatorCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698