Flutter Engine
The Flutter Engine
ax_platform_node.cc
Go to the documentation of this file.
1// Copyright 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#include "ax_platform_node.h"
6
7#include "ax/ax_node_data.h"
10
11namespace ui {
12
13std::vector<AXModeObserver*> AXPlatformNode::ax_mode_observers_;
14
15std::function<AXPlatformNode::NativeWindowHandlerCallback>
16 AXPlatformNode::native_window_handler_;
17// static
18AXMode AXPlatformNode::ax_mode_;
19
20// static
21gfx::NativeViewAccessible AXPlatformNode::popup_focus_override_ = nullptr;
22
23// static
25 gfx::NativeWindow native_window) {
26 if (native_window_handler_)
27 return native_window_handler_(native_window);
28 return nullptr;
29}
30
32 std::function<AXPlatformNode::NativeWindowHandlerCallback> handler) {
33 native_window_handler_ = handler;
34}
35
37
39
41
44 return GetDelegate() ? GetDelegate()->GetUniqueId().Get() : -1;
45}
46
48 is_primary_web_contents_for_window_ = is_primary;
49}
50
52 return is_primary_web_contents_for_window_;
53}
54
56 return GetDelegate() ? GetDelegate()->ToString() : "No delegate";
57}
58
60 return GetDelegate() ? GetDelegate()->SubtreeToString() : "No delegate";
61}
62
63std::ostream& operator<<(std::ostream& stream, AXPlatformNode& node) {
64 return stream << node.ToString();
65}
66
67// static
69 ax_mode_observers_.push_back(observer);
70}
71
72// static
74 ax_mode_observers_.erase(std::find(ax_mode_observers_.begin(),
75 ax_mode_observers_.end(), observer));
76}
77
78// static
80 // Note: this is only called on Windows.
81 AXMode new_ax_mode(ax_mode_);
82 new_ax_mode |= mode_flags;
83
84 if (new_ax_mode == ax_mode_)
85 return; // No change.
86
87 ax_mode_ = new_ax_mode;
88 for (AXModeObserver* observer : ax_mode_observers_)
89 observer->OnAXModeAdded(mode_flags);
90}
91
92// static
94 gfx::NativeViewAccessible popup_focus_override) {
95 popup_focus_override_ = popup_focus_override;
96}
97
98// static
100 return popup_focus_override_;
101}
102
103} // namespace ui
int find(T *array, int N, T item)
virtual const AXUniqueId & GetUniqueId() const =0
static void RemoveAXModeObserver(AXModeObserver *observer)
static gfx::NativeViewAccessible GetPopupFocusOverride()
static void RegisterNativeWindowHandler(std::function< NativeWindowHandlerCallback > handler)
static AXPlatformNode * FromNativeWindow(gfx::NativeWindow native_window)
virtual AXPlatformNodeDelegate * GetDelegate() const =0
std::string SubtreeToString()
virtual void Destroy()
static void AddAXModeObserver(AXModeObserver *observer)
int32_t GetUniqueId() const
void SetIsPrimaryWebContentsForWindow(bool is_primary)
static void NotifyAddAXModeFlags(AXMode mode_flags)
std::string ToString()
bool IsPrimaryWebContentsForWindow() const
static void SetPopupFocusOverride(gfx::NativeViewAccessible focus_override)
int32_t Get() const
Definition: ax_unique_id.h:30
UnimplementedNativeViewAccessible * NativeViewAccessible
std::ostream & operator<<(std::ostream &os, AXEventGenerator::Event event)
#define BASE_DCHECK(condition)
Definition: logging.h:63