| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 // If we're inserting the break at the end of the quoted content, we don't n
eed to break the quote. | 126 // If we're inserting the break at the end of the quoted content, we don't n
eed to break the quote. |
| 127 if (isLastVisPosInNode) { | 127 if (isLastVisPosInNode) { |
| 128 setEndingSelection(VisibleSelection(positionBeforeNode(breakElement.get(
)), TextAffinity::Downstream, endingSelection().isDirectional())); | 128 setEndingSelection(VisibleSelection(positionBeforeNode(breakElement.get(
)), TextAffinity::Downstream, endingSelection().isDirectional())); |
| 129 rebalanceWhitespace(); | 129 rebalanceWhitespace(); |
| 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 // TODO(yosin) We should use |PositionMoveType::Character| for | 136 pos = nextPositionOf(pos, PositionMoveType::GraphemeCluster); |
| 137 // |nextPositionOf()| to avoid editing middle of character. | |
| 138 pos = nextPositionOf(pos, PositionMoveType::CodePoint); | |
| 139 } | 137 } |
| 140 | 138 |
| 141 // 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. |
| 142 while (isFirstVisiblePositionInNode(createVisiblePosition(pos), toHTMLQuoteE
lement(enclosingNodeOfType(pos, isMailHTMLBlockquoteElement)))) { | 140 while (isFirstVisiblePositionInNode(createVisiblePosition(pos), toHTMLQuoteE
lement(enclosingNodeOfType(pos, isMailHTMLBlockquoteElement)))) { |
| 143 // TODO(yosin) We should use |PositionMoveType::Character| for | 141 pos = previousPositionOf(pos, PositionMoveType::GraphemeCluster); |
| 144 // |previousPositionOf()| to avoid editing middle character. | |
| 145 pos = previousPositionOf(pos, PositionMoveType::CodePoint); | |
| 146 } | 142 } |
| 147 | 143 |
| 148 // 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. |
| 149 Node* startNode = pos.anchorNode(); | 145 Node* startNode = pos.anchorNode(); |
| 150 ASSERT(startNode); | 146 ASSERT(startNode); |
| 151 | 147 |
| 152 // Split at pos if in the middle of a text node. | 148 // Split at pos if in the middle of a text node. |
| 153 if (startNode->isTextNode()) { | 149 if (startNode->isTextNode()) { |
| 154 Text* textNode = toText(startNode); | 150 Text* textNode = toText(startNode); |
| 155 int textOffset = pos.computeOffsetInContainerNode(); | 151 int textOffset = pos.computeOffsetInContainerNode(); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 addBlockPlaceholderIfNeeded(clonedBlockquote.get(), editingState); | 234 addBlockPlaceholderIfNeeded(clonedBlockquote.get(), editingState); |
| 239 if (editingState->isAborted()) | 235 if (editingState->isAborted()) |
| 240 return; | 236 return; |
| 241 | 237 |
| 242 // Put the selection right before the break. | 238 // Put the selection right before the break. |
| 243 setEndingSelection(VisibleSelection(positionBeforeNode(breakElement.get()),
TextAffinity::Downstream, endingSelection().isDirectional())); | 239 setEndingSelection(VisibleSelection(positionBeforeNode(breakElement.get()),
TextAffinity::Downstream, endingSelection().isDirectional())); |
| 244 rebalanceWhitespace(); | 240 rebalanceWhitespace(); |
| 245 } | 241 } |
| 246 | 242 |
| 247 } // namespace blink | 243 } // namespace blink |
| OLD | NEW |