| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 HTMLBRElement* breakElement = HTMLBRElement::create(document()); | 106 HTMLBRElement* breakElement = HTMLBRElement::create(document()); |
| 107 | 107 |
| 108 bool isLastVisPosInNode = isLastVisiblePositionInNode(visiblePos, topBlockqu
ote); | 108 bool isLastVisPosInNode = isLastVisiblePositionInNode(visiblePos, topBlockqu
ote); |
| 109 | 109 |
| 110 // If the position is at the beginning of the top quoted content, we don't n
eed to break the quote. | 110 // If the position is at the beginning of the top quoted content, we don't n
eed to break the quote. |
| 111 // Instead, insert the break before the blockquote, unless the position is a
s the end of the the quoted content. | 111 // Instead, insert the break before the blockquote, unless the position is a
s the end of the the quoted content. |
| 112 if (isFirstVisiblePositionInNode(visiblePos, topBlockquote) && !isLastVisPos
InNode) { | 112 if (isFirstVisiblePositionInNode(visiblePos, topBlockquote) && !isLastVisPos
InNode) { |
| 113 insertNodeBefore(breakElement, topBlockquote, editingState); | 113 insertNodeBefore(breakElement, topBlockquote, editingState); |
| 114 if (editingState->isAborted()) | 114 if (editingState->isAborted()) |
| 115 return; | 115 return; |
| 116 setEndingSelection(VisibleSelection(positionBeforeNode(breakElement), Te
xtAffinity::Downstream, endingSelection().isDirectional())); | 116 setEndingSelection(VisibleSelection(Position::beforeNode(breakElement),
TextAffinity::Downstream, endingSelection().isDirectional())); |
| 117 rebalanceWhitespace(); | 117 rebalanceWhitespace(); |
| 118 return; | 118 return; |
| 119 } | 119 } |
| 120 | 120 |
| 121 // Insert a break after the top blockquote. | 121 // Insert a break after the top blockquote. |
| 122 insertNodeAfter(breakElement, topBlockquote, editingState); | 122 insertNodeAfter(breakElement, topBlockquote, editingState); |
| 123 if (editingState->isAborted()) | 123 if (editingState->isAborted()) |
| 124 return; | 124 return; |
| 125 | 125 |
| 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), Te
xtAffinity::Downstream, endingSelection().isDirectional())); | 128 setEndingSelection(VisibleSelection(Position::beforeNode(breakElement),
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 pos = nextPositionOf(pos, PositionMoveType::GraphemeCluster); | 136 pos = nextPositionOf(pos, PositionMoveType::GraphemeCluster); |
| 137 } | 137 } |
| 138 | 138 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 return; | 229 return; |
| 230 } | 230 } |
| 231 } | 231 } |
| 232 | 232 |
| 233 // Make sure the cloned block quote renders. | 233 // Make sure the cloned block quote renders. |
| 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(positionBeforeNode(breakElement), TextAf
finity::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 |