Accessibility/NewArchitecture

From MozillaWiki
Jump to: navigation, search

Summary

The page describes proposed Gecko a11y architectural changes.

Folders

  1. build - accessibility service factory
  2. idl
    1. ia2 - IAccessible2 interfaces
    2. msaa - ISimpleDOM interfaces
    3. xpcom - XPCOM interfaces
  3. public - exported a11y headers
  4. src
    1. base - common files
    2. generic - generic accessible classes
    3. html - HTML accessible classes
    4. xul - XUL accessible classes
    5. xforms - XForms accessible classes
    6. atk - ATK implementation (Linux)
    7. windows - MSAA/IAccessible2/SimpleDOM interfaces implementation (Windows)
    8. mac - NSAccessibility protocol implementation (OS X)
    9. others - other platforms
    10. xpcom - XPCOM interfaces implementation
  5. tests
    1. crashtests
    2. mochitest

'public' folder

  1. No excess dependences. All inline methods that requires extra includes are prototyped here and defined in implementation classes.
  2. Defined inside mozilla::a11y namespace

accessible objects

/**
 * The existing base/nsAccessNode.
 */
class DOMNodeAccessible;
/**
 * The existing base/nsAccessible.
 */
class Accessible : public DOMNodeAccessible {};
/**
 * Existing html/nsHyperTextAccessible.
 */
class HyperTextAccessible : public Accessible {};
/**
 * Existing base/nsDocAccessible.
 */
class DocAccessible : public HyperTextAccessible {};
/**
 * Existing base/nsRootAccessible.
 */
class RootAccessible : public DocAccessible {};
/**
 * Existing base/nsApplicationAccessible.
 */
class AppAccessible : public Accessible {};
/**
 * New interface classes based on nsIAccessibleTable and nsIAccessibleTableCell.
 */
class TableAccessible : public Accessible {
 int32 GetIndx(row, col);
 void GetPositionFromIndex(index, row, col);
 tableCellAccessible* GetTableCellAt(row, col);
 void GetExtents(row, col, rowExtent, colExtent);
 int getRows()
  int getCols()
Accessible* Caption()
//  these might be faster if on table cell not the table not sure though
  Accessible* array getRowHeadercells(int row)
  Accessible* array getColHeadercells(int col )
  string Summary()
  bool forLayout()
// who uses these?
  selectRow(int row)
selectCol(int col)
  unselectRow(int row)
  unselectCol(int col)
// seems somewhat reduntant with geting header cells, but maybe we need it
  string  rowDescription(int row)
  string colDescription(int col)
// are these useful?
 bool isRowSelected(row)
 bool isColSelected(col);
 GetSelectedCells(array<accessible>& cells);
 void GetSelectedRows(array<int>& rows);
 void GetSelectedCols(array<int32>& cols);
};
class TableCellAccessible : public HyperTextAccessible {
 int GetIndex();
 void Getposition(row, col);
 void GetExtents(rowExtent, colExtent);
 bool isSelected();
TableAccessible* getTable()
};

accessibility service

/**
 * Existing nsDocAccManager and nsAccessibilityService
 */
class DocAccessibleMgr {};
class AccService : public DocAccessibleMgr {};

src/generic folder

