| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/render_widget.h" | 5 #include "content/renderer/render_widget.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1301 void RenderWidget::Close() { | 1301 void RenderWidget::Close() { |
| 1302 screen_metrics_emulator_.reset(); | 1302 screen_metrics_emulator_.reset(); |
| 1303 WillCloseLayerTreeView(); | 1303 WillCloseLayerTreeView(); |
| 1304 compositor_.reset(); | 1304 compositor_.reset(); |
| 1305 if (webwidget_) { | 1305 if (webwidget_) { |
| 1306 webwidget_->close(); | 1306 webwidget_->close(); |
| 1307 webwidget_ = nullptr; | 1307 webwidget_ = nullptr; |
| 1308 } | 1308 } |
| 1309 } | 1309 } |
| 1310 | 1310 |
| 1311 void RenderWidget::ScreenRectToEmulatedIfNeeded(WebRect* window_rect) const { |
| 1312 DCHECK(window_rect); |
| 1313 float scale = popup_origin_scale_for_emulation_; |
| 1314 if (!scale) |
| 1315 return; |
| 1316 window_rect->x = |
| 1317 popup_view_origin_for_emulation_.x() + |
| 1318 (window_rect->x - popup_screen_origin_for_emulation_.x()) / scale; |
| 1319 window_rect->y = |
| 1320 popup_view_origin_for_emulation_.y() + |
| 1321 (window_rect->y - popup_screen_origin_for_emulation_.y()) / scale; |
| 1322 } |
| 1323 |
| 1324 void RenderWidget::EmulatedToScreenRectIfNeeded(WebRect* window_rect) const { |
| 1325 DCHECK(window_rect); |
| 1326 float scale = popup_origin_scale_for_emulation_; |
| 1327 if (!scale) |
| 1328 return; |
| 1329 window_rect->x = |
| 1330 popup_screen_origin_for_emulation_.x() + |
| 1331 (window_rect->x - popup_view_origin_for_emulation_.x()) * scale; |
| 1332 window_rect->y = |
| 1333 popup_screen_origin_for_emulation_.y() + |
| 1334 (window_rect->y - popup_view_origin_for_emulation_.y()) * scale; |
| 1335 } |
| 1336 |
| 1311 WebRect RenderWidget::windowRect() { | 1337 WebRect RenderWidget::windowRect() { |
| 1338 WebRect rect; |
| 1312 if (pending_window_rect_count_) { | 1339 if (pending_window_rect_count_) { |
| 1313 // NOTE(mbelshe): If there is a pending_window_rect_, then getting | 1340 // NOTE(mbelshe): If there is a pending_window_rect_, then getting |
| 1314 // the RootWindowRect is probably going to return wrong results since the | 1341 // the RootWindowRect is probably going to return wrong results since the |
| 1315 // browser may not have processed the Move yet. There isn't really anything | 1342 // browser may not have processed the Move yet. There isn't really anything |
| 1316 // good to do in this case, and it shouldn't happen - since this size is | 1343 // good to do in this case, and it shouldn't happen - since this size is |
| 1317 // only really needed for windowToScreen, which is only used for Popups. | 1344 // only really needed for windowToScreen, which is only used for Popups. |
| 1318 return pending_window_rect_; | 1345 rect = pending_window_rect_; |
| 1346 } else { |
| 1347 rect = window_screen_rect_; |
| 1319 } | 1348 } |
| 1320 | 1349 |
| 1321 return window_screen_rect_; | 1350 ScreenRectToEmulatedIfNeeded(&rect); |
| 1351 return rect; |
| 1322 } | 1352 } |
| 1323 | 1353 |
| 1324 WebRect RenderWidget::viewRect() { | 1354 WebRect RenderWidget::viewRect() { |
| 1325 return view_screen_rect_; | 1355 WebRect rect = view_screen_rect_; |
| 1356 ScreenRectToEmulatedIfNeeded(&rect); |
| 1357 return rect; |
| 1326 } | 1358 } |
| 1327 | 1359 |
| 1328 void RenderWidget::setToolTipText(const blink::WebString& text, | 1360 void RenderWidget::setToolTipText(const blink::WebString& text, |
| 1329 WebTextDirection hint) { | 1361 WebTextDirection hint) { |
| 1330 Send(new ViewHostMsg_SetTooltipText(routing_id_, text, hint)); | 1362 Send(new ViewHostMsg_SetTooltipText(routing_id_, text, hint)); |
| 1331 } | 1363 } |
| 1332 | 1364 |
| 1333 void RenderWidget::setWindowRect(const WebRect& rect_in_screen) { | 1365 void RenderWidget::setWindowRect(const WebRect& rect_in_screen) { |
| 1334 WebRect window_rect = rect_in_screen; | 1366 WebRect window_rect = rect_in_screen; |
| 1335 if (popup_origin_scale_for_emulation_) { | 1367 EmulatedToScreenRectIfNeeded(&window_rect); |
| 1336 float scale = popup_origin_scale_for_emulation_; | |
| 1337 window_rect.x = popup_screen_origin_for_emulation_.x() + | |
| 1338 (window_rect.x - popup_view_origin_for_emulation_.x()) * scale; | |
| 1339 window_rect.y = popup_screen_origin_for_emulation_.y() + | |
| 1340 (window_rect.y - popup_view_origin_for_emulation_.y()) * scale; | |
| 1341 } | |
| 1342 | 1368 |
| 1343 if (!resizing_mode_selector_->is_synchronous_mode()) { | 1369 if (!resizing_mode_selector_->is_synchronous_mode()) { |
| 1344 if (did_show_) { | 1370 if (did_show_) { |
| 1345 Send(new ViewHostMsg_RequestMove(routing_id_, window_rect)); | 1371 Send(new ViewHostMsg_RequestMove(routing_id_, window_rect)); |
| 1346 SetPendingWindowRect(window_rect); | 1372 SetPendingWindowRect(window_rect); |
| 1347 } else { | 1373 } else { |
| 1348 initial_rect_ = window_rect; | 1374 initial_rect_ = window_rect; |
| 1349 } | 1375 } |
| 1350 } else { | 1376 } else { |
| 1351 SetWindowRectSynchronously(window_rect); | 1377 SetWindowRectSynchronously(window_rect); |
| (...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2100 void RenderWidget::requestPointerUnlock() { | 2126 void RenderWidget::requestPointerUnlock() { |
| 2101 mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get()); | 2127 mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get()); |
| 2102 } | 2128 } |
| 2103 | 2129 |
| 2104 bool RenderWidget::isPointerLocked() { | 2130 bool RenderWidget::isPointerLocked() { |
| 2105 return mouse_lock_dispatcher_->IsMouseLockedTo( | 2131 return mouse_lock_dispatcher_->IsMouseLockedTo( |
| 2106 webwidget_mouse_lock_target_.get()); | 2132 webwidget_mouse_lock_target_.get()); |
| 2107 } | 2133 } |
| 2108 | 2134 |
| 2109 } // namespace content | 2135 } // namespace content |
| OLD | NEW |