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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 applyStyle(typingStyle.get()); | 222 applyStyle(typingStyle.get()); |
223 } | 223 } |
224 | 224 |
225 if (!m_selectInsertedText) | 225 if (!m_selectInsertedText) |
226 setEndingSelection(VisibleSelection(endingSelection().end(), endingSelec
tion().affinity(), endingSelection().isDirectional())); | 226 setEndingSelection(VisibleSelection(endingSelection().end(), endingSelec
tion().affinity(), endingSelection().isDirectional())); |
227 } | 227 } |
228 | 228 |
229 Position InsertTextCommand::insertTab(const Position& pos) | 229 Position InsertTextCommand::insertTab(const Position& pos) |
230 { | 230 { |
231 Position insertPos = VisiblePosition(pos, DOWNSTREAM).deepEquivalent(); | 231 Position insertPos = VisiblePosition(pos, DOWNSTREAM).deepEquivalent(); |
| 232 if (insertPos.isNull()) |
| 233 return pos; |
232 | 234 |
233 Node* node = insertPos.containerNode(); | 235 Node* node = insertPos.containerNode(); |
234 unsigned offset = node->isTextNode() ? insertPos.offsetInContainerNode() : 0
; | 236 unsigned offset = node->isTextNode() ? insertPos.offsetInContainerNode() : 0
; |
235 | 237 |
236 // keep tabs coalesced in tab span | 238 // keep tabs coalesced in tab span |
237 if (isTabSpanTextNode(node)) { | 239 if (isTabSpanTextNode(node)) { |
238 RefPtrWillBeRawPtr<Text> textNode = toText(node); | 240 RefPtrWillBeRawPtr<Text> textNode = toText(node); |
239 insertTextIntoNode(textNode, offset, "\t"); | 241 insertTextIntoNode(textNode, offset, "\t"); |
240 return Position(textNode.release(), offset + 1); | 242 return Position(textNode.release(), offset + 1); |
241 } | 243 } |
(...skipping 17 matching lines...) Expand all Loading... |
259 splitTextNode(textNode, offset); | 261 splitTextNode(textNode, offset); |
260 insertNodeBefore(spanNode, textNode.release()); | 262 insertNodeBefore(spanNode, textNode.release()); |
261 } | 263 } |
262 } | 264 } |
263 | 265 |
264 // return the position following the new tab | 266 // return the position following the new tab |
265 return lastPositionInNode(spanNode.get()); | 267 return lastPositionInNode(spanNode.get()); |
266 } | 268 } |
267 | 269 |
268 } | 270 } |
OLD | NEW |