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

Side by Side Diff: third_party/WebKit/Source/core/editing/SurroundingText.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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 if (forward_range.IsNull() || 85 if (forward_range.IsNull() ||
86 !Range::Create(*document, end_position, forward_range.StartPosition()) 86 !Range::Create(*document, end_position, forward_range.StartPosition())
87 ->GetText() 87 ->GetText()
88 .length()) 88 .length())
89 return; 89 return;
90 90
91 // Same as with the forward range but with the backward range. The range 91 // Same as with the forward range but with the backward range. The range
92 // starts at the document's or input element's start and ends at the selection 92 // starts at the document's or input element's start and ends at the selection
93 // start and will be updated. 93 // start and will be updated.
94 BackwardsCharacterIterator backwards_iterator( 94 BackwardsCharacterIterator backwards_iterator(
95 Position::FirstPositionInNode(root_element).ParentAnchoredEquivalent(), 95 Position::FirstPositionInNode(*root_element).ParentAnchoredEquivalent(),
96 start_position, 96 start_position,
97 TextIteratorBehavior::Builder().SetStopsOnFormControls(true).Build()); 97 TextIteratorBehavior::Builder().SetStopsOnFormControls(true).Build());
98 if (!backwards_iterator.AtEnd()) 98 if (!backwards_iterator.AtEnd())
99 backwards_iterator.Advance(half_max_length); 99 backwards_iterator.Advance(half_max_length);
100 100
101 const TextIteratorBehavior behavior = 101 const TextIteratorBehavior behavior =
102 TextIteratorBehavior::NoTrailingSpaceRangeLengthBehavior(); 102 TextIteratorBehavior::NoTrailingSpaceRangeLengthBehavior();
103 start_offset_in_content_ = TextIterator::RangeLength( 103 start_offset_in_content_ = TextIterator::RangeLength(
104 backwards_iterator.EndPosition(), start_position, behavior); 104 backwards_iterator.EndPosition(), start_position, behavior);
105 end_offset_in_content_ = TextIterator::RangeLength( 105 end_offset_in_content_ = TextIterator::RangeLength(
(...skipping 15 matching lines...) Expand all
121 121
122 unsigned SurroundingText::StartOffsetInContent() const { 122 unsigned SurroundingText::StartOffsetInContent() const {
123 return start_offset_in_content_; 123 return start_offset_in_content_;
124 } 124 }
125 125
126 unsigned SurroundingText::EndOffsetInContent() const { 126 unsigned SurroundingText::EndOffsetInContent() const {
127 return end_offset_in_content_; 127 return end_offset_in_content_;
128 } 128 }
129 129
130 } // namespace blink 130 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/SelectionEditor.cpp ('k') | third_party/WebKit/Source/core/editing/TextFinder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698