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

Unified Diff: ui/accessibility/platform/ax_platform_node.cc

Issue 420653003: MacViews: Accessibility bridge (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 2nd draft, based on 423513005 Created 6 years, 5 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: ui/accessibility/platform/ax_platform_node.cc
diff --git a/ui/accessibility/platform/ax_platform_node.cc b/ui/accessibility/platform/ax_platform_node.cc
index ad4aa4c09e65bad997d79375aac330975cdf46a5..0cbfc06dd66fb6062c85bab56b1bed772888cb0f 100644
--- a/ui/accessibility/platform/ax_platform_node.cc
+++ b/ui/accessibility/platform/ax_platform_node.cc
@@ -3,16 +3,16 @@
// found in the LICENSE file.
#include "ui/accessibility/platform/ax_platform_node.h"
+
+#include "ui/accessibility/ax_node_data.h"
#include "ui/accessibility/platform/ax_platform_node_delegate.h"
namespace ui {
-#if !defined(OS_WIN)
+#if !defined(OS_MACOSX)
// static
AXPlatformNode* AXPlatformNode::Create(AXPlatformNodeDelegate* delegate) {
- AXPlatformNode* node = new AXPlatformNode();
- node->Init(delegate);
- return node;
+ return NULL;
}
#endif
@@ -30,301 +30,26 @@ void AXPlatformNode::Detach() {
delegate_ = NULL;
}
-gfx::NativeViewAccessible AXPlatformNode::GetNativeViewAccessible() {
- return NULL;
-}
-
-AXPlatformNode* AXPlatformNode::NextSibling() {
- if (!delegate_)
- return NULL;
-
- AXPlatformNode* parent = delegate_->GetParent();
- if (!parent)
- return NULL;
-
- int next_index = delegate_->GetIndexInParent() + 1;
- if (next_index >= 0 && next_index < parent->GetChildCount())
- return parent->ChildAtIndex(next_index);
-
- return NULL;
-}
-
-AXPlatformNode* AXPlatformNode::PreviousSibling() {
- if (!delegate_)
- return NULL;
-
- AXPlatformNode* parent = delegate_->GetParent();
- if (!parent)
- return NULL;
-
- int previous_index = delegate_->GetIndexInParent() - 1;
- if (previous_index >= 0 && previous_index < parent->GetChildCount())
- return parent->ChildAtIndex(previous_index);
-
- return NULL;
+AXRole AXPlatformNode::GetRole() const {
+ return delegate_ ? delegate_->GetData()->role : AX_ROLE_UNKNOWN;
}
-bool AXPlatformNode::HasBoolAttribute(
- ui::AXBoolAttribute attribute) const {
- ui::AXNodeData* data = delegate_->GetData();
- if (!data)
- return false;
-
- for (size_t i = 0; i < data.bool_attributes.size(); ++i) {
- if (data.bool_attributes[i].first == attribute)
- return true;
- }
-
- return false;
+gfx::Rect AXPlatformNode::GetBoundsInScreen() const {
+ gfx::Rect bounds = delegate_->GetData()->location;
dmazzoni 2014/07/29 06:35:14 Check delegate_ for NULL everywhere
Andre 2014/07/29 21:58:56 Done.
+ bounds.Offset(delegate_->GetGlobalCoordinateOffset());
+ return bounds;
}
-
-bool AXPlatformNode::GetBoolAttribute(
- ui::AXBoolAttribute attribute) const {
- ui::AXNodeData* data = delegate_->GetData();
- if (!data)
- return false;
-
- for (size_t i = 0; i < data.bool_attributes.size(); ++i) {
- if (data.bool_attributes[i].first == attribute)
- return data.bool_attributes[i].second;
- }
-
- return false;
+gfx::NativeViewAccessible AXPlatformNode::GetParent() {
+ return delegate_ ? delegate_->GetParent() : NULL;
}
-bool AXPlatformNode::GetBoolAttribute(
- ui::AXBoolAttribute attribute, bool* value) const {
- ui::AXNodeData* data = delegate_->GetData();
- if (!data)
- return false;
-
- for (size_t i = 0; i < data.bool_attributes.size(); ++i) {
- if (data.bool_attributes[i].first == attribute) {
- *value = data.bool_attributes[i].second;
- return true;
- }
- }
-
- return false;
-}
-
-bool AXPlatformNode::HasFloatAttribute(
- ui::AXFloatAttribute attribute) const {
- ui::AXNodeData* data = delegate_->GetData();
- if (!data)
- return false;
-
- for (size_t i = 0; i < data.float_attributes.size(); ++i) {
- if (data.float_attributes[i].first == attribute)
- return true;
- }
-
- return false;
-}
-
-float AXPlatformNode::GetFloatAttribute(
- ui::AXFloatAttribute attribute) const {
- ui::AXNodeData* data = delegate_->GetData();
- if (!data)
- return false;
-
- for (size_t i = 0; i < data.float_attributes.size(); ++i) {
- if (data.float_attributes[i].first == attribute)
- return data.float_attributes[i].second;
- }
-
- return 0.0;
-}
-
-bool AXPlatformNode::GetFloatAttribute(
- ui::AXFloatAttribute attribute, float* value) const {
- ui::AXNodeData* data = delegate_->GetData();
- if (!data)
- return false;
-
- for (size_t i = 0; i < data.float_attributes.size(); ++i) {
- if (data.float_attributes[i].first == attribute) {
- *value = data.float_attributes[i].second;
- return true;
- }
- }
-
- return false;
-}
-
-bool AXPlatformNode::HasIntAttribute(
- ui::AXIntAttribute attribute) const {
- ui::AXNodeData* data = delegate_->GetData();
- if (!data)
- return false;
-
- for (size_t i = 0; i < data.int_attributes.size(); ++i) {
- if (data.int_attributes[i].first == attribute)
- return true;
- }
-
- return false;
-}
-
-int AXPlatformNode::GetIntAttribute(ui::AXIntAttribute attribute) const {
- ui::AXNodeData* data = delegate_->GetData();
- if (!data)
- return false;
-
- for (size_t i = 0; i < data.int_attributes.size(); ++i) {
- if (data.int_attributes[i].first == attribute)
- return data.int_attributes[i].second;
- }
-
- return 0;
-}
-
-bool AXPlatformNode::GetIntAttribute(
- ui::AXIntAttribute attribute, int* value) const {
- ui::AXNodeData* data = delegate_->GetData();
- if (!data)
- return false;
-
- for (size_t i = 0; i < data.int_attributes.size(); ++i) {
- if (data.int_attributes[i].first == attribute) {
- *value = data.int_attributes[i].second;
- return true;
- }
- }
-
- return false;
-}
-
-bool AXPlatformNode::HasStringAttribute(
- ui::AXStringAttribute attribute) const {
- ui::AXNodeData* data = delegate_->GetData();
- if (!data)
- return false;
-
- for (size_t i = 0; i < data.string_attributes.size(); ++i) {
- if (data.string_attributes[i].first == attribute)
- return true;
- }
-
- return false;
-}
-
-const std::string& AXPlatformNode::GetStringAttribute(
- ui::AXStringAttribute attribute) const {
- ui::AXNodeData* data = delegate_->GetData();
- if (!data)
- return false;
-
- CR_DEFINE_STATIC_LOCAL(std::string, empty_string, ());
- for (size_t i = 0; i < data.string_attributes.size(); ++i) {
- if (data.string_attributes[i].first == attribute)
- return data.string_attributes[i].second;
- }
-
- return empty_string;
-}
-
-bool AXPlatformNode::GetStringAttribute(
- ui::AXStringAttribute attribute, std::string* value) const {
- ui::AXNodeData* data = delegate_->GetData();
- if (!data)
- return false;
-
- for (size_t i = 0; i < data.string_attributes.size(); ++i) {
- if (data.string_attributes[i].first == attribute) {
- *value = data.string_attributes[i].second;
- return true;
- }
- }
-
- return false;
-}
-
-base::string16 AXPlatformNode::GetString16Attribute(
- ui::AXStringAttribute attribute) const {
- std::string value_utf8;
- if (!GetStringAttribute(attribute, &value_utf8))
- return base::string16();
- return base::UTF8ToUTF16(value_utf8);
-}
-
-bool AXPlatformNode::GetString16Attribute(
- ui::AXStringAttribute attribute,
- base::string16* value) const {
- std::string value_utf8;
- if (!GetStringAttribute(attribute, &value_utf8))
- return false;
- *value = base::UTF8ToUTF16(value_utf8);
- return true;
-}
-
-bool AXPlatformNode::HasIntListAttribute(
- ui::AXIntListAttribute attribute) const {
- ui::AXNodeData* data = delegate_->GetData();
- if (!data)
- return false;
-
- for (size_t i = 0; i < data.intlist_attributes.size(); ++i) {
- if (data.intlist_attributes[i].first == attribute)
- return true;
- }
-
- return false;
-}
-
-const std::vector<int32>& AXPlatformNode::GetIntListAttribute(
- ui::AXIntListAttribute attribute) const {
- ui::AXNodeData* data = delegate_->GetData();
- if (!data)
- return false;
-
- CR_DEFINE_STATIC_LOCAL(std::vector<int32>, empty_vector, ());
- for (size_t i = 0; i < data.intlist_attributes.size(); ++i) {
- if (data.intlist_attributes[i].first == attribute)
- return data.intlist_attributes[i].second;
- }
-
- return empty_vector;
-}
-
-bool AXPlatformNode::GetIntListAttribute(
- ui::AXIntListAttribute attribute,
- std::vector<int32>* value) const {
- ui::AXNodeData* data = delegate_->GetData();
- if (!data)
- return false;
-
- for (size_t i = 0; i < data.intlist_attributes.size(); ++i) {
- if (data.intlist_attributes[i].first == attribute) {
- *value = data.intlist_attributes[i].second;
- return true;
- }
- }
-
- return false;
-}
-
-bool AXPlatformNode::GetHtmlAttribute(
- const char* html_attr, std::string* value) const {
- for (size_t i = 0; i < GetHtmlAttributes().size(); ++i) {
- const std::string& attr = GetHtmlAttributes()[i].first;
- if (LowerCaseEqualsASCII(attr, html_attr)) {
- *value = GetHtmlAttributes()[i].second;
- return true;
- }
- }
-
- return false;
+int AXPlatformNode::GetChildCount() {
+ return delegate_ ? delegate_->GetChildCount() : 0;
}
-bool AXPlatformNode::GetHtmlAttribute(
- const char* html_attr, base::string16* value) const {
- std::string value_utf8;
- if (!GetHtmlAttribute(html_attr, &value_utf8))
- return false;
- *value = base::UTF8ToUTF16(value_utf8);
- return true;
+gfx::NativeViewAccessible AXPlatformNode::ChildAtIndex(int index) {
+ return delegate_ ? delegate_->ChildAtIndex(index) : NULL;
}
} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698