tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

MsaaIdGenerator.h (1238B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef mozilla_a11y_MsaaIdGenerator_h
      8 #define mozilla_a11y_MsaaIdGenerator_h
      9 
     10 #include "mozilla/a11y/IDSet.h"
     11 
     12 #include "mozilla/NotNull.h"
     13 #include "nsITimer.h"
     14 
     15 namespace mozilla {
     16 namespace a11y {
     17 
     18 class MsaaAccessible;
     19 
     20 /**
     21 * This class is responsible for generating child IDs used by our MSAA
     22 * implementation.
     23 */
     24 class MsaaIdGenerator {
     25 public:
     26  uint32_t GetID();
     27  void ReleaseID(NotNull<MsaaAccessible*> aMsaaAcc);
     28 
     29 private:
     30  bool ReleaseID(uint32_t aID);
     31  void ReleasePendingIDs();
     32  static void ReleasePendingIdsCallback(nsITimer* aTimer, void* aClosure);
     33 
     34 private:
     35  static constexpr uint32_t kNumFullIDBits = 31UL;
     36  IDSet mIDSet{kNumFullIDBits};
     37  nsTArray<uint32_t> mIDsToRelease;
     38  nsCOMPtr<nsITimer> mReleaseIDTimer;
     39  // Whether GetID has been called yet this session.
     40  bool mGetIDCalled = false;
     41 };
     42 
     43 }  // namespace a11y
     44 }  // namespace mozilla
     45 
     46 #endif  // mozilla_a11y_MsaaIdGenerator_h