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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 if (isEndOfParagraph(caret) && !lineBreakExistsAtVisiblePosition(caret)) { | 98 if (isEndOfParagraph(caret) && !lineBreakExistsAtVisiblePosition(caret)) { |
99 bool needExtraLineBreak = !isHTMLHRElement(*pos.anchorNode()) && !isHTML
TableElement(*pos.anchorNode()); | 99 bool needExtraLineBreak = !isHTMLHRElement(*pos.anchorNode()) && !isHTML
TableElement(*pos.anchorNode()); |
100 | 100 |
101 insertNodeAt(nodeToInsert, pos, editingState); | 101 insertNodeAt(nodeToInsert, pos, editingState); |
102 if (editingState->isAborted()) | 102 if (editingState->isAborted()) |
103 return; | 103 return; |
104 | 104 |
105 if (needExtraLineBreak) { | 105 if (needExtraLineBreak) { |
106 Node* extraNode; | 106 Node* extraNode; |
107 // TODO(tkent): Can we remove HTMLTextFormControlElement dependency? | 107 // TODO(tkent): Can we remove HTMLTextFormControlElement dependency? |
108 if (HTMLTextFormControlElement* textControl = enclosingTextFormContr
ol(nodeToInsert)) | 108 if (HTMLTextFormControlElement* textControl = enclosingTextFormContr
ol(nodeToInsert)) { |
109 extraNode = textControl->createPlaceholderBreakElement(); | 109 extraNode = textControl->createPlaceholderBreakElement(); |
110 else | 110 // The placeholder BR should be the last child. There might be |
| 111 // empty Text nodes at |pos|. |
| 112 appendNode(extraNode, nodeToInsert->parentNode(), editingState); |
| 113 } else { |
111 extraNode = nodeToInsert->cloneNode(false); | 114 extraNode = nodeToInsert->cloneNode(false); |
112 insertNodeAfter(extraNode, nodeToInsert, editingState); | 115 insertNodeAfter(extraNode, nodeToInsert, editingState); |
| 116 } |
113 if (editingState->isAborted()) | 117 if (editingState->isAborted()) |
114 return; | 118 return; |
115 nodeToInsert = extraNode; | 119 nodeToInsert = extraNode; |
116 } | 120 } |
117 | 121 |
118 VisiblePosition endingPosition = VisiblePosition::beforeNode(nodeToInser
t); | 122 VisiblePosition endingPosition = VisiblePosition::beforeNode(nodeToInser
t); |
119 setEndingSelection(VisibleSelection(endingPosition, endingSelection().is
Directional())); | 123 setEndingSelection(VisibleSelection(endingPosition, endingSelection().is
Directional())); |
120 } else if (pos.computeEditingOffset() <= caretMinOffset(pos.anchorNode())) { | 124 } else if (pos.computeEditingOffset() <= caretMinOffset(pos.anchorNode())) { |
121 insertNodeAt(nodeToInsert, pos, editingState); | 125 insertNodeAt(nodeToInsert, pos, editingState); |
122 if (editingState->isAborted()) | 126 if (editingState->isAborted()) |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 // before the line break (if the line break is at the end of a block it
isn't selectable). | 192 // before the line break (if the line break is at the end of a block it
isn't selectable). |
189 // So, this next call sets the endingSelection() to a caret just after t
he line break | 193 // So, this next call sets the endingSelection() to a caret just after t
he line break |
190 // that we inserted, or just before it if it's at the end of a block. | 194 // that we inserted, or just before it if it's at the end of a block. |
191 setEndingSelection(endingSelection().visibleEnd()); | 195 setEndingSelection(endingSelection().visibleEnd()); |
192 } | 196 } |
193 | 197 |
194 rebalanceWhitespace(); | 198 rebalanceWhitespace(); |
195 } | 199 } |
196 | 200 |
197 } // namespace blink | 201 } // namespace blink |
OLD | NEW |