| 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 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1180 VisiblePosition visibleEnd = endingSelection().visibleEnd(); | 1180 VisiblePosition visibleEnd = endingSelection().visibleEnd(); |
| 1181 | 1181 |
| 1182 bool startAfterParagraph = comparePositions(visibleStart, endOfParagraph
ToMove) > 0; | 1182 bool startAfterParagraph = comparePositions(visibleStart, endOfParagraph
ToMove) > 0; |
| 1183 bool endBeforeParagraph = comparePositions(visibleEnd, startOfParagraphT
oMove) < 0; | 1183 bool endBeforeParagraph = comparePositions(visibleEnd, startOfParagraphT
oMove) < 0; |
| 1184 | 1184 |
| 1185 if (!startAfterParagraph && !endBeforeParagraph) { | 1185 if (!startAfterParagraph && !endBeforeParagraph) { |
| 1186 bool startInParagraph = comparePositions(visibleStart, startOfParagr
aphToMove) >= 0; | 1186 bool startInParagraph = comparePositions(visibleStart, startOfParagr
aphToMove) >= 0; |
| 1187 bool endInParagraph = comparePositions(visibleEnd, endOfParagraphToM
ove) <= 0; | 1187 bool endInParagraph = comparePositions(visibleEnd, endOfParagraphToM
ove) <= 0; |
| 1188 | 1188 |
| 1189 startIndex = 0; | 1189 startIndex = 0; |
| 1190 if (startInParagraph) { | 1190 if (startInParagraph) |
| 1191 RefPtrWillBeRawPtr<Range> startRange = Range::create(document(),
startOfParagraphToMove.deepEquivalent().parentAnchoredEquivalent(), visibleStar
t.deepEquivalent().parentAnchoredEquivalent()); | 1191 startIndex = TextIterator::rangeLength(startOfParagraphToMove.to
ParentAnchoredPosition(), visibleStart.toParentAnchoredPosition(), true); |
| 1192 startIndex = TextIterator::rangeLength(startRange.get(), true); | |
| 1193 } | |
| 1194 | 1192 |
| 1195 endIndex = 0; | 1193 endIndex = 0; |
| 1196 if (endInParagraph) { | 1194 if (endInParagraph) |
| 1197 RefPtrWillBeRawPtr<Range> endRange = Range::create(document(), s
tartOfParagraphToMove.deepEquivalent().parentAnchoredEquivalent(), visibleEnd.de
epEquivalent().parentAnchoredEquivalent()); | 1195 endIndex = TextIterator::rangeLength(startOfParagraphToMove.toPa
rentAnchoredPosition(), visibleEnd.toParentAnchoredPosition(), true); |
| 1198 endIndex = TextIterator::rangeLength(endRange.get(), true); | |
| 1199 } | |
| 1200 } | 1196 } |
| 1201 } | 1197 } |
| 1202 | 1198 |
| 1203 VisiblePosition beforeParagraph = startOfParagraphToMove.previous(CannotCros
sEditingBoundary); | 1199 VisiblePosition beforeParagraph = startOfParagraphToMove.previous(CannotCros
sEditingBoundary); |
| 1204 VisiblePosition afterParagraph(endOfParagraphToMove.next(CannotCrossEditingB
oundary)); | 1200 VisiblePosition afterParagraph(endOfParagraphToMove.next(CannotCrossEditingB
oundary)); |
| 1205 | 1201 |
| 1206 // We upstream() the end and downstream() the start so that we don't include
collapsed whitespace in the move. | 1202 // We upstream() the end and downstream() the start so that we don't include
collapsed whitespace in the move. |
| 1207 // When we paste a fragment, spaces after the end and before the start are t
reated as though they were rendered. | 1203 // When we paste a fragment, spaces after the end and before the start are t
reated as though they were rendered. |
| 1208 Position start = startOfParagraphToMove.deepEquivalent().downstream(); | 1204 Position start = startOfParagraphToMove.deepEquivalent().downstream(); |
| 1209 Position end = endOfParagraphToMove.deepEquivalent().upstream(); | 1205 Position end = endOfParagraphToMove.deepEquivalent().upstream(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1248 // Must recononicalize these two VisiblePositions after the pruning above. | 1244 // Must recononicalize these two VisiblePositions after the pruning above. |
| 1249 beforeParagraph = VisiblePosition(beforeParagraph.deepEquivalent()); | 1245 beforeParagraph = VisiblePosition(beforeParagraph.deepEquivalent()); |
| 1250 afterParagraph = VisiblePosition(afterParagraph.deepEquivalent()); | 1246 afterParagraph = VisiblePosition(afterParagraph.deepEquivalent()); |
| 1251 if (beforeParagraph.isNotNull() && (!isEndOfParagraph(beforeParagraph) || be
foreParagraph == afterParagraph)) { | 1247 if (beforeParagraph.isNotNull() && (!isEndOfParagraph(beforeParagraph) || be
foreParagraph == afterParagraph)) { |
| 1252 // FIXME: Trim text between beforeParagraph and afterParagraph if they a
ren't equal. | 1248 // FIXME: Trim text between beforeParagraph and afterParagraph if they a
ren't equal. |
| 1253 insertNodeAt(createBreakElement(document()), beforeParagraph.deepEquival
ent()); | 1249 insertNodeAt(createBreakElement(document()), beforeParagraph.deepEquival
ent()); |
| 1254 // Need an updateLayout here in case inserting the br has split a text n
ode. | 1250 // Need an updateLayout here in case inserting the br has split a text n
ode. |
| 1255 document().updateLayoutIgnorePendingStylesheets(); | 1251 document().updateLayoutIgnorePendingStylesheets(); |
| 1256 } | 1252 } |
| 1257 | 1253 |
| 1258 RefPtrWillBeRawPtr<Range> startToDestinationRange(Range::create(document(),
firstPositionInNode(document().documentElement()), destination.deepEquivalent().
parentAnchoredEquivalent())); | 1254 destinationIndex = TextIterator::rangeLength(firstPositionInNode(document().
documentElement()), destination.toParentAnchoredPosition(), true); |
| 1259 destinationIndex = TextIterator::rangeLength(startToDestinationRange.get(),
true); | |
| 1260 | 1255 |
| 1261 setEndingSelection(VisibleSelection(destination, originalIsDirectional)); | 1256 setEndingSelection(VisibleSelection(destination, originalIsDirectional)); |
| 1262 ASSERT(endingSelection().isCaretOrRange()); | 1257 ASSERT(endingSelection().isCaretOrRange()); |
| 1263 ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::S
electReplacement | ReplaceSelectionCommand::MovingParagraph; | 1258 ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::S
electReplacement | ReplaceSelectionCommand::MovingParagraph; |
| 1264 if (!preserveStyle) | 1259 if (!preserveStyle) |
| 1265 options |= ReplaceSelectionCommand::MatchStyle; | 1260 options |= ReplaceSelectionCommand::MatchStyle; |
| 1266 applyCommandToComposite(ReplaceSelectionCommand::create(document(), fragment
, options)); | 1261 applyCommandToComposite(ReplaceSelectionCommand::create(document(), fragment
, options)); |
| 1267 | 1262 |
| 1268 document().frame()->spellChecker().markMisspellingsAndBadGrammar(endingSelec
tion()); | 1263 document().frame()->spellChecker().markMisspellingsAndBadGrammar(endingSelec
tion()); |
| 1269 | 1264 |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1499 } | 1494 } |
| 1500 | 1495 |
| 1501 void CompositeEditCommand::trace(Visitor* visitor) | 1496 void CompositeEditCommand::trace(Visitor* visitor) |
| 1502 { | 1497 { |
| 1503 visitor->trace(m_commands); | 1498 visitor->trace(m_commands); |
| 1504 visitor->trace(m_composition); | 1499 visitor->trace(m_composition); |
| 1505 EditCommand::trace(visitor); | 1500 EditCommand::trace(visitor); |
| 1506 } | 1501 } |
| 1507 | 1502 |
| 1508 } // namespace blink | 1503 } // namespace blink |
| OLD | NEW |