From b598852e297ba81cfd321b482a16a169b978defc Mon Sep 17 00:00:00 2001 From: Youngbok Yoon Date: Mon, 9 Jun 2014 11:49:56 -0700 Subject: [PATCH] Hide the selection handlers and context menu while page is scrolled Issues: CBBROWSER-64, CBGRAPHICS-242 Change-Id: I1d99ba46b63bceb8a879203e34ee72b09af2486f Conflicts: impl/browser/renderer_host/render_widget_host_view_efl.cc --- .../renderer_host/render_widget_host_view_efl.cc | 31 ++++++++++++++++------ .../renderer_host/render_widget_host_view_efl.h | 3 +++ tizen_src/impl/selection_controller_efl.cc | 24 +++++++++++++++-- tizen_src/impl/selection_controller_efl.h | 8 +++++- 4 files changed, 55 insertions(+), 11 deletions(-) diff --git a/tizen_src/impl/browser/renderer_host/render_widget_host_view_efl.cc b/tizen_src/impl/browser/renderer_host/render_widget_host_view_efl.cc index 4fa7978..6efa336 100644 --- a/tizen_src/impl/browser/renderer_host/render_widget_host_view_efl.cc +++ b/tizen_src/impl/browser/renderer_host/render_widget_host_view_efl.cc @@ -474,12 +474,9 @@ bool RenderWidgetHostViewEfl::GetCompositionCharacterBounds(uint32 index, gfx::R void RenderWidgetHostViewEfl::ImeCompositionRangeChanged( const gfx::Range& range, const std::vector& character_bounds) { - SelectionControllerEfl* controller = web_view_->GetSelectionController(); - if (controller) { - if (controller->GetCaretSelectionStatus()){ - controller->SetCaretSelectionStatus(false); - } - } + SelectionControllerEfl* controller = GetSelectionController(); + if (controller && controller->GetCaretSelectionStatus()) + controller->SetCaretSelectionStatus(false); composition_character_bounds_ = character_bounds; } @@ -506,7 +503,7 @@ void RenderWidgetHostViewEfl::SetTooltipText(const base::string16& text) { void RenderWidgetHostViewEfl::SelectionChanged(const base::string16& text, size_t offset, const gfx::Range& range) { - SelectionControllerEfl* controller = web_view_->GetSelectionController(); + SelectionControllerEfl* controller = GetSelectionController(); if (controller) controller->UpdateSelectionData(text); } @@ -520,7 +517,7 @@ void RenderWidgetHostViewEfl::SelectionBoundsChanged( if (im_context_) im_context_->UpdateCaretBounds(gfx::UnionRects(guest_params.anchor_rect, guest_params.focus_rect)); - SelectionControllerEfl* controller = web_view_->GetSelectionController(); + SelectionControllerEfl* controller = GetSelectionController(); if (controller) controller->UpdateSelectionDataAndShow(guest_params.anchor_rect, guest_params.focus_rect, guest_params.is_anchor_first); } @@ -529,6 +526,12 @@ void RenderWidgetHostViewEfl::ScrollOffsetChanged() { NOTIMPLEMENTED(); } +void RenderWidgetHostViewEfl::DidStopFlinging() { + // Unhide Selection UI when scrolling with fling gesture + if (GetSelectionController() && GetSelectionController()->GetScrollStatus()) + GetSelectionController()->SetScrollStatus(false); +} + void RenderWidgetHostViewEfl::CopyFromCompositingSurface( const gfx::Rect& src_subrect, const gfx::Size& /* dst_size */, @@ -939,6 +942,14 @@ void RenderWidgetHostViewEfl::HandleGesture(ui::GestureEvent* event) { fling_cancel.type = blink::WebInputEvent::GestureFlingCancel; fling_cancel.sourceDevice = blink::WebGestureDeviceTouchscreen; host_->ForwardGestureEvent(fling_cancel); + } else if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN) { + if (GetSelectionController()) + GetSelectionController()->SetScrollStatus(true); + } else if (event->type() == ui::ET_GESTURE_SCROLL_END) { + if (GetSelectionController() && GetSelectionController()->GetScrollStatus()) + GetSelectionController()->SetScrollStatus(false); + } else if (event->type() == ui::ET_GESTURE_END) { + // Gesture end event is received (1) After scroll end (2) After Fling start } #ifdef OS_TIZEN @@ -1044,4 +1055,8 @@ void RenderWidgetHostViewEfl::OnDidChangePageScaleRange(double min_scale, double eweb_view()->DidChangePageScaleRange(min_scale, max_scale); } +SelectionControllerEfl* RenderWidgetHostViewEfl::GetSelectionController() { + return web_view_->GetSelectionController(); +} + } // namespace content diff --git a/tizen_src/impl/browser/renderer_host/render_widget_host_view_efl.h b/tizen_src/impl/browser/renderer_host/render_widget_host_view_efl.h index b082b99..38bc321 100755 --- a/tizen_src/impl/browser/renderer_host/render_widget_host_view_efl.h +++ b/tizen_src/impl/browser/renderer_host/render_widget_host_view_efl.h @@ -174,6 +174,7 @@ class RenderWidgetHostViewEfl virtual void OnCandidateWindowShown() OVERRIDE {} virtual void OnCandidateWindowUpdated() OVERRIDE {} virtual void OnCandidateWindowHidden() OVERRIDE {} + virtual void DidStopFlinging() OVERRIDE; void OnDidFirstVisuallyNonEmptyLayout(); void OnSelectionTextStyleState(const SelectionStylePrams&); @@ -230,6 +231,8 @@ class RenderWidgetHostViewEfl void OnDidChangePageScaleFactor(double); void OnDidChangePageScaleRange(double, double); + SelectionControllerEfl* GetSelectionController(); + static void CopyFromCompositingSurfaceHasResultForVideo( base::WeakPtr rwhvefl, scoped_refptr subscriber_texture, diff --git a/tizen_src/impl/selection_controller_efl.cc b/tizen_src/impl/selection_controller_efl.cc index 3da41b3..523db27 100644 --- a/tizen_src/impl/selection_controller_efl.cc +++ b/tizen_src/impl/selection_controller_efl.cc @@ -37,6 +37,7 @@ SelectionControllerEfl::SelectionControllerEfl(EWebView* parent_view) : parent_view_(parent_view), mouse_press_(false), long_mouse_press_(false), + scrolling_(false), selection_data_(new SelectionBoxEfl(parent_view)), start_handle_(new SelectionHandleEfl(this, SelectionHandleEfl::HANDLE_TYPE_LEFT, parent_view->evas_object())), end_handle_(new SelectionHandleEfl(this, SelectionHandleEfl::HANDLE_TYPE_RIGHT, parent_view->evas_object())), @@ -75,6 +76,20 @@ bool SelectionControllerEfl::GetCaretSelectionStatus() const { return selection_data_->GetCaretSelectionStatus(); } +void SelectionControllerEfl::SetScrollStatus(const bool enable) { + LOG(INFO) << __PRETTY_FUNCTION__ << " enable : " << enable; + scrolling_ = enable; + if (enable) + Clear(); + else + ShowHandleAndContextMenuIfRequired(); +} + +bool SelectionControllerEfl::GetScrollStatus() { + LOG(INFO) << __PRETTY_FUNCTION__ << " " << scrolling_; + return scrolling_; +} + void SelectionControllerEfl::UpdateSelectionData(const base::string16& text) { selection_data_->UpdateSelectStringData(text); } @@ -95,6 +110,10 @@ void SelectionControllerEfl::UpdateSelectionDataAndShow(const gfx::Rect& left_re if (long_mouse_press_) return; + // Do not show the context menu and handlers while page is scrolling + if (scrolling_) + return; + ShowHandleAndContextMenuIfRequired(); } @@ -138,6 +157,7 @@ void SelectionControllerEfl::HideHandle() { } void SelectionControllerEfl::Clear() { + parent_view_->CancelContextMenu(0); start_handle_->Hide(); end_handle_->Hide(); input_handle_->Hide(); @@ -230,15 +250,15 @@ bool SelectionControllerEfl::IsSelectionValid(const gfx::Rect& left_rect, const } void SelectionControllerEfl::ClearSelection() { - LOG(INFO) << "SelectionControllerEfl::ClearSelection"; + LOG(INFO) << __PRETTY_FUNCTION__; Clear(); - parent_view_->CancelContextMenu(0); selection_data_->SetStatus(false); SetSelectionEditable(false); SetCaretSelectionStatus(false); } void SelectionControllerEfl::OnParentParentViewMove() { + LOG(INFO) << __PRETTY_FUNCTION__; parent_view_->CancelContextMenu(0); start_handle_->Move(start_handle_->GetBasePosition()); end_handle_->Move(end_handle_->GetBasePosition()); diff --git a/tizen_src/impl/selection_controller_efl.h b/tizen_src/impl/selection_controller_efl.h index 559a309..9a5ec76 100644 --- a/tizen_src/impl/selection_controller_efl.h +++ b/tizen_src/impl/selection_controller_efl.h @@ -75,6 +75,9 @@ class SelectionControllerEfl { EWebView* GetParentView() { return parent_view_; } void HideHandle(); + void SetScrollStatus(const bool enable); + bool GetScrollStatus(); + private: void ShowHandleAndContextMenuIfRequired(); void Clear(); @@ -88,9 +91,12 @@ class SelectionControllerEfl { // Is required to send back selction points and range extenstion co-ordinates EWebView* parent_view_; - // Saves state so that context menu is not displyed during extending selection + // Saves state so that context menu is not displayed during extending selection bool mouse_press_; + // Saves state so that context menu is not displayed during page scrolling + bool scrolling_; + // Saves state so that handlers and context menu is not shown when seletion change event occurs. bool long_mouse_press_; -- 2.7.4