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

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

Issue 3092017: Merge 63773 - 2010-07-20 Abhishek Arya <inferno@chromium.org>... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/WebKit/375/
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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 // Insert an extra br or '\n' if the just inserted one collapsed. 124 // Insert an extra br or '\n' if the just inserted one collapsed.
125 if (!isStartOfParagraph(VisiblePosition(Position(nodeToInsert.get(), 0)) )) 125 if (!isStartOfParagraph(VisiblePosition(Position(nodeToInsert.get(), 0)) ))
126 insertNodeBefore(nodeToInsert->cloneNode(false).get(), nodeToInsert. get()); 126 insertNodeBefore(nodeToInsert->cloneNode(false).get(), nodeToInsert. get());
127 127
128 setEndingSelection(VisibleSelection(positionInParentAfterNode(nodeToInse rt.get()), DOWNSTREAM)); 128 setEndingSelection(VisibleSelection(positionInParentAfterNode(nodeToInse rt.get()), DOWNSTREAM));
129 // If we're inserting after all of the rendered text in a text node, or into a non-text node, 129 // If we're inserting after all of the rendered text in a text node, or into a non-text node,
130 // a simple insertion is sufficient. 130 // a simple insertion is sufficient.
131 } else if (pos.deprecatedEditingOffset() >= caretMaxOffset(pos.node()) || !p os.node()->isTextNode()) { 131 } else if (pos.deprecatedEditingOffset() >= caretMaxOffset(pos.node()) || !p os.node()->isTextNode()) {
132 insertNodeAt(nodeToInsert.get(), pos); 132 insertNodeAt(nodeToInsert.get(), pos);
133 setEndingSelection(VisibleSelection(positionInParentAfterNode(nodeToInse rt.get()), DOWNSTREAM)); 133 setEndingSelection(VisibleSelection(positionInParentAfterNode(nodeToInse rt.get()), DOWNSTREAM));
134 } else { 134 } else if (pos.node()->isTextNode()) {
135 // Split a text node 135 // Split a text node
136 ASSERT(pos.node()->isTextNode());
137
138 // Do the split
139 Text* textNode = static_cast<Text*>(pos.node()); 136 Text* textNode = static_cast<Text*>(pos.node());
140 splitTextNode(textNode, pos.deprecatedEditingOffset()); 137 splitTextNode(textNode, pos.deprecatedEditingOffset());
141 insertNodeBefore(nodeToInsert, textNode); 138 insertNodeBefore(nodeToInsert, textNode);
142 Position endingPosition = Position(textNode, 0); 139 Position endingPosition = Position(textNode, 0);
143 140
144 // Handle whitespace that occurs after the split 141 // Handle whitespace that occurs after the split
145 updateLayout(); 142 updateLayout();
146 if (!endingPosition.isRenderedCharacter()) { 143 if (!endingPosition.isRenderedCharacter()) {
147 Position positionBeforeTextNode(positionInParentBeforeNode(textNode) ); 144 Position positionBeforeTextNode(positionInParentBeforeNode(textNode) );
148 // Clear out all whitespace and insert one non-breaking space 145 // Clear out all whitespace and insert one non-breaking space
(...skipping 28 matching lines...) Expand all
177 // before the line break (if the line break is at the end of a block it isn't selectable). 174 // before the line break (if the line break is at the end of a block it isn't selectable).
178 // So, this next call sets the endingSelection() to a caret just after t he line break 175 // So, this next call sets the endingSelection() to a caret just after t he line break
179 // that we inserted, or just before it if it's at the end of a block. 176 // that we inserted, or just before it if it's at the end of a block.
180 setEndingSelection(endingSelection().visibleEnd()); 177 setEndingSelection(endingSelection().visibleEnd());
181 } 178 }
182 179
183 rebalanceWhitespace(); 180 rebalanceWhitespace();
184 } 181 }
185 182
186 } 183 }
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