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

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

Issue 214313002: Don't inherit block style if text is inserted after paragraph selection. (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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2005 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 ASSERT(m_text.find('\n') == kNotFound); 123 ASSERT(m_text.find('\n') == kNotFound);
124 124
125 if (!endingSelection().isNonOrphanedCaretOrRange()) 125 if (!endingSelection().isNonOrphanedCaretOrRange())
126 return; 126 return;
127 127
128 // Delete the current selection. 128 // Delete the current selection.
129 // FIXME: This delete operation blows away the typing style. 129 // FIXME: This delete operation blows away the typing style.
130 if (endingSelection().isRange()) { 130 if (endingSelection().isRange()) {
131 if (performTrivialReplace(m_text, m_selectInsertedText)) 131 if (performTrivialReplace(m_text, m_selectInsertedText))
132 return; 132 return;
133 bool endOfSelectionWasAtStartOfBlock = isStartOfBlock(endingSelection(). visibleEnd());
133 deleteSelection(false, true, false, false); 134 deleteSelection(false, true, false, false);
134 // deleteSelection eventually makes a new endingSelection out of a Posit ion. If that Position doesn't have 135 // deleteSelection eventually makes a new endingSelection out of a Posit ion. If that Position doesn't have
135 // a renderer (e.g. it is on a <frameset> in the DOM), the VisibleSelect ion cannot be canonicalized to 136 // a renderer (e.g. it is on a <frameset> in the DOM), the VisibleSelect ion cannot be canonicalized to
136 // anything other than NoSelection. The rest of this function requires a real endingSelection, so bail out. 137 // anything other than NoSelection. The rest of this function requires a real endingSelection, so bail out.
137 if (endingSelection().isNone()) 138 if (endingSelection().isNone())
138 return; 139 return;
140 if (endOfSelectionWasAtStartOfBlock) {
141 if (EditingStyle* typingStyle = document().frame()->selection().typi ngStyle())
142 typingStyle->removeBlockProperties();
143 }
139 } else if (document().frame()->editor().isOverwriteModeEnabled()) { 144 } else if (document().frame()->editor().isOverwriteModeEnabled()) {
140 if (performOverwrite(m_text, m_selectInsertedText)) 145 if (performOverwrite(m_text, m_selectInsertedText))
141 return; 146 return;
142 } 147 }
143 148
144 Position startPosition(endingSelection().start()); 149 Position startPosition(endingSelection().start());
145 150
146 Position placeholder; 151 Position placeholder;
147 // We want to remove preserved newlines and brs that will collapse (and thus become unnecessary) when content 152 // We want to remove preserved newlines and brs that will collapse (and thus become unnecessary) when content
148 // is inserted just before them. 153 // is inserted just before them.
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 splitTextNode(textNode, offset); 259 splitTextNode(textNode, offset);
255 insertNodeBefore(spanNode, textNode.release()); 260 insertNodeBefore(spanNode, textNode.release());
256 } 261 }
257 } 262 }
258 263
259 // return the position following the new tab 264 // return the position following the new tab
260 return lastPositionInNode(spanNode.get()); 265 return lastPositionInNode(spanNode.get());
261 } 266 }
262 267
263 } 268 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698