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 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 | 483 |
484 ASSERT(m_objects.size() >= m_idsInUse.size()); | 484 ASSERT(m_objects.size() >= m_idsInUse.size()); |
485 } | 485 } |
486 | 486 |
487 void AXObjectCacheImpl::remove(LayoutObject* layoutObject) { | 487 void AXObjectCacheImpl::remove(LayoutObject* layoutObject) { |
488 if (!layoutObject) | 488 if (!layoutObject) |
489 return; | 489 return; |
490 | 490 |
491 AXID axID = m_layoutObjectMapping.get(layoutObject); | 491 AXID axID = m_layoutObjectMapping.get(layoutObject); |
492 remove(axID); | 492 remove(axID); |
493 m_layoutObjectMapping.remove(layoutObject); | 493 m_layoutObjectMapping.erase(layoutObject); |
494 } | 494 } |
495 | 495 |
496 void AXObjectCacheImpl::remove(Node* node) { | 496 void AXObjectCacheImpl::remove(Node* node) { |
497 if (!node) | 497 if (!node) |
498 return; | 498 return; |
499 | 499 |
500 // This is all safe even if we didn't have a mapping. | 500 // This is all safe even if we didn't have a mapping. |
501 AXID axID = m_nodeObjectMapping.get(node); | 501 AXID axID = m_nodeObjectMapping.get(node); |
502 remove(axID); | 502 remove(axID); |
503 m_nodeObjectMapping.remove(node); | 503 m_nodeObjectMapping.erase(node); |
504 | 504 |
505 if (node->layoutObject()) { | 505 if (node->layoutObject()) { |
506 remove(node->layoutObject()); | 506 remove(node->layoutObject()); |
507 return; | 507 return; |
508 } | 508 } |
509 } | 509 } |
510 | 510 |
511 void AXObjectCacheImpl::remove(AbstractInlineTextBox* inlineTextBox) { | 511 void AXObjectCacheImpl::remove(AbstractInlineTextBox* inlineTextBox) { |
512 if (!inlineTextBox) | 512 if (!inlineTextBox) |
513 return; | 513 return; |
514 | 514 |
515 AXID axID = m_inlineTextBoxObjectMapping.get(inlineTextBox); | 515 AXID axID = m_inlineTextBoxObjectMapping.get(inlineTextBox); |
516 remove(axID); | 516 remove(axID); |
517 m_inlineTextBoxObjectMapping.remove(inlineTextBox); | 517 m_inlineTextBoxObjectMapping.erase(inlineTextBox); |
518 } | 518 } |
519 | 519 |
520 AXID AXObjectCacheImpl::platformGenerateAXID() const { | 520 AXID AXObjectCacheImpl::platformGenerateAXID() const { |
521 static AXID lastUsedID = 0; | 521 static AXID lastUsedID = 0; |
522 | 522 |
523 // Generate a new ID. | 523 // Generate a new ID. |
524 AXID objID = lastUsedID; | 524 AXID objID = lastUsedID; |
525 do { | 525 do { |
526 ++objID; | 526 ++objID; |
527 } while (!objID || HashTraits<AXID>::isDeletedValue(objID) || | 527 } while (!objID || HashTraits<AXID>::isDeletedValue(objID) || |
(...skipping 28 matching lines...) Expand all Loading... |
556 if (!objID) | 556 if (!objID) |
557 return; | 557 return; |
558 ASSERT(!HashTraits<AXID>::isDeletedValue(objID)); | 558 ASSERT(!HashTraits<AXID>::isDeletedValue(objID)); |
559 ASSERT(m_idsInUse.contains(objID)); | 559 ASSERT(m_idsInUse.contains(objID)); |
560 object->setAXObjectID(0); | 560 object->setAXObjectID(0); |
561 m_idsInUse.remove(objID); | 561 m_idsInUse.remove(objID); |
562 | 562 |
563 if (m_ariaOwnerToChildrenMapping.contains(objID)) { | 563 if (m_ariaOwnerToChildrenMapping.contains(objID)) { |
564 Vector<AXID> childAXIDs = m_ariaOwnerToChildrenMapping.get(objID); | 564 Vector<AXID> childAXIDs = m_ariaOwnerToChildrenMapping.get(objID); |
565 for (size_t i = 0; i < childAXIDs.size(); ++i) | 565 for (size_t i = 0; i < childAXIDs.size(); ++i) |
566 m_ariaOwnedChildToOwnerMapping.remove(childAXIDs[i]); | 566 m_ariaOwnedChildToOwnerMapping.erase(childAXIDs[i]); |
567 m_ariaOwnerToChildrenMapping.remove(objID); | 567 m_ariaOwnerToChildrenMapping.erase(objID); |
568 } | 568 } |
569 m_ariaOwnedChildToOwnerMapping.remove(objID); | 569 m_ariaOwnedChildToOwnerMapping.erase(objID); |
570 m_ariaOwnedChildToRealParentMapping.remove(objID); | 570 m_ariaOwnedChildToRealParentMapping.erase(objID); |
571 m_ariaOwnerToIdsMapping.remove(objID); | 571 m_ariaOwnerToIdsMapping.erase(objID); |
572 } | 572 } |
573 | 573 |
574 void AXObjectCacheImpl::selectionChanged(Node* node) { | 574 void AXObjectCacheImpl::selectionChanged(Node* node) { |
575 // Find the nearest ancestor that already has an accessibility object, since | 575 // Find the nearest ancestor that already has an accessibility object, since |
576 // we might be in the middle of a layout. | 576 // we might be in the middle of a layout. |
577 while (node) { | 577 while (node) { |
578 if (AXObject* obj = get(node)) { | 578 if (AXObject* obj = get(node)) { |
579 obj->selectionChanged(); | 579 obj->selectionChanged(); |
580 return; | 580 return; |
581 } | 581 } |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 owners->insert(owner->axObjectID()); | 723 owners->insert(owner->axObjectID()); |
724 } | 724 } |
725 } | 725 } |
726 for (const String& id : currentIds) { | 726 for (const String& id : currentIds) { |
727 if (!newIds.contains(id)) { | 727 if (!newIds.contains(id)) { |
728 idsChanged = true; | 728 idsChanged = true; |
729 HashSet<AXID>* owners = m_idToAriaOwnersMapping.get(id); | 729 HashSet<AXID>* owners = m_idToAriaOwnersMapping.get(id); |
730 if (owners) { | 730 if (owners) { |
731 owners->remove(owner->axObjectID()); | 731 owners->remove(owner->axObjectID()); |
732 if (owners->isEmpty()) | 732 if (owners->isEmpty()) |
733 m_idToAriaOwnersMapping.remove(id); | 733 m_idToAriaOwnersMapping.erase(id); |
734 } | 734 } |
735 } | 735 } |
736 } | 736 } |
737 if (idsChanged) | 737 if (idsChanged) |
738 m_ariaOwnerToIdsMapping.set(owner->axObjectID(), newIds); | 738 m_ariaOwnerToIdsMapping.set(owner->axObjectID(), newIds); |
739 | 739 |
740 // | 740 // |
741 // Now figure out the ids that actually correspond to children that exist and | 741 // Now figure out the ids that actually correspond to children that exist and |
742 // that we can legally own (not cyclical, not already owned, etc.) and update | 742 // that we can legally own (not cyclical, not already owned, etc.) and update |
743 // the maps and |ownedChildren| based on that. | 743 // the maps and |ownedChildren| based on that. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 AXID removedChildID = currentChildAXIDs[i]; | 805 AXID removedChildID = currentChildAXIDs[i]; |
806 AXObject* removedChild = objectFromAXID(removedChildID); | 806 AXObject* removedChild = objectFromAXID(removedChildID); |
807 | 807 |
808 // It's possible that this child has already been owned by some other owner, | 808 // It's possible that this child has already been owned by some other owner, |
809 // in which case we don't need to do anything. | 809 // in which case we don't need to do anything. |
810 if (removedChild && getAriaOwnedParent(removedChild) != owner) | 810 if (removedChild && getAriaOwnedParent(removedChild) != owner) |
811 continue; | 811 continue; |
812 | 812 |
813 // Remove it from the child -> owner mapping so it's not owned by this owner | 813 // Remove it from the child -> owner mapping so it's not owned by this owner |
814 // anymore. | 814 // anymore. |
815 m_ariaOwnedChildToOwnerMapping.remove(removedChildID); | 815 m_ariaOwnedChildToOwnerMapping.erase(removedChildID); |
816 | 816 |
817 if (removedChild) { | 817 if (removedChild) { |
818 // If the child still exists, find its "real" parent, and reparent it back | 818 // If the child still exists, find its "real" parent, and reparent it back |
819 // to its real parent in the tree by detaching it from its current parent | 819 // to its real parent in the tree by detaching it from its current parent |
820 // and calling childrenChanged on its real parent. | 820 // and calling childrenChanged on its real parent. |
821 removedChild->detachFromParent(); | 821 removedChild->detachFromParent(); |
822 AXID realParentID = | 822 AXID realParentID = |
823 m_ariaOwnedChildToRealParentMapping.get(removedChildID); | 823 m_ariaOwnedChildToRealParentMapping.get(removedChildID); |
824 AXObject* realParent = objectFromAXID(realParentID); | 824 AXObject* realParent = objectFromAXID(realParentID); |
825 childrenChanged(realParent); | 825 childrenChanged(realParent); |
826 } | 826 } |
827 | 827 |
828 // Remove the child -> original parent mapping too since this object has now | 828 // Remove the child -> original parent mapping too since this object has now |
829 // been reparented back to its original parent. | 829 // been reparented back to its original parent. |
830 m_ariaOwnedChildToRealParentMapping.remove(removedChildID); | 830 m_ariaOwnedChildToRealParentMapping.erase(removedChildID); |
831 } | 831 } |
832 | 832 |
833 for (size_t i = 0; i < newChildAXIDs.size(); ++i) { | 833 for (size_t i = 0; i < newChildAXIDs.size(); ++i) { |
834 // Find the AXObject for the child that will now be a child of this owner. | 834 // Find the AXObject for the child that will now be a child of this owner. |
835 AXID addedChildID = newChildAXIDs[i]; | 835 AXID addedChildID = newChildAXIDs[i]; |
836 AXObject* addedChild = objectFromAXID(addedChildID); | 836 AXObject* addedChild = objectFromAXID(addedChildID); |
837 | 837 |
838 // Add this child to the mapping from child to owner. | 838 // Add this child to the mapping from child to owner. |
839 m_ariaOwnedChildToOwnerMapping.set(addedChildID, owner->axObjectID()); | 839 m_ariaOwnedChildToOwnerMapping.set(addedChildID, owner->axObjectID()); |
840 | 840 |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 visitor->trace(m_document); | 1252 visitor->trace(m_document); |
1253 visitor->trace(m_nodeObjectMapping); | 1253 visitor->trace(m_nodeObjectMapping); |
1254 | 1254 |
1255 visitor->trace(m_objects); | 1255 visitor->trace(m_objects); |
1256 visitor->trace(m_notificationsToPost); | 1256 visitor->trace(m_notificationsToPost); |
1257 | 1257 |
1258 AXObjectCache::trace(visitor); | 1258 AXObjectCache::trace(visitor); |
1259 } | 1259 } |
1260 | 1260 |
1261 } // namespace blink | 1261 } // namespace blink |
OLD | NEW |