| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/accessibility/platform/ax_platform_node_auralinux.h" | 5 #include "ui/accessibility/platform/ax_platform_node_auralinux.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
| 9 #include "ui/accessibility/ax_node_data.h" | 9 #include "ui/accessibility/ax_node_data.h" |
| 10 #include "ui/accessibility/platform/atk_util_auralinux.h" | 10 #include "ui/accessibility/platform/atk_util_auralinux.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 AtkObject parent; | 38 AtkObject parent; |
| 39 ui::AXPlatformNodeAuraLinux* m_object; | 39 ui::AXPlatformNodeAuraLinux* m_object; |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 struct _AXPlatformNodeAuraLinuxClass { | 42 struct _AXPlatformNodeAuraLinuxClass { |
| 43 AtkObjectClass parent_class; | 43 AtkObjectClass parent_class; |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 GType ax_platform_node_auralinux_get_type(); | 46 GType ax_platform_node_auralinux_get_type(); |
| 47 | 47 |
| 48 static gpointer ax_platform_node_auralinux_parent_class = nullptr; |
| 49 |
| 48 static ui::AXPlatformNodeAuraLinux* ToAXPlatformNodeAuraLinux( | 50 static ui::AXPlatformNodeAuraLinux* ToAXPlatformNodeAuraLinux( |
| 49 AXPlatformNodeAuraLinuxObject* atk_object) { | 51 AXPlatformNodeAuraLinuxObject* atk_object) { |
| 50 if (!atk_object) | 52 if (!atk_object) |
| 51 return nullptr; | 53 return nullptr; |
| 52 | 54 |
| 53 return atk_object->m_object; | 55 return atk_object->m_object; |
| 54 } | 56 } |
| 55 | 57 |
| 56 static ui::AXPlatformNodeAuraLinux* AtkObjectToAXPlatformNodeAuraLinux( | 58 static ui::AXPlatformNodeAuraLinux* AtkObjectToAXPlatformNodeAuraLinux( |
| 57 AtkObject* atk_object) { | 59 AtkObject* atk_object) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 } | 118 } |
| 117 | 119 |
| 118 static AtkRole ax_platform_node_auralinux_get_role(AtkObject* atk_object) { | 120 static AtkRole ax_platform_node_auralinux_get_role(AtkObject* atk_object) { |
| 119 ui::AXPlatformNodeAuraLinux* obj = | 121 ui::AXPlatformNodeAuraLinux* obj = |
| 120 AtkObjectToAXPlatformNodeAuraLinux(atk_object); | 122 AtkObjectToAXPlatformNodeAuraLinux(atk_object); |
| 121 if (!obj) | 123 if (!obj) |
| 122 return ATK_ROLE_INVALID; | 124 return ATK_ROLE_INVALID; |
| 123 return obj->GetAtkRole(); | 125 return obj->GetAtkRole(); |
| 124 } | 126 } |
| 125 | 127 |
| 128 static AtkStateSet* ax_platform_node_auralinux_ref_state_set( |
| 129 AtkObject* atk_object) { |
| 130 ui::AXPlatformNodeAuraLinux* obj = |
| 131 AtkObjectToAXPlatformNodeAuraLinux(atk_object); |
| 132 AtkStateSet* state_set = |
| 133 ATK_OBJECT_CLASS(ax_platform_node_auralinux_parent_class)-> |
| 134 ref_state_set(atk_object); |
| 135 |
| 136 if (!obj) { |
| 137 atk_state_set_add_state(state_set, ATK_STATE_DEFUNCT); |
| 138 return state_set; |
| 139 } |
| 140 obj->GetAtkState(state_set); |
| 141 |
| 142 return state_set; |
| 143 } |
| 144 |
| 126 // | 145 // |
| 127 // The rest of the AXPlatformNodeAuraLinux code, not specific to one | 146 // The rest of the AXPlatformNodeAuraLinux code, not specific to one |
| 128 // of the Atk* interfaces. | 147 // of the Atk* interfaces. |
| 129 // | 148 // |
| 130 | 149 |
| 131 static gpointer ax_platform_node_auralinux_parent_class = nullptr; | |
| 132 | |
| 133 static void ax_platform_node_auralinux_init(AtkObject* atk_object, | 150 static void ax_platform_node_auralinux_init(AtkObject* atk_object, |
| 134 gpointer data) { | 151 gpointer data) { |
| 135 if (ATK_OBJECT_CLASS(ax_platform_node_auralinux_parent_class)->initialize) { | 152 if (ATK_OBJECT_CLASS(ax_platform_node_auralinux_parent_class)->initialize) { |
| 136 ATK_OBJECT_CLASS(ax_platform_node_auralinux_parent_class)->initialize( | 153 ATK_OBJECT_CLASS(ax_platform_node_auralinux_parent_class)->initialize( |
| 137 atk_object, data); | 154 atk_object, data); |
| 138 } | 155 } |
| 139 | 156 |
| 140 AX_PLATFORM_NODE_AURALINUX(atk_object)->m_object = | 157 AX_PLATFORM_NODE_AURALINUX(atk_object)->m_object = |
| 141 reinterpret_cast<ui::AXPlatformNodeAuraLinux*>(data); | 158 reinterpret_cast<ui::AXPlatformNodeAuraLinux*>(data); |
| 142 } | 159 } |
| 143 | 160 |
| 144 static void ax_platform_node_auralinux_finalize(GObject* atk_object) { | 161 static void ax_platform_node_auralinux_finalize(GObject* atk_object) { |
| 145 G_OBJECT_CLASS(ax_platform_node_auralinux_parent_class)->finalize(atk_object); | 162 G_OBJECT_CLASS(ax_platform_node_auralinux_parent_class)->finalize(atk_object); |
| 146 } | 163 } |
| 147 | 164 |
| 148 static void ax_platform_node_auralinux_class_init(AtkObjectClass* klass) { | 165 static void ax_platform_node_auralinux_class_init(AtkObjectClass* klass) { |
| 149 GObjectClass* gobject_class = G_OBJECT_CLASS(klass); | 166 GObjectClass* gobject_class = G_OBJECT_CLASS(klass); |
| 150 ax_platform_node_auralinux_parent_class = g_type_class_peek_parent(klass); | 167 ax_platform_node_auralinux_parent_class = g_type_class_peek_parent(klass); |
| 151 | 168 |
| 152 gobject_class->finalize = ax_platform_node_auralinux_finalize; | 169 gobject_class->finalize = ax_platform_node_auralinux_finalize; |
| 153 klass->initialize = ax_platform_node_auralinux_init; | 170 klass->initialize = ax_platform_node_auralinux_init; |
| 154 klass->get_name = ax_platform_node_auralinux_get_name; | 171 klass->get_name = ax_platform_node_auralinux_get_name; |
| 155 klass->get_description = ax_platform_node_auralinux_get_description; | 172 klass->get_description = ax_platform_node_auralinux_get_description; |
| 156 klass->get_parent = ax_platform_node_auralinux_get_parent; | 173 klass->get_parent = ax_platform_node_auralinux_get_parent; |
| 157 klass->get_n_children = ax_platform_node_auralinux_get_n_children; | 174 klass->get_n_children = ax_platform_node_auralinux_get_n_children; |
| 158 klass->ref_child = ax_platform_node_auralinux_ref_child; | 175 klass->ref_child = ax_platform_node_auralinux_ref_child; |
| 159 klass->get_role = ax_platform_node_auralinux_get_role; | 176 klass->get_role = ax_platform_node_auralinux_get_role; |
| 177 klass->ref_state_set = ax_platform_node_auralinux_ref_state_set; |
| 160 } | 178 } |
| 161 | 179 |
| 162 GType ax_platform_node_auralinux_get_type() { | 180 GType ax_platform_node_auralinux_get_type() { |
| 163 static volatile gsize type_volatile = 0; | 181 static volatile gsize type_volatile = 0; |
| 164 | 182 |
| 165 if (g_once_init_enter(&type_volatile)) { | 183 if (g_once_init_enter(&type_volatile)) { |
| 166 static const GTypeInfo tinfo = { | 184 static const GTypeInfo tinfo = { |
| 167 sizeof(AXPlatformNodeAuraLinuxClass), | 185 sizeof(AXPlatformNodeAuraLinuxClass), |
| 168 (GBaseInitFunc) 0, | 186 (GBaseInitFunc) 0, |
| 169 (GBaseFinalizeFunc) 0, | 187 (GBaseFinalizeFunc) 0, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 case ui::AX_ROLE_ALERT: | 252 case ui::AX_ROLE_ALERT: |
| 235 return ATK_ROLE_ALERT; | 253 return ATK_ROLE_ALERT; |
| 236 case ui::AX_ROLE_APPLICATION: | 254 case ui::AX_ROLE_APPLICATION: |
| 237 return ATK_ROLE_APPLICATION; | 255 return ATK_ROLE_APPLICATION; |
| 238 case ui::AX_ROLE_BUTTON: | 256 case ui::AX_ROLE_BUTTON: |
| 239 return ATK_ROLE_PUSH_BUTTON; | 257 return ATK_ROLE_PUSH_BUTTON; |
| 240 case ui::AX_ROLE_CHECK_BOX: | 258 case ui::AX_ROLE_CHECK_BOX: |
| 241 return ATK_ROLE_CHECK_BOX; | 259 return ATK_ROLE_CHECK_BOX; |
| 242 case ui::AX_ROLE_COMBO_BOX: | 260 case ui::AX_ROLE_COMBO_BOX: |
| 243 return ATK_ROLE_COMBO_BOX; | 261 return ATK_ROLE_COMBO_BOX; |
| 262 case ui::AX_ROLE_DIALOG: |
| 263 return ATK_ROLE_DIALOG; |
| 244 case ui::AX_ROLE_GROUP: | 264 case ui::AX_ROLE_GROUP: |
| 245 return ATK_ROLE_PANEL; | 265 return ATK_ROLE_PANEL; |
| 266 case ui::AX_ROLE_IMAGE: |
| 267 return ATK_ROLE_IMAGE; |
| 246 case ui::AX_ROLE_MENU_ITEM: | 268 case ui::AX_ROLE_MENU_ITEM: |
| 247 return ATK_ROLE_MENU_ITEM; | 269 return ATK_ROLE_MENU_ITEM; |
| 270 case ui::AX_ROLE_SCROLL_BAR: |
| 271 return ATK_ROLE_SCROLL_BAR; |
| 272 case ui::AX_ROLE_SLIDER: |
| 273 return ATK_ROLE_SLIDER; |
| 248 case ui::AX_ROLE_SPLITTER: | 274 case ui::AX_ROLE_SPLITTER: |
| 249 return ATK_ROLE_SEPARATOR; | 275 return ATK_ROLE_SEPARATOR; |
| 250 case ui::AX_ROLE_STATIC_TEXT: | 276 case ui::AX_ROLE_STATIC_TEXT: |
| 251 return ATK_ROLE_TEXT; | 277 return ATK_ROLE_TEXT; |
| 252 case ui::AX_ROLE_TAB: | 278 case ui::AX_ROLE_TAB: |
| 253 return ATK_ROLE_PAGE_TAB; | 279 return ATK_ROLE_PAGE_TAB; |
| 254 case ui::AX_ROLE_TAB_LIST: | 280 case ui::AX_ROLE_TAB_LIST: |
| 255 return ATK_ROLE_PAGE_TAB_LIST; | 281 return ATK_ROLE_PAGE_TAB_LIST; |
| 256 case ui::AX_ROLE_TEXT_FIELD: | 282 case ui::AX_ROLE_TEXT_FIELD: |
| 257 return ATK_ROLE_ENTRY; | 283 return ATK_ROLE_ENTRY; |
| 258 case ui::AX_ROLE_TOOLBAR: | 284 case ui::AX_ROLE_TOOLBAR: |
| 259 return ATK_ROLE_TOOL_BAR; | 285 return ATK_ROLE_TOOL_BAR; |
| 260 case ui::AX_ROLE_WINDOW: | 286 case ui::AX_ROLE_WINDOW: |
| 261 return ATK_ROLE_WINDOW; | 287 return ATK_ROLE_WINDOW; |
| 262 default: | 288 default: |
| 263 return ATK_ROLE_UNKNOWN; | 289 return ATK_ROLE_UNKNOWN; |
| 264 } | 290 } |
| 265 } | 291 } |
| 266 | 292 |
| 293 void AXPlatformNodeAuraLinux::GetAtkState(AtkStateSet* state_set) { |
| 294 uint32 state = GetData().state; |
| 295 |
| 296 if (state & (1 << ui::AX_STATE_CHECKED)) |
| 297 atk_state_set_add_state(state_set, ATK_STATE_CHECKED); |
| 298 if (state & (1 << ui::AX_STATE_DEFAULT)) |
| 299 atk_state_set_add_state(state_set, ATK_STATE_DEFAULT); |
| 300 if (state & (1 << ui::AX_STATE_EDITABLE)) |
| 301 atk_state_set_add_state(state_set, ATK_STATE_EDITABLE); |
| 302 if (state & (1 << ui::AX_STATE_ENABLED)) |
| 303 atk_state_set_add_state(state_set, ATK_STATE_ENABLED); |
| 304 if (state & (1 << ui::AX_STATE_EXPANDED)) |
| 305 atk_state_set_add_state(state_set, ATK_STATE_EXPANDED); |
| 306 if (state & (1 << ui::AX_STATE_FOCUSABLE)) |
| 307 atk_state_set_add_state(state_set, ATK_STATE_FOCUSABLE); |
| 308 if (state & (1 << ui::AX_STATE_FOCUSED)) |
| 309 atk_state_set_add_state(state_set, ATK_STATE_FOCUSED); |
| 310 if (state & (1 << ui::AX_STATE_PRESSED)) |
| 311 atk_state_set_add_state(state_set, ATK_STATE_PRESSED); |
| 312 if (state & (1 << ui::AX_STATE_SELECTABLE)) |
| 313 atk_state_set_add_state(state_set, ATK_STATE_SELECTABLE); |
| 314 if (state & (1 << ui::AX_STATE_SELECTED)) |
| 315 atk_state_set_add_state(state_set, ATK_STATE_SELECTED); |
| 316 } |
| 317 |
| 267 AXPlatformNodeAuraLinux::AXPlatformNodeAuraLinux() | 318 AXPlatformNodeAuraLinux::AXPlatformNodeAuraLinux() |
| 268 : atk_object_(nullptr) { | 319 : atk_object_(nullptr) { |
| 269 } | 320 } |
| 270 | 321 |
| 271 AXPlatformNodeAuraLinux::~AXPlatformNodeAuraLinux() { | 322 AXPlatformNodeAuraLinux::~AXPlatformNodeAuraLinux() { |
| 272 g_object_unref(atk_object_); | 323 g_object_unref(atk_object_); |
| 273 } | 324 } |
| 274 | 325 |
| 275 void AXPlatformNodeAuraLinux::Init(AXPlatformNodeDelegate* delegate) { | 326 void AXPlatformNodeAuraLinux::Init(AXPlatformNodeDelegate* delegate) { |
| 276 // Initialize ATK. | 327 // Initialize ATK. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 288 } | 339 } |
| 289 | 340 |
| 290 void AXPlatformNodeAuraLinux::NotifyAccessibilityEvent(ui::AXEvent event_type) { | 341 void AXPlatformNodeAuraLinux::NotifyAccessibilityEvent(ui::AXEvent event_type) { |
| 291 } | 342 } |
| 292 | 343 |
| 293 int AXPlatformNodeAuraLinux::GetIndexInParent() { | 344 int AXPlatformNodeAuraLinux::GetIndexInParent() { |
| 294 return 0; | 345 return 0; |
| 295 } | 346 } |
| 296 | 347 |
| 297 } // namespace ui | 348 } // namespace ui |
| OLD | NEW |