| 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 return 0; | 199 return 0; |
| 200 | 200 |
| 201 return m_objects.get(axID); | 201 return m_objects.get(axID); |
| 202 } | 202 } |
| 203 | 203 |
| 204 AXObject* AXObjectCacheImpl::get(Node* node) | 204 AXObject* AXObjectCacheImpl::get(Node* node) |
| 205 { | 205 { |
| 206 if (!node) | 206 if (!node) |
| 207 return 0; | 207 return 0; |
| 208 | 208 |
| 209 AXID layoutID = node->renderer() ? m_layoutObjectMapping.get(node->renderer(
)) : 0; | 209 AXID layoutID = node->layoutObject() ? m_layoutObjectMapping.get(node->layou
tObject()) : 0; |
| 210 ASSERT(!HashTraits<AXID>::isDeletedValue(layoutID)); | 210 ASSERT(!HashTraits<AXID>::isDeletedValue(layoutID)); |
| 211 | 211 |
| 212 AXID nodeID = m_nodeObjectMapping.get(node); | 212 AXID nodeID = m_nodeObjectMapping.get(node); |
| 213 ASSERT(!HashTraits<AXID>::isDeletedValue(nodeID)); | 213 ASSERT(!HashTraits<AXID>::isDeletedValue(nodeID)); |
| 214 | 214 |
| 215 if (node->renderer() && nodeID && !layoutID) { | 215 if (node->layoutObject() && nodeID && !layoutID) { |
| 216 // This can happen if an AXNodeObject is created for a node that's not | 216 // This can happen if an AXNodeObject is created for a node that's not |
| 217 // laid out, but later something changes and it gets a layoutObject (lik
e if it's | 217 // laid out, but later something changes and it gets a layoutObject (lik
e if it's |
| 218 // reparented). | 218 // reparented). |
| 219 remove(nodeID); | 219 remove(nodeID); |
| 220 return 0; | 220 return 0; |
| 221 } | 221 } |
| 222 | 222 |
| 223 if (layoutID) | 223 if (layoutID) |
| 224 return m_objects.get(layoutID); | 224 return m_objects.get(layoutID); |
| 225 | 225 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 } | 349 } |
| 350 | 350 |
| 351 AXObject* AXObjectCacheImpl::getOrCreate(Node* node) | 351 AXObject* AXObjectCacheImpl::getOrCreate(Node* node) |
| 352 { | 352 { |
| 353 if (!node) | 353 if (!node) |
| 354 return 0; | 354 return 0; |
| 355 | 355 |
| 356 if (AXObject* obj = get(node)) | 356 if (AXObject* obj = get(node)) |
| 357 return obj; | 357 return obj; |
| 358 | 358 |
| 359 if (node->renderer()) | 359 if (node->layoutObject()) |
| 360 return getOrCreate(node->renderer()); | 360 return getOrCreate(node->layoutObject()); |
| 361 | 361 |
| 362 if (!node->parentElement()) | 362 if (!node->parentElement()) |
| 363 return 0; | 363 return 0; |
| 364 | 364 |
| 365 // It's only allowed to create an AXObject from a Node if it's in a canvas s
ubtree. | 365 // It's only allowed to create an AXObject from a Node if it's in a canvas s
ubtree. |
| 366 // Or if it's a hidden element, but we still want to expose it because of ot
her ARIA attributes. | 366 // Or if it's a hidden element, but we still want to expose it because of ot
her ARIA attributes. |
| 367 bool inCanvasSubtree = node->parentElement()->isInCanvasSubtree(); | 367 bool inCanvasSubtree = node->parentElement()->isInCanvasSubtree(); |
| 368 bool isHidden = !node->renderer() && isNodeAriaVisible(node); | 368 bool isHidden = !node->layoutObject() && isNodeAriaVisible(node); |
| 369 if (!inCanvasSubtree && !isHidden) | 369 if (!inCanvasSubtree && !isHidden) |
| 370 return 0; | 370 return 0; |
| 371 | 371 |
| 372 RefPtr<AXObject> newObj = createFromNode(node); | 372 RefPtr<AXObject> newObj = createFromNode(node); |
| 373 | 373 |
| 374 // Will crash later if we have two objects for the same node. | 374 // Will crash later if we have two objects for the same node. |
| 375 ASSERT(!get(node)); | 375 ASSERT(!get(node)); |
| 376 | 376 |
| 377 getAXID(newObj.get()); | 377 getAXID(newObj.get()); |
| 378 | 378 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 if (!node) | 517 if (!node) |
| 518 return; | 518 return; |
| 519 | 519 |
| 520 removeNodeForUse(node); | 520 removeNodeForUse(node); |
| 521 | 521 |
| 522 // This is all safe even if we didn't have a mapping. | 522 // This is all safe even if we didn't have a mapping. |
| 523 AXID axID = m_nodeObjectMapping.get(node); | 523 AXID axID = m_nodeObjectMapping.get(node); |
| 524 remove(axID); | 524 remove(axID); |
| 525 m_nodeObjectMapping.remove(node); | 525 m_nodeObjectMapping.remove(node); |
| 526 | 526 |
| 527 if (node->renderer()) { | 527 if (node->layoutObject()) { |
| 528 remove(node->renderer()); | 528 remove(node->layoutObject()); |
| 529 return; | 529 return; |
| 530 } | 530 } |
| 531 } | 531 } |
| 532 | 532 |
| 533 void AXObjectCacheImpl::remove(Widget* view) | 533 void AXObjectCacheImpl::remove(Widget* view) |
| 534 { | 534 { |
| 535 if (!view) | 535 if (!view) |
| 536 return; | 536 return; |
| 537 | 537 |
| 538 AXID axID = m_widgetObjectMapping.get(view); | 538 AXID axID = m_widgetObjectMapping.get(view); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 continue; | 690 continue; |
| 691 | 691 |
| 692 if (!obj->axObjectCache()) | 692 if (!obj->axObjectCache()) |
| 693 continue; | 693 continue; |
| 694 | 694 |
| 695 #if ENABLE(ASSERT) | 695 #if ENABLE(ASSERT) |
| 696 // Make sure none of the layout views are in the process of being layed
out. | 696 // Make sure none of the layout views are in the process of being layed
out. |
| 697 // Notifications should only be sent after the layoutObject has finished | 697 // Notifications should only be sent after the layoutObject has finished |
| 698 if (obj->isAXLayoutObject()) { | 698 if (obj->isAXLayoutObject()) { |
| 699 AXLayoutObject* layoutObj = toAXLayoutObject(obj); | 699 AXLayoutObject* layoutObj = toAXLayoutObject(obj); |
| 700 LayoutObject* layoutObject = layoutObj->renderer(); | 700 LayoutObject* layoutObject = layoutObj->layoutObject(); |
| 701 if (layoutObject && layoutObject->view()) | 701 if (layoutObject && layoutObject->view()) |
| 702 ASSERT(!layoutObject->view()->layoutState()); | 702 ASSERT(!layoutObject->view()->layoutState()); |
| 703 } | 703 } |
| 704 #endif | 704 #endif |
| 705 | 705 |
| 706 AXNotification notification = m_notificationsToPost[i].second; | 706 AXNotification notification = m_notificationsToPost[i].second; |
| 707 postPlatformNotification(obj, notification); | 707 postPlatformNotification(obj, notification); |
| 708 | 708 |
| 709 if (notification == AXChildrenChanged && obj->parentObjectIfExists() &&
obj->lastKnownIsIgnoredValue() != obj->accessibilityIsIgnored()) | 709 if (notification == AXChildrenChanged && obj->parentObjectIfExists() &&
obj->lastKnownIsIgnoredValue() != obj->accessibilityIsIgnored()) |
| 710 childrenChanged(obj->parentObject()); | 710 childrenChanged(obj->parentObject()); |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 } | 929 } |
| 930 | 930 |
| 931 return result; | 931 return result; |
| 932 } | 932 } |
| 933 | 933 |
| 934 AXObject* AXObjectCacheImpl::firstAccessibleObjectFromNode(const Node* node) | 934 AXObject* AXObjectCacheImpl::firstAccessibleObjectFromNode(const Node* node) |
| 935 { | 935 { |
| 936 if (!node) | 936 if (!node) |
| 937 return 0; | 937 return 0; |
| 938 | 938 |
| 939 AXObject* accessibleObject = getOrCreate(node->renderer()); | 939 AXObject* accessibleObject = getOrCreate(node->layoutObject()); |
| 940 while (accessibleObject && accessibleObject->accessibilityIsIgnored()) { | 940 while (accessibleObject && accessibleObject->accessibilityIsIgnored()) { |
| 941 node = NodeTraversal::next(*node); | 941 node = NodeTraversal::next(*node); |
| 942 | 942 |
| 943 while (node && !node->renderer()) | 943 while (node && !node->layoutObject()) |
| 944 node = NodeTraversal::nextSkippingChildren(*node); | 944 node = NodeTraversal::nextSkippingChildren(*node); |
| 945 | 945 |
| 946 if (!node) | 946 if (!node) |
| 947 return 0; | 947 return 0; |
| 948 | 948 |
| 949 accessibleObject = getOrCreate(node->renderer()); | 949 accessibleObject = getOrCreate(node->layoutObject()); |
| 950 } | 950 } |
| 951 | 951 |
| 952 return accessibleObject; | 952 return accessibleObject; |
| 953 } | 953 } |
| 954 | 954 |
| 955 bool AXObjectCacheImpl::nodeIsTextControl(const Node* node) | 955 bool AXObjectCacheImpl::nodeIsTextControl(const Node* node) |
| 956 { | 956 { |
| 957 if (!node) | 957 if (!node) |
| 958 return false; | 958 return false; |
| 959 | 959 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 void AXObjectCacheImpl::setCanvasObjectBounds(Element* element, const LayoutRect
& rect) | 1121 void AXObjectCacheImpl::setCanvasObjectBounds(Element* element, const LayoutRect
& rect) |
| 1122 { | 1122 { |
| 1123 AXObject* obj = getOrCreate(element); | 1123 AXObject* obj = getOrCreate(element); |
| 1124 if (!obj) | 1124 if (!obj) |
| 1125 return; | 1125 return; |
| 1126 | 1126 |
| 1127 obj->setElementRect(rect); | 1127 obj->setElementRect(rect); |
| 1128 } | 1128 } |
| 1129 | 1129 |
| 1130 } // namespace blink | 1130 } // namespace blink |
| OLD | NEW |