| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 // Insert an extra br or '\n' if the just inserted one collapsed. | 129 // Insert an extra br or '\n' if the just inserted one collapsed. |
| 130 if (!isStartOfParagraph(VisiblePosition(Position(nodeToInsert.get(), 0))
)) | 130 if (!isStartOfParagraph(VisiblePosition(Position(nodeToInsert.get(), 0))
)) |
| 131 insertNodeBefore(nodeToInsert->cloneNode(false).get(), nodeToInsert.
get()); | 131 insertNodeBefore(nodeToInsert->cloneNode(false).get(), nodeToInsert.
get()); |
| 132 | 132 |
| 133 setEndingSelection(VisibleSelection(positionInParentAfterNode(nodeToInse
rt.get()), DOWNSTREAM)); | 133 setEndingSelection(VisibleSelection(positionInParentAfterNode(nodeToInse
rt.get()), DOWNSTREAM)); |
| 134 // If we're inserting after all of the rendered text in a text node, or into
a non-text node, | 134 // If we're inserting after all of the rendered text in a text node, or into
a non-text node, |
| 135 // a simple insertion is sufficient. | 135 // a simple insertion is sufficient. |
| 136 } else if (pos.deprecatedEditingOffset() >= caretMaxOffset(pos.node()) || !p
os.node()->isTextNode()) { | 136 } else if (pos.deprecatedEditingOffset() >= caretMaxOffset(pos.node()) || !p
os.node()->isTextNode()) { |
| 137 insertNodeAt(nodeToInsert.get(), pos); | 137 insertNodeAt(nodeToInsert.get(), pos); |
| 138 setEndingSelection(VisibleSelection(positionInParentAfterNode(nodeToInse
rt.get()), DOWNSTREAM)); | 138 setEndingSelection(VisibleSelection(positionInParentAfterNode(nodeToInse
rt.get()), DOWNSTREAM)); |
| 139 } else { | 139 } else if (pos.node()->isTextNode()) { |
| 140 // Split a text node | 140 // Split a text node |
| 141 ASSERT(pos.node()->isTextNode()); | |
| 142 | |
| 143 // Do the split | |
| 144 Text* textNode = static_cast<Text*>(pos.node()); | 141 Text* textNode = static_cast<Text*>(pos.node()); |
| 145 splitTextNode(textNode, pos.deprecatedEditingOffset()); | 142 splitTextNode(textNode, pos.deprecatedEditingOffset()); |
| 146 insertNodeBefore(nodeToInsert, textNode); | 143 insertNodeBefore(nodeToInsert, textNode); |
| 147 Position endingPosition = Position(textNode, 0); | 144 Position endingPosition = Position(textNode, 0); |
| 148 | 145 |
| 149 // Handle whitespace that occurs after the split | 146 // Handle whitespace that occurs after the split |
| 150 updateLayout(); | 147 updateLayout(); |
| 151 if (!endingPosition.isRenderedCharacter()) { | 148 if (!endingPosition.isRenderedCharacter()) { |
| 152 Position positionBeforeTextNode(positionInParentBeforeNode(textNode)
); | 149 Position positionBeforeTextNode(positionInParentBeforeNode(textNode)
); |
| 153 // Clear out all whitespace and insert one non-breaking space | 150 // Clear out all whitespace and insert one non-breaking space |
| (...skipping 28 matching lines...) Expand all Loading... |
| 182 // before the line break (if the line break is at the end of a block it
isn't selectable). | 179 // before the line break (if the line break is at the end of a block it
isn't selectable). |
| 183 // So, this next call sets the endingSelection() to a caret just after t
he line break | 180 // So, this next call sets the endingSelection() to a caret just after t
he line break |
| 184 // that we inserted, or just before it if it's at the end of a block. | 181 // that we inserted, or just before it if it's at the end of a block. |
| 185 setEndingSelection(endingSelection().visibleEnd()); | 182 setEndingSelection(endingSelection().visibleEnd()); |
| 186 } | 183 } |
| 187 | 184 |
| 188 rebalanceWhitespace(); | 185 rebalanceWhitespace(); |
| 189 } | 186 } |
| 190 | 187 |
| 191 } | 188 } |
| OLD | NEW |