Skip to content

Commit

Permalink
Add accessibility support for both windowed and OSR modes (#449).
Browse files Browse the repository at this point in the history
Add Browser.SetAccessibilityState.
Add AccessibilityHandler (OSR mode).

Add cef.SetGlobalClientHandler.
Add osr_test.py unittest for off-screen rendering mode (#59).
Refactor main_test.py.

Update tools/apidocs.py - generate TOCs by default
Update tools/build_distrib.py - run all unit tests
  • Loading branch information
cztomczak committed Aug 18, 2018
1 parent cb9628b commit e72609c
Show file tree
Hide file tree
Showing 24 changed files with 816 additions and 244 deletions.
114 changes: 60 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,63 +256,67 @@ Additional information for v31.2 release:

### API categories

#### Modules

* [cefpython](api/cefpython.md#cefpython) module


#### Settings

* [ApplicationSettings](api/ApplicationSettings.md#application-settings) dictionary
* [BrowserSettings](api/BrowserSettings.md#browser-settings) dictionary
* [CommandLineSwitches](api/CommandLineSwitches.md#command-line-switches) dictionary


#### Classes and objects

* [Browser](api/Browser.md#browser-object) object
* [Callback](api/Callback.md#callback-object) object
* [Cookie](api/Cookie.md#cookie-class) class
* [CookieManager](api/CookieManager.md#cookiemanager-class) class
* [DpiAware](api/DpiAware.md#dpiaware-class) class (Win)
* [DragData](api/DragData.md#dragdata-object) object
* [Frame](api/Frame.md#frame-object) object
* [Image](api/Image.md#image-object) object
* [JavascriptBindings](api/JavascriptBindings.md#javascriptbindings-class) class
* [JavascriptCallback](api/JavascriptCallback.md#javascriptcallback-object) object
* [PaintBuffer](api/PaintBuffer.md#paintbuffer-object) object
* [Request](api/Request.md#request-class) class
* [Response](api/Response.md#response-object) object
* [WebPluginInfo](api/WebPluginInfo.md#webplugininfo-object) object
* [WebRequest](api/WebRequest.md#webrequest-class) class
* [WindowInfo](api/WindowInfo.md#windowinfo-class) class
* [WindowUtils](api/WindowUtils.md#windowutils-class) class


#### Client handlers (interfaces)

* [DisplayHandler](api/DisplayHandler.md#displayhandler-interface)
* [DownloadHandler](api/DownloadHandler.md#downloadhandler)
* [FocusHandler](api/FocusHandler.md#focushandler-interface)
* [JavascriptDialogHandler](api/JavascriptDialogHandler.md#javascriptdialoghandler-interface)
* [KeyboardHandler](api/KeyboardHandler.md#keyboardhandler-interface)
* [LifespanHandler](api/LifespanHandler.md#lifespanhandler-interface)
* [LoadHandler](api/LoadHandler.md#loadhandler-interface)
* [RenderHandler](api/RenderHandler.md#renderhandler-interface)
* [RequestHandler](api/RequestHandler.md#requesthandler-interface)
* [ResourceHandler](api/ResourceHandler.md#resourcehandler-interface)
* [V8ContextHandler](api/V8ContextHandler.md#v8contexthandler-interface)


#### Other interfaces

* [CookieVisitor](api/CookieVisitor.md#cookievisitor-interface) interface
* [StringVisitor](api/StringVisitor.md#stringvisitor-interface) interface
* [WebRequestClient](api/WebRequestClient.md#webrequestclient-interface) interface

#### Modules

* [cefpython](api/cefpython.md#cefpython) module


#### Settings

* [ApplicationSettings](api/ApplicationSettings.md#application-settings) dictionary
* [BrowserSettings](api/BrowserSettings.md#browser-settings) dictionary
* [CommandLineSwitches](api/CommandLineSwitches.md#command-line-switches) dictionary


#### Classes and objects

* [Browser](api/Browser.md#browser-object) object
* [Callback](api/Callback.md#callback-object) object
* [Cookie](api/Cookie.md#cookie-class) class
* [CookieManager](api/CookieManager.md#cookiemanager-class) class
* [DpiAware](api/DpiAware.md#dpiaware-class) class (Win)
* [DragData](api/DragData.md#dragdata-object) object
* [Frame](api/Frame.md#frame-object) object
* [Image](api/Image.md#image-object) object
* [JavascriptBindings](api/JavascriptBindings.md#javascriptbindings-class) class
* [JavascriptCallback](api/JavascriptCallback.md#javascriptcallback-object) object
* [PaintBuffer](api/PaintBuffer.md#paintbuffer-object) object
* [Request](api/Request.md#request-class) class
* [Response](api/Response.md#response-object) object
* [WebPluginInfo](api/WebPluginInfo.md#webplugininfo-object) object
* [WebRequest](api/WebRequest.md#webrequest-class) class
* [WindowInfo](api/WindowInfo.md#windowinfo-class) class
* [WindowUtils](api/WindowUtils.md#windowutils-class) class


#### Client handlers (interfaces)

* [AccessibilityHandler](api/AccessibilityHandler.md#accessibilityhandler-interface)
* [DisplayHandler](api/DisplayHandler.md#displayhandler-interface)
* [DownloadHandler](api/DownloadHandler.md#downloadhandler)
* [FocusHandler](api/FocusHandler.md#focushandler-interface)
* [JavascriptDialogHandler](api/JavascriptDialogHandler.md#javascriptdialoghandler-interface)
* [KeyboardHandler](api/KeyboardHandler.md#keyboardhandler-interface)
* [LifespanHandler](api/LifespanHandler.md#lifespanhandler-interface)
* [LoadHandler](api/LoadHandler.md#loadhandler-interface)
* [RenderHandler](api/RenderHandler.md#renderhandler-interface)
* [RequestHandler](api/RequestHandler.md#requesthandler-interface)
* [ResourceHandler](api/ResourceHandler.md#resourcehandler-interface)
* [V8ContextHandler](api/V8ContextHandler.md#v8contexthandler-interface)


#### Other interfaces

* [CookieVisitor](api/CookieVisitor.md#cookievisitor-interface) interface
* [StringVisitor](api/StringVisitor.md#stringvisitor-interface) interface
* [WebRequestClient](api/WebRequestClient.md#webrequestclient-interface) interface


### API index

* [AccessibilityHandler (interface)](api/AccessibilityHandler.md#accessibilityhandler-interface)
* [_OnAccessibilityTreeChange](api/AccessibilityHandler.md#_onaccessibilitytreechange)
* [_OnAccessibilityLocationChange](api/AccessibilityHandler.md#_onaccessibilitylocationchange)
* [Application settings](api/ApplicationSettings.md#application-settings)
* [accept_language_list](api/ApplicationSettings.md#accept_language_list)
* [app_user_model_id](api/ApplicationSettings.md#app_user_model_id)
Expand Down Expand Up @@ -408,6 +412,7 @@ Additional information for v31.2 release:
* [SendMouseWheelEvent](api/Browser.md#sendmousewheelevent)
* [SendFocusEvent](api/Browser.md#sendfocusevent)
* [SendCaptureLostEvent](api/Browser.md#sendcapturelostevent)
* [SetAccessibilityState](api/Browser.md#setaccessibilitystate)
* [SetClientCallback](api/Browser.md#setclientcallback)
* [SetClientHandler](api/Browser.md#setclienthandler)
* [SetFocus](api/Browser.md#setfocus)
Expand Down Expand Up @@ -469,6 +474,7 @@ Additional information for v31.2 release:
* [PostDelayedTask](api/cefpython.md#postdelayedtask)
* [QuitMessageLoop](api/cefpython.md#quitmessageloop)
* [SetGlobalClientCallback](api/cefpython.md#setglobalclientcallback)
* [SetGlobalClientHandler](api/cefpython.md#setglobalclienthandler)
* [SetOsModalLoop](api/cefpython.md#setosmodalloop)
* [Shutdown](api/cefpython.md#shutdown)
* [Command line switches](api/CommandLineSwitches.md#command-line-switches)
Expand Down
1 change: 1 addition & 0 deletions api/API-categories.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

### Client handlers (interfaces)

* [AccessibilityHandler](AccessibilityHandler.md#accessibilityhandler-interface)
* [DisplayHandler](DisplayHandler.md#displayhandler-interface)
* [DownloadHandler](DownloadHandler.md#downloadhandler)
* [FocusHandler](FocusHandler.md#focushandler-interface)
Expand Down
5 changes: 5 additions & 0 deletions api/API-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

# API index

* [AccessibilityHandler (interface)](AccessibilityHandler.md#accessibilityhandler-interface)
* [_OnAccessibilityTreeChange](AccessibilityHandler.md#_onaccessibilitytreechange)
* [_OnAccessibilityLocationChange](AccessibilityHandler.md#_onaccessibilitylocationchange)
* [Application settings](ApplicationSettings.md#application-settings)
* [accept_language_list](ApplicationSettings.md#accept_language_list)
* [app_user_model_id](ApplicationSettings.md#app_user_model_id)
Expand Down Expand Up @@ -97,6 +100,7 @@
* [SendMouseWheelEvent](Browser.md#sendmousewheelevent)
* [SendFocusEvent](Browser.md#sendfocusevent)
* [SendCaptureLostEvent](Browser.md#sendcapturelostevent)
* [SetAccessibilityState](Browser.md#setaccessibilitystate)
* [SetClientCallback](Browser.md#setclientcallback)
* [SetClientHandler](Browser.md#setclienthandler)
* [SetFocus](Browser.md#setfocus)
Expand Down Expand Up @@ -158,6 +162,7 @@
* [PostDelayedTask](cefpython.md#postdelayedtask)
* [QuitMessageLoop](cefpython.md#quitmessageloop)
* [SetGlobalClientCallback](cefpython.md#setglobalclientcallback)
* [SetGlobalClientHandler](cefpython.md#setglobalclienthandler)
* [SetOsModalLoop](cefpython.md#setosmodalloop)
* [Shutdown](cefpython.md#shutdown)
* [Command line switches](CommandLineSwitches.md#command-line-switches)
Expand Down
50 changes: 50 additions & 0 deletions api/AccessibilityHandler.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[API categories](API-categories.md) | [API index](API-index.md)


# AccessibilityHandler (interface)

This handler is for use only with off-screen rendering enabled.
See [RenderHandler](RenderHandler.md) for details.

Implement this interface to receive accessibility notification when
accessibility events have been registered. The methods of this class will
be called on the UI thread.

Callbacks in this interface are not associated with any specific browser,
thus you must call cefpython.[SetGlobalClientHandler] or
SetGlobalClientCallback() to use them. The callbacks names were prefixed
with "`_`" to distinguish this special behavior.

For an example of how to implement handler see [cefpython](cefpython.md).CreateBrowser(). For a list of all handler interfaces see [API > Client handlers](API#Client_handlers).


Table of contents:
* [Callbacks](#callbacks)
* [_OnAccessibilityTreeChange](#_onaccessibilitytreechange)
* [_OnAccessibilityLocationChange](#_onaccessibilitylocationchange)


## Callbacks


### _OnAccessibilityTreeChange

| Parameter | Type |
| --- | --- |
| value | list |
| __Return__ | void |

Called after renderer process sends accessibility tree changes to the
browser process.


### _OnAccessibilityLocationChange

| Parameter | Type |
| --- | --- |
| value | list |
| __Return__ | void |

Called after renderer process sends accessibility location changes to the
browser process.

39 changes: 39 additions & 0 deletions api/Browser.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Table of contents:
* [SendMouseWheelEvent](#sendmousewheelevent)
* [SendFocusEvent](#sendfocusevent)
* [SendCaptureLostEvent](#sendcapturelostevent)
* [SetAccessibilityState](#setaccessibilitystate)
* [SetClientCallback](#setclientcallback)
* [SetClientHandler](#setclienthandler)
* [SetFocus](#setfocus)
Expand Down Expand Up @@ -844,6 +845,44 @@ Send a focus event to the browser.
Send a capture lost event to the browser.


### SetAccessibilityState

| | |
| --- | --- |
| state | cef_state_t |
| __Return__ | void |

cef_state_t enum values defined in cefpython module:
- STATE_DEFAULT
- STATE_ENABLED
- STATE_DISABLED

Description from upstream CEF:
> Set accessibility state for all frames. |accessibility_state| may be
> default, enabled or disabled. If |accessibility_state| is STATE_DEFAULT
> then accessibility will be disabled by default and the state may be further
> controlled with the "force-renderer-accessibility" and
> "disable-renderer-accessibility" command-line switches. If
> |accessibility_state| is STATE_ENABLED then accessibility will be enabled.
> If |accessibility_state| is STATE_DISABLED then accessibility will be
> completely disabled.
>
> For windowed browsers accessibility will be enabled in Complete mode (which
> corresponds to kAccessibilityModeComplete in Chromium). In this mode all
> platform accessibility objects will be created and managed by Chromium's
> internal implementation. The client needs only to detect the screen reader
> and call this method appropriately. For example, on macOS the client can
> handle the @"AXEnhancedUserInterface" accessibility attribute to detect
> VoiceOver state changes and on Windows the client can handle WM_GETOBJECT
> with OBJID_CLIENT to detect accessibility readers.
>
> For windowless browsers accessibility will be enabled in TreeOnly mode
> (which corresponds to kAccessibilityModeWebContentsOnly in Chromium). In
> this mode renderer accessibility is enabled, the full tree is computed, and
> events are passed to CefAccessibiltyHandler, but platform accessibility
> objects are not created. The client may implement platform accessibility
> objects using CefAccessibiltyHandler callbacks if desired.
### SetClientCallback

| Parameter | Type |
Expand Down
21 changes: 20 additions & 1 deletion api/cefpython.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Table of contents:
* [PostDelayedTask](#postdelayedtask)
* [QuitMessageLoop](#quitmessageloop)
* [SetGlobalClientCallback](#setglobalclientcallback)
* [SetGlobalClientHandler](#setglobalclienthandler)
* [SetOsModalLoop](#setosmodalloop)
* [Shutdown](#shutdown)

Expand Down Expand Up @@ -133,7 +134,8 @@ Returns the [CommandLineSwitches](CommandLineSwitches.md) switch that was passed
| name | string |
| __Return__ | object |

Returns a global client callback that was set using SetGlobalClientCallback(). Returns None if callback was not set.
Returns a global client callback that was set using SetGlobalClientCallback()
or SetGlobalClientHandler. Returns None if callback was not set.


### GetModuleDirectory
Expand Down Expand Up @@ -290,6 +292,23 @@ Some client callbacks are not associated with any browser. In such case use this
Example of using SetGlobalClientCallback() is provided in the wxpython.py example.


### SetGlobalClientHandler

| Parameter | Type |
| --- | --- |
| handler | object |
| __Return__ | void |

Set client handler object (class instance). Its members will be inspected.
Private methods that are not meant to be callbacks should have their names
prepended with two underscores. Methods with single underscore or no
underscore are treated the same as client callbacks.

You can call this method multiple times to set many handlers. For
example you can create in your code several objects named AccessibilityHandler,
RequestHandler etc.


### SetOsModalLoop

| Parameter | Type |
Expand Down
4 changes: 4 additions & 0 deletions src/browser.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
include "cefpython.pyx"

cimport cef_types
from cef_types cimport cef_state_t
IF UNAME_SYSNAME == "Linux":
cimport x11

Expand Down Expand Up @@ -513,6 +514,9 @@ cdef class PyBrowser:
ELSE:
NonCriticalError("SetBounds() not implemented on this platform")

cpdef py_void SetAccessibilityState(self, cef_state_t state):
self.GetCefBrowserHost().get().SetAccessibilityState(state)

cpdef py_void SetFocus(self, enable):
self.GetCefBrowserHost().get().SetFocus(bool(enable))

Expand Down
9 changes: 9 additions & 0 deletions src/cef_types.pyx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2014 CEF Python, see the Authors file.
# All rights reserved. Licensed under BSD 3-clause license.
# Project website: https://github.com/cztomczak/cefpython

cimport cef_types

STATE_DEFAULT = cef_types.STATE_DEFAULT
STATE_ENABLED = cef_types.STATE_ENABLED
STATE_DISABLED = cef_types.STATE_DISABLED
15 changes: 9 additions & 6 deletions src/cef_v59..v66_changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ MISC
NEW FEATURES
------------

+ unittests/osr_test.py - new test for off-screen rendering mode

internal/cef_types.h
+ cef_log_severity_t: new key LOGSEVERITY_DEBUG (no need to expose,
same as LOGSEVERITY_VERBOSE, see code comments in setting.pyx
Expand All @@ -81,14 +83,15 @@ internal/cef_types.h
+ cef_referrer_policy_t changes (not exposed, info only)

cef_accessibility_handler.h
- CefAccessibilityHandler
- CefRenderHandler::GetAccessibilityHandler
+ CefAccessibilityHandler
+ CefRenderHandler::GetAccessibilityHandler
+ cefpython.SetGlobalClientHandler

cef_render_handler.h
- OnTextSelectionChanged

cef_browser.h
- SetAccessibilityState
+ SetAccessibilityState
- SetAutoResizeEnabled
- GetExtension
- IsBackgroundHost
Expand All @@ -101,9 +104,9 @@ cef_display_handler.h
- OnLoadingProgressChange

cef_drag_data.h
- GetImage (cross-platform)
- GetImageHotspot (cross-platform)
- HasImage (cross-platform)
+ GetImage (cross-platform)
+ GetImageHotspot (cross-platform)
+ HasImage (cross-platform)

cef_extension.h
- CefExtension
Expand Down
Loading

0 comments on commit e72609c

Please sign in to comment.