Commit 6573e7a7 authored by yosin@chromium.org's avatar yosin@chromium.org

Make EditorCommand to use VisibleSelection::toNormalizedEphemeralRange()...

Make EditorCommand to use VisibleSelection::toNormalizedEphemeralRange() instead of toNormalizedRange()

This patch changes |EditorCOmmand| class to use |toNormalizedEphemeralRange()|
in |VisibleSelection| class instead of |toNormalizedRange()| as a preparation
of templatizing |VisibleSelection| to use templatized positions instead of
DOM position to represent range and avoid registering temporary |Range|
object into |Document|.

This patch is a preparation of making selection to handle granularity for web
component, http://crrev.com/1277863002

BUG=388681, 513568
TEST=n/a; no behavior changes

Review URL: https://codereview.chromium.org/1315813003

git-svn-id: svn://svn.chromium.org/blink/trunk@201127 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent ef00a413
...@@ -394,11 +394,9 @@ static bool executeDeleteToEndOfParagraph(LocalFrame& frame, Event*, EditorComma ...@@ -394,11 +394,9 @@ static bool executeDeleteToEndOfParagraph(LocalFrame& frame, Event*, EditorComma
static bool executeDeleteToMark(LocalFrame& frame, Event*, EditorCommandSource, const String&) static bool executeDeleteToMark(LocalFrame& frame, Event*, EditorCommandSource, const String&)
{ {
// TODO(yosin) We should use |EphemeralRange| version of const EphemeralRange mark = frame.editor().mark().toNormalizedEphemeralRange();
// |VisibleSelection::toNormalizedRange()|. if (mark.isNotNull()) {
RefPtrWillBeRawPtr<Range> mark = frame.editor().mark().toNormalizedRange(); bool selected = frame.selection().setSelectedRange(unionEphemeralRanges(mark, frame.editor().selectedRange()), TextAffinity::Downstream, FrameSelection::NonDirectional, FrameSelection::CloseTyping);
if (mark) {
bool selected = frame.selection().setSelectedRange(unionEphemeralRanges(EphemeralRange(mark.get()), frame.editor().selectedRange()), TextAffinity::Downstream, FrameSelection::NonDirectional, FrameSelection::CloseTyping);
ASSERT(selected); ASSERT(selected);
if (!selected) if (!selected)
return false; return false;
...@@ -1042,13 +1040,11 @@ static bool executeSelectSentence(LocalFrame& frame, Event*, EditorCommandSource ...@@ -1042,13 +1040,11 @@ static bool executeSelectSentence(LocalFrame& frame, Event*, EditorCommandSource
static bool executeSelectToMark(LocalFrame& frame, Event*, EditorCommandSource, const String&) static bool executeSelectToMark(LocalFrame& frame, Event*, EditorCommandSource, const String&)
{ {
// TODO(yosin) We should use |EphemeralRange| version of const EphemeralRange mark = frame.editor().mark().toNormalizedEphemeralRange();
// |VisibleSelection::toNormalizedRange()|.
RefPtrWillBeRawPtr<Range> mark = frame.editor().mark().toNormalizedRange();
EphemeralRange selection = frame.editor().selectedRange(); EphemeralRange selection = frame.editor().selectedRange();
if (!mark || selection.isNull()) if (mark.isNull() || selection.isNull())
return false; return false;
frame.selection().setSelectedRange(unionEphemeralRanges(EphemeralRange(mark.get()), selection), TextAffinity::Downstream, FrameSelection::NonDirectional, FrameSelection::CloseTyping); frame.selection().setSelectedRange(unionEphemeralRanges(mark, selection), TextAffinity::Downstream, FrameSelection::NonDirectional, FrameSelection::CloseTyping);
return true; 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