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

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

Issue 2952983002: Make Position::FirstPositionInNode() to take const Node& instead of Node* (Closed)
Patch Set: 2017-06-23T10:37:43 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/EditingUtilitiesTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007 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 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 } 648 }
649 649
650 template <typename Strategy> 650 template <typename Strategy>
651 PositionTemplate<Strategy> FirstEditablePositionAfterPositionInRootAlgorithm( 651 PositionTemplate<Strategy> FirstEditablePositionAfterPositionInRootAlgorithm(
652 const PositionTemplate<Strategy>& position, 652 const PositionTemplate<Strategy>& position,
653 Node& highest_root) { 653 Node& highest_root) {
654 DCHECK(!NeedsLayoutTreeUpdate(highest_root)) 654 DCHECK(!NeedsLayoutTreeUpdate(highest_root))
655 << position << ' ' << highest_root; 655 << position << ' ' << highest_root;
656 // position falls before highestRoot. 656 // position falls before highestRoot.
657 if (position.CompareTo(PositionTemplate<Strategy>::FirstPositionInNode( 657 if (position.CompareTo(PositionTemplate<Strategy>::FirstPositionInNode(
658 &highest_root)) == -1 && 658 highest_root)) == -1 &&
659 HasEditableStyle(highest_root)) 659 HasEditableStyle(highest_root))
660 return PositionTemplate<Strategy>::FirstPositionInNode(&highest_root); 660 return PositionTemplate<Strategy>::FirstPositionInNode(highest_root);
661 661
662 PositionTemplate<Strategy> editable_position = position; 662 PositionTemplate<Strategy> editable_position = position;
663 663
664 if (position.AnchorNode()->GetTreeScope() != highest_root.GetTreeScope()) { 664 if (position.AnchorNode()->GetTreeScope() != highest_root.GetTreeScope()) {
665 Node* shadow_ancestor = highest_root.GetTreeScope().AncestorInThisScope( 665 Node* shadow_ancestor = highest_root.GetTreeScope().AncestorInThisScope(
666 editable_position.AnchorNode()); 666 editable_position.AnchorNode());
667 if (!shadow_ancestor) 667 if (!shadow_ancestor)
668 return PositionTemplate<Strategy>(); 668 return PositionTemplate<Strategy>();
669 669
670 editable_position = PositionTemplate<Strategy>::AfterNode(*shadow_ancestor); 670 editable_position = PositionTemplate<Strategy>::AfterNode(*shadow_ancestor);
(...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1900 Document& document = *p.GetDocument(); 1900 Document& document = *p.GetDocument();
1901 DCHECK(!document.NeedsLayoutTreeUpdate()); 1901 DCHECK(!document.NeedsLayoutTreeUpdate());
1902 1902
1903 ShadowRoot* shadow_root = p.AnchorNode()->ContainingShadowRoot(); 1903 ShadowRoot* shadow_root = p.AnchorNode()->ContainingShadowRoot();
1904 1904
1905 if (shadow_root) 1905 if (shadow_root)
1906 scope = shadow_root; 1906 scope = shadow_root;
1907 else 1907 else
1908 scope = document.documentElement(); 1908 scope = document.documentElement();
1909 1909
1910 EphemeralRange range(Position::FirstPositionInNode(scope), 1910 EphemeralRange range(Position::FirstPositionInNode(*scope),
1911 p.ParentAnchoredEquivalent()); 1911 p.ParentAnchoredEquivalent());
1912 1912
1913 return TextIterator::RangeLength( 1913 return TextIterator::RangeLength(
1914 range.StartPosition(), range.EndPosition(), 1914 range.StartPosition(), range.EndPosition(),
1915 TextIteratorBehavior::AllVisiblePositionsRangeLengthBehavior()); 1915 TextIteratorBehavior::AllVisiblePositionsRangeLengthBehavior());
1916 } 1916 }
1917 1917
1918 EphemeralRange MakeRange(const VisiblePosition& start, 1918 EphemeralRange MakeRange(const VisiblePosition& start,
1919 const VisiblePosition& end) { 1919 const VisiblePosition& end) {
1920 if (start.IsNull() || end.IsNull()) 1920 if (start.IsNull() || end.IsNull())
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
2179 return InputType::kDeleteSoftLineBackward; 2179 return InputType::kDeleteSoftLineBackward;
2180 if (granularity == kParagraphBoundary) 2180 if (granularity == kParagraphBoundary)
2181 return InputType::kDeleteHardLineBackward; 2181 return InputType::kDeleteHardLineBackward;
2182 return InputType::kDeleteContentBackward; 2182 return InputType::kDeleteContentBackward;
2183 default: 2183 default:
2184 return InputType::kNone; 2184 return InputType::kNone;
2185 } 2185 }
2186 } 2186 }
2187 2187
2188 } // namespace blink 2188 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/EditingUtilitiesTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698