| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2008, 2009 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 visible_end.IsNull() || visible_end.IsOrphan()) | 256 visible_end.IsNull() || visible_end.IsOrphan()) |
| 257 return; | 257 return; |
| 258 | 258 |
| 259 // Save and restore the selection endpoints using their indices in the | 259 // Save and restore the selection endpoints using their indices in the |
| 260 // document, since addBlockStyleIfNeeded may moveParagraphs, which can remove | 260 // document, since addBlockStyleIfNeeded may moveParagraphs, which can remove |
| 261 // these endpoints. Calculate start and end indices from the start of the tree | 261 // these endpoints. Calculate start and end indices from the start of the tree |
| 262 // that they're in. | 262 // that they're in. |
| 263 Node& scope = NodeTraversal::HighestAncestorOrSelf( | 263 Node& scope = NodeTraversal::HighestAncestorOrSelf( |
| 264 *visible_start.DeepEquivalent().AnchorNode()); | 264 *visible_start.DeepEquivalent().AnchorNode()); |
| 265 Range* start_range = | 265 Range* start_range = |
| 266 Range::Create(GetDocument(), Position::FirstPositionInNode(&scope), | 266 Range::Create(GetDocument(), Position::FirstPositionInNode(scope), |
| 267 visible_start.DeepEquivalent().ParentAnchoredEquivalent()); | 267 visible_start.DeepEquivalent().ParentAnchoredEquivalent()); |
| 268 Range* end_range = | 268 Range* end_range = |
| 269 Range::Create(GetDocument(), Position::FirstPositionInNode(&scope), | 269 Range::Create(GetDocument(), Position::FirstPositionInNode(scope), |
| 270 visible_end.DeepEquivalent().ParentAnchoredEquivalent()); | 270 visible_end.DeepEquivalent().ParentAnchoredEquivalent()); |
| 271 | 271 |
| 272 const TextIteratorBehavior behavior = | 272 const TextIteratorBehavior behavior = |
| 273 TextIteratorBehavior::AllVisiblePositionsRangeLengthBehavior(); | 273 TextIteratorBehavior::AllVisiblePositionsRangeLengthBehavior(); |
| 274 | 274 |
| 275 int start_index = TextIterator::RangeLength( | 275 int start_index = TextIterator::RangeLength( |
| 276 start_range->StartPosition(), start_range->EndPosition(), behavior); | 276 start_range->StartPosition(), start_range->EndPosition(), behavior); |
| 277 int end_index = TextIterator::RangeLength(end_range->StartPosition(), | 277 int end_index = TextIterator::RangeLength(end_range->StartPosition(), |
| 278 end_range->EndPosition(), behavior); | 278 end_range->EndPosition(), behavior); |
| 279 | 279 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 296 paragraph_start.DeepEquivalent(); | 296 paragraph_start.DeepEquivalent(); |
| 297 if (!remove_only_ && IsEditablePosition(paragraph_start_to_move)) { | 297 if (!remove_only_ && IsEditablePosition(paragraph_start_to_move)) { |
| 298 HTMLElement* new_block = MoveParagraphContentsToNewBlockIfNecessary( | 298 HTMLElement* new_block = MoveParagraphContentsToNewBlockIfNecessary( |
| 299 paragraph_start_to_move, editing_state); | 299 paragraph_start_to_move, editing_state); |
| 300 if (editing_state->IsAborted()) | 300 if (editing_state->IsAborted()) |
| 301 return; | 301 return; |
| 302 if (new_block) { | 302 if (new_block) { |
| 303 block = new_block; | 303 block = new_block; |
| 304 if (paragraph_start.IsOrphan()) { | 304 if (paragraph_start.IsOrphan()) { |
| 305 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets(); | 305 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets(); |
| 306 paragraph_start = | 306 paragraph_start = CreateVisiblePosition( |
| 307 CreateVisiblePosition(Position::FirstPositionInNode(new_block)); | 307 Position::FirstPositionInNode(*new_block)); |
| 308 } | 308 } |
| 309 } | 309 } |
| 310 DCHECK(!paragraph_start.IsOrphan()) << paragraph_start; | 310 DCHECK(!paragraph_start.IsOrphan()) << paragraph_start; |
| 311 } | 311 } |
| 312 if (block && block->IsHTMLElement()) { | 312 if (block && block->IsHTMLElement()) { |
| 313 RemoveCSSStyle(style, ToHTMLElement(block), editing_state); | 313 RemoveCSSStyle(style, ToHTMLElement(block), editing_state); |
| 314 if (editing_state->IsAborted()) | 314 if (editing_state->IsAborted()) |
| 315 return; | 315 return; |
| 316 DCHECK(!paragraph_start.IsOrphan()) << paragraph_start; | 316 DCHECK(!paragraph_start.IsOrphan()) << paragraph_start; |
| 317 if (!remove_only_) { | 317 if (!remove_only_) { |
| (...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1545 if (end.IsOffsetInAnchor() && | 1545 if (end.IsOffsetInAnchor() && |
| 1546 start.ComputeContainerNode() == end.ComputeContainerNode()) | 1546 start.ComputeContainerNode() == end.ComputeContainerNode()) |
| 1547 new_end = | 1547 new_end = |
| 1548 Position(end.ComputeContainerNode(), | 1548 Position(end.ComputeContainerNode(), |
| 1549 end.OffsetInContainerNode() - start.OffsetInContainerNode()); | 1549 end.OffsetInContainerNode() - start.OffsetInContainerNode()); |
| 1550 else | 1550 else |
| 1551 new_end = end; | 1551 new_end = end; |
| 1552 | 1552 |
| 1553 Text* text = ToText(start.ComputeContainerNode()); | 1553 Text* text = ToText(start.ComputeContainerNode()); |
| 1554 SplitTextNode(text, start.OffsetInContainerNode()); | 1554 SplitTextNode(text, start.OffsetInContainerNode()); |
| 1555 UpdateStartEnd(Position::FirstPositionInNode(text), new_end); | 1555 UpdateStartEnd(Position::FirstPositionInNode(*text), new_end); |
| 1556 } | 1556 } |
| 1557 | 1557 |
| 1558 void ApplyStyleCommand::SplitTextAtEnd(const Position& start, | 1558 void ApplyStyleCommand::SplitTextAtEnd(const Position& start, |
| 1559 const Position& end) { | 1559 const Position& end) { |
| 1560 DCHECK(end.ComputeContainerNode()->IsTextNode()) << end; | 1560 DCHECK(end.ComputeContainerNode()->IsTextNode()) << end; |
| 1561 | 1561 |
| 1562 bool should_update_start = | 1562 bool should_update_start = |
| 1563 start.IsOffsetInAnchor() && | 1563 start.IsOffsetInAnchor() && |
| 1564 start.ComputeContainerNode() == end.ComputeContainerNode(); | 1564 start.ComputeContainerNode() == end.ComputeContainerNode(); |
| 1565 Text* text = ToText(end.AnchorNode()); | 1565 Text* text = ToText(end.AnchorNode()); |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2046 | 2046 |
| 2047 DEFINE_TRACE(ApplyStyleCommand) { | 2047 DEFINE_TRACE(ApplyStyleCommand) { |
| 2048 visitor->Trace(style_); | 2048 visitor->Trace(style_); |
| 2049 visitor->Trace(start_); | 2049 visitor->Trace(start_); |
| 2050 visitor->Trace(end_); | 2050 visitor->Trace(end_); |
| 2051 visitor->Trace(styled_inline_element_); | 2051 visitor->Trace(styled_inline_element_); |
| 2052 CompositeEditCommand::Trace(visitor); | 2052 CompositeEditCommand::Trace(visitor); |
| 2053 } | 2053 } |
| 2054 | 2054 |
| 2055 } // namespace blink | 2055 } // namespace blink |
| OLD | NEW |