Chromium Code Reviews| 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_impl.h" | 5 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 #include "content/browser/renderer_host/backing_store.h" | 21 #include "content/browser/renderer_host/backing_store.h" |
| 22 #include "content/browser/renderer_host/backing_store_manager.h" | 22 #include "content/browser/renderer_host/backing_store_manager.h" |
| 23 #include "content/browser/renderer_host/render_process_host_impl.h" | 23 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 24 #include "content/browser/renderer_host/render_view_host_impl.h" | 24 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 25 #include "content/browser/renderer_host/render_widget_helper.h" | 25 #include "content/browser/renderer_host/render_widget_helper.h" |
| 26 #include "content/browser/renderer_host/tap_suppression_controller.h" | 26 #include "content/browser/renderer_host/tap_suppression_controller.h" |
| 27 #include "content/common/accessibility_messages.h" | 27 #include "content/common/accessibility_messages.h" |
| 28 #include "content/common/gpu/gpu_messages.h" | 28 #include "content/common/gpu/gpu_messages.h" |
| 29 #include "content/common/view_messages.h" | 29 #include "content/common/view_messages.h" |
| 30 #include "content/port/browser/render_widget_host_view_port.h" | 30 #include "content/port/browser/render_widget_host_view_port.h" |
| 31 #include "content/public/browser/browser_accessibility_state.h" | |
| 32 #include "content/public/browser/native_web_keyboard_event.h" | 31 #include "content/public/browser/native_web_keyboard_event.h" |
| 33 #include "content/public/browser/notification_service.h" | 32 #include "content/public/browser/notification_service.h" |
| 34 #include "content/public/browser/notification_types.h" | 33 #include "content/public/browser/notification_types.h" |
| 35 #include "content/public/browser/user_metrics.h" | 34 #include "content/public/browser/user_metrics.h" |
| 36 #include "content/public/common/content_switches.h" | 35 #include "content/public/common/content_switches.h" |
| 37 #include "content/public/common/result_codes.h" | 36 #include "content/public/common/result_codes.h" |
| 38 #include "skia/ext/image_operations.h" | 37 #include "skia/ext/image_operations.h" |
| 39 #include "skia/ext/platform_canvas.h" | 38 #include "skia/ext/platform_canvas.h" |
| 40 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderli ne.h" | 39 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderli ne.h" |
| 41 #include "ui/base/keycodes/keyboard_codes.h" | 40 #include "ui/base/keycodes/keyboard_codes.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 /////////////////////////////////////////////////////////////////////////////// | 98 /////////////////////////////////////////////////////////////////////////////// |
| 100 // RenderWidgetHostImpl | 99 // RenderWidgetHostImpl |
| 101 | 100 |
| 102 RenderWidgetHostImpl::RenderWidgetHostImpl(RenderProcessHost* process, | 101 RenderWidgetHostImpl::RenderWidgetHostImpl(RenderProcessHost* process, |
| 103 int routing_id) | 102 int routing_id) |
| 104 : view_(NULL), | 103 : view_(NULL), |
| 105 renderer_initialized_(false), | 104 renderer_initialized_(false), |
| 106 hung_renderer_delay_ms_(kHungRendererDelayMs), | 105 hung_renderer_delay_ms_(kHungRendererDelayMs), |
| 107 process_(process), | 106 process_(process), |
| 108 routing_id_(routing_id), | 107 routing_id_(routing_id), |
| 109 renderer_accessible_(false), | |
| 110 surface_id_(0), | 108 surface_id_(0), |
| 111 is_loading_(false), | 109 is_loading_(false), |
| 112 is_hidden_(false), | 110 is_hidden_(false), |
| 113 is_fullscreen_(false), | 111 is_fullscreen_(false), |
| 114 is_accelerated_compositing_active_(false), | 112 is_accelerated_compositing_active_(false), |
| 115 repaint_ack_pending_(false), | 113 repaint_ack_pending_(false), |
| 116 resize_ack_pending_(false), | 114 resize_ack_pending_(false), |
| 117 should_auto_resize_(false), | 115 should_auto_resize_(false), |
| 118 mouse_move_pending_(false), | 116 mouse_move_pending_(false), |
| 119 mouse_wheel_pending_(false), | 117 mouse_wheel_pending_(false), |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 147 surface_id_ = GpuSurfaceTracker::Get()->LookupSurfaceForRenderer( | 145 surface_id_ = GpuSurfaceTracker::Get()->LookupSurfaceForRenderer( |
| 148 process_->GetID(), | 146 process_->GetID(), |
| 149 routing_id_); | 147 routing_id_); |
| 150 DCHECK(surface_id_); | 148 DCHECK(surface_id_); |
| 151 } | 149 } |
| 152 | 150 |
| 153 process_->Attach(this, routing_id_); | 151 process_->Attach(this, routing_id_); |
| 154 // Because the widget initializes as is_hidden_ == false, | 152 // Because the widget initializes as is_hidden_ == false, |
| 155 // tell the process host that we're alive. | 153 // tell the process host that we're alive. |
| 156 process_->WidgetRestored(); | 154 process_->WidgetRestored(); |
| 157 | |
| 158 // Enable accessibility if it was manually specified or if it was | |
| 159 // auto-detected. | |
| 160 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 161 switches::kForceRendererAccessibility)) { | |
| 162 BrowserAccessibilityState::GetInstance()->OnAccessibilityEnabledManually(); | |
| 163 EnableRendererAccessibility(); | |
| 164 } else if (BrowserAccessibilityState::GetInstance()->IsAccessibleBrowser()) { | |
| 165 EnableRendererAccessibility(); | |
| 166 } | |
| 167 } | 155 } |
| 168 | 156 |
| 169 RenderWidgetHostImpl::~RenderWidgetHostImpl() { | 157 RenderWidgetHostImpl::~RenderWidgetHostImpl() { |
| 170 SetView(NULL); | 158 SetView(NULL); |
| 171 | 159 |
| 172 // Clear our current or cached backing store if either remains. | 160 // Clear our current or cached backing store if either remains. |
| 173 BackingStoreManager::RemoveBackingStore(this); | 161 BackingStoreManager::RemoveBackingStore(this); |
| 174 | 162 |
| 175 GpuSurfaceTracker::Get()->RemoveSurface(surface_id_); | 163 GpuSurfaceTracker::Get()->RemoveSurface(surface_id_); |
| 176 surface_id_ = 0; | 164 surface_id_ = 0; |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 660 TimeDelta::FromMilliseconds(hung_renderer_delay_ms_)); | 648 TimeDelta::FromMilliseconds(hung_renderer_delay_ms_)); |
| 661 } | 649 } |
| 662 | 650 |
| 663 void RenderWidgetHostImpl::StopHangMonitorTimeout() { | 651 void RenderWidgetHostImpl::StopHangMonitorTimeout() { |
| 664 time_when_considered_hung_ = Time(); | 652 time_when_considered_hung_ = Time(); |
| 665 RendererIsResponsive(); | 653 RendererIsResponsive(); |
| 666 // We do not bother to stop the hung_renderer_timer_ here in case it will be | 654 // We do not bother to stop the hung_renderer_timer_ here in case it will be |
| 667 // started again shortly, which happens to be the common use case. | 655 // started again shortly, which happens to be the common use case. |
| 668 } | 656 } |
| 669 | 657 |
| 658 void RenderWidgetHostImpl::EnableFullAccessibilityMode() { | |
|
David Tseng
2012/04/09 17:57:34
It looks like this is only referenced once; do we
dmazzoni
2012/04/09 18:51:47
The reason for this is because the AccessibilityMo
| |
| 659 SetAccessibilityMode(AccessibilityModeComplete); | |
| 660 } | |
| 661 | |
| 670 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) { | 662 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) { |
| 671 TRACE_EVENT2("renderer_host", "RenderWidgetHostImpl::ForwardMouseEvent", | 663 TRACE_EVENT2("renderer_host", "RenderWidgetHostImpl::ForwardMouseEvent", |
| 672 "x", mouse_event.x, "y", mouse_event.y); | 664 "x", mouse_event.x, "y", mouse_event.y); |
| 673 if (ignore_input_events_ || process_->IgnoreInputEvents()) | 665 if (ignore_input_events_ || process_->IgnoreInputEvents()) |
| 674 return; | 666 return; |
| 675 | 667 |
| 676 // Avoid spamming the renderer with mouse move events. It is important | 668 // Avoid spamming the renderer with mouse move events. It is important |
| 677 // to note that WM_MOUSEMOVE events are anyways synthetic, but since our | 669 // to note that WM_MOUSEMOVE events are anyways synthetic, but since our |
| 678 // thread is able to rapidly consume WM_MOUSEMOVE events, we may get way | 670 // thread is able to rapidly consume WM_MOUSEMOVE events, we may get way |
| 679 // more WM_MOUSEMOVE events than we wish to send to the renderer. | 671 // more WM_MOUSEMOVE events than we wish to send to the renderer. |
| (...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1478 BackingStore* backing_store = BackingStoreManager::Lookup(this); | 1470 BackingStore* backing_store = BackingStoreManager::Lookup(this); |
| 1479 if (!backing_store || (backing_store->size() != view_size)) | 1471 if (!backing_store || (backing_store->size() != view_size)) |
| 1480 return; | 1472 return; |
| 1481 backing_store->ScrollBackingStore(dx, dy, clip_rect, view_size); | 1473 backing_store->ScrollBackingStore(dx, dy, clip_rect, view_size); |
| 1482 } | 1474 } |
| 1483 | 1475 |
| 1484 void RenderWidgetHostImpl::Replace(const string16& word) { | 1476 void RenderWidgetHostImpl::Replace(const string16& word) { |
| 1485 Send(new ViewMsg_Replace(routing_id_, word)); | 1477 Send(new ViewMsg_Replace(routing_id_, word)); |
| 1486 } | 1478 } |
| 1487 | 1479 |
| 1488 void RenderWidgetHostImpl::EnableRendererAccessibility() { | |
| 1489 if (renderer_accessible_) | |
| 1490 return; | |
| 1491 | |
| 1492 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 1493 switches::kDisableRendererAccessibility)) { | |
| 1494 return; | |
| 1495 } | |
| 1496 | |
| 1497 renderer_accessible_ = true; | |
| 1498 | |
| 1499 if (process_->HasConnection()) { | |
| 1500 // Renderer accessibility wasn't enabled on process launch. Enable it now. | |
| 1501 Send(new AccessibilityMsg_Enable(GetRoutingID())); | |
| 1502 } | |
| 1503 } | |
| 1504 | |
| 1505 void RenderWidgetHostImpl::SetIgnoreInputEvents(bool ignore_input_events) { | 1480 void RenderWidgetHostImpl::SetIgnoreInputEvents(bool ignore_input_events) { |
| 1506 ignore_input_events_ = ignore_input_events; | 1481 ignore_input_events_ = ignore_input_events; |
| 1507 } | 1482 } |
| 1508 | 1483 |
| 1509 void RenderWidgetHostImpl::ProcessKeyboardEventAck(int type, bool processed) { | 1484 void RenderWidgetHostImpl::ProcessKeyboardEventAck(int type, bool processed) { |
| 1510 if (key_queue_.empty()) { | 1485 if (key_queue_.empty()) { |
| 1511 LOG(ERROR) << "Got a KeyEvent back from the renderer but we " | 1486 LOG(ERROR) << "Got a KeyEvent back from the renderer but we " |
| 1512 << "don't seem to have sent it to the renderer!"; | 1487 << "don't seem to have sent it to the renderer!"; |
| 1513 } else if (key_queue_.front().type != type) { | 1488 } else if (key_queue_.front().type != type) { |
| 1514 LOG(ERROR) << "We seem to have a different key type sent from " | 1489 LOG(ERROR) << "We seem to have a different key type sent from " |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1570 | 1545 |
| 1571 void RenderWidgetHostImpl::SetBackground(const SkBitmap& background) { | 1546 void RenderWidgetHostImpl::SetBackground(const SkBitmap& background) { |
| 1572 Send(new ViewMsg_SetBackground(GetRoutingID(), background)); | 1547 Send(new ViewMsg_SetBackground(GetRoutingID(), background)); |
| 1573 } | 1548 } |
| 1574 | 1549 |
| 1575 void RenderWidgetHostImpl::SetEditCommandsForNextKeyEvent( | 1550 void RenderWidgetHostImpl::SetEditCommandsForNextKeyEvent( |
| 1576 const std::vector<EditCommand>& commands) { | 1551 const std::vector<EditCommand>& commands) { |
| 1577 Send(new ViewMsg_SetEditCommandsForNextKeyEvent(GetRoutingID(), commands)); | 1552 Send(new ViewMsg_SetEditCommandsForNextKeyEvent(GetRoutingID(), commands)); |
| 1578 } | 1553 } |
| 1579 | 1554 |
| 1555 void RenderWidgetHostImpl::SetAccessibilityMode(AccessibilityMode mode) { | |
| 1556 Send(new AccessibilityMsg_SetMode(routing_id_, mode)); | |
| 1557 } | |
| 1558 | |
| 1580 void RenderWidgetHostImpl::AccessibilityDoDefaultAction(int object_id) { | 1559 void RenderWidgetHostImpl::AccessibilityDoDefaultAction(int object_id) { |
| 1581 Send(new AccessibilityMsg_DoDefaultAction(GetRoutingID(), object_id)); | 1560 Send(new AccessibilityMsg_DoDefaultAction(GetRoutingID(), object_id)); |
| 1582 } | 1561 } |
| 1583 | 1562 |
| 1584 void RenderWidgetHostImpl::AccessibilitySetFocus(int object_id) { | 1563 void RenderWidgetHostImpl::AccessibilitySetFocus(int object_id) { |
| 1585 Send(new AccessibilityMsg_SetFocus(GetRoutingID(), object_id)); | 1564 Send(new AccessibilityMsg_SetFocus(GetRoutingID(), object_id)); |
| 1586 } | 1565 } |
| 1587 | 1566 |
| 1588 void RenderWidgetHostImpl::AccessibilityScrollToMakeVisible( | 1567 void RenderWidgetHostImpl::AccessibilityScrollToMakeVisible( |
| 1589 int acc_obj_id, gfx::Rect subfocus) { | 1568 int acc_obj_id, gfx::Rect subfocus) { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1709 // indicate that no callback is in progress (i.e. without this line | 1688 // indicate that no callback is in progress (i.e. without this line |
| 1710 // DelayedAutoResized will not get called again). | 1689 // DelayedAutoResized will not get called again). |
| 1711 new_auto_size_.SetSize(0, 0); | 1690 new_auto_size_.SetSize(0, 0); |
| 1712 if (!should_auto_resize_) | 1691 if (!should_auto_resize_) |
| 1713 return; | 1692 return; |
| 1714 | 1693 |
| 1715 OnRenderAutoResized(new_size); | 1694 OnRenderAutoResized(new_size); |
| 1716 } | 1695 } |
| 1717 | 1696 |
| 1718 } // namespace content | 1697 } // namespace content |
| OLD | NEW |