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

Side by Side Diff: content/renderer/render_widget.cc

Issue 2394073002: RenderWidget::windowRect and viewRect should apply device emulation transform. (Closed)
Patch Set: Addressed comments Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « content/renderer/render_widget.h ('k') | content/renderer/render_widget_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 void RenderWidget::Close() { 1329 void RenderWidget::Close() {
1330 screen_metrics_emulator_.reset(); 1330 screen_metrics_emulator_.reset();
1331 WillCloseLayerTreeView(); 1331 WillCloseLayerTreeView();
1332 compositor_.reset(); 1332 compositor_.reset();
1333 if (webwidget_internal_) { 1333 if (webwidget_internal_) {
1334 webwidget_internal_->close(); 1334 webwidget_internal_->close();
1335 webwidget_internal_ = nullptr; 1335 webwidget_internal_ = nullptr;
1336 } 1336 }
1337 } 1337 }
1338 1338
1339 void RenderWidget::ScreenRectToEmulatedIfNeeded(WebRect* window_rect) const {
1340 DCHECK(window_rect);
1341 float scale = popup_origin_scale_for_emulation_;
1342 if (!scale)
1343 return;
1344 window_rect->x =
1345 popup_view_origin_for_emulation_.x() +
1346 (window_rect->x - popup_screen_origin_for_emulation_.x()) / scale;
1347 window_rect->y =
1348 popup_view_origin_for_emulation_.y() +
1349 (window_rect->y - popup_screen_origin_for_emulation_.y()) / scale;
1350 }
1351
1352 void RenderWidget::EmulatedToScreenRectIfNeeded(WebRect* window_rect) const {
1353 DCHECK(window_rect);
1354 float scale = popup_origin_scale_for_emulation_;
1355 if (!scale)
1356 return;
1357 window_rect->x =
1358 popup_screen_origin_for_emulation_.x() +
1359 (window_rect->x - popup_view_origin_for_emulation_.x()) * scale;
1360 window_rect->y =
1361 popup_screen_origin_for_emulation_.y() +
1362 (window_rect->y - popup_view_origin_for_emulation_.y()) * scale;
1363 }
1364
1339 WebRect RenderWidget::windowRect() { 1365 WebRect RenderWidget::windowRect() {
1366 WebRect rect;
1340 if (pending_window_rect_count_) { 1367 if (pending_window_rect_count_) {
1341 // NOTE(mbelshe): If there is a pending_window_rect_, then getting 1368 // NOTE(mbelshe): If there is a pending_window_rect_, then getting
1342 // the RootWindowRect is probably going to return wrong results since the 1369 // the RootWindowRect is probably going to return wrong results since the
1343 // browser may not have processed the Move yet. There isn't really anything 1370 // browser may not have processed the Move yet. There isn't really anything
1344 // good to do in this case, and it shouldn't happen - since this size is 1371 // good to do in this case, and it shouldn't happen - since this size is
1345 // only really needed for windowToScreen, which is only used for Popups. 1372 // only really needed for windowToScreen, which is only used for Popups.
1346 return pending_window_rect_; 1373 rect = pending_window_rect_;
1374 } else {
1375 rect = window_screen_rect_;
1347 } 1376 }
1348 1377
1349 return window_screen_rect_; 1378 ScreenRectToEmulatedIfNeeded(&rect);
1379 return rect;
1350 } 1380 }
1351 1381
1352 WebRect RenderWidget::viewRect() { 1382 WebRect RenderWidget::viewRect() {
1353 return view_screen_rect_; 1383 WebRect rect = view_screen_rect_;
1384 ScreenRectToEmulatedIfNeeded(&rect);
1385 return rect;
1354 } 1386 }
1355 1387
1356 void RenderWidget::setToolTipText(const blink::WebString& text, 1388 void RenderWidget::setToolTipText(const blink::WebString& text,
1357 WebTextDirection hint) { 1389 WebTextDirection hint) {
1358 Send(new ViewHostMsg_SetTooltipText(routing_id_, text, hint)); 1390 Send(new ViewHostMsg_SetTooltipText(routing_id_, text, hint));
1359 } 1391 }
1360 1392
1361 void RenderWidget::setWindowRect(const WebRect& rect_in_screen) { 1393 void RenderWidget::setWindowRect(const WebRect& rect_in_screen) {
1362 WebRect window_rect = rect_in_screen; 1394 WebRect window_rect = rect_in_screen;
1363 if (popup_origin_scale_for_emulation_) { 1395 EmulatedToScreenRectIfNeeded(&window_rect);
1364 float scale = popup_origin_scale_for_emulation_;
1365 window_rect.x = popup_screen_origin_for_emulation_.x() +
1366 (window_rect.x - popup_view_origin_for_emulation_.x()) * scale;
1367 window_rect.y = popup_screen_origin_for_emulation_.y() +
1368 (window_rect.y - popup_view_origin_for_emulation_.y()) * scale;
1369 }
1370 1396
1371 if (!resizing_mode_selector_->is_synchronous_mode()) { 1397 if (!resizing_mode_selector_->is_synchronous_mode()) {
1372 if (did_show_) { 1398 if (did_show_) {
1373 Send(new ViewHostMsg_RequestMove(routing_id_, window_rect)); 1399 Send(new ViewHostMsg_RequestMove(routing_id_, window_rect));
1374 SetPendingWindowRect(window_rect); 1400 SetPendingWindowRect(window_rect);
1375 } else { 1401 } else {
1376 initial_rect_ = window_rect; 1402 initial_rect_ = window_rect;
1377 } 1403 }
1378 } else { 1404 } else {
1379 SetWindowRectSynchronously(window_rect); 1405 SetWindowRectSynchronously(window_rect);
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
2167 bool RenderWidget::isPointerLocked() { 2193 bool RenderWidget::isPointerLocked() {
2168 return mouse_lock_dispatcher_->IsMouseLockedTo( 2194 return mouse_lock_dispatcher_->IsMouseLockedTo(
2169 webwidget_mouse_lock_target_.get()); 2195 webwidget_mouse_lock_target_.get());
2170 } 2196 }
2171 2197
2172 blink::WebWidget* RenderWidget::GetWebWidget() const { 2198 blink::WebWidget* RenderWidget::GetWebWidget() const {
2173 return webwidget_internal_; 2199 return webwidget_internal_;
2174 } 2200 }
2175 2201
2176 } // namespace content 2202 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_widget.h ('k') | content/renderer/render_widget_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698