| 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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 | 219 |
| 220 if (!m_selectInsertedText) | 220 if (!m_selectInsertedText) |
| 221 setEndingSelection(VisibleSelection(endingSelection().end(), endingSelec
tion().affinity(), endingSelection().isDirectional())); | 221 setEndingSelection(VisibleSelection(endingSelection().end(), endingSelec
tion().affinity(), endingSelection().isDirectional())); |
| 222 } | 222 } |
| 223 | 223 |
| 224 Position InsertTextCommand::insertTab(const Position& pos) | 224 Position InsertTextCommand::insertTab(const Position& pos) |
| 225 { | 225 { |
| 226 Position insertPos = VisiblePosition(pos, DOWNSTREAM).deepEquivalent(); | 226 Position insertPos = VisiblePosition(pos, DOWNSTREAM).deepEquivalent(); |
| 227 | 227 |
| 228 Node* node = insertPos.containerNode(); | 228 Node* node = insertPos.containerNode(); |
| 229 unsigned int offset = node->isTextNode() ? insertPos.offsetInContainerNode()
: 0; | 229 unsigned offset = node->isTextNode() ? insertPos.offsetInContainerNode() : 0
; |
| 230 | 230 |
| 231 // keep tabs coalesced in tab span | 231 // keep tabs coalesced in tab span |
| 232 if (isTabSpanTextNode(node)) { | 232 if (isTabSpanTextNode(node)) { |
| 233 RefPtr<Text> textNode = toText(node); | 233 RefPtr<Text> textNode = toText(node); |
| 234 insertTextIntoNode(textNode, offset, "\t"); | 234 insertTextIntoNode(textNode, offset, "\t"); |
| 235 return Position(textNode.release(), offset + 1); | 235 return Position(textNode.release(), offset + 1); |
| 236 } | 236 } |
| 237 | 237 |
| 238 // create new tab span | 238 // create new tab span |
| 239 RefPtr<Element> spanNode = createTabSpanElement(document()); | 239 RefPtr<Element> spanNode = createTabSpanElement(document()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 254 splitTextNode(textNode, offset); | 254 splitTextNode(textNode, offset); |
| 255 insertNodeBefore(spanNode, textNode.release()); | 255 insertNodeBefore(spanNode, textNode.release()); |
| 256 } | 256 } |
| 257 } | 257 } |
| 258 | 258 |
| 259 // return the position following the new tab | 259 // return the position following the new tab |
| 260 return lastPositionInNode(spanNode.get()); | 260 return lastPositionInNode(spanNode.get()); |
| 261 } | 261 } |
| 262 | 262 |
| 263 } | 263 } |
| OLD | NEW |