| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/devtools/render_widget_screen_metrics_emulator.h" | 5 #include "content/renderer/devtools/render_widget_screen_metrics_emulator.h" |
| 6 | 6 |
| 7 #include "content/common/resize_params.h" | 7 #include "content/common/resize_params.h" |
| 8 #include "content/public/common/context_menu_params.h" | 8 #include "content/public/common/context_menu_params.h" |
| 9 #include "content/renderer/devtools/render_widget_screen_metrics_emulator_delega
te.h" | 9 #include "content/renderer/devtools/render_widget_screen_metrics_emulator_delega
te.h" |
| 10 | 10 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 } | 132 } |
| 133 | 133 |
| 134 void RenderWidgetScreenMetricsEmulator::OnResize(const ResizeParams& params) { | 134 void RenderWidgetScreenMetricsEmulator::OnResize(const ResizeParams& params) { |
| 135 original_resize_params_ = params; | 135 original_resize_params_ = params; |
| 136 Apply(); | 136 Apply(); |
| 137 | 137 |
| 138 if (params.needs_resize_ack) | 138 if (params.needs_resize_ack) |
| 139 delegate_->Redraw(); | 139 delegate_->Redraw(); |
| 140 } | 140 } |
| 141 | 141 |
| 142 void RenderWidgetScreenMetricsEmulator::OnUpdateWindowScreenRect( |
| 143 const gfx::Rect& window_screen_rect) { |
| 144 original_window_screen_rect_ = window_screen_rect; |
| 145 if (emulation_params_.screenPosition == |
| 146 blink::WebDeviceEmulationParams::Desktop) |
| 147 Apply(); |
| 148 } |
| 149 |
| 142 void RenderWidgetScreenMetricsEmulator::OnUpdateScreenRects( | 150 void RenderWidgetScreenMetricsEmulator::OnUpdateScreenRects( |
| 143 const gfx::Rect& view_screen_rect, | 151 const gfx::Rect& view_screen_rect, |
| 144 const gfx::Rect& window_screen_rect) { | 152 const gfx::Rect& window_screen_rect) { |
| 145 original_view_screen_rect_ = view_screen_rect; | 153 original_view_screen_rect_ = view_screen_rect; |
| 146 original_window_screen_rect_ = window_screen_rect; | 154 original_window_screen_rect_ = window_screen_rect; |
| 147 if (emulation_params_.screenPosition == | 155 if (emulation_params_.screenPosition == |
| 148 blink::WebDeviceEmulationParams::Desktop) { | 156 blink::WebDeviceEmulationParams::Desktop) { |
| 149 Apply(); | 157 Apply(); |
| 150 } | 158 } |
| 151 } | 159 } |
| 152 | 160 |
| 153 void RenderWidgetScreenMetricsEmulator::OnShowContextMenu( | 161 void RenderWidgetScreenMetricsEmulator::OnShowContextMenu( |
| 154 ContextMenuParams* params) { | 162 ContextMenuParams* params) { |
| 155 params->x *= scale_; | 163 params->x *= scale_; |
| 156 params->x += offset_.x(); | 164 params->x += offset_.x(); |
| 157 params->y *= scale_; | 165 params->y *= scale_; |
| 158 params->y += offset_.y(); | 166 params->y += offset_.y(); |
| 159 } | 167 } |
| 160 | 168 |
| 161 gfx::Rect RenderWidgetScreenMetricsEmulator::AdjustValidationMessageAnchor( | 169 gfx::Rect RenderWidgetScreenMetricsEmulator::AdjustValidationMessageAnchor( |
| 162 const gfx::Rect& anchor) { | 170 const gfx::Rect& anchor) { |
| 163 gfx::Rect scaled = gfx::ScaleToEnclosedRect(anchor, scale_); | 171 gfx::Rect scaled = gfx::ScaleToEnclosedRect(anchor, scale_); |
| 164 scaled.set_x(scaled.x() + offset_.x()); | 172 scaled.set_x(scaled.x() + offset_.x()); |
| 165 scaled.set_y(scaled.y() + offset_.y()); | 173 scaled.set_y(scaled.y() + offset_.y()); |
| 166 return scaled; | 174 return scaled; |
| 167 } | 175 } |
| 168 | 176 |
| 169 } // namespace content | 177 } // namespace content |
| OLD | NEW |