return !strcmp(key, "Shift_L") || !strcmp(key, "Shift_R");
}
+class ScreenshotCapturedCallback {
+ public:
+ ScreenshotCapturedCallback(Screenshot_Captured_Callback func, void *user_data)
+ : func_(func), user_data_(user_data) {}
+ void Run(Evas_Object* image) {
+ if (func_ != NULL)
+ (func_)(image, user_data_);
+ }
+
+ private:
+ Screenshot_Captured_Callback func_;
+ void *user_data_;
+};
+
void RenderWidgetHostViewBase::GetDefaultScreenInfo(
blink::WebScreenInfo* results) {
const gfx::Display display = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay();
IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged, OnTextInputStateChanged)
IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputInFormStateChanged, OnTextInputInFormStateChanged)
IPC_MESSAGE_HANDLER(ViewHostMsg_HitTestAsyncReply, OnHitTestAsyncReply)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_SnapshotDataReceived, OnSnapshotDataReceived)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
params, request_id);
}
+void RenderWidgetHostViewEfl::OnSnapshotDataReceived(
+ SkBitmap bitmap,
+ int snapshotId) {
+ Evas_Object* image = NULL;
+ if (!bitmap.empty()) {
+ image = evas_object_image_filled_add(evas_);
+ evas_object_image_size_set(image, bitmap.width(), bitmap.height());
+ evas_object_image_data_copy_set(image, bitmap.getPixels());
+ }
+
+ ScreenshotCapturedCallback* callback = screen_capture_cb_map_.Lookup(snapshotId);
+ if (!callback) {
+ return;
+ }
+ callback->Run(image);
+ screen_capture_cb_map_.Remove(snapshotId);
+}
+
void RenderWidgetHostViewEfl::InitAsPopup(RenderWidgetHostView*, const gfx::Rect&) {
NOTIMPLEMENTED();
}
NOTIMPLEMENTED();
}
+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
+ // http://107.108.218.239/bugzilla/show_bug.cgi?id=9858
+ NOTIMPLEMENTED();
+ }
+}
+
+bool RenderWidgetHostViewEfl::RequestSnapshotAsync(const Eina_Rectangle rect,
+ Screenshot_Captured_Callback callback,
+ void* user_data) {
+ int width = rect.w;
+ int height = rect.h;
+ int x = rect.x;
+ int y = rect.y;
+
+ int device_x, device_y;
+ int view_x, view_y;
+
+ evas_object_geometry_get(smart_parent(),
+ &device_x,
+ &device_y,
+ NULL,
+ NULL);
+
+ if (width > device_x + GetViewBoundsInPix().width() - rect.x)
+ width = device_x + GetViewBoundsInPix().width() - rect.x;
+ if (height > device_y + GetViewBoundsInPix().height() - rect.y)
+ height = device_y + GetViewBoundsInPix().height() - rect.y;
+
+ EvasToBlinkCords(x, y, &view_x, &view_y);
+
+ width /= device_scale_factor_;
+ height /= device_scale_factor_;
+
+ ScreenshotCapturedCallback* cb =
+ new ScreenshotCapturedCallback(callback, user_data);
+
+ int cbId = screen_capture_cb_map_.Add(cb);
+
+ GetSnapshotAsync(gfx::Rect(view_x, view_y, width, height), cbId);
+ return true;
+}
+
// CopyFromCompositingSurfaceToVideoFrame implementation borrowed from Aura port
bool RenderWidgetHostViewEfl::CanSubscribeFrame() const {
return true;
#include "base/basictypes.h"
#include "base/format_macros.h"
+#include "base/id_map.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"
namespace content {
+typedef void (*Screenshot_Captured_Callback)(Evas_Object* image, void* user_data);
+
class DisambiguationPopupEfl;
class EdgeEffect;
class IMContextEfl;
class RenderWidgetHostView;
class ReadbackYUVInterface;
class WebContents;
+class ScreenshotCapturedCallback;
// RenderWidgetHostView class hierarchy described in render_widget_host_view.h.
class RenderWidgetHostViewEfl
bool IsIMEShow() const;
gfx::Rect GetIMERect() const;
void ExecuteEditCommand(const char* command, const char* value);
+ void GetSnapshotAsync(const gfx::Rect& snapshot_area, int request_id);
+ bool RequestSnapshotAsync(const Eina_Rectangle rect,
+ Screenshot_Captured_Callback callback,
+ void* user_data);
+ void OnSnapshotDataReceived(SkBitmap bitmap, int snapshotId);
protected:
friend class RenderWidgetHostView;
// is saved and restored when gesture will end.
scoped_ptr<bool> restore_showing_large_handle_on_gesture_end_;
+ IDMap<ScreenshotCapturedCallback, IDMapOwnPointer> screen_capture_cb_map_;
+
DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewEfl);
};
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
+ RenderWidgetHostViewEfl* rwhv =
+ static_cast<RenderWidgetHostViewEfl*>(web_contents_.GetRenderWidgetHostView());
+ if (rwhv)
+ rwhv->RequestSnapshotAsync(rect, MagnifierGetSnapshotCb, this);
}
void SelectionMagnifierEfl::Move(const gfx::Point& location) {
web_view_->DidChangePageScaleRange(min_scale, max_scale);
}
- void OnSnapshot(const std::vector<unsigned char> pixData, int snapshotId, const gfx::Size& size) {
- if (web_view_)
- web_view_->OnSnapshot(pixData, size.width(), size.height(), snapshotId);
- }
-
void OnDidChangeMaxScrollOffset(int maxScrollX, int maxScrollY) {
if (web_view_)
web_view_->GetScrollDetector()->SetMaxScroll(maxScrollX, maxScrollY);
WebViewBrowserMessageFilterPrivate::OnFormSubmit)
IPC_MESSAGE_FORWARD(ViewHostMsg_StartContentIntent, private_,
WebViewBrowserMessageFilterPrivate::OnStartContentIntent)
-#if defined(OS_TIZEN) && !defined(EWK_BRINGUP)
- IPC_MESSAGE_FORWARD(ViewHostMsg_SnapshotDataReceived, private_,
- WebViewBrowserMessageFilterPrivate::OnSnapshot)
-#endif
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
web_contents_->GetRenderViewHost()->SyncRendererPrefs();
}
-void EWebView::OnSnapshot(const std::vector<unsigned char>& pixData, int width, int height, int snapshotId) {
- WebAppScreenshotCapturedCallback* callback = screen_capture_cb_map_.Lookup(snapshotId);
- if (!callback) {
- return;
- }
-
- Evas_Object* image = evas_object_image_filled_add(rwhv()->evas());
- evas_object_image_size_set(image, width, height);
- evas_object_image_data_copy_set(image, const_cast<unsigned char*>(&pixData[0]));
-
- callback->Run(image);
- screen_capture_cb_map_.Remove(snapshotId);
-}
-
bool EWebView::GetSnapshotAsync(Eina_Rectangle rect,
- Evas* canvas,
Ewk_Web_App_Screenshot_Captured_Callback callback,
void* user_data) {
-#if defined(OS_TIZEN) && defined(EWK_REFACTOR)
if (!rwhv())
return false;
- int width = rect.w;
- int height = rect.h;
- int x = rect.x;
- int y = rect.y;
-
- int device_x, device_y;
- int view_x, view_y;
- evas_object_geometry_get(evas_object(),
- &device_x,
- &device_y,
- NULL,
- NULL);
-
- if (width > device_x + rwhv()->GetViewBoundsInPix().width() - rect.x)
- width = device_x + rwhv()->GetViewBoundsInPix().width() - rect.x;
- if (height > device_y + rwhv()->GetViewBoundsInPix().height() - rect.y)
- height = device_y + rwhv()->GetViewBoundsInPix().height() - rect.y;
-
- EvasToBlinkCords(x, y, &view_x, &view_y);
-
- width /= gfx::Screen::GetNativeScreen()->
- GetPrimaryDisplay().device_scale_factor();
- height /= gfx::Screen::GetNativeScreen()->
- GetPrimaryDisplay().device_scale_factor();
-
- WebAppScreenshotCapturedCallback* cb =
- new WebAppScreenshotCapturedCallback(callback, user_data, canvas);
-
- int cbId = screen_capture_cb_map_.Add(cb);
-
- rwhv()->GetSnapshotAsync(gfx::Rect(view_x, view_y, width, height), cbId);
- return true;
-#else
- NOTIMPLEMENTED();
- return false;
-#endif
+ return rwhv()->RequestSnapshotAsync(rect, callback, user_data);
}
void EWebView::GetSnapShotForRect(gfx::Rect& rect) {
class WebViewEvasEventHandler;
class _Ewk_Quota_Permission_Request;
-class WebAppScreenshotCapturedCallback : public base::RefCounted<WebAppScreenshotCapturedCallback> {
- public:
- WebAppScreenshotCapturedCallback(Ewk_Web_App_Screenshot_Captured_Callback func, void *user_data, Evas* canvas)
- : func_(func), user_data_(user_data), canvas_(canvas) {}
- void Run(Evas_Object* image) {
- if (func_ != NULL)
- (func_)(image, user_data_);
- }
-
- private:
- Ewk_Web_App_Screenshot_Captured_Callback func_;
- void *user_data_;
- Evas* canvas_;
-};
-
class EwkViewPlainTextGetCallback {
public:
EwkViewPlainTextGetCallback(Ewk_View_Plain_Text_Get_Callback callback,
*/
Evas_Object* GetSnapshot(Eina_Rectangle rect);
- bool GetSnapshotAsync(Eina_Rectangle rect, Evas* canvas, Ewk_Web_App_Screenshot_Captured_Callback callback, void* user_data);
+ bool GetSnapshotAsync(Eina_Rectangle rect, Ewk_Web_App_Screenshot_Captured_Callback callback, void* user_data);
void InvokePolicyResponseCallback(_Ewk_Policy_Decision* policy_decision);
void InvokePolicyNavigationCallback(content::RenderViewHost* rvh,
NavigationPolicyParams params, bool* handled);
void DismissColorPicker();
bool SetColorPickerColor(int r, int g, int b, int a);
void InputPickerShow(ui::TextInputType input_type, double input_value);
- void OnSnapshot(const std::vector<unsigned char>& pixData, int width, int height, int snapshotId);
void ShowContentsDetectedPopup(const char*);
IDMap<WebApplicationIconUrlGetCallback, IDMapOwnPointer> web_app_icon_url_get_callback_map_;
IDMap<WebApplicationIconUrlsGetCallback, IDMapOwnPointer> web_app_icon_urls_get_callback_map_;
IDMap<WebApplicationCapableGetCallback, IDMapOwnPointer> web_app_capable_get_callback_map_;
- IDMap< WebAppScreenshotCapturedCallback, IDMapOwnPointer> screen_capture_cb_map_;
scoped_ptr<NotificationPermissionCallback> notification_permission_callback_;
content::DevToolsDelegateEfl* inspector_server_;
scoped_ptr<ScrollDetector> scroll_detector_;
<< "Scaling option will be supported after hardware acceleration is enabled.";
return EINA_FALSE;
}
- return impl->GetSnapshotAsync(view_area, canvas, callback, user_data) ? EINA_TRUE : EINA_FALSE;
+ return impl->GetSnapshotAsync(view_area, callback, user_data) ? EINA_TRUE : EINA_FALSE;
}
unsigned int ewk_view_inspector_server_start(Evas_Object* ewkView, unsigned int port)