OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1322 if (m_endOfInsertedContent.isOrphan()) | 1322 if (m_endOfInsertedContent.isOrphan()) |
1323 m_endOfInsertedContent = mostBackwardCaretPosition(endingSelection()
.visibleEnd().deepEquivalent()); | 1323 m_endOfInsertedContent = mostBackwardCaretPosition(endingSelection()
.visibleEnd().deepEquivalent()); |
1324 } | 1324 } |
1325 | 1325 |
1326 Position lastPositionToSelect; | 1326 Position lastPositionToSelect; |
1327 if (fragment.hasInterchangeNewlineAtEnd()) { | 1327 if (fragment.hasInterchangeNewlineAtEnd()) { |
1328 VisiblePosition endOfInsertedContent = positionAtEndOfInsertedContent(); | 1328 VisiblePosition endOfInsertedContent = positionAtEndOfInsertedContent(); |
1329 VisiblePosition next = nextPositionOf(endOfInsertedContent, CannotCrossE
ditingBoundary); | 1329 VisiblePosition next = nextPositionOf(endOfInsertedContent, CannotCrossE
ditingBoundary); |
1330 | 1330 |
1331 if (selectionEndWasEndOfParagraph || !isEndOfParagraph(endOfInsertedCont
ent) || next.isNull()) { | 1331 if (selectionEndWasEndOfParagraph || !isEndOfParagraph(endOfInsertedCont
ent) || next.isNull()) { |
1332 if (!isStartOfParagraph(endOfInsertedContent)) { | 1332 if (HTMLTextFormControlElement* textControl = enclosingTextFormContr
ol(currentRoot)) { |
| 1333 if (!insertedNodes.lastLeafInserted()->nextSibling()) { |
| 1334 insertNodeAfter(textControl->createPlaceholderBreakElement()
, insertedNodes.lastLeafInserted(), editingState); |
| 1335 if (editingState->isAborted()) |
| 1336 return; |
| 1337 } |
| 1338 setEndingSelection(createVisiblePosition(positionAfterNode(inser
tedNodes.lastLeafInserted()))); |
| 1339 // Select up to the paragraph separator that was added. |
| 1340 lastPositionToSelect = endingSelection().visibleStart().deepEqui
valent(); |
| 1341 } else if (!isStartOfParagraph(endOfInsertedContent)) { |
1333 setEndingSelection(endOfInsertedContent); | 1342 setEndingSelection(endOfInsertedContent); |
1334 Element* enclosingBlockElement = enclosingBlock(endOfInsertedCon
tent.deepEquivalent().anchorNode()); | 1343 Element* enclosingBlockElement = enclosingBlock(endOfInsertedCon
tent.deepEquivalent().anchorNode()); |
1335 if (isListItem(enclosingBlockElement)) { | 1344 if (isListItem(enclosingBlockElement)) { |
1336 RefPtrWillBeRawPtr<HTMLLIElement> newListItem = HTMLLIElemen
t::create(document()); | 1345 RefPtrWillBeRawPtr<HTMLLIElement> newListItem = HTMLLIElemen
t::create(document()); |
1337 insertNodeAfter(newListItem, enclosingBlockElement, editingS
tate); | 1346 insertNodeAfter(newListItem, enclosingBlockElement, editingS
tate); |
1338 if (editingState->isAborted()) | 1347 if (editingState->isAborted()) |
1339 return; | 1348 return; |
1340 setEndingSelection(createVisiblePosition(firstPositionInNode
(newListItem.get()))); | 1349 setEndingSelection(createVisiblePosition(firstPositionInNode
(newListItem.get()))); |
1341 } else if (HTMLTextFormControlElement* textControl = enclosingTe
xtFormControl(enclosingBlockElement)) { | |
1342 insertNodeAfter(textControl->createPlaceholderBreakElement()
, insertedNodes.lastLeafInserted(), editingState); | |
1343 if (editingState->isAborted()) | |
1344 return; | |
1345 setEndingSelection(createVisiblePosition(positionAfterNode(i
nsertedNodes.lastLeafInserted()))); | |
1346 } else { | 1350 } else { |
1347 // Use a default paragraph element (a plain div) for the emp
ty paragraph, using the last paragraph | 1351 // Use a default paragraph element (a plain div) for the emp
ty paragraph, using the last paragraph |
1348 // block's style seems to annoy users. | 1352 // block's style seems to annoy users. |
1349 insertParagraphSeparator(editingState, true, !startIsInsideM
ailBlockquote && highestEnclosingNodeOfType(endOfInsertedContent.deepEquivalent(
), | 1353 insertParagraphSeparator(editingState, true, !startIsInsideM
ailBlockquote && highestEnclosingNodeOfType(endOfInsertedContent.deepEquivalent(
), |
1350 isMailHTMLBlockquoteElement, CannotCrossEditingBoundary,
insertedNodes.firstNodeInserted()->parentNode())); | 1354 isMailHTMLBlockquoteElement, CannotCrossEditingBoundary,
insertedNodes.firstNodeInserted()->parentNode())); |
1351 if (editingState->isAborted()) | 1355 if (editingState->isAborted()) |
1352 return; | 1356 return; |
1353 } | 1357 } |
1354 | 1358 |
1355 // Select up to the paragraph separator that was added. | 1359 // Select up to the paragraph separator that was added. |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1699 visitor->trace(m_startOfInsertedContent); | 1703 visitor->trace(m_startOfInsertedContent); |
1700 visitor->trace(m_endOfInsertedContent); | 1704 visitor->trace(m_endOfInsertedContent); |
1701 visitor->trace(m_insertionStyle); | 1705 visitor->trace(m_insertionStyle); |
1702 visitor->trace(m_documentFragment); | 1706 visitor->trace(m_documentFragment); |
1703 visitor->trace(m_startOfInsertedRange); | 1707 visitor->trace(m_startOfInsertedRange); |
1704 visitor->trace(m_endOfInsertedRange); | 1708 visitor->trace(m_endOfInsertedRange); |
1705 CompositeEditCommand::trace(visitor); | 1709 CompositeEditCommand::trace(visitor); |
1706 } | 1710 } |
1707 | 1711 |
1708 } // namespace blink | 1712 } // namespace blink |
OLD | NEW |