mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Implement accessibility enhancements (issue #1217)
- Add new CefBrowserHost::SetAccessibilityState method for toggling accessibility state when readers are detected by the client. - Add new CefAccessibilityHandler interface for the delivery of accessibility notifications to windowless (OSR) clients. - Fix delivery of CefFocusHandler callbacks to windowless clients. - cefclient: Add example windowless accessibility implementation on Windows and macOS. - cefclient: Automatically detect screen readers on Windows and macOS.
This commit is contained in:
committed by
Marshall Greenblatt
parent
64fcfa6068
commit
816f700d3e
@ -46,6 +46,7 @@
|
||||
#include "components/zoom/zoom_controller.h"
|
||||
#include "content/browser/renderer_host/render_view_host_impl.h"
|
||||
#include "content/browser/gpu/compositor_util.h"
|
||||
#include "content/browser/web_contents/web_contents_impl.h"
|
||||
#include "content/common/view_messages.h"
|
||||
#include "content/public/browser/desktop_media_id.h"
|
||||
#include "content/public/browser/download_manager.h"
|
||||
@ -930,6 +931,39 @@ CefRefPtr<CefNavigationEntry> CefBrowserHostImpl::GetVisibleNavigationEntry() {
|
||||
return new CefNavigationEntryImpl(entry);
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::SetAccessibilityState(
|
||||
cef_state_t accessibility_state) {
|
||||
// Do nothing if state is set to default. It'll be disabled by default and
|
||||
// controlled by the commmand-line flags "force-renderer-accessibility" and
|
||||
// "disable-renderer-accessibility".
|
||||
if (accessibility_state == STATE_DEFAULT)
|
||||
return;
|
||||
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefBrowserHostImpl::SetAccessibilityState,
|
||||
this, accessibility_state));
|
||||
return;
|
||||
}
|
||||
|
||||
content::WebContentsImpl* web_contents_impl =
|
||||
static_cast<content::WebContentsImpl*>(web_contents());
|
||||
|
||||
if (!web_contents_impl)
|
||||
return;
|
||||
|
||||
content::AccessibilityMode accMode;
|
||||
// In windowless mode set accessibility to TreeOnly mode. Else native
|
||||
// accessibility APIs, specific to each platform, are also created.
|
||||
if (accessibility_state == STATE_ENABLED) {
|
||||
if (IsWindowless())
|
||||
accMode = content::kAccessibilityModeWebContentsOnly;
|
||||
else
|
||||
accMode = content::kAccessibilityModeComplete;
|
||||
}
|
||||
web_contents_impl->SetAccessibilityMode(accMode);
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::SetMouseCursorChangeDisabled(bool disabled) {
|
||||
base::AutoLock lock_scope(state_lock_);
|
||||
mouse_cursor_change_disabled_ = disabled;
|
||||
@ -2690,6 +2724,28 @@ bool CefBrowserHostImpl::OnMessageReceived(const IPC::Message& message) {
|
||||
return handled;
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::AccessibilityEventReceived(
|
||||
const std::vector<content::AXEventNotificationDetails>& eventData) {
|
||||
// Only needed in windowless mode.
|
||||
if (IsWindowless()) {
|
||||
if (!web_contents() || !platform_delegate_)
|
||||
return;
|
||||
|
||||
platform_delegate_->AccessibilityEventReceived(eventData);
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::AccessibilityLocationChangesReceived(
|
||||
const std::vector<content::AXLocationChangeNotificationDetails>& locData) {
|
||||
// Only needed in windowless mode.
|
||||
if (IsWindowless()) {
|
||||
if (!web_contents() || !platform_delegate_)
|
||||
return;
|
||||
|
||||
platform_delegate_->AccessibilityLocationChangesReceived(locData);
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::OnWebContentsFocused() {
|
||||
if (client_.get()) {
|
||||
CefRefPtr<CefFocusHandler> handler = client_->GetFocusHandler();
|
||||
|
Reference in New Issue
Block a user