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

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

Issue 2950053002: Make Position::BeforeNode() to take const Node& instead of Node* (Closed)
Patch Set: 2017-06-21T17:56:36 Created 3 years, 6 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) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2004, 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 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 // The selection starts in editable content or non-editable content inside a 623 // The selection starts in editable content or non-editable content inside a
624 // different editable ancestor, move forward until non-editable content 624 // different editable ancestor, move forward until non-editable content
625 // inside the same lowest editable ancestor is reached. 625 // inside the same lowest editable ancestor is reached.
626 Element* start_editable_ancestor = 626 Element* start_editable_ancestor =
627 LowestEditableAncestor(start_.ComputeContainerNode()); 627 LowestEditableAncestor(start_.ComputeContainerNode());
628 if (start_root || start_editable_ancestor != base_editable_ancestor) { 628 if (start_root || start_editable_ancestor != base_editable_ancestor) {
629 PositionTemplate<Strategy> p = NextVisuallyDistinctCandidate(start_); 629 PositionTemplate<Strategy> p = NextVisuallyDistinctCandidate(start_);
630 Element* shadow_ancestor = 630 Element* shadow_ancestor =
631 start_root ? start_root->OwnerShadowHost() : nullptr; 631 start_root ? start_root->OwnerShadowHost() : nullptr;
632 if (p.IsNull() && shadow_ancestor) 632 if (p.IsNull() && shadow_ancestor)
633 p = PositionTemplate<Strategy>::BeforeNode(shadow_ancestor); 633 p = PositionTemplate<Strategy>::BeforeNode(*shadow_ancestor);
634 while (p.IsNotNull() && 634 while (p.IsNotNull() &&
635 !(LowestEditableAncestor(p.ComputeContainerNode()) == 635 !(LowestEditableAncestor(p.ComputeContainerNode()) ==
636 base_editable_ancestor && 636 base_editable_ancestor &&
637 !IsEditablePosition(p))) { 637 !IsEditablePosition(p))) {
638 Element* root = RootEditableElementOf(p); 638 Element* root = RootEditableElementOf(p);
639 shadow_ancestor = root ? root->OwnerShadowHost() : nullptr; 639 shadow_ancestor = root ? root->OwnerShadowHost() : nullptr;
640 p = IsAtomicNode(p.ComputeContainerNode()) 640 p = IsAtomicNode(p.ComputeContainerNode())
641 ? PositionTemplate<Strategy>::InParentAfterNode( 641 ? PositionTemplate<Strategy>::InParentAfterNode(
642 *p.ComputeContainerNode()) 642 *p.ComputeContainerNode())
643 : NextVisuallyDistinctCandidate(p); 643 : NextVisuallyDistinctCandidate(p);
644 if (p.IsNull() && shadow_ancestor) 644 if (p.IsNull() && shadow_ancestor)
645 p = PositionTemplate<Strategy>::BeforeNode(shadow_ancestor); 645 p = PositionTemplate<Strategy>::BeforeNode(*shadow_ancestor);
646 } 646 }
647 const VisiblePositionTemplate<Strategy> next = CreateVisiblePosition(p); 647 const VisiblePositionTemplate<Strategy> next = CreateVisiblePosition(p);
648 648
649 if (next.IsNull()) { 649 if (next.IsNull()) {
650 // The selection crosses an Editing boundary. This is a 650 // The selection crosses an Editing boundary. This is a
651 // programmer error in the editing code. Happy debugging! 651 // programmer error in the editing code. Happy debugging!
652 NOTREACHED(); 652 NOTREACHED();
653 *this = VisibleSelectionTemplate<Strategy>(); 653 *this = VisibleSelectionTemplate<Strategy>();
654 return; 654 return;
655 } 655 }
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 784
785 void showTree(const blink::VisibleSelectionInFlatTree& sel) { 785 void showTree(const blink::VisibleSelectionInFlatTree& sel) {
786 sel.ShowTreeForThis(); 786 sel.ShowTreeForThis();
787 } 787 }
788 788
789 void showTree(const blink::VisibleSelectionInFlatTree* sel) { 789 void showTree(const blink::VisibleSelectionInFlatTree* sel) {
790 if (sel) 790 if (sel)
791 sel->ShowTreeForThis(); 791 sel->ShowTreeForThis();
792 } 792 }
793 #endif 793 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698