OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/renderer_host/render_widget_host_view_win.h" | 5 #include "chrome/browser/renderer_host/render_widget_host_view_win.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/l10n_util_win.h" | 8 #include "app/l10n_util_win.h" |
9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 backing_store_dc, | 245 backing_store_dc, |
246 paint_rect.x(), | 246 paint_rect.x(), |
247 paint_rect.y(), | 247 paint_rect.y(), |
248 SRCCOPY); | 248 SRCCOPY); |
249 canvas.endPlatformPaint(); | 249 canvas.endPlatformPaint(); |
250 // 178 is 70% grey. | 250 // 178 is 70% grey. |
251 canvas.FillRectInt(SkColorSetARGB(178, 0, 0, 0), 0, 0, | 251 canvas.FillRectInt(SkColorSetARGB(178, 0, 0, 0), 0, 0, |
252 paint_rect.width(), paint_rect.height()); | 252 paint_rect.width(), paint_rect.height()); |
253 canvas.getTopPlatformDevice().drawToHDC(paint_dc, paint_rect.x(), | 253 canvas.getTopPlatformDevice().drawToHDC(paint_dc, paint_rect.x(), |
254 paint_rect.y(), NULL); | 254 paint_rect.y(), NULL); |
| 255 |
255 } | 256 } |
256 | 257 |
257 } // namespace | 258 } // namespace |
258 | 259 |
259 // RenderWidgetHostView -------------------------------------------------------- | 260 // RenderWidgetHostView -------------------------------------------------------- |
260 | 261 |
261 // static | 262 // static |
262 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( | 263 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( |
263 RenderWidgetHost* widget) { | 264 RenderWidgetHost* widget) { |
264 return new RenderWidgetHostViewWin(widget); | 265 return new RenderWidgetHostViewWin(widget); |
(...skipping 11 matching lines...) Expand all Loading... |
276 about_to_validate_and_paint_(false), | 277 about_to_validate_and_paint_(false), |
277 close_on_deactivate_(false), | 278 close_on_deactivate_(false), |
278 being_destroyed_(false), | 279 being_destroyed_(false), |
279 tooltip_hwnd_(NULL), | 280 tooltip_hwnd_(NULL), |
280 tooltip_showing_(false), | 281 tooltip_showing_(false), |
281 shutdown_factory_(this), | 282 shutdown_factory_(this), |
282 parent_hwnd_(NULL), | 283 parent_hwnd_(NULL), |
283 is_loading_(false), | 284 is_loading_(false), |
284 visually_deemphasized_(false) { | 285 visually_deemphasized_(false) { |
285 render_widget_host_->set_view(this); | 286 render_widget_host_->set_view(this); |
| 287 renderer_accessible_ = |
| 288 CommandLine::ForCurrentProcess()->HasSwitch( |
| 289 switches::kEnableRendererAccessibility); |
286 registrar_.Add(this, | 290 registrar_.Add(this, |
287 NotificationType::RENDERER_PROCESS_TERMINATED, | 291 NotificationType::RENDERER_PROCESS_TERMINATED, |
288 NotificationService::AllSources()); | 292 NotificationService::AllSources()); |
289 | |
290 BOOL screenreader_running = FALSE; | |
291 if (SystemParametersInfo(SPI_GETSCREENREADER, 0, &screenreader_running, 0) && | |
292 screenreader_running) { | |
293 render_widget_host_->EnableRendererAccessibility(); | |
294 } | |
295 } | 293 } |
296 | 294 |
297 RenderWidgetHostViewWin::~RenderWidgetHostViewWin() { | 295 RenderWidgetHostViewWin::~RenderWidgetHostViewWin() { |
298 ResetTooltip(); | 296 ResetTooltip(); |
299 } | 297 } |
300 | 298 |
301 void RenderWidgetHostViewWin::CreateWnd(HWND parent) { | 299 void RenderWidgetHostViewWin::CreateWnd(HWND parent) { |
302 Create(parent); // ATL function to create the window. | 300 Create(parent); // ATL function to create the window. |
303 | 301 |
304 // Add a property indicating that a particular renderer is associated with | 302 // Add a property indicating that a particular renderer is associated with |
(...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1478 } | 1476 } |
1479 } | 1477 } |
1480 handled = FALSE; | 1478 handled = FALSE; |
1481 return MA_ACTIVATE; | 1479 return MA_ACTIVATE; |
1482 } | 1480 } |
1483 | 1481 |
1484 void RenderWidgetHostViewWin::UpdateAccessibilityTree( | 1482 void RenderWidgetHostViewWin::UpdateAccessibilityTree( |
1485 const webkit_glue::WebAccessibility& tree) { | 1483 const webkit_glue::WebAccessibility& tree) { |
1486 browser_accessibility_manager_.reset( | 1484 browser_accessibility_manager_.reset( |
1487 new BrowserAccessibilityManager(m_hWnd, tree, this)); | 1485 new BrowserAccessibilityManager(m_hWnd, tree, this)); |
1488 | |
1489 ::NotifyWinEvent( | |
1490 IA2_EVENT_DOCUMENT_LOAD_COMPLETE, m_hWnd, OBJID_CLIENT, CHILDID_SELF); | |
1491 } | 1486 } |
1492 | 1487 |
1493 void RenderWidgetHostViewWin::OnAccessibilityFocusChange(int acc_obj_id) { | 1488 void RenderWidgetHostViewWin::OnAccessibilityFocusChange(int acc_obj_id) { |
1494 if (browser_accessibility_manager_.get()) { | 1489 if (browser_accessibility_manager_.get()) { |
1495 browser_accessibility_manager_->OnAccessibilityFocusChange(acc_obj_id); | 1490 browser_accessibility_manager_->OnAccessibilityFocusChange(acc_obj_id); |
1496 } | 1491 } |
1497 } | 1492 } |
1498 | 1493 |
1499 void RenderWidgetHostViewWin::OnAccessibilityObjectStateChange(int acc_obj_id) { | 1494 void RenderWidgetHostViewWin::OnAccessibilityObjectStateChange(int acc_obj_id) { |
1500 if (browser_accessibility_manager_.get()) { | 1495 if (browser_accessibility_manager_.get()) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1540 !render_widget_host_->process() || | 1535 !render_widget_host_->process() || |
1541 !render_widget_host_->process()->HasConnection()) { | 1536 !render_widget_host_->process()->HasConnection()) { |
1542 return; | 1537 return; |
1543 } | 1538 } |
1544 | 1539 |
1545 render_widget_host_->AccessibilityDoDefaultAction(acc_obj_id); | 1540 render_widget_host_->AccessibilityDoDefaultAction(acc_obj_id); |
1546 } | 1541 } |
1547 | 1542 |
1548 LRESULT RenderWidgetHostViewWin::OnGetObject(UINT message, WPARAM wparam, | 1543 LRESULT RenderWidgetHostViewWin::OnGetObject(UINT message, WPARAM wparam, |
1549 LPARAM lparam, BOOL& handled) { | 1544 LPARAM lparam, BOOL& handled) { |
1550 if (lparam != OBJID_CLIENT) { | 1545 // TODO(dmazzoni): http://crbug.com/25564 Disabling accessibility in the |
| 1546 // renderer is a temporary work-around until that bug is fixed. |
| 1547 if (!renderer_accessible_) { |
1551 handled = false; | 1548 handled = false; |
1552 return static_cast<LRESULT>(0L); | 1549 return static_cast<LRESULT>(0L); |
1553 } | 1550 } |
1554 | 1551 |
1555 if (!browser_accessibility_manager_.get()) { | 1552 if (lparam == OBJID_CLIENT && browser_accessibility_manager_.get()) { |
1556 render_widget_host_->EnableRendererAccessibility(); | |
1557 | |
1558 if (!loading_accessible_.get()) { | |
1559 // Create IAccessible to return while waiting for the accessibility tree | |
1560 // from the renderer. | |
1561 HRESULT hr = ::CreateStdAccessibleObject( | |
1562 m_hWnd, OBJID_CLIENT, IID_IAccessible, | |
1563 reinterpret_cast<void **>(&loading_accessible_)); | |
1564 | |
1565 // Annotate with STATE_SYSTEM_BUSY to indicate that the page is loading. | |
1566 // We annotate the HWND, not the loading_accessible IAccessible, but the | |
1567 // IAccessible will reflect the state annotation. | |
1568 ScopedComPtr<IAccPropServices> pAccPropServices; | |
1569 hr = CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER, | |
1570 IID_IAccPropServices, reinterpret_cast<void**>(&pAccPropServices)); | |
1571 if (SUCCEEDED(hr)) { | |
1572 VARIANT var; | |
1573 var.vt = VT_I4; | |
1574 var.lVal = STATE_SYSTEM_BUSY; | |
1575 pAccPropServices->SetHwndProp(m_hWnd, OBJID_CLIENT, | |
1576 CHILDID_SELF, PROPID_ACC_STATE, var); | |
1577 } | |
1578 } | |
1579 | |
1580 if (loading_accessible_.get()) { | |
1581 return LresultFromObject( | |
1582 IID_IAccessible, wparam, | |
1583 static_cast<IAccessible*>(loading_accessible_)); | |
1584 } | |
1585 } else { | |
1586 BrowserAccessibility* root = browser_accessibility_manager_->GetRoot(); | 1553 BrowserAccessibility* root = browser_accessibility_manager_->GetRoot(); |
1587 if (root) { | 1554 if (root) { |
1588 return LresultFromObject(IID_IAccessible, wparam, | 1555 return LresultFromObject(IID_IAccessible, wparam, |
1589 static_cast<IAccessible*>(root->NewReference())); | 1556 static_cast<IAccessible*>(root->NewReference())); |
1590 } | 1557 } |
1591 } | 1558 } |
1592 | 1559 |
1593 handled = false; | 1560 handled = false; |
1594 return static_cast<LRESULT>(0L); | 1561 return static_cast<LRESULT>(0L); |
1595 } | 1562 } |
1596 | 1563 |
1597 void RenderWidgetHostViewWin::OnFinalMessage(HWND window) { | 1564 void RenderWidgetHostViewWin::OnFinalMessage(HWND window) { |
1598 // When the render widget host is being destroyed, it ends up calling | 1565 // When the render widget host is being destroyed, it ends up calling |
1599 // WillDestroyRenderWidget (through the RENDER_WIDGET_HOST_DESTROYED | 1566 // WillDestroyRenderWidget (through the RENDER_WIDGET_HOST_DESTROYED |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1714 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( | 1681 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( |
1715 gfx::NativeView native_view) { | 1682 gfx::NativeView native_view) { |
1716 if (::IsWindow(native_view)) { | 1683 if (::IsWindow(native_view)) { |
1717 HANDLE raw_render_host_view = ::GetProp(native_view, | 1684 HANDLE raw_render_host_view = ::GetProp(native_view, |
1718 kRenderWidgetHostViewKey); | 1685 kRenderWidgetHostViewKey); |
1719 if (raw_render_host_view) | 1686 if (raw_render_host_view) |
1720 return reinterpret_cast<RenderWidgetHostView*>(raw_render_host_view); | 1687 return reinterpret_cast<RenderWidgetHostView*>(raw_render_host_view); |
1721 } | 1688 } |
1722 return NULL; | 1689 return NULL; |
1723 } | 1690 } |
OLD | NEW |