AccessibleNode.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 "AccessibleNode.h"
  6. #include "mozilla/dom/AccessibleNodeBinding.h"
  7. #include "mozilla/dom/BindingDeclarations.h"
  8. #include "Accessible-inl.h"
  9. #include "nsAccessibilityService.h"
  10. #include "DocAccessible.h"
  11. using namespace mozilla;
  12. using namespace mozilla::a11y;
  13. using namespace mozilla::dom;
  14. NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(AccessibleNode)
  15. NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(AccessibleNode)
  16. NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
  17. NS_INTERFACE_MAP_ENTRY(nsISupports)
  18. NS_INTERFACE_MAP_END
  19. NS_IMPL_CYCLE_COLLECTING_ADDREF(AccessibleNode)
  20. NS_IMPL_CYCLE_COLLECTING_RELEASE(AccessibleNode)
  21. AccessibleNode::AccessibleNode(nsINode* aNode) : mDOMNode(aNode)
  22. {
  23. DocAccessible* doc =
  24. GetOrCreateAccService()->GetDocAccessible(mDOMNode->OwnerDoc());
  25. if (doc) {
  26. mIntl = doc->GetAccessible(mDOMNode);
  27. }
  28. }
  29. AccessibleNode::~AccessibleNode()
  30. {
  31. }
  32. /* virtual */ JSObject*
  33. AccessibleNode::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
  34. {
  35. return AccessibleNodeBinding::Wrap(aCx, this, aGivenProto);
  36. }
  37. /* virtual */ ParentObject
  38. AccessibleNode::GetParentObject() const
  39. {
  40. return mDOMNode->GetParentObject();
  41. }
  42. void
  43. AccessibleNode::GetRole(nsAString& aRole)
  44. {
  45. if (mIntl) {
  46. GetOrCreateAccService()->GetStringRole(mIntl->Role(), aRole);
  47. return;
  48. }
  49. aRole.AssignLiteral("unknown");
  50. }
  51. nsINode*
  52. AccessibleNode::GetDOMNode()
  53. {
  54. return mDOMNode;
  55. }