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 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1259 | 1259 |
1260 void CompositeEditCommand::MoveParagraphWithClones( | 1260 void CompositeEditCommand::MoveParagraphWithClones( |
1261 const VisiblePosition& start_of_paragraph_to_move, | 1261 const VisiblePosition& start_of_paragraph_to_move, |
1262 const VisiblePosition& end_of_paragraph_to_move, | 1262 const VisiblePosition& end_of_paragraph_to_move, |
1263 HTMLElement* block_element, | 1263 HTMLElement* block_element, |
1264 Node* outer_node, | 1264 Node* outer_node, |
1265 EditingState* editing_state) { | 1265 EditingState* editing_state) { |
1266 DCHECK(outer_node); | 1266 DCHECK(outer_node); |
1267 DCHECK(block_element); | 1267 DCHECK(block_element); |
1268 | 1268 |
1269 VisiblePosition before_paragraph = | 1269 RelocatablePosition relocatable_before_paragraph( |
1270 PreviousPositionOf(start_of_paragraph_to_move); | 1270 PreviousPositionOf(start_of_paragraph_to_move).DeepEquivalent()); |
1271 VisiblePosition after_paragraph = NextPositionOf(end_of_paragraph_to_move); | 1271 RelocatablePosition relocatable_after_paragraph( |
| 1272 NextPositionOf(end_of_paragraph_to_move).DeepEquivalent()); |
1272 | 1273 |
1273 // We upstream() the end and downstream() the start so that we don't include | 1274 // We upstream() the end and downstream() the start so that we don't include |
1274 // collapsed whitespace in the move. When we paste a fragment, spaces after | 1275 // collapsed whitespace in the move. When we paste a fragment, spaces after |
1275 // the end and before the start are treated as though they were rendered. | 1276 // the end and before the start are treated as though they were rendered. |
1276 Position start = | 1277 Position start = |
1277 MostForwardCaretPosition(start_of_paragraph_to_move.DeepEquivalent()); | 1278 MostForwardCaretPosition(start_of_paragraph_to_move.DeepEquivalent()); |
1278 Position end = start_of_paragraph_to_move.DeepEquivalent() == | 1279 Position end = start_of_paragraph_to_move.DeepEquivalent() == |
1279 end_of_paragraph_to_move.DeepEquivalent() | 1280 end_of_paragraph_to_move.DeepEquivalent() |
1280 ? start | 1281 ? start |
1281 : MostBackwardCaretPosition( | 1282 : MostBackwardCaretPosition( |
(...skipping 22 matching lines...) Expand all Loading... |
1304 | 1305 |
1305 // Add a br if pruning an empty block level element caused a collapse. For | 1306 // Add a br if pruning an empty block level element caused a collapse. For |
1306 // example: | 1307 // example: |
1307 // foo^ | 1308 // foo^ |
1308 // <div>bar</div> | 1309 // <div>bar</div> |
1309 // baz | 1310 // baz |
1310 // Imagine moving 'bar' to ^. 'bar' will be deleted and its div pruned. That | 1311 // Imagine moving 'bar' to ^. 'bar' will be deleted and its div pruned. That |
1311 // would cause 'baz' to collapse onto the line with 'foobar' unless we insert | 1312 // would cause 'baz' to collapse onto the line with 'foobar' unless we insert |
1312 // a br. Must recononicalize these two VisiblePositions after the pruning | 1313 // a br. Must recononicalize these two VisiblePositions after the pruning |
1313 // above. | 1314 // above. |
1314 // TODO(yosin): We should abort when |beforeParagraph| is a orphan when | 1315 const VisiblePosition& before_paragraph = |
1315 // we have a sample. | 1316 CreateVisiblePosition(relocatable_before_paragraph.GetPosition()); |
1316 before_paragraph = CreateVisiblePosition(before_paragraph.DeepEquivalent()); | 1317 const VisiblePosition& after_paragraph = |
1317 if (after_paragraph.IsOrphan()) { | 1318 CreateVisiblePosition(relocatable_after_paragraph.GetPosition()); |
1318 editing_state->Abort(); | |
1319 return; | |
1320 } | |
1321 after_paragraph = CreateVisiblePosition(after_paragraph.DeepEquivalent()); | |
1322 | 1319 |
1323 if (before_paragraph.IsNotNull() && | 1320 if (before_paragraph.IsNotNull() && |
1324 !IsDisplayInsideTable(before_paragraph.DeepEquivalent().AnchorNode()) && | 1321 !IsDisplayInsideTable(before_paragraph.DeepEquivalent().AnchorNode()) && |
1325 ((!IsEndOfParagraph(before_paragraph) && | 1322 ((!IsEndOfParagraph(before_paragraph) && |
1326 !IsStartOfParagraph(before_paragraph)) || | 1323 !IsStartOfParagraph(before_paragraph)) || |
1327 before_paragraph.DeepEquivalent() == after_paragraph.DeepEquivalent())) { | 1324 before_paragraph.DeepEquivalent() == after_paragraph.DeepEquivalent())) { |
1328 // FIXME: Trim text between beforeParagraph and afterParagraph if they | 1325 // FIXME: Trim text between beforeParagraph and afterParagraph if they |
1329 // aren't equal. | 1326 // aren't equal. |
1330 InsertNodeAt(HTMLBRElement::Create(GetDocument()), | 1327 InsertNodeAt(HTMLBRElement::Create(GetDocument()), |
1331 before_paragraph.DeepEquivalent(), editing_state); | 1328 before_paragraph.DeepEquivalent(), editing_state); |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1978 | 1975 |
1979 DEFINE_TRACE(CompositeEditCommand) { | 1976 DEFINE_TRACE(CompositeEditCommand) { |
1980 visitor->Trace(commands_); | 1977 visitor->Trace(commands_); |
1981 visitor->Trace(starting_selection_); | 1978 visitor->Trace(starting_selection_); |
1982 visitor->Trace(ending_selection_); | 1979 visitor->Trace(ending_selection_); |
1983 visitor->Trace(undo_step_); | 1980 visitor->Trace(undo_step_); |
1984 EditCommand::Trace(visitor); | 1981 EditCommand::Trace(visitor); |
1985 } | 1982 } |
1986 | 1983 |
1987 } // namespace blink | 1984 } // namespace blink |
OLD | NEW |