+++ /dev/null
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Copyright 2014 Samsung Electronics. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "browser/renderer_host/render_widget_host_view_efl.h"
-
-#include "base/auto_reset.h"
-#include "base/basictypes.h"
-#include "base/bind.h"
-#include "base/callback_helpers.h"
-#include "base/command_line.h"
-#include "base/debug/trace_event.h"
-#include "base/message_loop/message_loop.h"
-#include "base/strings/string_number_conversions.h"
-#include "base/logging.h"
-#include "base/strings/utf_string_conversions.h"
-#include "browser/disambiguation_popup_efl.h"
-#include "browser/renderer_host/im_context_efl.h"
-#include "browser/renderer_host/scroll_detector.h"
-#include "browser/renderer_host/web_event_factory_efl.h"
-#include "browser/sound_effect.h"
-#include "content/browser/gpu/browser_gpu_channel_host_factory.h"
-#include "content/browser/gpu/compositor_util.h"
-#include "content/browser/renderer_host/render_widget_host_impl.h"
-#include "content/browser/renderer_host/ui_events_helper.h"
-#include "content/browser/renderer_host/event_with_latency_info.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/browser/renderer_host/dip_util.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"
-#include "content/public/browser/render_widget_host_view_frame_subscriber.h"
-#include "content/public/browser/screen_orientation_dispatcher_host.h"
-#include "content/public/common/content_switches.h"
-#include "content/common/view_messages.h"
-#include "content/common/gpu/gpu_messages.h"
-#include "common/render_messages_efl.h"
-#if defined(TIZEN_CONTENTS_DETECTION)
-#include "components/autofill/core/browser/validation.h"
-#endif
-#include "eweb_context.h"
-#include "gl/gl_shared_context_efl.h"
-#include "gpu/command_buffer/service/mailbox_manager.h"
-#include "media/base/video_util.h"
-#include "platform/WindowsKeyboardCodes.h"
-#include "selection_controller_efl.h"
-#include "skia/ext/image_operations.h"
-#include "third_party/WebKit/public/web/WebInputEvent.h"
-#include "third_party/WebKit/public/platform/WebScreenInfo.h"
-#include "third_party/WebKit/public/web/WebTouchPoint.h"
-#include "third_party/WebKit/public/web/WebViewModeEnums.h"
-#include "ui/gfx/display.h"
-#include "ui/gfx/rect.h"
-#include "ui/gfx/screen.h"
-#include "ui/views/widget/desktop_aura/desktop_screen.h"
-#include "ui/events/event_utils.h"
-#include "ui/events/gestures/gesture_types.h"
-#include "ui/events/gestures/gesture_recognizer.h"
-#if defined(OS_TIZEN_MOBILE)
-#include "browser/motion/wkext_motion.h"
-#endif
-#include "content/common/input_messages.h"
-#include "components/clipboard/clipboard_helper_efl.h"
-#include "common/webcursor_efl.h"
-#include <assert.h>
-#include <Ecore.h>
-#include <Ecore_Evas.h>
-#include <Ecore_Input.h>
-#include "ecore_x_wrapper.h"
-#include <Elementary.h>
-
-#define EFL_MAX_WIDTH 10000
-#define EFL_MAX_HEIGHT 10000 // borrowed from GTK+ port
-
-#define MAX_SURFACE_WIDTH_EGL 4096 //max supported Framebuffer width
-#define MAX_SURFACE_HEIGHT_EGL 4096 //max supported Framebuffer height
-
-namespace content {
-
-void RenderWidgetHostViewBase::GetDefaultScreenInfo(
- blink::WebScreenInfo* results) {
- const gfx::Display display = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay();
-
- results->rect = display.bounds();
- results->availableRect = display.work_area();
- results->deviceScaleFactor = display.device_scale_factor();
- results->orientationAngle = display.RotationAsDegree();
-#if defined(OS_TIZEN_MOBILE)
- results->orientationType =
- RenderWidgetHostViewBase::GetOrientationTypeForMobile(display);
-#else
- results->orientationType =
- RenderWidgetHostViewBase::GetOrientationTypeForDesktop(display);
-#endif
-
- // TODO(derat|oshima): Don't hardcode this. Get this from display object.
- results->depth = 24;
- results->depthPerComponent = 8;
-}
-
-RenderWidgetHostViewEfl::RenderWidgetHostViewEfl(RenderWidgetHost* widget, EWebView* eweb_view)
- : host_(RenderWidgetHostImpl::From(widget)),
- web_view_(eweb_view),
- im_context_(NULL),
- evas_(NULL),
- content_image_(NULL),
- scroll_detector_(new EflWebview::ScrollDetector()),
- m_IsEvasGLInit(0),
- device_scale_factor_(1.0f),
- m_magnifier(false),
- is_loading_(false),
- gesture_recognizer_(ui::GestureRecognizer::Create()),
- current_orientation_(0),
- evas_gl_(NULL),
- evas_gl_api_(NULL),
- evas_gl_context_(NULL),
- evas_gl_surface_(NULL),
- evas_gl_config_(NULL),
- egl_image_(NULL),
- current_pixmap_id_(0),
- next_pixmap_id_(0),
- texture_id_(0),
- surface_id_(0),
- should_restore_selection_menu_(false),
- selection_acked_on_tap_(false),
- was_scrolled_(false),
- scroll_offset_changed_(false),
- single_tap_performed_(false),
- restore_showing_large_handler_(false) {
-
- device_scale_factor_ = gfx::Screen::GetNativeScreen()->
- GetPrimaryDisplay().device_scale_factor();
-
- host_->SetView(this);
-
- static bool scale_factor_initialized = false;
- if (!scale_factor_initialized) {
- std::vector<ui::ScaleFactor> supported_scale_factors;
- supported_scale_factors.push_back(ui::SCALE_FACTOR_100P);
- supported_scale_factors.push_back(ui::SCALE_FACTOR_200P);
- ui::SetSupportedScaleFactors(supported_scale_factors);
- scale_factor_initialized = true;
- }
-
- gesture_recognizer_->AddGestureEventHelper(this);
-}
-
-void RenderWidgetHostViewEfl::Init(Evas_Object* view, const gfx::Size& size) {
- DCHECK(view);
- content_image_ = view;
- evas_ = evas_object_evas_get(view);
-
- // IMContext calls evas() getter on 'this' so it needs to be
- // initialized after evas_ is valid
- im_context_ = IMContextEfl::Create(this);
-
- DCHECK(!size.IsEmpty());
- Init_EvasGL(size.width(), size.height());
-
-#if defined(OS_TIZEN_MOBILE)
- disambiguation_popup_.reset(new DisambiguationPopupEfl(content_image_, this));
-#endif
-}
-
-RenderWidgetHostViewEfl::~RenderWidgetHostViewEfl() {
- if (im_context_)
- delete im_context_;
-}
-
-gfx::Point RenderWidgetHostViewEfl::ConvertPointInViewPix(gfx::Point point) {
- return gfx::ToFlooredPoint(gfx::ScalePoint(point, device_scale_factor_));
-}
-
-gfx::Rect RenderWidgetHostViewEfl::GetViewBoundsInPix() const {
- int x, y, w, h;
- evas_object_geometry_get(content_image_, &x, &y, &w, &h);
- return gfx::Rect(x, y, w, h);
-}
-
-static const char* vertexShaderSourceSimple =
- "attribute vec4 a_position; \n"
- "attribute vec2 a_texCoord; \n"
- "varying vec2 v_texCoord; \n"
- "void main() { \n"
- " gl_Position = a_position; \n"
- " v_texCoord = a_texCoord; \n"
- "} \n";
-
-static const char* fragmentShaderSourceSimple =
- "precision mediump float; \n"
- "varying vec2 v_texCoord; \n"
- "uniform sampler2D s_texture; \n"
- "void main() { \n"
- " gl_FragColor = texture2D( s_texture, v_texCoord );\n"
- "} \n";
-
-#if defined(NDEBUG)
-#define GL_CHECK_HELPER(code, msg) \
- ((code), false)
-#else
-static GLenum s_gl_err;
-#define GL_CHECK_HELPER(code, msg) \
- (((code), ((s_gl_err = evas_gl_api_->glGetError()) == GL_NO_ERROR)) ? false : \
- ((LOG(ERROR) << "GL Error: " << s_gl_err << " " << msg), true))
-#endif
-
-#define GL_CHECK(code) GL_CHECK_HELPER(code, "")
-#define GL_CHECK_STATUS(msg) GL_CHECK_HELPER(1, msg)
-
-static void GLCheckProgramHelper(Evas_GL_API* api, GLuint program,
- const char* file, int line) {
- GLint status;
- api->glGetProgramiv(program, GL_LINK_STATUS, &status);
- if (!status) {
- const GLsizei buf_length = 2048;
- scoped_ptr<GLchar[]> log(new GLchar[buf_length]);
- GLsizei length = 0;
- api->glGetProgramInfoLog(program, buf_length, &length, log.get());
- LOG(ERROR) << "GL program link failed in: " << file << ":" << line
- << ": " << log.get();
- }
-}
-
-#define GLCheckProgram(api, program) \
- GLCheckProgramHelper(api, program, __FILE__, __LINE__)
-
-static void GLCheckShaderHelper(
- Evas_GL_API* api, GLuint shader, const char* file, int line) {
- GLint status;
- api->glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
- if (!status) {
- const GLsizei buf_length = 2048;
- scoped_ptr<GLchar[]> log(new GLchar[buf_length]);
- GLsizei length = 0;
- api->glGetShaderInfoLog(shader, buf_length, &length, log.get());
- LOG(ERROR) << "GL shader compile failed in " << file << ":" << line
- << ": " << log.get();
- }
-}
-
-#define GLCheckShader(api, shader) \
- GLCheckShaderHelper((api), (shader), __FILE__, __LINE__)
-
-void RenderWidgetHostViewEfl::initializeProgram() {
- evas_gl_make_current(evas_gl_, evas_gl_surface_, evas_gl_context_);
-
- GL_CHECK_STATUS("GL Error before program initialization");
-
- const char* vertexShaderSourceProgram = vertexShaderSourceSimple;
- const char* fragmentShaderSourceProgram = fragmentShaderSourceSimple;
- GLuint vertexShader = evas_gl_api_->glCreateShader(GL_VERTEX_SHADER);
- GL_CHECK_STATUS("vertex shader");
- GLuint fragmentShader = evas_gl_api_->glCreateShader(GL_FRAGMENT_SHADER);
- GL_CHECK_STATUS("fragment shader");
-
- const GLfloat vertex_attributes[] = {
- -1.0f, -1.0f, 0.0f, 0.0f, 0.0f,
- -1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
- 1.0f, 1.0f, 0.0f, 1.0f, 1.0f,
- 1.0f, -1.0f, 0.0f, 1.0f, 0.0f};
-
- GL_CHECK(evas_gl_api_->glGenBuffers(1, &vertex_buffer_obj_));
- GL_CHECK(evas_gl_api_->glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer_obj_));
- GL_CHECK(evas_gl_api_->glBufferData(GL_ARRAY_BUFFER,
- sizeof(vertex_attributes),
- vertex_attributes, GL_STATIC_DRAW));
-
- const GLfloat vertex_attributes_270[] = {
- -1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
- -1.0f, 1.0f, 0.0f, 0.0f, 0.0f,
- 1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
- 1.0f, -1.0f, 0.0f, 1.0f, 1.0f};
-
- GL_CHECK(evas_gl_api_->glGenBuffers(1, &vertex_buffer_obj_270_));
- GL_CHECK(evas_gl_api_->glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer_obj_270_));
- GL_CHECK(evas_gl_api_->glBufferData(GL_ARRAY_BUFFER,
- sizeof(vertex_attributes_270),
- vertex_attributes_270, GL_STATIC_DRAW));
-
- const GLfloat vertex_attributes_90[] = {
- -1.0f, -1.0f, 0.0f, 0.0f, 1.0f,
- -1.0f, 1.0f, 0.0f, 1.0f, 1.0f,
- 1.0f, 1.0f, 0.0f, 1.0f, 0.0f,
- 1.0f, -1.0f, 0.0f, 0.0f, 0.0f};
-
- GL_CHECK(evas_gl_api_->glGenBuffers(1, &vertex_buffer_obj_90_));
- GL_CHECK(evas_gl_api_->glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer_obj_90_));
- GL_CHECK(evas_gl_api_->glBufferData(GL_ARRAY_BUFFER,
- sizeof(vertex_attributes_90),
- vertex_attributes_90, GL_STATIC_DRAW));
-
- const GLushort index_attributes[] = {0, 1, 2, 0, 2, 3};
- GL_CHECK(evas_gl_api_->glGenBuffers(1, &index_buffer_obj_));
- GL_CHECK(
- evas_gl_api_->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_buffer_obj_));
- GL_CHECK(evas_gl_api_->glBufferData(GL_ELEMENT_ARRAY_BUFFER,
- sizeof(index_attributes),
- index_attributes, GL_STATIC_DRAW));
-
- GL_CHECK(evas_gl_api_->glShaderSource(vertexShader, 1, &vertexShaderSourceProgram, 0));
- GL_CHECK(evas_gl_api_->glShaderSource(fragmentShader, 1, &fragmentShaderSourceProgram, 0));
- GL_CHECK(program_id_ = evas_gl_api_->glCreateProgram());
- GL_CHECK(evas_gl_api_->glCompileShader(vertexShader));
- GLCheckShader(evas_gl_api_, vertexShader);
- GL_CHECK(evas_gl_api_->glCompileShader(fragmentShader));
- GLCheckShader(evas_gl_api_, fragmentShader);
- GL_CHECK(evas_gl_api_->glAttachShader(program_id_, vertexShader));
- GL_CHECK(evas_gl_api_->glAttachShader(program_id_, fragmentShader));
- GL_CHECK(evas_gl_api_->glLinkProgram(program_id_));
- GLCheckProgram(evas_gl_api_, program_id_);
-
- GL_CHECK(position_attrib_ = evas_gl_api_->glGetAttribLocation(program_id_, "a_position"));
- GL_CHECK(texcoord_attrib_ = evas_gl_api_->glGetAttribLocation(program_id_, "a_texCoord"));
- GL_CHECK(source_texture_location_ = evas_gl_api_->glGetUniformLocation (program_id_, "s_texture" ));
-}
-
-void RenderWidgetHostViewEfl::PaintTextureToSurface(GLuint texture_id) {
- Evas_GL_API* gl_api = evasGlApi();
- DCHECK(gl_api);
-
- evas_gl_make_current(evas_gl_, evas_gl_surface_, evas_gl_context_);
-
- GL_CHECK_STATUS("GL error before texture paint.");
-
- gfx::Rect bounds = GetViewBoundsInPix();
- gfx::Size surface = surface_size_;
-
- GL_CHECK(gl_api->glViewport(0, bounds.height() - surface.height(), surface.width(), surface.height()));
- GL_CHECK(gl_api->glClearColor(1.0, 1.0, 1.0, 1.0));
- GL_CHECK(gl_api->glClear(GL_COLOR_BUFFER_BIT));
- GL_CHECK(gl_api->glUseProgram(program_id_));
-
- current_orientation_ = ecore_evas_rotation_get(ecore_evas_ecore_evas_get(evas_));
-
- switch (current_orientation_) {
- case 270:
- GL_CHECK(gl_api->glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer_obj_270_));
- break;
- case 90:
- GL_CHECK(gl_api->glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer_obj_90_));
- break;
- default:
- GL_CHECK(gl_api->glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer_obj_));
- } // switch(current_orientation_)
-
- GL_CHECK(gl_api->glEnableVertexAttribArray(position_attrib_));
- // Below 5 * sizeof(GLfloat) value specifies the size of a vertex
- // attribute (x, y, z, u, v).
- GL_CHECK(gl_api->glVertexAttribPointer(position_attrib_, 3, GL_FLOAT,
- GL_FALSE, 5 * sizeof(GLfloat), NULL));
- GL_CHECK(gl_api->glEnableVertexAttribArray(texcoord_attrib_));
- // Below 3 * sizeof(GLfloat) value specifies the location of texture
- // coordinate in the vertex.
- GL_CHECK(gl_api->glVertexAttribPointer(texcoord_attrib_, 2, GL_FLOAT,
- GL_FALSE, 5 * sizeof(GLfloat),
- (void*)(3 * sizeof(GLfloat))));
- GL_CHECK(gl_api->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_buffer_obj_));
-
- GL_CHECK(gl_api->glActiveTexture(GL_TEXTURE0));
- GL_CHECK(gl_api->glBindTexture(GL_TEXTURE_2D, texture_id));
- GL_CHECK(gl_api->glUniform1i(source_texture_location_, 0));
- GL_CHECK(gl_api->glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, NULL));
-
- GL_CHECK(gl_api->glBindTexture(GL_TEXTURE_2D, 0));
- evas_gl_make_current(evas_gl_, 0, 0);
-}
-
-void RenderWidgetHostViewEfl::EvasObjectImagePixelsGetCallback(void* data, Evas_Object* obj) {
- RenderWidgetHostViewEfl* rwhv_efl = reinterpret_cast<RenderWidgetHostViewEfl*>(data);
- if (rwhv_efl->texture_id_)
- rwhv_efl->PaintTextureToSurface(rwhv_efl->texture_id_);
-}
-
-void RenderWidgetHostViewEfl::Init_EvasGL(int width, int height) {
- assert(width > 0 && height > 0);
-
- setenv("EVAS_GL_DIRECT_OVERRIDE", "1", 1);
- setenv("EVAS_GL_DIRECT_MEM_OPT", "1",1);
-
- evas_gl_config_ = evas_gl_config_new();
- evas_gl_config_->options_bits = EVAS_GL_OPTIONS_DIRECT;
- evas_gl_config_->color_format = EVAS_GL_RGBA_8888;
- evas_gl_config_->depth_bits = EVAS_GL_DEPTH_BIT_24;
- evas_gl_config_->stencil_bits = EVAS_GL_STENCIL_BIT_8;
-
- evas_gl_ = evas_gl_new(evas_);
- evas_gl_api_ = evas_gl_api_get(evas_gl_);
- evas_gl_context_ = evas_gl_context_create(
- evas_gl_, GLSharedContextEfl::GetEvasGLContext());
- if (!evas_gl_context_) {
- LOG(ERROR) << "set_eweb_view -- Create evas gl context Fail";
- }
-
- if(width > MAX_SURFACE_WIDTH_EGL)
- width = MAX_SURFACE_WIDTH_EGL;
-
- if(height > MAX_SURFACE_HEIGHT_EGL)
- height = MAX_SURFACE_HEIGHT_EGL;
-
- evas_gl_surface_ = evas_gl_surface_create(evas_gl_, evas_gl_config_, width, height);
- if (!evas_gl_surface_) {
- LOG(ERROR) << "set_eweb_view -- Create evas gl Surface Fail";
- }
-
- Evas_Native_Surface nativeSurface;
- if (evas_gl_native_surface_get(evas_gl_, evas_gl_surface_, &nativeSurface)) {
- evas_object_color_set(content_image_, 255, 255, 255, 1);
- evas_object_image_native_surface_set(content_image_, &nativeSurface);
- evas_object_image_pixels_get_callback_set(content_image_, EvasObjectImagePixelsGetCallback, this);
- } else {
- LOG(ERROR) << "set_eweb_view -- Fail to get Natvie surface";
- }
-
- initializeProgram();
-
- m_IsEvasGLInit = 1;
-}
-
-bool RenderWidgetHostViewEfl::OnMessageReceived(const IPC::Message& message) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostViewEfl, message)
- IPC_MESSAGE_HANDLER(EwkHostMsg_PlainTextGetContents, OnPlainTextGetContents)
- IPC_MESSAGE_HANDLER(EwkHostMsg_WebAppIconUrlGet, OnWebAppIconUrlGet)
- IPC_MESSAGE_HANDLER(EwkHostMsg_WebAppIconUrlsGet, OnWebAppIconUrlsGet)
- IPC_MESSAGE_HANDLER(EwkHostMsg_WebAppCapableGet, OnWebAppCapableGet)
- IPC_MESSAGE_HANDLER(EwkHostMsg_DidChangeContentsSize, OnDidChangeContentsSize)
- IPC_MESSAGE_HANDLER(EwkViewMsg_SelectionTextStyleState, OnSelectionTextStyleState)
- IPC_MESSAGE_HANDLER(EwkHostMsg_DidChangeMaxScrollOffset, OnDidChangeMaxScrollOffset)
- IPC_MESSAGE_HANDLER(EwkHostMsg_DidChangeScrollOffset, OnDidChangeScrollOffset)
- IPC_MESSAGE_HANDLER(EwkHostMsg_ReadMHTMLData, OnMHTMLContentGet)
- IPC_MESSAGE_HANDLER(EwkHostMsg_DidChangePageScaleFactor, OnDidChangePageScaleFactor)
- IPC_MESSAGE_HANDLER(EwkHostMsg_DidChangePageScaleRange, OnDidChangePageScaleRange)
- IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged, OnTextInputStateChanged)
- IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputInFormStateChanged, OnTextInputInFormStateChanged)
-#if defined(OS_TIZEN)
- IPC_MESSAGE_HANDLER(InputHostMsg_DidHandleKeyEvent, OnDidHandleKeyEvent)
- IPC_MESSAGE_HANDLER(ViewHostMsg_SnapshotDataReceived, OnSnapshot)
-#if defined(TIZEN_CONTENTS_DETECTION)
- IPC_MESSAGE_HANDLER(ViewHostMsg_GetTextAtPositionReply, OnGetTextAtPositionReply)
-#endif
-#endif
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- return handled;
-}
-
-bool RenderWidgetHostViewEfl::Send(IPC::Message* message) {
- return host_->Send(message);
-}
-
-void RenderWidgetHostViewEfl::OnSelectionTextStyleState(const SelectionStylePrams& params) {
- if (web_view_)
- web_view_->OnQuerySelectionStyleReply(params);
-}
-
-void RenderWidgetHostViewEfl::InitAsChild(gfx::NativeView parent_view) {
- NOTIMPLEMENTED();
-}
-
-void RenderWidgetHostViewEfl::InitAsPopup(RenderWidgetHostView*, const gfx::Rect&) {
- NOTIMPLEMENTED();
-}
-
-void RenderWidgetHostViewEfl::InitAsFullscreen(RenderWidgetHostView*) {
- NOTIMPLEMENTED();
-}
-
-RenderWidgetHost* RenderWidgetHostViewEfl::GetRenderWidgetHost() const {
- return host_;
-}
-
-Ecore_X_Window RenderWidgetHostViewEfl::GetEcoreXWindow() const {
- Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_);
- return ecore_evas_gl_x11_window_get(ee);
-}
-
-void RenderWidgetHostViewEfl::SetSize(const gfx::Size& size) {
- // This is a hack. See WebContentsView::SizeContents
- int width = std::min(size.width(), EFL_MAX_WIDTH);
- int height = std::min(size.height(), EFL_MAX_HEIGHT);
- if (popup_type_ != blink::WebPopupTypeNone) {
- // We're a popup, honor the size request.
- ecore_x_window_resize(GetEcoreXWindow(), width, height);
- }
-
- // Update the size of the RWH.
- //if (requested_size_.width() != width ||
- // requested_size_.height() != height) {
- // Disabled for now, will enable it while implementing InitAsPopUp (P1) API
- //equested_size_ = gfx::Size(width, height);
- host_->SendScreenRects();
- host_->WasResized();
- //}
-
-}
-
-void RenderWidgetHostViewEfl::SetBounds(const gfx::Rect& rect) {
- // FIXME: ditto.
- NOTIMPLEMENTED();
-}
-
-gfx::Vector2dF RenderWidgetHostViewEfl::GetLastScrollOffset() const {
- // FIXME: Aura RWHV sets last_scroll_offset_ in OnSwapCompositorFrame()
- // Other ways to get scroll offset are already removed.
- // We need to switch to the ui::Compositor ASAP!
- return last_scroll_offset_;
-}
-
-gfx::NativeView RenderWidgetHostViewEfl::GetNativeView() const {
- return content_image_;
-}
-
-void RenderWidgetHostViewEfl::OnSnapshot(const std::vector<unsigned char> pixData, int snapshotId, const gfx::Size& size) {
- Evas_Object* image = evas_object_image_filled_add(evas_);
- evas_object_image_size_set(image, size.width(), size.height());
- evas_object_image_data_copy_set(image, const_cast<unsigned char*>(&pixData[0]));
-
- web_view_->FindAndRunSnapshotCallback(image, snapshotId);
-}
-
-gfx::NativeViewId RenderWidgetHostViewEfl::GetNativeViewId() const {
- if (m_IsEvasGLInit) {
- Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_);
- return ecore_evas_window_get(ee);
- } else {
- return 0;
- }
-}
-
-gfx::NativeViewAccessible RenderWidgetHostViewEfl::GetNativeViewAccessible() {
- NOTIMPLEMENTED();
- return 0;
-}
-
-bool RenderWidgetHostViewEfl::IsSurfaceAvailableForCopy() const {
- return false;
-}
-
-void RenderWidgetHostViewEfl::Show() {
- evas_object_show(content_image_);
-}
-
-void RenderWidgetHostViewEfl::Hide() {
- //evas_object_hide(content_image_);
-}
-
-bool RenderWidgetHostViewEfl::IsShowing() {
- return evas_object_visible_get(content_image_);
-}
-
-gfx::Rect RenderWidgetHostViewEfl::GetViewBounds() const {
- return ConvertRectToDIP(device_scale_factor_, GetViewBoundsInPix());
-}
-
-bool RenderWidgetHostViewEfl::LockMouse() {
- NOTIMPLEMENTED();
- return false;
-}
-
-void RenderWidgetHostViewEfl::UnlockMouse() {
- NOTIMPLEMENTED();
-}
-
-void RenderWidgetHostViewEfl::WasShown() {
- host_->WasShown(ui::LatencyInfo());
-}
-
-void RenderWidgetHostViewEfl::WasHidden() {
- host_->WasHidden();
-}
-
-void RenderWidgetHostViewEfl::Focus() {
- if (web_view_)
- web_view_->SetFocus(EINA_TRUE);
- host_->Focus();
-}
-
-bool RenderWidgetHostViewEfl::HasFocus() const {
- if (web_view_)
- return web_view_->HasFocus();
-
- return evas_object_focus_get(content_image_) == EINA_TRUE;
-}
-
-void RenderWidgetHostViewEfl::MovePluginContainer(const WebPluginGeometry& move) {
- Ecore_X_Window surface_window = 0;
- PluginWindowToWidgetMap::const_iterator i = plugin_window_to_widget_map_.find(move.window);
-
- if (i != plugin_window_to_widget_map_.end())
- surface_window = i->second;
-
- if (!surface_window)
- return;
-
- if (!move.visible) {
- ecore_x_window_hide(surface_window);
- return;
- }
-
- ecore_x_window_show(surface_window);
-
- if (!move.rects_valid)
- return;
-
- ecore_x_window_move(surface_window, move.window_rect.x(), move.window_rect.y());
- ecore_x_window_resize(surface_window, move.window_rect.width(), move.window_rect.height());
-}
-
-void RenderWidgetHostViewEfl::MovePluginWindows(
- const std::vector<WebPluginGeometry>& moves) {
- for (size_t i = 0; i < moves.size(); i++)
- MovePluginContainer(moves[i]);
-}
-
-void RenderWidgetHostViewEfl::Blur() {
- host_->Blur();
-}
-
-void RenderWidgetHostViewEfl::UpdateCursor(const WebCursor& webcursor) {
- if (is_loading_) {
- // Setting native Loading cursor
- ecore_x_window_cursor_set(GetEcoreXWindow(), ecore_x_cursor_shape_get(ECORE_X_CURSOR_CLOCK));
- } else {
- WebCursor::CursorInfo cursor_info;
- webcursor.GetCursorInfo(&cursor_info);
-
- int cursor_type = GetCursorType(cursor_info.type);
- ecore_x_window_cursor_set(GetEcoreXWindow(), ecore_x_cursor_shape_get(cursor_type));
- }
- // Need to check for cursor visibility
- //ecore_x_window_cursor_show(GetEcoreXWindow(), true);
-
-}
-
-void RenderWidgetHostViewEfl::SetIsLoading(bool is_loading) {
- is_loading_ = is_loading;
- UpdateCursor(WebCursor());
- if (disambiguation_popup_)
- disambiguation_popup_->Dismiss();
-}
-
-void RenderWidgetHostViewEfl::TextInputTypeChanged(ui::TextInputType type,
- ui::TextInputMode input_mode,
- bool can_compose_inline,
- int flags) {
- if (GetSelectionController()) {
- GetSelectionController()->SetSelectionEditable(
- type != ui::TEXT_INPUT_TYPE_NONE);
- }
-}
-
-void RenderWidgetHostViewEfl::OnTextInputStateChanged(
- const ViewHostMsg_TextInputState_Params& params) {
- if (!params.show_ime_if_needed && !eweb_view()->GetSettings()->useKeyPadWithoutUserAction())
- return;
-
- if (im_context_) {
- im_context_->UpdateInputMethodState(params.type, params.can_compose_inline,
- params.show_ime_if_needed);
-
- if (web_view_)
- web_view_->QuerySelectionStyle();
- }
-
- if (GetSelectionController()) {
- GetSelectionController()->SetSelectionEditable(
- params.type != ui::TEXT_INPUT_TYPE_NONE);
- }
-}
-
-void RenderWidgetHostViewEfl::ImeCancelComposition() {
- if (im_context_)
- im_context_->CancelComposition();
-}
-
-void RenderWidgetHostViewEfl::OnTextInputInFormStateChanged(bool is_in_form_tag) {
- if (im_context_)
- im_context_->SetIsInFormTag(is_in_form_tag);
-}
-
-void RenderWidgetHostViewEfl::ImeCompositionRangeChanged(
- const gfx::Range& range,
- const std::vector<gfx::Rect>& character_bounds) {
- if (web_view_) {
- SelectionControllerEfl* controller = web_view_->GetSelectionController();
- if (controller) {
- controller->SetCaretSelectionStatus(false);
- controller->HideHandleAndContextMenu();
- }
- }
-}
-
-void RenderWidgetHostViewEfl::FocusedNodeChanged(bool is_editable_node) {
- if (web_view_) {
- SelectionControllerEfl* controller = web_view_->GetSelectionController();
- if (controller) {
- controller->SetCaretSelectionStatus(false);
- controller->HideHandleAndContextMenu();
- }
- if (im_context_) {
- if (im_context_->IsShow() &&
- ClipboardHelperEfl::GetInstance()->IsClipboardWindowOpened()) {
- ClipboardHelperEfl::GetInstance()->CloseClipboardWindow();
- }
- im_context_->ResetIMFContext();
- im_context_->ClearQueues();
- }
- }
-}
-
-void RenderWidgetHostViewEfl::Destroy() {
- delete this;
-}
-
-void RenderWidgetHostViewEfl::SetTooltipText(const base::string16& text) {
- if (web_view_)
- web_view_->SmartCallback<EWebViewCallbacks::TooltipTextSet>().call(UTF16ToUTF8(text).c_str());
-}
-
-void RenderWidgetHostViewEfl::SelectionChanged(const base::string16& text,
- size_t offset,
- const gfx::Range& range) {
- RenderWidgetHostViewBase::SelectionChanged(text, offset, range);
-
- if (!web_view_)
- return;
-
- SelectionControllerEfl* controller = web_view_->GetSelectionController();
- if (!controller)
- return;
-
- base::string16 selectedText;
- if (!text.empty() && !range.is_empty())
- selectedText = GetSelectedText();
-
- controller->UpdateSelectionData(selectedText);
-}
-
-void RenderWidgetHostViewEfl::SelectionBoundsChanged(
- const ViewHostMsg_SelectionBounds_Params& params) {
- ViewHostMsg_SelectionBounds_Params guest_params(params);
- guest_params.anchor_rect = ConvertRectToPixel(device_scale_factor_, params.anchor_rect);
- guest_params.focus_rect = ConvertRectToPixel(device_scale_factor_, params.focus_rect);
-
- if (im_context_)
- im_context_->UpdateCaretBounds(gfx::UnionRects(guest_params.anchor_rect, guest_params.focus_rect));
-
- if (GetSelectionController()) {
- GetSelectionController()->UpdateSelectionDataAndShow(
- guest_params.anchor_rect,
- guest_params.focus_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::DidStopFlinging() {
-#if defined(TIZEN_EDGE_EFFECT)
- if (web_view_)
- web_view_->edgeEffect()->hide();
-#endif
-
- SelectionControllerEfl* controller = GetSelectionController();
- if (!controller)
- return;
-
- // Unhide Selection UI when scrolling with fling gesture
- if (controller->GetScrollStatus())
- controller->SetScrollStatus(false);
-
- controller->UpdateSelectionDataAndShow(
- controller->GetLeftRect(),
- controller->GetRightRect(),
- false,
- false);
-}
-
-void RenderWidgetHostViewEfl::ShowDisambiguationPopup(const gfx::Rect& rect_pixels, const SkBitmap& zoomed_bitmap) {
- if (disambiguation_popup_)
- disambiguation_popup_->Show(rect_pixels, zoomed_bitmap);
-}
-
-bool RenderWidgetHostViewEfl::CanDispatchToConsumer(ui::GestureConsumer* consumer) {
- return this == consumer;
-}
-
-void RenderWidgetHostViewEfl::DispatchCancelTouchEvent(ui::TouchEvent* event) {
-}
-
-void RenderWidgetHostViewEfl::DispatchGestureEvent(ui::GestureEvent* event) {
- HandleGesture(event);
-}
-
-#if defined(OS_TIZEN)
-void RenderWidgetHostViewEfl::GetSnapshotForRect(gfx::Rect& rect) {
-#if !defined(EWK_BRINGUP)
- GpuProcessHost::SendOnIO(
- GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED,
- CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH,
- new GpuMsg_GetPixelRegion(surface_id_, rect));
-#endif
-}
-#endif
-
-void RenderWidgetHostViewEfl::CopyFromCompositingSurface(
- const gfx::Rect& src_subrect,
- const gfx::Size& /* dst_size */,
- const base::Callback<void(bool, const SkBitmap&)>& callback,
- const SkColorType color_type) {
-
-}
-
-#if defined(OS_TIZEN)
-void RenderWidgetHostViewEfl::GetSnapshotAsync(const gfx::Rect& snapshot_area, int request_id) {
- if (!IsDelegatedRendererEnabled())
- Send(new ViewMsg_GetSnapshotFromRender(host_->GetRoutingID(), snapshot_area, request_id));
- else {
- //TODO: Add alternative way after porting delegated rendering
- NOTIMPLEMENTED();
- }
-}
-#endif
-
-// CopyFromCompositingSurfaceToVideoFrame implementation borrowed from Aura port
-bool RenderWidgetHostViewEfl::CanSubscribeFrame() const {
- return true;
-}
-
-void RenderWidgetHostViewEfl::BeginFrameSubscription(
- scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) {
- frame_subscriber_ = subscriber.Pass();
-}
-
-void RenderWidgetHostViewEfl::EndFrameSubscription() {
- idle_frame_subscriber_textures_.clear();
- frame_subscriber_.reset();
-}
-
-#ifdef TIZEN_EDGE_EFFECT
-void RenderWidgetHostViewEfl::DidOverscroll(const DidOverscrollParams& params) {
- if (web_view_) {
- const gfx::Vector2dF& accumulated_overscroll = params.accumulated_overscroll;
- const gfx::Vector2dF& latest_overscroll_delta = params.latest_overscroll_delta;
-
- if (latest_overscroll_delta.x() < 0 && (int)accumulated_overscroll.x() < 0)
- web_view_->edgeEffect()->show("edge,left");
- if (latest_overscroll_delta.x() > 0 && (int)accumulated_overscroll.x() > 0)
- web_view_->edgeEffect()->show("edge,right");
- if (latest_overscroll_delta.y() < 0 && (int)accumulated_overscroll.y() < 0)
- web_view_->edgeEffect()->show("edge,top");
- if (latest_overscroll_delta.y() > 0 && (int)accumulated_overscroll.y() > 0)
- web_view_->edgeEffect()->show("edge,bottom");
- }
-}
-#endif
-
-#ifdef TIZEN_CONTENTS_DETECTION
-void RenderWidgetHostViewEfl::OnContentsDetected(const char* message) {
- if (web_view_)
- web_view_->ShowContentsDetectedPopup(message);
-}
-#endif
-
-void RenderWidgetHostViewEfl::ReturnSubscriberTexture(
- base::WeakPtr<RenderWidgetHostViewEfl> rwhvefl,
- scoped_refptr<OwnedMailbox> subscriber_texture,
- uint32 sync_point) {
- if (!subscriber_texture.get())
- return;
- if (!rwhvefl)
- return;
- DCHECK_NE(
- rwhvefl->active_frame_subscriber_textures_.count(subscriber_texture.get()),
- 0u);
-
- subscriber_texture->UpdateSyncPoint(sync_point);
-
- rwhvefl->active_frame_subscriber_textures_.erase(subscriber_texture.get());
- if (rwhvefl->frame_subscriber_ && subscriber_texture->texture_id())
- rwhvefl->idle_frame_subscriber_textures_.push_back(subscriber_texture);
-}
-
-void RenderWidgetHostViewEfl::CopyFromCompositingSurfaceFinishedForVideo(
- base::WeakPtr<RenderWidgetHostViewEfl> rwhvefl,
- const base::Callback<void(bool)>& callback,
- scoped_refptr<OwnedMailbox> subscriber_texture,
- scoped_ptr<cc::SingleReleaseCallback> release_callback,
- bool result) {
- callback.Run(result);
-
- GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper();
- uint32 sync_point = gl_helper ? gl_helper->InsertSyncPoint() : 0;
- if (release_callback) {
- // A release callback means the texture came from the compositor, so there
- // should be no |subscriber_texture|.
- DCHECK(!subscriber_texture.get());
- release_callback->Run(sync_point, false);
- }
- ReturnSubscriberTexture(rwhvefl, subscriber_texture, sync_point);
-}
-
-void RenderWidgetHostViewEfl::CopyFromCompositingSurfaceHasResultForVideo(
- base::WeakPtr<RenderWidgetHostViewEfl> rwhvefl,
- scoped_refptr<OwnedMailbox> subscriber_texture,
- scoped_refptr<media::VideoFrame> video_frame,
- const base::Callback<void(bool)>& callback,
- scoped_ptr<cc::CopyOutputResult> result) {
- base::ScopedClosureRunner scoped_callback_runner(base::Bind(callback, false));
- base::ScopedClosureRunner scoped_return_subscriber_texture(
- base::Bind(&ReturnSubscriberTexture, rwhvefl, subscriber_texture, 0));
-
- if (!rwhvefl)
- return;
- if (result->IsEmpty())
- return;
- if (result->size().IsEmpty())
- return;
-
- // Compute the dest size we want after the letterboxing resize. Make the
- // coordinates and sizes even because we letterbox in YUV space
- // (see CopyRGBToVideoFrame). They need to be even for the UV samples to
- // line up correctly.
- // The video frame's coded_size() and the result's size() are both physical
- // pixels.
- gfx::Rect region_in_frame =
- media::ComputeLetterboxRegion(gfx::Rect(video_frame->coded_size()),
- result->size());
- region_in_frame = gfx::Rect(region_in_frame.x() & ~1,
- region_in_frame.y() & ~1,
- region_in_frame.width() & ~1,
- region_in_frame.height() & ~1);
- if (region_in_frame.IsEmpty())
- return;
-
- if (!result->HasTexture()) {
- DCHECK(result->HasBitmap());
- scoped_ptr<SkBitmap> bitmap = result->TakeBitmap();
- // Scale the bitmap to the required size, if necessary.
- SkBitmap scaled_bitmap;
- if (result->size().width() != region_in_frame.width() ||
- result->size().height() != region_in_frame.height()) {
- skia::ImageOperations::ResizeMethod method =
- skia::ImageOperations::RESIZE_GOOD;
- scaled_bitmap = skia::ImageOperations::Resize(*bitmap.get(), method,
- region_in_frame.width(),
- region_in_frame.height());
- } else {
- scaled_bitmap = *bitmap.get();
- }
-
- {
- SkAutoLockPixels scaled_bitmap_locker(scaled_bitmap);
-
- media::CopyRGBToVideoFrame(
- reinterpret_cast<uint8*>(scaled_bitmap.getPixels()),
- scaled_bitmap.rowBytes(),
- region_in_frame,
- video_frame.get());
- }
- ignore_result(scoped_callback_runner.Release());
- callback.Run(true);
- return;
- }
-
- ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
- GLHelper* gl_helper = factory->GetGLHelper();
- if (!gl_helper)
- return;
- if (subscriber_texture.get() && !subscriber_texture->texture_id())
- return;
-
- cc::TextureMailbox texture_mailbox;
- scoped_ptr<cc::SingleReleaseCallback> release_callback;
- result->TakeTexture(&texture_mailbox, &release_callback);
- DCHECK(texture_mailbox.IsTexture());
- if (!texture_mailbox.IsTexture())
- return;
-
- gfx::Rect result_rect(result->size());
-
- content::ReadbackYUVInterface* yuv_readback_pipeline =
- rwhvefl->yuv_readback_pipeline_.get();
- if (yuv_readback_pipeline == NULL ||
- yuv_readback_pipeline->scaler()->SrcSize() != result_rect.size() ||
- yuv_readback_pipeline->scaler()->SrcSubrect() != result_rect ||
- yuv_readback_pipeline->scaler()->DstSize() != region_in_frame.size()) {
- GLHelper::ScalerQuality quality = GLHelper::SCALER_QUALITY_FAST;
- std::string quality_switch = switches::kTabCaptureDownscaleQuality;
- // If we're scaling up, we can use the "best" quality.
- if (result_rect.size().width() < region_in_frame.size().width() &&
- result_rect.size().height() < region_in_frame.size().height())
- quality_switch = switches::kTabCaptureUpscaleQuality;
-
- std::string switch_value =
- CommandLine::ForCurrentProcess()->GetSwitchValueASCII(quality_switch);
- if (switch_value == "fast")
- quality = GLHelper::SCALER_QUALITY_FAST;
- else if (switch_value == "good")
- quality = GLHelper::SCALER_QUALITY_GOOD;
- else if (switch_value == "best")
- quality = GLHelper::SCALER_QUALITY_BEST;
-
- rwhvefl->yuv_readback_pipeline_.reset(
- gl_helper->CreateReadbackPipelineYUV(quality,
- result_rect.size(),
- result_rect,
- video_frame->coded_size(),
- region_in_frame,
- true,
- true));
- yuv_readback_pipeline = rwhvefl->yuv_readback_pipeline_.get();
- }
-
- ignore_result(scoped_callback_runner.Release());
- ignore_result(scoped_return_subscriber_texture.Release());
- base::Callback<void(bool result)> finished_callback = base::Bind(
- &RenderWidgetHostViewEfl::CopyFromCompositingSurfaceFinishedForVideo,
- rwhvefl->AsWeakPtr(),
- callback,
- subscriber_texture,
- base::Passed(&release_callback));
- yuv_readback_pipeline->ReadbackYUV(
- texture_mailbox.mailbox(),
- texture_mailbox.sync_point(),
- video_frame,
- finished_callback);
-}
-
-// Efl port - Implementation done, will enable this function after getting video test site to verify
-void RenderWidgetHostViewEfl::CopyFromCompositingSurfaceToVideoFrame(
- const gfx::Rect& src_subrect,
- const scoped_refptr<media::VideoFrame>& target,
- const base::Callback<void(bool)>& callback) {
- NOTIMPLEMENTED();
- callback.Run(false);
-}
-
-bool RenderWidgetHostViewEfl::CanCopyToVideoFrame() const {
- return false;
-}
-
-void RenderWidgetHostViewEfl::AcceleratedSurfaceInitialized(int route_id) {
- // FIXME: new API in M34. need proper implementation.
- NOTIMPLEMENTED();
-}
-
-// Defined in gl_current_context_efl.cc because of conflicts of
-// texture_manager.h with efl GL API wrappers.
-
-extern GLuint GetTextureIdFromTexture(gpu::gles2::Texture* texture);
-
-bool RenderWidgetHostViewEfl::HasAcceleratedSurface(const gfx::Size&) {
- return false;
-}
-
-void RenderWidgetHostViewEfl::GetScreenInfo(
- blink::WebScreenInfo* results) {
- RenderWidgetHostViewBase::GetDefaultScreenInfo(results);
-}
-
-gfx::Rect RenderWidgetHostViewEfl::GetBoundsInRootWindow() {
- Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_);
- int x, y, w, h;
- ecore_evas_geometry_get(ee, &x, &y, &w, &h);
- if (current_orientation_ == 90 || current_orientation_ == 270)
- return ConvertRectToDIP(device_scale_factor_, gfx::Rect(x, y, h, w));
-
- return ConvertRectToDIP(device_scale_factor_, gfx::Rect(x, y, w, h));
-}
-
-gfx::GLSurfaceHandle RenderWidgetHostViewEfl::GetCompositingSurface() {
- return gfx::GLSurfaceHandle(gfx::kNullPluginWindow, gfx::NULL_TRANSPORT);
-}
-
-void RenderWidgetHostViewEfl::ResizeCompositingSurface(const gfx::Size& size) {
- if (web_view_)
- web_view_->DidChangeContentsArea(size.width(), size.height());
-}
-
-void RenderWidgetHostViewEfl::RenderProcessGone(base::TerminationStatus, int error_code) {
- Destroy();
-}
-
-void RenderWidgetHostViewEfl::HandleShow() {
- host_->WasShown(ui::LatencyInfo());
-}
-
-void RenderWidgetHostViewEfl::HandleHide() {
- host_->WasHidden();
-}
-
-void RenderWidgetHostViewEfl::HandleResize(int width, int height) {
- // Have to use UpdateScreenInfo(GetNativeView()); when real native surface is used.
- UpdateScreenInfo(GetNativeView());
- host_->WasResized();
-
- if (im_context_ && im_context_->IsShow())
- ScrollFocusedEditableNode();
-}
-
-void RenderWidgetHostViewEfl::HandleFocusIn() {
- if (im_context_)
- im_context_->OnFocusIn();
-
- host_->SetActive(true);
- host_->GotFocus();
- //Will resume the videos playbacks if any were paused when Application was
- // hidden
- host_->WasShown(ui::LatencyInfo());
-}
-
-void RenderWidgetHostViewEfl::HandleFocusOut() {
- if (GetSelectionController() &&
- GetSelectionController()->IsAnyHandleVisible()) {
- GetSelectionController()->HideHandleAndContextMenu();
- GetSelectionController()->ClearSelectionViaEWebView();
- }
-
- if (im_context_)
- im_context_->OnFocusOut();
-
- if (ClipboardHelperEfl::GetInstance()->IsClipboardWindowOpened())
- ClipboardHelperEfl::GetInstance()->CloseClipboardWindow();
-
- host_->SetActive(false);
- host_->LostCapture();
- Blur();
-}
-
-void RenderWidgetHostViewEfl::set_magnifier(bool status) {
- m_magnifier = status;
-}
-
-void RenderWidgetHostViewEfl::HandleEvasEvent(const Evas_Event_Mouse_Down* event) {
- host_->ForwardMouseEvent(WebEventFactoryEfl::toWebMouseEvent(evas_, content_image_, event, device_scale_factor_));
-}
-
-void RenderWidgetHostViewEfl::HandleEvasEvent(const Evas_Event_Mouse_Up* event) {
- host_->ForwardMouseEvent(WebEventFactoryEfl::toWebMouseEvent(evas_, content_image_, event, device_scale_factor_));
-}
-
-void RenderWidgetHostViewEfl::HandleEvasEvent(const Evas_Event_Mouse_Move* event) {
- host_->ForwardMouseEvent(WebEventFactoryEfl::toWebMouseEvent(evas_, content_image_, event, device_scale_factor_));
-}
-
-void RenderWidgetHostViewEfl::HandleEvasEvent(const Evas_Event_Mouse_Wheel* event) {
- host_->ForwardWheelEvent(WebEventFactoryEfl::toWebMouseEvent(evas_, content_image_, event, device_scale_factor_));
-}
-
-void RenderWidgetHostViewEfl::HandleEvasEvent(const Evas_Event_Key_Down* event) {
- if (WebEventFactoryEfl::isHardwareBackKey(event) && disambiguation_popup_) {
- disambiguation_popup_->Dismiss();
- }
-
- if (!strcmp(event->key, "XF86Phone")) {
- host_->WasHidden();
- }
-
- if (!strcmp(event->key, "XF86PowerOff")) {
- host_->WasHidden();
- }
-
- if (web_view_) {
-#ifdef TIZEN_CONTENTS_DETECTION
- if (!strcmp(event->key, "XF86Stop")) {
- PopupControllerEfl* popup_controller = web_view_->GetPopupController();
- if (popup_controller)
- popup_controller->closePopup();
- }
-#endif
-
- //if (!strcmp(event->key, "XF86Stop") || !strcmp(event->key, "BackSpace")) {
- if (!strcmp(event->key, "BackSpace")) {
- SelectionControllerEfl* controller = web_view_->GetSelectionController();
- if (controller)
- controller->HideHandleAndContextMenu();
- }
- }
-
- if (im_context_) {
- if (!strcmp(event->key, "Return")) {
- im_context_->CancelComposition();
- }
-
- bool wasFiltered = false;
- std::string utf8_key = event->string ? event->string : "";
- im_context_->HandleKeyDownEvent(event, &wasFiltered, &utf8_key);
-
- NativeWebKeyboardEvent n_event = WebEventFactoryEfl::toWebKeyboardEvent(
- evas_, event, event->string ? utf8_key.c_str() : 0);
-
- // When upper case letter is entered there are two events
- // Shift + letter key
- // Do not forward shift key to prevent shift keydown event.
- if (!strcmp(event->key, "Shift_L"))
- return;
-
- if (wasFiltered)
- n_event.isSystemKey = true;
-
- // Do not forward keyevent now if there is fake key event
- // handling at the moment to preserve orders of events as in Webkit
- if (im_context_->GetPreeditQueue().empty() || keyupev_queue_.empty()) {
- host_->ForwardKeyboardEvent(n_event);
- } else {
- NativeWebKeyboardEvent *n_event_ptr = new NativeWebKeyboardEvent();
-
- n_event_ptr->timeStampSeconds = n_event.timeStampSeconds;
- n_event_ptr->type = n_event.type;
- n_event_ptr->modifiers = n_event.modifiers;
- n_event_ptr->windowsKeyCode = n_event.windowsKeyCode;
- n_event_ptr->nativeKeyCode = n_event.nativeKeyCode;
- n_event_ptr->isSystemKey = n_event.isSystemKey;
- memcpy(n_event_ptr->text, n_event.text,
- sizeof(n_event_ptr->text));
- memcpy(n_event_ptr->unmodifiedText, n_event.unmodifiedText,
- sizeof(n_event_ptr->unmodifiedText));
- memcpy(n_event_ptr->keyIdentifier, n_event.keyIdentifier,
- sizeof(n_event_ptr->keyIdentifier));
-
- keydownev_queue_.push(n_event_ptr);
- }
-
- keyupev_queue_.push(n_event.windowsKeyCode);
- } else {
- host_->ForwardKeyboardEvent(WebEventFactoryEfl::toWebKeyboardEvent(evas_, event));
- }
-}
-
-void RenderWidgetHostViewEfl::HandleEvasEvent(const Evas_Event_Key_Up* event) {
- if (im_context_) {
- bool wasFiltered = false;
- im_context_->HandleKeyUpEvent(event, &wasFiltered);
- } else {
- host_->ForwardKeyboardEvent(WebEventFactoryEfl::toWebKeyboardEvent(evas_, event));
- }
-}
-
-#if defined(OS_TIZEN)
-#if defined(OS_TIZEN_MOBILE)
-void RenderWidgetHostViewEfl::FilterInputMotion(const blink::WebGestureEvent& gesture_event) {
- if (gesture_event.type == blink::WebInputEvent::GesturePinchUpdate) {
- Evas_Coord_Point position;
-
- position.x = gesture_event.x;
- position.y = gesture_event.y;
- wkext_motion_tilt_position_update(&position);
- }
-}
-#endif
-
-void RenderWidgetHostViewEfl::makePinchZoom(void* eventInfo) {
-#if !defined(EWK_BRINGUP) && defined(OS_TIZEN_MOBILE)
- Wkext_Motion_Event* motionEvent = static_cast<Wkext_Motion_Event*>(eventInfo);
-
- ui::GestureEvent event(ui::ET_GESTURE_PINCH_UPDATE,
- motionEvent->position.x, motionEvent->position.y, 0, ui::EventTimeForNow(),
- ui::GestureEventDetails(ui::ET_GESTURE_PINCH_UPDATE, motionEvent->scale, 0), 1);
- HandleGesture(&event);
-#endif
-}
-
-void RenderWidgetHostViewEfl::OnDidHandleKeyEvent(const blink::WebInputEvent* input_event, bool processed) {
- if (!im_context_)
- return;
-
- if (input_event->type == blink::WebInputEvent::KeyDown) {
- HandleCommitQueue(processed);
- HandlePreeditQueue(processed);
- HandleKeyUpQueue();
- HandleKeyDownQueue();
-
- const blink::WebKeyboardEvent* key = static_cast
- <const blink::WebKeyboardEvent*>(input_event);
-
- if (web_view_ && !processed) {
- Eina_Bool result = false;
- if (key->nativeKeyCode == 116) {
- web_view_->InvokeViewUnfocusAllowCallback(
- tizen_webview::UNFOCUS_DIRECTION_DOWN, &result);
- } else if (key->nativeKeyCode == 111) {
- web_view_->InvokeViewUnfocusAllowCallback(
- tizen_webview::UNFOCUS_DIRECTION_UP, &result);
- }
- }
- }
-}
-#endif
-
-namespace {
-
-void HandleTap(
- Evas_Object* o, int x, int y, int ,
- tizen_webview::Hit_Test* hit_test, void* data) {
- RenderWidgetHostViewEfl* rwhv = static_cast<RenderWidgetHostViewEfl*>(data);
- Ewk_Settings* settings = rwhv->eweb_view()->GetSettings();
-
- if (!settings)
- return;
-
- if (!hit_test)
- return;
-
- if (hit_test->GetResultContext() &
- tizen_webview::TW_HIT_TEST_RESULT_CONTEXT_LINK) {
- if (settings->linkEffectEnabled())
- sound_effect::playLinkEffect();
-#if defined(TIZEN_CONTENTS_DETECTION)
- rwhv->OnContentsDetected(hit_test->GetLinkUri());
- } else if (settings->detectContentsAutomatically() &&
- (hit_test->GetResultContext() &
- tizen_webview::TW_HIT_TEST_RESULT_CONTEXT_TEXT)) {
- rwhv->DetectContentOnPosition(x, y);
-#endif
- }
-}
-
-} // namespace
-
-void RenderWidgetHostViewEfl::HandleTapEvent(blink::WebGestureEvent& event) {
- Ewk_Settings* settings = web_view_->GetSettings();
- if (!settings || (settings && !settings->linkEffectEnabled() &&
- !settings->detectContentsAutomatically()))
- return;
-
- web_view_->AsyncRequestHitTestDataAtBlinkCords(
- event.x, event.y,
- tizen_webview::TW_HIT_TEST_MODE_NODE_DATA,
- HandleTap, this);
-}
-
-#if defined(TIZEN_CONTENTS_DETECTION)
-void RenderWidgetHostViewEfl::OnGetTextAtPositionReply(
- const std::string& text) {
- base::string16 content = base::UTF8ToUTF16(text);
-
- std::string message;
- if(autofill::IsValidEmailAddress(content))
- message = std::string("mailto:").append(text);
- else if(autofill::IsValidPhoneNumber(content))
- message = std::string("tel:").append(text);
- else
- return;
-
- OnContentsDetected(message.c_str());
-}
-
-void RenderWidgetHostViewEfl::DetectContentOnPosition(int x, int y) {
- host_->Send(new ViewMsg_GetTextAtPosition(host_->GetRoutingID(), x, y));
-}
-#endif
-
-ui::LatencyInfo CreateLatencyInfo(const blink::WebInputEvent& event) {
- ui::LatencyInfo latency_info;
- // The latency number should only be added if the timestamp is valid.
- if (event.timeStampSeconds) {
- const int64 time_micros = static_cast<int64>(
- event.timeStampSeconds * base::Time::kMicrosecondsPerSecond);
- latency_info.AddLatencyNumberWithTimestamp(
- ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
- 0,
- 0,
- base::TimeTicks() + base::TimeDelta::FromMicroseconds(time_micros),
- 1);
- }
- return latency_info;
-}
-
-void RenderWidgetHostViewEfl::SendGestureEvent(
- blink::WebGestureEvent& event) {
- HandleGesture(event);
-#if defined(OS_TIZEN_MOBILE)
- FilterInputMotion(event);
-#endif
- if (m_magnifier && event.type == blink::WebInputEvent::GestureScrollUpdate)
- return;
- if (host_ && event.type != blink::WebInputEvent::Undefined)
- host_->ForwardGestureEventWithLatencyInfo(event, CreateLatencyInfo(event));
-}
-
-void RenderWidgetHostViewEfl::HandleGestureBegin() {
- selection_acked_on_tap_ = false;
- single_tap_performed_ = false;
- was_scrolled_ = false;
-
-#ifdef TIZEN_EDGE_EFFECT
- web_view_->edgeEffect()->enable();
-#endif
- if (GetSelectionController()) {
- should_restore_selection_menu_ =
- GetSelectionController()->IsAnyHandleVisible();
- restore_showing_large_handler_ =
- GetSelectionController()->GetShowOnlyLargeHandler();
- }
-}
-
-void RenderWidgetHostViewEfl::HandleGestureEnd() {
- if (GetSelectionController()) {
- if (should_restore_selection_menu_ && !was_scrolled_ &&
- !selection_acked_on_tap_ &&
- !(single_tap_performed_ &&
- GetSelectionController()->GetSelectionEditable())) {
- should_restore_selection_menu_ = false;
- GetSelectionController()->HideHandleAndContextMenu();
- }
- }
- 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.
-#ifdef TIZEN_EDGE_EFFECT
- web_view_->edgeEffect()->disable();
-#endif
-}
-
-void RenderWidgetHostViewEfl::HandleGesture(
- blink::WebGestureEvent& event) {
-
- 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);
- }
-
- if ((event.type == blink::WebInputEvent::GesturePinchBegin ||
- event.type == blink::WebInputEvent::GesturePinchUpdate ||
- event.type == blink::WebInputEvent::GesturePinchEnd) &&
- (!pinch_zoom_enabled_ || eweb_view()->IsFullscreen())) {
- return;
- }
-
- if (event.type == blink::WebInputEvent::GestureDoubleTap ||
- event.type == blink::WebInputEvent::GesturePinchBegin) {
- eweb_view()->SmartCallback<EWebViewCallbacks::ZoomStarted>().call();
- }
- if (event.type == blink::WebInputEvent::GestureDoubleTap ||
- event.type == blink::WebInputEvent::GesturePinchEnd) {
- eweb_view()->SmartCallback<EWebViewCallbacks::ZoomFinished>().call();
- }
-
- if (event.type == blink::WebInputEvent::GestureTap)
- HandleTapEvent(event);
-
- if (event.type == blink::WebInputEvent::GestureTap ||
- event.type == blink::WebInputEvent::GestureTapCancel) {
- float size = 32.0f; // Default value
-#if defined(OS_TIZEN_MOBILE)
- size = elm_config_finger_size_get() / device_scale_factor_;
-#endif
- event.data.tap.width = size;
- event.data.tap.height = size;
- }
-
- if ((event.type == blink::WebInputEvent::GestureScrollBegin ||
- event.type == blink::WebInputEvent::GestureScrollUpdate ||
- event.type == blink::WebInputEvent::GestureScrollEnd) &&
- eweb_view()->IsDragging()) {
- // Disable screen scrolling while D&D is active.
- event.data.scrollUpdate.deltaX = 0;
- event.data.scrollUpdate.deltaY = 0;
- }
-
- if (event.type == blink::WebInputEvent::GestureTapDown) {
- // Webkit does not stop a fling-scroll on tap-down. So explicitly send an
- // event to stop any in-progress flings.
- blink::WebGestureEvent fling_cancel = event;
- 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 if (event.type == blink::WebInputEvent::GestureScrollEnd) {
- if (GetSelectionController()) {
- if (GetSelectionController()->GetScrollStatus())
- GetSelectionController()->SetScrollStatus(false);
-
- if (GetSelectionController()->GetSelectionStatus()) {
- GetSelectionController()->SetShowOnlyLargeHandler(
- single_tap_performed_ || restore_showing_large_handler_);
-
- GetSelectionController()->UpdateSelectionDataAndShow(
- GetSelectionController()->GetLeftRect(),
- GetSelectionController()->GetRightRect(),
- false /* unused */,
- should_restore_selection_menu_);
- }
- }
- } else if (web_view_ && event.type == blink::WebInputEvent::GestureScrollUpdate) {
-#ifdef TIZEN_EDGE_EFFECT
- if (event.data.scrollUpdate.deltaX < 0)
- web_view_->edgeEffect()->hide("edge,left");
- else if (event.data.scrollUpdate.deltaX > 0)
- web_view_->edgeEffect()->hide("edge,right");
- if (event.data.scrollUpdate.deltaY < 0)
- web_view_->edgeEffect()->hide("edge,top");
- else if (event.data.scrollUpdate.deltaY > 0)
- web_view_->edgeEffect()->hide("edge,bottom");
- } else if (web_view_ && event.type == blink::WebInputEvent::GesturePinchBegin) {
- web_view_->edgeEffect()->disable();
- } else if (web_view_ && event.type == blink::WebInputEvent::GesturePinchEnd) {
- web_view_->edgeEffect()->enable();
-#endif
- }
-}
-
-void RenderWidgetHostViewEfl::HandleGesture(ui::GestureEvent* event) {
- blink::WebGestureEvent gesture =
- content::MakeWebGestureEventFromUIEvent(*event);
- gesture.x = event->x();
- gesture.y = event->y();
-
- const gfx::Point root_point = event->root_location();
- gesture.globalX = root_point.x();
- gesture.globalY = root_point.y();
-
- if (event->type() == ui::ET_GESTURE_BEGIN)
- HandleGestureBegin();
- else if (event->type() == ui::ET_GESTURE_END)
- HandleGestureEnd();
-
- SendGestureEvent(gesture);
- event->SetHandled();
-}
-
-bool RenderWidgetHostViewEfl::IsLastAvailableTextEmpty() const {
- return RenderWidgetHostViewBase::selection_text_.empty();
-}
-
-// Copied from render_widget_host_view_aura.cc
-void UpdateWebTouchEventAfterDispatch(blink::WebTouchEvent* event,
- blink::WebTouchPoint* point) {
- if (point->state != blink::WebTouchPoint::StateReleased
- && point->state != blink::WebTouchPoint::StateCancelled)
- return;
- --event->touchesLength;
- for (unsigned i = point - event->touches;
- i < event->touchesLength;
- ++i)
- event->touches[i] = event->touches[i + 1];
-}
-
-void RenderWidgetHostViewEfl::HandleTouchEvent(ui::TouchEvent* event) {
- if (!gesture_recognizer_->ProcessTouchEventPreDispatch(*event, this)) {
- event->StopPropagation();
- return;
- }
-
- // Update the touch event first.
- blink::WebTouchPoint* point =
- content::UpdateWebTouchEventFromUIEvent(*event, &touch_event_);
- // Forward the touch event only if a touch point was updated, and there's a
- // touch-event handler in the page, and no other touch-event is in the queue.
- // It is important to always consume the event if there is a touch-event
- // handler in the page, or some touch-event is already in the queue, even if
- // no point has been updated, to make sure that this event does not get
- // processed by the gesture recognizer before the events in the queue.
- if (host_->ShouldForwardTouchEvent()) {
- event->StopPropagation();
- }
-
- bool forwarded = false;
- if (point) {
- if (host_->ShouldForwardTouchEvent()) {
- forwarded = true;
- host_->ForwardTouchEventWithLatencyInfo(touch_event_, *event->latency());
- }
- UpdateWebTouchEventAfterDispatch(&touch_event_, point);
- }
-
- // If we forward it to the renderer than either blink handles it or we will
- // have a second round with it in ProcessAckedTouchEvent.
- if (forwarded)
- return;
-
- scoped_ptr<ui::GestureRecognizer::Gestures> gestures(
- gesture_recognizer_->ProcessTouchEventPostDispatch(*event, ui::ER_UNHANDLED, this));
- if (!gestures)
- return;
- for (size_t j = 0; j < gestures->size(); ++j) {
- ui::GestureEvent* event = gestures->get().at(j);
- HandleGesture(event);
- }
-}
-
-void RenderWidgetHostViewEfl::ProcessAckedTouchEvent(
- const TouchEventWithLatencyInfo& touch,
- InputEventAckState ack_result) {
- ScopedVector<ui::TouchEvent> events;
- if (!MakeUITouchEventsFromWebTouchEvents(touch, &events, LOCAL_COORDINATES))
- return;
-
- ui::EventResult result = (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) ?
- ui::ER_HANDLED : ui::ER_UNHANDLED;
- for (ScopedVector<ui::TouchEvent>::const_iterator iter = events.begin(),
- end = events.end(); iter != end; ++iter) {
- scoped_ptr<ui::GestureRecognizer::Gestures> gestures(
- gesture_recognizer_->ProcessTouchEventOnAsyncAck(**iter, result, this));
- if (gestures) {
- for (size_t j = 0; j < gestures->size(); ++j) {
- ui::GestureEvent* event = gestures->get().at(j);
- HandleGesture(event);
- }
- }
- }
-}
-
-void RenderWidgetHostViewEfl::OnPlainTextGetContents(const std::string& content_text, int plain_text_get_callback_id) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- eweb_view()->InvokePlainTextGetCallback(content_text, plain_text_get_callback_id);
-}
-
-void RenderWidgetHostViewEfl::OnWebAppCapableGet(bool capable, int callback_id) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- eweb_view()->InvokeWebAppCapableGetCallback(capable, callback_id);
-}
-
-void RenderWidgetHostViewEfl::OnWebAppIconUrlGet(const std::string &icon_url, int callback_id) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- eweb_view()->InvokeWebAppIconUrlGetCallback(icon_url, callback_id);
-}
-
-void RenderWidgetHostViewEfl::OnWebAppIconUrlsGet(const std::map<std::string, std::string> &icon_urls, int callback_id) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- eweb_view()->InvokeWebAppIconUrlsGetCallback(icon_urls, callback_id);
-}
-
-void RenderWidgetHostViewEfl::OnDidChangeContentsSize(int width, int height) {
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- if (web_view_)
- web_view_->DidChangeContentsSize(width, height);
-}
-
-void RenderWidgetHostViewEfl::OnOrientationChangeEvent(int orientation) {
- current_orientation_ = orientation;
-}
-
-void RenderWidgetHostViewEfl::OnDidChangeMaxScrollOffset(int maxScrollX, int maxScrollY) {
- scroll_detector_->SetMaxScroll(maxScrollX, maxScrollY);
-}
-
-void RenderWidgetHostViewEfl::OnDidChangeScrollOffset(int scrollX, int scrollY) {
- scroll_detector_->OnChangeScrollOffset(web_view_, gfx::Vector2d(scrollX, scrollY));
- scroll_offset_changed_ = false;
-}
-
-void RenderWidgetHostViewEfl::SelectRange(const gfx::Point& start, const gfx::Point& end) {
- RenderViewHost* rvh = RenderViewHost::From(host_);
- WebContentsImpl* wci = static_cast<WebContentsImpl*>(
- content::WebContents::FromRenderViewHost(rvh));
- wci->SelectRange(gfx::Point(start.x() / device_scale_factor_, start.y() / device_scale_factor_),
- gfx::Point(end.x() / device_scale_factor_, end.y() / device_scale_factor_));
-}
-
-void RenderWidgetHostViewEfl::MoveCaret(const gfx::Point& point) {
- host_->MoveCaret(gfx::Point(point.x() / device_scale_factor_, point.y() / device_scale_factor_));
-}
-
-void RenderWidgetHostViewEfl::OnMHTMLContentGet(const std::string& mhtml_content, int callback_id) {
- eweb_view()->OnMHTMLContentGet(mhtml_content, callback_id);
-}
-
-void RenderWidgetHostViewEfl::OnDidChangePageScaleFactor(double scale_factor) {
- eweb_view()->DidChangePageScaleFactor(scale_factor);
-}
-
-void RenderWidgetHostViewEfl::OnDidChangePageScaleRange(double min_scale, double max_scale) {
- eweb_view()->DidChangePageScaleRange(min_scale, max_scale);
-}
-
-SelectionControllerEfl* RenderWidgetHostViewEfl::GetSelectionController() {
- if (web_view_)
- return web_view_->GetSelectionController();
-
- return NULL;
-}
-
-void RenderWidgetHostViewEfl::SetComposition(const ui::CompositionText& composition_text) {
- const std::vector<blink::WebCompositionUnderline>& underlines =
- reinterpret_cast<const std::vector<blink::WebCompositionUnderline>&>(
- composition_text.underlines);
-
- host_->ImeSetComposition(
- composition_text.text, underlines, composition_text.selection.start(),
- composition_text.selection.end());
-}
-
-void RenderWidgetHostViewEfl::ClearQueues() {
- while (!keyupev_queue_.empty()) {
- keyupev_queue_.pop();
- }
-
- while (!keydownev_queue_.empty()) {
- delete keydownev_queue_.front();
- keydownev_queue_.pop();
- }
-}
-
-void RenderWidgetHostViewEfl::ConfirmComposition(base::string16& text) {
- host_->ImeConfirmComposition(text, gfx::Range::InvalidRange(), false);
-}
-
-void RenderWidgetHostViewEfl::HandleCommitQueue(bool processed) {
- if (!im_context_)
- return;
-
- while (!im_context_->GetCommitQueue().empty()) {
- const bool isEmpty = im_context_->GetCommitQueue().front().empty();
-
- if (!processed && !isEmpty)
- ConfirmComposition(im_context_->GetCommitQueue().front());
-
- im_context_->CommitQueuePop();
-
- if (isEmpty)
- break;
- }
-}
-
-void RenderWidgetHostViewEfl::HandlePreeditQueue(bool processed) {
- if (!im_context_)
- return;
-
- if (!im_context_->GetPreeditQueue().empty()) {
- if (!processed) {
- SetComposition(im_context_->GetPreeditQueue().front());
- } else {
- im_context_->ResetIMFContext();
- }
- im_context_->PreeditQueuePop();
- }
-}
-
-void RenderWidgetHostViewEfl::HandleKeyUpQueue() {
- if (!im_context_)
- return;
-
- if (keyupev_queue_.empty())
- return;
-
- int keyCode = keyupev_queue_.front();
- SendCompositionKeyUpEvent(keyCode);
- keyupev_queue_.pop();
-}
-
-void RenderWidgetHostViewEfl::HandleKeyDownQueue() {
- if (!im_context_)
- return;
-
- if (keydownev_queue_.empty())
- return;
-
- NativeWebKeyboardEvent *n_event = keydownev_queue_.front();
- host_->ForwardKeyboardEvent(*n_event);
- keydownev_queue_.pop();
- delete n_event;
-}
-
-void RenderWidgetHostViewEfl::SendCompositionKeyUpEvent(char c) {
- NativeWebKeyboardEvent event;
- event.windowsKeyCode = c;
- event.skip_in_browser = false;
- event.type = blink::WebInputEvent::KeyUp;
- host_->ForwardKeyboardEvent(event);
-}
-
-void RenderWidgetHostViewEfl::OnSwapCompositorFrame(
- uint32 output_surface_id, scoped_ptr<cc::CompositorFrame> frame) {
- cc::CompositorFrameAck ack;
-
- // TODO(prashant.n): Delegated and software frames not supported. So with
- // those frames black screen will appear.
- if (frame->gl_frame_data) {
- ack.gl_frame_data = frame->gl_frame_data.Pass();
-
- surface_size_ = ack.gl_frame_data->size;
-
- if (m_IsEvasGLInit) {
- std::swap(ack.gl_frame_data->mailbox, pending_mailbox_);
- gpu::gles2::MailboxManager* manager =
- GLSharedContextEfl::GetMailboxManager();
-
- gpu::gles2::Texture* texture =
- manager->ConsumeTexture(pending_mailbox_);
- if (texture != NULL) {
- texture_id_ = GetTextureIdFromTexture(texture);
- evas_object_image_pixels_dirty_set(content_image_, true);
- } else {
- LOG(ERROR) << "Frame produced without texture.";
- }
- }
-
- ack.gl_frame_data->sync_point = 0;
- } else if (frame->delegated_frame_data) {
- LOG(ERROR) << "Delegated frame is not supported.";
- cc::TransferableResource::ReturnResources(
- frame->delegated_frame_data->resource_list,
- &ack.resources);
- } else if (frame->software_frame_data) {
- LOG(ERROR) << "Software frame is not supported.";
- ack.last_software_frame_id = frame->software_frame_data->id;
- }
-
- // TODO(prashant.n): Check if ack should be sent after frame is drawn.
- host_->SendSwapCompositorFrameAck(host_->GetRoutingID(),
- output_surface_id,
- host_->GetProcess()->GetID(),
- ack);
-}
-
-void RenderWidgetHostViewEfl::SetViewMode(blink::WebViewMode view_mode) {
- host_->Send(new ViewMsg_SetViewMode(host_->GetRoutingID(), view_mode));
-}
-
-gfx::Vector2d RenderWidgetHostViewEfl::scroll_offset() const {
- return scroll_detector_->GetLastScrollPosition();
-}
-
-void RenderWidgetHostViewEfl::ScrollFocusedEditableNode() {
- host_->ScrollFocusedEditableNodeIntoRect(gfx::Rect(0, 0, 0, 0));
-}
-
-} // namespace content
+++ /dev/null
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Copyright 2014 Samsung Electronics. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef RENDER_WIDGET_HOST_VIEW_EFL
-#define RENDER_WIDGET_HOST_VIEW_EFL
-
-#include "base/basictypes.h"
-#include "base/format_macros.h"
-#include "content/browser/renderer_host/render_widget_host_view_base.h"
-#include "content/common/content_export.h"
-#include "cc/layers/delegated_frame_provider.h"
-#include "cc/layers/delegated_frame_resource_collection.h"
-#include "cc/output/compositor_frame.h"
-#include "cc/output/compositor_frame_ack.h"
-#include "cc/output/copy_output_request.h"
-#include "cc/output/copy_output_result.h"
-#include "cc/resources/single_release_callback.h"
-#include "cc/resources/texture_mailbox.h"
-#include "content/browser/accessibility/browser_accessibility_manager.h"
-#include "content/browser/compositor/image_transport_factory.h"
-#include "content/browser/compositor/owned_mailbox.h"
-#include "gpu/command_buffer/common/mailbox.h"
-#include "ui/base/ime/composition_text.h"
-#include "ui/base/ime/text_input_client.h"
-#include "eweb_view.h"
-#include "browser/renderer_host/im_context_efl.h"
-#include "third_party/WebKit/public/web/WebInputEvent.h"
-
-#include <deque>
-#include <Evas.h>
-#include <Ecore_Evas.h>
-#include <Evas_GL.h>
-#include <Ecore_IMF_Evas.h>
-
-#ifndef OS_TIZEN
-// On desktops using mesa as GLES2 implementation GLchar is not defined
-// Normally chromium uses it's own modified khronos headers from third_party/khronos,
-// unfortunately those headers won't be included by Evas_GL.h
-typedef char GLchar;
-#endif
-
-namespace ui {
-class GestureEvent;
-class TouchEvent;
-}
-
-namespace EflWebview {
-class ScrollDetector;
-}
-
-namespace content {
-
-class DisambiguationPopupEfl;
-class IMContextEfl;
-class RenderWidgetHostImpl;
-class RenderWidgetHostView;
-class ReadbackYUVInterface;
-
-// RenderWidgetHostView class hierarchy described in render_widget_host_view.h.
-class RenderWidgetHostViewEfl
- : public RenderWidgetHostViewBase,
- public ui::GestureConsumer,
- public ui::GestureEventHelper,
- public base::SupportsWeakPtr<RenderWidgetHostViewEfl>,
- public IPC::Sender {
- public:
- explicit RenderWidgetHostViewEfl(RenderWidgetHost*, EWebView*);
-
- // RenderWidgetHostViewBase implementation.
- virtual void InitAsChild(gfx::NativeView) override;
- virtual void InitAsPopup(content::RenderWidgetHostView*, const gfx::Rect&) override;
- virtual void InitAsFullscreen(content::RenderWidgetHostView*) override;
- virtual RenderWidgetHost* GetRenderWidgetHost() const override;
- virtual void SetSize(const gfx::Size&) override;
- virtual void SetBounds(const gfx::Rect&) override;
- virtual gfx::Vector2dF GetLastScrollOffset() const override;
- virtual gfx::NativeView GetNativeView() const override;
- virtual gfx::NativeViewId GetNativeViewId() const override;
- virtual gfx::NativeViewAccessible GetNativeViewAccessible() override;
- virtual bool IsSurfaceAvailableForCopy() const override;
- virtual void Show() override;
- virtual void Hide() override;
- virtual bool IsShowing() override;
- virtual gfx::Rect GetViewBounds() const override;
- virtual bool LockMouse() override;
- virtual void UnlockMouse() override;
- virtual void WasShown() override;
- virtual void WasHidden() override;
- virtual void Focus() override;
- virtual bool HasFocus() const override;
- void MovePluginContainer(const WebPluginGeometry&);
- virtual void MovePluginWindows(
- const std::vector<WebPluginGeometry>&) override;
- virtual void Blur() override;
- virtual void UpdateCursor(const WebCursor&) override;
- virtual void SetIsLoading(bool) override;
-
- void OnTextInputStateChanged(const ViewHostMsg_TextInputState_Params& params);
-
- virtual void TextInputTypeChanged(ui::TextInputType type,
- ui::TextInputMode mode,
- bool can_compose_inline,
- int flags) override;
-
- virtual void ImeCancelComposition() override;
- virtual void ImeCompositionRangeChanged(const gfx::Range&, const std::vector<gfx::Rect>&) override;
- virtual void FocusedNodeChanged(bool is_editable_node) override;
-
- virtual void Destroy() override;
- virtual void SetTooltipText(const base::string16&) override;
- virtual void SelectionChanged(const base::string16&, size_t, const gfx::Range&) override;
- virtual void SelectionBoundsChanged(const ViewHostMsg_SelectionBounds_Params&) override;
- void SelectionRootBoundsChanged(const gfx::Rect&) override;
- virtual void CopyFromCompositingSurface(
- const gfx::Rect&,
- const gfx::Size& /* dst_size */,
- const base::Callback<void(bool, const SkBitmap&)>&,
- const SkColorType) override;
-
- virtual void CopyFromCompositingSurfaceToVideoFrame(
- const gfx::Rect&,
- const scoped_refptr<media::VideoFrame>&,
- const base::Callback<void(bool)>&) override;
-
- virtual bool CanCopyToVideoFrame() const override;
- virtual bool CanSubscribeFrame() const override;
- virtual void BeginFrameSubscription(
- scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) override;
- virtual void EndFrameSubscription() override;
-
-
-#ifdef TIZEN_EDGE_EFFECT
- virtual void DidOverscroll(const DidOverscrollParams& params) override;
-#endif
-
-#ifdef TIZEN_CONTENTS_DETECTION
- void OnContentsDetected(const char*);
-#endif
-
- virtual void AcceleratedSurfaceInitialized(int) override;
- virtual bool HasAcceleratedSurface(const gfx::Size&) override;
- virtual void GetScreenInfo(blink::WebScreenInfo*) override;
- virtual gfx::Rect GetBoundsInRootWindow() override;
- virtual gfx::GLSurfaceHandle GetCompositingSurface() override;
- virtual void ResizeCompositingSurface(const gfx::Size&);
- virtual void RenderProcessGone(base::TerminationStatus, int) override;
- virtual bool OnMessageReceived(const IPC::Message&) override;
-
- void OnFilteredMessageReceived(const IPC::Message&);
-
- virtual void ProcessAckedTouchEvent(const TouchEventWithLatencyInfo&, InputEventAckState) override;
- virtual void DidStopFlinging() override;
-
- virtual void ShowDisambiguationPopup(const gfx::Rect& rect_pixels,
- const SkBitmap& zoomed_bitmap) override;
-
- virtual void OnSwapCompositorFrame(
- uint32 output_surface_id, scoped_ptr<cc::CompositorFrame> frame) override;
-
- // ui::GestureEventHelper implementation.
- virtual bool CanDispatchToConsumer(ui::GestureConsumer* consumer) override;
- virtual void DispatchCancelTouchEvent(ui::TouchEvent* event) override;
- virtual void DispatchGestureEvent(ui::GestureEvent*) override;
-
- // IPC::Sender implementation:
- virtual bool Send(IPC::Message*) override;
-
- void OnSelectionTextStyleState(const SelectionStylePrams& params);
- void OnDidChangeMaxScrollOffset(int maxScrollX, int maxScrollY);
- void OnDidChangeScrollOffset(int scrollX, int scrollY);
-
-#ifdef OS_TIZEN
- void FilterInputMotion(const blink::WebGestureEvent& gesture_event);
- void makePinchZoom(void* eventInfo);
- void OnDidHandleKeyEvent(const blink::WebInputEvent* input_event, bool processed);
- void GetSnapshotForRect(gfx::Rect& rect);
- void GetSnapshotAsync(const gfx::Rect& snapshot_area, int request_id);
-#endif
-
- Evas* evas() const {
- DCHECK(evas_);
- return evas_;
- }
-
- bool IsLastAvailableTextEmpty() const;
- void set_magnifier(bool status);
-
- void Init_EvasGL(int width, int height);
- void Init(Evas_Object* view, const gfx::Size& size);
-
- EWebView* eweb_view() const { return web_view_; }
- RenderWidgetHostImpl* host() const { return host_; }
- IMContextEfl* im_context() const { return im_context_; }
- gfx::Vector2d scroll_offset() const;
-
- void HandleShow();
- void HandleHide();
- void HandleMove(int, int) {}
- void HandleResize(int, int );
- void HandleFocusIn();
- void HandleFocusOut();
-
- void HandleEvasEvent(const Evas_Event_Mouse_Down*);
- void HandleEvasEvent(const Evas_Event_Mouse_Up*);
- void HandleEvasEvent(const Evas_Event_Mouse_Move*);
- void HandleEvasEvent(const Evas_Event_Mouse_Wheel*);
- void HandleEvasEvent(const Evas_Event_Key_Down*);
- void HandleEvasEvent(const Evas_Event_Key_Up*);
- void HandleGestureBegin();
- void HandleGestureEnd();
- void HandleGesture(ui::GestureEvent*);
- void HandleGesture(blink::WebGestureEvent&);
- void HandleTouchEvent(ui::TouchEvent*);
- void OnPlainTextGetContents(const std::string&, int);
- void OnWebAppCapableGet(bool capable, int callback_id);
- void OnWebAppIconUrlGet(const std::string &icon_url, int callback_id);
- void OnWebAppIconUrlsGet(const std::map<std::string, std::string> &icon_urls, int callback_id);
- void SelectRange(const gfx::Point& start, const gfx::Point& end);
- void MoveCaret(const gfx::Point& point);
- void OnMHTMLContentGet(const std::string& mhtml_content, int callback_id);
-
- Evas_GL_API* evasGlApi() { return evas_gl_api_; }
- gfx::Point ConvertPointInViewPix(gfx::Point point);
- gfx::Rect GetViewBoundsInPix() const;
-
- void OnTextInputInFormStateChanged(bool is_in_form_tag);
- void KeyUpEventQueuePush(int key) { keyupev_queue_.push(key); }
- void ClearQueues();
-
- // This function sets CSS "view-mode" media feature value.
- void SetViewMode(blink::WebViewMode view_mode);
-
- void SetComposition(const ui::CompositionText& composition_text);
- void ConfirmComposition(base::string16& text);
- void SendGestureEvent(blink::WebGestureEvent& event);
-
- bool IsScrollOffsetChanged() const { return scroll_offset_changed_; }
- void SetScrollOffsetChanged() { scroll_offset_changed_ = true; }
-
-#if defined(TIZEN_CONTENTS_DETECTION)
- void DetectContentOnPosition(int x, int y);
-#endif
-
- void ScrollFocusedEditableNode();
-
- protected:
- friend class RenderWidgetHostView;
-
- private:
- virtual ~RenderWidgetHostViewEfl();
-
- void OnDidChangeContentsSize(int, int);
- void OnOrientationChangeEvent(int);
- void OnDidChangePageScaleFactor(double);
- void OnDidChangePageScaleRange(double, double);
- void OnSnapshot(const std::vector<unsigned char> pixData, int snapshotId, const gfx::Size& size);
-
-#if defined(TIZEN_CONTENTS_DETECTION)
- void OnGetTextAtPositionReply(const std::string&);
-#endif
-
- void HandleTapEvent(blink::WebGestureEvent& event);
-
- SelectionControllerEfl* GetSelectionController();
-
- static void CopyFromCompositingSurfaceHasResultForVideo(
- base::WeakPtr<RenderWidgetHostViewEfl> rwhvefl,
- scoped_refptr<OwnedMailbox> subscriber_texture,
- scoped_refptr<media::VideoFrame> video_frame,
- const base::Callback<void(bool)>& callback,
- scoped_ptr<cc::CopyOutputResult> result);
- static void CopyFromCompositingSurfaceFinishedForVideo(
- base::WeakPtr<RenderWidgetHostViewEfl> rwhvefl,
- const base::Callback<void(bool)>& callback,
- scoped_refptr<OwnedMailbox> subscriber_texture,
- scoped_ptr<cc::SingleReleaseCallback> release_callback,
- bool result);
- static void ReturnSubscriberTexture(
- base::WeakPtr<RenderWidgetHostViewEfl> rwhvefl,
- scoped_refptr<OwnedMailbox> subscriber_texture,
- uint32 sync_point);
-
- static void EvasObjectImagePixelsGetCallback(void*, Evas_Object*);
- void initializeProgram();
-
- Ecore_X_Window GetEcoreXWindow() const;
-
- void HandleCommitQueue(bool processed);
- void HandlePreeditQueue(bool processed);
- void HandleKeyUpQueue();
- void HandleKeyDownQueue();
- void SendCompositionKeyUpEvent(char c);
-
- void PaintTextureToSurface(GLuint texture_id);
-
- RenderWidgetHostImpl* host_;
- EWebView* web_view_;
- IMContextEfl* im_context_;
-
- Evas* evas_;
- Evas_Object* content_image_;
- scoped_ptr<EflWebview::ScrollDetector> scroll_detector_;
- int m_IsEvasGLInit;
- float device_scale_factor_;
-
- typedef std::map<gfx::PluginWindowHandle, Ecore_X_Window> PluginWindowToWidgetMap;
- PluginWindowToWidgetMap plugin_window_to_widget_map_;
-
- bool m_magnifier;
-
- // Whether we are currently loading.
- bool is_loading_;
-
- // YUV readback pipeline.
- scoped_ptr<content::ReadbackYUVInterface>
- yuv_readback_pipeline_;
-
- // Subscriber that listens to frame presentation events.
- scoped_ptr<RenderWidgetHostViewFrameSubscriber> frame_subscriber_;
- std::vector<scoped_refptr<OwnedMailbox> > idle_frame_subscriber_textures_;
- std::set<OwnedMailbox*> active_frame_subscriber_textures_;
-
- // The touch-event. Its touch-points are updated as necessary. A new
- // touch-point is added from an ET_TOUCH_PRESSED event, and a touch-point is
- // removed from the list on an ET_TOUCH_RELEASED event.
- blink::WebTouchEvent touch_event_;
-
- // The gesture recognizer for this view.
- // In Aura GestureRecognizer is global. Should we follow that?
- scoped_ptr<ui::GestureRecognizer> gesture_recognizer_;
-
- scoped_ptr<DisambiguationPopupEfl> disambiguation_popup_;
-
- int current_orientation_;
-
- Evas_GL* evas_gl_;
- Evas_GL_API* evas_gl_api_;
- Evas_GL_Context* evas_gl_context_;
- Evas_GL_Surface* evas_gl_surface_;
- Evas_GL_Config* evas_gl_config_;
-
- GLuint program_id_;
- GLint source_texture_location_;
- GLuint position_attrib_;
- GLuint texcoord_attrib_;
- void* egl_image_;
- unsigned long current_pixmap_id_;
- unsigned long next_pixmap_id_;
- GLuint texture_id_;
- int surface_id_;
- gfx::Size surface_size_;
- GLuint vertex_buffer_obj_;
- GLuint vertex_buffer_obj_270_;
- GLuint vertex_buffer_obj_90_;
- GLuint index_buffer_obj_;
- typedef std::queue<int> KeyUpEventQueue;
- KeyUpEventQueue keyupev_queue_;
-
- typedef std::queue<NativeWebKeyboardEvent*> KeyDownEventQueue;
- KeyDownEventQueue keydownev_queue_;
-
- bool should_restore_selection_menu_;
- bool selection_acked_on_tap_;
- // Used only to indicate that user scrolled view
- // after gesture GestureTapDown.
- bool was_scrolled_;
-
- // The last scroll offset of the view.
- gfx::Vector2dF last_scroll_offset_;
- gfx::Point scroll_offset_;
- bool scroll_offset_changed_;
-
- gpu::Mailbox pending_mailbox_;
-
- bool single_tap_performed_;
- bool restore_showing_large_handler_;
- DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewEfl);
-};
-
-} // namespace content
-
-#endif
+++ /dev/null
-// Copyright 2014 Samsung Electronics. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "browser/renderer_host/web_event_factory_efl.h"
-
-#include "base/time/time.h"
-#include "base/strings/utf_string_conversions.h"
-#include "platform/WindowsKeyboardCodes.h"
-#include "third_party/WebKit/public/web/WebInputEvent.h"
-#include "ui/events/keycodes/keyboard_codes.h"
-#include "ui/events/keycodes/keyboard_code_conversion_x.h"
-
-#include <Ecore.h>
-#include "ecore_x_wrapper.h"
-
-// TODO: Figure out how to avoid this includes.
-#include <X11/Xutil.h>
-#include <X11/keysym.h>
-
-#include "tizen_webview/public/tw_touch_point.h"
-
-using namespace blink;
-using namespace tizen_webview;
-
-namespace {
-
-static void TranslateEvasCoordToWebKitCoord(Evas_Object *web_view, int& x, int& y) {
- Evas_Coord tmpX, tmpY;
- evas_object_geometry_get(web_view, &tmpX, &tmpY, 0, 0);
- x -= tmpX;
- y -= tmpY;
-}
-
-}
-
-namespace content {
-
-typedef base::hash_map<std::string, int> WindowsKeyMap;
-static const float cDefaultScrollStep = 20;
-
-static WindowsKeyMap& WinKeyMap() {
- CR_DEFINE_STATIC_LOCAL(WindowsKeyMap, windowsKeyMap, ());
- return windowsKeyMap;
-}
-
-static inline void AddCharactersToWinKeyMap(const char from, const char to, const int baseCode) {
- int i = 0;
- for (char c = from; c <= to; c++, i++) {
- WinKeyMap()[std::string(&c, 1)] = baseCode + i;
- }
-}
-
-static void PopulateWindowsKeyMap() {
- WinKeyMap()["Return"] = VK_RETURN;
- WinKeyMap()["KP_Return"] = VK_RETURN;
- WinKeyMap()["Alt_L"] = VK_LMENU;
- WinKeyMap()["Alt_R"] = VK_RMENU;
- WinKeyMap()["ISO_Level3_Shift"] = VK_MENU;
- WinKeyMap()["Menu"] = VK_MENU;
- WinKeyMap()["Shift_L"] = VK_LSHIFT;
- WinKeyMap()["Shift_R"] = VK_RSHIFT;
- WinKeyMap()["Control_L"] = VK_LCONTROL;
- WinKeyMap()["Control_R"] = VK_RCONTROL;
- WinKeyMap()["Pause"] = VK_PAUSE;
- WinKeyMap()["Break"] = VK_PAUSE;
- WinKeyMap()["Caps_Lock"] = VK_CAPITAL;
- WinKeyMap()["Scroll_Lock"] = VK_SCROLL;
- WinKeyMap()["Num_Lock"] = VK_NUMLOCK;
- WinKeyMap()["Escape"] = VK_ESCAPE;
- WinKeyMap()["Tab"] = VK_TAB;
- WinKeyMap()["ISO_Left_Tab"] = VK_TAB;
- WinKeyMap()["BackSpace"] = VK_BACK;
- WinKeyMap()["space"] = VK_SPACE;
- WinKeyMap()["Next"] = VK_NEXT;
- WinKeyMap()["Prior"] = VK_PRIOR;
- WinKeyMap()["Home"] = VK_HOME;
- WinKeyMap()["End"] = VK_END;
- WinKeyMap()["Right"] = VK_RIGHT;
- WinKeyMap()["Left"] = VK_LEFT;
- WinKeyMap()["Up"] = VK_UP;
- WinKeyMap()["Down"] = VK_DOWN;
- WinKeyMap()["Print"] = VK_SNAPSHOT;
- WinKeyMap()["Insert"] = VK_INSERT;
- WinKeyMap()["Delete"] = VK_DELETE;
-
- WinKeyMap()["comma"] = VK_OEM_COMMA;
- WinKeyMap()["less"] = VK_OEM_COMMA;
- WinKeyMap()["period"] = VK_OEM_PERIOD;
- WinKeyMap()["greater"] = VK_OEM_PERIOD;
- WinKeyMap()["semicolon"] = VK_OEM_1;
- WinKeyMap()["colon"] = VK_OEM_1;
- WinKeyMap()["slash"] = VK_OEM_2;
- WinKeyMap()["question"] = VK_OEM_2;
- WinKeyMap()["grave"] = VK_OEM_3;
- WinKeyMap()["asciitilde"] = VK_OEM_3;
- WinKeyMap()["bracketleft"] = VK_OEM_4;
- WinKeyMap()["braceleft"] = VK_OEM_4;
- WinKeyMap()["backslash"] = VK_OEM_5;
- WinKeyMap()["bar"] = VK_OEM_5;
- WinKeyMap()["bracketright"] = VK_OEM_6;
- WinKeyMap()["braceright"] = VK_OEM_6;
- WinKeyMap()["apostrophe"] = VK_OEM_7;
- WinKeyMap()["quotedbl"] = VK_OEM_7;
- // Keypad location
- WinKeyMap()["KP_Left"] = VK_LEFT;
- WinKeyMap()["KP_Right"] = VK_RIGHT;
- WinKeyMap()["KP_Up"] = VK_UP;
- WinKeyMap()["KP_Down"] = VK_DOWN;
- WinKeyMap()["KP_Prior"] = VK_PRIOR;
- WinKeyMap()["KP_Next"] = VK_NEXT;
- WinKeyMap()["KP_Home"] = VK_HOME;
- WinKeyMap()["KP_End"] = VK_END;
- WinKeyMap()["KP_Insert"] = VK_INSERT;
- WinKeyMap()["KP_Delete"] = VK_DELETE;
-
- // Set alphabet to the windowsKeyMap.
- AddCharactersToWinKeyMap('a', 'z', VK_A);
- AddCharactersToWinKeyMap('A', 'Z', VK_A);
-
- // Set digits to the windowsKeyMap.
- AddCharactersToWinKeyMap('0', '9', VK_0);
-
- // Set shifted digits to the windowsKeyMap.
- WinKeyMap()["exclam"] = VK_1;
- WinKeyMap()["at"] = VK_2;
- WinKeyMap()["numbersign"] = VK_3;
- WinKeyMap()["dollar"] = VK_4;
- WinKeyMap()["percent"] = VK_5;
- WinKeyMap()["asciicircum"] = VK_6;
- WinKeyMap()["ampersand"] = VK_7;
- WinKeyMap()["asterisk"] = VK_8;
- WinKeyMap()["parenleft"] = VK_9;
- WinKeyMap()["parenright"] = VK_0;
- WinKeyMap()["minus"] = VK_OEM_MINUS;
- WinKeyMap()["underscore"] = VK_OEM_MINUS;
- WinKeyMap()["equal"] = VK_OEM_PLUS;
- WinKeyMap()["plus"] = VK_OEM_PLUS;
-
- // Set F_XX keys to the windowsKeyMap.
- for (unsigned i = 1; i < 25; i++) {
- std::string key = "F" + std::to_string(i);
- WinKeyMap()[key] = VK_F1 + i - 1;
- }
-
- WinKeyMap()["KP_Enter"] = VK_RETURN;
- WinKeyMap()["Hangul"] = VK_HANGUL;
- WinKeyMap()["Hangul_Hanja"] = VK_HANJA;
- WinKeyMap()["KP_Multiply"] = VK_MULTIPLY;
- WinKeyMap()["KP_Add"] = VK_ADD;
- WinKeyMap()["KP_Subtract"] = VK_SUBTRACT;
- WinKeyMap()["KP_Decimal"] = VK_DECIMAL;
- WinKeyMap()["KP_Divide"] = VK_DIVIDE;
- WinKeyMap()["dead_grave"] = VK_OEM_3;
- WinKeyMap()["ISO_Level3_Shift"] = 0xE1;
-
- for (unsigned i = 0; i < 10; i++) {
- std::string key = "KP_" + std::to_string(i);
- WinKeyMap()[key] = VK_NUMPAD0 + i;
- }
-}
-
-static int KeyboardCodeFromEflKey(const char* key) {
-
- if (WinKeyMap().empty())
- PopulateWindowsKeyMap();
-
- std::string keyName(key);
- WindowsKeyMap::iterator it = WinKeyMap().find(keyName);
-
- if (it != WinKeyMap().end())
- return it->second;
-
- return 0;
-}
-
-static int WindowsKeyCodeFromEflKey(const char* key) {
- int windows_key_code = KeyboardCodeFromEflKey(key);
- if (windows_key_code == ui::VKEY_SHIFT ||
- windows_key_code == ui::VKEY_CONTROL ||
- windows_key_code == ui::VKEY_MENU) {
- // To support DOM3 'location' attribute, we need to lookup an X KeySym and
- // set ui::VKEY_[LR]XXX instead of ui::VKEY_XXX.
- KeySym keysym = XStringToKeysym(key);
- switch (keysym) {
- case XK_Shift_L:
- return ui::VKEY_LSHIFT;
- case XK_Shift_R:
- return ui::VKEY_RSHIFT;
- case XK_Control_L:
- return ui::VKEY_LCONTROL;
- case XK_Control_R:
- return ui::VKEY_RCONTROL;
- case XK_Meta_L:
- case XK_Alt_L:
- return ui::VKEY_LMENU;
- case XK_Meta_R:
- case XK_Alt_R:
- return ui::VKEY_RMENU;
- }
- }
- return windows_key_code;
-}
-
-static int NativeKeyCodeFromEflKey(const char* key) {
- //return ecore_x_keysym_keycode_get(ev->key);
- return XKeysymToKeycode((Display*)ecore_x_display_get(), XStringToKeysym(key));
-}
-
-// From
-// third_party/blink/Source/blink/chromium/src/gtk/WebInputEventFactory.cpp:
-static blink::WebUChar GetControlCharacter(int windows_key_code, bool shift) {
- if (windows_key_code >= ui::VKEY_A &&
- windows_key_code <= ui::VKEY_Z) {
- // ctrl-A ~ ctrl-Z map to \x01 ~ \x1A
- return windows_key_code - ui::VKEY_A + 1;
- }
- if (shift) {
- // following graphics chars require shift key to input.
- switch (windows_key_code) {
- // ctrl-@ maps to \x00 (Null byte)
- case ui::VKEY_2:
- return 0;
- // ctrl-^ maps to \x1E (Record separator, Information separator two)
- case ui::VKEY_6:
- return 0x1E;
- // ctrl-_ maps to \x1F (Unit separator, Information separator one)
- case ui::VKEY_OEM_MINUS:
- return 0x1F;
- // Returns 0 for all other keys to avoid inputting unexpected chars.
- default:
- break;
- }
- } else {
- switch (windows_key_code) {
- // ctrl-[ maps to \x1B (Escape)
- case ui::VKEY_OEM_4:
- return 0x1B;
- // ctrl-\ maps to \x1C (File separator, Information separator four)
- case ui::VKEY_OEM_5:
- return 0x1C;
- // ctrl-] maps to \x1D (Group separator, Information separator three)
- case ui::VKEY_OEM_6:
- return 0x1D;
- // ctrl-Enter maps to \x0A (Line feed)
- case ui::VKEY_RETURN:
- return 0x0A;
- // Returns 0 for all other keys to avoid inputting unexpected chars.
- default:
- break;
- }
- }
- return 0;
-}
-
-enum {
- LeftButton = 1,
- MiddleButton = 2,
- RightButton = 3
-};
-
-static WebMouseEvent::Button EvasToWebMouseButton(int button) {
- if (button == LeftButton)
- return WebMouseEvent::ButtonLeft;
- if (button == MiddleButton)
- return WebMouseEvent::ButtonMiddle;
- if (button == RightButton)
- return WebMouseEvent::ButtonRight;
-
- return WebMouseEvent::ButtonNone;
-}
-
-static WebInputEvent::Modifiers EvasToWebModifiers(const Evas_Modifier* modifiers) {
- unsigned result = 0;
-
- if (evas_key_modifier_is_set(modifiers, "Shift"))
- result |= WebInputEvent::ShiftKey;
- if (evas_key_modifier_is_set(modifiers, "Control"))
- result |= WebInputEvent::ControlKey;
- if (evas_key_modifier_is_set(modifiers, "Alt"))
- result |= WebInputEvent::AltKey;
- if (evas_key_modifier_is_set(modifiers, "Meta"))
- result |= WebInputEvent::MetaKey;
-
- return static_cast<WebInputEvent::Modifiers>(result);
-}
-
-blink::WebMouseEvent WebEventFactoryEfl::toWebMouseEvent(Evas* evas, Evas_Object* web_view, const Evas_Event_Mouse_Down* ev, float scale_factor) {
- WebMouseEvent webKitEvent;
- webKitEvent.timeStampSeconds = (double)ev->timestamp / 1000;
- webKitEvent.button = EvasToWebMouseButton(ev->button);
- webKitEvent.modifiers = EvasToWebModifiers(ev->modifiers);
-
- webKitEvent.windowX = (ev->canvas.x) / scale_factor;
- webKitEvent.windowY = (ev->canvas.y) / scale_factor;
-
- TranslateEvasCoordToWebKitCoord(web_view, webKitEvent.windowX, webKitEvent.windowY);
-
- webKitEvent.x = webKitEvent.windowX;
- webKitEvent.y = webKitEvent.windowY;
-
- webKitEvent.globalX = (evas_coord_world_x_to_screen(evas, ev->canvas.x)) / scale_factor;
- webKitEvent.globalY = (evas_coord_world_y_to_screen(evas, ev->canvas.y)) / scale_factor;
- webKitEvent.type = WebInputEvent::MouseDown;
-
- webKitEvent.clickCount = 1;
-
- return webKitEvent;
-}
-
-blink::WebMouseEvent WebEventFactoryEfl::toWebMouseEvent(Evas* evas, Evas_Object* web_view, const Evas_Event_Mouse_Up* ev, float scale_factor) {
- WebMouseEvent webKitEvent;
- webKitEvent.timeStampSeconds = (double)ev->timestamp / 1000;
- webKitEvent.button = EvasToWebMouseButton(ev->button);
- webKitEvent.modifiers = EvasToWebModifiers(ev->modifiers);
-
- webKitEvent.windowX = (ev->canvas.x) / scale_factor;
- webKitEvent.windowY = (ev->canvas.y) / scale_factor;
-
- TranslateEvasCoordToWebKitCoord(web_view, webKitEvent.windowX, webKitEvent.windowY);
-
- webKitEvent.x = webKitEvent.windowX;
- webKitEvent.y = webKitEvent.windowY;
-
- webKitEvent.globalX = (evas_coord_world_x_to_screen(evas, ev->canvas.x)) / scale_factor;
- webKitEvent.globalY = (evas_coord_world_y_to_screen(evas, ev->canvas.y)) / scale_factor;
- webKitEvent.type = WebInputEvent::MouseUp;
-
- webKitEvent.clickCount = 1;
-
- return webKitEvent;
-}
-
-blink::WebMouseEvent WebEventFactoryEfl::toWebMouseEvent(Evas* evas, Evas_Object* web_view, const Evas_Event_Mouse_Move* ev, float scale_factor) {
- WebMouseEvent webKitEvent;
- webKitEvent.timeStampSeconds = (double)ev->timestamp / 1000;
- webKitEvent.modifiers = EvasToWebModifiers(ev->modifiers);
-
- webKitEvent.windowX = (ev->cur.canvas.x) / scale_factor;
- webKitEvent.windowY = (ev->cur.canvas.y) / scale_factor;
-
- TranslateEvasCoordToWebKitCoord(web_view, webKitEvent.windowX, webKitEvent.windowY);
-
- webKitEvent.x = webKitEvent.windowX;
- webKitEvent.y = webKitEvent.windowY;
-
- webKitEvent.globalX = (evas_coord_world_x_to_screen(evas, ev->cur.canvas.x)) / scale_factor;
- webKitEvent.globalY = (evas_coord_world_y_to_screen(evas, ev->cur.canvas.y)) / scale_factor;
- webKitEvent.type = WebInputEvent::MouseMove;
-
- return webKitEvent;
-}
-
-blink::WebMouseWheelEvent WebEventFactoryEfl::toWebMouseEvent(Evas* evas, Evas_Object* web_view, const Evas_Event_Mouse_Wheel* ev, float scale_factor) {
- WebMouseWheelEvent webKitEvent;
- webKitEvent.timeStampSeconds = (double)ev->timestamp / 1000;
- webKitEvent.modifiers = EvasToWebModifiers(ev->modifiers);
-
- webKitEvent.windowX = (ev->canvas.x) / scale_factor;
- webKitEvent.windowY = (ev->canvas.y) / scale_factor;
-
- TranslateEvasCoordToWebKitCoord(web_view, webKitEvent.windowX, webKitEvent.windowY);
-
- webKitEvent.x = webKitEvent.windowX;
- webKitEvent.y = webKitEvent.windowY;
-
- webKitEvent.globalX = (evas_coord_world_x_to_screen(evas, ev->canvas.x)) / scale_factor;
- webKitEvent.globalY = (evas_coord_world_y_to_screen(evas, ev->canvas.y)) / scale_factor;
- webKitEvent.type = WebInputEvent::MouseWheel;
-
- if (ev->direction) {
- webKitEvent.wheelTicksX = ev->z;
- webKitEvent.deltaX = ev->z * cDefaultScrollStep;
- } else {
- webKitEvent.wheelTicksY = -(ev->z);
- webKitEvent.deltaY = -(ev->z * cDefaultScrollStep);
- }
-
- return webKitEvent;
-}
-
-static content::NativeWebKeyboardEvent WebKeyEvent(
- unsigned int timestamp, const Evas_Modifier* modifiers, const char* key,
- const char* string, bool pressed) {
- content::NativeWebKeyboardEvent webKitEvent;
- webKitEvent.timeStampSeconds = (double)timestamp / 1000;
- webKitEvent.modifiers = EvasToWebModifiers(modifiers);
- webKitEvent.type = pressed ? WebInputEvent::KeyDown : WebInputEvent::KeyUp;
-
- webKitEvent.nativeKeyCode = NativeKeyCodeFromEflKey(key);
- webKitEvent.windowsKeyCode = WindowsKeyCodeFromEflKey(key);
-
- if (webKitEvent.windowsKeyCode == ui::VKEY_RETURN) {
- memset(webKitEvent.unmodifiedText, 0,
- sizeof(webKitEvent.unmodifiedText));
- webKitEvent.unmodifiedText[0] = '\r';
- } else {
- if (string) {
- base::string16 utf16str = base::UTF8ToUTF16(string);
- size_t size = base::c16len(utf16str.data());
- base::c16memcpy(webKitEvent.unmodifiedText, utf16str.data(),
- std::min(size, NativeWebKeyboardEvent::textLengthCap));
- if (size > NativeWebKeyboardEvent::textLengthCap) {
- LOG(WARNING) << "Truncated value was copied into unmodifiedText field.";
- }
- } else {
- memset(webKitEvent.unmodifiedText, 0,
- sizeof(webKitEvent.unmodifiedText));
- }
- }
-
- if (webKitEvent.modifiers & blink::WebInputEvent::ControlKey) {
- webKitEvent.text[0] =
- GetControlCharacter(
- webKitEvent.windowsKeyCode,
- webKitEvent.modifiers & blink::WebInputEvent::ShiftKey);
- } else {
- memcpy(webKitEvent.text, webKitEvent.unmodifiedText,
- sizeof(webKitEvent.text));
- }
-
- webKitEvent.setKeyIdentifierFromWindowsKeyCode();
-
- return webKitEvent;
-}
-
-content::NativeWebKeyboardEvent WebEventFactoryEfl::toWebKeyboardEvent(Evas*,
- const Evas_Event_Key_Down* ev, const char* utf8) {
- return WebKeyEvent(ev->timestamp,
- ev->modifiers, ev->key, utf8 ? utf8 : ev->string, true);
-}
-
-content::NativeWebKeyboardEvent WebEventFactoryEfl::toWebKeyboardEvent(Evas*,
- const Evas_Event_Key_Up* ev) {
- return WebKeyEvent(ev->timestamp, ev->modifiers, ev->key, ev->string, false);
-}
-
-static ui::EventType EvasTouchEventTypeToUI(Evas_Touch_Point_State evas_touch) {
- switch (evas_touch) {
- case EVAS_TOUCH_POINT_DOWN:
- return ui::ET_TOUCH_PRESSED;
- case EVAS_TOUCH_POINT_MOVE:
- return ui::ET_TOUCH_MOVED;
- case EVAS_TOUCH_POINT_UP:
- return ui::ET_TOUCH_RELEASED;
- case EVAS_TOUCH_POINT_CANCEL:
- return ui::ET_TOUCH_CANCELLED;
- case EVAS_TOUCH_POINT_STILL:
- // Not handled by chromium, should not be passed here.
- default:
- NOTREACHED();
- return ui::ET_UNKNOWN;
- }
-}
-
-ui::TouchEvent WebEventFactoryEfl::toUITouchEvent(const tizen_webview::Touch_Point* p, Evas_Object* web_view, float scale_factor) {
- int x = p->x, y = p->y;
-
- TranslateEvasCoordToWebKitCoord(web_view, x, y);
- return ui::TouchEvent(EvasTouchEventTypeToUI(p->state),
- gfx::Point(x / scale_factor, y / scale_factor),
- p->id, base::TimeDelta::FromMilliseconds(ecore_time_get() * 1000));
-}
-
-bool WebEventFactoryEfl::isHardwareBackKey(const Evas_Event_Key_Down* event) {
-#if defined(OS_TIZEN)
- return (strcmp(event->key, "XF86Stop") == 0);
-#endif
- return (strcmp(event->key, "Escape") == 0);
-}
-
-}