mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-17 04:30:46 +01:00
Windows: cefclient: Fix accessibility where TreeId type has changed from int to string
This commit is contained in:
parent
261a8899fc
commit
ea1324a9f1
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
namespace client {
|
namespace client {
|
||||||
|
|
||||||
OsrAXTree::OsrAXTree() : parent_tree_id_(-1), root_node_id_(-1) {}
|
OsrAXTree::OsrAXTree() : root_node_id_(-1) {}
|
||||||
|
|
||||||
OsrAXNode* OsrAXTree::GetNode(int nodeId) const {
|
OsrAXNode* OsrAXTree::GetNode(int nodeId) const {
|
||||||
auto result = node_map_.find(nodeId);
|
auto result = node_map_.find(nodeId);
|
||||||
@ -27,10 +27,9 @@ void OsrAXTree::AddNode(OsrAXNode* node) {
|
|||||||
|
|
||||||
void OsrAXTree::UpdateTreeData(CefRefPtr<CefDictionaryValue> value) {
|
void OsrAXTree::UpdateTreeData(CefRefPtr<CefDictionaryValue> value) {
|
||||||
if (value->HasKey("parent_tree_id")) {
|
if (value->HasKey("parent_tree_id")) {
|
||||||
parent_tree_id_ =
|
parent_tree_id_ = value->GetString("parent_tree_id");
|
||||||
OsrAccessibilityHelper::CastToInt(value->GetValue("parent_tree_id"));
|
|
||||||
} else {
|
} else {
|
||||||
parent_tree_id_ = -1;
|
parent_tree_id_ = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// may also update following:
|
// may also update following:
|
||||||
@ -39,9 +38,7 @@ void OsrAXTree::UpdateTreeData(CefRefPtr<CefDictionaryValue> value) {
|
|||||||
|
|
||||||
OsrAccessibilityHelper::OsrAccessibilityHelper(CefRefPtr<CefValue> value,
|
OsrAccessibilityHelper::OsrAccessibilityHelper(CefRefPtr<CefValue> value,
|
||||||
CefRefPtr<CefBrowser> browser)
|
CefRefPtr<CefBrowser> browser)
|
||||||
: root_tree_id_(-1),
|
: focused_node_id_(-1),
|
||||||
focused_tree_id_(-1),
|
|
||||||
focused_node_id_(-1),
|
|
||||||
browser_(browser) {
|
browser_(browser) {
|
||||||
UpdateAccessibilityTree(value);
|
UpdateAccessibilityTree(value);
|
||||||
}
|
}
|
||||||
@ -75,7 +72,7 @@ void OsrAccessibilityHelper::UpdateAccessibilityLocation(
|
|||||||
!locationChangeDict->HasKey("id")) {
|
!locationChangeDict->HasKey("id")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int treeId = CastToInt(locationChangeDict->GetValue("ax_tree_id"));
|
CefString treeId = locationChangeDict->GetString("ax_tree_id");
|
||||||
int nodeId = CastToInt(locationChangeDict->GetValue("id"));
|
int nodeId = CastToInt(locationChangeDict->GetValue("id"));
|
||||||
|
|
||||||
CefRefPtr<CefDictionaryValue> newLocationDict =
|
CefRefPtr<CefDictionaryValue> newLocationDict =
|
||||||
@ -103,7 +100,7 @@ void OsrAccessibilityHelper::UpdateAccessibilityTree(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int treeId = CastToInt(mainDict->GetValue("ax_tree_id"));
|
CefString treeId = mainDict->GetString("ax_tree_id");
|
||||||
CefRefPtr<CefListValue> updatesList = mainDict->GetList("updates");
|
CefRefPtr<CefListValue> updatesList = mainDict->GetList("updates");
|
||||||
|
|
||||||
size_t updatesCount = updatesList->GetSize();
|
size_t updatesCount = updatesList->GetSize();
|
||||||
@ -130,7 +127,8 @@ OsrAXNode* OsrAccessibilityHelper::GetFocusedNode() const {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
OsrAXNode* OsrAccessibilityHelper::GetTreeRootNode(int treeId) const {
|
OsrAXNode* OsrAccessibilityHelper::GetTreeRootNode(
|
||||||
|
const CefString& treeId) const {
|
||||||
auto tree = accessibility_node_map_.find(treeId);
|
auto tree = accessibility_node_map_.find(treeId);
|
||||||
if (tree != accessibility_node_map_.end()) {
|
if (tree != accessibility_node_map_.end()) {
|
||||||
return tree->second.GetNode(tree->second.GetRootNodeId());
|
return tree->second.GetNode(tree->second.GetRootNodeId());
|
||||||
@ -140,7 +138,7 @@ OsrAXNode* OsrAccessibilityHelper::GetTreeRootNode(int treeId) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OsrAccessibilityHelper::UpdateLayout(
|
void OsrAccessibilityHelper::UpdateLayout(
|
||||||
int treeId,
|
const CefString& treeId,
|
||||||
CefRefPtr<CefDictionaryValue> update) {
|
CefRefPtr<CefDictionaryValue> update) {
|
||||||
if (!update) {
|
if (!update) {
|
||||||
return;
|
return;
|
||||||
@ -154,12 +152,12 @@ void OsrAccessibilityHelper::UpdateLayout(
|
|||||||
auto tree = accessibility_node_map_.find(treeId);
|
auto tree = accessibility_node_map_.find(treeId);
|
||||||
if (tree != accessibility_node_map_.end()) {
|
if (tree != accessibility_node_map_.end()) {
|
||||||
if (tree->second.GetRootNodeId() == nodeId) {
|
if (tree->second.GetRootNodeId() == nodeId) {
|
||||||
root_tree_id_ = -1;
|
root_tree_id_ = "";
|
||||||
tree->second.SetRootNodeId(-1);
|
tree->second.SetRootNodeId(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((focused_tree_id_ == treeId) && (focused_node_id_ == nodeId)) {
|
if ((focused_tree_id_ == treeId) && (focused_node_id_ == nodeId)) {
|
||||||
UpdateFocusedNode(-1, -1);
|
UpdateFocusedNode("", -1);
|
||||||
}
|
}
|
||||||
OsrAXNode* node = GetNode(treeId, nodeId);
|
OsrAXNode* node = GetNode(treeId, nodeId);
|
||||||
DestroyNode(node);
|
DestroyNode(node);
|
||||||
@ -172,11 +170,11 @@ void OsrAccessibilityHelper::UpdateLayout(
|
|||||||
update->GetDictionary("tree_data");
|
update->GetDictionary("tree_data");
|
||||||
auto& tree = accessibility_node_map_[treeId];
|
auto& tree = accessibility_node_map_[treeId];
|
||||||
tree.UpdateTreeData(tree_data);
|
tree.UpdateTreeData(tree_data);
|
||||||
if (tree.GetParentTreeId() == -1) {
|
if (tree.GetParentTreeId().empty()) {
|
||||||
root_tree_id_ = treeId;
|
root_tree_id_ = treeId;
|
||||||
}
|
}
|
||||||
if (tree_data->HasKey("focus_id") && tree_data->HasKey("focused_tree_id")) {
|
if (tree_data->HasKey("focus_id") && tree_data->HasKey("focused_tree_id")) {
|
||||||
UpdateFocusedNode(CastToInt(tree_data->GetValue("focused_tree_id")),
|
UpdateFocusedNode(tree_data->GetString("focused_tree_id"),
|
||||||
CastToInt(tree_data->GetValue("focus_id")));
|
CastToInt(tree_data->GetValue("focus_id")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -212,7 +210,8 @@ void OsrAccessibilityHelper::UpdateLayout(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OsrAccessibilityHelper::UpdateFocusedNode(int treeId, int nodeId) {
|
void OsrAccessibilityHelper::UpdateFocusedNode(const CefString& treeId,
|
||||||
|
int nodeId) {
|
||||||
if ((focused_tree_id_ == treeId) && (focused_node_id_ == nodeId)) {
|
if ((focused_tree_id_ == treeId) && (focused_node_id_ == nodeId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -228,13 +227,14 @@ void OsrAccessibilityHelper::UpdateFocusedNode(int treeId, int nodeId) {
|
|||||||
|
|
||||||
void OsrAccessibilityHelper::Reset() {
|
void OsrAccessibilityHelper::Reset() {
|
||||||
accessibility_node_map_.clear();
|
accessibility_node_map_.clear();
|
||||||
root_tree_id_ = -1;
|
root_tree_id_ = "";
|
||||||
focused_tree_id_ = focused_node_id_ = -1;
|
focused_tree_id_ = "";
|
||||||
|
focused_node_id_ = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OsrAccessibilityHelper::DestroyNode(OsrAXNode* node) {
|
void OsrAccessibilityHelper::DestroyNode(OsrAXNode* node) {
|
||||||
if (node) {
|
if (node) {
|
||||||
int treeId = node->OsrAXTreeId();
|
CefString treeId = node->OsrAXTreeId();
|
||||||
int numChilds = node->GetChildCount();
|
int numChilds = node->GetChildCount();
|
||||||
if (numChilds > 0) {
|
if (numChilds > 0) {
|
||||||
for (int i = 0; i < numChilds; i++) {
|
for (int i = 0; i < numChilds; i++) {
|
||||||
@ -257,7 +257,8 @@ void OsrAccessibilityHelper::DestroyNode(OsrAXNode* node) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OsrAXNode* OsrAccessibilityHelper::GetNode(int treeId, int nodeId) const {
|
OsrAXNode* OsrAccessibilityHelper::GetNode(const CefString& treeId,
|
||||||
|
int nodeId) const {
|
||||||
auto tree = accessibility_node_map_.find(treeId);
|
auto tree = accessibility_node_map_.find(treeId);
|
||||||
if (tree != accessibility_node_map_.end()) {
|
if (tree != accessibility_node_map_.end()) {
|
||||||
return tree->second.GetNode(nodeId);
|
return tree->second.GetNode(nodeId);
|
||||||
|
@ -21,12 +21,12 @@ class OsrAXTree {
|
|||||||
void EraseNode(int nodeId);
|
void EraseNode(int nodeId);
|
||||||
void UpdateTreeData(CefRefPtr<CefDictionaryValue> value);
|
void UpdateTreeData(CefRefPtr<CefDictionaryValue> value);
|
||||||
void AddNode(OsrAXNode* node);
|
void AddNode(OsrAXNode* node);
|
||||||
int GetParentTreeId() const { return parent_tree_id_; }
|
const CefString& GetParentTreeId() const { return parent_tree_id_; }
|
||||||
int GetRootNodeId() const { return root_node_id_; }
|
int GetRootNodeId() const { return root_node_id_; }
|
||||||
void SetRootNodeId(int nodeId) { root_node_id_ = nodeId; }
|
void SetRootNodeId(int nodeId) { root_node_id_ = nodeId; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int parent_tree_id_;
|
CefString parent_tree_id_;
|
||||||
int root_node_id_;
|
int root_node_id_;
|
||||||
std::map<int, OsrAXNode*> node_map_;
|
std::map<int, OsrAXNode*> node_map_;
|
||||||
};
|
};
|
||||||
@ -53,26 +53,27 @@ class OsrAccessibilityHelper {
|
|||||||
|
|
||||||
CefRefPtr<CefBrowser> GetBrowser() const { return browser_; }
|
CefRefPtr<CefBrowser> GetBrowser() const { return browser_; }
|
||||||
|
|
||||||
OsrAXNode* GetNode(int treeId, int nodeId) const;
|
OsrAXNode* GetNode(const CefString& treeId, int nodeId) const;
|
||||||
|
|
||||||
OsrAXNode* GetTreeRootNode(int treeId) const;
|
OsrAXNode* GetTreeRootNode(const CefString& treeId) const;
|
||||||
|
|
||||||
static int CastToInt(CefRefPtr<CefValue> value);
|
static int CastToInt(CefRefPtr<CefValue> value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
||||||
void UpdateLayout(int treeId, CefRefPtr<CefDictionaryValue> update);
|
void UpdateLayout(const CefString& treeId,
|
||||||
|
CefRefPtr<CefDictionaryValue> update);
|
||||||
|
|
||||||
void UpdateFocusedNode(int treeId, int nodeId);
|
void UpdateFocusedNode(const CefString& treeId, int nodeId);
|
||||||
|
|
||||||
// Destroy the node and remove from Map
|
// Destroy the node and remove from Map
|
||||||
void DestroyNode(OsrAXNode* node);
|
void DestroyNode(OsrAXNode* node);
|
||||||
int root_tree_id_;
|
CefString root_tree_id_;
|
||||||
int focused_tree_id_;
|
CefString focused_tree_id_;
|
||||||
int focused_node_id_;
|
int focused_node_id_;
|
||||||
CefRefPtr<CefBrowser> browser_;
|
CefRefPtr<CefBrowser> browser_;
|
||||||
std::map<int, OsrAXTree> accessibility_node_map_;
|
std::map<CefString, OsrAXTree> accessibility_node_map_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace client
|
} // namespace client
|
||||||
|
@ -11,13 +11,12 @@
|
|||||||
|
|
||||||
namespace client {
|
namespace client {
|
||||||
|
|
||||||
OsrAXNode::OsrAXNode(int treeId,
|
OsrAXNode::OsrAXNode(const CefString& treeId,
|
||||||
int nodeId,
|
int nodeId,
|
||||||
CefRefPtr<CefDictionaryValue> value,
|
CefRefPtr<CefDictionaryValue> value,
|
||||||
OsrAccessibilityHelper* helper)
|
OsrAccessibilityHelper* helper)
|
||||||
: tree_id_(treeId),
|
: tree_id_(treeId),
|
||||||
node_id_(nodeId),
|
node_id_(nodeId),
|
||||||
child_tree_id_(-1),
|
|
||||||
platform_accessibility_(nullptr),
|
platform_accessibility_(nullptr),
|
||||||
parent_(nullptr),
|
parent_(nullptr),
|
||||||
offset_container_id_(-1),
|
offset_container_id_(-1),
|
||||||
@ -68,7 +67,7 @@ void OsrAXNode::UpdateValue(CefRefPtr<CefDictionaryValue> value) {
|
|||||||
}
|
}
|
||||||
// Update attributes
|
// Update attributes
|
||||||
if (value->HasKey("attributes")) {
|
if (value->HasKey("attributes")) {
|
||||||
child_tree_id_ = -1;
|
child_tree_id_ = "";
|
||||||
|
|
||||||
attributes_ = value->GetDictionary("attributes");
|
attributes_ = value->GetDictionary("attributes");
|
||||||
|
|
||||||
@ -84,8 +83,7 @@ void OsrAXNode::UpdateValue(CefRefPtr<CefDictionaryValue> value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (attributes_ && attributes_->HasKey("childTreeId")) {
|
if (attributes_ && attributes_->HasKey("childTreeId")) {
|
||||||
child_tree_id_ = OsrAccessibilityHelper::CastToInt(
|
child_tree_id_ = attributes_->GetString("childTreeId");
|
||||||
attributes_->GetValue("childTreeId"));
|
|
||||||
}
|
}
|
||||||
if (attributes_ && attributes_->HasKey("name"))
|
if (attributes_ && attributes_->HasKey("name"))
|
||||||
name_ = attributes_->GetString("name");
|
name_ = attributes_->GetString("name");
|
||||||
@ -139,7 +137,7 @@ CefRect OsrAXNode::AxLocation() const {
|
|||||||
|
|
||||||
int OsrAXNode::GetChildCount() const {
|
int OsrAXNode::GetChildCount() const {
|
||||||
int count = static_cast<int>(child_ids_.size());
|
int count = static_cast<int>(child_ids_.size());
|
||||||
if (child_tree_id_ >= 0) {
|
if (!child_tree_id_.empty()) {
|
||||||
OsrAXNode* childTreeRootNode =
|
OsrAXNode* childTreeRootNode =
|
||||||
accessibility_helper_->GetTreeRootNode(child_tree_id_);
|
accessibility_helper_->GetTreeRootNode(child_tree_id_);
|
||||||
if (childTreeRootNode) {
|
if (childTreeRootNode) {
|
||||||
@ -153,7 +151,7 @@ OsrAXNode* OsrAXNode::ChildAtIndex(int index) const {
|
|||||||
int count = static_cast<int>(child_ids_.size());
|
int count = static_cast<int>(child_ids_.size());
|
||||||
if (index < count)
|
if (index < count)
|
||||||
return accessibility_helper_->GetNode(OsrAXTreeId(), child_ids_[index]);
|
return accessibility_helper_->GetNode(OsrAXTreeId(), child_ids_[index]);
|
||||||
if ((index == count) && (child_tree_id_ >= 0)) {
|
if ((index == count) && (!child_tree_id_.empty())) {
|
||||||
OsrAXNode* childTreeRootNode =
|
OsrAXNode* childTreeRootNode =
|
||||||
accessibility_helper_->GetTreeRootNode(child_tree_id_);
|
accessibility_helper_->GetTreeRootNode(child_tree_id_);
|
||||||
if (childTreeRootNode) {
|
if (childTreeRootNode) {
|
||||||
@ -165,7 +163,7 @@ OsrAXNode* OsrAXNode::ChildAtIndex(int index) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create and return the platform specific OsrAXNode Object
|
// Create and return the platform specific OsrAXNode Object
|
||||||
OsrAXNode* OsrAXNode::CreateNode(int treeId,
|
OsrAXNode* OsrAXNode::CreateNode(const CefString& treeId,
|
||||||
int nodeId,
|
int nodeId,
|
||||||
CefRefPtr<CefDictionaryValue> value,
|
CefRefPtr<CefDictionaryValue> value,
|
||||||
OsrAccessibilityHelper* helper) {
|
OsrAccessibilityHelper* helper) {
|
||||||
|
@ -40,7 +40,7 @@ class OsrAccessibilityHelper;
|
|||||||
class OsrAXNode {
|
class OsrAXNode {
|
||||||
public:
|
public:
|
||||||
// Create and return the platform specific OsrAXNode Object.
|
// Create and return the platform specific OsrAXNode Object.
|
||||||
static OsrAXNode* CreateNode(int treeId,
|
static OsrAXNode* CreateNode(const CefString& treeId,
|
||||||
int nodeId,
|
int nodeId,
|
||||||
CefRefPtr<CefDictionaryValue> value,
|
CefRefPtr<CefDictionaryValue> value,
|
||||||
OsrAccessibilityHelper* helper);
|
OsrAccessibilityHelper* helper);
|
||||||
@ -77,7 +77,7 @@ class OsrAXNode {
|
|||||||
|
|
||||||
const CefString& AxRole() const { return role_; }
|
const CefString& AxRole() const { return role_; }
|
||||||
|
|
||||||
int OsrAXTreeId() const { return tree_id_; }
|
const CefString& OsrAXTreeId() const { return tree_id_; }
|
||||||
|
|
||||||
int OsrAXNodeId() const { return node_id_; }
|
int OsrAXNodeId() const { return node_id_; }
|
||||||
|
|
||||||
@ -96,14 +96,14 @@ class OsrAXNode {
|
|||||||
void SetParent(OsrAXNode* parent);
|
void SetParent(OsrAXNode* parent);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
OsrAXNode(int treeId,
|
OsrAXNode(const CefString& treeId,
|
||||||
int nodeId,
|
int nodeId,
|
||||||
CefRefPtr<CefDictionaryValue> value,
|
CefRefPtr<CefDictionaryValue> value,
|
||||||
OsrAccessibilityHelper* helper);
|
OsrAccessibilityHelper* helper);
|
||||||
|
|
||||||
int tree_id_;
|
CefString tree_id_;
|
||||||
int node_id_;
|
int node_id_;
|
||||||
int child_tree_id_;
|
CefString child_tree_id_;
|
||||||
CefString role_;
|
CefString role_;
|
||||||
CefString value_;
|
CefString value_;
|
||||||
CefString name_;
|
CefString name_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user