| OLD | NEW |
| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 Position startPosition(endingSelection().start()); | 162 Position startPosition(endingSelection().start()); |
| 163 | 163 |
| 164 Position placeholder; | 164 Position placeholder; |
| 165 // We want to remove preserved newlines and brs that will collapse (and thus
become unnecessary) when content | 165 // We want to remove preserved newlines and brs that will collapse (and thus
become unnecessary) when content |
| 166 // is inserted just before them. | 166 // is inserted just before them. |
| 167 // FIXME: We shouldn't really have to do this, but removing placeholders is
a workaround for 9661. | 167 // FIXME: We shouldn't really have to do this, but removing placeholders is
a workaround for 9661. |
| 168 // If the caret is just before a placeholder, downstream will normalize the
caret to it. | 168 // If the caret is just before a placeholder, downstream will normalize the
caret to it. |
| 169 Position downstream(mostForwardCaretPosition(startPosition)); | 169 Position downstream(mostForwardCaretPosition(startPosition)); |
| 170 if (lineBreakExistsAtPosition(downstream)) { | 170 if (lineBreakExistsAtPosition(downstream)) { |
| 171 // FIXME: This doesn't handle placeholders at the end of anonymous block
s. | 171 // FIXME: This doesn't handle placeholders at the end of anonymous block
s. |
| 172 VisiblePosition caret = createVisiblePosition(startPosition); | 172 VisiblePosition caret = createVisiblePositionDeprecated(startPosition); |
| 173 if (isEndOfBlock(caret) && isStartOfParagraph(caret)) | 173 if (isEndOfBlock(caret) && isStartOfParagraph(caret)) |
| 174 placeholder = downstream; | 174 placeholder = downstream; |
| 175 // Don't remove the placeholder yet, otherwise the block we're inserting
into would collapse before | 175 // Don't remove the placeholder yet, otherwise the block we're inserting
into would collapse before |
| 176 // we get a chance to insert into it. We check for a placeholder now, t
hough, because doing so requires | 176 // we get a chance to insert into it. We check for a placeholder now, t
hough, because doing so requires |
| 177 // the creation of a VisiblePosition, and if we did that post-insertion
it would force a layout. | 177 // the creation of a VisiblePosition, and if we did that post-insertion
it would force a layout. |
| 178 } | 178 } |
| 179 | 179 |
| 180 // Insert the character at the leftmost candidate. | 180 // Insert the character at the leftmost candidate. |
| 181 startPosition = mostBackwardCaretPosition(startPosition); | 181 startPosition = mostBackwardCaretPosition(startPosition); |
| 182 | 182 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 return; | 243 return; |
| 244 } | 244 } |
| 245 } | 245 } |
| 246 | 246 |
| 247 if (!m_selectInsertedText) | 247 if (!m_selectInsertedText) |
| 248 setEndingSelection(VisibleSelection(endingSelection().end(), endingSelec
tion().affinity(), endingSelection().isDirectional())); | 248 setEndingSelection(VisibleSelection(endingSelection().end(), endingSelec
tion().affinity(), endingSelection().isDirectional())); |
| 249 } | 249 } |
| 250 | 250 |
| 251 Position InsertTextCommand::insertTab(const Position& pos, EditingState* editing
State) | 251 Position InsertTextCommand::insertTab(const Position& pos, EditingState* editing
State) |
| 252 { | 252 { |
| 253 Position insertPos = createVisiblePosition(pos).deepEquivalent(); | 253 Position insertPos = createVisiblePositionDeprecated(pos).deepEquivalent(); |
| 254 if (insertPos.isNull()) | 254 if (insertPos.isNull()) |
| 255 return pos; | 255 return pos; |
| 256 | 256 |
| 257 Node* node = insertPos.computeContainerNode(); | 257 Node* node = insertPos.computeContainerNode(); |
| 258 unsigned offset = node->isTextNode() ? insertPos.offsetInContainerNode() : 0
; | 258 unsigned offset = node->isTextNode() ? insertPos.offsetInContainerNode() : 0
; |
| 259 | 259 |
| 260 // keep tabs coalesced in tab span | 260 // keep tabs coalesced in tab span |
| 261 if (isTabHTMLSpanElementTextNode(node)) { | 261 if (isTabHTMLSpanElementTextNode(node)) { |
| 262 Text* textNode = toText(node); | 262 Text* textNode = toText(node); |
| 263 insertTextIntoNode(textNode, offset, "\t"); | 263 insertTextIntoNode(textNode, offset, "\t"); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 285 } | 285 } |
| 286 } | 286 } |
| 287 if (editingState->isAborted()) | 287 if (editingState->isAborted()) |
| 288 return Position(); | 288 return Position(); |
| 289 | 289 |
| 290 // return the position following the new tab | 290 // return the position following the new tab |
| 291 return Position::lastPositionInNode(spanElement); | 291 return Position::lastPositionInNode(spanElement); |
| 292 } | 292 } |
| 293 | 293 |
| 294 } // namespace blink | 294 } // namespace blink |
| OLD | NEW |