Commit 526a6bcc authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

Make text find related functions in Editor class as static member

This patch changes text find related functions in |Editor| class as static
member function as preparation of them to moving |TextFinderHelper| class
to reduce source code size of |Editor| class for improving code health.

Change-Id: I1f274ae07568fd66a3dea8443b8bb03b6b896057
Reviewed-on: https://chromium-review.googlesource.com/985680Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547108}
parent 81f01d52
......@@ -746,24 +746,27 @@ void Editor::ComputeAndSetTypingStyle(CSSPropertyValueSet* style,
}
}
bool Editor::FindString(const String& target, FindOptions options) {
bool Editor::FindString(LocalFrame& frame,
const String& target,
FindOptions options) {
VisibleSelection selection =
GetFrameSelection().ComputeVisibleSelectionInDOMTreeDeprecated();
frame.Selection().ComputeVisibleSelectionInDOMTreeDeprecated();
// TODO(yosin) We should make |findRangeOfString()| to return
// |EphemeralRange| rather than|Range| object.
Range* result_range = FindRangeOfString(
target, EphemeralRange(selection.Start(), selection.End()),
static_cast<FindOptions>(options | kFindAPICall));
Range* const result_range =
FindRangeOfString(*frame.GetDocument(), target,
EphemeralRange(selection.Start(), selection.End()),
static_cast<FindOptions>(options | kFindAPICall));
if (!result_range)
return false;
GetFrameSelection().SetSelectionAndEndTyping(
frame.Selection().SetSelectionAndEndTyping(
SelectionInDOMTree::Builder()
.SetBaseAndExtent(EphemeralRange(result_range))
.Build());
GetFrameSelection().RevealSelection();
frame.Selection().RevealSelection();
return true;
}
......@@ -874,18 +877,20 @@ static Range* FindRangeOfStringAlgorithm(
return result_range;
}
Range* Editor::FindRangeOfString(const String& target,
Range* Editor::FindRangeOfString(Document& document,
const String& target,
const EphemeralRange& reference,
FindOptions options) {
return FindRangeOfStringAlgorithm<EditingStrategy>(
*GetFrame().GetDocument(), target, reference, options);
return FindRangeOfStringAlgorithm<EditingStrategy>(document, target,
reference, options);
}
Range* Editor::FindRangeOfString(const String& target,
Range* Editor::FindRangeOfString(Document& document,
const String& target,
const EphemeralRangeInFlatTree& reference,
FindOptions options) {
return FindRangeOfStringAlgorithm<EditingInFlatTreeStrategy>(
*GetFrame().GetDocument(), target, reference, options);
document, target, reference, options);
}
void Editor::SetMarkedTextMatchesAreHighlighted(bool flag) {
......
......@@ -158,14 +158,17 @@ class CORE_EXPORT Editor final : public GarbageCollectedFinalized<Editor> {
void AddToKillRing(const EphemeralRange&);
bool FindString(const String&, FindOptions);
Range* FindRangeOfString(const String& target,
const EphemeralRange& reference_range,
FindOptions);
Range* FindRangeOfString(const String& target,
const EphemeralRangeInFlatTree& reference_range,
FindOptions);
static bool FindString(LocalFrame&, const String&, FindOptions);
static Range* FindRangeOfString(Document&,
const String& target,
const EphemeralRange& reference_range,
FindOptions);
static Range* FindRangeOfString(
Document&,
const String& target,
const EphemeralRangeInFlatTree& reference_range,
FindOptions);
const VisibleSelection& Mark() const; // Mark, to be used as emacs uses it.
bool MarkIsDirectional() const;
......
......@@ -926,7 +926,7 @@ static bool ExecuteFindString(LocalFrame& frame,
Event*,
EditorCommandSource,
const String& value) {
return frame.GetEditor().FindString(value, kCaseInsensitive | kWrapAround);
return Editor::FindString(frame, value, kCaseInsensitive | kWrapAround);
}
bool StyleCommands::ExecuteFontName(LocalFrame& frame,
......
......@@ -159,8 +159,9 @@ bool TextFinder::Find(int identifier,
(options.medial_capital_as_word_start ? kTreatMedialCapitalAsWordStart
: 0) |
(options.find_next ? 0 : kStartInSelection);
active_match_ = OwnerFrame().GetFrame()->GetEditor().FindRangeOfString(
search_text, EphemeralRangeInFlatTree(active_match_.Get()), find_options);
active_match_ = Editor::FindRangeOfString(
*OwnerFrame().GetFrame()->GetDocument(), 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
......
......@@ -902,7 +902,7 @@ bool LocalDOMWindow::find(const String& string,
FindOptions options =
(backwards ? kBackwards : 0) | (case_sensitive ? 0 : kCaseInsensitive) |
(wrap ? kWrapAround : 0) | (whole_word ? kWholeWord | kAtWordStarts : 0);
return GetFrame()->GetEditor().FindString(string, options);
return Editor::FindString(*GetFrame(), string, options);
}
bool LocalDOMWindow::offscreenBuffering() const {
......
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