| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple 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 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 | 737 |
| 738 String string = text.substring(upstream, length); | 738 String string = text.substring(upstream, length); |
| 739 // FIXME: Because of the problem mentioned at the top of this function, we | 739 // FIXME: Because of the problem mentioned at the top of this function, we |
| 740 // must also use nbsps at the start/end of the string because this function | 740 // must also use nbsps at the start/end of the string because this function |
| 741 // doesn't get all surrounding whitespace, just the whitespace in the | 741 // doesn't get all surrounding whitespace, just the whitespace in the |
| 742 // current text node. However, if the next sibling node is a text node | 742 // current text node. However, if the next sibling node is a text node |
| 743 // (not empty, see http://crbug.com/632300), we should use a plain space. | 743 // (not empty, see http://crbug.com/632300), we should use a plain space. |
| 744 // See http://crbug.com/310149 | 744 // See http://crbug.com/310149 |
| 745 const bool nextSiblingIsTextNode = textNode->nextSibling() && textNode->next
Sibling()->isTextNode() | 745 const bool nextSiblingIsTextNode = textNode->nextSibling() && textNode->next
Sibling()->isTextNode() |
| 746 && toText(textNode->nextSibling())->data().length(); | 746 && toText(textNode->nextSibling())->data().length(); |
| 747 const bool shouldEmitNBSPbeforeEnd =(isEndOfParagraph(visibleDownstreamPos)
|| (unsigned)downstream == text.length()) && !nextSiblingIsTextNode; | 747 const bool shouldEmitNBSPbeforeEnd =(isEndOfParagraphDeprecated(visibleDowns
treamPos) || (unsigned)downstream == text.length()) && !nextSiblingIsTextNode; |
| 748 String rebalancedString = stringWithRebalancedWhitespace(string, | 748 String rebalancedString = stringWithRebalancedWhitespace(string, |
| 749 isStartOfParagraph(visibleUpstreamPos) || !upstream, shouldEmitNBSPbefor
eEnd); | 749 isStartOfParagraphDeprecated(visibleUpstreamPos) || !upstream, shouldEmi
tNBSPbeforeEnd); |
| 750 | 750 |
| 751 if (string != rebalancedString) | 751 if (string != rebalancedString) |
| 752 replaceTextInNodePreservingMarkers(textNode, upstream, length, rebalance
dString); | 752 replaceTextInNodePreservingMarkers(textNode, upstream, length, rebalance
dString); |
| 753 } | 753 } |
| 754 | 754 |
| 755 void CompositeEditCommand::prepareWhitespaceAtPositionForSplit(Position& positio
n) | 755 void CompositeEditCommand::prepareWhitespaceAtPositionForSplit(Position& positio
n) |
| 756 { | 756 { |
| 757 if (!isRichlyEditablePosition(position)) | 757 if (!isRichlyEditablePosition(position)) |
| 758 return; | 758 return; |
| 759 Node* node = position.anchorNode(); | 759 Node* node = position.anchorNode(); |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 | 990 |
| 991 // If the paragraph is not entirely within it's own block, create one and move t
he paragraph into | 991 // If the paragraph is not entirely within it's own block, create one and move t
he paragraph into |
| 992 // it, and return that block. Otherwise return 0. | 992 // it, and return that block. Otherwise return 0. |
| 993 HTMLElement* CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary(co
nst Position& pos, EditingState* editingState) | 993 HTMLElement* CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary(co
nst Position& pos, EditingState* editingState) |
| 994 { | 994 { |
| 995 DCHECK(isEditablePosition(pos)) << pos; | 995 DCHECK(isEditablePosition(pos)) << pos; |
| 996 | 996 |
| 997 // It's strange that this function is responsible for verifying that pos has
not been invalidated | 997 // It's strange that this function is responsible for verifying that pos has
not been invalidated |
| 998 // by an earlier call to this function. The caller, applyBlockStyle, should
do this. | 998 // by an earlier call to this function. The caller, applyBlockStyle, should
do this. |
| 999 VisiblePosition visiblePos = createVisiblePositionDeprecated(pos, VP_DEFAULT
_AFFINITY); | 999 VisiblePosition visiblePos = createVisiblePositionDeprecated(pos, VP_DEFAULT
_AFFINITY); |
| 1000 VisiblePosition visibleParagraphStart = startOfParagraph(visiblePos); | 1000 VisiblePosition visibleParagraphStart = startOfParagraphDeprecated(visiblePo
s); |
| 1001 VisiblePosition visibleParagraphEnd = endOfParagraph(visiblePos); | 1001 VisiblePosition visibleParagraphEnd = endOfParagraphDeprecated(visiblePos); |
| 1002 VisiblePosition next = nextPositionOf(visibleParagraphEnd); | 1002 VisiblePosition next = nextPositionOf(visibleParagraphEnd); |
| 1003 VisiblePosition visibleEnd = next.isNotNull() ? next : visibleParagraphEnd; | 1003 VisiblePosition visibleEnd = next.isNotNull() ? next : visibleParagraphEnd; |
| 1004 | 1004 |
| 1005 Position upstreamStart = mostBackwardCaretPosition(visibleParagraphStart.dee
pEquivalent()); | 1005 Position upstreamStart = mostBackwardCaretPosition(visibleParagraphStart.dee
pEquivalent()); |
| 1006 Position upstreamEnd = mostBackwardCaretPosition(visibleEnd.deepEquivalent()
); | 1006 Position upstreamEnd = mostBackwardCaretPosition(visibleEnd.deepEquivalent()
); |
| 1007 | 1007 |
| 1008 // If there are no VisiblePositions in the same block as pos then | 1008 // If there are no VisiblePositions in the same block as pos then |
| 1009 // upstreamStart will be outside the paragraph | 1009 // upstreamStart will be outside the paragraph |
| 1010 if (comparePositions(pos, upstreamStart) < 0) | 1010 if (comparePositions(pos, upstreamStart) < 0) |
| 1011 return nullptr; | 1011 return nullptr; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1040 | 1040 |
| 1041 HTMLElement* newBlock = insertNewDefaultParagraphElementAt(upstreamStart, ed
itingState); | 1041 HTMLElement* newBlock = insertNewDefaultParagraphElementAt(upstreamStart, ed
itingState); |
| 1042 if (editingState->isAborted()) | 1042 if (editingState->isAborted()) |
| 1043 return nullptr; | 1043 return nullptr; |
| 1044 | 1044 |
| 1045 bool endWasBr = isHTMLBRElement(*visibleParagraphEnd.deepEquivalent().anchor
Node()); | 1045 bool endWasBr = isHTMLBRElement(*visibleParagraphEnd.deepEquivalent().anchor
Node()); |
| 1046 | 1046 |
| 1047 // Inserting default paragraph element can change visible position. We | 1047 // Inserting default paragraph element can change visible position. We |
| 1048 // should update visible positions before use them. | 1048 // should update visible positions before use them. |
| 1049 visiblePos = createVisiblePositionDeprecated(pos, VP_DEFAULT_AFFINITY); | 1049 visiblePos = createVisiblePositionDeprecated(pos, VP_DEFAULT_AFFINITY); |
| 1050 visibleParagraphStart = startOfParagraph(visiblePos); | 1050 visibleParagraphStart = startOfParagraphDeprecated(visiblePos); |
| 1051 visibleParagraphEnd = endOfParagraph(visiblePos); | 1051 visibleParagraphEnd = endOfParagraphDeprecated(visiblePos); |
| 1052 moveParagraphs(visibleParagraphStart, visibleParagraphEnd, VisiblePosition::
firstPositionInNode(newBlock), editingState); | 1052 moveParagraphs(visibleParagraphStart, visibleParagraphEnd, VisiblePosition::
firstPositionInNode(newBlock), editingState); |
| 1053 if (editingState->isAborted()) | 1053 if (editingState->isAborted()) |
| 1054 return nullptr; | 1054 return nullptr; |
| 1055 | 1055 |
| 1056 if (newBlock->lastChild() && isHTMLBRElement(*newBlock->lastChild()) && !end
WasBr) { | 1056 if (newBlock->lastChild() && isHTMLBRElement(*newBlock->lastChild()) && !end
WasBr) { |
| 1057 removeNode(newBlock->lastChild(), editingState); | 1057 removeNode(newBlock->lastChild(), editingState); |
| 1058 if (editingState->isAborted()) | 1058 if (editingState->isAborted()) |
| 1059 return nullptr; | 1059 return nullptr; |
| 1060 } | 1060 } |
| 1061 | 1061 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1169 // There are bugs in deletion when it removes a fully selected table/list. | 1169 // There are bugs in deletion when it removes a fully selected table/list. |
| 1170 // It expands and removes the entire table/list, but will let content | 1170 // It expands and removes the entire table/list, but will let content |
| 1171 // before and after the table/list collapse onto one line. | 1171 // before and after the table/list collapse onto one line. |
| 1172 // Deleting a paragraph will leave a placeholder. Remove it (and prune | 1172 // Deleting a paragraph will leave a placeholder. Remove it (and prune |
| 1173 // empty or unrendered parents). | 1173 // empty or unrendered parents). |
| 1174 | 1174 |
| 1175 void CompositeEditCommand::cleanupAfterDeletion(EditingState* editingState, Visi
blePosition destination) | 1175 void CompositeEditCommand::cleanupAfterDeletion(EditingState* editingState, Visi
blePosition destination) |
| 1176 { | 1176 { |
| 1177 VisiblePosition caretAfterDelete = endingSelection().visibleStart(); | 1177 VisiblePosition caretAfterDelete = endingSelection().visibleStart(); |
| 1178 Node* destinationNode = destination.deepEquivalent().anchorNode(); | 1178 Node* destinationNode = destination.deepEquivalent().anchorNode(); |
| 1179 if (caretAfterDelete.deepEquivalent() != destination.deepEquivalent() && isS
tartOfParagraph(caretAfterDelete) && isEndOfParagraph(caretAfterDelete)) { | 1179 if (caretAfterDelete.deepEquivalent() != destination.deepEquivalent() && isS
tartOfParagraphDeprecated(caretAfterDelete) && isEndOfParagraphDeprecated(caretA
fterDelete)) { |
| 1180 // Note: We want the rightmost candidate. | 1180 // Note: We want the rightmost candidate. |
| 1181 Position position = mostForwardCaretPosition(caretAfterDelete.deepEquiva
lent()); | 1181 Position position = mostForwardCaretPosition(caretAfterDelete.deepEquiva
lent()); |
| 1182 Node* node = position.anchorNode(); | 1182 Node* node = position.anchorNode(); |
| 1183 | 1183 |
| 1184 // Bail if we'd remove an ancestor of our destination. | 1184 // Bail if we'd remove an ancestor of our destination. |
| 1185 if (destinationNode && destinationNode->isDescendantOf(node)) | 1185 if (destinationNode && destinationNode->isDescendantOf(node)) |
| 1186 return; | 1186 return; |
| 1187 | 1187 |
| 1188 // Normally deletion will leave a br as a placeholder. | 1188 // Normally deletion will leave a br as a placeholder. |
| 1189 if (isHTMLBRElement(*node)) { | 1189 if (isHTMLBRElement(*node)) { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1259 // TODO(yosin): We should abort when |beforeParagraph| is a orphan when | 1259 // TODO(yosin): We should abort when |beforeParagraph| is a orphan when |
| 1260 // we have a sample. | 1260 // we have a sample. |
| 1261 beforeParagraph = createVisiblePositionDeprecated(beforeParagraph.deepEquiva
lent()); | 1261 beforeParagraph = createVisiblePositionDeprecated(beforeParagraph.deepEquiva
lent()); |
| 1262 if (afterParagraph.isOrphan()) { | 1262 if (afterParagraph.isOrphan()) { |
| 1263 editingState->abort(); | 1263 editingState->abort(); |
| 1264 return; | 1264 return; |
| 1265 } | 1265 } |
| 1266 afterParagraph = createVisiblePositionDeprecated(afterParagraph.deepEquivale
nt()); | 1266 afterParagraph = createVisiblePositionDeprecated(afterParagraph.deepEquivale
nt()); |
| 1267 | 1267 |
| 1268 if (beforeParagraph.isNotNull() && !isDisplayInsideTable(beforeParagraph.dee
pEquivalent().anchorNode()) | 1268 if (beforeParagraph.isNotNull() && !isDisplayInsideTable(beforeParagraph.dee
pEquivalent().anchorNode()) |
| 1269 && ((!isEndOfParagraph(beforeParagraph) && !isStartOfParagraph(beforePar
agraph)) || beforeParagraph.deepEquivalent() == afterParagraph.deepEquivalent())
) { | 1269 && ((!isEndOfParagraphDeprecated(beforeParagraph) && !isStartOfParagraph
Deprecated(beforeParagraph)) || beforeParagraph.deepEquivalent() == afterParagra
ph.deepEquivalent())) { |
| 1270 // FIXME: Trim text between beforeParagraph and afterParagraph if they a
ren't equal. | 1270 // FIXME: Trim text between beforeParagraph and afterParagraph if they a
ren't equal. |
| 1271 insertNodeAt(HTMLBRElement::create(document()), beforeParagraph.deepEqui
valent(), editingState); | 1271 insertNodeAt(HTMLBRElement::create(document()), beforeParagraph.deepEqui
valent(), editingState); |
| 1272 } | 1272 } |
| 1273 } | 1273 } |
| 1274 | 1274 |
| 1275 void CompositeEditCommand::moveParagraph(const VisiblePosition& startOfParagraph
ToMove, const VisiblePosition& endOfParagraphToMove, const VisiblePosition& dest
ination, EditingState* editingState, ShouldPreserveSelection shouldPreserveSelec
tion, ShouldPreserveStyle shouldPreserveStyle, Node* constrainingAncestor) | 1275 void CompositeEditCommand::moveParagraph(const VisiblePosition& startOfParagraph
ToMove, const VisiblePosition& endOfParagraphToMove, const VisiblePosition& dest
ination, EditingState* editingState, ShouldPreserveSelection shouldPreserveSelec
tion, ShouldPreserveStyle shouldPreserveStyle, Node* constrainingAncestor) |
| 1276 { | 1276 { |
| 1277 DCHECK(isStartOfParagraph(startOfParagraphToMove)) << startOfParagraphToMove
; | 1277 DCHECK(isStartOfParagraphDeprecated(startOfParagraphToMove)) << startOfParag
raphToMove; |
| 1278 DCHECK(isEndOfParagraph(endOfParagraphToMove)) << endOfParagraphToMove; | 1278 DCHECK(isEndOfParagraphDeprecated(endOfParagraphToMove)) << endOfParagraphTo
Move; |
| 1279 moveParagraphs(startOfParagraphToMove, endOfParagraphToMove, destination, ed
itingState, shouldPreserveSelection, shouldPreserveStyle, constrainingAncestor); | 1279 moveParagraphs(startOfParagraphToMove, endOfParagraphToMove, destination, ed
itingState, shouldPreserveSelection, shouldPreserveStyle, constrainingAncestor); |
| 1280 } | 1280 } |
| 1281 | 1281 |
| 1282 void CompositeEditCommand::moveParagraphs(const VisiblePosition& startOfParagrap
hToMove, const VisiblePosition& endOfParagraphToMove, const VisiblePosition& des
tination, EditingState* editingState, ShouldPreserveSelection shouldPreserveSele
ction, ShouldPreserveStyle shouldPreserveStyle, Node* constrainingAncestor) | 1282 void CompositeEditCommand::moveParagraphs(const VisiblePosition& startOfParagrap
hToMove, const VisiblePosition& endOfParagraphToMove, const VisiblePosition& des
tination, EditingState* editingState, ShouldPreserveSelection shouldPreserveSele
ction, ShouldPreserveStyle shouldPreserveStyle, Node* constrainingAncestor) |
| 1283 { | 1283 { |
| 1284 if (startOfParagraphToMove.deepEquivalent() == destination.deepEquivalent()
|| startOfParagraphToMove.isNull()) | 1284 if (startOfParagraphToMove.deepEquivalent() == destination.deepEquivalent()
|| startOfParagraphToMove.isNull()) |
| 1285 return; | 1285 return; |
| 1286 | 1286 |
| 1287 int startIndex = -1; | 1287 int startIndex = -1; |
| 1288 int endIndex = -1; | 1288 int endIndex = -1; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1352 | 1352 |
| 1353 // Add a br if pruning an empty block level element caused a collapse. For e
xample: | 1353 // Add a br if pruning an empty block level element caused a collapse. For e
xample: |
| 1354 // foo^ | 1354 // foo^ |
| 1355 // <div>bar</div> | 1355 // <div>bar</div> |
| 1356 // baz | 1356 // baz |
| 1357 // Imagine moving 'bar' to ^. 'bar' will be deleted and its div pruned. That
would | 1357 // Imagine moving 'bar' to ^. 'bar' will be deleted and its div pruned. That
would |
| 1358 // cause 'baz' to collapse onto the line with 'foobar' unless we insert a br
. | 1358 // cause 'baz' to collapse onto the line with 'foobar' unless we insert a br
. |
| 1359 // Must recononicalize these two VisiblePositions after the pruning above. | 1359 // Must recononicalize these two VisiblePositions after the pruning above. |
| 1360 VisiblePosition beforeParagraph = createVisiblePositionDeprecated(beforePara
graphPosition.position()); | 1360 VisiblePosition beforeParagraph = createVisiblePositionDeprecated(beforePara
graphPosition.position()); |
| 1361 VisiblePosition afterParagraph = createVisiblePositionDeprecated(afterParagr
aphPosition.position()); | 1361 VisiblePosition afterParagraph = createVisiblePositionDeprecated(afterParagr
aphPosition.position()); |
| 1362 if (beforeParagraph.isNotNull() && (!isEndOfParagraph(beforeParagraph) || be
foreParagraph.deepEquivalent() == afterParagraph.deepEquivalent())) { | 1362 if (beforeParagraph.isNotNull() && (!isEndOfParagraphDeprecated(beforeParagr
aph) || beforeParagraph.deepEquivalent() == afterParagraph.deepEquivalent())) { |
| 1363 // FIXME: Trim text between beforeParagraph and afterParagraph if they a
ren't equal. | 1363 // FIXME: Trim text between beforeParagraph and afterParagraph if they a
ren't equal. |
| 1364 insertNodeAt(HTMLBRElement::create(document()), beforeParagraph.deepEqui
valent(), editingState); | 1364 insertNodeAt(HTMLBRElement::create(document()), beforeParagraph.deepEqui
valent(), editingState); |
| 1365 if (editingState->isAborted()) | 1365 if (editingState->isAborted()) |
| 1366 return; | 1366 return; |
| 1367 // Need an updateLayout here in case inserting the br has split a text n
ode. | 1367 // Need an updateLayout here in case inserting the br has split a text n
ode. |
| 1368 document().updateStyleAndLayoutIgnorePendingStylesheets(); | 1368 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| 1369 } | 1369 } |
| 1370 | 1370 |
| 1371 destinationIndex = TextIterator::rangeLength(Position::firstPositionInNode(d
ocument().documentElement()), destination.toParentAnchoredPosition(), true); | 1371 destinationIndex = TextIterator::rangeLength(Position::firstPositionInNode(d
ocument().documentElement()), destination.toParentAnchoredPosition(), true); |
| 1372 | 1372 |
| 1373 VisibleSelection destinationSelection(destination, originalIsDirectional); | 1373 VisibleSelection destinationSelection(destination, originalIsDirectional); |
| 1374 if (endingSelection().isNone()) { | 1374 if (endingSelection().isNone()) { |
| 1375 // We abort executing command since |destination| becomes invisible. | 1375 // We abort executing command since |destination| becomes invisible. |
| 1376 editingState->abort(); | 1376 editingState->abort(); |
| 1377 return; | 1377 return; |
| 1378 } | 1378 } |
| 1379 setEndingSelection(destinationSelection); | 1379 setEndingSelection(destinationSelection); |
| 1380 ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::S
electReplacement | ReplaceSelectionCommand::MovingParagraph; | 1380 ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::S
electReplacement | ReplaceSelectionCommand::MovingParagraph; |
| 1381 if (shouldPreserveStyle == DoNotPreserveStyle) | 1381 if (shouldPreserveStyle == DoNotPreserveStyle) |
| 1382 options |= ReplaceSelectionCommand::MatchStyle; | 1382 options |= ReplaceSelectionCommand::MatchStyle; |
| 1383 applyCommandToComposite(ReplaceSelectionCommand::create(document(), fragment
, options), editingState); | 1383 applyCommandToComposite(ReplaceSelectionCommand::create(document(), fragment
, options), editingState); |
| 1384 if (editingState->isAborted()) | 1384 if (editingState->isAborted()) |
| 1385 return; | 1385 return; |
| 1386 | 1386 |
| 1387 document().frame()->spellChecker().markMisspellingsAndBadGrammarForMovingPar
agraphs(endingSelection()); | 1387 document().frame()->spellChecker().markMisspellingsAndBadGrammarForMovingPar
agraphs(endingSelection()); |
| 1388 | 1388 |
| 1389 // If the selection is in an empty paragraph, restore styles from the old em
pty paragraph to the new empty paragraph. | 1389 // If the selection is in an empty paragraph, restore styles from the old em
pty paragraph to the new empty paragraph. |
| 1390 bool selectionIsEmptyParagraph = endingSelection().isCaret() && isStartOfPar
agraph(endingSelection().visibleStart()) && isEndOfParagraph(endingSelection().v
isibleStart()); | 1390 bool selectionIsEmptyParagraph = endingSelection().isCaret() && isStartOfPar
agraphDeprecated(endingSelection().visibleStart()) && isEndOfParagraphDeprecated
(endingSelection().visibleStart()); |
| 1391 if (styleInEmptyParagraph && selectionIsEmptyParagraph) { | 1391 if (styleInEmptyParagraph && selectionIsEmptyParagraph) { |
| 1392 applyStyle(styleInEmptyParagraph, editingState); | 1392 applyStyle(styleInEmptyParagraph, editingState); |
| 1393 if (editingState->isAborted()) | 1393 if (editingState->isAborted()) |
| 1394 return; | 1394 return; |
| 1395 } | 1395 } |
| 1396 | 1396 |
| 1397 if (shouldPreserveSelection == DoNotPreserveSelection || startIndex == -1) | 1397 if (shouldPreserveSelection == DoNotPreserveSelection || startIndex == -1) |
| 1398 return; | 1398 return; |
| 1399 Element* documentElement = document().documentElement(); | 1399 Element* documentElement = document().documentElement(); |
| 1400 if (!documentElement) | 1400 if (!documentElement) |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1504 bool CompositeEditCommand::breakOutOfEmptyMailBlockquotedParagraph(EditingState*
editingState) | 1504 bool CompositeEditCommand::breakOutOfEmptyMailBlockquotedParagraph(EditingState*
editingState) |
| 1505 { | 1505 { |
| 1506 if (!endingSelection().isCaret()) | 1506 if (!endingSelection().isCaret()) |
| 1507 return false; | 1507 return false; |
| 1508 | 1508 |
| 1509 VisiblePosition caret = endingSelection().visibleStart(); | 1509 VisiblePosition caret = endingSelection().visibleStart(); |
| 1510 HTMLQuoteElement* highestBlockquote = toHTMLQuoteElement(highestEnclosingNod
eOfType(caret.deepEquivalent(), &isMailHTMLBlockquoteElement)); | 1510 HTMLQuoteElement* highestBlockquote = toHTMLQuoteElement(highestEnclosingNod
eOfType(caret.deepEquivalent(), &isMailHTMLBlockquoteElement)); |
| 1511 if (!highestBlockquote) | 1511 if (!highestBlockquote) |
| 1512 return false; | 1512 return false; |
| 1513 | 1513 |
| 1514 if (!isStartOfParagraph(caret) || !isEndOfParagraph(caret)) | 1514 if (!isStartOfParagraphDeprecated(caret) || !isEndOfParagraphDeprecated(care
t)) |
| 1515 return false; | 1515 return false; |
| 1516 | 1516 |
| 1517 VisiblePosition previous = previousPositionOf(caret, CannotCrossEditingBound
ary); | 1517 VisiblePosition previous = previousPositionOf(caret, CannotCrossEditingBound
ary); |
| 1518 // Only move forward if there's nothing before the caret, or if there's unqu
oted content before it. | 1518 // Only move forward if there's nothing before the caret, or if there's unqu
oted content before it. |
| 1519 if (enclosingNodeOfType(previous.deepEquivalent(), &isMailHTMLBlockquoteElem
ent)) | 1519 if (enclosingNodeOfType(previous.deepEquivalent(), &isMailHTMLBlockquoteElem
ent)) |
| 1520 return false; | 1520 return false; |
| 1521 | 1521 |
| 1522 HTMLBRElement* br = HTMLBRElement::create(document()); | 1522 HTMLBRElement* br = HTMLBRElement::create(document()); |
| 1523 // We want to replace this quoted paragraph with an unquoted one, so insert
a br | 1523 // We want to replace this quoted paragraph with an unquoted one, so insert
a br |
| 1524 // to hold the caret before the highest blockquote. | 1524 // to hold the caret before the highest blockquote. |
| 1525 insertNodeBefore(br, highestBlockquote, editingState); | 1525 insertNodeBefore(br, highestBlockquote, editingState); |
| 1526 if (editingState->isAborted()) | 1526 if (editingState->isAborted()) |
| 1527 return false; | 1527 return false; |
| 1528 VisiblePosition atBR = VisiblePosition::beforeNode(br); | 1528 VisiblePosition atBR = VisiblePosition::beforeNode(br); |
| 1529 // If the br we inserted collapsed, for example foo<br><blockquote>...</bloc
kquote>, insert | 1529 // If the br we inserted collapsed, for example foo<br><blockquote>...</bloc
kquote>, insert |
| 1530 // a second one. | 1530 // a second one. |
| 1531 if (!isStartOfParagraph(atBR)) { | 1531 if (!isStartOfParagraphDeprecated(atBR)) { |
| 1532 insertNodeBefore(HTMLBRElement::create(document()), br, editingState); | 1532 insertNodeBefore(HTMLBRElement::create(document()), br, editingState); |
| 1533 if (editingState->isAborted()) | 1533 if (editingState->isAborted()) |
| 1534 return false; | 1534 return false; |
| 1535 } | 1535 } |
| 1536 setEndingSelection(VisibleSelection(atBR, endingSelection().isDirectional())
); | 1536 setEndingSelection(VisibleSelection(atBR, endingSelection().isDirectional())
); |
| 1537 | 1537 |
| 1538 // If this is an empty paragraph there must be a line break here. | 1538 // If this is an empty paragraph there must be a line break here. |
| 1539 if (!lineBreakExistsAtVisiblePosition(caret)) | 1539 if (!lineBreakExistsAtVisiblePosition(caret)) |
| 1540 return false; | 1540 return false; |
| 1541 | 1541 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1657 } | 1657 } |
| 1658 | 1658 |
| 1659 DEFINE_TRACE(CompositeEditCommand) | 1659 DEFINE_TRACE(CompositeEditCommand) |
| 1660 { | 1660 { |
| 1661 visitor->trace(m_commands); | 1661 visitor->trace(m_commands); |
| 1662 visitor->trace(m_composition); | 1662 visitor->trace(m_composition); |
| 1663 EditCommand::trace(visitor); | 1663 EditCommand::trace(visitor); |
| 1664 } | 1664 } |
| 1665 | 1665 |
| 1666 } // namespace blink | 1666 } // namespace blink |
| OLD | NEW |