Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(397)

Unified Diff: content/renderer/render_widget.h

Issue 23364004: Implementation of device metrics emulation in render view. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/render_widget.h
===================================================================
--- content/renderer/render_widget.h (revision 217537)
+++ content/renderer/render_widget.h (working copy)
@@ -54,6 +54,7 @@
class WebKeyboardEvent;
class WebMouseEvent;
class WebTouchEvent;
+class WebTouchPoint;
struct WebPoint;
struct WebRenderingStatsImpl;
}
@@ -281,6 +282,14 @@
bool is_fullscreen,
ResizeAck resize_ack);
+ // Emulates device and widget metrics. Supplied values override everything
+ // coming from host.
+ void EmulateDevice(bool enabled,
+ const gfx::Size& device_size,
+ const gfx::Rect& widget_rect,
+ float device_scale_factor,
+ bool fit_to_view);
+
// RenderWidget IPC message handlers
void OnHandleInputEvent(const WebKit::WebInputEvent* event,
const ui::LatencyInfo& latency_info,
@@ -295,6 +304,7 @@
virtual void OnWasHidden();
virtual void OnWasShown(bool needs_repainting);
virtual void OnWasSwappedOut();
+ void OnEmulateDeviceAck(bool enabled);
void OnUpdateRectAck();
void OnCreateVideoAck(int32 video_id);
void OnUpdateVideoAck(int32 video_id);
@@ -735,6 +745,65 @@
int outstanding_ime_acks_;
#endif
+ // Helper class which is managing device emulation.
+ // TODO(dgozman): fit to view is not supported yet.
+ class DeviceEmulationHelper {
jam 2013/09/11 02:59:47 nit: since this is a private class, just forward d
dgozman 2013/09/13 11:32:36 Unfortunately, this class is also used by RenderVi
+ public:
+ DeviceEmulationHelper(const gfx::Size& device_size,
+ const gfx::Rect& widget_rect,
+ float device_scale_factor,
+ bool fit_to_view);
+ virtual ~DeviceEmulationHelper();
+
+ void BeginEmulation(RenderWidget* widget);
+ void ChangeEmulationParams(RenderWidget* widget,
+ DeviceEmulationHelper* params);
+ void EndEmulation(RenderWidget* widget);
+
+ void OnResizeMessage(RenderWidget* widget,
+ const ViewMsg_Resize_Params& params);
+ void OnUpdateScreenRectsMessage(RenderWidget* widget,
+ const gfx::Rect view_screen_rect,
+ const gfx::Rect window_screen_rect);
+ WebKit::WebInputEvent* ConvertInputEventToEmulated(
+ RenderWidget* widget, const WebKit::WebInputEvent* event);
+
+ void PopupCreated(RenderWidget* widget, RenderWidget* popup);
+ WebKit::WebRect ConvertPopupScreenRectFromEmulated(
+ RenderWidget* popup, const WebKit::WebRect& rect);
+
+ private:
+ void Apply(RenderWidget* widget, float overdraw_bottom_height,
+ gfx::Rect resizer_rect, bool is_fullscreen);
+ void ConvertMouseEventToEmulated(WebKit::WebMouseEvent* event);
+ void ConvertTouchPointToEmulated(WebKit::WebTouchPoint* point);
+
+ gfx::Size device_size_;
+ gfx::Rect widget_rect_;
+ float device_scale_factor_;
+ bool fit_to_view_;
+
+ gfx::Size original_size_;
+ gfx::Size original_physical_backing_size_;
+ WebKit::WebScreenInfo original_screen_info_;
+ gfx::Rect original_view_screen_rect_;
+ gfx::Rect original_window_screen_rect_;
+
+ base::WeakPtrFactory<DeviceEmulationHelper> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(DeviceEmulationHelper);
+ };
+
+ scoped_ptr<DeviceEmulationHelper> device_emulation_helper_;
+
+ // Popup has a weak ptr to the device emulation helper of creator.
+ base::WeakPtr<DeviceEmulationHelper> popup_device_emulation_helper_;
+
+ // While we send ViewMsg_EmulateDevice to the host, these store the requested
+ // emulation parameters.
+ scoped_ptr<DeviceEmulationHelper> pending_device_emulation_helper_;
+ bool pending_device_emulation_enabled_;
+
base::WeakPtrFactory<RenderWidget> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(RenderWidget);

Powered by Google App Engine
This is Rietveld 408576698