Chromium Code Reviews| Index: content/renderer/accessibility/blink_ax_tree_source.h |
| diff --git a/content/renderer/accessibility/blink_ax_tree_source.h b/content/renderer/accessibility/blink_ax_tree_source.h |
| index 90f7f152224750dd9b2545a09f512e6dc5880d9f..1ba5877bcbbcb08bea82426c077ebef4dfbd1fc4 100644 |
| --- a/content/renderer/accessibility/blink_ax_tree_source.h |
| +++ b/content/renderer/accessibility/blink_ax_tree_source.h |
| @@ -9,13 +9,28 @@ |
| #include "content/common/ax_content_node_data.h" |
| #include "third_party/WebKit/public/web/WebAXObject.h" |
| +#include "third_party/WebKit/public/web/WebDocument.h" |
| #include "ui/accessibility/ax_node_data.h" |
| #include "ui/accessibility/ax_tree_source.h" |
| namespace content { |
| +class BlinkAXTreeSource; |
| class RenderFrameImpl; |
| +// Create this on the stack to freeze BlinkAXTreeSource and automatically |
| +// un-freeze it when it goes out of scope. |
| +class ScopedFreezeBlinkAXTreeSource { |
| + public: |
| + explicit ScopedFreezeBlinkAXTreeSource(BlinkAXTreeSource* tree_source); |
| + ~ScopedFreezeBlinkAXTreeSource(); |
| + |
| + private: |
| + BlinkAXTreeSource* tree_source_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ScopedFreezeBlinkAXTreeSource); |
| +}; |
| + |
| class BlinkAXTreeSource |
| : public ui::AXTreeSource<blink::WebAXObject, |
| AXContentNodeData, |
| @@ -24,6 +39,13 @@ class BlinkAXTreeSource |
| BlinkAXTreeSource(RenderFrameImpl* render_frame); |
| ~BlinkAXTreeSource() override; |
| + // Freeze caches the document, accessibility root, and current focused |
| + // object for fast retrieval during a batch of operations. Use |
| + // ScopedFreezeBlinkAXTreeSource on the stack rather than calling |
| +// these directly. |
| + void Freeze(); |
| + void Thaw(); |
| + |
| // It may be necessary to call SetRoot if you're using a WebScopedAXContext, |
| // because BlinkAXTreeSource can't get the root of the tree from the |
| // WebDocument if accessibility isn't enabled globally. |
| @@ -58,9 +80,18 @@ class BlinkAXTreeSource |
| private: |
| RenderFrameImpl* render_frame_; |
| - blink::WebAXObject root_; |
| + // An explicit root to use, otherwise it's taken from the WebDocument. |
| + blink::WebAXObject explicit_root_; |
| + |
| + // The id of the object with accessibility focus. |
| int accessibility_focus_id_; |
|
David Tseng
2016/09/07 18:59:27
Can you remove this now that you keep around |focu
dmazzoni
2016/09/08 05:26:43
No, because on Android we still use accessibility
|
| + |
| + // These are updated when calling |Freeze|. |
| + bool frozen_; |
| + blink::WebDocument document_; |
| + blink::WebAXObject root_; |
| + blink::WebAXObject focus_; |
|
David Tseng
2016/09/07 18:59:27
Suggestion: can we get a property accesser for thi
dmazzoni
2016/09/08 05:26:43
Sure, good idea
|
| }; |
| } // namespace content |