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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 | 119 |
120 // If we're inserting the break at the end of the quoted content, we don't n
eed to break the quote. | 120 // If we're inserting the break at the end of the quoted content, we don't n
eed to break the quote. |
121 if (isLastVisPosInNode) { | 121 if (isLastVisPosInNode) { |
122 setEndingSelection(VisibleSelection(positionBeforeNode(breakElement.get(
)), TextAffinity::Downstream, endingSelection().isDirectional())); | 122 setEndingSelection(VisibleSelection(positionBeforeNode(breakElement.get(
)), TextAffinity::Downstream, endingSelection().isDirectional())); |
123 rebalanceWhitespace(); | 123 rebalanceWhitespace(); |
124 return; | 124 return; |
125 } | 125 } |
126 | 126 |
127 // Don't move a line break just after the caret. Doing so would create an e
xtra, empty paragraph | 127 // Don't move a line break just after the caret. Doing so would create an e
xtra, empty paragraph |
128 // in the new blockquote. | 128 // in the new blockquote. |
129 if (lineBreakExistsAtVisiblePosition(visiblePos)) | 129 if (lineBreakExistsAtVisiblePosition(visiblePos)) { |
130 pos = pos.next(); | 130 // TODO(yosin) We should use |PositionMoveType::Character| for |
| 131 // |nextPositionOf()| to avoid editing middle of character. |
| 132 pos = nextPositionOf(pos, PositionMoveType::CodePoint); |
| 133 } |
131 | 134 |
132 // Adjust the position so we don't split at the beginning of a quote. | 135 // Adjust the position so we don't split at the beginning of a quote. |
133 while (isFirstVisiblePositionInNode(VisiblePosition(pos), toHTMLQuoteElement
(enclosingNodeOfType(pos, isMailHTMLBlockquoteElement)))) | 136 while (isFirstVisiblePositionInNode(VisiblePosition(pos), toHTMLQuoteElement
(enclosingNodeOfType(pos, isMailHTMLBlockquoteElement)))) { |
134 pos = pos.previous(); | 137 // TODO(yosin) We should use |PositionMoveType::Character| for |
| 138 // |previousPositionOf()| to avoid editing middle character. |
| 139 pos = previousPositionOf(pos, PositionMoveType::CodePoint); |
| 140 } |
135 | 141 |
136 // startNode is the first node that we need to move to the new blockquote. | 142 // startNode is the first node that we need to move to the new blockquote. |
137 Node* startNode = pos.anchorNode(); | 143 Node* startNode = pos.anchorNode(); |
138 ASSERT(startNode); | 144 ASSERT(startNode); |
139 | 145 |
140 // Split at pos if in the middle of a text node. | 146 // Split at pos if in the middle of a text node. |
141 if (startNode->isTextNode()) { | 147 if (startNode->isTextNode()) { |
142 Text* textNode = toText(startNode); | 148 Text* textNode = toText(startNode); |
143 int textOffset = pos.computeOffsetInContainerNode(); | 149 int textOffset = pos.computeOffsetInContainerNode(); |
144 if ((unsigned)textOffset >= textNode->length()) { | 150 if ((unsigned)textOffset >= textNode->length()) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 | 218 |
213 // Make sure the cloned block quote renders. | 219 // Make sure the cloned block quote renders. |
214 addBlockPlaceholderIfNeeded(clonedBlockquote.get()); | 220 addBlockPlaceholderIfNeeded(clonedBlockquote.get()); |
215 | 221 |
216 // Put the selection right before the break. | 222 // Put the selection right before the break. |
217 setEndingSelection(VisibleSelection(positionBeforeNode(breakElement.get()),
TextAffinity::Downstream, endingSelection().isDirectional())); | 223 setEndingSelection(VisibleSelection(positionBeforeNode(breakElement.get()),
TextAffinity::Downstream, endingSelection().isDirectional())); |
218 rebalanceWhitespace(); | 224 rebalanceWhitespace(); |
219 } | 225 } |
220 | 226 |
221 } // namespace blink | 227 } // namespace blink |
OLD | NEW |