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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_ACCESSIBILITY_FRAME_TREE_ACCESSIBILITY_H_
6 #define CONTENT_BROWSER_ACCESSIBILITY_FRAME_TREE_ACCESSIBILITY_H_
7
8 #include "base/basictypes.h"
9 #include "base/containers/hash_tables.h"
10 #include "base/memory/singleton.h"
11 #include "content/browser/accessibility/browser_accessibility_manager.h"
12 #include "content/common/content_export.h"
13
14 #if defined(COMPILER_GCC)
15 namespace BASE_HASH_NAMESPACE {
16
17 template<>
18 struct hash<content::BrowserAccessibilityDelegate*> {
19 std::size_t operator()(content::BrowserAccessibilityDelegate* const& ptr)
20 const {
21 return hash<size_t>()(reinterpret_cast<size_t>(ptr));
22 }
23 };
24
25 } // namespace __gnu_cxx
26
27 #elif defined(COMPILER_MSVC)
28 namespace stdext {
29
30 template<>
31 inline size_t hash_value(content::BrowserAccessibilityDelegate* const& ptr) {
32 return hash_value(reinterpret_cast<size_t>(ptr));
33 }
34
35 } // namespace stdext
36
37 #endif // COMPILER
38
39 namespace content {
40
41 // This singleton manages relationships between accessibility trees that are
42 // nested in other accessibility trees, due to a <webview> element or
43 // an out-of-process iframe. Every accessible frame is identified by its
44 // host BrowserAccessibilityDelegate and given a unique id.
45 class CONTENT_EXPORT FrameTreeAccessibility {
46 public:
47 // Get the single instance of this class.
48 static FrameTreeAccessibility* GetInstance();
49
50 // The class that implements BrowserAccessibilityDelegate registers each
51 // frame on creation and unregisters it on deletion, and associates a
52 // BrowserAccessibilityManager with a frame.
53 void OnFrameCreated(BrowserAccessibilityDelegate* frame);
54 void OnFrameDeleted(BrowserAccessibilityDelegate* frame);
55 void SetFrameAccessibilityManager(BrowserAccessibilityDelegate* frame,
56 BrowserAccessibilityManager* manager);
57
58 // When a node in an accessible tree contains a reference to an accessible
59 // frame, it can be looked up here. Note that it's not safe to hold onto a
60 // reference to a BrowserAccessibilityDelegate or BrowserAccessibilityManager
61 // because they could be subsequently deleted.
62 int32 GetFrameId(BrowserAccessibilityDelegate* frame);
63 BrowserAccessibilityDelegate* FindFrameById(int32 id);
64 BrowserAccessibilityManager* FindAccessibilityManagerById(int32 id);
65
66 protected:
67 FrameTreeAccessibility();
68 ~FrameTreeAccessibility();
69
70 private:
71 int next_id_;
72 base::hash_map<BrowserAccessibilityDelegate*, int32> frame_to_id_;
73 base::hash_map<int32, BrowserAccessibilityDelegate*> id_to_frame_;
74 base::hash_map<int32, BrowserAccessibilityManager*> id_to_manager_;
75
76 friend struct DefaultSingletonTraits<FrameTreeAccessibility>;
77 };
78
79 } // namespace content
80
81 #endif // CONTENT_BROWSER_ACCESSIBILITY_FRAME_TREE_ACCESSIBILITY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698