| 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/AXARIAGrid.h" | 36 #include "core/accessibility/AXARIAGrid.h" |
| 37 #include "core/accessibility/AXARIAGridCell.h" | 37 #include "core/accessibility/AXARIAGridCell.h" |
| 38 #include "core/accessibility/AXARIAGridRow.h" | 38 #include "core/accessibility/AXARIAGridRow.h" |
| 39 #include "core/accessibility/AXImageMapLink.h" | 39 #include "core/accessibility/AXImageMapLink.h" |
| 40 #include "core/accessibility/AXInlineTextBox.h" |
| 40 #include "core/accessibility/AXList.h" | 41 #include "core/accessibility/AXList.h" |
| 41 #include "core/accessibility/AXListBox.h" | 42 #include "core/accessibility/AXListBox.h" |
| 42 #include "core/accessibility/AXListBoxOption.h" | 43 #include "core/accessibility/AXListBoxOption.h" |
| 43 #include "core/accessibility/AXMediaControls.h" | 44 #include "core/accessibility/AXMediaControls.h" |
| 44 #include "core/accessibility/AXMenuList.h" | 45 #include "core/accessibility/AXMenuList.h" |
| 45 #include "core/accessibility/AXMenuListOption.h" | 46 #include "core/accessibility/AXMenuListOption.h" |
| 46 #include "core/accessibility/AXMenuListPopup.h" | 47 #include "core/accessibility/AXMenuListPopup.h" |
| 47 #include "core/accessibility/AXProgressIndicator.h" | 48 #include "core/accessibility/AXProgressIndicator.h" |
| 48 #include "core/accessibility/AXRenderObject.h" | 49 #include "core/accessibility/AXRenderObject.h" |
| 49 #include "core/accessibility/AXSVGRoot.h" | 50 #include "core/accessibility/AXSVGRoot.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 60 #include "core/frame/Frame.h" | 61 #include "core/frame/Frame.h" |
| 61 #include "core/html/HTMLAreaElement.h" | 62 #include "core/html/HTMLAreaElement.h" |
| 62 #include "core/html/HTMLImageElement.h" | 63 #include "core/html/HTMLImageElement.h" |
| 63 #include "core/html/HTMLInputElement.h" | 64 #include "core/html/HTMLInputElement.h" |
| 64 #include "core/html/HTMLLabelElement.h" | 65 #include "core/html/HTMLLabelElement.h" |
| 65 #include "core/page/Chrome.h" | 66 #include "core/page/Chrome.h" |
| 66 #include "core/page/ChromeClient.h" | 67 #include "core/page/ChromeClient.h" |
| 67 #include "core/page/FocusController.h" | 68 #include "core/page/FocusController.h" |
| 68 #include "core/page/Page.h" | 69 #include "core/page/Page.h" |
| 69 #include "core/platform/ScrollView.h" | 70 #include "core/platform/ScrollView.h" |
| 71 #include "core/rendering/AbstractInlineTextBox.h" |
| 70 #include "core/rendering/RenderListBox.h" | 72 #include "core/rendering/RenderListBox.h" |
| 71 #include "core/rendering/RenderMenuList.h" | 73 #include "core/rendering/RenderMenuList.h" |
| 72 #include "core/rendering/RenderProgress.h" | 74 #include "core/rendering/RenderProgress.h" |
| 73 #include "core/rendering/RenderSlider.h" | 75 #include "core/rendering/RenderSlider.h" |
| 74 #include "core/rendering/RenderTable.h" | 76 #include "core/rendering/RenderTable.h" |
| 75 #include "core/rendering/RenderTableCell.h" | 77 #include "core/rendering/RenderTableCell.h" |
| 76 #include "core/rendering/RenderTableRow.h" | 78 #include "core/rendering/RenderTableRow.h" |
| 77 #include "core/rendering/RenderView.h" | 79 #include "core/rendering/RenderView.h" |
| 78 #include "wtf/PassRefPtr.h" | 80 #include "wtf/PassRefPtr.h" |
| 79 | 81 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 98 m_idMapping.set(id, attributes); | 100 m_idMapping.set(id, attributes); |
| 99 } | 101 } |
| 100 } | 102 } |
| 101 | 103 |
| 102 void AXComputedObjectAttributeCache::clear() | 104 void AXComputedObjectAttributeCache::clear() |
| 103 { | 105 { |
| 104 m_idMapping.clear(); | 106 m_idMapping.clear(); |
| 105 } | 107 } |
| 106 | 108 |
| 107 bool AXObjectCache::gAccessibilityEnabled = false; | 109 bool AXObjectCache::gAccessibilityEnabled = false; |
| 110 bool AXObjectCache::gInlineTextBoxAccessibility = false; |
| 108 | 111 |
| 109 AXObjectCache::AXObjectCache(const Document* doc) | 112 AXObjectCache::AXObjectCache(const Document* doc) |
| 110 : m_notificationPostTimer(this, &AXObjectCache::notificationPostTimerFired) | 113 : m_notificationPostTimer(this, &AXObjectCache::notificationPostTimerFired) |
| 111 { | 114 { |
| 112 m_document = const_cast<Document*>(doc); | 115 m_document = const_cast<Document*>(doc); |
| 113 m_computedObjectAttributeCache = AXComputedObjectAttributeCache::create(); | 116 m_computedObjectAttributeCache = AXComputedObjectAttributeCache::create(); |
| 114 } | 117 } |
| 115 | 118 |
| 116 AXObjectCache::~AXObjectCache() | 119 AXObjectCache::~AXObjectCache() |
| 117 { | 120 { |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 | 235 |
| 233 if (renderID) | 236 if (renderID) |
| 234 return m_objects.get(renderID); | 237 return m_objects.get(renderID); |
| 235 | 238 |
| 236 if (!nodeID) | 239 if (!nodeID) |
| 237 return 0; | 240 return 0; |
| 238 | 241 |
| 239 return m_objects.get(nodeID); | 242 return m_objects.get(nodeID); |
| 240 } | 243 } |
| 241 | 244 |
| 245 AXObject* AXObjectCache::get(AbstractInlineTextBox* inlineTextBox) |
| 246 { |
| 247 if (!inlineTextBox) |
| 248 return 0; |
| 249 |
| 250 AXID axID = m_inlineTextBoxObjectMapping.get(inlineTextBox); |
| 251 ASSERT(!HashTraits<AXID>::isDeletedValue(axID)); |
| 252 if (!axID) |
| 253 return 0; |
| 254 |
| 255 return m_objects.get(axID); |
| 256 } |
| 257 |
| 242 // FIXME: This probably belongs on Node. | 258 // FIXME: This probably belongs on Node. |
| 243 // FIXME: This should take a const char*, but one caller passes nullAtom. | 259 // FIXME: This should take a const char*, but one caller passes nullAtom. |
| 244 bool nodeHasRole(Node* node, const String& role) | 260 bool nodeHasRole(Node* node, const String& role) |
| 245 { | 261 { |
| 246 if (!node || !node->isElementNode()) | 262 if (!node || !node->isElementNode()) |
| 247 return false; | 263 return false; |
| 248 | 264 |
| 249 return equalIgnoringCase(toElement(node)->getAttribute(roleAttr), role); | 265 return equalIgnoringCase(toElement(node)->getAttribute(roleAttr), role); |
| 250 } | 266 } |
| 251 | 267 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 } | 316 } |
| 301 | 317 |
| 302 return AXRenderObject::create(renderer); | 318 return AXRenderObject::create(renderer); |
| 303 } | 319 } |
| 304 | 320 |
| 305 static PassRefPtr<AXObject> createFromNode(Node* node) | 321 static PassRefPtr<AXObject> createFromNode(Node* node) |
| 306 { | 322 { |
| 307 return AXNodeObject::create(node); | 323 return AXNodeObject::create(node); |
| 308 } | 324 } |
| 309 | 325 |
| 326 static PassRefPtr<AXObject> createFromInlineTextBox(AbstractInlineTextBox* inlin
eTextBox) |
| 327 { |
| 328 return AXInlineTextBox::create(inlineTextBox); |
| 329 } |
| 330 |
| 310 AXObject* AXObjectCache::getOrCreate(Widget* widget) | 331 AXObject* AXObjectCache::getOrCreate(Widget* widget) |
| 311 { | 332 { |
| 312 if (!widget) | 333 if (!widget) |
| 313 return 0; | 334 return 0; |
| 314 | 335 |
| 315 if (AXObject* obj = get(widget)) | 336 if (AXObject* obj = get(widget)) |
| 316 return obj; | 337 return obj; |
| 317 | 338 |
| 318 RefPtr<AXObject> newObj = 0; | 339 RefPtr<AXObject> newObj = 0; |
| 319 if (widget->isFrameView()) | 340 if (widget->isFrameView()) |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 | 408 |
| 388 m_renderObjectMapping.set(renderer, newObj->axObjectID()); | 409 m_renderObjectMapping.set(renderer, newObj->axObjectID()); |
| 389 m_objects.set(newObj->axObjectID(), newObj); | 410 m_objects.set(newObj->axObjectID(), newObj); |
| 390 newObj->init(); | 411 newObj->init(); |
| 391 attachWrapper(newObj.get()); | 412 attachWrapper(newObj.get()); |
| 392 newObj->setLastKnownIsIgnoredValue(newObj->accessibilityIsIgnored()); | 413 newObj->setLastKnownIsIgnoredValue(newObj->accessibilityIsIgnored()); |
| 393 | 414 |
| 394 return newObj.get(); | 415 return newObj.get(); |
| 395 } | 416 } |
| 396 | 417 |
| 418 AXObject* AXObjectCache::getOrCreate(AbstractInlineTextBox* inlineTextBox) |
| 419 { |
| 420 if (!inlineTextBox) |
| 421 return 0; |
| 422 |
| 423 if (AXObject* obj = get(inlineTextBox)) |
| 424 return obj; |
| 425 |
| 426 RefPtr<AXObject> newObj = createFromInlineTextBox(inlineTextBox); |
| 427 |
| 428 // Will crash later if we have two objects for the same inlineTextBox. |
| 429 ASSERT(!get(inlineTextBox)); |
| 430 |
| 431 getAXID(newObj.get()); |
| 432 |
| 433 m_inlineTextBoxObjectMapping.set(inlineTextBox, newObj->axObjectID()); |
| 434 m_objects.set(newObj->axObjectID(), newObj); |
| 435 newObj->init(); |
| 436 attachWrapper(newObj.get()); |
| 437 newObj->setLastKnownIsIgnoredValue(newObj->accessibilityIsIgnored()); |
| 438 |
| 439 return newObj.get(); |
| 440 } |
| 441 |
| 397 AXObject* AXObjectCache::rootObject() | 442 AXObject* AXObjectCache::rootObject() |
| 398 { | 443 { |
| 399 if (!gAccessibilityEnabled) | 444 if (!gAccessibilityEnabled) |
| 400 return 0; | 445 return 0; |
| 401 | 446 |
| 402 return getOrCreate(m_document->view()); | 447 return getOrCreate(m_document->view()); |
| 403 } | 448 } |
| 404 | 449 |
| 405 AXObject* AXObjectCache::getOrCreate(AccessibilityRole role) | 450 AXObject* AXObjectCache::getOrCreate(AccessibilityRole role) |
| 406 { | 451 { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 void AXObjectCache::remove(Widget* view) | 547 void AXObjectCache::remove(Widget* view) |
| 503 { | 548 { |
| 504 if (!view) | 549 if (!view) |
| 505 return; | 550 return; |
| 506 | 551 |
| 507 AXID axID = m_widgetObjectMapping.get(view); | 552 AXID axID = m_widgetObjectMapping.get(view); |
| 508 remove(axID); | 553 remove(axID); |
| 509 m_widgetObjectMapping.remove(view); | 554 m_widgetObjectMapping.remove(view); |
| 510 } | 555 } |
| 511 | 556 |
| 557 void AXObjectCache::remove(AbstractInlineTextBox* inlineTextBox) |
| 558 { |
| 559 if (!inlineTextBox) |
| 560 return; |
| 561 |
| 562 AXID axID = m_inlineTextBoxObjectMapping.get(inlineTextBox); |
| 563 remove(axID); |
| 564 m_inlineTextBoxObjectMapping.remove(inlineTextBox); |
| 565 } |
| 512 | 566 |
| 513 AXID AXObjectCache::platformGenerateAXID() const | 567 AXID AXObjectCache::platformGenerateAXID() const |
| 514 { | 568 { |
| 515 static AXID lastUsedID = 0; | 569 static AXID lastUsedID = 0; |
| 516 | 570 |
| 517 // Generate a new ID. | 571 // Generate a new ID. |
| 518 AXID objID = lastUsedID; | 572 AXID objID = lastUsedID; |
| 519 do { | 573 do { |
| 520 ++objID; | 574 ++objID; |
| 521 } while (!objID || HashTraits<AXID>::isDeletedValue(objID) || m_idsInUse.con
tains(objID)); | 575 } while (!objID || HashTraits<AXID>::isDeletedValue(objID) || m_idsInUse.con
tains(objID)); |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 969 void AXObjectCache::handleScrolledToAnchor(const Node* anchorNode) | 1023 void AXObjectCache::handleScrolledToAnchor(const Node* anchorNode) |
| 970 { | 1024 { |
| 971 // The anchor node may not be accessible. Post the notification for the | 1025 // The anchor node may not be accessible. Post the notification for the |
| 972 // first accessible object. | 1026 // first accessible object. |
| 973 postPlatformNotification(AXObject::firstAccessibleObjectFromNode(anchorNode)
, AXScrolledToAnchor); | 1027 postPlatformNotification(AXObject::firstAccessibleObjectFromNode(anchorNode)
, AXScrolledToAnchor); |
| 974 } | 1028 } |
| 975 | 1029 |
| 976 } // namespace WebCore | 1030 } // namespace WebCore |
| 977 | 1031 |
| 978 #endif // HAVE(ACCESSIBILITY) | 1032 #endif // HAVE(ACCESSIBILITY) |
| OLD | NEW |