| 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 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 std::unique_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor( | 657 std::unique_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor( |
| 658 compositor_->CreateLatencyInfoSwapPromiseMonitor(&swap_latency_info)); | 658 compositor_->CreateLatencyInfoSwapPromiseMonitor(&swap_latency_info)); |
| 659 compositor_->SetNeedsForcedRedraw(); | 659 compositor_->SetNeedsForcedRedraw(); |
| 660 } | 660 } |
| 661 ScheduleComposite(); | 661 ScheduleComposite(); |
| 662 } | 662 } |
| 663 | 663 |
| 664 void RenderWidget::OnRequestMoveAck() { | 664 void RenderWidget::OnRequestMoveAck() { |
| 665 DCHECK(pending_window_rect_count_); | 665 DCHECK(pending_window_rect_count_); |
| 666 pending_window_rect_count_--; | 666 pending_window_rect_count_--; |
| 667 if (!pending_window_rect_count_) | |
| 668 view_screen_rect_ = pending_window_rect_; | |
| 669 } | 667 } |
| 670 | 668 |
| 671 GURL RenderWidget::GetURLForGraphicsContext3D() { | 669 GURL RenderWidget::GetURLForGraphicsContext3D() { |
| 672 return GURL(); | 670 return GURL(); |
| 673 } | 671 } |
| 674 | 672 |
| 675 void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event, | 673 void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event, |
| 676 const ui::LatencyInfo& latency_info, | 674 const ui::LatencyInfo& latency_info, |
| 677 InputEventDispatchType dispatch_type) { | 675 InputEventDispatchType dispatch_type) { |
| 678 if (!input_event) | 676 if (!input_event) |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1304 screen_metrics_emulator_.reset(); | 1302 screen_metrics_emulator_.reset(); |
| 1305 WillCloseLayerTreeView(); | 1303 WillCloseLayerTreeView(); |
| 1306 compositor_.reset(); | 1304 compositor_.reset(); |
| 1307 if (webwidget_) { | 1305 if (webwidget_) { |
| 1308 webwidget_->close(); | 1306 webwidget_->close(); |
| 1309 webwidget_ = nullptr; | 1307 webwidget_ = nullptr; |
| 1310 } | 1308 } |
| 1311 } | 1309 } |
| 1312 | 1310 |
| 1313 WebRect RenderWidget::windowRect() { | 1311 WebRect RenderWidget::windowRect() { |
| 1314 if (pending_window_rect_count_) | 1312 if (pending_window_rect_count_) { |
| 1313 // NOTE(mbelshe): If there is a pending_window_rect_, then getting |
| 1314 // 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 |
| 1316 // 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. |
| 1315 return pending_window_rect_; | 1318 return pending_window_rect_; |
| 1319 } |
| 1316 | 1320 |
| 1317 return view_screen_rect_; | 1321 return window_screen_rect_; |
| 1322 } |
| 1323 |
| 1324 WebRect RenderWidget::viewRect() { |
| 1325 return view_screen_rect_; |
| 1318 } | 1326 } |
| 1319 | 1327 |
| 1320 void RenderWidget::setToolTipText(const blink::WebString& text, | 1328 void RenderWidget::setToolTipText(const blink::WebString& text, |
| 1321 WebTextDirection hint) { | 1329 WebTextDirection hint) { |
| 1322 Send(new ViewHostMsg_SetTooltipText(routing_id_, text, hint)); | 1330 Send(new ViewHostMsg_SetTooltipText(routing_id_, text, hint)); |
| 1323 } | 1331 } |
| 1324 | 1332 |
| 1325 void RenderWidget::setWindowRect(const WebRect& rect_in_screen) { | 1333 void RenderWidget::setWindowRect(const WebRect& rect_in_screen) { |
| 1326 WebRect window_rect = rect_in_screen; | 1334 WebRect window_rect = rect_in_screen; |
| 1327 if (popup_origin_scale_for_emulation_) { | 1335 if (popup_origin_scale_for_emulation_) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1340 initial_rect_ = window_rect; | 1348 initial_rect_ = window_rect; |
| 1341 } | 1349 } |
| 1342 } else { | 1350 } else { |
| 1343 SetWindowRectSynchronously(window_rect); | 1351 SetWindowRectSynchronously(window_rect); |
| 1344 } | 1352 } |
| 1345 } | 1353 } |
| 1346 | 1354 |
| 1347 void RenderWidget::SetPendingWindowRect(const WebRect& rect) { | 1355 void RenderWidget::SetPendingWindowRect(const WebRect& rect) { |
| 1348 pending_window_rect_ = rect; | 1356 pending_window_rect_ = rect; |
| 1349 pending_window_rect_count_++; | 1357 pending_window_rect_count_++; |
| 1350 } | |
| 1351 | 1358 |
| 1352 gfx::Rect RenderWidget::RootWindowRect() { | 1359 // Popups don't get size updates back from the browser so just store the set |
| 1353 if (pending_window_rect_count_) { | 1360 // values. |
| 1354 // NOTE(mbelshe): If there is a pending_window_rect_, then getting | 1361 if (popup_type_ != blink::WebPopupTypeNone) { |
| 1355 // the RootWindowRect is probably going to return wrong results since the | 1362 window_screen_rect_ = rect; |
| 1356 // browser may not have processed the Move yet. There isn't really anything | 1363 view_screen_rect_ = rect; |
| 1357 // good to do in this case, and it shouldn't happen - since this size is | |
| 1358 // only really needed for windowToScreen, which is only used for Popups. | |
| 1359 return pending_window_rect_; | |
| 1360 } | 1364 } |
| 1361 | |
| 1362 return window_screen_rect_; | |
| 1363 } | 1365 } |
| 1364 | 1366 |
| 1365 WebRect RenderWidget::windowResizerRect() { | 1367 WebRect RenderWidget::windowResizerRect() { |
| 1366 return resizer_rect_; | 1368 return resizer_rect_; |
| 1367 } | 1369 } |
| 1368 | 1370 |
| 1369 void RenderWidget::OnImeSetComposition( | 1371 void RenderWidget::OnImeSetComposition( |
| 1370 const base::string16& text, | 1372 const base::string16& text, |
| 1371 const std::vector<WebCompositionUnderline>& underlines, | 1373 const std::vector<WebCompositionUnderline>& underlines, |
| 1372 const gfx::Range& replacement_range, | 1374 const gfx::Range& replacement_range, |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1470 screen_metrics_emulator_->OnUpdateScreenRects(view_screen_rect, | 1472 screen_metrics_emulator_->OnUpdateScreenRects(view_screen_rect, |
| 1471 window_screen_rect); | 1473 window_screen_rect); |
| 1472 } else { | 1474 } else { |
| 1473 SetScreenRects(view_screen_rect, window_screen_rect); | 1475 SetScreenRects(view_screen_rect, window_screen_rect); |
| 1474 } | 1476 } |
| 1475 Send(new ViewHostMsg_UpdateScreenRects_ACK(routing_id())); | 1477 Send(new ViewHostMsg_UpdateScreenRects_ACK(routing_id())); |
| 1476 } | 1478 } |
| 1477 | 1479 |
| 1478 void RenderWidget::OnUpdateWindowScreenRect( | 1480 void RenderWidget::OnUpdateWindowScreenRect( |
| 1479 const gfx::Rect& window_screen_rect) { | 1481 const gfx::Rect& window_screen_rect) { |
| 1480 if (screen_metrics_emulator_) { | 1482 if (screen_metrics_emulator_) |
| 1481 screen_metrics_emulator_->OnUpdateWindowScreenRect(window_screen_rect); | 1483 screen_metrics_emulator_->OnUpdateWindowScreenRect(window_screen_rect); |
| 1482 } else { | 1484 else |
| 1483 window_screen_rect_ = window_screen_rect; | 1485 window_screen_rect_ = window_screen_rect; |
| 1484 } | |
| 1485 } | 1486 } |
| 1486 | 1487 |
| 1487 void RenderWidget::OnSetSurfaceClientId(uint32_t surface_id_namespace) { | 1488 void RenderWidget::OnSetSurfaceClientId(uint32_t surface_id_namespace) { |
| 1488 if (compositor_) | 1489 if (compositor_) |
| 1489 compositor_->SetSurfaceClientId(surface_id_namespace); | 1490 compositor_->SetSurfaceClientId(surface_id_namespace); |
| 1490 } | 1491 } |
| 1491 | 1492 |
| 1492 void RenderWidget::OnHandleCompositorProto(const std::vector<uint8_t>& proto) { | 1493 void RenderWidget::OnHandleCompositorProto(const std::vector<uint8_t>& proto) { |
| 1493 if (compositor_) | 1494 if (compositor_) |
| 1494 compositor_->OnHandleCompositorProto(proto); | 1495 compositor_->OnHandleCompositorProto(proto); |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1808 } | 1809 } |
| 1809 | 1810 |
| 1810 void RenderWidget::DidAutoResize(const gfx::Size& new_size) { | 1811 void RenderWidget::DidAutoResize(const gfx::Size& new_size) { |
| 1811 WebRect new_size_in_window(0, 0, new_size.width(), new_size.height()); | 1812 WebRect new_size_in_window(0, 0, new_size.width(), new_size.height()); |
| 1812 convertViewportToWindow(&new_size_in_window); | 1813 convertViewportToWindow(&new_size_in_window); |
| 1813 if (size_.width() != new_size_in_window.width || | 1814 if (size_.width() != new_size_in_window.width || |
| 1814 size_.height() != new_size_in_window.height) { | 1815 size_.height() != new_size_in_window.height) { |
| 1815 size_ = gfx::Size(new_size_in_window.width, new_size_in_window.height); | 1816 size_ = gfx::Size(new_size_in_window.width, new_size_in_window.height); |
| 1816 | 1817 |
| 1817 if (resizing_mode_selector_->is_synchronous_mode()) { | 1818 if (resizing_mode_selector_->is_synchronous_mode()) { |
| 1818 gfx::Rect new_pos(RootWindowRect().x(), RootWindowRect().y(), | 1819 gfx::Rect new_pos(windowRect().x, windowRect().y, |
| 1819 size_.width(), size_.height()); | 1820 size_.width(), size_.height()); |
| 1820 view_screen_rect_ = new_pos; | 1821 view_screen_rect_ = new_pos; |
| 1821 window_screen_rect_ = new_pos; | 1822 window_screen_rect_ = new_pos; |
| 1822 } | 1823 } |
| 1823 | 1824 |
| 1824 AutoResizeCompositor(); | 1825 AutoResizeCompositor(); |
| 1825 | 1826 |
| 1826 if (!resizing_mode_selector_->is_synchronous_mode()) | 1827 if (!resizing_mode_selector_->is_synchronous_mode()) |
| 1827 need_update_rect_for_auto_resize_ = true; | 1828 need_update_rect_for_auto_resize_ = true; |
| 1828 } | 1829 } |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2099 void RenderWidget::requestPointerUnlock() { | 2100 void RenderWidget::requestPointerUnlock() { |
| 2100 mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get()); | 2101 mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get()); |
| 2101 } | 2102 } |
| 2102 | 2103 |
| 2103 bool RenderWidget::isPointerLocked() { | 2104 bool RenderWidget::isPointerLocked() { |
| 2104 return mouse_lock_dispatcher_->IsMouseLockedTo( | 2105 return mouse_lock_dispatcher_->IsMouseLockedTo( |
| 2105 webwidget_mouse_lock_target_.get()); | 2106 webwidget_mouse_lock_target_.get()); |
| 2106 } | 2107 } |
| 2107 | 2108 |
| 2108 } // namespace content | 2109 } // namespace content |
| OLD | NEW |