Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: third_party/WebKit/Source/core/editing/commands/InsertParagraphSeparatorCommand.cpp

Issue 2958483003: Make VisiblePosition::BeforeNode() to take const Node& instead of Node* (Closed)
Patch Set: 017-06-23T18:57:25 Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2005, 2006 Apple Computer, 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 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 !LineBreakExistsAtVisiblePosition(visible_pos)) { 531 !LineBreakExistsAtVisiblePosition(visible_pos)) {
532 AppendNode(HTMLBRElement::Create(GetDocument()), block_to_insert, 532 AppendNode(HTMLBRElement::Create(GetDocument()), block_to_insert,
533 editing_state); 533 editing_state);
534 if (editing_state->IsAborted()) 534 if (editing_state->IsAborted())
535 return; 535 return;
536 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets(); 536 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets();
537 } 537 }
538 538
539 // Move the start node and the siblings of the start node. 539 // Move the start node and the siblings of the start node.
540 if (CreateVisiblePosition(insertion_position).DeepEquivalent() != 540 if (CreateVisiblePosition(insertion_position).DeepEquivalent() !=
541 VisiblePosition::BeforeNode(block_to_insert).DeepEquivalent()) { 541 VisiblePosition::BeforeNode(*block_to_insert).DeepEquivalent()) {
542 Node* n; 542 Node* n;
543 if (insertion_position.ComputeContainerNode() == start_block) { 543 if (insertion_position.ComputeContainerNode() == start_block) {
544 n = insertion_position.ComputeNodeAfterPosition(); 544 n = insertion_position.ComputeNodeAfterPosition();
545 } else { 545 } else {
546 Node* split_to = insertion_position.ComputeContainerNode(); 546 Node* split_to = insertion_position.ComputeContainerNode();
547 if (split_to->IsTextNode() && 547 if (split_to->IsTextNode() &&
548 insertion_position.OffsetInContainerNode() >= 548 insertion_position.OffsetInContainerNode() >=
549 CaretMaxOffset(split_to)) 549 CaretMaxOffset(split_to))
550 split_to = NodeTraversal::Next(*split_to, start_block); 550 split_to = NodeTraversal::Next(*split_to, start_block);
551 if (split_to) 551 if (split_to)
552 SplitTreeToNode(split_to, start_block); 552 SplitTreeToNode(split_to, start_block);
553 553
554 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets(); 554 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets();
555 555
556 for (n = start_block->firstChild(); n; n = n->nextSibling()) { 556 for (n = start_block->firstChild(); n; n = n->nextSibling()) {
557 VisiblePosition before_node_position = VisiblePosition::BeforeNode(n); 557 VisiblePosition before_node_position = VisiblePosition::BeforeNode(*n);
558 if (!before_node_position.IsNull() && 558 if (!before_node_position.IsNull() &&
559 ComparePositions(CreateVisiblePosition(insertion_position), 559 ComparePositions(CreateVisiblePosition(insertion_position),
560 before_node_position) <= 0) 560 before_node_position) <= 0)
561 break; 561 break;
562 } 562 }
563 } 563 }
564 564
565 MoveRemainingSiblingsToNewParent(n, block_to_insert, block_to_insert, 565 MoveRemainingSiblingsToNewParent(n, block_to_insert, block_to_insert,
566 editing_state); 566 editing_state);
567 if (editing_state->IsAborted()) 567 if (editing_state->IsAborted())
(...skipping 27 matching lines...) Expand all
595 .Build()); 595 .Build());
596 ApplyStyleAfterInsertion(start_block, editing_state); 596 ApplyStyleAfterInsertion(start_block, editing_state);
597 } 597 }
598 598
599 DEFINE_TRACE(InsertParagraphSeparatorCommand) { 599 DEFINE_TRACE(InsertParagraphSeparatorCommand) {
600 visitor->Trace(style_); 600 visitor->Trace(style_);
601 CompositeEditCommand::Trace(visitor); 601 CompositeEditCommand::Trace(visitor);
602 } 602 }
603 603
604 } // namespace blink 604 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698