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) { ...@@ -1562,26 +1562,6 @@ bool Editor::FindString(const String& target, FindOptions options) {
return true; 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 // TODO(yosin) We should return |EphemeralRange| rather than |Range|. We use
// |Range| object for checking whether start and end position crossing shadow // |Range| object for checking whether start and end position crossing shadow
// boundaries, however we can do it without |Range| object. // boundaries, however we can do it without |Range| object.
......
...@@ -234,7 +234,6 @@ class CORE_EXPORT Editor final : public GarbageCollectedFinalized<Editor> { ...@@ -234,7 +234,6 @@ class CORE_EXPORT Editor final : public GarbageCollectedFinalized<Editor> {
bool FindString(const String&, FindOptions); bool FindString(const String&, FindOptions);
Range* FindStringAndScrollToVisible(const String&, Range*, FindOptions);
Range* FindRangeOfString(const String& target, Range* FindRangeOfString(const String& target,
const EphemeralRange& reference_range, const EphemeralRange& reference_range,
FindOptions); FindOptions);
......
...@@ -111,6 +111,17 @@ class TextFinder::DeferredScopeStringMatches ...@@ -111,6 +111,17 @@ class TextFinder::DeferredScopeStringMatches
const WebFindOptions options_; 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, bool TextFinder::Find(int identifier,
const WebString& search_text, const WebString& search_text,
const WebFindOptions& options, const WebFindOptions& options,
...@@ -148,9 +159,8 @@ bool TextFinder::Find(int identifier, ...@@ -148,9 +159,8 @@ bool TextFinder::Find(int identifier,
(options.medial_capital_as_word_start ? kTreatMedialCapitalAsWordStart (options.medial_capital_as_word_start ? kTreatMedialCapitalAsWordStart
: 0) | : 0) |
(options.find_next ? 0 : kStartInSelection); (options.find_next ? 0 : kStartInSelection);
active_match_ = active_match_ = OwnerFrame().GetFrame()->GetEditor().FindRangeOfString(
OwnerFrame().GetFrame()->GetEditor().FindStringAndScrollToVisible( search_text, EphemeralRangeInFlatTree(active_match_.Get()), find_options);
search_text, active_match_.Get(), find_options);
if (!active_match_) { if (!active_match_) {
// If we're finding next the next active match might not be in the current // If we're finding next the next active match might not be in the current
...@@ -161,6 +171,7 @@ bool TextFinder::Find(int identifier, ...@@ -161,6 +171,7 @@ bool TextFinder::Find(int identifier,
OwnerFrame().GetFrameView()->InvalidatePaintForTickmarks(); OwnerFrame().GetFrameView()->InvalidatePaintForTickmarks();
return false; return false;
} }
ScrollToVisible(active_match_);
// If the user is browsing a page with autosizing, adjust the zoom to the // 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 // 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