Text selection was refactored.
Selection handles and controller was moved to chromium_impl.
Whole change contains 3 patches(chromium-efl, s-blink, s-chromium)
Together with: Id00120d7f4cec49d16a110baa74a58e86d95cd37
Bug: http://web.sec.samsung.net/bugzilla/show_bug.cgi?id=12549
Reviewed by: Antonio Gomes, Hyunhak Kim, Piotr Grad, SeungSeop Park
Change-Id: Id62ff99f1aff9deeb72bc989a139ca9214ae092a
Signed-off-by: Karol Furmaniak <k.furmaniak@samsung.com>
Signed-off-by: Arnaud Renevier <a.renevier@samsung.com>
#include "content/browser/renderer_host/disambiguation_popup_efl.h"
#include "content/browser/renderer_host/web_event_factory_efl.h"
#include "content/browser/renderer_host/input/web_input_event_util.h"
+#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/browser/gpu/gpu_process_host.h"
#include "content/common/gpu/client/gl_helper.h"
#include "content/common/input/did_overscroll_params.h"
results->depthPerComponent = 8;
}
-RenderWidgetHostViewEfl::RenderWidgetHostViewEfl(RenderWidgetHost* widget)
+RenderWidgetHostViewEfl::RenderWidgetHostViewEfl(RenderWidgetHost* widget,
+ WebContents& web_contents)
: host_(RenderWidgetHostImpl::From(widget)),
im_context_(NULL),
evas_(NULL),
touch_events_enabled_(false),
should_restore_selection_menu_(false),
selection_acked_on_tap_(false),
- was_scrolled_(false) {
+ was_scrolled_(false),
+ web_contents_(web_contents),
+ single_tap_performed_(false) {
SetDoubleTapSupportEnabled(touch_events_enabled_);
IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostViewEfl, message)
IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged, OnTextInputStateChanged)
IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputInFormStateChanged, OnTextInputInFormStateChanged)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_HitTestAsyncReply, OnHitTestAsyncReply)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
return host_->Send(message);
}
+void RenderWidgetHostViewEfl::OnHitTestAsyncReply(
+ const ViewHostMsg_HitTestAsyncReply_Params& params,
+ int64_t request_id) {
+
+ if (GetSelectionController())
+ GetSelectionController()->OnHitTestAsyncReply(
+ params, request_id);
+}
+
void RenderWidgetHostViewEfl::InitAsPopup(RenderWidgetHostView*, const gfx::Rect&) {
NOTIMPLEMENTED();
}
ui::TextInputMode input_mode,
bool can_compose_inline,
int flags) {
-#if defined(EWK_REFACTOR)
if (GetSelectionController()) {
GetSelectionController()->SetSelectionEditable(
type != ui::TEXT_INPUT_TYPE_NONE);
}
-#endif
}
void RenderWidgetHostViewEfl::OnTextInputStateChanged(
const ViewHostMsg_TextInputState_Params& params) {
+ if (GetSelectionController()) {
+ GetSelectionController()->SetSelectionEditable(
+ params.type != ui::TEXT_INPUT_TYPE_NONE);
+ }
if (!params.show_ime_if_needed
#if defined(EWK_REFACTOR)
&& !eweb_view()->GetSettings()->useKeyPadWithoutUserAction()
// is turned on
host_->ScrollFocusedEditableNodeIntoRect(gfx::Rect(0, 0, 0, 0));
}
-#if defined(EWK_REFACTOR)
- if (GetSelectionController()) {
- GetSelectionController()->SetSelectionEditable(
- params.type != ui::TEXT_INPUT_TYPE_NONE);
- }
-#endif
}
void RenderWidgetHostViewEfl::OnTextInputInFormStateChanged(bool is_in_form_tag) {
void RenderWidgetHostViewEfl::ImeCompositionRangeChanged(
const gfx::Range& range,
const std::vector<gfx::Rect>& character_bounds) {
- NOTIMPLEMENTED();
-#if defined(EWK_REFACTOR)
- if (web_view_) {
- SelectionControllerEfl* controller = web_view_->GetSelectionController();
- if (controller) {
- controller->SetCaretSelectionStatus(false);
- controller->HideHandleAndContextMenu();
- }
+
+ if (GetSelectionController()) {
+ GetSelectionController()->SetCaretSelectionStatus(false);
+ GetSelectionController()->HideHandleAndContextMenu();
}
-#endif
}
void RenderWidgetHostViewEfl::FocusedNodeChanged(bool is_editable_node) {
-#if defined(EWK_REFACTOR)
- if (web_view_) {
- SelectionControllerEfl* controller = web_view_->GetSelectionController();
- if (controller) {
- controller->SetCaretSelectionStatus(false);
- controller->HideHandleAndContextMenu();
- }
- if (im_context_ && im_context_->IsShow() &&
- ClipboardHelperEfl::GetInstance()->IsClipboardWindowOpened()) {
- ClipboardHelperEfl::GetInstance()->CloseClipboardWindow();
- }
+ if (GetSelectionController()) {
+ GetSelectionController()->SetCaretSelectionStatus(false);
+ GetSelectionController()->HideHandleAndContextMenu();
+ }
+ if (im_context_ && im_context_->IsShow() &&
+ ClipboardHelperEfl::GetInstance()->IsClipboardWindowOpened()) {
+ ClipboardHelperEfl::GetInstance()->CloseClipboardWindow();
}
-#endif
}
void RenderWidgetHostViewEfl::Destroy() {
size_t offset,
const gfx::Range& range) {
RenderWidgetHostViewBase::SelectionChanged(text, offset, range);
-#if defined(EWK_REFACTOR)
- if (!web_view_)
- return;
- SelectionControllerEfl* controller = web_view_->GetSelectionController();
- if (!controller)
+ if (!GetSelectionController())
return;
base::string16 selectedText;
if (!text.empty() && !range.is_empty())
selectedText = GetSelectedText();
- controller->UpdateSelectionData(selectedText);
-#endif
+ GetSelectionController()->UpdateSelectionData(selectedText);
}
void RenderWidgetHostViewEfl::SelectionBoundsChanged(
if (im_context_)
im_context_->UpdateCaretBounds(gfx::UnionRects(guest_params.anchor_rect, guest_params.focus_rect));
-#if defined(EWK_REFACTOR)
+
if (GetSelectionController()) {
GetSelectionController()->UpdateSelectionDataAndShow(
guest_params.anchor_rect,
guest_params.is_anchor_first,
false);
}
+}
+
+void RenderWidgetHostViewEfl::SelectionRootBoundsChanged(const gfx::Rect& rect) {
+ if (GetSelectionController()) {
+ GetSelectionController()->SetVisibilityBounds(
+ ConvertRectToPixel(device_scale_factor_, rect));
+ }
+}
+
+void RenderWidgetHostViewEfl::ExecuteEditCommand(const char* command, const char* value) {
+ EINA_SAFETY_ON_NULL_RETURN(command);
+
+ value = (value == NULL) ? "" : value;
+
+ RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(web_contents_.GetRenderViewHost());
+
+ rvhi->ExecuteEditCommand(command, value);
+
+#if defined(EWK_REFACTOR)
+ // This is workaround for rich text toolbar buttons in email application
+ if ( !strcmp(command, "InsertOrderedList")
+ || !strcmp(command, "InsertUnorderedList")
+ || !strcmp(command, "AlignCenter")
+ || !strcmp(command, "AlignJustified")
+ || !strcmp(command, "AlignLeft")
+ || !strcmp(command, "AlignRight") ) {
+ QuerySelectionStyle();
+ }
#endif
}
void RenderWidgetHostViewEfl::DidStopFlinging() {
edge_effect_->Hide();
-#if defined(EWK_REFACTOR)
+
SelectionControllerEfl* controller = GetSelectionController();
if (!controller)
return;
controller->GetRightRect(),
false,
false);
-#endif
+}
+
+void RenderWidgetHostViewEfl::EvasToBlinkCords(int x, int y, int* view_x, int* view_y) {
+ Evas_Coord tmpX, tmpY;
+ evas_object_geometry_get(smart_parent(), &tmpX, &tmpY, NULL, NULL);
+
+ if (view_x) {
+ *view_x = x - tmpX;
+ *view_x /= device_scale_factor_;
+ }
+
+ if (view_y) {
+ *view_y = y - tmpY;
+ *view_y /= device_scale_factor_;
+ }
+}
+
+void RenderWidgetHostViewEfl::SelectClosestWord(const gfx::Point& touch_point) {
+ int view_x, view_y;
+ EvasToBlinkCords(touch_point.x(), touch_point.y(), &view_x, &view_y);
+
+ Send(new ViewMsg_SelectClosestWord(
+ host_->GetRoutingID(), view_x, view_y));
}
void RenderWidgetHostViewEfl::ShowDisambiguationPopup(const gfx::Rect& rect_pixels, const SkBitmap& zoomed_bitmap) {
void RenderWidgetHostViewEfl::HandleGestureBegin() {
edge_effect_->Enable();
-#if defined(EWK_REFACTOR)
selection_acked_on_tap_ = false;
+ single_tap_performed_ = false;
was_scrolled_ = false;
if (GetSelectionController()) {
should_restore_selection_menu_ =
GetSelectionController()->IsAnyHandleVisible();
+ // There can be multiple GestureBegin, but we need
+ // only state of showing large handle at first time
+ if (!restore_showing_large_handle_on_gesture_end_) {
+ restore_showing_large_handle_on_gesture_end_.reset(
+ new bool(GetSelectionController()->GetShowOnlyLargeHandle()));
+ GetSelectionController()->SetShowOnlyLargeHandle(false);
+ }
}
-#endif
}
void RenderWidgetHostViewEfl::HandleGestureEnd() {
- edge_effect_->Disable();
-#if defined(EWK_REFACTOR)
if (GetSelectionController()) {
- if (GetSelectionController()->GetScrollStatus())
- GetSelectionController()->SetScrollStatus(false);
-
if (should_restore_selection_menu_ && !was_scrolled_ &&
- !selection_acked_on_tap_) {
+ !selection_acked_on_tap_ &&
+ !(single_tap_performed_ &&
+ GetSelectionController()->GetSelectionEditable())) {
should_restore_selection_menu_ = false;
GetSelectionController()->HideHandleAndContextMenu();
- } else if (GetSelectionController()->GetSelectionStatus()) {
- GetSelectionController()->UpdateSelectionDataAndShow(
- GetSelectionController()->GetLeftRect(),
- GetSelectionController()->GetRightRect(),
- false /* unused */,
- should_restore_selection_menu_);
+ }
+
+ if (restore_showing_large_handle_on_gesture_end_) {
+ GetSelectionController()->SetShowOnlyLargeHandle(
+ *restore_showing_large_handle_on_gesture_end_);
+ restore_showing_large_handle_on_gesture_end_.reset();
}
}
+ single_tap_performed_ = false;
// Edge effect should be disabled upon scroll end/fling start.
// Gesture end comes just after those events, so it's disabled here.
-#endif
+ edge_effect_->Disable();
}
void RenderWidgetHostViewEfl::HandleGesture(
blink::WebGestureEvent& event) {
-#if defined(EWK_REFACTOR)
- if (event.type == blink::WebInputEvent::GestureTap) {
- eweb_view()->HandlePostponedGesture(event.x, event.y, ui::ET_GESTURE_TAP);
- } else if (event.type == blink::WebInputEvent::GestureShowPress) {
- eweb_view()->HandlePostponedGesture(
- event.x, event.y, ui::ET_GESTURE_SHOW_PRESS);
- } else if (event.type == blink::WebInputEvent::GestureLongPress) {
- eweb_view()->HandlePostponedGesture(
- event.x, event.y, ui::ET_GESTURE_LONG_PRESS);
- }
+ SelectionControllerEfl* controller = GetSelectionController();
+ if (controller)
+ controller->HandleGesture(event,
+ restore_showing_large_handle_on_gesture_end_,
+ should_restore_selection_menu_);
+#if defined(EWK_REFACTOR)
if ((event.type == blink::WebInputEvent::GesturePinchBegin ||
event.type == blink::WebInputEvent::GesturePinchUpdate ||
event.type == blink::WebInputEvent::GesturePinchEnd) &&
event.type == blink::WebInputEvent::GesturePinchEnd) {
eweb_view()->SmartCallback<EWebViewCallbacks::ZoomFinished>().call();
}
+#endif
if (event.type == blink::WebInputEvent::GestureTap ||
event.type == blink::WebInputEvent::GestureTapCancel) {
fling_cancel.type = blink::WebInputEvent::GestureFlingCancel;
fling_cancel.sourceDevice = blink::WebGestureDeviceTouchscreen;
SendGestureEvent(fling_cancel);
+ single_tap_performed_ = true;
} else if (event.type == blink::WebInputEvent::GestureTapCancel ||
event.type == blink::WebInputEvent::GestureTapUnconfirmed) {
selection_acked_on_tap_ = should_restore_selection_menu_;
+ single_tap_performed_ = false;
} else if (event.type == blink::WebInputEvent::GestureScrollBegin) {
was_scrolled_ = true;
- if (GetSelectionController())
- GetSelectionController()->SetScrollStatus(true);
- } else
-#endif
- DCHECK(edge_effect_.get());
- if (event.type == blink::WebInputEvent::GestureScrollUpdate) {
+ } else if (event.type == blink::WebInputEvent::GestureScrollUpdate) {
+ DCHECK(edge_effect_.get());
if (event.data.scrollUpdate.deltaX < 0)
edge_effect_->Hide("edge,left");
else if (event.data.scrollUpdate.deltaX > 0)
current_orientation_ = orientation;
}
-#if defined(EWK_REFACTOR)
SelectionControllerEfl* RenderWidgetHostViewEfl::GetSelectionController() {
- if (web_view_)
- return web_view_->GetSelectionController();
- return NULL;
+ WebContentsImpl* wci = static_cast<WebContentsImpl*>(&web_contents_);
+ DCHECK(wci);
+ WebContentsViewEfl* wcve = static_cast<WebContentsViewEfl*>(wci->GetView());
+ DCHECK(wcve);
+ return wcve->GetSelectionController();
}
-#endif
void RenderWidgetHostViewEfl::MoveCaret(const gfx::Point& point) {
host_->MoveCaret(gfx::Point(point.x() / device_scale_factor_, point.y() / device_scale_factor_));
#include "base/format_macros.h"
#include "content/browser/renderer_host/render_widget_host_view_base.h"
#include "content/browser/renderer_host/evas_event_handler.h"
+#include "content/browser/web_contents/web_contents_impl.h"
+#include "content/browser/web_contents/web_contents_view_efl.h"
#include "content/common/content_export.h"
#include "cc/layers/delegated_frame_provider.h"
#include "cc/layers/delegated_frame_resource_collection.h"
#include "gpu/command_buffer/common/mailbox.h"
#include "ui/base/ime/composition_text.h"
#include "ui/base/ime/text_input_client.h"
+#include "ui/base/selection/selection_controller_efl.h"
#include "ui/events/gestures/gesture_types.h"
#include "ui/events/gestures/gesture_recognizer.h"
#include "ui/events/gestures/motion_event_aura.h"
#endif
struct ViewHostMsg_TextInputState_Params;
+struct ViewHostMsg_HitTestAsyncReply_Params;
namespace ui {
class GestureEvent;
class RenderWidgetHostImpl;
class RenderWidgetHostView;
class ReadbackYUVInterface;
+class WebContents;
// RenderWidgetHostView class hierarchy described in render_widget_host_view.h.
class RenderWidgetHostViewEfl
public base::SupportsWeakPtr<RenderWidgetHostViewEfl>,
public IPC::Sender {
public:
- explicit RenderWidgetHostViewEfl(RenderWidgetHost*);
+ explicit RenderWidgetHostViewEfl(RenderWidgetHost*, WebContents& web_contents);
// RenderWidgetHostViewBase implementation.
void InitAsChild(gfx::NativeView) override;
void OnTextInputInFormStateChanged(bool is_in_form_tag);
void OnTextInputStateChanged(const ViewHostMsg_TextInputState_Params& params);
+ void OnHitTestAsyncReply(const
+ ViewHostMsg_HitTestAsyncReply_Params& params,
+ int64_t request_id);
void TextInputTypeChanged(ui::TextInputType type,
ui::TextInputMode mode,
void SetTooltipText(const base::string16&) override;
void SelectionChanged(const base::string16&, size_t, const gfx::Range&) override;
void SelectionBoundsChanged(const ViewHostMsg_SelectionBounds_Params&) override;
+ void SelectionRootBoundsChanged(const gfx::Rect&) override;
void CopyFromCompositingSurface(
const gfx::Rect&,
const gfx::Size& /* dst_size */,
void FilterInputMotion(const blink::WebGestureEvent& gesture_event);
+ void EvasToBlinkCords(int x, int y, int* view_x, int* view_y);
+ void SelectClosestWord(const gfx::Point& touch_point);
+
Evas* evas() const {
DCHECK(evas_);
return evas_;
bool IsIMEShow() const;
gfx::Rect GetIMERect() const;
+ void ExecuteEditCommand(const char* command, const char* value);
protected:
friend class RenderWidgetHostView;
void OnOrientationChangeEvent(int);
-#if 0
SelectionControllerEfl* GetSelectionController();
-#endif
static void CopyFromCompositingSurfaceHasResultForVideo(
base::WeakPtr<RenderWidgetHostViewEfl> rwhvefl,
static void EvasObjectImagePixelsGetCallback(void*, Evas_Object*);
void initializeProgram();
+ void HandleLongPressGesture(int x, int y,
+ const ViewHostMsg_HitTestAsyncReply_Params& params);
+ void HandleTapGesture(int x, int y,
+ const ViewHostMsg_HitTestAsyncReply_Params& params);
+
#if defined(USE_WAYLAND)
Ecore_Wl_Window* GetEcoreWlWindow() const;
#else
gpu::Mailbox pending_mailbox_;
+ WebContents& web_contents_;
+
+ bool single_tap_performed_;
+ // when gesture start, state of showing large handle
+ // is saved and restored when gesture will end.
+ scoped_ptr<bool> restore_showing_large_handle_on_gesture_end_;
+
DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewEfl);
};
RenderWidgetHost* render_widget_host, bool is_guest_view_hack) {
RenderWidgetHostViewEfl* view =
- new RenderWidgetHostViewEfl(render_widget_host);
+ new RenderWidgetHostViewEfl(render_widget_host, *web_contents_);
view->InitAsChild(native_view_);
+ selection_controller_.reset(new SelectionControllerEfl(
+ view->smart_parent(), *web_contents_));
+
elm_naviframe_item_pop(native_view_);
Evas_Object* content_view = static_cast<Evas_Object*>(view->GetNativeView());
Elm_Object_Item* item = elm_naviframe_item_push(native_view_,
view->Show();
SetOrientation(orientation_);
-
return view;
}
RenderWidgetHostViewBase* WebContentsViewEfl::CreateViewForPopupWidget(
RenderWidgetHost* render_widget_host) {
- return new RenderWidgetHostViewEfl(render_widget_host);
+ return new RenderWidgetHostViewEfl(render_widget_host, *web_contents_);
}
void WebContentsViewEfl::SetPageTitle(const base::string16& title) {
efl_delegate_->SetPageTitle(title);
}
+void WebContentsViewEfl::CancelContextMenu(int request_id) {
+ if (efl_delegate_)
+ efl_delegate_->CancelContextMenu(request_id);
+}
+
void WebContentsViewEfl::UpdateDragDest(RenderViewHost* host) {
// Drag-and-drop is entirely managed by BrowserPluginGuest for guest
// processes in a largely platform independent way. WebDragDestEfl
#include "content/browser/renderer_host/render_view_host_delegate_view.h"
#include "content/browser/web_contents/web_contents_view.h"
+#include "ui/base/selection/selection_controller_efl.h"
namespace content {
const gfx::ImageSkia& image,
const gfx::Vector2d& image_offset,
const DragEventSourceInfo& event_info) override;
+ void CancelContextMenu(int request_id);
bool IsDragging() const;
void SetOrientation(int orientation);
void SetTouchEventsEnabled(bool);
void SetPageScaleFactor(float);
+ SelectionControllerEfl* GetSelectionController() const {
+ return selection_controller_.get();
+ }
private:
// Our optional, generic views wrapper.
float page_scale_factor_;
WebContents* web_contents_;
+ scoped_ptr<SelectionControllerEfl> selection_controller_;
DISALLOW_COPY_AND_ASSIGN(WebContentsViewEfl);
};
virtual void HidePopupMenu() = 0;
virtual void SetPageTitle(const base::string16& title) = 0;
+ virtual void CancelContextMenu(int request_id) = 0;
};
} // namespace content
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "eweb_view.h"
-#include "selection_box_efl.h"
+#include "base/trace_event/trace_event.h"
+#include "ui/base/selection/selection_box_efl.h"
namespace content {
-SelectionBoxEfl::SelectionBoxEfl(EWebView* parent_view)
+SelectionBoxEfl::SelectionBoxEfl(Evas_Object* parent_view)
: status_(false),
editable_(false),
is_caret_selection_(false),
+ is_anchor_first_(false),
context_params_(new ContextMenuParams()),
parent_view_(parent_view) {
context_params_->has_image_contents = false;
ret = true;
left_rect_ = left_rect;
right_rect_ = right_rect;
+ is_anchor_first_ = true;
} else {
if (left_rect_ != right_rect || right_rect_ != left_rect)
ret = true;
right_rect_ = left_rect;
left_rect_ = right_rect;
+ is_anchor_first_ = false;
}
// Display point of context Menu
Evas_Coord x, y;
- evas_object_geometry_get(parent_view_->evas_object(), &x, &y, 0, 0);
+ evas_object_geometry_get(parent_view_, &x, &y, 0, 0);
//context params suppose to be global - related to evas not the web view
ret |= (context_params_->x != (left_rect_.x() + x));
ret |= (context_params_->y != (left_rect_.y() + y));
status_ = enable;
// invoke CB only if mode actually changed
- if (invokeCbAtEnd)
- parent_view_->SmartCallback<EWebViewCallbacks::TextSelectionMode>().call(&status_);
+ if (invokeCbAtEnd && parent_view_)
+ evas_object_smart_callback_call(parent_view_, "textselection,mode", &status_);
}
}
#ifndef selection_box_efl_h
#define selection_box_efl_h
+#include <Evas.h>
+
#include "base/memory/scoped_ptr.h"
#include "content/public/common/context_menu_params.h"
#include "content/public/common/menu_item.h"
// controlling
class SelectionBoxEfl {
public:
- SelectionBoxEfl(EWebView* parent_view);
+ SelectionBoxEfl(Evas_Object* parent_view);
void SetStatus(bool enable);
bool GetStatus() const { return status_; }
bool GetCaretSelectionStatus() const { return is_caret_selection_; }
gfx::Rect GetLeftRect() const { return left_rect_; }
gfx::Rect GetRightRect() const { return right_rect_; }
+ bool GetIsAnchorFirst() const { return is_anchor_first_; }
ContextMenuParams* GetContextMenuParams() const { return context_params_.get(); }
private:
// End of selection
gfx::Rect right_rect_;
+ bool is_anchor_first_;
+
// Contains the menu item data for which context needs to be populated
scoped_ptr<ContextMenuParams> context_params_;
- EWebView* parent_view_;
+ Evas_Object* parent_view_;
};
}
#include <Edje.h>
+#include "base/trace_event/trace_event.h"
#include "content/browser/renderer_host/render_widget_host_view_efl.h"
+#include "content/browser/renderer_host/render_widget_host_impl.h"
+#include "content/browser/renderer_host/render_view_host_impl.h"
+#include "content/browser/web_contents/web_contents_impl.h"
+#include "content/browser/web_contents/web_contents_impl_efl.h"
+#include "content/common/view_messages.h"
#include "content/public/browser/web_contents.h"
-#include "eweb_view.h"
-#include "public/ewk_hit_test.h"
+#include "content/public/browser/render_view_host.h"
+#include "content/public/common/context_menu_params.h"
#include "ui/gfx/screen.h"
namespace content {
+class ScAsyncRequestHitTestDataCallback
+{
+ public:
+ ScAsyncRequestHitTestDataCallback(const gfx::Point& point)
+ : point_(point) {
+ }
+ virtual ~ScAsyncRequestHitTestDataCallback() {};
+
+ virtual void Run(const ViewHostMsg_HitTestAsyncReply_Params& params,
+ SelectionControllerEfl* controller) = 0;
+
+ protected:
+ const gfx::Point& GetPoint() const { return point_; }
+
+ private:
+ const gfx::Point& point_;
+};
+
+class RwhvAsyncRequestHitTestDataInternalCallback
+ : public ScAsyncRequestHitTestDataCallback
+{
+ public:
+ typedef void (SelectionControllerEfl::*Callback)(const gfx::Point&,
+ const ViewHostMsg_HitTestAsyncReply_Params& params);
+
+ public:
+ RwhvAsyncRequestHitTestDataInternalCallback(const gfx::Point& point,
+ Callback cb)
+ : ScAsyncRequestHitTestDataCallback(point)
+ , callback_(cb) {
+ }
+
+ void Run(const ViewHostMsg_HitTestAsyncReply_Params& params,
+ SelectionControllerEfl* controller) override {
+ DCHECK(callback_);
+ (controller->*callback_)(GetPoint(), params);
+ }
+
+ private:
+ Callback callback_;
+};
+
static const int menuHeight = 140;// The Height fo the context menu.
static const int menuPadding = 60;// This is padding for deciding when to modify context menu position.
static const int spacePadding = 0; // 24;// This is for making context menu closer to the handles.
return (rect.x() == 0 && rect.y() == 0 && rect.height() == 0 && rect.width() == 0);
}
-SelectionControllerEfl::SelectionControllerEfl(EWebView* parent_view, WebContents& web_contents)
+SelectionControllerEfl::SelectionControllerEfl(Evas_Object* parent_view, WebContents& web_contents)
: parent_view_(parent_view),
mouse_press_(false),
scrolling_(false),
long_mouse_press_(false),
caret_selection_(true),
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())),
- input_handle_(new SelectionHandleEfl(*this, SelectionHandleEfl::HANDLE_TYPE_INPUT, parent_view->evas_object())),
+ start_handle_(new SelectionHandleEfl(*this, SelectionHandleEfl::HANDLE_TYPE_LEFT, parent_view)),
+ end_handle_(new SelectionHandleEfl(*this, SelectionHandleEfl::HANDLE_TYPE_RIGHT, parent_view)),
+ input_handle_(new SelectionHandleEfl(*this, SelectionHandleEfl::HANDLE_TYPE_INPUT, parent_view)),
- magnifier_(new SelectionMagnifierEfl(this)),
+ magnifier_(new SelectionMagnifierEfl(this, web_contents)),
is_selection_visible_(false),
- show_only_large_handler_(false),
+ show_only_large_handle_(false),
web_contents_(web_contents) {
- evas_object_event_callback_add(parent_view_->evas_object(), EVAS_CALLBACK_MOVE, &EvasParentViewMoveCallback, this);
+ evas_object_event_callback_add(parent_view_, EVAS_CALLBACK_MOVE, &EvasParentViewMoveCallback, this);
#if defined(OS_TIZEN)
vconf_notify_key_changed(VCONFKEY_LANGSET, PlatformLanguageChanged, this);
#endif
}
+SelectionControllerEfl::~SelectionControllerEfl() {
+ std::map<int64_t, ScAsyncRequestHitTestDataCallback*>::iterator hit_test_callback_iterator;
+ for (hit_test_callback_iterator = hit_test_callback_.begin();
+ hit_test_callback_iterator != hit_test_callback_.end();
+ hit_test_callback_iterator++)
+ delete hit_test_callback_iterator->second;
+ hit_test_callback_.clear();
+}
+
void SelectionControllerEfl::SetSelectionStatus(bool enable) {
TRACE_EVENT1("selection,efl", __PRETTY_FUNCTION__, "enable", enable);
selection_data_->SetStatus(enable);
void SelectionControllerEfl::SetScrollStatus(const bool enable) {
TRACE_EVENT1("selection,efl", __PRETTY_FUNCTION__, "scroll status", enable);
+ if (scrolling_ && enable)
+ return;
+
scrolling_ = enable;
if (enable) {
Clear(IsAnyHandleVisible() || postponed_);
- parent_view_->CancelContextMenu(0);
+ CancelContextMenu(0);
} else if (show_after_scroll_ || postponed_) {
ShowHandleAndContextMenuIfRequired();
}
}
bool SelectionControllerEfl::ClearSelectionViaEWebView() {
+ RenderWidgetHostViewEfl* rwhv =
+ static_cast<RenderWidgetHostViewEfl*>(web_contents_.GetRenderWidgetHostView());
if (GetSelectionStatus()) {
- parent_view_->ExecuteEditCommand("Unselect", NULL);
+ if (rwhv)
+ rwhv->ExecuteEditCommand("Unselect", NULL);
return true;
}
bool,
bool show) {
TRACE_EVENT0("selection,efl", __PRETTY_FUNCTION__);
-
if (!show && !IsSelectionValid(left_rect, right_rect)) {
if (!GetCaretSelectionStatus())
ClearSelection();
selection_data_->UpdateRectData(left_rect, right_rect);
return false;
}
-
- RenderWidgetHostViewEfl* rwhv = static_cast<RenderWidgetHostViewEfl*>(web_contents_.GetRenderWidgetHostView());
- if (show_only_large_handler_ && GetCaretSelectionStatus() &&
+ RenderWidgetHostViewEfl* rwhv =
+ static_cast<RenderWidgetHostViewEfl*>(web_contents_.GetRenderWidgetHostView());
+ if (show_only_large_handle_ && GetCaretSelectionStatus() &&
(rwhv && !rwhv->IsLastAvailableTextEmpty())) {
selection_data_->UpdateRectData(left_rect, right_rect);
ShowHandleAndContextMenuIfRequired();
return true;
}
-
if ((selection_data_->UpdateRectData(left_rect, right_rect) &&
IsAnyHandleVisible()) || show || postponed_) {
- show_only_large_handler_ = false;
- if (selection_data_->GetEditable()) {
- // In case we're selecting text in editable text field we've already sent
- // swapped coordinates from OnMouseMove. No need to do it for the second
- // time.
- ShowHandleAndContextMenuIfRequired();
- } else {
- ShowHandleAndContextMenuIfRequired(left_rect < right_rect);
- }
+ show_only_large_handle_ = false;
+ ShowHandleAndContextMenuIfRequired();
}
-
expecting_update_ = false;
return true;
}
-namespace {
-class HitTestContext
-{
-public:
- HitTestContext(SelectionControllerEfl* ctrl, bool anchor)
- : owner(ctrl)
- , anchor_first(anchor) {
- }
-
- SelectionControllerEfl* GetOwner() const { return owner; }
- bool GetAnchorFirst() const { return anchor_first; }
-
-private:
- SelectionControllerEfl* owner;
- bool anchor_first;
-};
-} // namespace
-
-void SelectionControllerEfl::ShowHandleAndContextMenuIfRequiredCallback(
- Evas_Object* o, int x, int y, int mode, _Ewk_Hit_Test* hit_test,
- void* data) {
- HitTestContext* context = static_cast<HitTestContext*>(data);
- DCHECK(context);
- DCHECK(context->GetOwner());
- context->GetOwner()->ShowHandleAndContextMenuIfRequired(
- o, x, y, mode, hit_test, context->GetAnchorFirst());
- delete context;
-}
-
void SelectionControllerEfl::ShowHandleAndContextMenuIfRequired(
- Evas_Object* o, int x, int y, int /* mode*/,
- _Ewk_Hit_Test* hit_test, bool anchor_first) {
+ int x, int y) {
if (scrolling_)
return;
return;
gfx::Rect left, right;
- if (anchor_first) {
+ if (selection_data_->GetIsAnchorFirst()) {
left = selection_data_->GetLeftRect();
right = selection_data_->GetRightRect();
} else {
right = selection_data_->GetLeftRect();
left = selection_data_->GetRightRect();
}
-
postponed_ = false;
// Is in edit field and no text is selected. show only single handle
if (selection_data_->IsInEditField() && left == right) {
-
- if (hit_test &&
- !(hit_test->GetResultContext() & EWK_HIT_TEST_RESULT_CONTEXT_EDITABLE)) {
+ if (!GetSelectionEditable()) {
postponed_ = true;
return;
}
}
start_handle_->Hide();
end_handle_->Hide();
+#if defined(EWK_REFACTOR)
parent_view_->QuerySelectionStyle();
+#endif
- if (!mouse_press_ && !show_only_large_handler_) {
- parent_view_->ShowContextMenu(*(selection_data_->GetContextMenuParams()),
- MENU_TYPE_SELECTION, false);
- }
+ if (!mouse_press_ && !show_only_large_handle_)
+ ShowContextMenu();
return;
} else {
selection_data_->ClearRectData();
return;
}
-
// The base position of start_handle should be set to the middle of the left
// rectangle. Otherwise the start_handle may be shifted up when the
// right_handle is moving
}
// Do not show the context menu during selection extend
- if (!mouse_press_) {
- parent_view_->ShowContextMenu(
- *(selection_data_->GetContextMenuParams()),
- MENU_TYPE_SELECTION,
- false);
- }
+ if (!mouse_press_)
+ ShowContextMenu();
+#if defined(EWK_REFACTOR)
parent_view_->QuerySelectionStyle();
+#endif
}
-void SelectionControllerEfl::ShowHandleAndContextMenuIfRequired(
- bool anchor_first) {
+void SelectionControllerEfl::ShowContextMenu() {
+ WebContentsImpl* wci = static_cast<WebContentsImpl*>(&web_contents_);
+ WebContentsViewEfl* wcve = static_cast<WebContentsViewEfl*>(wci->GetView());
+ RenderWidgetHostViewEfl* rwhv =
+ static_cast<RenderWidgetHostViewEfl*>(web_contents_.GetRenderWidgetHostView());
+ RenderViewHost* rvh = static_cast<RenderViewHost*>(wci->GetRenderViewHost());
+
+ content::ContextMenuParams convertedParams = *(selection_data_->GetContextMenuParams());
+
+ int blinkX, blinkY;
+ if (rwhv)
+ rwhv->EvasToBlinkCords(convertedParams.x, convertedParams.y, &blinkX, &blinkY);
+ convertedParams.x = blinkX;
+ convertedParams.y = blinkY;
+ wcve->ShowContextMenu(rvh->GetMainFrame(), convertedParams);
+}
+
+void SelectionControllerEfl::CancelContextMenu(int request_id) {
+ WebContentsImpl* wci = static_cast<WebContentsImpl*>(&web_contents_);
+ WebContentsViewEfl* wcve = static_cast<WebContentsViewEfl*>(wci->GetView());
+
+ wcve->CancelContextMenu(request_id);
+}
+
+void SelectionControllerEfl::ShowHandleAndContextMenuIfRequired() {
TRACE_EVENT0("selection,efl", __PRETTY_FUNCTION__);
if (!selection_data_->GetStatus()) {
if (scrolling_)
return;
- HitTestContext* ctx = new HitTestContext(this, anchor_first);
-
int hitX, hitY;
hitX = selection_data_->GetContextMenuParams()->x;
hitY = selection_data_->GetContextMenuParams()->y;
postponed_ = true;
- parent_view_->AsyncRequestHitTestDataAt(
- hitX,
- hitY,
- EWK_HIT_TEST_MODE_DEFAULT,
- ShowHandleAndContextMenuIfRequiredCallback,
- ctx);
+
+ ShowHandleAndContextMenuIfRequired(hitX, hitY);
}
void SelectionControllerEfl::HideHandles() {
}
void SelectionControllerEfl::HideHandleAndContextMenu() {
- parent_view_->CancelContextMenu(0);
+ CancelContextMenu(0);
HideHandles();
}
void SelectionControllerEfl::OnMouseDown(const gfx::Point& touch_point,
SelectionHandleEfl::HandleType handle) {
// Hide context menu on mouse down
- show_only_large_handler_ = false;
- parent_view_->CancelContextMenu(0);
+ show_only_large_handle_ = false;
+ CancelContextMenu(0);
+
mouse_press_ = true;
Evas_Coord x, y;
- evas_object_geometry_get(parent_view_->evas_object(), &x, &y, 0, 0);
+ evas_object_geometry_get(parent_view_, &x, &y, 0, 0);
gfx::Point magnifier_point;
switch (handle) {
void SelectionControllerEfl::OnMouseMove(const gfx::Point& touch_point,
SelectionHandleEfl::HandleType handle) {
- show_only_large_handler_ = false;
+ show_only_large_handle_ = false;
// FIXME : Check the text Direction later
Evas_Coord x, y;
- evas_object_geometry_get(parent_view_->evas_object(), &x, &y, 0, 0);
+ evas_object_geometry_get(parent_view_, &x, &y, 0, 0);
expecting_update_ = true;
gfx::Point magnifier_point;
gfx::Point start_point, end_point;
WebContentsImpl* wci = static_cast<WebContentsImpl*>(&web_contents_);
+ RenderWidgetHostViewEfl* rwhv =
+ static_cast<RenderWidgetHostViewEfl*>(web_contents_.GetRenderWidgetHostView());
float device_scale_factor =
gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().device_scale_factor();
magnifier_point.set_y(input_handle_->GetBasePosition().y() + y);
magnifier_->UpdateLocation(magnifier_point);
magnifier_->Move(magnifier_point);
- parent_view_->MoveCaret(input_handle_->GetBasePosition());
+ if (rwhv)
+ rwhv->MoveCaret(input_handle_->GetBasePosition());
return;
case SelectionHandleEfl::HANDLE_TYPE_LEFT:
magnifier_point.set_x(start_handle_->GetBasePosition().x() + x);
start_point.set_y(start_handle_->GetBasePosition().y() / device_scale_factor);
end_point.set_x(end_handle_->GetBasePosition().x() / device_scale_factor);
end_point.set_y(end_handle_->GetBasePosition().y() / device_scale_factor);
- if (GetSelectionEditable()) {
- // Form elements only support scrolling of extent/end caret. To
- // move the start element we need to swap the coordinates provided
- // to SelectRange function.
- wci->SelectRange(end_point, start_point);
- return;
- } else {
- wci->SelectRange(start_point, end_point);
- return;
- }
+ wci->SelectRange(start_point, end_point);
+ return;
case SelectionHandleEfl::HANDLE_TYPE_RIGHT:
magnifier_point.set_x(end_handle_->GetBasePosition().x() + x);
magnifier_point.set_y(end_handle_->GetBasePosition().y() + y);
}
void SelectionControllerEfl::OnMouseUp(const gfx::Point& touch_point) {
- show_only_large_handler_ = false;
+ show_only_large_handle_ = false;
mouse_press_ = false;
magnifier_->Hide();
start_handle_->SetBasePosition(selection_data_->GetLeftRect().bottom_left());
*right = selection_data_->GetRightRect();
}
+void SelectionControllerEfl::OnHitTestAsyncReply(
+ const ViewHostMsg_HitTestAsyncReply_Params& params,
+ int64_t request_id) {
+
+ std::map<int64_t, ScAsyncRequestHitTestDataCallback*>::iterator it =
+ hit_test_callback_.find(request_id);
+
+ if (it == hit_test_callback_.end())
+ return;
+
+ it->second->Run(params, this);
+ delete it->second;
+ hit_test_callback_.erase(it);
+}
+
+
+bool SelectionControllerEfl::AsyncRequestHitTestDataAt(int x, int y,
+ ScAsyncRequestHitTestDataCallback *cb) {
+ RenderWidgetHostViewEfl* rwhv =
+ static_cast<RenderWidgetHostViewEfl*>(web_contents_.GetRenderWidgetHostView());
+ int view_x, view_y;
+ if (rwhv)
+ rwhv->EvasToBlinkCords(x, y, &view_x, &view_y);
+ return AsyncRequestHitTestDataAtBlinkCords(
+ view_x,
+ view_y,
+ cb);
+}
+
+bool SelectionControllerEfl::AsyncRequestHitTestDataAtBlinkCords(int x, int y,
+ ScAsyncRequestHitTestDataCallback *cb) {
+ DCHECK(cb);
+
+ RenderWidgetHostViewEfl* rwhv =
+ static_cast<RenderWidgetHostViewEfl*>(web_contents_.GetRenderWidgetHostView());
+ if (!rwhv)
+ return false;
+
+ static int64_t request_id = 1;
+
+ if (cb) {
+ rwhv->Send(new ViewMsg_DoHitTestAsync(
+ rwhv->GetRenderWidgetHost()->GetRoutingID(), x, y, request_id));
+ hit_test_callback_[request_id] = cb;
+ ++request_id;
+ return true;
+ }
+
+ // if failed we delete callback as it is not needed anymore
+ delete cb;
+ return false;
+}
+
+void SelectionControllerEfl::HandleGesture(blink::WebGestureEvent& event,
+ scoped_ptr<bool>& restore_showing_large_handle_on_gesture_end,
+ bool should_restore_selection_menu) {
+ if (event.type == blink::WebInputEvent::GestureTap) {
+ if (GetCaretSelectionStatus())
+ restore_showing_large_handle_on_gesture_end.reset();
+ HandlePostponedGesture(event.x, event.y, ui::ET_GESTURE_TAP);
+ } else if (event.type == blink::WebInputEvent::GestureShowPress) {
+ HandlePostponedGesture(
+ event.x, event.y, ui::ET_GESTURE_SHOW_PRESS);
+ } else if (event.type == blink::WebInputEvent::GestureLongPress) {
+ restore_showing_large_handle_on_gesture_end.reset();
+ HandlePostponedGesture(
+ event.x, event.y, ui::ET_GESTURE_LONG_PRESS);
+ }
+
+ if (event.type == blink::WebInputEvent::GestureScrollBegin) {
+ SetScrollStatus(true);
+ } else if (event.type == blink::WebInputEvent::GestureScrollEnd) {
+ if (GetScrollStatus())
+ SetScrollStatus(false);
+
+ if (GetSelectionStatus()) {
+ if (restore_showing_large_handle_on_gesture_end) {
+ SetShowOnlyLargeHandle(
+ *restore_showing_large_handle_on_gesture_end);
+ restore_showing_large_handle_on_gesture_end.reset();
+ }
+ UpdateSelectionDataAndShow(
+ GetLeftRect(),
+ GetRightRect(),
+ false /* unused */,
+ should_restore_selection_menu);
+ }
+ }
+}
+
+void SelectionControllerEfl::HandlePostponedGesture(int x, int y, ui::EventType type) {
+ DVLOG(0) << "HandlePostponedGesture :: " << type;
+ RenderWidgetHostViewEfl* rwhv =
+ static_cast<RenderWidgetHostViewEfl*>(web_contents_.GetRenderWidgetHostView());
+
+ gfx::Point point = gfx::Point(x, y);
+ if (rwhv)
+ point = rwhv->ConvertPointInViewPix(point);
+
+ switch (type) {
+ case ui::ET_GESTURE_LONG_PRESS: {
+ ClearSelectionViaEWebView();
+ HideHandleAndContextMenu();
+ RwhvAsyncRequestHitTestDataInternalCallback* cb =
+ new RwhvAsyncRequestHitTestDataInternalCallback(point,
+ &SelectionControllerEfl::HandleLongPressEvent);
+ // below call takes full ownership of cb.
+ AsyncRequestHitTestDataAtBlinkCords(x, y, cb);
+ break;
+ }
+ case ui::ET_GESTURE_TAP: {
+ ClearSelectionViaEWebView();
+ HideHandleAndContextMenu();
+ if (GetSelectionStatus())
+ SetShowOnlyLargeHandle(true);
+ }
+ case ui::ET_GESTURE_SHOW_PRESS: {
+ RwhvAsyncRequestHitTestDataInternalCallback* cb =
+ new RwhvAsyncRequestHitTestDataInternalCallback(point,
+ &SelectionControllerEfl::HandleTapEvent);
+ // below call takes full ownership of cb.
+ AsyncRequestHitTestDataAtBlinkCords(x, y, cb);
+ break;
+ }
+ default:
+ ClearSelectionViaEWebView();
+ break;
+ }
+}
+
void SelectionControllerEfl::HandleLongPressEvent(
- const gfx::Point& touch_point, Ewk_Hit_Test_Result_Context context) {
- if (context & EWK_HIT_TEST_RESULT_CONTEXT_EDITABLE) {
+ const gfx::Point& touch_point,
+ const ViewHostMsg_HitTestAsyncReply_Params& params) {
+
+ if (params.isEditable) {
SetSelectionStatus(true);
SetSelectionEditable(true);
HandleLongPressEventPrivate(touch_point);
- } else if (!(context & EWK_HIT_TEST_RESULT_CONTEXT_LINK)
- && !(context & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE)
- && !(context & EWK_HIT_TEST_RESULT_CONTEXT_MEDIA)
- && context & EWK_HIT_TEST_RESULT_CONTEXT_TEXT) {
+ } else if (params.linkURI.empty()
+ && params.imageURI.empty()
+ && params.mediaURI.empty()
+ && params.isTextNode) {
SetSelectionStatus(true);
HandleLongPressEventPrivate(touch_point);
- LOG(INFO) << __PRETTY_FUNCTION__ << ":: link, !image, !media, text";
- } else if (context & EWK_HIT_TEST_RESULT_CONTEXT_DOCUMENT) {
- LOG(INFO) << __PRETTY_FUNCTION__ << ":: EWK_HIT_TEST_RESULT_CONTEXT_DOCUMENT";
- } else if (context & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE) {
- LOG(INFO) << __PRETTY_FUNCTION__ << ":: EWK_HIT_TEST_RESULT_CONTEXT_IMAGE";
- } else if (context & EWK_HIT_TEST_RESULT_CONTEXT_LINK) {
+ DVLOG(1) << __PRETTY_FUNCTION__ << ":: link, !image, !media, text";
+ } else if (!params.imageURI.empty()) {
+ DVLOG(1) << __PRETTY_FUNCTION__ << ":: IMAGE";
+ } else if (!params.linkURI.empty()) {
ClearSelectionViaEWebView();
- LOG(INFO) << __PRETTY_FUNCTION__ << ":: EWK_HIT_TEST_RESULT_CONTEXT_LINK";
- } else {
- LOG(INFO) << __PRETTY_FUNCTION__ << ":: hit_test = " << context;
+ DVLOG(1) << __PRETTY_FUNCTION__ << ":: LINK";
}
+
}
void SelectionControllerEfl::HandleLongPressEventPrivate(const gfx::Point& touch_point) {
- show_only_large_handler_ = false;
+ show_only_large_handle_ = false;
long_mouse_press_ = true;
Clear();
caret_selection_ = true;
SetCaretSelectionStatus(true);
if (caret_selection_) {
Evas_Coord x, y;
- evas_object_geometry_get(parent_view_->evas_object(), &x, &y, 0, 0);
+ evas_object_geometry_get(parent_view_, &x, &y, 0, 0);
magnifier_->HandleLongPress(gfx::Point(touch_point.x() + x,
touch_point.y() + y));
} else {
}
void SelectionControllerEfl::HandleLongPressMoveEvent(const gfx::Point& touch_point) {
+ RenderWidgetHostViewEfl* rwhv =
+ static_cast<RenderWidgetHostViewEfl*>(web_contents_.GetRenderWidgetHostView());
Clear();
if (selection_data_->IsInEditField()) {
Evas_Coord x, y;
- evas_object_geometry_get(parent_view_->evas_object(), &x, &y, 0, 0);
- parent_view_->MoveCaret(gfx::Point(touch_point.x() - x, touch_point.y() - 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{
- parent_view_->SelectClosestWord(touch_point);
+ if (rwhv)
+ rwhv->SelectClosestWord(touch_point);
}
}
void SelectionControllerEfl::HandleLongPressEndEvent() {
+ show_only_large_handle_ = false;
long_mouse_press_ = false;
if (scrolling_)
show_after_scroll_ = true;
}
void SelectionControllerEfl::HandleTapEvent(
- const gfx::Point& touch_point, Ewk_Hit_Test_Result_Context context) {
- if (context & EWK_HIT_TEST_RESULT_CONTEXT_EDITABLE) {
- LOG(INFO) << "DispatchPostponedGestureEvent :: EWK_HIT_TEST_RESULT_CONTEXT_EDITABLE";
+ const gfx::Point& touch_point,
+ const ViewHostMsg_HitTestAsyncReply_Params& params) {
+ if (params.isEditable) {
+ DVLOG(1) << "DispatchPostponedGestureEvent :: Editable";
SetSelectionStatus(true);
if (GetSelectionEditable()){
SetCaretSelectionStatus(true);
SetSelectionEditable(true);
}
} else {
- if (context & EWK_HIT_TEST_RESULT_CONTEXT_DOCUMENT)
- LOG(INFO) << __PRETTY_FUNCTION__ << " DOCUMENT";
- if (context & EWK_HIT_TEST_RESULT_CONTEXT_TEXT)
- LOG(INFO) << __PRETTY_FUNCTION__ << " TEXT";
-
SetSelectionEditable(false);
+ SetCaretSelectionStatus(true);
}
}
int handleHeight, webViewX, webViewY, webViewWidth, webViewHeight;
gfx::Rect imeRect;
edje_object_part_geometry_get(input_handle_->evas_object(), "handle", 0, 0, 0, &handleHeight);
- evas_object_geometry_get(GetParentView()->evas_object(), &webViewX, &webViewY, &webViewWidth, &webViewHeight);
+ evas_object_geometry_get(GetParentView(), &webViewX, &webViewY, &webViewWidth, &webViewHeight);
gfx::Rect viewportRect = gfx::Rect(webViewX, webViewY, webViewWidth, webViewHeight);
RenderWidgetHostViewEfl* rwhv =
#ifndef selection_controller_h
#define selection_controller_h
+#include <map>
+
#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
-#include "public/ewk_hit_test.h"
-#include "selection_box_efl.h"
-#include "selection_handle_efl.h"
-#include "selection_magnifier_efl.h"
+#include "third_party/WebKit/public/web/WebInputEvent.h"
+#include "ui/base/selection/selection_box_efl.h"
+#include "ui/base/selection/selection_handle_efl.h"
+#include "ui/base/selection/selection_magnifier_efl.h"
+#include "ui/events/event_constants.h"
#include "ui/gfx/range/range.h"
#include "ui/gfx/geometry/rect.h"
#include <libintl.h>
-class EWebView;
+struct ViewHostMsg_HitTestAsyncReply_Params;
namespace content {
class WebContents;
+class WebContentsImpl;
+class ScAsyncRequestHitTestDataCallback;
// Controls the selection after long tap.
// This handles long tap down, long tap move, long tap up.
};
public:
- explicit SelectionControllerEfl(EWebView* parent_view, WebContents& web_contents);
+ explicit SelectionControllerEfl(Evas_Object* parent_view, WebContents& web_contents);
+ ~SelectionControllerEfl();
// Functions that handle long press, long press move and release
- void HandleLongPressEvent(const gfx::Point& touch_point, Ewk_Hit_Test_Result_Context);
+ void HandleLongPressEvent(const gfx::Point& touch_point,
+ const ViewHostMsg_HitTestAsyncReply_Params& params);
void HandleLongPressMoveEvent(const gfx::Point& touch_point);
void HandleLongPressEndEvent();
- void HandleTapEvent(const gfx::Point& touch_point, Ewk_Hit_Test_Result_Context);
+ void HandleTapEvent(const gfx::Point& touch_point,
+ const ViewHostMsg_HitTestAsyncReply_Params& params);
// Set if selection is valid
void SetSelectionStatus(bool enable);
// Clears the selection and hides context menu and handles
void ClearSelection();
bool ClearSelectionViaEWebView();
- EWebView* GetParentView() { return parent_view_; }
+ Evas_Object* GetParentView() { return parent_view_; }
void HideHandles();
void HideHandleAndContextMenu();
bool IsAnyHandleVisible() const;
bool GetIsSelectionVisible() const { return is_selection_visible_; }
void SetIsSelectionVisible(const bool isVisible) { is_selection_visible_ = isVisible; }
- void SetShowOnlyLargeHandler(const bool show_only_large_handler)
- { show_only_large_handler_ = show_only_large_handler; }
- bool GetShowOnlyLargeHandler() const { return show_only_large_handler_; }
+ void SetShowOnlyLargeHandle(const bool show_only_large_handle)
+ { show_only_large_handle_ = show_only_large_handle; }
+ bool GetShowOnlyLargeHandle() const { return show_only_large_handle_; }
+ void HandlePostponedGesture(int x, int y, ui::EventType type);
+ void HandleGesture(blink::WebGestureEvent& event,
+ scoped_ptr<bool>& restore_showing_large_handle_on_gesture_end,
+ bool should_restore_selection_menu);
+
+ bool AsyncRequestHitTestDataAt(int x, int y,
+ ScAsyncRequestHitTestDataCallback *cb);
+
+ bool AsyncRequestHitTestDataAtBlinkCords(int x, int y,
+ ScAsyncRequestHitTestDataCallback *cb);
+ void OnHitTestAsyncReply(const
+ ViewHostMsg_HitTestAsyncReply_Params& params,
+ int64_t request_id);
private:
void HandleLongPressEventPrivate(const gfx::Point& touch_point);
// TODO: This method should be renamed to ScheduleShowHandleAndContextMenuIfNeeded
// as it now performs an asyncrhonous hit test passing the method that actually
// updates the selection handles and context menu as a registered callback.
- void ShowHandleAndContextMenuIfRequired(bool anchor_first = true);
- void ShowHandleAndContextMenuIfRequired(Evas_Object*,
- int x, int y, int mode, _Ewk_Hit_Test*, bool anchor_first);
- static void ShowHandleAndContextMenuIfRequiredCallback(Evas_Object*,
- int x, int y, int mode, _Ewk_Hit_Test*, void* data);
+ void ShowHandleAndContextMenuIfRequired();
+ void ShowHandleAndContextMenuIfRequired(
+ int x, int y);
void Clear(bool show_after_scroll = false);
bool IsSelectionValid(const gfx::Rect& left_rect, const gfx::Rect& right_rect);
+ void ShowContextMenu();
+ void CancelContextMenu(int request_id);
+
static void EvasParentViewMoveCallback(void *data, Evas *e, Evas_Object *obj, void *event_info)
{ reinterpret_cast<SelectionControllerEfl*>(data)->OnParentParentViewMove(); }
void OnParentParentViewMove();
+ Evas_Object* parent_view_;
// Is required to send back selction points and range extenstion co-ordinates
- EWebView* parent_view_;
// Saves state so that context menu is not displayed during extending selection
bool mouse_press_;
gfx::Rect visibility_rect_;
bool is_selection_visible_;
- bool show_only_large_handler_;
+ bool show_only_large_handle_;
WebContents& web_contents_;
+ std::map<int64_t, ScAsyncRequestHitTestDataCallback*> hit_test_callback_;
};
} // namespace content
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "eweb_view.h"
-#include "selection_handle_efl.h"
-#include "selection_controller_efl.h"
-
#include <Edje.h>
#include <Eina.h>
#include <Elementary.h>
+#include "base/trace_event/trace_event.h"
+#include "ui/base/selection/selection_handle_efl.h"
+#include "ui/base/selection/selection_controller_efl.h"
+
namespace content {
// Size of the left/right margin which causes selection handles to be rotated
evas_object_event_callback_del(handle->handle_, EVAS_CALLBACK_MOUSE_MOVE, OnMouseMove);
Evas_Coord x, y;
- evas_object_geometry_get(handle->controller_.GetParentView()->evas_object(), &x, &y, 0, 0);
+ evas_object_geometry_get(handle->controller_.GetParentView(), &x, &y, 0, 0);
handle->controller_.OnMouseUp(gfx::Point(event->canvas.x - x, event->canvas.y - y));
}
int handleHeight;
edje_object_part_geometry_get(handle_, "handle", 0, 0, 0, &handleHeight);
- evas_object_geometry_get(controller_.GetParentView()->evas_object(),
+ evas_object_geometry_get(controller_.GetParentView(),
&x, &y, &deviceWidth, &deviceHeight);
gfx::Point conv_point(point.x() + x, point.y() + y);
switch (handle_type_) {
case HANDLE_TYPE_LEFT:
- evas_object_smart_callback_call(controller_.GetParentView()->evas_object(),
+ evas_object_smart_callback_call(controller_.GetParentView(),
"selection,handle,left,direction", &direction);
break;
case HANDLE_TYPE_RIGHT:
- evas_object_smart_callback_call(controller_.GetParentView()->evas_object(),
+ evas_object_smart_callback_call(controller_.GetParentView(),
"selection,handle,right,direction", &direction);
break;
case HANDLE_TYPE_INPUT:
- evas_object_smart_callback_call(controller_.GetParentView()->evas_object(),
+ evas_object_smart_callback_call(controller_.GetParentView(),
"selection,handle,large,direction", &direction);
break;
}
void SelectionHandleEfl::MoveObject(const gfx::Point& point) {
Evas_Coord x, y;
- evas_object_geometry_get(controller_.GetParentView()->evas_object(), &x, &y,
+ evas_object_geometry_get(controller_.GetParentView(), &x, &y,
0, 0);
if (handle_type_ == HANDLE_TYPE_INPUT && IsTop()) {
evas_object_move(handle_, point.x() + x,
#include <Evas.h>
#include "ui/gfx/geometry/point.h"
+#include "ui/gfx/geometry/rect.h"
namespace content {
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "selection_magnifier_efl.h"
+#include "ui/base/selection/selection_magnifier_efl.h"
#include <Elementary.h>
#include "base/path_service.h"
#include "base/files/file_path.h"
+#include "content/browser/renderer_host/render_widget_host_view_efl.h"
#include "content/common/paths_efl.h"
#include "content/public/browser/browser_thread.h"
-#include "eweb_view.h"
-#include "selection_controller_efl.h"
+#include "content/public/browser/web_contents.h"
+#include "ui/base/selection/selection_controller_efl.h"
namespace content {
const int kHeightOffset = 60;
const float kZoomScale = 0.66;
-SelectionMagnifierEfl::SelectionMagnifierEfl(content::SelectionControllerEfl* controller)
+SelectionMagnifierEfl::SelectionMagnifierEfl(
+ content::SelectionControllerEfl* controller,
+ content::WebContents& web_contents)
: controller_(controller),
+ web_contents_(web_contents),
content_image_(0),
animator_(0),
shown_(false) {
Evas_Object* top_widget = static_cast<Evas_Object*>(controller->
- GetParentView()->web_contents().GetNativeView());
+ GetParentView());
base::FilePath edj_dir;
base::FilePath magnifier_edj;
}
void SelectionMagnifierEfl::HandleLongPress(const gfx::Point& touch_point) {
- evas_object_event_callback_add(controller_->GetParentView()->evas_object(),
+ evas_object_event_callback_add(controller_->GetParentView(),
EVAS_CALLBACK_MOUSE_UP,
OnAnimatorUp,
this);
animator_ = 0;
}
- evas_object_event_callback_del(controller_->GetParentView()->evas_object(),
+ evas_object_event_callback_del(controller_->GetParentView(),
EVAS_CALLBACK_MOUSE_UP,
OnAnimatorUp);
}
SelectionMagnifierEfl* magnifier_data = static_cast<SelectionMagnifierEfl*>(data);
Evas_Coord_Point point;
- evas_pointer_canvas_xy_get(evas_object_evas_get(magnifier_data->controller_->GetParentView()->evas_object()),
+ evas_pointer_canvas_xy_get(evas_object_evas_get(magnifier_data->controller_->GetParentView()),
&point.x,
&point.y);
gfx::Point display_point(point.x, point.y);
void SelectionMagnifierEfl::UpdateLocation(const gfx::Point& location) {
int device_x, device_y, device_width, device_height;
- evas_object_geometry_get(controller_->GetParentView()->evas_object(),
+ evas_object_geometry_get(controller_->GetParentView(),
&device_x,
&device_y,
&device_width,
rect.w = content_rect.width();
rect.h = content_rect.height();
+#if defined(EWK_REFACTOR)
controller_->GetParentView()->GetSnapshotAsync(rect,
evas_object_evas_get(controller_->GetParentView()->evas_object()),
MagnifierGetSnapshotCb, this);
+#endif
}
void SelectionMagnifierEfl::Move(const gfx::Point& location) {
int device_x, device_y, device_width, device_height;
- evas_object_geometry_get(controller_->GetParentView()->evas_object(),
+ evas_object_geometry_get(controller_->GetParentView(),
&device_x,
&device_y,
&device_width,
void SelectionMagnifierEfl::Show() {
shown_ = true;
evas_object_show(container_);
- controller_->GetParentView()->SmartCallback<EWebViewCallbacks::MagnifierShow>().call();
- controller_->GetParentView()->set_magnifier(true);
+
+ RenderWidgetHostViewEfl* rwhv =
+ static_cast<RenderWidgetHostViewEfl*>(web_contents_.GetRenderWidgetHostView());
+ if (rwhv)
+ rwhv->set_magnifier(true);
+ if (controller_->GetParentView())
+ evas_object_smart_callback_call(controller_->GetParentView(), "magnifier,show", NULL);
}
void SelectionMagnifierEfl::Hide() {
shown_ = false;
evas_object_hide(content_image_);
evas_object_hide(container_);
- controller_->GetParentView()->SmartCallback<EWebViewCallbacks::MagnifierHide>().call();
- controller_->GetParentView()->set_magnifier(false);
+
+ RenderWidgetHostViewEfl* rwhv =
+ static_cast<RenderWidgetHostViewEfl*>(web_contents_.GetRenderWidgetHostView());
+ if (rwhv)
+ rwhv->set_magnifier(false);
+ if (controller_->GetParentView())
+ evas_object_smart_callback_call(controller_->GetParentView(), "magnifier,hide", NULL);
}
}
namespace content {
class SelectionControllerEfl;
+class WebContents;
class SelectionMagnifierEfl {
public:
- SelectionMagnifierEfl(content::SelectionControllerEfl* controller);
+ SelectionMagnifierEfl(content::SelectionControllerEfl* controller,
+ WebContents& web_contents);
~SelectionMagnifierEfl();
void HandleLongPress(const gfx::Point& touch_point);
static void MagnifierGetSnapshotCb(Evas_Object* image, void* user_data);
// Parent to send back mouse events
- content::SelectionControllerEfl* controller_;
+ SelectionControllerEfl* controller_;
+
+ WebContents& web_contents_;
// Magnifier
Evas_Object* container_;
}],
['_target_name=="ui_base"', {
+ 'include_dirs': [
+ '<(DEPTH)/third_party/mojo/src/',
+ ],
'sources': [
'<(DEPTH)/ui/base/cursor/cursor.h',
'<(DEPTH)/ui/base/cursor/cursor.cc',
'base/clipboard/clipboard_efl.h',
'base/clipboard/clipboard_helper_efl.cc',
'base/clipboard/clipboard_helper_efl.h',
+ 'base/selection/selection_controller_efl.h',
+ 'base/selection/selection_controller_efl.cc',
+ 'base/selection/selection_handle_efl.h',
+ 'base/selection/selection_handle_efl.cc',
+ 'base/selection/selection_box_efl.h',
+ 'base/selection/selection_box_efl.cc',
+ 'base/selection/selection_magnifier_efl.h',
+ 'base/selection/selection_magnifier_efl.cc',
],
}],
#include "content/common/paths_efl.h"
#include "third_party/WebKit/public/platform/WebReferrerPolicy.h"
#include "ui/base/clipboard/clipboard.h"
+#include "ui/base/selection/selection_controller_efl.h"
#include "private/ewk_context_menu_private.h"
-#include "selection_controller_efl.h"
-
#if defined(OS_TIZEN_MOBILE)
#include <efl_assist.h>
#endif
if (appended_item)
_appended_item_size++;
}
+ // Workaround
+ // Need to set "copypaste" style, to let moving handles
+ // when ctxpopup is visible
+ // http://107.108.218.239/bugzilla/show_bug.cgi?id=11613
+ elm_object_style_set(popup_, "copypaste");
} else {
GURL url = web_contents_.GetVisibleURL();
std::string selected_link (url.host().c_str());
'scroll_detector.h',
'text_encoding_map_efl.cc',
'text_encoding_map_efl.h',
- 'selection_box_efl.cc',
- 'selection_box_efl.h',
- 'selection_controller_efl.cc',
- 'selection_controller_efl.h',
- 'selection_handle_efl.cc',
- 'selection_handle_efl.h',
- 'selection_magnifier_efl.cc',
- 'selection_magnifier_efl.h',
'url_request_context_getter_efl.cc',
'url_request_context_getter_efl.h',
'web_contents_efl_delegate_ewk.cc',
InitializeContent();
- selection_controller_.reset(new content::SelectionControllerEfl(this, *web_contents_.get()));
evas_event_handler_ = new WebViewEvasEventHandler(this);
scroll_detector_.reset(new ScrollDetector(this));
}
}
-/* FIXME: Figure out wher this code should be placed.
-void EWebView::DispatchPostponedGestureEvent(ui::GestureEvent* event) {
- Ewk_Settings* settings = GetSettings();
- LOG(INFO) << "DispatchPostponedGestureEvent :: " << event->details().type();
- if (event->details().type() == ui::ET_GESTURE_LONG_PRESS) {
- if (selection_controller_->GetSelectionEditable())
- ClearSelection();
-
- if (settings && settings->textSelectionEnabled()) {
- _Ewk_Hit_Test* hit_test = RequestHitTestDataAtBlinkCoords(event->x(), event->y(), EWK_HIT_TEST_MODE_DEFAULT);
- if (hit_test && hit_test->GetResultContext() & EWK_HIT_TEST_RESULT_CONTEXT_EDITABLE) {
- selection_controller_->SetSelectionStatus(true);
- selection_controller_->SetCaretSelectionStatus(true);
- selection_controller_->SetSelectionEditable(true);
- selection_controller_->HandleLongPressEvent(rwhv()->ConvertPointInViewPix(gfx::Point(event->x(), event->y())));
- } else if (hit_test
- && !(hit_test->GetResultContext() & EWK_HIT_TEST_RESULT_CONTEXT_LINK)
- && !(hit_test->GetResultContext() & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE)
- && !(hit_test->GetResultContext() & EWK_HIT_TEST_RESULT_CONTEXT_MEDIA)
- && hit_test->GetResultContext() & EWK_HIT_TEST_RESULT_CONTEXT_TEXT) {
- selection_controller_->SetSelectionStatus(true);
- selection_controller_->HandleLongPressEvent(rwhv()->ConvertPointInViewPix(gfx::Point(event->x(), event->y())));
- LOG(INFO) << __PRETTY_FUNCTION__ << ":: link, !image, !media, text";
- } else if (hit_test && hit_test->GetResultContext() & EWK_HIT_TEST_RESULT_CONTEXT_DOCUMENT) {
- LOG(INFO) << __PRETTY_FUNCTION__ << ":: EWK_HIT_TEST_RESULT_CONTEXT_DOCUMENT";
- } else if (hit_test && hit_test->GetResultContext() & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE) {
- LOG(INFO) << __PRETTY_FUNCTION__ << ":: EWK_HIT_TEST_RESULT_CONTEXT_IMAGE";
- } else if (hit_test && hit_test->GetResultContext() & EWK_HIT_TEST_RESULT_CONTEXT_LINK) {
- ClearSelection();
- LOG(INFO) << __PRETTY_FUNCTION__ << ":: EWK_HIT_TEST_RESULT_CONTEXT_LINK";
- } else {
- LOG(INFO) << __PRETTY_FUNCTION__ << ":: hit_test = " << hit_test->GetResultContext();
- }
- delete hit_test;
- rwhv()->HandleGesture(event);
- }
- } else if ((event->details().type() == ui::ET_GESTURE_TAP) || (event->details().type() == ui::ET_GESTURE_SHOW_PRESS)) {
- _Ewk_Hit_Test* hit_test = RequestHitTestDataAtBlinkCoords(event->x(), event->y(), EWK_HIT_TEST_MODE_DEFAULT);
- LOG(INFO) << __PRETTY_FUNCTION__ << " hit_test = " << hit_test;
- if (hit_test && hit_test->GetResultContext() & EWK_HIT_TEST_RESULT_CONTEXT_EDITABLE) {
- LOG(INFO) << "DispatchPostponedGestureEvent :: EWK_HIT_TEST_RESULT_CONTEXT_EDITABLE";
- selection_controller_->SetSelectionStatus(true);
- if (selection_controller_->GetSelectionEditable()) {
- selection_controller_->HideHandles();
- selection_controller_->SetCaretSelectionStatus(true);
- } else
- selection_controller_->SetSelectionEditable(true);
- } else {
- if (hit_test && hit_test->GetResultContext() & EWK_HIT_TEST_RESULT_CONTEXT_DOCUMENT)
- LOG(INFO) << __PRETTY_FUNCTION__ << " DOCUMENT";
- if (hit_test && hit_test->GetResultContext() & EWK_HIT_TEST_RESULT_CONTEXT_TEXT)
- LOG(INFO) << __PRETTY_FUNCTION__ << " TEXT";
-
- selection_controller_->SetSelectionEditable(false);
- //ClearSelection();
- }
- delete hit_test;
- rwhv()->HandleGesture(event);
- } else {
- ClearSelection();
- rwhv()->HandleGesture(event);
- }
- // FIXME:As there is only single window currently, and even there are no
- // other evas objects, adding focus in event here for display of key board.
- //Once added build with proper apps to be removed
- rwhv()->HandleFocusIn();
-}
-*/
-
-void EWebView::HandleLongPressGesture(int x, int y,
- Ewk_Hit_Test_Mode,
- _Ewk_Hit_Test* hit_test) {
- if (!hit_test)
- return;
-
- selection_controller_->HandleLongPressEvent(
- rwhv()->ConvertPointInViewPix(gfx::Point(x, y)), hit_test->GetResultContext());
-}
-
-void EWebView::HandleTapGesture(int x, int y,
- Ewk_Hit_Test_Mode,
- _Ewk_Hit_Test* hit_test) {
- if (!hit_test)
- return;
-
- selection_controller_->HandleTapEvent(
- rwhv()->ConvertPointInViewPix(gfx::Point(x, y)), hit_test->GetResultContext());
-}
-
content::WebContentsViewEfl* EWebView::GetWebContentsViewEfl() const {
WebContentsImpl* wc = static_cast<WebContentsImpl*>(web_contents_.get());
return static_cast<WebContentsViewEfl*>(wc->GetView());
}
-void EWebView::HandlePostponedGesture(int x, int y, ui::EventType type) {
- LOG(INFO) << "HandlePostponedGesture :: " << type;
- switch (type) {
- case ui::ET_GESTURE_LONG_PRESS: {
- selection_controller_->ClearSelectionViaEWebView();
- if (settings_->textSelectionEnabled()) {
- WebViewAsyncRequestHitTestDataInternalCallback* cb =
- new WebViewAsyncRequestHitTestDataInternalCallback(x,y,
- EWK_HIT_TEST_MODE_DEFAULT, &EWebView::HandleLongPressGesture);
- // below call takes full ownership of cb.
- AsyncRequestHitTestDataAtBlinkCords(x, y, EWK_HIT_TEST_MODE_DEFAULT, cb);
- }
- break;
- }
- case ui::ET_GESTURE_TAP:
- case ui::ET_GESTURE_SHOW_PRESS: {
- WebViewAsyncRequestHitTestDataInternalCallback* cb =
- new WebViewAsyncRequestHitTestDataInternalCallback(x, y,
- EWK_HIT_TEST_MODE_DEFAULT, &EWebView::HandleTapGesture);
- // below call takes full ownership of cb.
- AsyncRequestHitTestDataAtBlinkCords(x, y, EWK_HIT_TEST_MODE_DEFAULT, cb);
- break;
- }
- default:
- selection_controller_->ClearSelectionViaEWebView();
- break;
- }
-}
-
bool EWebView::TouchEventsEnabled() const {
return touch_events_enabled_;
}
void EWebView::ShowContextMenu(
const content::ContextMenuParams& params,
- content::ContextMenuType type,
- bool show_selection) {
+ content::ContextMenuType type) {
// fix for context menu coordinates type: MENU_TYPE_LINK (introduced by CBGRAPHICS-235),
// this menu is created in renderer process and it does not now anything about
// view scaling factor and it has another calling sequence, so coordinates is not updated
context_menu_position_ = gfx::Point(convertedParams.x, convertedParams.y);
- if (!selection_controller_->IsShowingMagnifier() &&
- selection_controller_->IsCaretSelection()) {
- if(!context_menu_->PopulateAndShowContextMenu(convertedParams))
- context_menu_.reset();
- if (show_selection)
- selection_controller_->UpdateSelectionDataAndShow(
- selection_controller_->GetLeftRect(),
- selection_controller_->GetRightRect(),
- false /* unused */,
- true);
+ if (GetSelectionController()) {
+ if (!GetSelectionController()->IsShowingMagnifier() &&
+ GetSelectionController()->IsCaretSelection()) {
+ if(!context_menu_->PopulateAndShowContextMenu(convertedParams)) {
+ context_menu_.reset();
+ GetSelectionController()->HideHandles();
+ }
+ }
}
}
void EWebView::OnQuerySelectionStyleReply(const SelectionStylePrams& params) {
gfx::Rect left_rect, right_rect;
- selection_controller_->GetSelectionBounds(&left_rect, &right_rect);
- _Ewk_Text_Style style_data(params, left_rect.origin(), right_rect.bottom_right());
- SmartCallback<EWebViewCallbacks::TextStyleState>().call(&style_data);
+ if (GetSelectionController()) {
+ GetSelectionController()->GetSelectionBounds(&left_rect, &right_rect);
+ _Ewk_Text_Style style_data(params, left_rect.origin(), right_rect.bottom_right());
+ SmartCallback<EWebViewCallbacks::TextStyleState>().call(&style_data);
+ }
+}
+
+SelectionControllerEfl* EWebView::GetSelectionController() const {
+ return GetWebContentsViewEfl()->GetSelectionController();
}
void EWebView::SelectClosestWord(const gfx::Point& touch_point) {
bool EWebView::GetSelectionRange(Eina_Rectangle* left_rect, Eina_Rectangle* right_rect) {
if (left_rect && right_rect) {
gfx::Rect left, right;
- selection_controller_->GetSelectionBounds(&left, &right);
- GetEinaRectFromGfxRect(left, left_rect);
- GetEinaRectFromGfxRect(right, right_rect);
- return true;
+ if (GetSelectionController()) {
+ GetSelectionController()->GetSelectionBounds(&left, &right);
+ GetEinaRectFromGfxRect(left, left_rect);
+ GetEinaRectFromGfxRect(right, right_rect);
+ return true;
+ }
}
return false;
}
}
bool EWebView::HandleTextSelectionDown(int x, int y) {
- if (!selection_controller_)
+ if (!GetSelectionController())
return false;
- return selection_controller_->TextSelectionDown(x, y);
+ return GetSelectionController()->TextSelectionDown(x, y);
}
bool EWebView::HandleTextSelectionUp(int x, int y) {
- if (!selection_controller_)
+ if (!GetSelectionController())
return false;
- return selection_controller_->TextSelectionUp(x, y);
+ return GetSelectionController()->TextSelectionUp(x, y);
}
void EWebView::SendDelayedMessages(RenderViewHost* render_view_host) {
#include "public/ewk_view.h"
#include "eweb_view_callbacks.h"
#include "scroll_detector.h"
-#include "selection_controller_efl.h"
+#include "ui/base/selection/selection_controller_efl.h"
#include "web_contents_delegate_efl.h"
#include "context_menu_controller_efl.h"
#include "file_chooser_controller_efl.h"
Eina_Bool PopupMenuClose();
void ShowContextMenu(
const content::ContextMenuParams& params,
- content::ContextMenuType type = content::MENU_TYPE_LINK,
- bool show_selection = true);
+ content::ContextMenuType type = content::MENU_TYPE_LINK);
void CancelContextMenu(int request_id);
void SetScale(double scale_factor, int x, int y);
bool GetScrollPosition(int* x, int* y) const;
Eina_Hash* headers,
const char* body);
- content::SelectionControllerEfl* GetSelectionController() const { return selection_controller_.get(); }
+ content::SelectionControllerEfl* GetSelectionController() const;
content::PopupControllerEfl* GetPopupController() const { return popup_controller_.get(); }
ScrollDetector* GetScrollDetector() const { return scroll_detector_.get(); }
void MoveCaret(const gfx::Point& point);
void HandleRendererProcessCrash();
void InvokeWebProcessCrashedCallback();
- void HandlePostponedGesture(int x, int y, ui::EventType type);
+
private:
void InitializeContent();
void SendDelayedMessages(content::RenderViewHost* render_view_host);
Eina_Bool AsyncRequestHitTestDataAtBlinkCords(int x, int y,
Ewk_Hit_Test_Mode mode,
WebViewAsyncRequestHitTestDataCallback* cb);
- void HandleLongPressGesture(int x, int y, Ewk_Hit_Test_Mode mode,
- _Ewk_Hit_Test*);
- void HandleTapGesture(int x, int y, Ewk_Hit_Test_Mode mode,
- _Ewk_Hit_Test*);
+
content::WebContentsViewEfl* GetWebContentsViewEfl() const;
#if defined(OS_TIZEN_MOBILE) && !defined(EWK_BRINGUP)
scoped_ptr<content::ContextMenuControllerEfl> context_menu_;
scoped_ptr<content::FileChooserControllerEfl> file_chooser_;
scoped_ptr<content::PopupControllerEfl> popup_controller_;
- scoped_ptr<content::SelectionControllerEfl> selection_controller_;
base::string16 previous_text_;
int current_find_request_id_;
static int find_request_id_counter_;
web_view_->SmartCallback<EWebViewCallbacks::TitleChange>().
call(base::UTF16ToUTF8(title).c_str());
}
+
+void WebContentsViewEflDelegateEwk::CancelContextMenu(int request_id) {
+ web_view_->CancelContextMenu(request_id);
+}
void SetPageTitle(const base::string16& title) override;
+ void CancelContextMenu(int request_id) override;
+
private:
EWebView* web_view_;
};