| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 , m_text(text) | 51 , m_text(text) |
| 52 , m_selectInsertedText(false) | 52 , m_selectInsertedText(false) |
| 53 , m_rebalanceType(RebalanceLeadingAndTrailingWhitespaces) | 53 , m_rebalanceType(RebalanceLeadingAndTrailingWhitespaces) |
| 54 , m_markerSupplier(markerSupplier) | 54 , m_markerSupplier(markerSupplier) |
| 55 { | 55 { |
| 56 } | 56 } |
| 57 | 57 |
| 58 Position InsertTextCommand::positionInsideTextNode(const Position& p) | 58 Position InsertTextCommand::positionInsideTextNode(const Position& p) |
| 59 { | 59 { |
| 60 Position pos = p; | 60 Position pos = p; |
| 61 if (isTabSpanTextNode(pos.anchorNode().handle().raw())) { | 61 if (isTabSpanTextNode(pos.anchorNode())) { |
| 62 Handle<Node> textNode = document()->createEditingTextNode(""); | 62 Handle<Node> textNode = document()->createEditingTextNode(""); |
| 63 insertNodeAtTabSpanPosition(textNode, pos); | 63 insertNodeAtTabSpanPosition(textNode, pos); |
| 64 return firstPositionInNode(textNode); | 64 return firstPositionInNode(textNode); |
| 65 } | 65 } |
| 66 | 66 |
| 67 // Prepare for text input by looking at the specified position. | 67 // Prepare for text input by looking at the specified position. |
| 68 // It may be necessary to insert a text node to receive characters. | 68 // It may be necessary to insert a text node to receive characters. |
| 69 if (!pos.containerNode()->isTextNode()) { | 69 if (!pos.containerNode()->isTextNode()) { |
| 70 Handle<Node> textNode = document()->createEditingTextNode(""); | 70 Handle<Node> textNode = document()->createEditingTextNode(""); |
| 71 insertNodeAt(textNode, pos); | 71 insertNodeAt(textNode, pos); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 } | 234 } |
| 235 | 235 |
| 236 Position InsertTextCommand::insertTab(const Position& pos) | 236 Position InsertTextCommand::insertTab(const Position& pos) |
| 237 { | 237 { |
| 238 Position insertPos = VisiblePosition(pos, DOWNSTREAM).deepEquivalent(); | 238 Position insertPos = VisiblePosition(pos, DOWNSTREAM).deepEquivalent(); |
| 239 | 239 |
| 240 Handle<Node> node = insertPos.containerNode(); | 240 Handle<Node> node = insertPos.containerNode(); |
| 241 unsigned int offset = node->isTextNode() ? insertPos.offsetInContainerNode()
: 0; | 241 unsigned int offset = node->isTextNode() ? insertPos.offsetInContainerNode()
: 0; |
| 242 | 242 |
| 243 // keep tabs coalesced in tab span | 243 // keep tabs coalesced in tab span |
| 244 if (isTabSpanTextNode(node.raw())) { | 244 if (isTabSpanTextNode(node)) { |
| 245 Handle<Text> textNode = toText(node.raw()); | 245 Handle<Text> textNode = toText(node); |
| 246 insertTextIntoNode(textNode, offset, "\t"); | 246 insertTextIntoNode(textNode, offset, "\t"); |
| 247 return Position(textNode, offset + 1); | 247 return Position(textNode, offset + 1); |
| 248 } | 248 } |
| 249 | 249 |
| 250 // create new tab span | 250 // create new tab span |
| 251 Handle<Element> spanNode = createTabSpanElement(document()); | 251 Handle<Element> spanNode = createTabSpanElement(document()); |
| 252 | 252 |
| 253 // place it | 253 // place it |
| 254 if (!node->isTextNode()) { | 254 if (!node->isTextNode()) { |
| 255 insertNodeAt(spanNode, insertPos); | 255 insertNodeAt(spanNode, insertPos); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 266 splitTextNode(textNode, offset); | 266 splitTextNode(textNode, offset); |
| 267 insertNodeBefore(spanNode, textNode); | 267 insertNodeBefore(spanNode, textNode); |
| 268 } | 268 } |
| 269 } | 269 } |
| 270 | 270 |
| 271 // return the position following the new tab | 271 // return the position following the new tab |
| 272 return lastPositionInNode(spanNode); | 272 return lastPositionInNode(spanNode); |
| 273 } | 273 } |
| 274 | 274 |
| 275 } | 275 } |
| OLD | NEW |