accessible/src/xul/nsXULAlertAccessible.cpp
author David Anderson <danderson@mozilla.com>
Mon, 21 May 2012 14:40:04 -0700
changeset 106274 80e4ab0d24bc64ceaa7693ab5def36faffde7a40
parent 106193 c660397f6ab25e596d6fd1a2ce3eb2ca1b52626f
parent 94484 f4157e8c410708d76703f19e4dfb61859bfe32d8
child 106311 474d3f16960fb6bc790f0f46b77d0248424b84ef
permissions -rw-r--r--
Merge from mozilla-central.

/* -*- 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 "nsXULAlertAccessible.h"

#include "Role.h"
#include "States.h"

using namespace mozilla::a11y;

////////////////////////////////////////////////////////////////////////////////
// nsXULAlertAccessible
////////////////////////////////////////////////////////////////////////////////

nsXULAlertAccessible::
  nsXULAlertAccessible(nsIContent* aContent, nsDocAccessible* aDoc) :
  nsAccessibleWrap(aContent, aDoc)
{
}

NS_IMPL_ISUPPORTS_INHERITED0(nsXULAlertAccessible, nsAccessible)

role
nsXULAlertAccessible::NativeRole()
{
  return roles::ALERT;
}

PRUint64
nsXULAlertAccessible::NativeState()
{
  return nsAccessible::NativeState() | states::ALERT;
}

ENameValueFlag
nsXULAlertAccessible::Name(nsString& aName)
{
  // Screen readers need to read contents of alert, not the accessible name.
  // If we have both some screen readers will read the alert twice.
  aName.Truncate();
  return eNameOK;
}

////////////////////////////////////////////////////////////////////////////////
// Widgets

bool
nsXULAlertAccessible::IsWidget() const
{
  return true;
}

nsAccessible*
nsXULAlertAccessible::ContainerWidget() const
{
  // If a part of colorpicker widget.
  if (mParent && mParent->IsMenuButton())
    return mParent;
  return nsnull;
}