[approach shouldn't work because of multiple inheritance from non abstract classes]

is this supposed to be where the implementation of accessible objects goes?

class GenericAccessible : public Accessible; (nsAccessible)

class ApplicationAccessible : public Accessible; (nsApplicationAccessible)

class ARIAGridAccessible (nsARIAGridAccessible)

class DocAccessible : public GenericAccessible, DocAccessible; (nsDocAccessible)

class HyperTextAccessible

src platforms folders

Every platform defines AccServiceWrap used for initialization (currently done by nsAccessNodeWrap classes).

class AccServiceWrap : public AccService {};

atk

windows

A generic class that used as a bridge to gecko accessible.

class NativeObject
{
public:
  NativeObject(DOMNodeAccessible* aGeckoAcc) : mGeckoAcc(aGeckoAcc) { }

protected:
  DOMNodeAccessible* mGeckoAcc;
};

Classes that implement IAccessible2 interfaces.

class ia2Accessible : virtual public NativeObject,
                      public IAccessible
{
public:
  // IAccessible
};

hresult
ia2Accessible::IAccessible2Method()
{
  Accessible* geckoAcc = mGeckoAcc->AsAccessible();
  geckoAcc->AccessibleMethod();
  return S_OK;
}

class ia2TableAccessible : virtual public NativeObject,
                           public IAccessibleTable
{
public:
  // IAccessibleTable
  // IAccessibleTable2
};

hresult
ia2TableAccessible::IATableMethod()
{
  TableAccessible* geckoAcc = mGeckoObj->AsTable();
  geckoAcc->TableMethod();
  return S_OK;
}

Final classes that implements native interfaces for specific Gecko accessible classes.

class NativeDOMNodeAccessible : virtual public NativeObject,
                                public ISimpleDOMNode
                                public IServiceProvider
{
public:
  // IUknown
  // IServiceProvider
  // ISimpleDOMNode
};

class NativeAccessible : public NativeDOMNodeAccessible,
                         public IAccessible,
                         public IEnumVARIANT,
                         public ia2Accessible
{
  // IDispatch
  // IAccessible
  // IEnumVariant
};

class NativeTableAccessible : public NativeAccessible,
                              public ia2TableAccessible
{
};

class NativeDocAccessible : public NativeAccessible,
                            public ISimpleDOMDocument
{
  // ISimpleDOMDocument
};

Wrappers for Gecko classes that are used to create proper native class.

class AccessibleWrap: public Accessible
{
public:
  inline NativeObject* AsNativeObject()
  {
    if (!mNativeObj || !IsDefunct())
      mNativeObj = CreateNativeAccessible();
    return mNativeObj;
  }

protected:
  virtual NativeObject* CreateNativeAccessible()
  {
    return new NativeAccessible(this);
  }
};

class HTMLTableAccessibleWrap : public HTMLTableAccessible
{
public:
  virtual NativeObject* CreateNativeAccessible()
  {
    return new NativeTableAccessible(this);
  }
};

class DocAccessibleWrap : public DocAccessible
{
public:
  virtual NativeObject* CreateNativeAccessible()
  {
    return new NativeDocAccessible(this);
  }
};

mac

NSAccessibility protocol implementation.

'xpcom' folder

Classes are prefixed by 'xp'. Each xp class holds weak pointer to internal accessible object. All xp objects are contained in hash, when xp object is requested for internal object then hash is checked and new one is created if it doesn't have existing object. The xp objects creation is based on checking the supported interface (see Accessible downcasting methods).

accessible objects

template<class T>
class xpTAccessible : public nsIAccessible,
                      public nsIHyperLinkAccessible,
                      public nsISelectableAccessible
{
private:
  T* mInternalObj;
};

typedef xpTAccessible<Accessible> xpAccessible;
template<class T>
class xpTHyperTextAccessible : public xpTAccessible<T>,
                               public nsIAccessibleText,
                               public nsIAccessibleEdtiableText,
                               public nsIAccessibleHypertext
{};

typedef xpTHyperTextAccessible<HyperTextAccessible> xpHyperTextAccessible;
class xpImageAccessible : public xpTAccessible<ImageAccessible>,
                          public nsIAccessibleImage
class xpTableAccessible : public xpTAccessible<TableAccessible>,
                          public nsIAccessibleTable
{};
class xpTableCellAccessible : public xpTHyperTextAccessible<TableCellAccessible>,
                              public nsIAccessibleTableCell
{};
class xpDocumentAccessible : public xpTHyperTextAccessible<DocAccessible>,
                             public nsIAccessibleDocument
{};
class xpApplicationAccessible : public xpTAccessible<AppAccessible>,
                                public nsIApplicationAccessible
{};

accessible relations

class xpRelation : public nsIAccessibleRelation
{};

accessibility service

class xpAccService : public AccServiceWrap,
                     public nsIAccessibleProvider
{};