Commit 786ec7d5 authored by tanvir.rizvi's avatar tanvir.rizvi Committed by Commit Bot

Use FrameSelection for SetMark in Editor class

SetMark caches the VisibleSelection and is always set by
FrameSelection::ComputeVisibleSelectionInDOMTreeDeprecated.
So instead of passing VisibleSelection, this CL passes
FrameSelection, and then compute the visible selection
at call site. With this, it also prepares for the movement
of is_directional_ to FrameSelection.

Bug: 740804
Change-Id: I0e7a27af4d926ae0c68f15fbba612cb7d9a5f268
Reviewed-on: https://chromium-review.googlesource.com/766027Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Tanvir Rizvi <tanvir.rizvi@samsung.com>
Cr-Commit-Position: refs/heads/master@{#517048}
parent 69e586cb
......@@ -1763,6 +1763,10 @@ FrameSelection& Editor::GetFrameSelection() const {
return GetFrame().Selection();
}
void Editor::SetMark() {
mark_ = GetFrameSelection().ComputeVisibleSelectionInDOMTree();
}
void Editor::ToggleOverwriteModeEnabled() {
overwrite_mode_enabled_ = !overwrite_mode_enabled_;
GetFrameSelection().SetShouldShowBlockCursor(overwrite_mode_enabled_);
......
......@@ -244,7 +244,7 @@ class CORE_EXPORT Editor final : public GarbageCollectedFinalized<Editor> {
FindOptions);
const VisibleSelection& Mark() const; // Mark, to be used as emacs uses it.
void SetMark(const VisibleSelection&);
void SetMark();
void ComputeAndSetTypingStyle(CSSPropertyValueSet*, InputEvent::InputType);
......@@ -370,10 +370,6 @@ inline const VisibleSelection& Editor::Mark() const {
return mark_;
}
inline void Editor::SetMark(const VisibleSelection& selection) {
mark_ = selection;
}
inline bool Editor::MarkedTextMatchesAreHighlighted() const {
return are_marked_text_matches_highlighted_;
}
......
......@@ -825,8 +825,11 @@ static bool ExecuteDeleteToMark(LocalFrame& frame,
SetSelectionOptions::Builder().SetShouldCloseTyping(true).Build());
}
frame.GetEditor().PerformDelete();
frame.GetEditor().SetMark(
frame.Selection().ComputeVisibleSelectionInDOMTreeDeprecated());
// TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets
// needs to be audited. See http://crbug.com/590369 for more details.
frame.GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets();
frame.GetEditor().SetMark();
return true;
}
......@@ -1876,8 +1879,7 @@ static bool ExecuteSetMark(LocalFrame& frame,
Event*,
EditorCommandSource,
const String&) {
frame.GetEditor().SetMark(
frame.Selection().ComputeVisibleSelectionInDOMTreeDeprecated());
frame.GetEditor().SetMark();
return true;
}
......@@ -1932,13 +1934,13 @@ static bool ExecuteSwapWithMark(LocalFrame& frame,
Event*,
EditorCommandSource,
const String&) {
const VisibleSelection& mark = frame.GetEditor().Mark();
const VisibleSelection mark(frame.GetEditor().Mark());
const VisibleSelection& selection =
frame.Selection().ComputeVisibleSelectionInDOMTreeDeprecated();
if (mark.IsNone() || selection.IsNone())
return false;
frame.GetEditor().SetMark();
frame.Selection().SetSelection(mark.AsSelection());
frame.GetEditor().SetMark(selection);
return true;
}
......
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