| 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 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 | 913 |
| 914 return EditingStyle::elementIsStyledSpanOrHTMLEquivalent(element); | 914 return EditingStyle::elementIsStyledSpanOrHTMLEquivalent(element); |
| 915 } | 915 } |
| 916 | 916 |
| 917 static inline HTMLElement* elementToSplitToAvoidPastingIntoInlineElementsWithSty
le(const Position& insertionPos) | 917 static inline HTMLElement* elementToSplitToAvoidPastingIntoInlineElementsWithSty
le(const Position& insertionPos) |
| 918 { | 918 { |
| 919 Element* containingBlock = enclosingBlock(insertionPos.computeContainerNode(
)); | 919 Element* containingBlock = enclosingBlock(insertionPos.computeContainerNode(
)); |
| 920 return toHTMLElement(highestEnclosingNodeOfType(insertionPos, isInlineHTMLEl
ementWithStyle, CannotCrossEditingBoundary, containingBlock)); | 920 return toHTMLElement(highestEnclosingNodeOfType(insertionPos, isInlineHTMLEl
ementWithStyle, CannotCrossEditingBoundary, containingBlock)); |
| 921 } | 921 } |
| 922 | 922 |
| 923 void ReplaceSelectionCommand::doApply(EditingState*) | 923 void ReplaceSelectionCommand::doApply(EditingState* editingState) |
| 924 { | 924 { |
| 925 const VisibleSelection selection = endingSelection(); | 925 const VisibleSelection selection = endingSelection(); |
| 926 ASSERT(selection.isCaretOrRange()); | 926 ASSERT(selection.isCaretOrRange()); |
| 927 ASSERT(selection.start().anchorNode()); | 927 ASSERT(selection.start().anchorNode()); |
| 928 if (!selection.isNonOrphanedCaretOrRange() || !selection.start().anchorNode(
)) | 928 if (!selection.isNonOrphanedCaretOrRange() || !selection.start().anchorNode(
)) |
| 929 return; | 929 return; |
| 930 | 930 |
| 931 if (!selection.rootEditableElement()) | 931 if (!selection.rootEditableElement()) |
| 932 return; | 932 return; |
| 933 | 933 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 if (selection.isRange()) { | 967 if (selection.isRange()) { |
| 968 // When the end of the selection being pasted into is at the end of a pa
ragraph, and that selection | 968 // When the end of the selection being pasted into is at the end of a pa
ragraph, and that selection |
| 969 // spans multiple blocks, not merging may leave an empty line. | 969 // spans multiple blocks, not merging may leave an empty line. |
| 970 // When the start of the selection being pasted into is at the start of
a block, not merging | 970 // When the start of the selection being pasted into is at the start of
a block, not merging |
| 971 // will leave hanging block(s). | 971 // will leave hanging block(s). |
| 972 // Merge blocks if the start of the selection was in a Mail blockquote,
since we handle | 972 // Merge blocks if the start of the selection was in a Mail blockquote,
since we handle |
| 973 // that case specially to prevent nesting. | 973 // that case specially to prevent nesting. |
| 974 bool mergeBlocksAfterDelete = startIsInsideMailBlockquote || isEndOfPara
graph(visibleEnd) || isStartOfBlock(visibleStart); | 974 bool mergeBlocksAfterDelete = startIsInsideMailBlockquote || isEndOfPara
graph(visibleEnd) || isStartOfBlock(visibleStart); |
| 975 // FIXME: We should only expand to include fully selected special elemen
ts if we are copying a | 975 // FIXME: We should only expand to include fully selected special elemen
ts if we are copying a |
| 976 // selection and pasting it on top of itself. | 976 // selection and pasting it on top of itself. |
| 977 deleteSelection(ASSERT_NO_EDITING_ABORT, false, mergeBlocksAfterDelete,
false); | 977 deleteSelection(editingState, false, mergeBlocksAfterDelete, false); |
| 978 if (editingState->isAborted()) |
| 979 return; |
| 978 if (fragment.hasInterchangeNewlineAtStart()) { | 980 if (fragment.hasInterchangeNewlineAtStart()) { |
| 979 VisiblePosition startAfterDelete = endingSelection().visibleStart(); | 981 VisiblePosition startAfterDelete = endingSelection().visibleStart(); |
| 980 if (isEndOfParagraph(startAfterDelete) && !isStartOfParagraph(startA
fterDelete) && !isEndOfEditableOrNonEditableContent(startAfterDelete)) | 982 if (isEndOfParagraph(startAfterDelete) && !isStartOfParagraph(startA
fterDelete) && !isEndOfEditableOrNonEditableContent(startAfterDelete)) |
| 981 setEndingSelection(nextPositionOf(startAfterDelete)); | 983 setEndingSelection(nextPositionOf(startAfterDelete)); |
| 982 else | 984 else |
| 983 insertParagraphSeparator(); | 985 insertParagraphSeparator(); |
| 984 } | 986 } |
| 985 } else { | 987 } else { |
| 986 ASSERT(selection.isCaret()); | 988 ASSERT(selection.isCaret()); |
| 987 if (fragment.hasInterchangeNewlineAtStart()) { | 989 if (fragment.hasInterchangeNewlineAtStart()) { |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1564 visitor->trace(m_startOfInsertedContent); | 1566 visitor->trace(m_startOfInsertedContent); |
| 1565 visitor->trace(m_endOfInsertedContent); | 1567 visitor->trace(m_endOfInsertedContent); |
| 1566 visitor->trace(m_insertionStyle); | 1568 visitor->trace(m_insertionStyle); |
| 1567 visitor->trace(m_documentFragment); | 1569 visitor->trace(m_documentFragment); |
| 1568 visitor->trace(m_startOfInsertedRange); | 1570 visitor->trace(m_startOfInsertedRange); |
| 1569 visitor->trace(m_endOfInsertedRange); | 1571 visitor->trace(m_endOfInsertedRange); |
| 1570 CompositeEditCommand::trace(visitor); | 1572 CompositeEditCommand::trace(visitor); |
| 1571 } | 1573 } |
| 1572 | 1574 |
| 1573 } // namespace blink | 1575 } // namespace blink |
| OLD | NEW |