accessible/android/DocAccessibleWrap.h
author Karl Tomlinson <karlt+@karlt.net>
Mon, 07 Jan 2019 08:51:31 +0000
changeset 506591 39fe709c6cf8de41c2a739ad456877eb5fa1e7c3
parent 505383 6f3709b3878117466168c40affa7bca0b60cf75b
child 509549 f0a91d36587266d7454a450c6044d573664fbed5
permissions -rw-r--r--
Bug 1512737 - Assign HRTF to panningModel attribute instead of adding type property. r=padenot, a=test-only Differential Revision: https://phabricator.services.mozilla.com/D14494

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef mozilla_a11y_DocAccessibleWrap_h__
#define mozilla_a11y_DocAccessibleWrap_h__

#include "DocAccessible.h"
#include "nsITimer.h"

namespace mozilla {
namespace a11y {

class DocAccessibleWrap : public DocAccessible {
 public:
  DocAccessibleWrap(nsIDocument* aDocument, nsIPresShell* aPresShell);
  virtual ~DocAccessibleWrap();

  virtual nsresult HandleAccEvent(AccEvent* aEvent) override;

  /**
   * Manage the mapping from id to Accessible.
   */
  void AddID(uint32_t aID, AccessibleWrap* aAcc) {
    mIDToAccessibleMap.Put(aID, aAcc);
  }
  void RemoveID(uint32_t aID) { mIDToAccessibleMap.Remove(aID); }
  AccessibleWrap* GetAccessibleByID(int32_t aID) const;

  DocAccessibleWrap* GetTopLevelContentDoc(AccessibleWrap* aAccessible);

  void CacheFocusPath(AccessibleWrap* aAccessible);

  enum {
    eBatch_Viewport = 0,
    eBatch_FocusPath = 1,
    eBatch_BoundsUpdate = 2,
  };

 protected:
  /*
   * This provides a mapping from 32 bit id to accessible objects.
   */
  nsDataHashtable<nsUint32HashKey, AccessibleWrap*> mIDToAccessibleMap;

  virtual void DoInitialUpdate() override;

 private:
  void CacheViewport();

  void UpdateFocusPathBounds();

  static void CacheViewportCallback(nsITimer* aTimer, void* aDocAccParam);

  nsCOMPtr<nsITimer> mCacheRefreshTimer;

  AccessibleHashtable mFocusPath;
};

}  // namespace a11y
}  // namespace mozilla

#endif