OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "AccessibilityObject.h" | 7 #include "AccessibilityObject.h" |
8 #include "EventHandler.h" | 8 #include "EventHandler.h" |
9 #include "FrameView.h" | 9 #include "FrameView.h" |
10 #include "PlatformKeyboardEvent.h" | 10 #include "PlatformKeyboardEvent.h" |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 | 287 |
288 bool GlueAccessibilityObject::State(int child_id, long* state) { | 288 bool GlueAccessibilityObject::State(int child_id, long* state) { |
289 if (!state) | 289 if (!state) |
290 return false; | 290 return false; |
291 | 291 |
292 *state = 0; | 292 *state = 0; |
293 AccessibilityObject* child_obj; | 293 AccessibilityObject* child_obj; |
294 if (!GetAccessibilityObjectForChild(child_id, child_obj)) | 294 if (!GetAccessibilityObjectForChild(child_id, child_obj)) |
295 return false; | 295 return false; |
296 | 296 |
| 297 if (child_obj->isChecked()) |
| 298 *state |= static_cast<long>(1 << WebAccessibility::STATE_CHECKED); |
| 299 |
| 300 if (child_obj->canSetFocusAttribute()) |
| 301 *state |= static_cast<long>(1 << WebAccessibility::STATE_FOCUSABLE); |
| 302 |
| 303 if (child_obj->isFocused()) |
| 304 *state |= static_cast<long>(1 << WebAccessibility::STATE_FOCUSED); |
| 305 |
| 306 if (child_obj->isHovered()) |
| 307 *state |= static_cast<long>(1 << WebAccessibility::STATE_HOTTRACKED); |
| 308 |
| 309 if (child_obj->isIndeterminate()) |
| 310 *state |= static_cast<long>(1 << WebAccessibility::STATE_INDETERMINATE); |
| 311 |
297 if (child_obj->isAnchor()) | 312 if (child_obj->isAnchor()) |
298 *state |= static_cast<long>(1 << WebAccessibility::STATE_LINKED); | 313 *state |= static_cast<long>(1 << WebAccessibility::STATE_LINKED); |
299 | 314 |
300 if (child_obj->isHovered()) | 315 if (child_obj->isMultiSelect()) |
301 *state |= static_cast<long>(1 << WebAccessibility::STATE_HOTTRACKED); | 316 *state |= static_cast<long>(1 << WebAccessibility::STATE_MULTISELECTABLE); |
| 317 |
| 318 if (child_obj->isOffScreen()) |
| 319 *state |= static_cast<long>(1 << WebAccessibility::STATE_OFFSCREEN); |
| 320 |
| 321 if (child_obj->isPressed()) |
| 322 *state |= static_cast<long>(1 << WebAccessibility::STATE_PRESSED); |
| 323 |
| 324 if (child_obj->isPasswordField()) |
| 325 *state |= static_cast<long>(1 << WebAccessibility::STATE_PROTECTED); |
| 326 |
| 327 if (child_obj->isReadOnly()) |
| 328 *state |= static_cast<long>(1 << WebAccessibility::STATE_READONLY); |
| 329 |
| 330 if (child_obj->isVisited()) |
| 331 *state |= static_cast<long>(1 << WebAccessibility::STATE_TRAVERSED); |
302 | 332 |
303 if (!child_obj->isEnabled()) | 333 if (!child_obj->isEnabled()) |
304 *state |= static_cast<long>(1 << WebAccessibility::STATE_UNAVAILABLE); | 334 *state |= static_cast<long>(1 << WebAccessibility::STATE_UNAVAILABLE); |
305 | 335 |
306 if (child_obj->isReadOnly()) | |
307 *state |= static_cast<long>(1 << WebAccessibility::STATE_READONLY); | |
308 | |
309 if (child_obj->isOffScreen()) | |
310 *state |= static_cast<long>(1 << WebAccessibility::STATE_OFFSCREEN); | |
311 | |
312 if (child_obj->isMultiSelect()) | |
313 *state |= static_cast<long>(1 << WebAccessibility::STATE_MULTISELECTABLE); | |
314 | |
315 if (child_obj->isPasswordField()) | |
316 *state |= static_cast<long>(1 << WebAccessibility::STATE_PROTECTED); | |
317 | |
318 if (child_obj->isIndeterminate()) | |
319 *state |= static_cast<long>(1 << WebAccessibility::STATE_INDETERMINATE); | |
320 | |
321 if (child_obj->isChecked()) | |
322 *state |= static_cast<long>(1 << WebAccessibility::STATE_CHECKED); | |
323 | |
324 if (child_obj->isPressed()) | |
325 *state |= static_cast<long>(1 << WebAccessibility::STATE_PRESSED); | |
326 | |
327 if (child_obj->isFocused()) | |
328 *state |= static_cast<long>(1 << WebAccessibility::STATE_FOCUSED); | |
329 | |
330 if (child_obj->isVisited()) | |
331 *state |= static_cast<long>(1 << WebAccessibility::STATE_TRAVERSED); | |
332 | |
333 if (child_obj->canSetFocusAttribute()) | |
334 *state |= static_cast<long>(1 << WebAccessibility::STATE_FOCUSABLE); | |
335 | |
336 // TODO(klink): Add selected and selectable states. | 336 // TODO(klink): Add selected and selectable states. |
337 | 337 |
338 return true; | 338 return true; |
339 } | 339 } |
340 | 340 |
341 // Helper functions | 341 // Helper functions |
342 String GlueAccessibilityObject::name() const { | 342 String GlueAccessibilityObject::name() const { |
343 return m_object->title(); | 343 return m_object->title(); |
344 } | 344 } |
345 | 345 |
346 String GlueAccessibilityObject::value() const { | 346 String GlueAccessibilityObject::value() const { |
347 return m_object->stringValue(); | 347 return m_object->stringValue(); |
348 } | 348 } |
349 | 349 |
350 String GlueAccessibilityObject::description() const { | 350 String GlueAccessibilityObject::description() const { |
351 String desc = m_object->accessibilityDescription(); | 351 String desc = m_object->accessibilityDescription(); |
352 if (desc.isNull()) | 352 if (desc.isNull()) |
353 return desc; | 353 return desc; |
354 | 354 |
355 // From the Mozilla MSAA implementation: | 355 // From the Mozilla MSAA implementation: |
356 // "Signal to screen readers that this description is speakable and is not | 356 // "Signal to screen readers that this description is speakable and is not |
357 // a formatted positional information description. Don't localize the | 357 // a formatted positional information description. Don't localize the |
358 // 'Description: ' part of this string, it will be parsed out by assistive | 358 // 'Description: ' part of this string, it will be parsed out by assistive |
359 // technologies." | 359 // technologies." |
360 return "Description: " + desc; | 360 return "Description: " + desc; |
361 } | 361 } |
362 | 362 |
363 // Provides a conversion between the WebCore::AccessibilityRole and a | 363 // Provides a conversion between the WebCore::AccessibilityRole and a |
364 // role supported on the Browser side. Static function. | 364 // role supported on the Browser side. Listed alphabetically by the |
| 365 // WebAccessibility role (except for default role). Static function. |
365 static WebAccessibility::Role SupportedRole(WebCore::AccessibilityRole role) { | 366 static WebAccessibility::Role SupportedRole(WebCore::AccessibilityRole role) { |
366 switch (role) { | 367 switch (role) { |
| 368 case WebCore::CellRole: |
| 369 return WebAccessibility::ROLE_CELL; |
| 370 case WebCore::CheckBoxRole: |
| 371 return WebAccessibility::ROLE_CHECKBUTTON; |
| 372 case WebCore::ColumnRole: |
| 373 return WebAccessibility::ROLE_COLUMN; |
| 374 case WebCore::ColumnHeaderRole: |
| 375 return WebAccessibility::ROLE_COLUMNHEADER; |
| 376 case WebCore::ImageMapRole: |
| 377 case WebCore::ImageRole: |
| 378 return WebAccessibility::ROLE_GRAPHIC; |
| 379 case WebCore::GroupRole: |
| 380 return WebAccessibility::ROLE_GROUPING; |
| 381 case WebCore::LinkRole: |
| 382 case WebCore::WebCoreLinkRole: |
| 383 return WebAccessibility::ROLE_LINK; |
| 384 case WebCore::ListRole: |
| 385 return WebAccessibility::ROLE_LIST; |
| 386 case WebCore::ListBoxRole: |
| 387 return WebAccessibility::ROLE_LISTBOX; |
| 388 case WebCore::MenuButtonRole: |
| 389 case WebCore::MenuItemRole: |
| 390 return WebAccessibility::ROLE_MENUITEM; |
| 391 case WebCore::MenuRole: |
| 392 return WebAccessibility::ROLE_MENUPOPUP; |
| 393 case WebCore::OutlineRole: |
| 394 return WebAccessibility::ROLE_OUTLINE; |
| 395 case WebCore::TabGroupRole: |
| 396 return WebAccessibility::ROLE_PAGETABLIST; |
| 397 case WebCore::ProgressIndicatorRole: |
| 398 return WebAccessibility::ROLE_PROGRESSBAR; |
367 case WebCore::ButtonRole: | 399 case WebCore::ButtonRole: |
368 return WebAccessibility::ROLE_PUSHBUTTON; | 400 return WebAccessibility::ROLE_PUSHBUTTON; |
369 case WebCore::RadioButtonRole: | 401 case WebCore::RadioButtonRole: |
370 return WebAccessibility::ROLE_RADIOBUTTON; | 402 return WebAccessibility::ROLE_RADIOBUTTON; |
371 case WebCore::CheckBoxRole: | 403 case WebCore::RowRole: |
372 return WebAccessibility::ROLE_CHECKBUTTON; | 404 return WebAccessibility::ROLE_ROW; |
| 405 case WebCore::RowHeaderRole: |
| 406 return WebAccessibility::ROLE_ROWHEADER; |
373 case WebCore::SliderRole: | 407 case WebCore::SliderRole: |
374 return WebAccessibility::ROLE_SLIDER; | 408 return WebAccessibility::ROLE_SLIDER; |
375 case WebCore::TabGroupRole: | 409 case WebCore::StaticTextRole: |
376 return WebAccessibility::ROLE_PAGETABLIST; | 410 return WebAccessibility::ROLE_STATICTEXT; |
| 411 case WebCore::TableRole: |
| 412 return WebAccessibility::ROLE_TABLE; |
| 413 case WebCore::ListMarkerRole: |
377 case WebCore::TextFieldRole: | 414 case WebCore::TextFieldRole: |
378 case WebCore::TextAreaRole: | 415 case WebCore::TextAreaRole: |
379 case WebCore::ListMarkerRole: | |
380 return WebAccessibility::ROLE_TEXT; | 416 return WebAccessibility::ROLE_TEXT; |
381 case WebCore::StaticTextRole: | 417 case WebCore::UnknownRole: |
382 return WebAccessibility::ROLE_STATICTEXT; | |
383 case WebCore::OutlineRole: | |
384 return WebAccessibility::ROLE_OUTLINE; | |
385 case WebCore::ColumnRole: | |
386 return WebAccessibility::ROLE_COLUMN; | |
387 case WebCore::RowRole: | |
388 return WebAccessibility::ROLE_ROW; | |
389 case WebCore::GroupRole: | |
390 return WebAccessibility::ROLE_GROUPING; | |
391 case WebCore::ListRole: | |
392 return WebAccessibility::ROLE_LIST; | |
393 case WebCore::TableRole: | |
394 return WebAccessibility::ROLE_TABLE; | |
395 case WebCore::LinkRole: | |
396 case WebCore::WebCoreLinkRole: | |
397 return WebAccessibility::ROLE_LINK; | |
398 case WebCore::ImageMapRole: | |
399 case WebCore::ImageRole: | |
400 return WebAccessibility::ROLE_GRAPHIC; | |
401 default: | 418 default: |
402 // This is the default role. | 419 // This is the default role. |
403 return WebAccessibility::ROLE_CLIENT; | 420 return WebAccessibility::ROLE_CLIENT; |
404 } | 421 } |
405 } | 422 } |
406 | 423 |
407 WebAccessibility::Role GlueAccessibilityObject::role() const { | 424 WebAccessibility::Role GlueAccessibilityObject::role() const { |
408 return SupportedRole(m_object->roleValue()); | 425 return SupportedRole(m_object->roleValue()); |
409 } | 426 } |
410 | 427 |
(...skipping 25 matching lines...) Expand all Loading... |
436 if (!obj) | 453 if (!obj) |
437 return NULL; | 454 return NULL; |
438 | 455 |
439 GlueAccessibilityObject* result = | 456 GlueAccessibilityObject* result = |
440 static_cast<GlueAccessibilityObject*>(obj->wrapper()); | 457 static_cast<GlueAccessibilityObject*>(obj->wrapper()); |
441 if (!result) | 458 if (!result) |
442 result = CreateInstance(obj); | 459 result = CreateInstance(obj); |
443 | 460 |
444 return result; | 461 return result; |
445 } | 462 } |
OLD | NEW |