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