2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* 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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-04-12 04:11:40 -07:00
|
|
|
#include "HTMLFormControlAccessible.h"
|
2010-04-26 23:52:03 -07:00
|
|
|
|
2012-04-13 07:17:03 -07:00
|
|
|
#include "Accessible-inl.h"
|
2010-04-26 23:52:03 -07:00
|
|
|
#include "nsAccUtils.h"
|
2012-07-27 21:21:40 -07:00
|
|
|
#include "nsEventShell.h"
|
2010-04-26 23:52:03 -07:00
|
|
|
#include "nsTextEquivUtils.h"
|
2012-01-11 19:07:35 -08:00
|
|
|
#include "Relation.h"
|
|
|
|
#include "Role.h"
|
|
|
|
#include "States.h"
|
2010-04-26 23:52:03 -07:00
|
|
|
|
2012-05-30 06:34:33 -07:00
|
|
|
#include "nsContentList.h"
|
2013-03-28 12:41:32 -07:00
|
|
|
#include "mozilla/dom/HTMLInputElement.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIDOMNSEditableElement.h"
|
|
|
|
#include "nsIDOMHTMLTextAreaElement.h"
|
2007-08-14 09:25:24 -07:00
|
|
|
#include "nsIEditor.h"
|
2012-05-30 06:34:33 -07:00
|
|
|
#include "nsIFormControl.h"
|
2013-09-10 15:18:59 -07:00
|
|
|
#include "nsIPersistentProperties2.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsISelectionController.h"
|
2007-07-24 23:24:00 -07:00
|
|
|
#include "nsIServiceManager.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsITextControlFrame.h"
|
2014-02-27 15:04:46 -08:00
|
|
|
#include "nsNameSpaceManager.h"
|
2013-12-11 17:51:58 -08:00
|
|
|
#include "mozilla/dom/ScriptSettings.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-04-02 21:18:36 -07:00
|
|
|
#include "mozilla/EventStates.h"
|
2013-11-19 13:01:15 -08:00
|
|
|
#include "mozilla/FloatingPoint.h"
|
2012-05-07 22:10:31 -07:00
|
|
|
#include "mozilla/Preferences.h"
|
|
|
|
|
|
|
|
using namespace mozilla;
|
2013-03-28 12:41:32 -07:00
|
|
|
using namespace mozilla::dom;
|
2011-07-27 05:43:01 -07:00
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 04:11:40 -07:00
|
|
|
// HTMLCheckboxAccessible
|
2010-06-11 01:23:18 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
role
|
2012-04-12 04:11:40 -07:00
|
|
|
HTMLCheckboxAccessible::NativeRole()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::CHECKBUTTON;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t
|
2012-04-12 04:11:40 -07:00
|
|
|
HTMLCheckboxAccessible::ActionCount()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-06-05 12:35:43 -07:00
|
|
|
return 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2014-09-16 10:30:23 -07:00
|
|
|
void
|
|
|
|
HTMLCheckboxAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (aIndex == eAction_Click) { // 0 is the magic value for default action
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t state = NativeState();
|
2011-04-09 16:38:06 -07:00
|
|
|
if (state & states::CHECKED)
|
2014-09-16 10:30:23 -07:00
|
|
|
aName.AssignLiteral("uncheck");
|
2011-04-09 16:38:06 -07:00
|
|
|
else if (state & states::MIXED)
|
2014-09-16 10:30:23 -07:00
|
|
|
aName.AssignLiteral("cycle");
|
2007-03-22 10:30:00 -07:00
|
|
|
else
|
2014-09-16 10:30:23 -07:00
|
|
|
aName.AssignLiteral("check");
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-16 10:30:23 -07:00
|
|
|
bool
|
2012-08-22 08:56:38 -07:00
|
|
|
HTMLCheckboxAccessible::DoAction(uint8_t aIndex)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-01-25 07:09:25 -08:00
|
|
|
if (aIndex != 0)
|
2014-09-16 10:30:23 -07:00
|
|
|
return false;
|
2010-01-25 07:09:25 -08:00
|
|
|
|
|
|
|
DoCommand();
|
2014-09-16 10:30:23 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t
|
2012-04-12 04:11:40 -07:00
|
|
|
HTMLCheckboxAccessible::NativeState()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t state = LeafAccessible::NativeState();
|
2007-05-06 07:50:03 -07:00
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
state |= states::CHECKABLE;
|
2013-03-28 12:41:32 -07:00
|
|
|
HTMLInputElement* input = HTMLInputElement::FromContent(mContent);
|
2012-06-03 04:36:51 -07:00
|
|
|
if (!input)
|
|
|
|
return state;
|
|
|
|
|
|
|
|
if (input->Indeterminate())
|
|
|
|
return state | states::MIXED;
|
2009-02-11 00:40:27 -08:00
|
|
|
|
2012-06-03 04:36:51 -07:00
|
|
|
if (input->Checked())
|
|
|
|
return state | states::CHECKED;
|
2009-02-11 00:40:27 -08:00
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
return state;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 20:13:08 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 04:11:40 -07:00
|
|
|
// HTMLCheckboxAccessible: Widgets
|
2011-09-28 20:13:08 -07:00
|
|
|
|
|
|
|
bool
|
2012-04-12 04:11:40 -07:00
|
|
|
HTMLCheckboxAccessible::IsWidget() const
|
2011-09-28 20:13:08 -07:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-06 02:36:50 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 04:11:40 -07:00
|
|
|
// HTMLRadioButtonAccessible
|
2010-01-06 02:36:50 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t
|
2012-04-12 04:11:40 -07:00
|
|
|
HTMLRadioButtonAccessible::NativeState()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t state = AccessibleWrap::NativeState();
|
2007-04-02 08:56:24 -07:00
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
state |= states::CHECKABLE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-03-28 12:41:32 -07:00
|
|
|
HTMLInputElement* input = HTMLInputElement::FromContent(mContent);
|
2012-06-03 04:36:51 -07:00
|
|
|
if (input && input->Checked())
|
2011-04-09 16:38:06 -07:00
|
|
|
state |= states::CHECKED;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
return state;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-01-06 02:36:50 -08:00
|
|
|
void
|
2012-08-22 08:56:38 -07:00
|
|
|
HTMLRadioButtonAccessible::GetPositionAndSizeInternal(int32_t* aPosInSet,
|
|
|
|
int32_t* aSetSize)
|
2007-03-27 05:17:11 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t namespaceId = mContent->NodeInfo()->NamespaceID();
|
2007-03-27 05:17:11 -07:00
|
|
|
nsAutoString tagName;
|
2010-06-11 01:23:18 -07:00
|
|
|
mContent->NodeInfo()->GetName(tagName);
|
2007-04-03 01:27:43 -07:00
|
|
|
|
|
|
|
nsAutoString type;
|
2011-06-03 14:35:17 -07:00
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::type, type);
|
2007-04-03 01:27:43 -07:00
|
|
|
nsAutoString name;
|
2011-06-03 14:35:17 -07:00
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::name, name);
|
2007-04-03 01:27:43 -07:00
|
|
|
|
2012-05-30 06:34:33 -07:00
|
|
|
nsRefPtr<nsContentList> inputElms;
|
2007-03-27 05:17:11 -07:00
|
|
|
|
2012-05-30 06:34:33 -07:00
|
|
|
nsCOMPtr<nsIFormControl> formControlNode(do_QueryInterface(mContent));
|
|
|
|
dom::Element* formElm = formControlNode->GetFormElement();
|
|
|
|
if (formElm)
|
|
|
|
inputElms = NS_GetContentList(formElm, namespaceId, tagName);
|
|
|
|
else
|
|
|
|
inputElms = NS_GetContentList(mContent->OwnerDoc(), namespaceId, tagName);
|
2012-09-14 03:00:31 -07:00
|
|
|
NS_ENSURE_TRUE_VOID(inputElms);
|
2007-03-27 05:17:11 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t inputCount = inputElms->Length(false);
|
2007-03-27 05:17:11 -07:00
|
|
|
|
2010-01-06 02:36:50 -08:00
|
|
|
// Compute posinset and setsize.
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t indexOf = 0;
|
|
|
|
int32_t count = 0;
|
2007-04-03 01:27:43 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
for (uint32_t index = 0; index < inputCount; index++) {
|
2012-05-30 06:34:33 -07:00
|
|
|
nsIContent* inputElm = inputElms->Item(index, false);
|
|
|
|
if (inputElm->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
|
|
|
type, eCaseMatters) &&
|
|
|
|
inputElm->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name,
|
2013-02-21 08:31:40 -08:00
|
|
|
name, eCaseMatters) && mDoc->HasAccessible(inputElm)) {
|
|
|
|
count++;
|
2012-05-30 06:34:33 -07:00
|
|
|
if (inputElm == mContent)
|
2007-04-03 01:27:43 -07:00
|
|
|
indexOf = count;
|
2007-03-27 05:17:11 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-06 02:36:50 -08:00
|
|
|
*aPosInSet = indexOf;
|
|
|
|
*aSetSize = count;
|
2007-03-27 05:17:11 -07:00
|
|
|
}
|
|
|
|
|
2010-01-06 02:36:50 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 04:11:40 -07:00
|
|
|
// HTMLButtonAccessible
|
2010-01-06 02:36:50 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-04-12 04:11:40 -07:00
|
|
|
HTMLButtonAccessible::
|
2012-05-27 02:01:40 -07:00
|
|
|
HTMLButtonAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessibleWrap(aContent, aDoc)
|
2010-06-11 01:23:18 -07:00
|
|
|
{
|
2014-04-04 01:01:19 -07:00
|
|
|
mGenericTypes |= eButton;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t
|
2012-04-12 04:11:40 -07:00
|
|
|
HTMLButtonAccessible::ActionCount()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-06-05 12:35:43 -07:00
|
|
|
return 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2014-09-16 10:30:23 -07:00
|
|
|
void
|
|
|
|
HTMLButtonAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2014-09-16 10:30:23 -07:00
|
|
|
if (aIndex == eAction_Click)
|
|
|
|
aName.AssignLiteral("press");
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2014-09-16 10:30:23 -07:00
|
|
|
bool
|
2012-08-22 08:56:38 -07:00
|
|
|
HTMLButtonAccessible::DoAction(uint8_t aIndex)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-01-25 07:09:25 -08:00
|
|
|
if (aIndex != eAction_Click)
|
2014-09-16 10:30:23 -07:00
|
|
|
return false;
|
2010-01-25 07:09:25 -08:00
|
|
|
|
|
|
|
DoCommand();
|
2014-09-16 10:30:23 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t
|
2012-04-12 04:11:40 -07:00
|
|
|
HTMLButtonAccessible::State()
|
2011-11-30 04:36:20 -08:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t state = HyperTextAccessibleWrap::State();
|
2011-11-30 04:36:20 -08:00
|
|
|
if (state == states::DEFUNCT)
|
|
|
|
return state;
|
|
|
|
|
|
|
|
// Inherit states from input@type="file" suitable for the button. Note,
|
|
|
|
// no special processing for unavailable state since inheritance is supplied
|
|
|
|
// other code paths.
|
|
|
|
if (mParent && mParent->IsHTMLFileInput()) {
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t parentState = mParent->State();
|
2011-11-30 04:36:20 -08:00
|
|
|
state |= parentState & (states::BUSY | states::REQUIRED |
|
|
|
|
states::HASPOPUP | states::INVALID);
|
|
|
|
}
|
|
|
|
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t
|
2012-04-12 04:11:40 -07:00
|
|
|
HTMLButtonAccessible::NativeState()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t state = HyperTextAccessibleWrap::NativeState();
|
2008-02-11 04:12:17 -08:00
|
|
|
|
2014-04-02 21:18:36 -07:00
|
|
|
EventStates elmState = mContent->AsElement()->State();
|
2011-10-03 07:26:18 -07:00
|
|
|
if (elmState.HasState(NS_EVENT_STATE_DEFAULT))
|
2011-04-09 16:38:06 -07:00
|
|
|
state |= states::DEFAULT;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
return state;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
role
|
2012-04-12 04:11:40 -07:00
|
|
|
HTMLButtonAccessible::NativeRole()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::PUSHBUTTON;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-10-13 21:18:39 -07:00
|
|
|
ENameValueFlag
|
|
|
|
HTMLButtonAccessible::NativeName(nsString& aName)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-02-02 20:49:18 -08:00
|
|
|
// No need to check @value attribute for buttons since this attribute results
|
|
|
|
// in native anonymous text node and the name is calculated from subtree.
|
|
|
|
// The same magic works for @alt and @value attributes in case of type="image"
|
|
|
|
// element that has no valid @src (note if input@type="image" has an image
|
|
|
|
// then neither @alt nor @value attributes are used to generate a visual label
|
|
|
|
// and thus we need to obtain the accessible name directly from attribute
|
|
|
|
// value). Also the same algorithm works in case of default labels for
|
|
|
|
// type="submit"/"reset"/"image" elements.
|
|
|
|
|
2012-10-16 23:38:16 -07:00
|
|
|
ENameValueFlag nameFlag = Accessible::NativeName(aName);
|
2013-02-02 20:49:18 -08:00
|
|
|
if (!aName.IsEmpty() || mContent->Tag() != nsGkAtoms::input ||
|
|
|
|
!mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
|
|
|
nsGkAtoms::image, eCaseMatters))
|
2012-10-16 23:38:16 -07:00
|
|
|
return nameFlag;
|
2008-10-14 01:27:02 -07:00
|
|
|
|
2013-02-02 20:49:18 -08:00
|
|
|
if (!mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::alt, aName))
|
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::value, aName);
|
2008-10-14 01:27:02 -07:00
|
|
|
|
2012-10-13 21:18:39 -07:00
|
|
|
aName.CompressWhitespace();
|
|
|
|
return eNameOK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 20:13:08 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 04:11:40 -07:00
|
|
|
// HTMLButtonAccessible: Widgets
|
2011-09-28 20:13:08 -07:00
|
|
|
|
|
|
|
bool
|
2012-04-12 04:11:40 -07:00
|
|
|
HTMLButtonAccessible::IsWidget() const
|
2011-09-28 20:13:08 -07:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 04:11:40 -07:00
|
|
|
// HTMLTextFieldAccessible
|
2010-06-11 01:23:18 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-04-12 04:11:40 -07:00
|
|
|
HTMLTextFieldAccessible::
|
2012-05-27 02:01:40 -07:00
|
|
|
HTMLTextFieldAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessibleWrap(aContent, aDoc)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-04-05 01:15:26 -07:00
|
|
|
mType = eHTMLTextFieldType;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2014-10-21 17:49:28 -07:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED0(HTMLTextFieldAccessible,
|
|
|
|
HyperTextAccessible)
|
2007-11-09 11:27:07 -08:00
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
role
|
2012-04-12 04:11:40 -07:00
|
|
|
HTMLTextFieldAccessible::NativeRole()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-06-03 14:35:17 -07:00
|
|
|
if (mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
|
|
|
nsGkAtoms::password, eIgnoreCase)) {
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::PASSWORD_TEXT;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2013-12-10 19:19:26 -08:00
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::ENTRY;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-10-24 20:21:24 -07:00
|
|
|
already_AddRefed<nsIPersistentProperties>
|
|
|
|
HTMLTextFieldAccessible::NativeAttributes()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIPersistentProperties> attributes =
|
|
|
|
HyperTextAccessibleWrap::NativeAttributes();
|
|
|
|
|
|
|
|
// Expose type for text input elements as it gives some useful context,
|
|
|
|
// especially for mobile.
|
|
|
|
nsAutoString type;
|
|
|
|
if (mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::type, type))
|
|
|
|
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::textInputType, type);
|
|
|
|
|
|
|
|
return attributes.forget();
|
|
|
|
}
|
|
|
|
|
2012-10-13 21:18:39 -07:00
|
|
|
ENameValueFlag
|
|
|
|
HTMLTextFieldAccessible::NativeName(nsString& aName)
|
2007-06-14 18:50:37 -07:00
|
|
|
{
|
2012-10-16 23:38:16 -07:00
|
|
|
ENameValueFlag nameFlag = Accessible::NativeName(aName);
|
2008-10-10 05:26:55 -07:00
|
|
|
if (!aName.IsEmpty())
|
2012-10-16 23:38:16 -07:00
|
|
|
return nameFlag;
|
2008-10-10 05:26:55 -07:00
|
|
|
|
2013-12-07 13:37:04 -08:00
|
|
|
// If part of compound of XUL widget then grab a name from XUL widget element.
|
|
|
|
nsIContent* widgetElm = XULWidgetElm();
|
|
|
|
if (widgetElm)
|
|
|
|
XULElmName(mDoc, widgetElm, aName);
|
2010-11-08 05:33:25 -08:00
|
|
|
|
|
|
|
if (!aName.IsEmpty())
|
2012-10-13 21:18:39 -07:00
|
|
|
return eNameOK;
|
2007-06-14 18:50:37 -07:00
|
|
|
|
2010-11-08 05:33:25 -08:00
|
|
|
// text inputs and textareas might have useful placeholder text
|
2011-06-03 14:35:17 -07:00
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::placeholder, aName);
|
2012-10-13 21:18:39 -07:00
|
|
|
return eNameOK;
|
2007-06-14 18:50:37 -07:00
|
|
|
}
|
|
|
|
|
2012-04-09 02:48:41 -07:00
|
|
|
void
|
2012-04-12 04:11:40 -07:00
|
|
|
HTMLTextFieldAccessible::Value(nsString& aValue)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-04-09 02:48:41 -07:00
|
|
|
aValue.Truncate();
|
2011-04-09 16:38:06 -07:00
|
|
|
if (NativeState() & states::PROTECTED) // Don't return password text!
|
2012-04-09 02:48:41 -07:00
|
|
|
return;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea(do_QueryInterface(mContent));
|
2007-03-22 10:30:00 -07:00
|
|
|
if (textArea) {
|
2012-04-09 02:48:41 -07:00
|
|
|
textArea->GetValue(aValue);
|
|
|
|
return;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-12-22 16:54:13 -08:00
|
|
|
|
2013-03-28 12:41:32 -07:00
|
|
|
HTMLInputElement* input = HTMLInputElement::FromContent(mContent);
|
2012-06-03 04:36:51 -07:00
|
|
|
if (input)
|
|
|
|
input->GetValue(aValue);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-01 08:37:24 -07:00
|
|
|
void
|
2012-08-22 08:56:38 -07:00
|
|
|
HTMLTextFieldAccessible::ApplyARIAState(uint64_t* aState) const
|
2011-09-01 08:37:24 -07:00
|
|
|
{
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessibleWrap::ApplyARIAState(aState);
|
2012-04-05 09:23:30 -07:00
|
|
|
aria::MapToState(aria::eARIAAutoComplete, mContent->AsElement(), aState);
|
2013-12-07 13:37:04 -08:00
|
|
|
|
|
|
|
// If part of compound of XUL widget then pick up ARIA stuff from XUL widget
|
|
|
|
// element.
|
|
|
|
nsIContent* widgetElm = XULWidgetElm();
|
|
|
|
if (widgetElm)
|
|
|
|
aria::MapToState(aria::eARIAAutoComplete, widgetElm->AsElement(), aState);
|
2011-11-30 04:36:20 -08:00
|
|
|
}
|
2011-09-01 08:37:24 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t
|
2012-04-12 04:11:40 -07:00
|
|
|
HTMLTextFieldAccessible::NativeState()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t state = HyperTextAccessibleWrap::NativeState();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-01-21 08:24:23 -08:00
|
|
|
// Text fields are always editable, even if they are also read only or
|
|
|
|
// disabled.
|
|
|
|
state |= states::EDITABLE;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// can be focusable, focused, protected. readonly, unavailable, selected
|
2011-06-03 14:35:17 -07:00
|
|
|
if (mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
|
|
|
nsGkAtoms::password, eIgnoreCase)) {
|
2011-04-09 16:38:06 -07:00
|
|
|
state |= states::PROTECTED;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-06-03 14:35:17 -07:00
|
|
|
if (mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::readonly)) {
|
2011-04-09 16:38:06 -07:00
|
|
|
state |= states::READONLY;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Is it an <input> or a <textarea> ?
|
2013-03-28 12:41:32 -07:00
|
|
|
HTMLInputElement* input = HTMLInputElement::FromContent(mContent);
|
2012-06-03 04:36:51 -07:00
|
|
|
state |= input && input->IsSingleLineTextControl() ?
|
|
|
|
states::SINGLE_LINE : states::MULTI_LINE;
|
2011-09-27 18:46:11 -07:00
|
|
|
|
2014-01-21 08:24:23 -08:00
|
|
|
if (state & (states::PROTECTED | states::MULTI_LINE | states::READONLY |
|
|
|
|
states::UNAVAILABLE))
|
2011-09-27 18:46:11 -07:00
|
|
|
return state;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
// Expose autocomplete states if this input is part of autocomplete widget.
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* widget = ContainerWidget();
|
2011-09-27 18:46:11 -07:00
|
|
|
if (widget && widget-IsAutoComplete()) {
|
|
|
|
state |= states::HASPOPUP | states::SUPPORTS_AUTOCOMPLETION;
|
2011-04-09 16:38:06 -07:00
|
|
|
return state;
|
2011-09-27 18:46:11 -07:00
|
|
|
}
|
2008-07-02 01:42:58 -07:00
|
|
|
|
2011-10-06 23:02:18 -07:00
|
|
|
// Expose autocomplete state if it has associated autocomplete list.
|
|
|
|
if (mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::list))
|
2013-06-03 23:52:39 -07:00
|
|
|
return state | states::SUPPORTS_AUTOCOMPLETION | states::HASPOPUP;
|
2011-10-06 23:02:18 -07:00
|
|
|
|
2013-12-07 13:37:04 -08:00
|
|
|
// Ordinal XUL textboxes don't support autocomplete.
|
|
|
|
if (!XULWidgetElm() && Preferences::GetBool("browser.formfill.enable")) {
|
2007-04-05 15:14:08 -07:00
|
|
|
// Check to see if autocompletion is allowed on this input. We don't expose
|
|
|
|
// it for password fields even though the entire password can be remembered
|
|
|
|
// for a page if the user asks it to be. However, the kind of autocomplete
|
|
|
|
// we're talking here is based on what the user types, where a popup of
|
|
|
|
// possible choices comes up.
|
|
|
|
nsAutoString autocomplete;
|
2011-06-03 14:35:17 -07:00
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::autocomplete,
|
2010-06-11 01:23:18 -07:00
|
|
|
autocomplete);
|
2007-04-05 15:14:08 -07:00
|
|
|
|
|
|
|
if (!autocomplete.LowerCaseEqualsLiteral("off")) {
|
2012-06-03 04:36:51 -07:00
|
|
|
nsIContent* formContent = input->GetFormElement();
|
2007-04-05 15:14:08 -07:00
|
|
|
if (formContent) {
|
|
|
|
formContent->GetAttr(kNameSpaceID_None,
|
2011-06-03 14:35:17 -07:00
|
|
|
nsGkAtoms::autocomplete, autocomplete);
|
2007-04-05 14:52:03 -07:00
|
|
|
}
|
2007-04-05 15:14:08 -07:00
|
|
|
|
|
|
|
if (!formContent || !autocomplete.LowerCaseEqualsLiteral("off"))
|
2011-04-09 16:38:06 -07:00
|
|
|
state |= states::SUPPORTS_AUTOCOMPLETION;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
return state;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t
|
2012-04-12 04:11:40 -07:00
|
|
|
HTMLTextFieldAccessible::ActionCount()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-06-05 12:35:43 -07:00
|
|
|
return 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2014-09-16 10:30:23 -07:00
|
|
|
void
|
|
|
|
HTMLTextFieldAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2014-09-16 10:30:23 -07:00
|
|
|
if (aIndex == eAction_Click)
|
2007-03-22 10:30:00 -07:00
|
|
|
aName.AssignLiteral("activate");
|
|
|
|
}
|
|
|
|
|
2014-09-16 10:30:23 -07:00
|
|
|
bool
|
2012-08-22 08:56:38 -07:00
|
|
|
HTMLTextFieldAccessible::DoAction(uint8_t aIndex)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2014-09-16 10:30:23 -07:00
|
|
|
if (aIndex != 0)
|
|
|
|
return false;
|
2012-04-12 04:11:40 -07:00
|
|
|
|
2014-09-16 10:30:23 -07:00
|
|
|
TakeFocus();
|
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-03-07 19:28:38 -08:00
|
|
|
already_AddRefed<nsIEditor>
|
2012-04-12 04:11:40 -07:00
|
|
|
HTMLTextFieldAccessible::GetEditor() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-06-11 01:23:18 -07:00
|
|
|
nsCOMPtr<nsIDOMNSEditableElement> editableElt(do_QueryInterface(mContent));
|
2012-03-07 19:28:38 -08:00
|
|
|
if (!editableElt)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-07-24 23:24:00 -07:00
|
|
|
// nsGenericHTMLElement::GetEditor has a security check.
|
|
|
|
// Make sure we're not restricted by the permissions of
|
|
|
|
// whatever script is currently running.
|
2014-04-14 20:27:00 -07:00
|
|
|
mozilla::dom::AutoNoJSAPI nojsapi;
|
2007-07-24 23:24:00 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIEditor> editor;
|
2012-03-07 19:28:38 -08:00
|
|
|
editableElt->GetEditor(getter_AddRefs(editor));
|
2007-07-24 23:24:00 -07:00
|
|
|
|
2012-03-07 19:28:38 -08:00
|
|
|
return editor.forget();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 04:11:40 -07:00
|
|
|
// HTMLTextFieldAccessible: Widgets
|
2011-09-27 18:46:11 -07:00
|
|
|
|
|
|
|
bool
|
2012-04-12 04:11:40 -07:00
|
|
|
HTMLTextFieldAccessible::IsWidget() const
|
2011-09-27 18:46:11 -07:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible*
|
2012-04-12 04:11:40 -07:00
|
|
|
HTMLTextFieldAccessible::ContainerWidget() const
|
2011-09-27 18:46:11 -07:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
return mParent && mParent->Role() == roles::AUTOCOMPLETE ? mParent : nullptr;
|
2011-09-27 18:46:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-30 04:36:20 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 04:11:40 -07:00
|
|
|
// HTMLFileInputAccessible
|
2011-11-30 04:36:20 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-04-12 04:11:40 -07:00
|
|
|
HTMLFileInputAccessible::
|
2012-05-27 02:01:40 -07:00
|
|
|
HTMLFileInputAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessibleWrap(aContent, aDoc)
|
2011-11-30 04:36:20 -08:00
|
|
|
{
|
2012-12-17 21:22:26 -08:00
|
|
|
mType = eHTMLFileInputType;
|
2011-11-30 04:36:20 -08:00
|
|
|
}
|
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
role
|
2012-04-12 04:11:40 -07:00
|
|
|
HTMLFileInputAccessible::NativeRole()
|
2011-11-30 04:36:20 -08:00
|
|
|
{
|
|
|
|
// JAWS wants a text container, others don't mind. No specific role in
|
|
|
|
// AT APIs.
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::TEXT_CONTAINER;
|
2011-11-30 04:36:20 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2012-04-12 04:11:40 -07:00
|
|
|
HTMLFileInputAccessible::HandleAccEvent(AccEvent* aEvent)
|
2011-11-30 04:36:20 -08:00
|
|
|
{
|
2012-05-31 01:04:41 -07:00
|
|
|
nsresult rv = HyperTextAccessibleWrap::HandleAccEvent(aEvent);
|
2011-11-30 04:36:20 -08:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
// Redirect state change events for inherited states to child controls. Note,
|
|
|
|
// unavailable state is not redirected. That's a standard for unavailable
|
|
|
|
// state handling.
|
|
|
|
AccStateChangeEvent* event = downcast_accEvent(aEvent);
|
|
|
|
if (event &&
|
|
|
|
(event->GetState() == states::BUSY ||
|
|
|
|
event->GetState() == states::REQUIRED ||
|
|
|
|
event->GetState() == states::HASPOPUP ||
|
|
|
|
event->GetState() == states::INVALID)) {
|
2013-03-27 04:35:22 -07:00
|
|
|
Accessible* button = GetChildAt(0);
|
2012-01-11 19:07:35 -08:00
|
|
|
if (button && button->Role() == roles::PUSHBUTTON) {
|
2011-11-30 04:36:20 -08:00
|
|
|
nsRefPtr<AccStateChangeEvent> childEvent =
|
|
|
|
new AccStateChangeEvent(button, event->GetState(),
|
2013-10-26 07:58:53 -07:00
|
|
|
event->IsStateEnabled(), event->FromUserInput());
|
2011-11-30 04:36:20 -08:00
|
|
|
nsEventShell::FireEvent(childEvent);
|
|
|
|
}
|
|
|
|
}
|
2013-03-27 04:35:22 -07:00
|
|
|
|
2011-11-30 04:36:20 -08:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-04-27 17:54:54 -07:00
|
|
|
|
2013-12-10 19:19:26 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// HTMLSpinnerAccessible
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
role
|
|
|
|
HTMLSpinnerAccessible::NativeRole()
|
|
|
|
{
|
|
|
|
return roles::SPINBUTTON;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
HTMLSpinnerAccessible::Value(nsString& aValue)
|
|
|
|
{
|
|
|
|
AccessibleWrap::Value(aValue);
|
|
|
|
if (!aValue.IsEmpty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
HTMLInputElement::FromContent(mContent)->GetValue(aValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
double
|
|
|
|
HTMLSpinnerAccessible::MaxValue() const
|
|
|
|
{
|
|
|
|
double value = AccessibleWrap::MaxValue();
|
|
|
|
if (!IsNaN(value))
|
|
|
|
return value;
|
|
|
|
|
|
|
|
return HTMLInputElement::FromContent(mContent)->GetMaximum().toDouble();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
double
|
|
|
|
HTMLSpinnerAccessible::MinValue() const
|
|
|
|
{
|
|
|
|
double value = AccessibleWrap::MinValue();
|
|
|
|
if (!IsNaN(value))
|
|
|
|
return value;
|
|
|
|
|
|
|
|
return HTMLInputElement::FromContent(mContent)->GetMinimum().toDouble();
|
|
|
|
}
|
|
|
|
|
|
|
|
double
|
|
|
|
HTMLSpinnerAccessible::Step() const
|
|
|
|
{
|
|
|
|
double value = AccessibleWrap::Step();
|
|
|
|
if (!IsNaN(value))
|
|
|
|
return value;
|
|
|
|
|
|
|
|
return HTMLInputElement::FromContent(mContent)->GetStep().toDouble();
|
|
|
|
}
|
|
|
|
|
|
|
|
double
|
|
|
|
HTMLSpinnerAccessible::CurValue() const
|
|
|
|
{
|
|
|
|
double value = AccessibleWrap::CurValue();
|
|
|
|
if (!IsNaN(value))
|
|
|
|
return value;
|
|
|
|
|
|
|
|
return HTMLInputElement::FromContent(mContent)->GetValueAsDecimal().toDouble();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
HTMLSpinnerAccessible::SetCurValue(double aValue)
|
|
|
|
{
|
|
|
|
ErrorResult er;
|
|
|
|
HTMLInputElement::FromContent(mContent)->SetValueAsNumber(aValue, er);
|
|
|
|
return !er.Failed();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-27 17:54:54 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// HTMLRangeAccessible
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
role
|
|
|
|
HTMLRangeAccessible::NativeRole()
|
|
|
|
{
|
|
|
|
return roles::SLIDER;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
HTMLRangeAccessible::IsWidget() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
HTMLRangeAccessible::Value(nsString& aValue)
|
|
|
|
{
|
|
|
|
LeafAccessible::Value(aValue);
|
|
|
|
if (!aValue.IsEmpty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
HTMLInputElement::FromContent(mContent)->GetValue(aValue);
|
|
|
|
}
|
|
|
|
|
2013-11-19 13:01:15 -08:00
|
|
|
double
|
|
|
|
HTMLRangeAccessible::MaxValue() const
|
2013-04-27 17:54:54 -07:00
|
|
|
{
|
2013-11-19 13:01:15 -08:00
|
|
|
double value = LeafAccessible::MaxValue();
|
|
|
|
if (!IsNaN(value))
|
|
|
|
return value;
|
2013-04-27 17:54:54 -07:00
|
|
|
|
2013-11-19 13:01:15 -08:00
|
|
|
return HTMLInputElement::FromContent(mContent)->GetMaximum().toDouble();
|
2013-04-27 17:54:54 -07:00
|
|
|
}
|
|
|
|
|
2013-11-19 13:01:15 -08:00
|
|
|
double
|
|
|
|
HTMLRangeAccessible::MinValue() const
|
2013-04-27 17:54:54 -07:00
|
|
|
{
|
2013-11-19 13:01:15 -08:00
|
|
|
double value = LeafAccessible::MinValue();
|
|
|
|
if (!IsNaN(value))
|
|
|
|
return value;
|
2013-04-27 17:54:54 -07:00
|
|
|
|
2013-11-19 13:01:15 -08:00
|
|
|
return HTMLInputElement::FromContent(mContent)->GetMinimum().toDouble();
|
2013-04-27 17:54:54 -07:00
|
|
|
}
|
|
|
|
|
2013-11-19 13:01:15 -08:00
|
|
|
double
|
|
|
|
HTMLRangeAccessible::Step() const
|
2013-04-27 17:54:54 -07:00
|
|
|
{
|
2013-11-19 13:01:15 -08:00
|
|
|
double value = LeafAccessible::Step();
|
|
|
|
if (!IsNaN(value))
|
|
|
|
return value;
|
2013-04-27 17:54:54 -07:00
|
|
|
|
2013-11-19 13:01:15 -08:00
|
|
|
return HTMLInputElement::FromContent(mContent)->GetStep().toDouble();
|
2013-04-27 17:54:54 -07:00
|
|
|
}
|
|
|
|
|
2013-11-19 13:01:15 -08:00
|
|
|
double
|
|
|
|
HTMLRangeAccessible::CurValue() const
|
2013-04-27 17:54:54 -07:00
|
|
|
{
|
2013-11-19 13:01:15 -08:00
|
|
|
double value = LeafAccessible::CurValue();
|
|
|
|
if (!IsNaN(value))
|
|
|
|
return value;
|
2013-04-27 17:54:54 -07:00
|
|
|
|
2013-11-19 13:01:15 -08:00
|
|
|
return HTMLInputElement::FromContent(mContent)->GetValueAsDecimal().toDouble();
|
2013-04-27 17:54:54 -07:00
|
|
|
}
|
|
|
|
|
2013-11-19 13:01:15 -08:00
|
|
|
bool
|
|
|
|
HTMLRangeAccessible::SetCurValue(double aValue)
|
2013-04-27 17:54:54 -07:00
|
|
|
{
|
|
|
|
ErrorResult er;
|
|
|
|
HTMLInputElement::FromContent(mContent)->SetValueAsNumber(aValue, er);
|
2013-11-19 13:01:15 -08:00
|
|
|
return !er.Failed();
|
2013-04-27 17:54:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 04:11:40 -07:00
|
|
|
// HTMLGroupboxAccessible
|
2010-06-11 01:23:18 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-04-12 04:11:40 -07:00
|
|
|
HTMLGroupboxAccessible::
|
2012-05-27 02:01:40 -07:00
|
|
|
HTMLGroupboxAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessibleWrap(aContent, aDoc)
|
2010-06-11 01:23:18 -07:00
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
role
|
2012-04-12 04:11:40 -07:00
|
|
|
HTMLGroupboxAccessible::NativeRole()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::GROUPING;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-12-06 23:20:17 -08:00
|
|
|
nsIContent*
|
2014-09-16 10:30:23 -07:00
|
|
|
HTMLGroupboxAccessible::GetLegend() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-12-06 23:20:17 -08:00
|
|
|
for (nsIContent* legendContent = mContent->GetFirstChild(); legendContent;
|
|
|
|
legendContent = legendContent->GetNextSibling()) {
|
2011-06-03 14:35:17 -07:00
|
|
|
if (legendContent->NodeInfo()->Equals(nsGkAtoms::legend,
|
2010-06-11 01:23:18 -07:00
|
|
|
mContent->GetNameSpaceID())) {
|
2007-06-30 13:06:13 -07:00
|
|
|
// Either XHTML namespace or no namespace
|
2010-06-11 01:23:18 -07:00
|
|
|
return legendContent;
|
2007-06-30 13:06:13 -07:00
|
|
|
}
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-10-13 21:18:39 -07:00
|
|
|
ENameValueFlag
|
|
|
|
HTMLGroupboxAccessible::NativeName(nsString& aName)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-10-16 23:38:16 -07:00
|
|
|
ENameValueFlag nameFlag = Accessible::NativeName(aName);
|
2008-10-10 05:26:55 -07:00
|
|
|
if (!aName.IsEmpty())
|
2012-10-16 23:38:16 -07:00
|
|
|
return nameFlag;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-10-13 21:18:39 -07:00
|
|
|
nsIContent* legendContent = GetLegend();
|
|
|
|
if (legendContent)
|
|
|
|
nsTextEquivUtils::AppendTextEquivFromContent(this, legendContent, &aName);
|
2007-06-30 13:06:13 -07:00
|
|
|
|
2012-10-13 21:18:39 -07:00
|
|
|
return eNameOK;
|
2007-06-30 13:06:13 -07:00
|
|
|
}
|
|
|
|
|
2011-08-09 18:44:00 -07:00
|
|
|
Relation
|
2013-10-19 11:19:50 -07:00
|
|
|
HTMLGroupboxAccessible::RelationByType(RelationType aType)
|
2007-06-30 13:06:13 -07:00
|
|
|
{
|
2012-05-31 01:04:41 -07:00
|
|
|
Relation rel = HyperTextAccessibleWrap::RelationByType(aType);
|
2007-06-30 13:06:13 -07:00
|
|
|
// No override for label, so use <legend> for this <fieldset>
|
2013-10-19 11:19:50 -07:00
|
|
|
if (aType == RelationType::LABELLED_BY)
|
2012-05-07 17:00:29 -07:00
|
|
|
rel.AppendTarget(mDoc, GetLegend());
|
2007-06-30 13:06:13 -07:00
|
|
|
|
2011-08-09 18:44:00 -07:00
|
|
|
return rel;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-03-07 07:38:58 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 04:11:40 -07:00
|
|
|
// HTMLLegendAccessible
|
2010-06-11 01:23:18 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2009-03-07 07:38:58 -08:00
|
|
|
|
2012-04-12 04:11:40 -07:00
|
|
|
HTMLLegendAccessible::
|
2012-05-27 02:01:40 -07:00
|
|
|
HTMLLegendAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessibleWrap(aContent, aDoc)
|
2010-06-11 01:23:18 -07:00
|
|
|
{
|
2007-06-30 13:06:13 -07:00
|
|
|
}
|
|
|
|
|
2011-08-09 18:44:00 -07:00
|
|
|
Relation
|
2013-10-19 11:19:50 -07:00
|
|
|
HTMLLegendAccessible::RelationByType(RelationType aType)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-05-31 01:04:41 -07:00
|
|
|
Relation rel = HyperTextAccessibleWrap::RelationByType(aType);
|
2013-10-19 11:19:50 -07:00
|
|
|
if (aType != RelationType::LABEL_FOR)
|
2011-08-09 18:44:00 -07:00
|
|
|
return rel;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* groupbox = Parent();
|
2012-01-11 19:07:35 -08:00
|
|
|
if (groupbox && groupbox->Role() == roles::GROUPING)
|
2011-08-09 18:44:00 -07:00
|
|
|
rel.AppendTarget(groupbox);
|
2007-06-30 13:06:13 -07:00
|
|
|
|
2011-08-09 18:44:00 -07:00
|
|
|
return rel;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2009-03-07 07:38:58 -08:00
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
role
|
2012-04-12 04:11:40 -07:00
|
|
|
HTMLLegendAccessible::NativeRole()
|
2009-03-07 07:38:58 -08:00
|
|
|
{
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::LABEL;
|
2009-03-07 07:38:58 -08:00
|
|
|
}
|
2011-12-04 22:04:06 -08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 04:11:40 -07:00
|
|
|
// HTMLFigureAccessible
|
2011-12-04 22:04:06 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-04-12 04:11:40 -07:00
|
|
|
HTMLFigureAccessible::
|
2012-05-27 02:01:40 -07:00
|
|
|
HTMLFigureAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessibleWrap(aContent, aDoc)
|
2011-12-04 22:04:06 -08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-10-19 00:15:23 -07:00
|
|
|
already_AddRefed<nsIPersistentProperties>
|
|
|
|
HTMLFigureAccessible::NativeAttributes()
|
2011-12-04 22:04:06 -08:00
|
|
|
{
|
2012-10-19 00:15:23 -07:00
|
|
|
nsCOMPtr<nsIPersistentProperties> attributes =
|
|
|
|
HyperTextAccessibleWrap::NativeAttributes();
|
2011-12-04 22:04:06 -08:00
|
|
|
|
|
|
|
// Expose figure xml-role.
|
2012-10-19 00:15:23 -07:00
|
|
|
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::xmlroles,
|
2011-12-04 22:04:06 -08:00
|
|
|
NS_LITERAL_STRING("figure"));
|
2012-10-19 00:15:23 -07:00
|
|
|
return attributes.forget();
|
2011-12-04 22:04:06 -08:00
|
|
|
}
|
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
role
|
2012-04-12 04:11:40 -07:00
|
|
|
HTMLFigureAccessible::NativeRole()
|
2011-12-04 22:04:06 -08:00
|
|
|
{
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::FIGURE;
|
2011-12-04 22:04:06 -08:00
|
|
|
}
|
|
|
|
|
2012-10-13 21:18:39 -07:00
|
|
|
ENameValueFlag
|
|
|
|
HTMLFigureAccessible::NativeName(nsString& aName)
|
2011-12-04 22:04:06 -08:00
|
|
|
{
|
2012-10-16 23:38:16 -07:00
|
|
|
ENameValueFlag nameFlag = HyperTextAccessibleWrap::NativeName(aName);
|
2011-12-04 22:04:06 -08:00
|
|
|
if (!aName.IsEmpty())
|
2012-10-16 23:38:16 -07:00
|
|
|
return nameFlag;
|
2011-12-04 22:04:06 -08:00
|
|
|
|
|
|
|
nsIContent* captionContent = Caption();
|
2012-10-13 21:18:39 -07:00
|
|
|
if (captionContent)
|
|
|
|
nsTextEquivUtils::AppendTextEquivFromContent(this, captionContent, &aName);
|
2011-12-04 22:04:06 -08:00
|
|
|
|
2012-10-13 21:18:39 -07:00
|
|
|
return eNameOK;
|
2011-12-04 22:04:06 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
Relation
|
2013-10-19 11:19:50 -07:00
|
|
|
HTMLFigureAccessible::RelationByType(RelationType aType)
|
2011-12-04 22:04:06 -08:00
|
|
|
{
|
2012-05-31 01:04:41 -07:00
|
|
|
Relation rel = HyperTextAccessibleWrap::RelationByType(aType);
|
2013-10-19 11:19:50 -07:00
|
|
|
if (aType == RelationType::LABELLED_BY)
|
2012-05-07 17:00:29 -07:00
|
|
|
rel.AppendTarget(mDoc, Caption());
|
2011-12-04 22:04:06 -08:00
|
|
|
|
|
|
|
return rel;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIContent*
|
2012-04-12 04:11:40 -07:00
|
|
|
HTMLFigureAccessible::Caption() const
|
2011-12-04 22:04:06 -08:00
|
|
|
{
|
|
|
|
for (nsIContent* childContent = mContent->GetFirstChild(); childContent;
|
|
|
|
childContent = childContent->GetNextSibling()) {
|
|
|
|
if (childContent->NodeInfo()->Equals(nsGkAtoms::figcaption,
|
|
|
|
mContent->GetNameSpaceID())) {
|
|
|
|
return childContent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2011-12-04 22:04:06 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 04:11:40 -07:00
|
|
|
// HTMLFigcaptionAccessible
|
2011-12-04 22:04:06 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-04-12 04:11:40 -07:00
|
|
|
HTMLFigcaptionAccessible::
|
2012-05-27 02:01:40 -07:00
|
|
|
HTMLFigcaptionAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessibleWrap(aContent, aDoc)
|
2011-12-04 22:04:06 -08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
role
|
2012-04-12 04:11:40 -07:00
|
|
|
HTMLFigcaptionAccessible::NativeRole()
|
2011-12-04 22:04:06 -08:00
|
|
|
{
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::CAPTION;
|
2011-12-04 22:04:06 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
Relation
|
2013-10-19 11:19:50 -07:00
|
|
|
HTMLFigcaptionAccessible::RelationByType(RelationType aType)
|
2011-12-04 22:04:06 -08:00
|
|
|
{
|
2012-05-31 01:04:41 -07:00
|
|
|
Relation rel = HyperTextAccessibleWrap::RelationByType(aType);
|
2013-10-19 11:19:50 -07:00
|
|
|
if (aType != RelationType::LABEL_FOR)
|
2011-12-04 22:04:06 -08:00
|
|
|
return rel;
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* figure = Parent();
|
2011-12-04 22:04:06 -08:00
|
|
|
if (figure &&
|
|
|
|
figure->GetContent()->NodeInfo()->Equals(nsGkAtoms::figure,
|
|
|
|
mContent->GetNameSpaceID())) {
|
|
|
|
rel.AppendTarget(figure);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rel;
|
|
|
|
}
|