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 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 std::unique_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor( | 682 std::unique_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor( |
683 compositor_->CreateLatencyInfoSwapPromiseMonitor(&swap_latency_info)); | 683 compositor_->CreateLatencyInfoSwapPromiseMonitor(&swap_latency_info)); |
684 compositor_->SetNeedsForcedRedraw(); | 684 compositor_->SetNeedsForcedRedraw(); |
685 } | 685 } |
686 ScheduleComposite(); | 686 ScheduleComposite(); |
687 } | 687 } |
688 | 688 |
689 void RenderWidget::OnRequestMoveAck() { | 689 void RenderWidget::OnRequestMoveAck() { |
690 DCHECK(pending_window_rect_count_); | 690 DCHECK(pending_window_rect_count_); |
691 pending_window_rect_count_--; | 691 pending_window_rect_count_--; |
692 if (!pending_window_rect_count_) | |
693 view_screen_rect_ = pending_window_rect_; | |
694 } | 692 } |
695 | 693 |
696 GURL RenderWidget::GetURLForGraphicsContext3D() { | 694 GURL RenderWidget::GetURLForGraphicsContext3D() { |
697 return GURL(); | 695 return GURL(); |
698 } | 696 } |
699 | 697 |
700 void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event, | 698 void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event, |
701 const ui::LatencyInfo& latency_info, | 699 const ui::LatencyInfo& latency_info, |
702 InputEventDispatchType dispatch_type) { | 700 InputEventDispatchType dispatch_type) { |
703 if (!input_event) | 701 if (!input_event) |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1332 screen_metrics_emulator_.reset(); | 1330 screen_metrics_emulator_.reset(); |
1333 WillCloseLayerTreeView(); | 1331 WillCloseLayerTreeView(); |
1334 compositor_.reset(); | 1332 compositor_.reset(); |
1335 if (webwidget_internal_) { | 1333 if (webwidget_internal_) { |
1336 webwidget_internal_->close(); | 1334 webwidget_internal_->close(); |
1337 webwidget_internal_ = nullptr; | 1335 webwidget_internal_ = nullptr; |
1338 } | 1336 } |
1339 } | 1337 } |
1340 | 1338 |
1341 WebRect RenderWidget::windowRect() { | 1339 WebRect RenderWidget::windowRect() { |
1342 if (pending_window_rect_count_) | 1340 if (pending_window_rect_count_) { |
| 1341 // NOTE(mbelshe): If there is a pending_window_rect_, then getting |
| 1342 // 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 |
| 1344 // 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. |
1343 return pending_window_rect_; | 1346 return pending_window_rect_; |
| 1347 } |
1344 | 1348 |
1345 return view_screen_rect_; | 1349 return window_screen_rect_; |
| 1350 } |
| 1351 |
| 1352 WebRect RenderWidget::viewRect() { |
| 1353 return view_screen_rect_; |
1346 } | 1354 } |
1347 | 1355 |
1348 void RenderWidget::setToolTipText(const blink::WebString& text, | 1356 void RenderWidget::setToolTipText(const blink::WebString& text, |
1349 WebTextDirection hint) { | 1357 WebTextDirection hint) { |
1350 Send(new ViewHostMsg_SetTooltipText(routing_id_, text, hint)); | 1358 Send(new ViewHostMsg_SetTooltipText(routing_id_, text, hint)); |
1351 } | 1359 } |
1352 | 1360 |
1353 void RenderWidget::setWindowRect(const WebRect& rect_in_screen) { | 1361 void RenderWidget::setWindowRect(const WebRect& rect_in_screen) { |
1354 WebRect window_rect = rect_in_screen; | 1362 WebRect window_rect = rect_in_screen; |
1355 if (popup_origin_scale_for_emulation_) { | 1363 if (popup_origin_scale_for_emulation_) { |
(...skipping 12 matching lines...) Expand all Loading... |
1368 initial_rect_ = window_rect; | 1376 initial_rect_ = window_rect; |
1369 } | 1377 } |
1370 } else { | 1378 } else { |
1371 SetWindowRectSynchronously(window_rect); | 1379 SetWindowRectSynchronously(window_rect); |
1372 } | 1380 } |
1373 } | 1381 } |
1374 | 1382 |
1375 void RenderWidget::SetPendingWindowRect(const WebRect& rect) { | 1383 void RenderWidget::SetPendingWindowRect(const WebRect& rect) { |
1376 pending_window_rect_ = rect; | 1384 pending_window_rect_ = rect; |
1377 pending_window_rect_count_++; | 1385 pending_window_rect_count_++; |
1378 } | |
1379 | 1386 |
1380 gfx::Rect RenderWidget::RootWindowRect() { | 1387 // Popups don't get size updates back from the browser so just store the set |
1381 if (pending_window_rect_count_) { | 1388 // values. |
1382 // NOTE(mbelshe): If there is a pending_window_rect_, then getting | 1389 if (popup_type_ != blink::WebPopupTypeNone) { |
1383 // the RootWindowRect is probably going to return wrong results since the | 1390 window_screen_rect_ = rect; |
1384 // browser may not have processed the Move yet. There isn't really anything | 1391 view_screen_rect_ = rect; |
1385 // good to do in this case, and it shouldn't happen - since this size is | |
1386 // only really needed for windowToScreen, which is only used for Popups. | |
1387 return pending_window_rect_; | |
1388 } | 1392 } |
1389 | |
1390 return window_screen_rect_; | |
1391 } | 1393 } |
1392 | 1394 |
1393 WebRect RenderWidget::windowResizerRect() { | 1395 WebRect RenderWidget::windowResizerRect() { |
1394 return resizer_rect_; | 1396 return resizer_rect_; |
1395 } | 1397 } |
1396 | 1398 |
1397 void RenderWidget::OnImeSetComposition( | 1399 void RenderWidget::OnImeSetComposition( |
1398 const base::string16& text, | 1400 const base::string16& text, |
1399 const std::vector<WebCompositionUnderline>& underlines, | 1401 const std::vector<WebCompositionUnderline>& underlines, |
1400 const gfx::Range& replacement_range, | 1402 const gfx::Range& replacement_range, |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1513 screen_metrics_emulator_->OnUpdateScreenRects(view_screen_rect, | 1515 screen_metrics_emulator_->OnUpdateScreenRects(view_screen_rect, |
1514 window_screen_rect); | 1516 window_screen_rect); |
1515 } else { | 1517 } else { |
1516 SetScreenRects(view_screen_rect, window_screen_rect); | 1518 SetScreenRects(view_screen_rect, window_screen_rect); |
1517 } | 1519 } |
1518 Send(new ViewHostMsg_UpdateScreenRects_ACK(routing_id())); | 1520 Send(new ViewHostMsg_UpdateScreenRects_ACK(routing_id())); |
1519 } | 1521 } |
1520 | 1522 |
1521 void RenderWidget::OnUpdateWindowScreenRect( | 1523 void RenderWidget::OnUpdateWindowScreenRect( |
1522 const gfx::Rect& window_screen_rect) { | 1524 const gfx::Rect& window_screen_rect) { |
1523 if (screen_metrics_emulator_) { | 1525 if (screen_metrics_emulator_) |
1524 screen_metrics_emulator_->OnUpdateWindowScreenRect(window_screen_rect); | 1526 screen_metrics_emulator_->OnUpdateWindowScreenRect(window_screen_rect); |
1525 } else { | 1527 else |
1526 window_screen_rect_ = window_screen_rect; | 1528 window_screen_rect_ = window_screen_rect; |
1527 } | |
1528 } | 1529 } |
1529 | 1530 |
1530 void RenderWidget::OnSetFrameSinkId(const cc::FrameSinkId& frame_sink_id) { | 1531 void RenderWidget::OnSetFrameSinkId(const cc::FrameSinkId& frame_sink_id) { |
1531 if (compositor_) | 1532 if (compositor_) |
1532 compositor_->SetFrameSinkId(frame_sink_id); | 1533 compositor_->SetFrameSinkId(frame_sink_id); |
1533 } | 1534 } |
1534 | 1535 |
1535 void RenderWidget::OnHandleCompositorProto(const std::vector<uint8_t>& proto) { | 1536 void RenderWidget::OnHandleCompositorProto(const std::vector<uint8_t>& proto) { |
1536 if (compositor_) | 1537 if (compositor_) |
1537 compositor_->OnHandleCompositorProto(proto); | 1538 compositor_->OnHandleCompositorProto(proto); |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1852 } | 1853 } |
1853 | 1854 |
1854 void RenderWidget::DidAutoResize(const gfx::Size& new_size) { | 1855 void RenderWidget::DidAutoResize(const gfx::Size& new_size) { |
1855 WebRect new_size_in_window(0, 0, new_size.width(), new_size.height()); | 1856 WebRect new_size_in_window(0, 0, new_size.width(), new_size.height()); |
1856 convertViewportToWindow(&new_size_in_window); | 1857 convertViewportToWindow(&new_size_in_window); |
1857 if (size_.width() != new_size_in_window.width || | 1858 if (size_.width() != new_size_in_window.width || |
1858 size_.height() != new_size_in_window.height) { | 1859 size_.height() != new_size_in_window.height) { |
1859 size_ = gfx::Size(new_size_in_window.width, new_size_in_window.height); | 1860 size_ = gfx::Size(new_size_in_window.width, new_size_in_window.height); |
1860 | 1861 |
1861 if (resizing_mode_selector_->is_synchronous_mode()) { | 1862 if (resizing_mode_selector_->is_synchronous_mode()) { |
1862 gfx::Rect new_pos(RootWindowRect().x(), RootWindowRect().y(), | 1863 gfx::Rect new_pos(windowRect().x, windowRect().y, |
1863 size_.width(), size_.height()); | 1864 size_.width(), size_.height()); |
1864 view_screen_rect_ = new_pos; | 1865 view_screen_rect_ = new_pos; |
1865 window_screen_rect_ = new_pos; | 1866 window_screen_rect_ = new_pos; |
1866 } | 1867 } |
1867 | 1868 |
1868 AutoResizeCompositor(); | 1869 AutoResizeCompositor(); |
1869 | 1870 |
1870 if (!resizing_mode_selector_->is_synchronous_mode()) | 1871 if (!resizing_mode_selector_->is_synchronous_mode()) |
1871 need_update_rect_for_auto_resize_ = true; | 1872 need_update_rect_for_auto_resize_ = true; |
1872 } | 1873 } |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2166 bool RenderWidget::isPointerLocked() { | 2167 bool RenderWidget::isPointerLocked() { |
2167 return mouse_lock_dispatcher_->IsMouseLockedTo( | 2168 return mouse_lock_dispatcher_->IsMouseLockedTo( |
2168 webwidget_mouse_lock_target_.get()); | 2169 webwidget_mouse_lock_target_.get()); |
2169 } | 2170 } |
2170 | 2171 |
2171 blink::WebWidget* RenderWidget::GetWebWidget() const { | 2172 blink::WebWidget* RenderWidget::GetWebWidget() const { |
2172 return webwidget_internal_; | 2173 return webwidget_internal_; |
2173 } | 2174 } |
2174 | 2175 |
2175 } // namespace content | 2176 } // namespace content |
OLD | NEW |