LCOV - code coverage report
Current view: top level - accessible/ipc - ProxyAccessibleBase.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 54 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 23 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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_ProxyAccessibleBase_h
       8             : #define mozilla_a11y_ProxyAccessibleBase_h
       9             : 
      10             : #include "mozilla/a11y/Role.h"
      11             : #include "nsIAccessibleText.h"
      12             : #include "nsIAccessibleTypes.h"
      13             : #include "Accessible.h"
      14             : #include "nsString.h"
      15             : #include "nsTArray.h"
      16             : #include "nsRect.h"
      17             : #include "Accessible.h"
      18             : 
      19             : namespace mozilla {
      20             : namespace a11y {
      21             : 
      22             : class Accessible;
      23             : class Attribute;
      24             : class DocAccessibleParent;
      25             : class ProxyAccessible;
      26             : enum class RelationType;
      27             : 
      28             : enum Interfaces
      29             : {
      30             :   HYPERTEXT = 1,
      31             :   HYPERLINK = 1 << 1,
      32             :   IMAGE = 1 << 2,
      33             :   VALUE = 1 << 3,
      34             :   TABLE = 1 << 4,
      35             :   TABLECELL = 1 << 5,
      36             :   DOCUMENT = 1 << 6,
      37             :   SELECTION = 1 << 7,
      38             :   ACTION = 1 << 8,
      39             : };
      40             : 
      41             : template <class Derived>
      42             : class ProxyAccessibleBase
      43             : {
      44             : public:
      45           0 :   ~ProxyAccessibleBase()
      46             :   {
      47           0 :     MOZ_ASSERT(!mWrapper);
      48           0 :   }
      49             : 
      50           0 :   void AddChildAt(uint32_t aIdx, Derived* aChild)
      51           0 :   { mChildren.InsertElementAt(aIdx, aChild); }
      52             : 
      53           0 :   uint32_t ChildrenCount() const { return mChildren.Length(); }
      54           0 :   Derived* ChildAt(uint32_t aIdx) const { return mChildren[aIdx]; }
      55           0 :   Derived* FirstChild() const
      56           0 :     { return mChildren.Length() ? mChildren[0] : nullptr; }
      57           0 :   Derived* LastChild() const
      58           0 :     { return mChildren.Length() ? mChildren[mChildren.Length() - 1] : nullptr; }
      59           0 :   Derived* PrevSibling() const
      60             :   {
      61           0 :     size_t idx = IndexInParent();
      62           0 :     return idx > 0 ? Parent()->mChildren[idx - 1] : nullptr;
      63             :   }
      64           0 :   Derived* NextSibling() const
      65             :   {
      66           0 :     size_t idx = IndexInParent();
      67           0 :     return idx + 1 < Parent()->mChildren.Length() ? Parent()->mChildren[idx + 1]
      68           0 :     : nullptr;
      69             :   }
      70             : 
      71             :   // XXX evaluate if this is fast enough.
      72           0 :   size_t IndexInParent() const { return
      73           0 :     Parent()->mChildren.IndexOf(static_cast<const Derived*>(this)); }
      74             :   uint32_t EmbeddedChildCount() const;
      75             :   int32_t IndexOfEmbeddedChild(const Derived* aChild);
      76             :   Derived* EmbeddedChildAt(size_t aChildIdx);
      77             :   bool MustPruneChildren() const;
      78             : 
      79             :   void Shutdown();
      80             : 
      81             :   void SetChildDoc(DocAccessibleParent* aChildDoc);
      82             :   void ClearChildDoc(DocAccessibleParent* aChildDoc);
      83             : 
      84             :   /**
      85             :    * Remove The given child.
      86             :    */
      87           0 :   void RemoveChild(Derived* aChild)
      88           0 :     { mChildren.RemoveElement(aChild); }
      89             : 
      90             :   /**
      91             :    * Return the proxy for the parent of the wrapped accessible.
      92             :    */
      93             :   Derived* Parent() const;
      94             : 
      95             :   Accessible* OuterDocOfRemoteBrowser() const;
      96             : 
      97             :   /**
      98             :    * Get the role of the accessible we're proxying.
      99             :    */
     100           0 :   role Role() const { return mRole; }
     101             : 
     102             :   /**
     103             :    * Return true if this is an embedded object.
     104             :    */
     105           0 :   bool IsEmbeddedObject() const
     106             :   {
     107           0 :     role role = Role();
     108           0 :     return role != roles::TEXT_LEAF &&
     109           0 :            role != roles::WHITESPACE &&
     110           0 :            role != roles::STATICTEXT;
     111             :   }
     112             : 
     113             :   /**
     114             :    * Allow the platform to store a pointers worth of data on us.
     115             :    */
     116           0 :   uintptr_t GetWrapper() const { return mWrapper; }
     117           0 :   void SetWrapper(uintptr_t aWrapper) { mWrapper = aWrapper; }
     118             : 
     119             :   /*
     120             :    * Return the ID of the accessible being proxied.
     121             :    */
     122           0 :   uint64_t ID() const { return mID; }
     123             : 
     124             :   /**
     125             :    * Return the document containing this proxy, or the proxy itself if it is a
     126             :    * document.
     127             :    */
     128           0 :   DocAccessibleParent* Document() const { return mDoc; }
     129             : 
     130             :   /**
     131             :    * Return true if this proxy is a DocAccessibleParent.
     132             :    */
     133           0 :   bool IsDoc() const { return mIsDoc; }
     134           0 :   DocAccessibleParent* AsDoc() const { return IsDoc() ? mDoc : nullptr; }
     135             : 
     136             :   // XXX checking mRole alone may not result in same behavior as Accessibles
     137             :   // due to ARIA roles. See bug 1210477.
     138           0 :   inline bool IsTable() const
     139             :   {
     140           0 :     return mRole == roles::TABLE || mRole == roles::MATHML_TABLE;
     141             :   }
     142           0 :   inline bool IsTableRow() const
     143             :   {
     144           0 :     return (mRole == roles::ROW ||
     145           0 :         mRole == roles::MATHML_TABLE_ROW ||
     146           0 :         mRole == roles::MATHML_LABELED_ROW);
     147             :   }
     148           0 :   inline bool IsTableCell() const
     149             :   {
     150           0 :     return (mRole == roles::CELL ||
     151           0 :         mRole == roles::COLUMNHEADER ||
     152           0 :         mRole == roles::ROWHEADER ||
     153           0 :         mRole == roles::GRID_CELL ||
     154           0 :         mRole == roles::MATHML_CELL);
     155             :   }
     156             : 
     157             : protected:
     158           0 :   ProxyAccessibleBase(uint64_t aID, Derived* aParent,
     159             :                       DocAccessibleParent* aDoc, role aRole,
     160             :                       uint32_t aInterfaces)
     161             :     : mParent(aParent->ID())
     162             :     , mDoc(aDoc)
     163             :     , mWrapper(0)
     164             :     , mID(aID)
     165             :     , mRole(aRole)
     166             :     , mOuterDoc(false)
     167             :     , mIsDoc(false)
     168           0 :     , mHasValue(aInterfaces & Interfaces::VALUE)
     169           0 :     , mIsHyperLink(aInterfaces & Interfaces::HYPERLINK)
     170           0 :     , mIsHyperText(aInterfaces & Interfaces::HYPERTEXT)
     171             :   {
     172           0 :   }
     173             : 
     174           0 :   explicit ProxyAccessibleBase(DocAccessibleParent* aThisAsDoc) :
     175             :     mParent(kNoParent), mDoc(aThisAsDoc), mWrapper(0), mID(0),
     176             :     mRole(roles::DOCUMENT), mOuterDoc(false), mIsDoc(true), mHasValue(false),
     177           0 :     mIsHyperLink(false), mIsHyperText(false)
     178           0 :   {}
     179             : 
     180             : protected:
     181             :   void SetParent(Derived* aParent);
     182             : 
     183             : private:
     184             :   uintptr_t mParent;
     185             :   static const uintptr_t kNoParent = UINTPTR_MAX;
     186             : 
     187             :   friend Derived;
     188             : 
     189             :   nsTArray<Derived*> mChildren;
     190             :   DocAccessibleParent* mDoc;
     191             :   uintptr_t mWrapper;
     192             :   uint64_t mID;
     193             : 
     194             : protected:
     195             :   // XXX DocAccessibleParent gets to change this to change the role of
     196             :   // documents.
     197             :   role mRole : 27;
     198             : 
     199             : private:
     200             :   bool mOuterDoc : 1;
     201             : 
     202             : public:
     203             :   const bool mIsDoc: 1;
     204             :   const bool mHasValue: 1;
     205             :   const bool mIsHyperLink: 1;
     206             :   const bool mIsHyperText: 1;
     207             : };
     208             : 
     209             : extern template class ProxyAccessibleBase<ProxyAccessible>;
     210             : 
     211             : }
     212             : }
     213             : 
     214             : #endif

Generated by: LCOV version 1.13