void SetStatus(bool enable);
bool GetStatus() const { return status_; }
- void SetEditable(bool enable) { GetContextMenuParams()->is_editable = editable_ = enable; }
- bool GetEditable() const { return editable_; }
+ void SetEditable(bool enable) { GetContextMenuParams()->is_editable = enable; }
+ bool GetEditable() const { return GetContextMenuParams()->is_editable; }
void UpdateSelectStringData(const base::string16& text);
// Returns true if the rectangle is changed.
bool UpdateRectData(const gfx::Rect& left_rect, const gfx::Rect& right_rect);
void ClearRectData();
bool IsInEditField() const;
- void SetCaretSelectionStatus(const bool enable) { is_caret_selection_ = enable; }
- bool GetCaretSelectionStatus() const { return is_caret_selection_; }
gfx::Rect GetLeftRect() const { return left_rect_; }
gfx::Rect GetRightRect() const { return right_rect_; }
void SetIsAnchorFirst(bool value) { is_anchor_first_ = value; }
// Save the state of selection, if active or not
bool status_;
- // Save if the selection is in one of the editable fields
- bool editable_;
-
- // Caret is in a input field
- bool is_caret_selection_;
-
// Start of selection
gfx::Rect left_rect_;
is_selection_visible_(false),
show_only_large_handle_(false),
handle_being_dragged_(false),
- web_contents_(web_contents) {
+ web_contents_(web_contents),
+ selection_mode_(None) {
evas_object_event_callback_add(parent_view_, EVAS_CALLBACK_MOVE, &EvasParentViewMoveCallback, this);
#if defined(OS_TIZEN)
return selection_data_->GetEditable();
}
-void SelectionControllerEfl::SetCaretSelectionStatus(const bool enable) {
- TRACE_EVENT1("selection,efl", __PRETTY_FUNCTION__, "caret selection", enable);
- selection_data_->SetCaretSelectionStatus(enable);
-}
-
bool SelectionControllerEfl::GetCaretSelectionStatus() const {
TRACE_EVENT1("selection,efl", __PRETTY_FUNCTION__,
- "caret selection", selection_data_->GetCaretSelectionStatus());
- return selection_data_->GetCaretSelectionStatus();
+ "caret selection", selection_mode_ == Caret);
+ return selection_mode_ == Caret;
}
void SelectionControllerEfl::SetScrollStatus(const bool enable) {
return false;
}
+void SelectionControllerEfl::SetSelectionMode(enum SelectionMode mode) {
+ selection_mode_ = mode;
+}
+
+void SelectionControllerEfl::DetermineSelectionMode(
+ const gfx::Rect& left_rect,
+ const gfx::Rect& right_rect) {
+
+ if (left_rect == gfx::Rect() && right_rect == gfx::Rect())
+ SetSelectionMode(None);
+ else if (left_rect == right_rect && GetSelectionEditable())
+ SetSelectionMode(Caret);
+ else
+ SetSelectionMode(Range);
+}
+
bool SelectionControllerEfl::UpdateSelectionDataAndShow(
const gfx::Rect& left_rect,
const gfx::Rect& right_rect,
bool show) {
+
+ DetermineSelectionMode(left_rect, right_rect);
+
TRACE_EVENT0("selection,efl", __PRETTY_FUNCTION__);
if (!show && !IsSelectionValid(left_rect, right_rect)) {
if (!GetCaretSelectionStatus())
}
gfx::Rect left = selection_data_->GetLeftRect();
- if (selection_data_->GetCaretSelectionStatus()) {
+ if (GetCaretSelectionStatus()) {
input_handle_->SetBasePosition(gfx::Point(left.x(), left.y()));
input_handle_->Move(left.bottom_right());
input_handle_->Show();
}
void SelectionControllerEfl::HideHandles() {
- SetCaretSelectionStatus(false);
Clear();
}
void SelectionControllerEfl::HandleLongPressEventPrivate(const gfx::Point& touch_point) {
show_only_large_handle_ = false;
Clear();
- if (selection_data_->IsInEditField())
- SetCaretSelectionStatus(true);
Evas_Coord x, y;
evas_object_geometry_get(parent_view_, &x, &y, 0, 0);
if (rwhv)
rwhv->MoveCaret(gfx::Point(touch_point.x() - x, touch_point.y() - y));
SetSelectionStatus(true);
- SetCaretSelectionStatus(true);
} else{
if (rwhv)
rwhv->SelectClosestWord(touch_point);
long_mouse_press_ = false;
if (scrolling_)
show_after_scroll_ = true;
- if (selection_data_->GetCaretSelectionStatus()) {
+ if (GetCaretSelectionStatus()) {
SetSelectionStatus(true);
SetSelectionEditable(true);
}
DVLOG(1) << "DispatchPostponedGestureEvent :: Editable";
SetSelectionStatus(true);
if (GetSelectionEditable()){
- SetCaretSelectionStatus(true);
UpdateSelectionDataAndShow(
GetLeftRect(), GetRightRect(), false);
} else {
}
} else {
SetSelectionEditable(false);
- SetCaretSelectionStatus(false);
}
}
if (!GetSelectionStatus())
SetSelectionStatus(true);
- if ((left_rect.x() != right_rect.x() || left_rect.y() != right_rect.y()) &&
- selection_data_->IsInEditField() && GetCaretSelectionStatus()) {
- if (!long_mouse_press_)
- SetCaretSelectionStatus(false);
- }
-
return true;
}
Clear();
selection_data_->SetStatus(false);
SetSelectionEditable(false);
- SetCaretSelectionStatus(false);
+ SetSelectionMode(None);
}
void SelectionControllerEfl::OnParentParentViewMove() {
// Set if selection is valid
void SetSelectionStatus(bool enable);
bool GetSelectionStatus() const;
+
// Set if selection is in edit field
void SetSelectionEditable(bool enable);
bool GetSelectionEditable() const;
+ bool GetCaretSelectionStatus() const;
+
// Set if the selection base (or anchor) comes logically
// first than its respective extent.
void SetIsAnchorFirst(bool value);
void HandleDragUpdateNotification(SelectionHandleEfl*);
void HandleDragEndNotification();
- void SetCaretSelectionStatus(const bool enable);
- bool GetCaretSelectionStatus() const;
-
// Clears the selection and hides context menu and handles
void ClearSelection();
bool ClearSelectionViaEWebView();
void HandleGestureEnd();
private:
+ enum SelectionMode {
+ None = 0,
+ Caret,
+ Range
+ };
+ void DetermineSelectionMode(const gfx::Rect& left_rect, const gfx::Rect& right_rect);
+ void SetSelectionMode(enum SelectionMode);
+
void HandleLongPressEventPrivate(const gfx::Point& touch_point);
void ShowHandleAndContextMenuIfRequired();
WebContents& web_contents_;
+ enum SelectionMode selection_mode_;
ui::SelectionBound start_selection_;
ui::SelectionBound end_selection_;
};