OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2014, Google Inc. All rights reserved. | 2 * Copyright (C) 2014, Google 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 return false; | 224 return false; |
225 LayoutObject* layoutObject = select->layoutObject(); | 225 LayoutObject* layoutObject = select->layoutObject(); |
226 return layoutObject && layoutObject->isMenuList(); | 226 return layoutObject && layoutObject->isMenuList(); |
227 } | 227 } |
228 | 228 |
229 AXObject* AXObjectCacheImpl::get(Node* node) | 229 AXObject* AXObjectCacheImpl::get(Node* node) |
230 { | 230 { |
231 if (!node) | 231 if (!node) |
232 return 0; | 232 return 0; |
233 | 233 |
234 AXID layoutID = node->layoutObject() ? m_layoutObjectMapping.get(node->layou
tObject()) : 0; | 234 // Menu list option and HTML area elements are indexed by DOM node, never by
layout object. |
| 235 LayoutObject* layoutObject = node->layoutObject(); |
| 236 if (isMenuListOption(node) || isHTMLAreaElement(node)) |
| 237 layoutObject = nullptr; |
| 238 |
| 239 AXID layoutID = layoutObject ? m_layoutObjectMapping.get(layoutObject) : 0; |
235 ASSERT(!HashTraits<AXID>::isDeletedValue(layoutID)); | 240 ASSERT(!HashTraits<AXID>::isDeletedValue(layoutID)); |
236 | 241 |
237 AXID nodeID = m_nodeObjectMapping.get(node); | 242 AXID nodeID = m_nodeObjectMapping.get(node); |
238 ASSERT(!HashTraits<AXID>::isDeletedValue(nodeID)); | 243 ASSERT(!HashTraits<AXID>::isDeletedValue(nodeID)); |
239 | 244 |
240 if (node->layoutObject() && nodeID && !layoutID && !isMenuListOption(node))
{ | 245 if (layoutObject && nodeID && !layoutID) { |
241 // This can happen if an AXNodeObject is created for a node that's not | 246 // This can happen if an AXNodeObject is created for a node that's not |
242 // laid out, but later something changes and it gets a layoutObject (lik
e if it's | 247 // laid out, but later something changes and it gets a layoutObject (lik
e if it's |
243 // reparented). | 248 // reparented). |
244 remove(nodeID); | 249 remove(nodeID); |
245 return 0; | 250 return 0; |
246 } | 251 } |
247 | 252 |
248 if (layoutID) | 253 if (layoutID) |
249 return m_objects.get(layoutID); | 254 return m_objects.get(layoutID); |
250 | 255 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 } | 336 } |
332 | 337 |
333 return AXLayoutObject::create(layoutObject, *this); | 338 return AXLayoutObject::create(layoutObject, *this); |
334 } | 339 } |
335 | 340 |
336 AXObject* AXObjectCacheImpl::createFromNode(Node* node) | 341 AXObject* AXObjectCacheImpl::createFromNode(Node* node) |
337 { | 342 { |
338 if (isMenuListOption(node)) | 343 if (isMenuListOption(node)) |
339 return AXMenuListOption::create(toHTMLOptionElement(node), *this); | 344 return AXMenuListOption::create(toHTMLOptionElement(node), *this); |
340 | 345 |
| 346 if (isHTMLAreaElement(node)) |
| 347 return AXImageMapLink::create(toHTMLAreaElement(node), *this); |
| 348 |
341 return AXNodeObject::create(node, *this); | 349 return AXNodeObject::create(node, *this); |
342 } | 350 } |
343 | 351 |
344 AXObject* AXObjectCacheImpl::createFromInlineTextBox(AbstractInlineTextBox* inli
neTextBox) | 352 AXObject* AXObjectCacheImpl::createFromInlineTextBox(AbstractInlineTextBox* inli
neTextBox) |
345 { | 353 { |
346 return AXInlineTextBox::create(inlineTextBox, *this); | 354 return AXInlineTextBox::create(inlineTextBox, *this); |
347 } | 355 } |
348 | 356 |
349 AXObject* AXObjectCacheImpl::getOrCreate(Widget* widget) | 357 AXObject* AXObjectCacheImpl::getOrCreate(Widget* widget) |
350 { | 358 { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 } | 393 } |
386 | 394 |
387 AXObject* AXObjectCacheImpl::getOrCreate(Node* node) | 395 AXObject* AXObjectCacheImpl::getOrCreate(Node* node) |
388 { | 396 { |
389 if (!node) | 397 if (!node) |
390 return 0; | 398 return 0; |
391 | 399 |
392 if (AXObject* obj = get(node)) | 400 if (AXObject* obj = get(node)) |
393 return obj; | 401 return obj; |
394 | 402 |
395 if (node->layoutObject()) | 403 // If the node has a layout object, prefer using that as the primary key for
the AXObject, |
| 404 // with the exception of an HTMLAreaElement, which is created based on its n
ode. |
| 405 if (node->layoutObject() && !isHTMLAreaElement(node)) |
396 return getOrCreate(node->layoutObject()); | 406 return getOrCreate(node->layoutObject()); |
397 | 407 |
398 if (!node->parentElement()) | 408 if (!node->parentElement()) |
399 return 0; | 409 return 0; |
400 | 410 |
401 if (isHTMLHeadElement(node)) | 411 if (isHTMLHeadElement(node)) |
402 return 0; | 412 return 0; |
403 | 413 |
404 AXObject* newObj = createFromNode(node); | 414 AXObject* newObj = createFromNode(node); |
405 | 415 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 | 482 |
473 return getOrCreate(m_document->view()); | 483 return getOrCreate(m_document->view()); |
474 } | 484 } |
475 | 485 |
476 AXObject* AXObjectCacheImpl::getOrCreate(AccessibilityRole role) | 486 AXObject* AXObjectCacheImpl::getOrCreate(AccessibilityRole role) |
477 { | 487 { |
478 AXObject* obj = nullptr; | 488 AXObject* obj = nullptr; |
479 | 489 |
480 // will be filled in... | 490 // will be filled in... |
481 switch (role) { | 491 switch (role) { |
482 case ImageMapLinkRole: | |
483 obj = AXImageMapLink::create(*this); | |
484 break; | |
485 case ColumnRole: | 492 case ColumnRole: |
486 obj = AXTableColumn::create(*this); | 493 obj = AXTableColumn::create(*this); |
487 break; | 494 break; |
488 case TableHeaderContainerRole: | 495 case TableHeaderContainerRole: |
489 obj = AXTableHeaderContainer::create(*this); | 496 obj = AXTableHeaderContainer::create(*this); |
490 break; | 497 break; |
491 case SliderThumbRole: | 498 case SliderThumbRole: |
492 obj = AXSliderThumb::create(*this); | 499 obj = AXSliderThumb::create(*this); |
493 break; | 500 break; |
494 case MenuListPopupRole: | 501 case MenuListPopupRole: |
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1360 visitor->trace(m_nodeObjectMapping); | 1367 visitor->trace(m_nodeObjectMapping); |
1361 #endif | 1368 #endif |
1362 | 1369 |
1363 visitor->trace(m_objects); | 1370 visitor->trace(m_objects); |
1364 visitor->trace(m_notificationsToPost); | 1371 visitor->trace(m_notificationsToPost); |
1365 | 1372 |
1366 AXObjectCache::trace(visitor); | 1373 AXObjectCache::trace(visitor); |
1367 } | 1374 } |
1368 | 1375 |
1369 } // namespace blink | 1376 } // namespace blink |
OLD | NEW |