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 13 matching lines...) Expand all Loading... |
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 */ | 27 */ |
28 | 28 |
29 #include "modules/accessibility/AXObjectCacheImpl.h" | 29 #include "modules/accessibility/AXObjectCacheImpl.h" |
30 | 30 |
31 #include "core/HTMLNames.h" | 31 #include "core/HTMLNames.h" |
32 #include "core/InputTypeNames.h" | 32 #include "core/InputTypeNames.h" |
33 #include "core/dom/Document.h" | 33 #include "core/dom/Document.h" |
| 34 #include "core/dom/TaskRunnerHelper.h" |
34 #include "core/editing/EditingUtilities.h" | 35 #include "core/editing/EditingUtilities.h" |
35 #include "core/frame/FrameView.h" | 36 #include "core/frame/FrameView.h" |
36 #include "core/frame/LocalFrame.h" | 37 #include "core/frame/LocalFrame.h" |
37 #include "core/frame/Settings.h" | 38 #include "core/frame/Settings.h" |
38 #include "core/html/HTMLAreaElement.h" | 39 #include "core/html/HTMLAreaElement.h" |
39 #include "core/html/HTMLCanvasElement.h" | 40 #include "core/html/HTMLCanvasElement.h" |
40 #include "core/html/HTMLImageElement.h" | 41 #include "core/html/HTMLImageElement.h" |
41 #include "core/html/HTMLInputElement.h" | 42 #include "core/html/HTMLInputElement.h" |
42 #include "core/html/HTMLLabelElement.h" | 43 #include "core/html/HTMLLabelElement.h" |
43 #include "core/html/HTMLOptionElement.h" | 44 #include "core/html/HTMLOptionElement.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 { | 91 { |
91 return new AXObjectCacheImpl(document); | 92 return new AXObjectCacheImpl(document); |
92 } | 93 } |
93 | 94 |
94 AXObjectCacheImpl::AXObjectCacheImpl(Document& document) | 95 AXObjectCacheImpl::AXObjectCacheImpl(Document& document) |
95 : m_document(document) | 96 : m_document(document) |
96 , m_modificationCount(0) | 97 , m_modificationCount(0) |
97 #if ENABLE(ASSERT) | 98 #if ENABLE(ASSERT) |
98 , m_hasBeenDisposed(false) | 99 , m_hasBeenDisposed(false) |
99 #endif | 100 #endif |
100 , m_notificationPostTimer(this, &AXObjectCacheImpl::notificationPostTimerFir
ed) | |
101 { | 101 { |
102 } | 102 } |
103 | 103 |
104 AXObjectCacheImpl::~AXObjectCacheImpl() | 104 AXObjectCacheImpl::~AXObjectCacheImpl() |
105 { | 105 { |
106 ASSERT(m_hasBeenDisposed); | 106 ASSERT(m_hasBeenDisposed); |
107 } | 107 } |
108 | 108 |
109 void AXObjectCacheImpl::dispose() | 109 void AXObjectCacheImpl::dispose() |
110 { | 110 { |
111 m_notificationPostTimer.stop(); | 111 m_notificationPostCanceller.cancel(); |
112 | 112 |
113 for (auto& entry : m_objects) { | 113 for (auto& entry : m_objects) { |
114 AXObject* obj = entry.value; | 114 AXObject* obj = entry.value; |
115 obj->detach(); | 115 obj->detach(); |
116 removeAXID(obj); | 116 removeAXID(obj); |
117 } | 117 } |
118 | 118 |
119 #if ENABLE(ASSERT) | 119 #if ENABLE(ASSERT) |
120 m_hasBeenDisposed = true; | 120 m_hasBeenDisposed = true; |
121 #endif | 121 #endif |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 } | 641 } |
642 | 642 |
643 void AXObjectCacheImpl::childrenChanged(AXObject* obj) | 643 void AXObjectCacheImpl::childrenChanged(AXObject* obj) |
644 { | 644 { |
645 if (!obj) | 645 if (!obj) |
646 return; | 646 return; |
647 | 647 |
648 obj->childrenChanged(); | 648 obj->childrenChanged(); |
649 } | 649 } |
650 | 650 |
651 void AXObjectCacheImpl::notificationPostTimerFired(TimerBase*) | 651 void AXObjectCacheImpl::postNotificationsNow() |
652 { | 652 { |
653 m_notificationPostTimer.stop(); | |
654 | |
655 unsigned i = 0, count = m_notificationsToPost.size(); | 653 unsigned i = 0, count = m_notificationsToPost.size(); |
656 for (i = 0; i < count; ++i) { | 654 for (i = 0; i < count; ++i) { |
657 AXObject* obj = m_notificationsToPost[i].first; | 655 AXObject* obj = m_notificationsToPost[i].first; |
658 | 656 |
659 if (!obj->axObjectID()) | 657 if (!obj->axObjectID()) |
660 continue; | 658 continue; |
661 | 659 |
662 if (obj->isDetached()) | 660 if (obj->isDetached()) |
663 continue; | 661 continue; |
664 | 662 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 postNotification(get(node), notification); | 699 postNotification(get(node), notification); |
702 } | 700 } |
703 | 701 |
704 void AXObjectCacheImpl::postNotification(AXObject* object, AXNotification notifi
cation) | 702 void AXObjectCacheImpl::postNotification(AXObject* object, AXNotification notifi
cation) |
705 { | 703 { |
706 m_modificationCount++; | 704 m_modificationCount++; |
707 if (!object) | 705 if (!object) |
708 return; | 706 return; |
709 | 707 |
710 m_notificationsToPost.append(std::make_pair(object, notification)); | 708 m_notificationsToPost.append(std::make_pair(object, notification)); |
711 if (!m_notificationPostTimer.isActive()) | 709 if (m_notificationPostCanceller.isActive()) |
712 m_notificationPostTimer.startOneShot(0, BLINK_FROM_HERE); | 710 return; |
| 711 |
| 712 auto result = WTF::makeCancellable(WTF::bind(&AXObjectCacheImpl::postNotific
ationsNow, wrapWeakPersistent(this))); |
| 713 m_notificationPostCanceller = std::move(result.canceller); |
| 714 TaskRunnerHelper::get(TaskType::Internal, m_document)->postTask(BLINK_FROM_H
ERE, std::move(result.function)); |
713 } | 715 } |
714 | 716 |
715 bool AXObjectCacheImpl::isAriaOwned(const AXObject* child) const | 717 bool AXObjectCacheImpl::isAriaOwned(const AXObject* child) const |
716 { | 718 { |
717 return m_ariaOwnedChildToOwnerMapping.contains(child->axObjectID()); | 719 return m_ariaOwnedChildToOwnerMapping.contains(child->axObjectID()); |
718 } | 720 } |
719 | 721 |
720 AXObject* AXObjectCacheImpl::getAriaOwnedParent(const AXObject* child) const | 722 AXObject* AXObjectCacheImpl::getAriaOwnedParent(const AXObject* child) const |
721 { | 723 { |
722 return objectFromAXID(m_ariaOwnedChildToOwnerMapping.get(child->axObjectID()
)); | 724 return objectFromAXID(m_ariaOwnedChildToOwnerMapping.get(child->axObjectID()
)); |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1284 visitor->trace(m_document); | 1286 visitor->trace(m_document); |
1285 visitor->trace(m_nodeObjectMapping); | 1287 visitor->trace(m_nodeObjectMapping); |
1286 | 1288 |
1287 visitor->trace(m_objects); | 1289 visitor->trace(m_objects); |
1288 visitor->trace(m_notificationsToPost); | 1290 visitor->trace(m_notificationsToPost); |
1289 | 1291 |
1290 AXObjectCache::trace(visitor); | 1292 AXObjectCache::trace(visitor); |
1291 } | 1293 } |
1292 | 1294 |
1293 } // namespace blink | 1295 } // namespace blink |
OLD | NEW |