| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|    81 namespace blink { |    81 namespace blink { | 
|    82  |    82  | 
|    83 using namespace HTMLNames; |    83 using namespace HTMLNames; | 
|    84  |    84  | 
|    85 // static |    85 // static | 
|    86 AXObjectCache* AXObjectCache::create(Document& document) |    86 AXObjectCache* AXObjectCache::create(Document& document) | 
|    87 { |    87 { | 
|    88     return new AXObjectCacheImpl(document); |    88     return new AXObjectCacheImpl(document); | 
|    89 } |    89 } | 
|    90  |    90  | 
|    91 AXObjectInclusion AXComputedObjectAttributeCache::getIgnored(AXID id) const |  | 
|    92 { |  | 
|    93     HashMap<AXID, CachedAXObjectAttributes>::const_iterator it = m_idMapping.fin
      d(id); |  | 
|    94     return it != m_idMapping.end() ? it->value.ignored : DefaultBehavior; |  | 
|    95 } |  | 
|    96  |  | 
|    97 void AXComputedObjectAttributeCache::setIgnored(AXID id, AXObjectInclusion inclu
      sion) |  | 
|    98 { |  | 
|    99     HashMap<AXID, CachedAXObjectAttributes>::iterator it = m_idMapping.find(id); |  | 
|   100     if (it != m_idMapping.end()) { |  | 
|   101         it->value.ignored = inclusion; |  | 
|   102     } else { |  | 
|   103         CachedAXObjectAttributes attributes; |  | 
|   104         attributes.ignored = inclusion; |  | 
|   105         m_idMapping.set(id, attributes); |  | 
|   106     } |  | 
|   107 } |  | 
|   108  |  | 
|   109 void AXComputedObjectAttributeCache::clear() |  | 
|   110 { |  | 
|   111     m_idMapping.clear(); |  | 
|   112 } |  | 
|   113  |  | 
|   114 AXObjectCacheImpl::AXObjectCacheImpl(Document& document) |    91 AXObjectCacheImpl::AXObjectCacheImpl(Document& document) | 
|   115     : m_document(document) |    92     : m_document(document) | 
 |    93     , m_modificationCount(0) | 
|   116     , m_notificationPostTimer(this, &AXObjectCacheImpl::notificationPostTimerFir
      ed) |    94     , m_notificationPostTimer(this, &AXObjectCacheImpl::notificationPostTimerFir
      ed) | 
|   117 { |    95 { | 
|   118     m_computedObjectAttributeCache = AXComputedObjectAttributeCache::create(); |  | 
|   119 } |    96 } | 
|   120  |    97  | 
|   121 AXObjectCacheImpl::~AXObjectCacheImpl() |    98 AXObjectCacheImpl::~AXObjectCacheImpl() | 
|   122 { |    99 { | 
|   123     m_notificationPostTimer.stop(); |   100     m_notificationPostTimer.stop(); | 
|   124  |   101  | 
|   125     HashMap<AXID, RefPtr<AXObject> >::iterator end = m_objects.end(); |   102     HashMap<AXID, RefPtr<AXObject> >::iterator end = m_objects.end(); | 
|   126     for (HashMap<AXID, RefPtr<AXObject> >::iterator it = m_objects.begin(); it !
      = end; ++it) { |   103     for (HashMap<AXID, RefPtr<AXObject> >::iterator it = m_objects.begin(); it !
      = end; ++it) { | 
|   127         AXObject* obj = (*it).value.get(); |   104         AXObject* obj = (*it).value.get(); | 
|   128         detachWrapper(obj); |   105         detachWrapper(obj); | 
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   751     } |   728     } | 
|   752  |   729  | 
|   753     m_notificationsToPost.clear(); |   730     m_notificationsToPost.clear(); | 
|   754 } |   731 } | 
|   755  |   732  | 
|   756 void AXObjectCacheImpl::postNotification(RenderObject* renderer, AXNotification 
      notification, bool postToElement, PostType postType) |   733 void AXObjectCacheImpl::postNotification(RenderObject* renderer, AXNotification 
      notification, bool postToElement, PostType postType) | 
|   757 { |   734 { | 
|   758     if (!renderer) |   735     if (!renderer) | 
|   759         return; |   736         return; | 
|   760  |   737  | 
|   761     m_computedObjectAttributeCache->clear(); |   738     m_modificationCount++; | 
|   762  |   739  | 
|   763     // Get an accessibility object that already exists. One should not be create
      d here |   740     // Get an accessibility object that already exists. One should not be create
      d here | 
|   764     // because a render update may be in progress and creating an AX object can 
      re-trigger a layout |   741     // because a render update may be in progress and creating an AX object can 
      re-trigger a layout | 
|   765     RefPtr<AXObject> object = get(renderer); |   742     RefPtr<AXObject> object = get(renderer); | 
|   766     while (!object && renderer) { |   743     while (!object && renderer) { | 
|   767         renderer = renderer->parent(); |   744         renderer = renderer->parent(); | 
|   768         object = get(renderer); |   745         object = get(renderer); | 
|   769     } |   746     } | 
|   770  |   747  | 
|   771     if (!renderer) |   748     if (!renderer) | 
|   772         return; |   749         return; | 
|   773  |   750  | 
|   774     postNotification(object.get(), &renderer->document(), notification, postToEl
      ement, postType); |   751     postNotification(object.get(), &renderer->document(), notification, postToEl
      ement, postType); | 
|   775 } |   752 } | 
|   776  |   753  | 
|   777 void AXObjectCacheImpl::postNotification(Node* node, AXNotification notification
      , bool postToElement, PostType postType) |   754 void AXObjectCacheImpl::postNotification(Node* node, AXNotification notification
      , bool postToElement, PostType postType) | 
|   778 { |   755 { | 
|   779     if (!node) |   756     if (!node) | 
|   780         return; |   757         return; | 
|   781  |   758  | 
|   782     m_computedObjectAttributeCache->clear(); |   759     m_modificationCount++; | 
|   783  |   760  | 
|   784     // Get an accessibility object that already exists. One should not be create
      d here |   761     // Get an accessibility object that already exists. One should not be create
      d here | 
|   785     // because a render update may be in progress and creating an AX object can 
      re-trigger a layout |   762     // because a render update may be in progress and creating an AX object can 
      re-trigger a layout | 
|   786     RefPtr<AXObject> object = get(node); |   763     RefPtr<AXObject> object = get(node); | 
|   787     while (!object && node) { |   764     while (!object && node) { | 
|   788         node = node->parentNode(); |   765         node = node->parentNode(); | 
|   789         object = get(node); |   766         object = get(node); | 
|   790     } |   767     } | 
|   791  |   768  | 
|   792     if (!node) |   769     if (!node) | 
|   793         return; |   770         return; | 
|   794  |   771  | 
|   795     postNotification(object.get(), &node->document(), notification, postToElemen
      t, postType); |   772     postNotification(object.get(), &node->document(), notification, postToElemen
      t, postType); | 
|   796 } |   773 } | 
|   797  |   774  | 
|   798 void AXObjectCacheImpl::postNotification(AXObject* object, Document* document, A
      XNotification notification, bool postToElement, PostType postType) |   775 void AXObjectCacheImpl::postNotification(AXObject* object, Document* document, A
      XNotification notification, bool postToElement, PostType postType) | 
|   799 { |   776 { | 
|   800     m_computedObjectAttributeCache->clear(); |   777     m_modificationCount++; | 
|   801  |   778  | 
|   802     if (object && !postToElement) |   779     if (object && !postToElement) | 
|   803         object = object->observableObject(); |   780         object = object->observableObject(); | 
|   804  |   781  | 
|   805     if (!object && document) |   782     if (!object && document) | 
|   806         object = get(document->renderView()); |   783         object = get(document->renderView()); | 
|   807  |   784  | 
|   808     if (!object) |   785     if (!object) | 
|   809         return; |   786         return; | 
|   810  |   787  | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
|   836     postNotification(renderer, AXSelectedChildrenChanged, false); |   813     postNotification(renderer, AXSelectedChildrenChanged, false); | 
|   837 } |   814 } | 
|   838  |   815  | 
|   839 void AXObjectCacheImpl::handleScrollbarUpdate(FrameView* view) |   816 void AXObjectCacheImpl::handleScrollbarUpdate(FrameView* view) | 
|   840 { |   817 { | 
|   841     if (!view) |   818     if (!view) | 
|   842         return; |   819         return; | 
|   843  |   820  | 
|   844     // We don't want to create a scroll view from this method, only update an ex
      isting one. |   821     // We don't want to create a scroll view from this method, only update an ex
      isting one. | 
|   845     if (AXObject* scrollViewObject = get(view)) { |   822     if (AXObject* scrollViewObject = get(view)) { | 
|   846         m_computedObjectAttributeCache->clear(); |   823         m_modificationCount++; | 
|   847         scrollViewObject->updateChildrenIfNecessary(); |   824         scrollViewObject->updateChildrenIfNecessary(); | 
|   848     } |   825     } | 
|   849 } |   826 } | 
|   850  |   827  | 
|   851 void AXObjectCacheImpl::handleLayoutComplete(RenderObject* renderer) |   828 void AXObjectCacheImpl::handleLayoutComplete(RenderObject* renderer) | 
|   852 { |   829 { | 
|   853     if (!renderer) |   830     if (!renderer) | 
|   854         return; |   831         return; | 
|   855  |   832  | 
|   856     m_computedObjectAttributeCache->clear(); |   833     m_modificationCount++; | 
|   857  |   834  | 
|   858     // Create the AXObject if it didn't yet exist - that's always safe at the en
      d of a layout, and it |   835     // Create the AXObject if it didn't yet exist - that's always safe at the en
      d of a layout, and it | 
|   859     // allows an AX notification to be sent when a page has its first layout, ra
      ther than when the |   836     // allows an AX notification to be sent when a page has its first layout, ra
      ther than when the | 
|   860     // document first loads. |   837     // document first loads. | 
|   861     if (AXObject* obj = getOrCreate(renderer)) |   838     if (AXObject* obj = getOrCreate(renderer)) | 
|   862         postNotification(obj, obj->document(), AXLayoutComplete, true); |   839         postNotification(obj, obj->document(), AXLayoutComplete, true); | 
|   863 } |   840 } | 
|   864  |   841  | 
|   865 void AXObjectCacheImpl::handleAriaExpandedChange(Node* node) |   842 void AXObjectCacheImpl::handleAriaExpandedChange(Node* node) | 
|   866 { |   843 { | 
|   867     if (AXObject* obj = getOrCreate(node)) |   844     if (AXObject* obj = getOrCreate(node)) | 
|   868         obj->handleAriaExpandedChanged(); |   845         obj->handleAriaExpandedChanged(); | 
|   869 } |   846 } | 
|   870  |   847  | 
|   871 void AXObjectCacheImpl::handleActiveDescendantChanged(Node* node) |   848 void AXObjectCacheImpl::handleActiveDescendantChanged(Node* node) | 
|   872 { |   849 { | 
|   873     if (AXObject* obj = getOrCreate(node)) |   850     if (AXObject* obj = getOrCreate(node)) | 
|   874         obj->handleActiveDescendantChanged(); |   851         obj->handleActiveDescendantChanged(); | 
|   875 } |   852 } | 
|   876  |   853  | 
|   877 void AXObjectCacheImpl::handleAriaRoleChanged(Node* node) |   854 void AXObjectCacheImpl::handleAriaRoleChanged(Node* node) | 
|   878 { |   855 { | 
|   879     if (AXObject* obj = getOrCreate(node)) { |   856     if (AXObject* obj = getOrCreate(node)) { | 
|   880         obj->updateAccessibilityRole(); |   857         obj->updateAccessibilityRole(); | 
|   881         m_computedObjectAttributeCache->clear(); |   858         m_modificationCount++; | 
|   882         obj->notifyIfIgnoredValueChanged(); |   859         obj->notifyIfIgnoredValueChanged(); | 
|   883     } |   860     } | 
|   884 } |   861 } | 
|   885  |   862  | 
|   886 void AXObjectCacheImpl::handleAttributeChanged(const QualifiedName& attrName, El
      ement* element) |   863 void AXObjectCacheImpl::handleAttributeChanged(const QualifiedName& attrName, El
      ement* element) | 
|   887 { |   864 { | 
|   888     if (attrName == roleAttr) |   865     if (attrName == roleAttr) | 
|   889         handleAriaRoleChanged(element); |   866         handleAriaRoleChanged(element); | 
|   890     else if (attrName == altAttr || attrName == titleAttr) |   867     else if (attrName == altAttr || attrName == titleAttr) | 
|   891         textChanged(element); |   868         textChanged(element); | 
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1110 void AXObjectCacheImpl::setCanvasObjectBounds(Element* element, const LayoutRect
      & rect) |  1087 void AXObjectCacheImpl::setCanvasObjectBounds(Element* element, const LayoutRect
      & rect) | 
|  1111 { |  1088 { | 
|  1112     AXObject* obj = getOrCreate(element); |  1089     AXObject* obj = getOrCreate(element); | 
|  1113     if (!obj) |  1090     if (!obj) | 
|  1114         return; |  1091         return; | 
|  1115  |  1092  | 
|  1116     obj->setElementRect(rect); |  1093     obj->setElementRect(rect); | 
|  1117 } |  1094 } | 
|  1118  |  1095  | 
|  1119 } // namespace blink |  1096 } // namespace blink | 
| OLD | NEW |