TextLeafAccessible.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "TextLeafAccessible.h"
  6. #include "nsAccUtils.h"
  7. #include "DocAccessible.h"
  8. #include "Role.h"
  9. using namespace mozilla::a11y;
  10. ////////////////////////////////////////////////////////////////////////////////
  11. // TextLeafAccessible
  12. ////////////////////////////////////////////////////////////////////////////////
  13. TextLeafAccessible::
  14. TextLeafAccessible(nsIContent* aContent, DocAccessible* aDoc) :
  15. LinkableAccessible(aContent, aDoc)
  16. {
  17. mType = eTextLeafType;
  18. mGenericTypes |= eText;
  19. mStateFlags |= eNoKidsFromDOM;
  20. }
  21. TextLeafAccessible::~TextLeafAccessible()
  22. {
  23. }
  24. role
  25. TextLeafAccessible::NativeRole()
  26. {
  27. nsIFrame* frame = GetFrame();
  28. if (frame && frame->IsGeneratedContentFrame())
  29. return roles::STATICTEXT;
  30. return roles::TEXT_LEAF;
  31. }
  32. void
  33. TextLeafAccessible::AppendTextTo(nsAString& aText, uint32_t aStartOffset,
  34. uint32_t aLength)
  35. {
  36. aText.Append(Substring(mText, aStartOffset, aLength));
  37. }
  38. ENameValueFlag
  39. TextLeafAccessible::Name(nsString& aName)
  40. {
  41. // Text node, ARIA can't be used.
  42. aName = mText;
  43. return eNameOK;
  44. }