Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Unified Diff: content/renderer/accessibility/blink_ax_tree_source.h

Issue 2205083002: Optimize BlinkAXTreeSource by adding freeze/thaw for things like root, focus. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix pdf accessibility Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/renderer/accessibility/blink_ax_tree_source.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | content/renderer/accessibility/blink_ax_tree_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698