| 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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 return 0; | 196 return 0; |
| 197 | 197 |
| 198 AXID axID = m_layoutObjectMapping.get(layoutObject); | 198 AXID axID = m_layoutObjectMapping.get(layoutObject); |
| 199 ASSERT(!HashTraits<AXID>::isDeletedValue(axID)); | 199 ASSERT(!HashTraits<AXID>::isDeletedValue(axID)); |
| 200 if (!axID) | 200 if (!axID) |
| 201 return 0; | 201 return 0; |
| 202 | 202 |
| 203 return m_objects.get(axID); | 203 return m_objects.get(axID); |
| 204 } | 204 } |
| 205 | 205 |
| 206 // Returns true if |node| is an <option> element and its parent <select> | |
| 207 // is a menu list (not a list box). | |
| 208 static bool isMenuListOption(Node* node) | |
| 209 { | |
| 210 if (!isHTMLOptionElement(node)) | |
| 211 return false; | |
| 212 Element* parent = node->parentElement(); | |
| 213 if (!isHTMLSelectElement(parent)) | |
| 214 return false; | |
| 215 LayoutObject* layoutObject = toHTMLSelectElement(node->parentElement())->lay
outObject(); | |
| 216 return layoutObject && layoutObject->isMenuList(); | |
| 217 } | |
| 218 | |
| 219 AXObject* AXObjectCacheImpl::get(Node* node) | 206 AXObject* AXObjectCacheImpl::get(Node* node) |
| 220 { | 207 { |
| 221 if (!node) | 208 if (!node) |
| 222 return 0; | 209 return 0; |
| 223 | 210 |
| 224 AXID layoutID = node->layoutObject() ? m_layoutObjectMapping.get(node->layou
tObject()) : 0; | 211 AXID layoutID = node->layoutObject() ? m_layoutObjectMapping.get(node->layou
tObject()) : 0; |
| 225 ASSERT(!HashTraits<AXID>::isDeletedValue(layoutID)); | 212 ASSERT(!HashTraits<AXID>::isDeletedValue(layoutID)); |
| 226 | 213 |
| 227 AXID nodeID = m_nodeObjectMapping.get(node); | 214 AXID nodeID = m_nodeObjectMapping.get(node); |
| 228 ASSERT(!HashTraits<AXID>::isDeletedValue(nodeID)); | 215 ASSERT(!HashTraits<AXID>::isDeletedValue(nodeID)); |
| 229 | 216 |
| 230 if (node->layoutObject() && nodeID && !layoutID && !isMenuListOption(node))
{ | 217 if (node->layoutObject() && nodeID && !layoutID) { |
| 231 // This can happen if an AXNodeObject is created for a node that's not | 218 // This can happen if an AXNodeObject is created for a node that's not |
| 232 // laid out, but later something changes and it gets a layoutObject (lik
e if it's | 219 // laid out, but later something changes and it gets a layoutObject (lik
e if it's |
| 233 // reparented). | 220 // reparented). |
| 234 remove(nodeID); | 221 remove(nodeID); |
| 235 return 0; | 222 return 0; |
| 236 } | 223 } |
| 237 | 224 |
| 238 if (layoutID) | 225 if (layoutID) |
| 239 return m_objects.get(layoutID); | 226 return m_objects.get(layoutID); |
| 240 | 227 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 // input type=range | 305 // input type=range |
| 319 if (cssBox->isSlider()) | 306 if (cssBox->isSlider()) |
| 320 return AXSlider::create(toLayoutSlider(cssBox), this); | 307 return AXSlider::create(toLayoutSlider(cssBox), this); |
| 321 } | 308 } |
| 322 | 309 |
| 323 return AXLayoutObject::create(layoutObject, this); | 310 return AXLayoutObject::create(layoutObject, this); |
| 324 } | 311 } |
| 325 | 312 |
| 326 PassRefPtr<AXObject> AXObjectCacheImpl::createFromNode(Node* node) | 313 PassRefPtr<AXObject> AXObjectCacheImpl::createFromNode(Node* node) |
| 327 { | 314 { |
| 328 if (isMenuListOption(node)) | |
| 329 return AXMenuListOption::create(toHTMLOptionElement(node), this); | |
| 330 | |
| 331 return AXNodeObject::create(node, this); | 315 return AXNodeObject::create(node, this); |
| 332 } | 316 } |
| 333 | 317 |
| 334 PassRefPtr<AXObject> AXObjectCacheImpl::createFromInlineTextBox(AbstractInlineTe
xtBox* inlineTextBox) | 318 PassRefPtr<AXObject> AXObjectCacheImpl::createFromInlineTextBox(AbstractInlineTe
xtBox* inlineTextBox) |
| 335 { | 319 { |
| 336 return AXInlineTextBox::create(inlineTextBox, this); | 320 return AXInlineTextBox::create(inlineTextBox, this); |
| 337 } | 321 } |
| 338 | 322 |
| 339 AXObject* AXObjectCacheImpl::getOrCreate(Widget* widget) | 323 AXObject* AXObjectCacheImpl::getOrCreate(Widget* widget) |
| 340 { | 324 { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 if (node->layoutObject()) | 361 if (node->layoutObject()) |
| 378 return getOrCreate(node->layoutObject()); | 362 return getOrCreate(node->layoutObject()); |
| 379 | 363 |
| 380 if (!node->parentElement()) | 364 if (!node->parentElement()) |
| 381 return 0; | 365 return 0; |
| 382 | 366 |
| 383 // It's only allowed to create an AXObject from a Node if it's in a canvas s
ubtree. | 367 // It's only allowed to create an AXObject from a Node if it's in a canvas s
ubtree. |
| 384 // Or if it's a hidden element, but we still want to expose it because of ot
her ARIA attributes. | 368 // Or if it's a hidden element, but we still want to expose it because of ot
her ARIA attributes. |
| 385 bool inCanvasSubtree = node->parentElement()->isInCanvasSubtree(); | 369 bool inCanvasSubtree = node->parentElement()->isInCanvasSubtree(); |
| 386 bool isHidden = !node->layoutObject() && isNodeAriaVisible(node); | 370 bool isHidden = !node->layoutObject() && isNodeAriaVisible(node); |
| 387 if (!inCanvasSubtree && !isHidden && !isMenuListOption(node)) | 371 if (!inCanvasSubtree && !isHidden) |
| 388 return 0; | 372 return 0; |
| 389 | 373 |
| 390 RefPtr<AXObject> newObj = createFromNode(node); | 374 RefPtr<AXObject> newObj = createFromNode(node); |
| 391 | 375 |
| 392 // Will crash later if we have two objects for the same node. | 376 // Will crash later if we have two objects for the same node. |
| 393 ASSERT(!get(node)); | 377 ASSERT(!get(node)); |
| 394 | 378 |
| 395 getAXID(newObj.get()); | 379 getAXID(newObj.get()); |
| 396 | 380 |
| 397 m_nodeObjectMapping.set(node, newObj->axObjectID()); | 381 m_nodeObjectMapping.set(node, newObj->axObjectID()); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 break; | 454 break; |
| 471 case TableHeaderContainerRole: | 455 case TableHeaderContainerRole: |
| 472 obj = AXTableHeaderContainer::create(this); | 456 obj = AXTableHeaderContainer::create(this); |
| 473 break; | 457 break; |
| 474 case SliderThumbRole: | 458 case SliderThumbRole: |
| 475 obj = AXSliderThumb::create(this); | 459 obj = AXSliderThumb::create(this); |
| 476 break; | 460 break; |
| 477 case MenuListPopupRole: | 461 case MenuListPopupRole: |
| 478 obj = AXMenuListPopup::create(this); | 462 obj = AXMenuListPopup::create(this); |
| 479 break; | 463 break; |
| 464 case MenuListOptionRole: |
| 465 obj = AXMenuListOption::create(this); |
| 466 break; |
| 480 case SpinButtonRole: | 467 case SpinButtonRole: |
| 481 obj = AXSpinButton::create(this); | 468 obj = AXSpinButton::create(this); |
| 482 break; | 469 break; |
| 483 case SpinButtonPartRole: | 470 case SpinButtonPartRole: |
| 484 obj = AXSpinButtonPart::create(this); | 471 obj = AXSpinButtonPart::create(this); |
| 485 break; | 472 break; |
| 486 default: | 473 default: |
| 487 obj = nullptr; | 474 obj = nullptr; |
| 488 } | 475 } |
| 489 | 476 |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 void AXObjectCacheImpl::setCanvasObjectBounds(Element* element, const LayoutRect
& rect) | 1125 void AXObjectCacheImpl::setCanvasObjectBounds(Element* element, const LayoutRect
& rect) |
| 1139 { | 1126 { |
| 1140 AXObject* obj = getOrCreate(element); | 1127 AXObject* obj = getOrCreate(element); |
| 1141 if (!obj) | 1128 if (!obj) |
| 1142 return; | 1129 return; |
| 1143 | 1130 |
| 1144 obj->setElementRect(rect); | 1131 obj->setElementRect(rect); |
| 1145 } | 1132 } |
| 1146 | 1133 |
| 1147 } // namespace blink | 1134 } // namespace blink |
| OLD | NEW |