OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009, 2010 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 #if HAVE(ACCESSIBILITY) | 31 #if HAVE(ACCESSIBILITY) |
32 | 32 |
33 #include "core/accessibility/AXObjectCache.h" | 33 #include "core/accessibility/AXObjectCache.h" |
34 | 34 |
35 #include "HTMLNames.h" | 35 #include "HTMLNames.h" |
36 #include "core/accessibility/AccessibilityARIAGrid.h" | 36 #include "core/accessibility/AccessibilityARIAGrid.h" |
37 #include "core/accessibility/AccessibilityARIAGridCell.h" | 37 #include "core/accessibility/AccessibilityARIAGridCell.h" |
38 #include "core/accessibility/AccessibilityARIAGridRow.h" | 38 #include "core/accessibility/AccessibilityARIAGridRow.h" |
39 #include "core/accessibility/AccessibilityImageMapLink.h" | 39 #include "core/accessibility/AccessibilityImageMapLink.h" |
| 40 #include "core/accessibility/AccessibilityInlineTextBox.h" |
40 #include "core/accessibility/AccessibilityList.h" | 41 #include "core/accessibility/AccessibilityList.h" |
41 #include "core/accessibility/AccessibilityListBox.h" | 42 #include "core/accessibility/AccessibilityListBox.h" |
42 #include "core/accessibility/AccessibilityListBoxOption.h" | 43 #include "core/accessibility/AccessibilityListBoxOption.h" |
43 #include "core/accessibility/AccessibilityMediaControls.h" | 44 #include "core/accessibility/AccessibilityMediaControls.h" |
44 #include "core/accessibility/AccessibilityMenuList.h" | 45 #include "core/accessibility/AccessibilityMenuList.h" |
45 #include "core/accessibility/AccessibilityMenuListOption.h" | 46 #include "core/accessibility/AccessibilityMenuListOption.h" |
46 #include "core/accessibility/AccessibilityMenuListPopup.h" | 47 #include "core/accessibility/AccessibilityMenuListPopup.h" |
47 #include "core/accessibility/AccessibilityProgressIndicator.h" | 48 #include "core/accessibility/AccessibilityProgressIndicator.h" |
48 #include "core/accessibility/AccessibilityRenderObject.h" | 49 #include "core/accessibility/AccessibilityRenderObject.h" |
49 #include "core/accessibility/AccessibilitySVGRoot.h" | 50 #include "core/accessibility/AccessibilitySVGRoot.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 if (it != m_idMapping.end()) | 94 if (it != m_idMapping.end()) |
94 it->value.ignored = inclusion; | 95 it->value.ignored = inclusion; |
95 else { | 96 else { |
96 CachedAXObjectAttributes attributes; | 97 CachedAXObjectAttributes attributes; |
97 attributes.ignored = inclusion; | 98 attributes.ignored = inclusion; |
98 m_idMapping.set(id, attributes); | 99 m_idMapping.set(id, attributes); |
99 } | 100 } |
100 } | 101 } |
101 | 102 |
102 bool AXObjectCache::gAccessibilityEnabled = false; | 103 bool AXObjectCache::gAccessibilityEnabled = false; |
| 104 bool AXObjectCache::gInlineTextBoxAccessibility = false; |
103 | 105 |
104 AXObjectCache::AXObjectCache(const Document* doc) | 106 AXObjectCache::AXObjectCache(const Document* doc) |
105 : m_notificationPostTimer(this, &AXObjectCache::notificationPostTimerFired) | 107 : m_notificationPostTimer(this, &AXObjectCache::notificationPostTimerFired) |
106 { | 108 { |
107 m_document = const_cast<Document*>(doc); | 109 m_document = const_cast<Document*>(doc); |
108 } | 110 } |
109 | 111 |
110 AXObjectCache::~AXObjectCache() | 112 AXObjectCache::~AXObjectCache() |
111 { | 113 { |
112 m_notificationPostTimer.stop(); | 114 m_notificationPostTimer.stop(); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 | 228 |
227 if (renderID) | 229 if (renderID) |
228 return m_objects.get(renderID); | 230 return m_objects.get(renderID); |
229 | 231 |
230 if (!nodeID) | 232 if (!nodeID) |
231 return 0; | 233 return 0; |
232 | 234 |
233 return m_objects.get(nodeID); | 235 return m_objects.get(nodeID); |
234 } | 236 } |
235 | 237 |
| 238 AccessibilityObject* AXObjectCache::get(InlineTextBox* inlineTextBox) |
| 239 { |
| 240 if (!inlineTextBox) |
| 241 return 0; |
| 242 |
| 243 AXID axID = m_inlineTextBoxObjectMapping.get(inlineTextBox); |
| 244 ASSERT(!HashTraits<AXID>::isDeletedValue(axID)); |
| 245 if (!axID) |
| 246 return 0; |
| 247 |
| 248 return m_objects.get(axID); |
| 249 } |
| 250 |
236 // FIXME: This probably belongs on Node. | 251 // FIXME: This probably belongs on Node. |
237 // FIXME: This should take a const char*, but one caller passes nullAtom. | 252 // FIXME: This should take a const char*, but one caller passes nullAtom. |
238 bool nodeHasRole(Node* node, const String& role) | 253 bool nodeHasRole(Node* node, const String& role) |
239 { | 254 { |
240 if (!node || !node->isElementNode()) | 255 if (!node || !node->isElementNode()) |
241 return false; | 256 return false; |
242 | 257 |
243 return equalIgnoringCase(toElement(node)->getAttribute(roleAttr), role); | 258 return equalIgnoringCase(toElement(node)->getAttribute(roleAttr), role); |
244 } | 259 } |
245 | 260 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 } | 309 } |
295 | 310 |
296 return AccessibilityRenderObject::create(renderer); | 311 return AccessibilityRenderObject::create(renderer); |
297 } | 312 } |
298 | 313 |
299 static PassRefPtr<AccessibilityObject> createFromNode(Node* node) | 314 static PassRefPtr<AccessibilityObject> createFromNode(Node* node) |
300 { | 315 { |
301 return AccessibilityNodeObject::create(node); | 316 return AccessibilityNodeObject::create(node); |
302 } | 317 } |
303 | 318 |
| 319 static PassRefPtr<AccessibilityObject> createFromInlineTextBox(InlineTextBox* in
lineTextBox) |
| 320 { |
| 321 return AccessibilityInlineTextBox::create(inlineTextBox); |
| 322 } |
| 323 |
304 AccessibilityObject* AXObjectCache::getOrCreate(Widget* widget) | 324 AccessibilityObject* AXObjectCache::getOrCreate(Widget* widget) |
305 { | 325 { |
306 if (!widget) | 326 if (!widget) |
307 return 0; | 327 return 0; |
308 | 328 |
309 if (AccessibilityObject* obj = get(widget)) | 329 if (AccessibilityObject* obj = get(widget)) |
310 return obj; | 330 return obj; |
311 | 331 |
312 RefPtr<AccessibilityObject> newObj = 0; | 332 RefPtr<AccessibilityObject> newObj = 0; |
313 if (widget->isFrameView()) | 333 if (widget->isFrameView()) |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 | 401 |
382 m_renderObjectMapping.set(renderer, newObj->axObjectID()); | 402 m_renderObjectMapping.set(renderer, newObj->axObjectID()); |
383 m_objects.set(newObj->axObjectID(), newObj); | 403 m_objects.set(newObj->axObjectID(), newObj); |
384 newObj->init(); | 404 newObj->init(); |
385 attachWrapper(newObj.get()); | 405 attachWrapper(newObj.get()); |
386 newObj->setLastKnownIsIgnoredValue(newObj->accessibilityIsIgnored()); | 406 newObj->setLastKnownIsIgnoredValue(newObj->accessibilityIsIgnored()); |
387 | 407 |
388 return newObj.get(); | 408 return newObj.get(); |
389 } | 409 } |
390 | 410 |
| 411 AccessibilityObject* AXObjectCache::getOrCreate(InlineTextBox* inlineTextBox) |
| 412 { |
| 413 if (!inlineTextBox) |
| 414 return 0; |
| 415 |
| 416 if (AccessibilityObject* obj = get(inlineTextBox)) |
| 417 return obj; |
| 418 |
| 419 RefPtr<AccessibilityObject> newObj = createFromInlineTextBox(inlineTextBox); |
| 420 |
| 421 // Will crash later if we have two objects for the same inlineTextBox. |
| 422 ASSERT(!get(inlineTextBox)); |
| 423 |
| 424 getAXID(newObj.get()); |
| 425 |
| 426 m_inlineTextBoxObjectMapping.set(inlineTextBox, newObj->axObjectID()); |
| 427 m_objects.set(newObj->axObjectID(), newObj); |
| 428 newObj->init(); |
| 429 attachWrapper(newObj.get()); |
| 430 newObj->setLastKnownIsIgnoredValue(newObj->accessibilityIsIgnored()); |
| 431 |
| 432 return newObj.get(); |
| 433 } |
| 434 |
391 AccessibilityObject* AXObjectCache::rootObject() | 435 AccessibilityObject* AXObjectCache::rootObject() |
392 { | 436 { |
393 if (!gAccessibilityEnabled) | 437 if (!gAccessibilityEnabled) |
394 return 0; | 438 return 0; |
395 | 439 |
396 return getOrCreate(m_document->view()); | 440 return getOrCreate(m_document->view()); |
397 } | 441 } |
398 | 442 |
399 AccessibilityObject* AXObjectCache::getOrCreate(AccessibilityRole role) | 443 AccessibilityObject* AXObjectCache::getOrCreate(AccessibilityRole role) |
400 { | 444 { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 void AXObjectCache::remove(Widget* view) | 540 void AXObjectCache::remove(Widget* view) |
497 { | 541 { |
498 if (!view) | 542 if (!view) |
499 return; | 543 return; |
500 | 544 |
501 AXID axID = m_widgetObjectMapping.get(view); | 545 AXID axID = m_widgetObjectMapping.get(view); |
502 remove(axID); | 546 remove(axID); |
503 m_widgetObjectMapping.remove(view); | 547 m_widgetObjectMapping.remove(view); |
504 } | 548 } |
505 | 549 |
| 550 void AXObjectCache::remove(InlineTextBox* inlineTextBox) |
| 551 { |
| 552 if (!inlineTextBox) |
| 553 return; |
| 554 |
| 555 AXID axID = m_inlineTextBoxObjectMapping.get(inlineTextBox); |
| 556 remove(axID); |
| 557 m_inlineTextBoxObjectMapping.remove(inlineTextBox); |
| 558 } |
506 | 559 |
507 AXID AXObjectCache::platformGenerateAXID() const | 560 AXID AXObjectCache::platformGenerateAXID() const |
508 { | 561 { |
509 static AXID lastUsedID = 0; | 562 static AXID lastUsedID = 0; |
510 | 563 |
511 // Generate a new ID. | 564 // Generate a new ID. |
512 AXID objID = lastUsedID; | 565 AXID objID = lastUsedID; |
513 do { | 566 do { |
514 ++objID; | 567 ++objID; |
515 } while (!objID || HashTraits<AXID>::isDeletedValue(objID) || m_idsInUse.con
tains(objID)); | 568 } while (!objID || HashTraits<AXID>::isDeletedValue(objID) || m_idsInUse.con
tains(objID)); |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 void AXObjectCache::handleScrolledToAnchor(const Node* anchorNode) | 1016 void AXObjectCache::handleScrolledToAnchor(const Node* anchorNode) |
964 { | 1017 { |
965 // The anchor node may not be accessible. Post the notification for the | 1018 // The anchor node may not be accessible. Post the notification for the |
966 // first accessible object. | 1019 // first accessible object. |
967 postPlatformNotification(AccessibilityObject::firstAccessibleObjectFromNode(
anchorNode), AXScrolledToAnchor); | 1020 postPlatformNotification(AccessibilityObject::firstAccessibleObjectFromNode(
anchorNode), AXScrolledToAnchor); |
968 } | 1021 } |
969 | 1022 |
970 } // namespace WebCore | 1023 } // namespace WebCore |
971 | 1024 |
972 #endif // HAVE(ACCESSIBILITY) | 1025 #endif // HAVE(ACCESSIBILITY) |
OLD | NEW |