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

Unified Diff: content/browser/accessibility/frame_tree_accessibility.h

Issue 252253002: Implement initial support for nesting one ax tree in another. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address feedback Created 6 years, 7 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
Index: content/browser/accessibility/frame_tree_accessibility.h
diff --git a/content/browser/accessibility/frame_tree_accessibility.h b/content/browser/accessibility/frame_tree_accessibility.h
new file mode 100644
index 0000000000000000000000000000000000000000..2b16b64826a0babca2ef099d0fab30cba3d9238f
--- /dev/null
+++ b/content/browser/accessibility/frame_tree_accessibility.h
@@ -0,0 +1,83 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_ACCESSIBILITY_FRAME_TREE_ACCESSIBILITY_H_
+#define CONTENT_BROWSER_ACCESSIBILITY_FRAME_TREE_ACCESSIBILITY_H_
+
+#include "base/basictypes.h"
+#include "base/containers/hash_tables.h"
+#include "base/memory/singleton.h"
+#include "content/browser/accessibility/browser_accessibility_manager.h"
+#include "content/common/content_export.h"
+
+#if defined(COMPILER_GCC)
+namespace BASE_HASH_NAMESPACE {
+
+template<>
+struct hash<content::BrowserAccessibilityDelegate*> {
+ std::size_t operator()(content::BrowserAccessibilityDelegate* const& ptr)
+ const {
+ return hash<size_t>()(reinterpret_cast<size_t>(ptr));
+ }
+};
+
+} // namespace __gnu_cxx
aboxhall 2014/05/06 15:41:27 BASE_HASH_NAMESPACE?
+
+#elif defined(COMPILER_MSVC)
+namespace stdext {
+
+template<>
+inline size_t hash_value(content::BrowserAccessibilityDelegate* const& ptr) {
+ return hash_value(reinterpret_cast<size_t>(ptr));
+}
+
+} // namespace stdext
+
+#endif // COMPILER
+
+namespace content {
+
+extern const uint32 kNoFrameId;
+
+// This singleton manages relationships between accessibility trees that are
+// nested in other accessibility trees, due to a <webview> element or
+// an out-of-process iframe. Every accessible frame is identified by its
+// host BrowserAccessibilityDelegate and given a unique id.
+class CONTENT_EXPORT FrameTreeAccessibility {
+ public:
+ // Get the single instance of this class.
+ static FrameTreeAccessibility* GetInstance();
+
+ // The class that implements BrowserAccessibilityDelegate registers each
+ // frame on creation and unregisters it on deletion, and associates a
+ // BrowserAccessibilityManager with a frame.
+ void OnFrameCreated(BrowserAccessibilityDelegate* frame);
+ void OnFrameDeleted(BrowserAccessibilityDelegate* frame);
+ void SetFrameAccessibilityManager(BrowserAccessibilityDelegate* frame,
+ BrowserAccessibilityManager* manager);
+
+ // When a node in an accessible tree contains a reference to an accessible
+ // frame, it can be looked up here. Note that it's not safe to hold onto a
+ // reference to a BrowserAccessibilityDelegate or BrowserAccessibilityManager
+ // because they could be subsequently deleted.
+ uint32 GetFrameId(BrowserAccessibilityDelegate* frame);
+ BrowserAccessibilityDelegate* FindFrameById(uint32 id);
+ BrowserAccessibilityManager* FindAccessibilityManagerById(uint32 id);
+
+ protected:
+ FrameTreeAccessibility();
+ ~FrameTreeAccessibility();
+
+ private:
+ uint32 next_id_;
+ base::hash_map<BrowserAccessibilityDelegate*, uint32> frame_to_id_;
+ base::hash_map<uint32, BrowserAccessibilityDelegate*> id_to_frame_;
+ base::hash_map<uint32, BrowserAccessibilityManager*> id_to_manager_;
+
+ friend struct DefaultSingletonTraits<FrameTreeAccessibility>;
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_ACCESSIBILITY_FRAME_TREE_ACCESSIBILITY_H_

Powered by Google App Engine
This is Rietveld 408576698