Commit b2ebc978 authored by yoichio@chromium.org's avatar yoichio@chromium.org

Change a FrameSelection::setSelectedRange argument type from bool to enum.

Let's use FrameSelection::DirectoinalOption instead of bool.


BUG=

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

git-svn-id: svn://svn.chromium.org/blink/trunk@176192 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent e3efb997
...@@ -219,7 +219,7 @@ static bool expandSelectionToGranularity(LocalFrame& frame, TextGranularity gran ...@@ -219,7 +219,7 @@ static bool expandSelectionToGranularity(LocalFrame& frame, TextGranularity gran
if (newRange->collapsed()) if (newRange->collapsed())
return false; return false;
EAffinity affinity = frame.selection().affinity(); EAffinity affinity = frame.selection().affinity();
frame.selection().setSelectedRange(newRange.get(), affinity, false, FrameSelection::CloseTyping); frame.selection().setSelectedRange(newRange.get(), affinity, FrameSelection::NonDirectional, FrameSelection::CloseTyping);
return true; return true;
} }
...@@ -381,7 +381,7 @@ static bool executeDeleteToMark(LocalFrame& frame, Event*, EditorCommandSource, ...@@ -381,7 +381,7 @@ static bool executeDeleteToMark(LocalFrame& frame, Event*, EditorCommandSource,
{ {
RefPtrWillBeRawPtr<Range> mark = frame.editor().mark().toNormalizedRange(); RefPtrWillBeRawPtr<Range> mark = frame.editor().mark().toNormalizedRange();
if (mark) { if (mark) {
bool selected = frame.selection().setSelectedRange(unionDOMRanges(mark.get(), frame.editor().selectedRange().get()).get(), DOWNSTREAM, false, FrameSelection::CloseTyping); bool selected = frame.selection().setSelectedRange(unionDOMRanges(mark.get(), frame.editor().selectedRange().get()).get(), DOWNSTREAM, FrameSelection::NonDirectional, FrameSelection::CloseTyping);
ASSERT(selected); ASSERT(selected);
if (!selected) if (!selected)
return false; return false;
...@@ -1031,7 +1031,7 @@ static bool executeSelectToMark(LocalFrame& frame, Event*, EditorCommandSource, ...@@ -1031,7 +1031,7 @@ static bool executeSelectToMark(LocalFrame& frame, Event*, EditorCommandSource,
RefPtrWillBeRawPtr<Range> selection = frame.editor().selectedRange(); RefPtrWillBeRawPtr<Range> selection = frame.editor().selectedRange();
if (!mark || !selection) if (!mark || !selection)
return false; return false;
frame.selection().setSelectedRange(unionDOMRanges(mark.get(), selection.get()).get(), DOWNSTREAM, false, FrameSelection::CloseTyping); frame.selection().setSelectedRange(unionDOMRanges(mark.get(), selection.get()).get(), DOWNSTREAM, FrameSelection::NonDirectional, FrameSelection::CloseTyping);
return true; return true;
} }
......
...@@ -1407,7 +1407,7 @@ void FrameSelection::selectAll() ...@@ -1407,7 +1407,7 @@ void FrameSelection::selectAll()
notifyRendererOfSelectionChange(UserTriggered); notifyRendererOfSelectionChange(UserTriggered);
} }
bool FrameSelection::setSelectedRange(Range* range, EAffinity affinity, bool isDirectional, SetSelectionOptions options) bool FrameSelection::setSelectedRange(Range* range, EAffinity affinity, DirectoinalOption directional, SetSelectionOptions options)
{ {
if (!range || !range->startContainer() || !range->endContainer()) if (!range || !range->startContainer() || !range->endContainer())
return false; return false;
...@@ -1418,7 +1418,7 @@ bool FrameSelection::setSelectedRange(Range* range, EAffinity affinity, bool isD ...@@ -1418,7 +1418,7 @@ bool FrameSelection::setSelectedRange(Range* range, EAffinity affinity, bool isD
m_logicalRange = nullptr; m_logicalRange = nullptr;
stopObservingVisibleSelectionChangeIfNecessary(); stopObservingVisibleSelectionChangeIfNecessary();
VisibleSelection newSelection(range, affinity, isDirectional); VisibleSelection newSelection(range, affinity, directional == Directional);
setSelection(newSelection, options); setSelection(newSelection, options);
m_logicalRange = range->cloneRange(); m_logicalRange = range->cloneRange();
......
...@@ -85,6 +85,11 @@ public: ...@@ -85,6 +85,11 @@ public:
return static_cast<EUserTriggered>(options & UserTriggered); return static_cast<EUserTriggered>(options & UserTriggered);
} }
enum DirectoinalOption {
NonDirectional,
Directional
};
Element* rootEditableElement() const { return m_selection.rootEditableElement(); } Element* rootEditableElement() const { return m_selection.rootEditableElement(); }
Element* rootEditableElementOrDocumentElement() const; Element* rootEditableElementOrDocumentElement() const;
Node* rootEditableElementOrTreeScopeRootNode() const; Node* rootEditableElementOrTreeScopeRootNode() const;
...@@ -100,7 +105,7 @@ public: ...@@ -100,7 +105,7 @@ public:
const VisibleSelection& selection() const { return m_selection; } const VisibleSelection& selection() const { return m_selection; }
void setSelection(const VisibleSelection&, SetSelectionOptions = CloseTyping | ClearTypingStyle, CursorAlignOnScroll = AlignCursorOnScrollIfNeeded, TextGranularity = CharacterGranularity); void setSelection(const VisibleSelection&, SetSelectionOptions = CloseTyping | ClearTypingStyle, CursorAlignOnScroll = AlignCursorOnScrollIfNeeded, TextGranularity = CharacterGranularity);
void setSelection(const VisibleSelection& selection, TextGranularity granularity) { setSelection(selection, CloseTyping | ClearTypingStyle, AlignCursorOnScrollIfNeeded, granularity); } void setSelection(const VisibleSelection& selection, TextGranularity granularity) { setSelection(selection, CloseTyping | ClearTypingStyle, AlignCursorOnScrollIfNeeded, granularity); }
bool setSelectedRange(Range*, EAffinity, bool isDirectional = false, SetSelectionOptions = CloseTyping | ClearTypingStyle); bool setSelectedRange(Range*, EAffinity, DirectoinalOption directional = NonDirectional, SetSelectionOptions = CloseTyping | ClearTypingStyle);
void selectAll(); void selectAll();
void clear(); void clear();
void prepareForDestruction(); void prepareForDestruction();
......
...@@ -310,7 +310,7 @@ void InputMethodController::setComposition(const String& text, const Vector<Comp ...@@ -310,7 +310,7 @@ void InputMethodController::setComposition(const String& text, const Vector<Comp
unsigned start = std::min(baseOffset + selectionStart, extentOffset); unsigned start = std::min(baseOffset + selectionStart, extentOffset);
unsigned end = std::min(std::max(start, baseOffset + selectionEnd), extentOffset); unsigned end = std::min(std::max(start, baseOffset + selectionEnd), extentOffset);
RefPtrWillBeRawPtr<Range> selectedRange = Range::create(baseNode->document(), baseNode, start, baseNode, end); RefPtrWillBeRawPtr<Range> selectedRange = Range::create(baseNode->document(), baseNode, start, baseNode, end);
m_frame.selection().setSelectedRange(selectedRange.get(), DOWNSTREAM, false, NotUserTriggered); m_frame.selection().setSelectedRange(selectedRange.get(), DOWNSTREAM, FrameSelection::NonDirectional, NotUserTriggered);
} }
} }
} }
...@@ -383,7 +383,7 @@ bool InputMethodController::setSelectionOffsets(const PlainTextRange& selectionO ...@@ -383,7 +383,7 @@ bool InputMethodController::setSelectionOffsets(const PlainTextRange& selectionO
if (!range) if (!range)
return false; return false;
return m_frame.selection().setSelectedRange(range.get(), VP_DEFAULT_AFFINITY, false, FrameSelection::CloseTyping); return m_frame.selection().setSelectedRange(range.get(), VP_DEFAULT_AFFINITY, FrameSelection::NonDirectional, FrameSelection::CloseTyping);
} }
bool InputMethodController::setEditableSelectionOffsets(const PlainTextRange& selectionOffsets) bool InputMethodController::setEditableSelectionOffsets(const PlainTextRange& selectionOffsets)
......
...@@ -214,7 +214,7 @@ void DOMSelection::collapse(Node* node, int offset, ExceptionState& exceptionSta ...@@ -214,7 +214,7 @@ void DOMSelection::collapse(Node* node, int offset, ExceptionState& exceptionSta
range->setEnd(node, offset, exceptionState); range->setEnd(node, offset, exceptionState);
if (exceptionState.hadException()) if (exceptionState.hadException())
return; return;
m_frame->selection().setSelectedRange(range.get(), DOWNSTREAM, m_frame->selection().isDirectional()); m_frame->selection().setSelectedRange(range.get(), DOWNSTREAM, m_frame->selection().isDirectional() ? FrameSelection::Directional : FrameSelection::NonDirectional);
} }
void DOMSelection::collapse(Node* node, ExceptionState& exceptionState) void DOMSelection::collapse(Node* node, ExceptionState& exceptionState)
......
...@@ -1271,7 +1271,7 @@ void WebLocalFrameImpl::selectRange(const WebPoint& base, const WebPoint& extent ...@@ -1271,7 +1271,7 @@ void WebLocalFrameImpl::selectRange(const WebPoint& base, const WebPoint& extent
void WebLocalFrameImpl::selectRange(const WebRange& webRange) void WebLocalFrameImpl::selectRange(const WebRange& webRange)
{ {
if (RefPtrWillBeRawPtr<Range> range = static_cast<PassRefPtrWillBeRawPtr<Range> >(webRange)) if (RefPtrWillBeRawPtr<Range> range = static_cast<PassRefPtrWillBeRawPtr<Range> >(webRange))
frame()->selection().setSelectedRange(range.get(), WebCore::VP_DEFAULT_AFFINITY, false, NotUserTriggered); frame()->selection().setSelectedRange(range.get(), WebCore::VP_DEFAULT_AFFINITY, FrameSelection::NonDirectional, NotUserTriggered);
} }
void WebLocalFrameImpl::moveRangeSelection(const WebPoint& base, const WebPoint& extent) void WebLocalFrameImpl::moveRangeSelection(const WebPoint& base, const WebPoint& extent)
......
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