| 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..2f4001c558015deef532eb487f86d43037451c0c 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.
|
| @@ -57,10 +79,34 @@ class BlinkAXTreeSource
|
| blink::WebDocument GetMainDocument() const;
|
|
|
| private:
|
| + const blink::WebDocument& document() const {
|
| + DCHECK(frozen_);
|
| + return document_;
|
| + }
|
| + const blink::WebAXObject& root() const {
|
| + DCHECK(frozen_);
|
| + return root_;
|
| + }
|
| + const blink::WebAXObject& focus() const {
|
| + DCHECK(frozen_);
|
| + return focus_;
|
| + }
|
| +
|
| + blink::WebAXObject ComputeRoot() const;
|
| +
|
| 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_;
|
| +
|
| + // These are updated when calling |Freeze|.
|
| + bool frozen_;
|
| + blink::WebDocument document_;
|
| + blink::WebAXObject root_;
|
| + blink::WebAXObject focus_;
|
| };
|
|
|
| } // namespace content
|
|
|