| 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/browser/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 ::SetFocus(host->GetAcceleratedWidget()); | 758 ::SetFocus(host->GetAcceleratedWidget()); |
| 759 } | 759 } |
| 760 #endif | 760 #endif |
| 761 if (host_ && set_focus_on_mouse_down_) { | 761 if (host_ && set_focus_on_mouse_down_) { |
| 762 set_focus_on_mouse_down_ = false; | 762 set_focus_on_mouse_down_ = false; |
| 763 host_->Focus(); | 763 host_->Focus(); |
| 764 } | 764 } |
| 765 } | 765 } |
| 766 | 766 |
| 767 RenderFrameHostImpl* RenderWidgetHostViewAura::GetFocusedFrame() { | 767 RenderFrameHostImpl* RenderWidgetHostViewAura::GetFocusedFrame() { |
| 768 if (!host_->IsRenderView()) | |
| 769 return NULL; | |
| 770 RenderViewHost* rvh = RenderViewHost::From(host_); | 768 RenderViewHost* rvh = RenderViewHost::From(host_); |
| 769 if (!rvh) |
| 770 return nullptr; |
| 771 FrameTreeNode* focused_frame = | 771 FrameTreeNode* focused_frame = |
| 772 rvh->GetDelegate()->GetFrameTree()->GetFocusedFrame(); | 772 rvh->GetDelegate()->GetFrameTree()->GetFocusedFrame(); |
| 773 if (!focused_frame) | 773 if (!focused_frame) |
| 774 return NULL; | 774 return nullptr; |
| 775 | 775 |
| 776 return focused_frame->current_frame_host(); | 776 return focused_frame->current_frame_host(); |
| 777 } | 777 } |
| 778 | 778 |
| 779 bool RenderWidgetHostViewAura::CanRendererHandleEvent( | 779 bool RenderWidgetHostViewAura::CanRendererHandleEvent( |
| 780 const ui::MouseEvent* event, | 780 const ui::MouseEvent* event, |
| 781 bool mouse_locked, | 781 bool mouse_locked, |
| 782 bool selection_popup) { | 782 bool selection_popup) { |
| 783 #if defined(OS_WIN) | 783 #if defined(OS_WIN) |
| 784 bool showing_context_menu = showing_context_menu_; | 784 bool showing_context_menu = showing_context_menu_; |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1396 #if defined(OS_WIN) | 1396 #if defined(OS_WIN) |
| 1397 if (legacy_render_widget_host_HWND_) | 1397 if (legacy_render_widget_host_HWND_) |
| 1398 return legacy_render_widget_host_HWND_->window_accessible(); | 1398 return legacy_render_widget_host_HWND_->window_accessible(); |
| 1399 #endif | 1399 #endif |
| 1400 return NULL; | 1400 return NULL; |
| 1401 } | 1401 } |
| 1402 | 1402 |
| 1403 void RenderWidgetHostViewAura::ShowDisambiguationPopup( | 1403 void RenderWidgetHostViewAura::ShowDisambiguationPopup( |
| 1404 const gfx::Rect& rect_pixels, | 1404 const gfx::Rect& rect_pixels, |
| 1405 const SkBitmap& zoomed_bitmap) { | 1405 const SkBitmap& zoomed_bitmap) { |
| 1406 RenderViewHostDelegate* delegate = NULL; | 1406 RenderViewHost* rvh = RenderViewHost::From(host_); |
| 1407 if (host_->IsRenderView()) | 1407 if (rvh) { |
| 1408 delegate = RenderViewHost::From(host_)->GetDelegate(); | 1408 RenderViewHostDelegate* delegate = rvh->GetDelegate(); |
| 1409 // Suppress the link disambiguation popup if the virtual keyboard is currently | 1409 // Suppress the link disambiguation popup if the virtual keyboard is |
| 1410 // requested, as it doesn't interact well with the keyboard. | 1410 // currently requested, as it doesn't interact well with the keyboard. |
| 1411 if (delegate && delegate->IsVirtualKeyboardRequested()) | 1411 if (delegate && delegate->IsVirtualKeyboardRequested()) |
| 1412 return; | 1412 return; |
| 1413 } |
| 1413 | 1414 |
| 1414 // |target_rect| is provided in pixels, not DIPs. So we convert it to DIPs | 1415 // |target_rect| is provided in pixels, not DIPs. So we convert it to DIPs |
| 1415 // by scaling it by the inverse of the device scale factor. | 1416 // by scaling it by the inverse of the device scale factor. |
| 1416 gfx::RectF screen_target_rect_f(rect_pixels); | 1417 gfx::RectF screen_target_rect_f(rect_pixels); |
| 1417 screen_target_rect_f.Scale(1.0f / current_device_scale_factor_); | 1418 screen_target_rect_f.Scale(1.0f / current_device_scale_factor_); |
| 1418 disambiguation_target_rect_ = gfx::ToEnclosingRect(screen_target_rect_f); | 1419 disambiguation_target_rect_ = gfx::ToEnclosingRect(screen_target_rect_f); |
| 1419 | 1420 |
| 1420 float scale = static_cast<float>(zoomed_bitmap.width()) / | 1421 float scale = static_cast<float>(zoomed_bitmap.width()) / |
| 1421 static_cast<float>(rect_pixels.width()); | 1422 static_cast<float>(rect_pixels.width()); |
| 1422 gfx::Size zoomed_size = | 1423 gfx::Size zoomed_size = |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1436 | 1437 |
| 1437 void RenderWidgetHostViewAura::DisambiguationPopupRendered( | 1438 void RenderWidgetHostViewAura::DisambiguationPopupRendered( |
| 1438 const SkBitmap& result, | 1439 const SkBitmap& result, |
| 1439 ReadbackResponse response) { | 1440 ReadbackResponse response) { |
| 1440 if ((response != READBACK_SUCCESS) || | 1441 if ((response != READBACK_SUCCESS) || |
| 1441 disambiguation_scroll_offset_ != last_scroll_offset_) | 1442 disambiguation_scroll_offset_ != last_scroll_offset_) |
| 1442 return; | 1443 return; |
| 1443 | 1444 |
| 1444 // Use RenderViewHostDelegate to get to the WebContentsViewAura, which will | 1445 // Use RenderViewHostDelegate to get to the WebContentsViewAura, which will |
| 1445 // actually show the disambiguation popup. | 1446 // actually show the disambiguation popup. |
| 1446 RenderViewHostDelegate* delegate = NULL; | 1447 RenderViewHost* rvh = RenderViewHost::From(host_); |
| 1447 if (host_->IsRenderView()) | 1448 if (!rvh) |
| 1448 delegate = RenderViewHost::From(host_)->GetDelegate(); | 1449 return; |
| 1449 RenderViewHostDelegateView* delegate_view = NULL; | 1450 |
| 1450 if (delegate) { | 1451 RenderViewHostDelegate* delegate = rvh->GetDelegate(); |
| 1451 delegate_view = delegate->GetDelegateView(); | 1452 if (!delegate) |
| 1452 if (delegate->IsVirtualKeyboardRequested()) | 1453 return; |
| 1453 return; | 1454 |
| 1454 } | 1455 if (delegate->IsVirtualKeyboardRequested()) |
| 1456 return; |
| 1457 |
| 1458 RenderViewHostDelegateView* delegate_view = delegate->GetDelegateView(); |
| 1455 if (delegate_view) { | 1459 if (delegate_view) { |
| 1456 delegate_view->ShowDisambiguationPopup( | 1460 delegate_view->ShowDisambiguationPopup( |
| 1457 disambiguation_target_rect_, | 1461 disambiguation_target_rect_, |
| 1458 result, | 1462 result, |
| 1459 base::Bind(&RenderWidgetHostViewAura::ProcessDisambiguationGesture, | 1463 base::Bind(&RenderWidgetHostViewAura::ProcessDisambiguationGesture, |
| 1460 weak_ptr_factory_.GetWeakPtr()), | 1464 weak_ptr_factory_.GetWeakPtr()), |
| 1461 base::Bind(&RenderWidgetHostViewAura::ProcessDisambiguationMouse, | 1465 base::Bind(&RenderWidgetHostViewAura::ProcessDisambiguationMouse, |
| 1462 weak_ptr_factory_.GetWeakPtr())); | 1466 weak_ptr_factory_.GetWeakPtr())); |
| 1463 } | 1467 } |
| 1464 } | 1468 } |
| 1465 | 1469 |
| 1466 void RenderWidgetHostViewAura::HideDisambiguationPopup() { | 1470 void RenderWidgetHostViewAura::HideDisambiguationPopup() { |
| 1467 RenderViewHostDelegate* delegate = NULL; | 1471 RenderViewHost* rvh = RenderViewHost::From(host_); |
| 1468 if (host_->IsRenderView()) | 1472 if (!rvh) |
| 1469 delegate = RenderViewHost::From(host_)->GetDelegate(); | 1473 return; |
| 1470 RenderViewHostDelegateView* delegate_view = NULL; | 1474 |
| 1471 if (delegate) | 1475 RenderViewHostDelegate* delegate = rvh->GetDelegate(); |
| 1472 delegate_view = delegate->GetDelegateView(); | 1476 if (!delegate) |
| 1477 return; |
| 1478 |
| 1479 RenderViewHostDelegateView* delegate_view = delegate->GetDelegateView(); |
| 1473 if (delegate_view) | 1480 if (delegate_view) |
| 1474 delegate_view->HideDisambiguationPopup(); | 1481 delegate_view->HideDisambiguationPopup(); |
| 1475 } | 1482 } |
| 1476 | 1483 |
| 1477 void RenderWidgetHostViewAura::ProcessDisambiguationGesture( | 1484 void RenderWidgetHostViewAura::ProcessDisambiguationGesture( |
| 1478 ui::GestureEvent* event) { | 1485 ui::GestureEvent* event) { |
| 1479 blink::WebGestureEvent web_gesture = content::MakeWebGestureEvent(*event); | 1486 blink::WebGestureEvent web_gesture = content::MakeWebGestureEvent(*event); |
| 1480 // If we fail to make a WebGestureEvent that is a Tap from the provided event, | 1487 // If we fail to make a WebGestureEvent that is a Tap from the provided event, |
| 1481 // don't forward it to Blink. | 1488 // don't forward it to Blink. |
| 1482 if (web_gesture.type < blink::WebInputEvent::Type::GestureTap || | 1489 if (web_gesture.type < blink::WebInputEvent::Type::GestureTap || |
| (...skipping 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2884 | 2891 |
| 2885 //////////////////////////////////////////////////////////////////////////////// | 2892 //////////////////////////////////////////////////////////////////////////////// |
| 2886 // RenderWidgetHostViewBase, public: | 2893 // RenderWidgetHostViewBase, public: |
| 2887 | 2894 |
| 2888 // static | 2895 // static |
| 2889 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2896 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 2890 GetScreenInfoForWindow(results, NULL); | 2897 GetScreenInfoForWindow(results, NULL); |
| 2891 } | 2898 } |
| 2892 | 2899 |
| 2893 } // namespace content | 2900 } // namespace content |
| OLD | NEW |