| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 pos = positionOutsideTabSpan(pos); | 88 pos = positionOutsideTabSpan(pos); |
| 89 | 89 |
| 90 Node* nodeToInsert = nullptr; | 90 Node* nodeToInsert = nullptr; |
| 91 if (shouldUseBreakElement(pos)) | 91 if (shouldUseBreakElement(pos)) |
| 92 nodeToInsert = HTMLBRElement::create(document()); | 92 nodeToInsert = HTMLBRElement::create(document()); |
| 93 else | 93 else |
| 94 nodeToInsert = document().createTextNode("\n"); | 94 nodeToInsert = document().createTextNode("\n"); |
| 95 | 95 |
| 96 // FIXME: Need to merge text nodes when inserting just after or before text. | 96 // FIXME: Need to merge text nodes when inserting just after or before text. |
| 97 | 97 |
| 98 if (isEndOfParagraph(caret) && !lineBreakExistsAtVisiblePosition(caret)) { | 98 if (isEndOfParagraphDeprecated(caret) && !lineBreakExistsAtVisiblePosition(c
aret)) { |
| 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)) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 120 } | 120 } |
| 121 | 121 |
| 122 VisiblePosition endingPosition = VisiblePosition::beforeNode(nodeToInser
t); | 122 VisiblePosition endingPosition = VisiblePosition::beforeNode(nodeToInser
t); |
| 123 setEndingSelection(VisibleSelection(endingPosition, endingSelection().is
Directional())); | 123 setEndingSelection(VisibleSelection(endingPosition, endingSelection().is
Directional())); |
| 124 } else if (pos.computeEditingOffset() <= caretMinOffset(pos.anchorNode())) { | 124 } else if (pos.computeEditingOffset() <= caretMinOffset(pos.anchorNode())) { |
| 125 insertNodeAt(nodeToInsert, pos, editingState); | 125 insertNodeAt(nodeToInsert, pos, editingState); |
| 126 if (editingState->isAborted()) | 126 if (editingState->isAborted()) |
| 127 return; | 127 return; |
| 128 | 128 |
| 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::beforeNode(nodeToInsert))) { | 130 if (!isStartOfParagraphDeprecated(VisiblePosition::beforeNode(nodeToInse
rt))) { |
| 131 insertNodeBefore(nodeToInsert->cloneNode(false), nodeToInsert, editi
ngState); | 131 insertNodeBefore(nodeToInsert->cloneNode(false), nodeToInsert, editi
ngState); |
| 132 if (editingState->isAborted()) | 132 if (editingState->isAborted()) |
| 133 return; | 133 return; |
| 134 } | 134 } |
| 135 | 135 |
| 136 setEndingSelection(VisibleSelection(Position::inParentAfterNode(*nodeToI
nsert), TextAffinity::Downstream, endingSelection().isDirectional())); | 136 setEndingSelection(VisibleSelection(Position::inParentAfterNode(*nodeToI
nsert), TextAffinity::Downstream, endingSelection().isDirectional())); |
| 137 // If we're inserting after all of the rendered text in a text node, or into
a non-text node, | 137 // If we're inserting after all of the rendered text in a text node, or into
a non-text node, |
| 138 // a simple insertion is sufficient. | 138 // a simple insertion is sufficient. |
| 139 } else if (!pos.anchorNode()->isTextNode() || pos.computeOffsetInContainerNo
de() >= caretMaxOffset(pos.anchorNode())) { | 139 } else if (!pos.anchorNode()->isTextNode() || pos.computeOffsetInContainerNo
de() >= caretMaxOffset(pos.anchorNode())) { |
| 140 insertNodeAt(nodeToInsert, pos, editingState); | 140 insertNodeAt(nodeToInsert, pos, editingState); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 // 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). |
| 193 // 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 |
| 194 // 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. |
| 195 setEndingSelection(endingSelection().visibleEnd()); | 195 setEndingSelection(endingSelection().visibleEnd()); |
| 196 } | 196 } |
| 197 | 197 |
| 198 rebalanceWhitespace(); | 198 rebalanceWhitespace(); |
| 199 } | 199 } |
| 200 | 200 |
| 201 } // namespace blink | 201 } // namespace blink |
| OLD | NEW |