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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 insertNodeAt(nodeToInsert.get(), pos); | 94 insertNodeAt(nodeToInsert.get(), pos); |
95 setEndingSelection(VisibleSelection(positionInParentAfterNode(*nodeToIns
ert), DOWNSTREAM, endingSelection().isDirectional())); | 95 setEndingSelection(VisibleSelection(positionInParentAfterNode(*nodeToIns
ert), DOWNSTREAM, endingSelection().isDirectional())); |
96 } else if (pos.deprecatedNode()->isTextNode()) { | 96 } else if (pos.deprecatedNode()->isTextNode()) { |
97 // Split a text node | 97 // Split a text node |
98 Text* textNode = toText(pos.deprecatedNode()); | 98 Text* textNode = toText(pos.deprecatedNode()); |
99 splitTextNode(textNode, pos.deprecatedEditingOffset()); | 99 splitTextNode(textNode, pos.deprecatedEditingOffset()); |
100 insertNodeBefore(nodeToInsert, textNode); | 100 insertNodeBefore(nodeToInsert, textNode); |
101 Position endingPosition = firstPositionInNode(textNode); | 101 Position endingPosition = firstPositionInNode(textNode); |
102 | 102 |
103 // Handle whitespace that occurs after the split | 103 // Handle whitespace that occurs after the split |
104 document().updateLayoutIgnorePendingStylesheets(); | 104 document().updateLayout(); |
105 if (!endingPosition.isRenderedCharacter()) { | 105 if (!endingPosition.isRenderedCharacter()) { |
106 Position positionBeforeTextNode(positionInParentBeforeNode(*textNode
)); | 106 Position positionBeforeTextNode(positionInParentBeforeNode(*textNode
)); |
107 // Clear out all whitespace and insert one non-breaking space | 107 // Clear out all whitespace and insert one non-breaking space |
108 deleteInsignificantTextDownstream(endingPosition); | 108 deleteInsignificantTextDownstream(endingPosition); |
109 ASSERT(!textNode->renderer() || textNode->renderer()->style()->colla
pseWhiteSpace()); | 109 ASSERT(!textNode->renderer() || textNode->renderer()->style()->colla
pseWhiteSpace()); |
110 // Deleting insignificant whitespace will remove textNode if it cont
ains nothing but insignificant whitespace. | 110 // Deleting insignificant whitespace will remove textNode if it cont
ains nothing but insignificant whitespace. |
111 if (textNode->inDocument()) | 111 if (textNode->inDocument()) |
112 insertTextIntoNode(textNode, 0, nonBreakingSpaceString()); | 112 insertTextIntoNode(textNode, 0, nonBreakingSpaceString()); |
113 else { | 113 else { |
114 RefPtr<Text> nbspNode = document().createTextNode(nonBreakingSpa
ceString()); | 114 RefPtr<Text> nbspNode = document().createTextNode(nonBreakingSpa
ceString()); |
(...skipping 16 matching lines...) Expand all Loading... |
131 // before the line break (if the line break is at the end of a block it
isn't selectable). | 131 // before the line break (if the line break is at the end of a block it
isn't selectable). |
132 // So, this next call sets the endingSelection() to a caret just after t
he line break | 132 // So, this next call sets the endingSelection() to a caret just after t
he line break |
133 // that we inserted, or just before it if it's at the end of a block. | 133 // that we inserted, or just before it if it's at the end of a block. |
134 setEndingSelection(endingSelection().visibleEnd()); | 134 setEndingSelection(endingSelection().visibleEnd()); |
135 } | 135 } |
136 | 136 |
137 rebalanceWhitespace(); | 137 rebalanceWhitespace(); |
138 } | 138 } |
139 | 139 |
140 } | 140 } |
OLD | NEW |