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

Side by Side Diff: Source/core/accessibility/AXObjectCache.cpp

Issue 23983002: Expose InlineTextBoxes in the accessibility tree. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix include path Created 7 years, 2 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 | Annotate | Revision Log
OLDNEW
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
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 m_idMapping.set(id, attributes); 99 m_idMapping.set(id, attributes);
99 } 100 }
100 } 101 }
101 102
102 void AXComputedObjectAttributeCache::clear() 103 void AXComputedObjectAttributeCache::clear()
103 { 104 {
104 m_idMapping.clear(); 105 m_idMapping.clear();
105 } 106 }
106 107
107 bool AXObjectCache::gAccessibilityEnabled = false; 108 bool AXObjectCache::gAccessibilityEnabled = false;
109 bool AXObjectCache::gInlineTextBoxAccessibility = false;
108 110
109 AXObjectCache::AXObjectCache(const Document* doc) 111 AXObjectCache::AXObjectCache(const Document* doc)
110 : m_notificationPostTimer(this, &AXObjectCache::notificationPostTimerFired) 112 : m_notificationPostTimer(this, &AXObjectCache::notificationPostTimerFired)
111 { 113 {
112 m_document = const_cast<Document*>(doc); 114 m_document = const_cast<Document*>(doc);
113 m_computedObjectAttributeCache = AXComputedObjectAttributeCache::create(); 115 m_computedObjectAttributeCache = AXComputedObjectAttributeCache::create();
114 } 116 }
115 117
116 AXObjectCache::~AXObjectCache() 118 AXObjectCache::~AXObjectCache()
117 { 119 {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 234
233 if (renderID) 235 if (renderID)
234 return m_objects.get(renderID); 236 return m_objects.get(renderID);
235 237
236 if (!nodeID) 238 if (!nodeID)
237 return 0; 239 return 0;
238 240
239 return m_objects.get(nodeID); 241 return m_objects.get(nodeID);
240 } 242 }
241 243
244 AccessibilityObject* AXObjectCache::get(InlineTextBox* inlineTextBox)
245 {
246 if (!inlineTextBox)
247 return 0;
248
249 AXID axID = m_inlineTextBoxObjectMapping.get(inlineTextBox);
250 ASSERT(!HashTraits<AXID>::isDeletedValue(axID));
251 if (!axID)
252 return 0;
253
254 return m_objects.get(axID);
255 }
256
242 // FIXME: This probably belongs on Node. 257 // FIXME: This probably belongs on Node.
243 // FIXME: This should take a const char*, but one caller passes nullAtom. 258 // FIXME: This should take a const char*, but one caller passes nullAtom.
244 bool nodeHasRole(Node* node, const String& role) 259 bool nodeHasRole(Node* node, const String& role)
245 { 260 {
246 if (!node || !node->isElementNode()) 261 if (!node || !node->isElementNode())
247 return false; 262 return false;
248 263
249 return equalIgnoringCase(toElement(node)->getAttribute(roleAttr), role); 264 return equalIgnoringCase(toElement(node)->getAttribute(roleAttr), role);
250 } 265 }
251 266
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 } 315 }
301 316
302 return AccessibilityRenderObject::create(renderer); 317 return AccessibilityRenderObject::create(renderer);
303 } 318 }
304 319
305 static PassRefPtr<AccessibilityObject> createFromNode(Node* node) 320 static PassRefPtr<AccessibilityObject> createFromNode(Node* node)
306 { 321 {
307 return AccessibilityNodeObject::create(node); 322 return AccessibilityNodeObject::create(node);
308 } 323 }
309 324
325 static PassRefPtr<AccessibilityObject> createFromInlineTextBox(RenderText* rende rText, RenderText::AbstractInlineTextBox* inlineTextBox)
326 {
327 return AccessibilityInlineTextBox::create(renderText, inlineTextBox);
328 }
329
310 AccessibilityObject* AXObjectCache::getOrCreate(Widget* widget) 330 AccessibilityObject* AXObjectCache::getOrCreate(Widget* widget)
311 { 331 {
312 if (!widget) 332 if (!widget)
313 return 0; 333 return 0;
314 334
315 if (AccessibilityObject* obj = get(widget)) 335 if (AccessibilityObject* obj = get(widget))
316 return obj; 336 return obj;
317 337
318 RefPtr<AccessibilityObject> newObj = 0; 338 RefPtr<AccessibilityObject> newObj = 0;
319 if (widget->isFrameView()) 339 if (widget->isFrameView())
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 407
388 m_renderObjectMapping.set(renderer, newObj->axObjectID()); 408 m_renderObjectMapping.set(renderer, newObj->axObjectID());
389 m_objects.set(newObj->axObjectID(), newObj); 409 m_objects.set(newObj->axObjectID(), newObj);
390 newObj->init(); 410 newObj->init();
391 attachWrapper(newObj.get()); 411 attachWrapper(newObj.get());
392 newObj->setLastKnownIsIgnoredValue(newObj->accessibilityIsIgnored()); 412 newObj->setLastKnownIsIgnoredValue(newObj->accessibilityIsIgnored());
393 413
394 return newObj.get(); 414 return newObj.get();
395 } 415 }
396 416
417 AccessibilityObject* AXObjectCache::getOrCreate(RenderText* renderText, RenderTe xt::AbstractInlineTextBox* inlineTextBox)
418 {
419 if (!renderText || !inlineTextBox)
420 return 0;
421
422 if (AccessibilityObject* obj = get(inlineTextBox))
423 return obj;
424
425 RefPtr<AccessibilityObject> newObj = createFromInlineTextBox(renderText, inl ineTextBox);
426
427 // Will crash later if we have two objects for the same inlineTextBox.
428 ASSERT(!get(inlineTextBox));
429
430 getAXID(newObj.get());
431
432 m_inlineTextBoxObjectMapping.set(inlineTextBox, newObj->axObjectID());
433 m_objects.set(newObj->axObjectID(), newObj);
434 newObj->init();
435 attachWrapper(newObj.get());
436 newObj->setLastKnownIsIgnoredValue(newObj->accessibilityIsIgnored());
437
438 return newObj.get();
439 }
440
397 AccessibilityObject* AXObjectCache::rootObject() 441 AccessibilityObject* AXObjectCache::rootObject()
398 { 442 {
399 if (!gAccessibilityEnabled) 443 if (!gAccessibilityEnabled)
400 return 0; 444 return 0;
401 445
402 return getOrCreate(m_document->view()); 446 return getOrCreate(m_document->view());
403 } 447 }
404 448
405 AccessibilityObject* AXObjectCache::getOrCreate(AccessibilityRole role) 449 AccessibilityObject* AXObjectCache::getOrCreate(AccessibilityRole role)
406 { 450 {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 void AXObjectCache::remove(Widget* view) 546 void AXObjectCache::remove(Widget* view)
503 { 547 {
504 if (!view) 548 if (!view)
505 return; 549 return;
506 550
507 AXID axID = m_widgetObjectMapping.get(view); 551 AXID axID = m_widgetObjectMapping.get(view);
508 remove(axID); 552 remove(axID);
509 m_widgetObjectMapping.remove(view); 553 m_widgetObjectMapping.remove(view);
510 } 554 }
511 555
556 void AXObjectCache::remove(InlineTextBox* inlineTextBox)
557 {
558 if (!inlineTextBox)
559 return;
560
561 AXID axID = m_inlineTextBoxObjectMapping.get(inlineTextBox);
562 remove(axID);
563 m_inlineTextBoxObjectMapping.remove(inlineTextBox);
564 }
512 565
513 AXID AXObjectCache::platformGenerateAXID() const 566 AXID AXObjectCache::platformGenerateAXID() const
514 { 567 {
515 static AXID lastUsedID = 0; 568 static AXID lastUsedID = 0;
516 569
517 // Generate a new ID. 570 // Generate a new ID.
518 AXID objID = lastUsedID; 571 AXID objID = lastUsedID;
519 do { 572 do {
520 ++objID; 573 ++objID;
521 } while (!objID || HashTraits<AXID>::isDeletedValue(objID) || m_idsInUse.con tains(objID)); 574 } while (!objID || HashTraits<AXID>::isDeletedValue(objID) || m_idsInUse.con tains(objID));
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 void AXObjectCache::handleScrolledToAnchor(const Node* anchorNode) 1021 void AXObjectCache::handleScrolledToAnchor(const Node* anchorNode)
969 { 1022 {
970 // The anchor node may not be accessible. Post the notification for the 1023 // The anchor node may not be accessible. Post the notification for the
971 // first accessible object. 1024 // first accessible object.
972 postPlatformNotification(AccessibilityObject::firstAccessibleObjectFromNode( anchorNode), AXScrolledToAnchor); 1025 postPlatformNotification(AccessibilityObject::firstAccessibleObjectFromNode( anchorNode), AXScrolledToAnchor);
973 } 1026 }
974 1027
975 } // namespace WebCore 1028 } // namespace WebCore
976 1029
977 #endif // HAVE(ACCESSIBILITY) 1030 #endif // HAVE(ACCESSIBILITY)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698