accessible/generic/TextLeafAccessible.cpp
author Jason Orendorff <jorendorff@mozilla.com>
Tue, 04 Aug 2015 18:16:08 -0500
changeset 281923 d60f375bf2eb1b7ec519174df45ec56bf725a56f
parent 228859 627909e0506ea91a66b8fe9ced863db7083878d7
child 328988 8af4e6b9642767e130a8e30ce15d84d93b8eacaf
permissions -rw-r--r--
Bug 1189744 - Fix crash after GetOwnPropertyDescriptor failed to populate all fields of desc. r=jandem, a=rkothari.

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "TextLeafAccessible.h"

#include "nsAccUtils.h"
#include "DocAccessible.h"
#include "Role.h"

using namespace mozilla::a11y;

////////////////////////////////////////////////////////////////////////////////
// TextLeafAccessible
////////////////////////////////////////////////////////////////////////////////

TextLeafAccessible::
  TextLeafAccessible(nsIContent* aContent, DocAccessible* aDoc) :
  LinkableAccessible(aContent, aDoc)
{
  mType = eTextLeafType;
}

TextLeafAccessible::~TextLeafAccessible()
{
}

role
TextLeafAccessible::NativeRole()
{
  nsIFrame* frame = GetFrame();
  if (frame && frame->IsGeneratedContentFrame())
    return roles::STATICTEXT;

  return roles::TEXT_LEAF;
}

void
TextLeafAccessible::AppendTextTo(nsAString& aText, uint32_t aStartOffset,
                                 uint32_t aLength)
{
  aText.Append(Substring(mText, aStartOffset, aLength));
}

ENameValueFlag
TextLeafAccessible::Name(nsString& aName)
{
  // Text node, ARIA can't be used.
  aName = mText;
  return eNameOK;
}

void
TextLeafAccessible::CacheChildren()
{
  // No children for text accessible.
}