Commit cb25260f authored by Zhuoyu Qian's avatar Zhuoyu Qian Committed by Commit Bot

Move FindStringAndScrollToVisible to TextFinder.cpp

Editor::FindStringAndScrollToVisible only used in TextFinder.cpp, split
it to FindRangeOfString() and ScrollToVisible(), move ScrollToVisible()
to TextFinder.cpp as a static function.

Bug: 672405
Signed-off-by: default avatarZhuoyu Qian <zhuoyu.qian@samsung.com>
Change-Id: Ic86f7bf824c41c3c01bec29e266df32388f59309
Reviewed-on: https://chromium-review.googlesource.com/903203Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534665}
parent 3a004d56
......@@ -1562,26 +1562,6 @@ bool Editor::FindString(const String& target, FindOptions options) {
return true;
}
Range* Editor::FindStringAndScrollToVisible(const String& target,
Range* previous_match,
FindOptions options) {
Range* next_match = FindRangeOfString(
target, EphemeralRangeInFlatTree(previous_match), options);
if (!next_match)
return nullptr;
Node* first_node = next_match->FirstNode();
first_node->GetLayoutObject()->ScrollRectToVisible(
LayoutRect(next_match->BoundingBox()),
WebScrollIntoViewParams(ScrollAlignment::kAlignCenterIfNeeded,
ScrollAlignment::kAlignCenterIfNeeded,
kUserScroll));
first_node->GetDocument().SetSequentialFocusNavigationStartingPoint(
first_node);
return next_match;
}
// TODO(yosin) We should return |EphemeralRange| rather than |Range|. We use
// |Range| object for checking whether start and end position crossing shadow
// boundaries, however we can do it without |Range| object.
......
......@@ -234,7 +234,6 @@ class CORE_EXPORT Editor final : public GarbageCollectedFinalized<Editor> {
bool FindString(const String&, FindOptions);
Range* FindStringAndScrollToVisible(const String&, Range*, FindOptions);
Range* FindRangeOfString(const String& target,
const EphemeralRange& reference_range,
FindOptions);
......
......@@ -111,6 +111,17 @@ class TextFinder::DeferredScopeStringMatches
const WebFindOptions options_;
};
static void ScrollToVisible(Range* match) {
const Node& first_node = *match->FirstNode();
first_node.GetLayoutObject()->ScrollRectToVisible(
LayoutRect(match->BoundingBox()),
WebScrollIntoViewParams(ScrollAlignment::kAlignCenterIfNeeded,
ScrollAlignment::kAlignCenterIfNeeded,
kUserScroll));
first_node.GetDocument().SetSequentialFocusNavigationStartingPoint(
const_cast<Node*>(&first_node));
}
bool TextFinder::Find(int identifier,
const WebString& search_text,
const WebFindOptions& options,
......@@ -148,9 +159,8 @@ bool TextFinder::Find(int identifier,
(options.medial_capital_as_word_start ? kTreatMedialCapitalAsWordStart
: 0) |
(options.find_next ? 0 : kStartInSelection);
active_match_ =
OwnerFrame().GetFrame()->GetEditor().FindStringAndScrollToVisible(
search_text, active_match_.Get(), find_options);
active_match_ = OwnerFrame().GetFrame()->GetEditor().FindRangeOfString(
search_text, EphemeralRangeInFlatTree(active_match_.Get()), find_options);
if (!active_match_) {
// If we're finding next the next active match might not be in the current
......@@ -161,6 +171,7 @@ bool TextFinder::Find(int identifier,
OwnerFrame().GetFrameView()->InvalidatePaintForTickmarks();
return false;
}
ScrollToVisible(active_match_);
// If the user is browsing a page with autosizing, adjust the zoom to the
// column where the next hit has been found. Doing this when autosizing is
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment