accessible/src/generic/TextLeafAccessible.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/accessible/src/generic/TextLeafAccessible.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,55 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef mozilla_a11y_TextLeafAccessible_h__
    1.10 +#define mozilla_a11y_TextLeafAccessible_h__
    1.11 +
    1.12 +#include "BaseAccessibles.h"
    1.13 +
    1.14 +namespace mozilla {
    1.15 +namespace a11y {
    1.16 + 
    1.17 +/**
    1.18 + * Generic class used for text nodes.
    1.19 + */
    1.20 +class TextLeafAccessible : public LinkableAccessible
    1.21 +{
    1.22 +public:
    1.23 +  TextLeafAccessible(nsIContent* aContent, DocAccessible* aDoc);
    1.24 +  virtual ~TextLeafAccessible();
    1.25 +
    1.26 +  // Accessible
    1.27 +  virtual mozilla::a11y::role NativeRole();
    1.28 +  virtual void AppendTextTo(nsAString& aText, uint32_t aStartOffset = 0,
    1.29 +                            uint32_t aLength = UINT32_MAX);
    1.30 +  virtual ENameValueFlag Name(nsString& aName);
    1.31 +
    1.32 +  // TextLeafAccessible
    1.33 +  void SetText(const nsAString& aText) { mText = aText; }
    1.34 +  const nsString& Text() const { return mText; }
    1.35 +
    1.36 +protected:
    1.37 +  // Accessible
    1.38 +  virtual void CacheChildren();
    1.39 +
    1.40 +protected:
    1.41 +  nsString mText;
    1.42 +};
    1.43 +
    1.44 +
    1.45 +////////////////////////////////////////////////////////////////////////////////
    1.46 +// Accessible downcast method
    1.47 +
    1.48 +inline TextLeafAccessible*
    1.49 +Accessible::AsTextLeaf()
    1.50 +{
    1.51 +  return IsTextLeaf() ? static_cast<TextLeafAccessible*>(this) : nullptr;
    1.52 +}
    1.53 +
    1.54 +} // namespace a11y
    1.55 +} // namespace mozilla
    1.56 +
    1.57 +#endif
    1.58 +

mercurial