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

Side by Side Diff: ui/accessibility/platform/ax_platform_node_auralinux.cc

Issue 1010083006: Implement AtkComponent interface for chrome UI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixing nits Created 5 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
« no previous file with comments | « ui/accessibility/platform/ax_platform_node_auralinux.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/task_runner.h" 9 #include "base/task_runner.h"
10 #include "ui/accessibility/ax_node_data.h" 10 #include "ui/accessibility/ax_node_data.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 177
178 AtkStateSet* atk_state_set = 178 AtkStateSet* atk_state_set =
179 ATK_OBJECT_CLASS(ax_platform_node_auralinux_parent_class)-> 179 ATK_OBJECT_CLASS(ax_platform_node_auralinux_parent_class)->
180 ref_state_set(atk_object); 180 ref_state_set(atk_object);
181 181
182 obj->GetAtkState(atk_state_set); 182 obj->GetAtkState(atk_state_set);
183 return atk_state_set; 183 return atk_state_set;
184 } 184 }
185 185
186 // 186 //
187 // AtkComponent interface
188 //
189
190 static gfx::Point FindAtkObjectParentCoords(AtkObject* atk_object) {
191 if (atk_object_get_role(atk_object) == ATK_ROLE_WINDOW) {
192 int x, y;
193 atk_component_get_position(ATK_COMPONENT(atk_object),
194 &x, &y, ATK_XY_WINDOW);
195 gfx::Point window_coords(x, y);
196 return window_coords;
197 }
198 atk_object = atk_object_get_parent(atk_object);
199
200 return FindAtkObjectParentCoords(atk_object);
201 }
202
203 static void ax_platform_node_auralinux_get_extents(AtkComponent* atk_component,
204 gint* x, gint* y,
205 gint* width, gint* height,
206 AtkCoordType coord_type) {
207 *x = *y = *width = *height = 0;
208 AtkObject* atk_object = ATK_OBJECT(atk_component);
209 ui::AXPlatformNodeAuraLinux* obj =
210 AtkObjectToAXPlatformNodeAuraLinux(atk_object);
211 if (!obj)
212 return;
213
214 obj->GetExtents(x, y, width, height, coord_type);
215 }
216
217 static void ax_platform_node_auralinux_get_position(AtkComponent* atk_component,
218 gint* x, gint* y,
219 AtkCoordType coord_type) {
220 *x = *y = 0;
221 AtkObject* atk_object = ATK_OBJECT(atk_component);
222 ui::AXPlatformNodeAuraLinux* obj =
223 AtkObjectToAXPlatformNodeAuraLinux(atk_object);
224 if (!obj)
225 return;
226
227 obj->GetPosition(x, y, coord_type);
228 }
229
230 static void ax_platform_node_auralinux_get_size(AtkComponent* atk_component,
231 gint* width, gint* height) {
232 *width = *height = 0;
233 AtkObject* atk_object = ATK_OBJECT(atk_component);
234 ui::AXPlatformNodeAuraLinux* obj =
235 AtkObjectToAXPlatformNodeAuraLinux(atk_object);
236 if (!obj)
237 return;
238
239 obj->GetSize(width, height);
240 }
241
242 void ax_component_interface_base_init(AtkComponentIface* iface) {
243 iface->get_extents = ax_platform_node_auralinux_get_extents;
244 iface->get_position = ax_platform_node_auralinux_get_position;
245 iface->get_size = ax_platform_node_auralinux_get_size;
246 }
247
248 static const GInterfaceInfo ComponentInfo = {
249 reinterpret_cast<GInterfaceInitFunc>(ax_component_interface_base_init), 0, 0
250 };
251
252 //
187 // The rest of the AXPlatformNodeAuraLinux code, not specific to one 253 // The rest of the AXPlatformNodeAuraLinux code, not specific to one
188 // of the Atk* interfaces. 254 // of the Atk* interfaces.
189 // 255 //
190 256
191 static void ax_platform_node_auralinux_init(AtkObject* atk_object, 257 static void ax_platform_node_auralinux_init(AtkObject* atk_object,
192 gpointer data) { 258 gpointer data) {
193 if (ATK_OBJECT_CLASS(ax_platform_node_auralinux_parent_class)->initialize) { 259 if (ATK_OBJECT_CLASS(ax_platform_node_auralinux_parent_class)->initialize) {
194 ATK_OBJECT_CLASS(ax_platform_node_auralinux_parent_class)->initialize( 260 ATK_OBJECT_CLASS(ax_platform_node_auralinux_parent_class)->initialize(
195 atk_object, data); 261 atk_object, data);
196 } 262 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 (GClassFinalizeFunc) 0, 299 (GClassFinalizeFunc) 0,
234 0, /* class data */ 300 0, /* class data */
235 sizeof(AXPlatformNodeAuraLinuxObject), /* instance size */ 301 sizeof(AXPlatformNodeAuraLinuxObject), /* instance size */
236 0, /* nb preallocs */ 302 0, /* nb preallocs */
237 (GInstanceInitFunc) 0, 303 (GInstanceInitFunc) 0,
238 0 /* value table */ 304 0 /* value table */
239 }; 305 };
240 306
241 GType type = g_type_register_static( 307 GType type = g_type_register_static(
242 ATK_TYPE_OBJECT, "AXPlatformNodeAuraLinux", &tinfo, GTypeFlags(0)); 308 ATK_TYPE_OBJECT, "AXPlatformNodeAuraLinux", &tinfo, GTypeFlags(0));
309 g_type_add_interface_static(type, ATK_TYPE_COMPONENT, &ComponentInfo);
243 g_once_init_leave(&type_volatile, type); 310 g_once_init_leave(&type_volatile, type);
244 } 311 }
245 312
246 return type_volatile; 313 return type_volatile;
247 } 314 }
248 315
249 AXPlatformNodeAuraLinuxObject* ax_platform_node_auralinux_new( 316 AXPlatformNodeAuraLinuxObject* ax_platform_node_auralinux_new(
250 ui::AXPlatformNodeAuraLinux* obj) { 317 ui::AXPlatformNodeAuraLinux* obj) {
251 #if !GLIB_CHECK_VERSION(2, 36, 0) 318 #if !GLIB_CHECK_VERSION(2, 36, 0)
252 static bool first_time = true; 319 static bool first_time = true;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 return atk_object_; 458 return atk_object_;
392 } 459 }
393 460
394 void AXPlatformNodeAuraLinux::NotifyAccessibilityEvent(ui::AXEvent event_type) { 461 void AXPlatformNodeAuraLinux::NotifyAccessibilityEvent(ui::AXEvent event_type) {
395 } 462 }
396 463
397 int AXPlatformNodeAuraLinux::GetIndexInParent() { 464 int AXPlatformNodeAuraLinux::GetIndexInParent() {
398 return 0; 465 return 0;
399 } 466 }
400 467
468 void AXPlatformNodeAuraLinux::GetExtents(gint* x, gint* y,
469 gint* width, gint* height,
470 AtkCoordType coord_type) {
471 gfx::Rect extents = GetBoundsInScreen();
472
473 *x = extents.x();
474 *y = extents.y();
475 *width = extents.width();
476 *height = extents.height();
477
478 if (coord_type == ATK_XY_WINDOW) {
479 AtkObject* atk_object = GetParent();
480 gfx::Point window_coords = FindAtkObjectParentCoords(atk_object);
481 *x -= window_coords.x();
482 *y -= window_coords.y();
483 }
484 }
485
486 void AXPlatformNodeAuraLinux::GetPosition(gint* x, gint* y,
487 AtkCoordType coord_type) {
488 gfx::Rect rect_pos = GetBoundsInScreen();
489
490 *x = rect_pos.x();
491 *y = rect_pos.y();
492
493 if (coord_type == ATK_XY_WINDOW) {
494 AtkObject* atk_object = GetParent();
495 gfx::Point window_coords = FindAtkObjectParentCoords(atk_object);
496 *x -= window_coords.x();
497 *y -= window_coords.y();
498 }
499 }
500
501 void AXPlatformNodeAuraLinux::GetSize(gint* width, gint* height) {
502 gfx::Rect rect_size = GetData().location;
503 *width = rect_size.width();
504 *height = rect_size.height();
505 }
506
401 } // namespace ui 507 } // namespace ui
OLDNEW
« no previous file with comments | « ui/accessibility/platform/ax_platform_node_auralinux.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698