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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 return; | 130 return; |
131 } | 131 } |
132 | 132 |
133 // Don't move a line break just after the caret. Doing so would create an e
xtra, empty paragraph | 133 // Don't move a line break just after the caret. Doing so would create an e
xtra, empty paragraph |
134 // in the new blockquote. | 134 // in the new blockquote. |
135 if (lineBreakExistsAtVisiblePosition(visiblePos)) { | 135 if (lineBreakExistsAtVisiblePosition(visiblePos)) { |
136 pos = nextPositionOf(pos, PositionMoveType::GraphemeCluster); | 136 pos = nextPositionOf(pos, PositionMoveType::GraphemeCluster); |
137 } | 137 } |
138 | 138 |
139 // Adjust the position so we don't split at the beginning of a quote. | 139 // Adjust the position so we don't split at the beginning of a quote. |
140 while (isFirstVisiblePositionInNode(createVisiblePosition(pos), toHTMLQuoteE
lement(enclosingNodeOfType(pos, isMailHTMLBlockquoteElement)))) { | 140 while (isFirstVisiblePositionInNode(createVisiblePositionDeprecated(pos), to
HTMLQuoteElement(enclosingNodeOfType(pos, isMailHTMLBlockquoteElement)))) { |
141 pos = previousPositionOf(pos, PositionMoveType::GraphemeCluster); | 141 pos = previousPositionOf(pos, PositionMoveType::GraphemeCluster); |
142 } | 142 } |
143 | 143 |
144 // startNode is the first node that we need to move to the new blockquote. | 144 // startNode is the first node that we need to move to the new blockquote. |
145 Node* startNode = pos.anchorNode(); | 145 Node* startNode = pos.anchorNode(); |
146 DCHECK(startNode); | 146 DCHECK(startNode); |
147 | 147 |
148 // Split at pos if in the middle of a text node. | 148 // Split at pos if in the middle of a text node. |
149 if (startNode->isTextNode()) { | 149 if (startNode->isTextNode()) { |
150 Text* textNode = toText(startNode); | 150 Text* textNode = toText(startNode); |
151 int textOffset = pos.computeOffsetInContainerNode(); | 151 int textOffset = pos.computeOffsetInContainerNode(); |
152 if ((unsigned)textOffset >= textNode->length()) { | 152 if ((unsigned)textOffset >= textNode->length()) { |
153 startNode = NodeTraversal::next(*startNode); | 153 startNode = NodeTraversal::next(*startNode); |
154 DCHECK(startNode); | 154 DCHECK(startNode); |
155 } else if (textOffset > 0) { | 155 } else if (textOffset > 0) { |
156 splitTextNode(textNode, textOffset); | 156 splitTextNode(textNode, textOffset); |
157 } | 157 } |
158 } else if (pos.computeEditingOffset() > 0) { | 158 } else if (pos.computeEditingOffset() > 0) { |
159 Node* childAtOffset = NodeTraversal::childAt(*startNode, pos.computeEdit
ingOffset()); | 159 Node* childAtOffset = NodeTraversal::childAt(*startNode, pos.computeEdit
ingOffset()); |
160 startNode = childAtOffset ? childAtOffset : NodeTraversal::next(*startNo
de); | 160 startNode = childAtOffset ? childAtOffset : NodeTraversal::next(*startNo
de); |
161 DCHECK(startNode); | 161 DCHECK(startNode); |
162 } | 162 } |
163 | 163 |
164 // If there's nothing inside topBlockquote to move, we're finished. | 164 // If there's nothing inside topBlockquote to move, we're finished. |
165 if (!startNode->isDescendantOf(topBlockquote)) { | 165 if (!startNode->isDescendantOf(topBlockquote)) { |
166 setEndingSelection(VisibleSelection(createVisiblePosition(firstPositionI
nOrBeforeNode(startNode)), endingSelection().isDirectional())); | 166 setEndingSelection(VisibleSelection(createVisiblePositionDeprecated(firs
tPositionInOrBeforeNode(startNode)), endingSelection().isDirectional())); |
167 return; | 167 return; |
168 } | 168 } |
169 | 169 |
170 // Build up list of ancestors in between the start node and the top blockquo
te. | 170 // Build up list of ancestors in between the start node and the top blockquo
te. |
171 HeapVector<Member<Element>> ancestors; | 171 HeapVector<Member<Element>> ancestors; |
172 for (Element* node = startNode->parentElement(); node && node != topBlockquo
te; node = node->parentElement()) | 172 for (Element* node = startNode->parentElement(); node && node != topBlockquo
te; node = node->parentElement()) |
173 ancestors.append(node); | 173 ancestors.append(node); |
174 | 174 |
175 // Insert a clone of the top blockquote after the break. | 175 // Insert a clone of the top blockquote after the break. |
176 Element* clonedBlockquote = topBlockquote->cloneElementWithoutChildren(); | 176 Element* clonedBlockquote = topBlockquote->cloneElementWithoutChildren(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 addBlockPlaceholderIfNeeded(clonedBlockquote, editingState); | 234 addBlockPlaceholderIfNeeded(clonedBlockquote, editingState); |
235 if (editingState->isAborted()) | 235 if (editingState->isAborted()) |
236 return; | 236 return; |
237 | 237 |
238 // Put the selection right before the break. | 238 // Put the selection right before the break. |
239 setEndingSelection(VisibleSelection(Position::beforeNode(breakElement), Text
Affinity::Downstream, endingSelection().isDirectional())); | 239 setEndingSelection(VisibleSelection(Position::beforeNode(breakElement), Text
Affinity::Downstream, endingSelection().isDirectional())); |
240 rebalanceWhitespace(); | 240 rebalanceWhitespace(); |
241 } | 241 } |
242 | 242 |
243 } // namespace blink | 243 } // namespace blink |
OLD | NEW |