| 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 30 matching lines...) Expand all Loading... |
| 41 : CompositeEditCommand(document) | 41 : CompositeEditCommand(document) |
| 42 , m_text(text) | 42 , m_text(text) |
| 43 , m_selectInsertedText(selectInsertedText) | 43 , m_selectInsertedText(selectInsertedText) |
| 44 , m_rebalanceType(rebalanceType) | 44 , m_rebalanceType(rebalanceType) |
| 45 { | 45 { |
| 46 } | 46 } |
| 47 | 47 |
| 48 Position InsertTextCommand::positionInsideTextNode(const Position& p) | 48 Position InsertTextCommand::positionInsideTextNode(const Position& p) |
| 49 { | 49 { |
| 50 Position pos = p; | 50 Position pos = p; |
| 51 if (isTabSpanTextNode(pos.anchorNode())) { | 51 if (isTabHTMLSpanElementTextNode(pos.anchorNode())) { |
| 52 RefPtrWillBeRawPtr<Node> textNode = document().createEditingTextNode("")
; | 52 RefPtrWillBeRawPtr<Node> textNode = document().createEditingTextNode("")
; |
| 53 insertNodeAtTabSpanPosition(textNode.get(), pos); | 53 insertNodeAtTabSpanPosition(textNode.get(), pos); |
| 54 return firstPositionInNode(textNode.get()); | 54 return firstPositionInNode(textNode.get()); |
| 55 } | 55 } |
| 56 | 56 |
| 57 // Prepare for text input by looking at the specified position. | 57 // Prepare for text input by looking at the specified position. |
| 58 // It may be necessary to insert a text node to receive characters. | 58 // It may be necessary to insert a text node to receive characters. |
| 59 if (!pos.containerNode()->isTextNode()) { | 59 if (!pos.containerNode()->isTextNode()) { |
| 60 RefPtrWillBeRawPtr<Node> textNode = document().createEditingTextNode("")
; | 60 RefPtrWillBeRawPtr<Node> textNode = document().createEditingTextNode("")
; |
| 61 insertNodeAt(textNode.get(), pos); | 61 insertNodeAt(textNode.get(), pos); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 Position InsertTextCommand::insertTab(const Position& pos) | 230 Position InsertTextCommand::insertTab(const Position& pos) |
| 231 { | 231 { |
| 232 Position insertPos = VisiblePosition(pos, DOWNSTREAM).deepEquivalent(); | 232 Position insertPos = VisiblePosition(pos, DOWNSTREAM).deepEquivalent(); |
| 233 if (insertPos.isNull()) | 233 if (insertPos.isNull()) |
| 234 return pos; | 234 return pos; |
| 235 | 235 |
| 236 Node* node = insertPos.containerNode(); | 236 Node* node = insertPos.containerNode(); |
| 237 unsigned offset = node->isTextNode() ? insertPos.offsetInContainerNode() : 0
; | 237 unsigned offset = node->isTextNode() ? insertPos.offsetInContainerNode() : 0
; |
| 238 | 238 |
| 239 // keep tabs coalesced in tab span | 239 // keep tabs coalesced in tab span |
| 240 if (isTabSpanTextNode(node)) { | 240 if (isTabHTMLSpanElementTextNode(node)) { |
| 241 RefPtrWillBeRawPtr<Text> textNode = toText(node); | 241 RefPtrWillBeRawPtr<Text> textNode = toText(node); |
| 242 insertTextIntoNode(textNode, offset, "\t"); | 242 insertTextIntoNode(textNode, offset, "\t"); |
| 243 return Position(textNode.release(), offset + 1); | 243 return Position(textNode.release(), offset + 1); |
| 244 } | 244 } |
| 245 | 245 |
| 246 // create new tab span | 246 // create new tab span |
| 247 RefPtrWillBeRawPtr<HTMLSpanElement> spanElement = createTabSpanElement(docum
ent()); | 247 RefPtrWillBeRawPtr<HTMLSpanElement> spanElement = createTabSpanElement(docum
ent()); |
| 248 | 248 |
| 249 // place it | 249 // place it |
| 250 if (!node->isTextNode()) { | 250 if (!node->isTextNode()) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 262 splitTextNode(textNode, offset); | 262 splitTextNode(textNode, offset); |
| 263 insertNodeBefore(spanElement, textNode.release()); | 263 insertNodeBefore(spanElement, textNode.release()); |
| 264 } | 264 } |
| 265 } | 265 } |
| 266 | 266 |
| 267 // return the position following the new tab | 267 // return the position following the new tab |
| 268 return lastPositionInNode(spanElement.get()); | 268 return lastPositionInNode(spanElement.get()); |
| 269 } | 269 } |
| 270 | 270 |
| 271 } | 271 } |
| OLD | NEW |