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