accessible/src/base/nsAccCache.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef _nsAccCache_H_
michael@0 7 #define _nsAccCache_H_
michael@0 8
michael@0 9 #include "nsIAccessible.h"
michael@0 10 #include "nsRefPtrHashtable.h"
michael@0 11 #include "nsCycleCollectionParticipant.h"
michael@0 12
michael@0 13 ////////////////////////////////////////////////////////////////////////////////
michael@0 14 // Accessible cache utils
michael@0 15 ////////////////////////////////////////////////////////////////////////////////
michael@0 16
michael@0 17 /**
michael@0 18 * Shutdown and removes the accessible from cache.
michael@0 19 */
michael@0 20 template <class T>
michael@0 21 static PLDHashOperator
michael@0 22 ClearCacheEntry(const void* aKey, nsRefPtr<T>& aAccessible, void* aUserArg)
michael@0 23 {
michael@0 24 NS_ASSERTION(aAccessible, "Calling ClearCacheEntry with a nullptr pointer!");
michael@0 25 if (aAccessible)
michael@0 26 aAccessible->Shutdown();
michael@0 27
michael@0 28 return PL_DHASH_REMOVE;
michael@0 29 }
michael@0 30
michael@0 31 /**
michael@0 32 * Clear the cache and shutdown the accessibles.
michael@0 33 */
michael@0 34
michael@0 35 static void
michael@0 36 ClearCache(mozilla::a11y::AccessibleHashtable& aCache)
michael@0 37 {
michael@0 38 aCache.Enumerate(ClearCacheEntry<mozilla::a11y::Accessible>, nullptr);
michael@0 39 }
michael@0 40
michael@0 41 /**
michael@0 42 * Traverse the accessible cache entry for cycle collector.
michael@0 43 */
michael@0 44 template <class T>
michael@0 45 static PLDHashOperator
michael@0 46 CycleCollectorTraverseCacheEntry(const void *aKey, T *aAccessible,
michael@0 47 void *aUserArg)
michael@0 48 {
michael@0 49 nsCycleCollectionTraversalCallback *cb =
michael@0 50 static_cast<nsCycleCollectionTraversalCallback*>(aUserArg);
michael@0 51
michael@0 52 NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(*cb, "accessible cache entry");
michael@0 53
michael@0 54 nsISupports *supports = static_cast<nsIAccessible*>(aAccessible);
michael@0 55 cb->NoteXPCOMChild(supports);
michael@0 56 return PL_DHASH_NEXT;
michael@0 57 }
michael@0 58
michael@0 59 /**
michael@0 60 * Unlink the accessible cache for the cycle collector.
michael@0 61 */
michael@0 62 inline void
michael@0 63 ImplCycleCollectionUnlink(mozilla::a11y::AccessibleHashtable& aCache)
michael@0 64 {
michael@0 65 ClearCache(aCache);
michael@0 66 }
michael@0 67
michael@0 68 /**
michael@0 69 * Traverse the accessible cache for cycle collector.
michael@0 70 */
michael@0 71 inline void
michael@0 72 ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
michael@0 73 mozilla::a11y::AccessibleHashtable& aCache,
michael@0 74 const char* aName,
michael@0 75 uint32_t aFlags = 0)
michael@0 76 {
michael@0 77 aCache.EnumerateRead(CycleCollectorTraverseCacheEntry<mozilla::a11y::Accessible>,
michael@0 78 &aCallback);
michael@0 79 }
michael@0 80
michael@0 81 #endif

mercurial