2001-09-25 04:48:50 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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/. */
|
2001-04-18 03:06:38 +04:00
|
|
|
|
2012-04-12 15:11:40 +04:00
|
|
|
#include "HTMLFormControlAccessible.h"
|
2010-04-27 10:52:03 +04:00
|
|
|
|
2012-04-13 18:17:03 +04:00
|
|
|
#include "Accessible-inl.h"
|
2010-04-27 10:52:03 +04:00
|
|
|
#include "nsAccUtils.h"
|
2012-07-28 08:21:40 +04:00
|
|
|
#include "nsEventShell.h"
|
2010-04-27 10:52:03 +04:00
|
|
|
#include "nsTextEquivUtils.h"
|
2012-01-12 07:07:35 +04:00
|
|
|
#include "Relation.h"
|
|
|
|
#include "Role.h"
|
|
|
|
#include "States.h"
|
2010-04-27 10:52:03 +04:00
|
|
|
|
2012-05-30 17:34:33 +04:00
|
|
|
#include "nsContentList.h"
|
2013-03-28 23:41:32 +04:00
|
|
|
#include "mozilla/dom/HTMLInputElement.h"
|
2017-10-31 02:14:51 +03:00
|
|
|
#include "mozilla/dom/HTMLTextAreaElement.h"
|
2007-08-14 20:25:24 +04:00
|
|
|
#include "nsIEditor.h"
|
2012-05-30 17:34:33 +04:00
|
|
|
#include "nsIFormControl.h"
|
2013-09-11 02:18:59 +04:00
|
|
|
#include "nsIPersistentProperties2.h"
|
2003-04-15 12:45:55 +04:00
|
|
|
#include "nsISelectionController.h"
|
2007-07-25 10:24:00 +04:00
|
|
|
#include "nsIServiceManager.h"
|
2017-08-07 11:42:50 +03:00
|
|
|
#include "nsITextControlElement.h"
|
2006-07-12 17:14:53 +04:00
|
|
|
#include "nsITextControlFrame.h"
|
2014-02-28 03:04:46 +04:00
|
|
|
#include "nsNameSpaceManager.h"
|
2013-12-12 05:51:58 +04:00
|
|
|
#include "mozilla/dom/ScriptSettings.h"
|
2001-04-18 03:06:38 +04:00
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
#include "mozilla/EventStates.h"
|
2013-11-20 01:01:15 +04:00
|
|
|
#include "mozilla/FloatingPoint.h"
|
2012-05-08 09:10:31 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2017-08-07 11:42:50 +03:00
|
|
|
#include "mozilla/TextEditor.h"
|
2012-05-08 09:10:31 +04:00
|
|
|
|
|
|
|
using namespace mozilla;
|
2013-03-28 23:41:32 +04:00
|
|
|
using namespace mozilla::dom;
|
2011-07-27 16:43:01 +04:00
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2010-06-11 12:23:18 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 15:11:40 +04:00
|
|
|
// HTMLCheckboxAccessible
|
2010-06-11 12:23:18 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2001-04-18 03:06:38 +04:00
|
|
|
|
2012-01-12 07:07:35 +04:00
|
|
|
role
|
2012-04-12 15:11:40 +04:00
|
|
|
HTMLCheckboxAccessible::NativeRole()
|
2001-04-18 03:06:38 +04:00
|
|
|
{
|
2012-01-12 07:07:35 +04:00
|
|
|
return roles::CHECKBUTTON;
|
2001-04-18 03:06:38 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t
|
2012-04-12 15:11:40 +04:00
|
|
|
HTMLCheckboxAccessible::ActionCount()
|
2001-04-18 03:06:38 +04:00
|
|
|
{
|
2011-06-05 23:35:43 +04:00
|
|
|
return 1;
|
2001-05-12 01:11:38 +04:00
|
|
|
}
|
|
|
|
|
2014-09-16 21:30:23 +04:00
|
|
|
void
|
|
|
|
HTMLCheckboxAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
2001-05-12 01:11:38 +04:00
|
|
|
{
|
2007-02-25 06:43:20 +03:00
|
|
|
if (aIndex == eAction_Click) { // 0 is the magic value for default action
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t state = NativeState();
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::CHECKED)
|
2014-09-16 21:30:23 +04:00
|
|
|
aName.AssignLiteral("uncheck");
|
2011-04-10 03:38:06 +04:00
|
|
|
else if (state & states::MIXED)
|
2014-09-16 21:30:23 +04:00
|
|
|
aName.AssignLiteral("cycle");
|
2001-05-12 08:20:34 +04:00
|
|
|
else
|
2014-09-16 21:30:23 +04:00
|
|
|
aName.AssignLiteral("check");
|
2001-05-12 01:11:38 +04:00
|
|
|
}
|
2001-04-18 03:06:38 +04:00
|
|
|
}
|
|
|
|
|
2014-09-16 21:30:23 +04:00
|
|
|
bool
|
2012-08-22 19:56:38 +04:00
|
|
|
HTMLCheckboxAccessible::DoAction(uint8_t aIndex)
|
2001-04-18 03:06:38 +04:00
|
|
|
{
|
2010-01-25 18:09:25 +03:00
|
|
|
if (aIndex != 0)
|
2014-09-16 21:30:23 +04:00
|
|
|
return false;
|
2010-01-25 18:09:25 +03:00
|
|
|
|
|
|
|
DoCommand();
|
2014-09-16 21:30:23 +04:00
|
|
|
return true;
|
2001-04-18 03:06:38 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t
|
2012-04-12 15:11:40 +04:00
|
|
|
HTMLCheckboxAccessible::NativeState()
|
2001-09-18 07:09:01 +04:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t state = LeafAccessible::NativeState();
|
2007-05-06 18:50:03 +04:00
|
|
|
|
2011-04-10 03:38:06 +04:00
|
|
|
state |= states::CHECKABLE;
|
2013-03-28 23:41:32 +04:00
|
|
|
HTMLInputElement* input = HTMLInputElement::FromContent(mContent);
|
2012-06-03 15:36:51 +04:00
|
|
|
if (!input)
|
|
|
|
return state;
|
|
|
|
|
|
|
|
if (input->Indeterminate())
|
|
|
|
return state | states::MIXED;
|
2009-02-11 11:40:27 +03:00
|
|
|
|
2012-06-03 15:36:51 +04:00
|
|
|
if (input->Checked())
|
|
|
|
return state | states::CHECKED;
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2011-04-10 03:38:06 +04:00
|
|
|
return state;
|
2001-09-18 07:09:01 +04:00
|
|
|
}
|
2001-04-18 03:06:38 +04:00
|
|
|
|
2011-09-29 07:13:08 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 15:11:40 +04:00
|
|
|
// HTMLCheckboxAccessible: Widgets
|
2011-09-29 07:13:08 +04:00
|
|
|
|
|
|
|
bool
|
2012-04-12 15:11:40 +04:00
|
|
|
HTMLCheckboxAccessible::IsWidget() const
|
2011-09-29 07:13:08 +04:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-06 13:36:50 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 15:11:40 +04:00
|
|
|
// HTMLRadioButtonAccessible
|
2010-01-06 13:36:50 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2001-04-18 03:06:38 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t
|
2012-04-12 15:11:40 +04:00
|
|
|
HTMLRadioButtonAccessible::NativeState()
|
2001-09-18 07:09:01 +04:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t state = AccessibleWrap::NativeState();
|
2007-04-02 19:56:24 +04:00
|
|
|
|
2011-04-10 03:38:06 +04:00
|
|
|
state |= states::CHECKABLE;
|
2001-09-18 07:09:01 +04:00
|
|
|
|
2013-03-28 23:41:32 +04:00
|
|
|
HTMLInputElement* input = HTMLInputElement::FromContent(mContent);
|
2012-06-03 15:36:51 +04:00
|
|
|
if (input && input->Checked())
|
2011-04-10 03:38:06 +04:00
|
|
|
state |= states::CHECKED;
|
2001-09-18 07:09:01 +04:00
|
|
|
|
2011-04-10 03:38:06 +04:00
|
|
|
return state;
|
2001-09-18 07:09:01 +04:00
|
|
|
}
|
|
|
|
|
2010-01-06 13:36:50 +03:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
HTMLRadioButtonAccessible::GetPositionAndSizeInternal(int32_t* aPosInSet,
|
|
|
|
int32_t* aSetSize)
|
2007-03-27 16:17:11 +04:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t namespaceId = mContent->NodeInfo()->NamespaceID();
|
2007-03-27 16:17:11 +04:00
|
|
|
nsAutoString tagName;
|
2010-06-11 12:23:18 +04:00
|
|
|
mContent->NodeInfo()->GetName(tagName);
|
2007-04-03 12:27:43 +04:00
|
|
|
|
|
|
|
nsAutoString type;
|
2017-12-07 21:13:50 +03:00
|
|
|
mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::type, type);
|
2007-04-03 12:27:43 +04:00
|
|
|
nsAutoString name;
|
2017-12-07 21:13:50 +03:00
|
|
|
mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::name, name);
|
2007-04-03 12:27:43 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsContentList> inputElms;
|
2007-03-27 16:17:11 +04:00
|
|
|
|
2012-05-30 17:34:33 +04: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 14:00:31 +04:00
|
|
|
NS_ENSURE_TRUE_VOID(inputElms);
|
2007-03-27 16:17:11 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t inputCount = inputElms->Length(false);
|
2007-03-27 16:17:11 +04:00
|
|
|
|
2010-01-06 13:36:50 +03:00
|
|
|
// Compute posinset and setsize.
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t indexOf = 0;
|
|
|
|
int32_t count = 0;
|
2007-04-03 12:27:43 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t index = 0; index < inputCount; index++) {
|
2012-05-30 17:34:33 +04:00
|
|
|
nsIContent* inputElm = inputElms->Item(index, false);
|
2017-12-07 21:13:50 +03:00
|
|
|
if (inputElm->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
|
|
|
type, eCaseMatters) &&
|
|
|
|
inputElm->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name,
|
|
|
|
name, eCaseMatters) &&
|
|
|
|
mDoc->HasAccessible(inputElm)) {
|
2013-02-21 20:31:40 +04:00
|
|
|
count++;
|
2012-05-30 17:34:33 +04:00
|
|
|
if (inputElm == mContent)
|
2007-04-03 12:27:43 +04:00
|
|
|
indexOf = count;
|
2007-03-27 16:17:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-06 13:36:50 +03:00
|
|
|
*aPosInSet = indexOf;
|
|
|
|
*aSetSize = count;
|
2007-03-27 16:17:11 +04:00
|
|
|
}
|
|
|
|
|
2010-01-06 13:36:50 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 15:11:40 +04:00
|
|
|
// HTMLButtonAccessible
|
2010-01-06 13:36:50 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2001-04-18 03:06:38 +04:00
|
|
|
|
2012-04-12 15:11:40 +04:00
|
|
|
HTMLButtonAccessible::
|
2012-05-27 13:01:40 +04:00
|
|
|
HTMLButtonAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-05-31 12:04:41 +04:00
|
|
|
HyperTextAccessibleWrap(aContent, aDoc)
|
2010-06-11 12:23:18 +04:00
|
|
|
{
|
2014-04-04 12:01:19 +04:00
|
|
|
mGenericTypes |= eButton;
|
2001-04-18 03:06:38 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t
|
2012-04-12 15:11:40 +04:00
|
|
|
HTMLButtonAccessible::ActionCount()
|
2001-04-18 03:06:38 +04:00
|
|
|
{
|
2011-06-05 23:35:43 +04:00
|
|
|
return 1;
|
2001-05-12 01:11:38 +04:00
|
|
|
}
|
|
|
|
|
2014-09-16 21:30:23 +04:00
|
|
|
void
|
|
|
|
HTMLButtonAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
2001-05-12 01:11:38 +04:00
|
|
|
{
|
2014-09-16 21:30:23 +04:00
|
|
|
if (aIndex == eAction_Click)
|
|
|
|
aName.AssignLiteral("press");
|
2001-04-18 03:06:38 +04:00
|
|
|
}
|
|
|
|
|
2014-09-16 21:30:23 +04:00
|
|
|
bool
|
2012-08-22 19:56:38 +04:00
|
|
|
HTMLButtonAccessible::DoAction(uint8_t aIndex)
|
2001-04-18 03:06:38 +04:00
|
|
|
{
|
2010-01-25 18:09:25 +03:00
|
|
|
if (aIndex != eAction_Click)
|
2014-09-16 21:30:23 +04:00
|
|
|
return false;
|
2010-01-25 18:09:25 +03:00
|
|
|
|
|
|
|
DoCommand();
|
2014-09-16 21:30:23 +04:00
|
|
|
return true;
|
2001-05-12 01:11:38 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t
|
2012-04-12 15:11:40 +04:00
|
|
|
HTMLButtonAccessible::State()
|
2011-11-30 16:36:20 +04:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t state = HyperTextAccessibleWrap::State();
|
2011-11-30 16:36:20 +04: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 19:56:38 +04:00
|
|
|
uint64_t parentState = mParent->State();
|
2011-11-30 16:36:20 +04:00
|
|
|
state |= parentState & (states::BUSY | states::REQUIRED |
|
|
|
|
states::HASPOPUP | states::INVALID);
|
|
|
|
}
|
|
|
|
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t
|
2012-04-12 15:11:40 +04:00
|
|
|
HTMLButtonAccessible::NativeState()
|
2002-03-10 08:14:24 +03:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t state = HyperTextAccessibleWrap::NativeState();
|
2008-02-11 15:12:17 +03:00
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates elmState = mContent->AsElement()->State();
|
2011-10-03 18:26:18 +04:00
|
|
|
if (elmState.HasState(NS_EVENT_STATE_DEFAULT))
|
2011-04-10 03:38:06 +04:00
|
|
|
state |= states::DEFAULT;
|
2002-03-10 08:14:24 +03:00
|
|
|
|
2011-04-10 03:38:06 +04:00
|
|
|
return state;
|
2002-03-10 08:14:24 +03:00
|
|
|
}
|
|
|
|
|
2012-01-12 07:07:35 +04:00
|
|
|
role
|
2012-04-12 15:11:40 +04:00
|
|
|
HTMLButtonAccessible::NativeRole()
|
2001-05-12 01:11:38 +04:00
|
|
|
{
|
2012-01-12 07:07:35 +04:00
|
|
|
return roles::PUSHBUTTON;
|
2001-04-18 03:06:38 +04:00
|
|
|
}
|
|
|
|
|
2012-10-14 08:18:39 +04:00
|
|
|
ENameValueFlag
|
|
|
|
HTMLButtonAccessible::NativeName(nsString& aName)
|
2001-04-18 03:06:38 +04:00
|
|
|
{
|
2013-02-03 08:49:18 +04: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-17 10:38:16 +04:00
|
|
|
ENameValueFlag nameFlag = Accessible::NativeName(aName);
|
2015-03-03 14:08:59 +03:00
|
|
|
if (!aName.IsEmpty() || !mContent->IsHTMLElement(nsGkAtoms::input) ||
|
2017-12-07 21:13:50 +03:00
|
|
|
!mContent->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
|
|
|
nsGkAtoms::image, eCaseMatters))
|
2012-10-17 10:38:16 +04:00
|
|
|
return nameFlag;
|
2008-10-14 12:27:02 +04:00
|
|
|
|
2017-12-07 21:13:50 +03:00
|
|
|
if (!mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::alt, aName))
|
|
|
|
mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::value, aName);
|
2008-10-14 12:27:02 +04:00
|
|
|
|
2012-10-14 08:18:39 +04:00
|
|
|
aName.CompressWhitespace();
|
|
|
|
return eNameOK;
|
2001-05-12 01:11:38 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 07:13:08 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 15:11:40 +04:00
|
|
|
// HTMLButtonAccessible: Widgets
|
2011-09-29 07:13:08 +04:00
|
|
|
|
|
|
|
bool
|
2012-04-12 15:11:40 +04:00
|
|
|
HTMLButtonAccessible::IsWidget() const
|
2011-09-29 07:13:08 +04:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2001-05-12 01:11:38 +04:00
|
|
|
|
2010-06-11 12:23:18 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 15:11:40 +04:00
|
|
|
// HTMLTextFieldAccessible
|
2010-06-11 12:23:18 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-04-12 15:11:40 +04:00
|
|
|
HTMLTextFieldAccessible::
|
2012-05-27 13:01:40 +04:00
|
|
|
HTMLTextFieldAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-05-31 12:04:41 +04:00
|
|
|
HyperTextAccessibleWrap(aContent, aDoc)
|
2006-07-12 17:14:53 +04:00
|
|
|
{
|
2013-04-05 12:15:26 +04:00
|
|
|
mType = eHTMLTextFieldType;
|
2001-05-12 01:11:38 +04:00
|
|
|
}
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED0(HTMLTextFieldAccessible,
|
|
|
|
HyperTextAccessible)
|
2007-11-09 22:27:07 +03:00
|
|
|
|
2012-01-12 07:07:35 +04:00
|
|
|
role
|
2012-04-12 15:11:40 +04:00
|
|
|
HTMLTextFieldAccessible::NativeRole()
|
2006-07-12 17:14:53 +04:00
|
|
|
{
|
2017-12-07 21:13:50 +03:00
|
|
|
if (mContent->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
|
|
|
nsGkAtoms::password, eIgnoreCase)) {
|
2012-01-12 07:07:35 +04:00
|
|
|
return roles::PASSWORD_TEXT;
|
2006-06-16 21:13:37 +04:00
|
|
|
}
|
2013-12-11 07:19:26 +04:00
|
|
|
|
2012-01-12 07:07:35 +04:00
|
|
|
return roles::ENTRY;
|
2001-05-12 01:11:38 +04:00
|
|
|
}
|
|
|
|
|
2013-10-25 07:21:24 +04: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;
|
2017-12-07 21:13:50 +03:00
|
|
|
if (mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::type, type)) {
|
2013-10-25 07:21:24 +04:00
|
|
|
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::textInputType, type);
|
2016-07-12 22:34:13 +03:00
|
|
|
if (!ARIARoleMap() && type.EqualsLiteral("search")) {
|
2015-02-27 17:41:57 +03:00
|
|
|
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::xmlroles,
|
|
|
|
NS_LITERAL_STRING("searchbox"));
|
|
|
|
}
|
|
|
|
}
|
2013-10-25 07:21:24 +04:00
|
|
|
|
|
|
|
return attributes.forget();
|
|
|
|
}
|
|
|
|
|
2012-10-14 08:18:39 +04:00
|
|
|
ENameValueFlag
|
|
|
|
HTMLTextFieldAccessible::NativeName(nsString& aName)
|
2007-06-15 05:50:37 +04:00
|
|
|
{
|
2012-10-17 10:38:16 +04:00
|
|
|
ENameValueFlag nameFlag = Accessible::NativeName(aName);
|
2008-10-10 16:26:55 +04:00
|
|
|
if (!aName.IsEmpty())
|
2012-10-17 10:38:16 +04:00
|
|
|
return nameFlag;
|
2008-10-10 16:26:55 +04:00
|
|
|
|
2013-12-08 01:37:04 +04: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 16:33:25 +03:00
|
|
|
|
|
|
|
if (!aName.IsEmpty())
|
2012-10-14 08:18:39 +04:00
|
|
|
return eNameOK;
|
2007-06-15 05:50:37 +04:00
|
|
|
|
2010-11-08 16:33:25 +03:00
|
|
|
// text inputs and textareas might have useful placeholder text
|
2017-12-07 21:13:50 +03:00
|
|
|
mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::placeholder, aName);
|
2012-10-14 08:18:39 +04:00
|
|
|
return eNameOK;
|
2007-06-15 05:50:37 +04:00
|
|
|
}
|
|
|
|
|
2012-04-09 13:48:41 +04:00
|
|
|
void
|
2012-04-12 15:11:40 +04:00
|
|
|
HTMLTextFieldAccessible::Value(nsString& aValue)
|
2001-05-12 01:11:38 +04:00
|
|
|
{
|
2012-04-09 13:48:41 +04:00
|
|
|
aValue.Truncate();
|
2011-04-10 03:38:06 +04:00
|
|
|
if (NativeState() & states::PROTECTED) // Don't return password text!
|
2012-04-09 13:48:41 +04:00
|
|
|
return;
|
2001-09-18 07:09:01 +04:00
|
|
|
|
2017-10-31 02:14:51 +03:00
|
|
|
HTMLTextAreaElement* textArea = HTMLTextAreaElement::FromContent(mContent);
|
2001-05-12 01:11:38 +04:00
|
|
|
if (textArea) {
|
2012-04-09 13:48:41 +04:00
|
|
|
textArea->GetValue(aValue);
|
|
|
|
return;
|
2001-05-12 01:11:38 +04:00
|
|
|
}
|
2012-12-23 04:54:13 +04:00
|
|
|
|
2013-03-28 23:41:32 +04:00
|
|
|
HTMLInputElement* input = HTMLInputElement::FromContent(mContent);
|
2016-11-15 20:46:32 +03:00
|
|
|
if (input) {
|
|
|
|
// Pass NonSystem as the caller type, to be safe. We don't expect to have a
|
|
|
|
// file input here.
|
|
|
|
input->GetValue(aValue, CallerType::NonSystem);
|
|
|
|
}
|
2001-04-18 03:06:38 +04:00
|
|
|
}
|
|
|
|
|
2011-09-01 19:37:24 +04:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
HTMLTextFieldAccessible::ApplyARIAState(uint64_t* aState) const
|
2011-09-01 19:37:24 +04:00
|
|
|
{
|
2012-05-31 12:04:41 +04:00
|
|
|
HyperTextAccessibleWrap::ApplyARIAState(aState);
|
2012-04-05 20:23:30 +04:00
|
|
|
aria::MapToState(aria::eARIAAutoComplete, mContent->AsElement(), aState);
|
2013-12-08 01:37:04 +04: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 16:36:20 +04:00
|
|
|
}
|
2011-09-01 19:37:24 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t
|
2012-04-12 15:11:40 +04:00
|
|
|
HTMLTextFieldAccessible::NativeState()
|
2001-04-18 03:06:38 +04:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t state = HyperTextAccessibleWrap::NativeState();
|
2006-06-16 21:13:37 +04:00
|
|
|
|
2014-01-21 20:24:23 +04:00
|
|
|
// Text fields are always editable, even if they are also read only or
|
|
|
|
// disabled.
|
|
|
|
state |= states::EDITABLE;
|
|
|
|
|
2005-03-15 02:10:53 +03:00
|
|
|
// can be focusable, focused, protected. readonly, unavailable, selected
|
2017-12-07 21:13:50 +03:00
|
|
|
if (mContent->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
|
|
|
nsGkAtoms::password, eIgnoreCase)) {
|
2011-04-10 03:38:06 +04:00
|
|
|
state |= states::PROTECTED;
|
2001-05-12 01:11:38 +04:00
|
|
|
}
|
2006-06-16 21:13:37 +04:00
|
|
|
|
2017-12-07 21:13:50 +03:00
|
|
|
if (mContent->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::readonly)) {
|
2011-04-10 03:38:06 +04:00
|
|
|
state |= states::READONLY;
|
2001-05-12 01:11:38 +04:00
|
|
|
}
|
|
|
|
|
2006-06-16 21:13:37 +04:00
|
|
|
// Is it an <input> or a <textarea> ?
|
2013-03-28 23:41:32 +04:00
|
|
|
HTMLInputElement* input = HTMLInputElement::FromContent(mContent);
|
2012-06-03 15:36:51 +04:00
|
|
|
state |= input && input->IsSingleLineTextControl() ?
|
|
|
|
states::SINGLE_LINE : states::MULTI_LINE;
|
2011-09-28 05:46:11 +04:00
|
|
|
|
2014-01-21 20:24:23 +04:00
|
|
|
if (state & (states::PROTECTED | states::MULTI_LINE | states::READONLY |
|
|
|
|
states::UNAVAILABLE))
|
2011-09-28 05:46:11 +04:00
|
|
|
return state;
|
2006-06-16 21:13:37 +04:00
|
|
|
|
2011-09-28 05:46:11 +04:00
|
|
|
// Expose autocomplete states if this input is part of autocomplete widget.
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* widget = ContainerWidget();
|
2011-09-28 05:46:11 +04:00
|
|
|
if (widget && widget-IsAutoComplete()) {
|
|
|
|
state |= states::HASPOPUP | states::SUPPORTS_AUTOCOMPLETION;
|
2011-04-10 03:38:06 +04:00
|
|
|
return state;
|
2011-09-28 05:46:11 +04:00
|
|
|
}
|
2008-07-02 12:42:58 +04:00
|
|
|
|
2011-10-07 10:02:18 +04:00
|
|
|
// Expose autocomplete state if it has associated autocomplete list.
|
2017-12-07 21:13:50 +03:00
|
|
|
if (mContent->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::list))
|
2013-06-04 10:52:39 +04:00
|
|
|
return state | states::SUPPORTS_AUTOCOMPLETION | states::HASPOPUP;
|
2011-10-07 10:02:18 +04:00
|
|
|
|
2013-12-08 01:37:04 +04:00
|
|
|
// Ordinal XUL textboxes don't support autocomplete.
|
|
|
|
if (!XULWidgetElm() && Preferences::GetBool("browser.formfill.enable")) {
|
2007-04-06 02:14:08 +04: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;
|
2017-12-07 21:13:50 +03:00
|
|
|
mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::autocomplete,
|
|
|
|
autocomplete);
|
2007-04-06 02:14:08 +04:00
|
|
|
|
|
|
|
if (!autocomplete.LowerCaseEqualsLiteral("off")) {
|
2017-12-07 21:13:50 +03:00
|
|
|
Element* formElement = input->GetFormElement();
|
|
|
|
if (formElement) {
|
|
|
|
formElement->GetAttr(kNameSpaceID_None,
|
2011-06-04 01:35:17 +04:00
|
|
|
nsGkAtoms::autocomplete, autocomplete);
|
2007-04-06 01:52:03 +04:00
|
|
|
}
|
2007-04-06 02:14:08 +04:00
|
|
|
|
2017-12-07 21:13:50 +03:00
|
|
|
if (!formElement || !autocomplete.LowerCaseEqualsLiteral("off"))
|
2011-04-10 03:38:06 +04:00
|
|
|
state |= states::SUPPORTS_AUTOCOMPLETION;
|
2007-03-13 06:22:44 +03:00
|
|
|
}
|
2006-06-16 21:13:37 +04:00
|
|
|
}
|
|
|
|
|
2011-04-10 03:38:06 +04:00
|
|
|
return state;
|
2005-03-15 02:10:53 +03:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t
|
2012-04-12 15:11:40 +04:00
|
|
|
HTMLTextFieldAccessible::ActionCount()
|
2004-06-01 09:25:00 +04:00
|
|
|
{
|
2011-06-05 23:35:43 +04:00
|
|
|
return 1;
|
2004-06-01 09:25:00 +04:00
|
|
|
}
|
|
|
|
|
2014-09-16 21:30:23 +04:00
|
|
|
void
|
|
|
|
HTMLTextFieldAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
2004-06-01 09:25:00 +04:00
|
|
|
{
|
2014-09-16 21:30:23 +04:00
|
|
|
if (aIndex == eAction_Click)
|
2007-02-25 06:43:20 +03:00
|
|
|
aName.AssignLiteral("activate");
|
2004-06-01 09:25:00 +04:00
|
|
|
}
|
|
|
|
|
2014-09-16 21:30:23 +04:00
|
|
|
bool
|
2012-08-22 19:56:38 +04:00
|
|
|
HTMLTextFieldAccessible::DoAction(uint8_t aIndex)
|
2004-06-01 09:25:00 +04:00
|
|
|
{
|
2014-09-16 21:30:23 +04:00
|
|
|
if (aIndex != 0)
|
|
|
|
return false;
|
2012-04-12 15:11:40 +04:00
|
|
|
|
2014-09-16 21:30:23 +04:00
|
|
|
TakeFocus();
|
|
|
|
return true;
|
2004-06-01 09:25:00 +04:00
|
|
|
}
|
|
|
|
|
2017-08-07 11:42:50 +03:00
|
|
|
already_AddRefed<TextEditor>
|
2012-04-12 15:11:40 +04:00
|
|
|
HTMLTextFieldAccessible::GetEditor() const
|
2006-07-12 17:14:53 +04:00
|
|
|
{
|
2017-08-07 11:42:50 +03:00
|
|
|
nsCOMPtr<nsITextControlElement> textControlElement =
|
|
|
|
do_QueryInterface(mContent);
|
|
|
|
if (!textControlElement) {
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2017-08-07 11:42:50 +03:00
|
|
|
}
|
|
|
|
RefPtr<TextEditor> textEditor = textControlElement->GetTextEditor();
|
|
|
|
return textEditor.forget();
|
2006-07-12 17:14:53 +04:00
|
|
|
}
|
|
|
|
|
2011-09-28 05:46:11 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 15:11:40 +04:00
|
|
|
// HTMLTextFieldAccessible: Widgets
|
2011-09-28 05:46:11 +04:00
|
|
|
|
|
|
|
bool
|
2012-04-12 15:11:40 +04:00
|
|
|
HTMLTextFieldAccessible::IsWidget() const
|
2011-09-28 05:46:11 +04:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible*
|
2012-04-12 15:11:40 +04:00
|
|
|
HTMLTextFieldAccessible::ContainerWidget() const
|
2011-09-28 05:46:11 +04:00
|
|
|
{
|
2015-08-13 15:22:48 +03:00
|
|
|
if (!mParent || mParent->Role() != roles::AUTOCOMPLETE) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return mParent;
|
2011-09-28 05:46:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-30 16:36:20 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 15:11:40 +04:00
|
|
|
// HTMLFileInputAccessible
|
2011-11-30 16:36:20 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-04-12 15:11:40 +04:00
|
|
|
HTMLFileInputAccessible::
|
2012-05-27 13:01:40 +04:00
|
|
|
HTMLFileInputAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-05-31 12:04:41 +04:00
|
|
|
HyperTextAccessibleWrap(aContent, aDoc)
|
2011-11-30 16:36:20 +04:00
|
|
|
{
|
2012-12-18 09:22:26 +04:00
|
|
|
mType = eHTMLFileInputType;
|
2011-11-30 16:36:20 +04:00
|
|
|
}
|
|
|
|
|
2012-01-12 07:07:35 +04:00
|
|
|
role
|
2012-04-12 15:11:40 +04:00
|
|
|
HTMLFileInputAccessible::NativeRole()
|
2011-11-30 16:36:20 +04:00
|
|
|
{
|
|
|
|
// JAWS wants a text container, others don't mind. No specific role in
|
|
|
|
// AT APIs.
|
2012-01-12 07:07:35 +04:00
|
|
|
return roles::TEXT_CONTAINER;
|
2011-11-30 16:36:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2012-04-12 15:11:40 +04:00
|
|
|
HTMLFileInputAccessible::HandleAccEvent(AccEvent* aEvent)
|
2011-11-30 16:36:20 +04:00
|
|
|
{
|
2012-05-31 12:04:41 +04:00
|
|
|
nsresult rv = HyperTextAccessibleWrap::HandleAccEvent(aEvent);
|
2011-11-30 16:36:20 +04: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 15:35:22 +04:00
|
|
|
Accessible* button = GetChildAt(0);
|
2012-01-12 07:07:35 +04:00
|
|
|
if (button && button->Role() == roles::PUSHBUTTON) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<AccStateChangeEvent> childEvent =
|
2011-11-30 16:36:20 +04:00
|
|
|
new AccStateChangeEvent(button, event->GetState(),
|
2013-10-26 18:58:53 +04:00
|
|
|
event->IsStateEnabled(), event->FromUserInput());
|
2011-11-30 16:36:20 +04:00
|
|
|
nsEventShell::FireEvent(childEvent);
|
|
|
|
}
|
|
|
|
}
|
2013-03-27 15:35:22 +04:00
|
|
|
|
2011-11-30 16:36:20 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-04-28 04:54:54 +04:00
|
|
|
|
2013-12-11 07:19:26 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// HTMLSpinnerAccessible
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
role
|
|
|
|
HTMLSpinnerAccessible::NativeRole()
|
|
|
|
{
|
|
|
|
return roles::SPINBUTTON;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
HTMLSpinnerAccessible::Value(nsString& aValue)
|
|
|
|
{
|
|
|
|
AccessibleWrap::Value(aValue);
|
|
|
|
if (!aValue.IsEmpty())
|
|
|
|
return;
|
|
|
|
|
2016-11-15 20:46:32 +03:00
|
|
|
// Pass NonSystem as the caller type, to be safe. We don't expect to have a
|
|
|
|
// file input here.
|
|
|
|
HTMLInputElement::FromContent(mContent)->GetValue(aValue,
|
|
|
|
CallerType::NonSystem);
|
2013-12-11 07:19:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
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-28 04:54:54 +04: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;
|
|
|
|
|
2016-11-15 20:46:32 +03:00
|
|
|
// Pass NonSystem as the caller type, to be safe. We don't expect to have a
|
|
|
|
// file input here.
|
|
|
|
HTMLInputElement::FromContent(mContent)->GetValue(aValue,
|
|
|
|
CallerType::NonSystem);
|
2013-04-28 04:54:54 +04:00
|
|
|
}
|
|
|
|
|
2013-11-20 01:01:15 +04:00
|
|
|
double
|
|
|
|
HTMLRangeAccessible::MaxValue() const
|
2013-04-28 04:54:54 +04:00
|
|
|
{
|
2013-11-20 01:01:15 +04:00
|
|
|
double value = LeafAccessible::MaxValue();
|
|
|
|
if (!IsNaN(value))
|
|
|
|
return value;
|
2013-04-28 04:54:54 +04:00
|
|
|
|
2013-11-20 01:01:15 +04:00
|
|
|
return HTMLInputElement::FromContent(mContent)->GetMaximum().toDouble();
|
2013-04-28 04:54:54 +04:00
|
|
|
}
|
|
|
|
|
2013-11-20 01:01:15 +04:00
|
|
|
double
|
|
|
|
HTMLRangeAccessible::MinValue() const
|
2013-04-28 04:54:54 +04:00
|
|
|
{
|
2013-11-20 01:01:15 +04:00
|
|
|
double value = LeafAccessible::MinValue();
|
|
|
|
if (!IsNaN(value))
|
|
|
|
return value;
|
2013-04-28 04:54:54 +04:00
|
|
|
|
2013-11-20 01:01:15 +04:00
|
|
|
return HTMLInputElement::FromContent(mContent)->GetMinimum().toDouble();
|
2013-04-28 04:54:54 +04:00
|
|
|
}
|
|
|
|
|
2013-11-20 01:01:15 +04:00
|
|
|
double
|
|
|
|
HTMLRangeAccessible::Step() const
|
2013-04-28 04:54:54 +04:00
|
|
|
{
|
2013-11-20 01:01:15 +04:00
|
|
|
double value = LeafAccessible::Step();
|
|
|
|
if (!IsNaN(value))
|
|
|
|
return value;
|
2013-04-28 04:54:54 +04:00
|
|
|
|
2013-11-20 01:01:15 +04:00
|
|
|
return HTMLInputElement::FromContent(mContent)->GetStep().toDouble();
|
2013-04-28 04:54:54 +04:00
|
|
|
}
|
|
|
|
|
2013-11-20 01:01:15 +04:00
|
|
|
double
|
|
|
|
HTMLRangeAccessible::CurValue() const
|
2013-04-28 04:54:54 +04:00
|
|
|
{
|
2013-11-20 01:01:15 +04:00
|
|
|
double value = LeafAccessible::CurValue();
|
|
|
|
if (!IsNaN(value))
|
|
|
|
return value;
|
2013-04-28 04:54:54 +04:00
|
|
|
|
2013-11-20 01:01:15 +04:00
|
|
|
return HTMLInputElement::FromContent(mContent)->GetValueAsDecimal().toDouble();
|
2013-04-28 04:54:54 +04:00
|
|
|
}
|
|
|
|
|
2013-11-20 01:01:15 +04:00
|
|
|
bool
|
|
|
|
HTMLRangeAccessible::SetCurValue(double aValue)
|
2013-04-28 04:54:54 +04:00
|
|
|
{
|
|
|
|
ErrorResult er;
|
|
|
|
HTMLInputElement::FromContent(mContent)->SetValueAsNumber(aValue, er);
|
2013-11-20 01:01:15 +04:00
|
|
|
return !er.Failed();
|
2013-04-28 04:54:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-11 12:23:18 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 15:11:40 +04:00
|
|
|
// HTMLGroupboxAccessible
|
2010-06-11 12:23:18 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2002-02-16 04:34:42 +03:00
|
|
|
|
2012-04-12 15:11:40 +04:00
|
|
|
HTMLGroupboxAccessible::
|
2012-05-27 13:01:40 +04:00
|
|
|
HTMLGroupboxAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-05-31 12:04:41 +04:00
|
|
|
HyperTextAccessibleWrap(aContent, aDoc)
|
2010-06-11 12:23:18 +04:00
|
|
|
{
|
2002-02-16 04:34:42 +03:00
|
|
|
}
|
|
|
|
|
2012-01-12 07:07:35 +04:00
|
|
|
role
|
2012-04-12 15:11:40 +04:00
|
|
|
HTMLGroupboxAccessible::NativeRole()
|
2002-02-16 04:34:42 +03:00
|
|
|
{
|
2012-01-12 07:07:35 +04:00
|
|
|
return roles::GROUPING;
|
2002-02-16 04:34:42 +03:00
|
|
|
}
|
|
|
|
|
2011-12-07 11:20:17 +04:00
|
|
|
nsIContent*
|
2014-09-16 21:30:23 +04:00
|
|
|
HTMLGroupboxAccessible::GetLegend() const
|
2002-02-16 04:34:42 +03:00
|
|
|
{
|
2011-12-07 11:20:17 +04:00
|
|
|
for (nsIContent* legendContent = mContent->GetFirstChild(); legendContent;
|
|
|
|
legendContent = legendContent->GetNextSibling()) {
|
2011-06-04 01:35:17 +04:00
|
|
|
if (legendContent->NodeInfo()->Equals(nsGkAtoms::legend,
|
2010-06-11 12:23:18 +04:00
|
|
|
mContent->GetNameSpaceID())) {
|
2007-07-01 00:06:13 +04:00
|
|
|
// Either XHTML namespace or no namespace
|
2010-06-11 12:23:18 +04:00
|
|
|
return legendContent;
|
2007-07-01 00:06:13 +04:00
|
|
|
}
|
|
|
|
}
|
2002-02-16 04:34:42 +03:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2002-02-16 04:34:42 +03:00
|
|
|
}
|
|
|
|
|
2012-10-14 08:18:39 +04:00
|
|
|
ENameValueFlag
|
|
|
|
HTMLGroupboxAccessible::NativeName(nsString& aName)
|
2002-02-16 04:34:42 +03:00
|
|
|
{
|
2012-10-17 10:38:16 +04:00
|
|
|
ENameValueFlag nameFlag = Accessible::NativeName(aName);
|
2008-10-10 16:26:55 +04:00
|
|
|
if (!aName.IsEmpty())
|
2012-10-17 10:38:16 +04:00
|
|
|
return nameFlag;
|
2005-06-01 18:03:38 +04:00
|
|
|
|
2012-10-14 08:18:39 +04:00
|
|
|
nsIContent* legendContent = GetLegend();
|
|
|
|
if (legendContent)
|
|
|
|
nsTextEquivUtils::AppendTextEquivFromContent(this, legendContent, &aName);
|
2007-07-01 00:06:13 +04:00
|
|
|
|
2012-10-14 08:18:39 +04:00
|
|
|
return eNameOK;
|
2007-07-01 00:06:13 +04:00
|
|
|
}
|
|
|
|
|
2011-08-10 05:44:00 +04:00
|
|
|
Relation
|
2013-10-19 22:19:50 +04:00
|
|
|
HTMLGroupboxAccessible::RelationByType(RelationType aType)
|
2007-07-01 00:06:13 +04:00
|
|
|
{
|
2012-05-31 12:04:41 +04:00
|
|
|
Relation rel = HyperTextAccessibleWrap::RelationByType(aType);
|
2007-07-01 00:06:13 +04:00
|
|
|
// No override for label, so use <legend> for this <fieldset>
|
2013-10-19 22:19:50 +04:00
|
|
|
if (aType == RelationType::LABELLED_BY)
|
2012-05-08 04:00:29 +04:00
|
|
|
rel.AppendTarget(mDoc, GetLegend());
|
2007-07-01 00:06:13 +04:00
|
|
|
|
2011-08-10 05:44:00 +04:00
|
|
|
return rel;
|
2002-02-16 04:34:42 +03:00
|
|
|
}
|
2004-05-26 17:01:13 +04:00
|
|
|
|
2009-03-07 18:38:58 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 15:11:40 +04:00
|
|
|
// HTMLLegendAccessible
|
2010-06-11 12:23:18 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2009-03-07 18:38:58 +03:00
|
|
|
|
2012-04-12 15:11:40 +04:00
|
|
|
HTMLLegendAccessible::
|
2012-05-27 13:01:40 +04:00
|
|
|
HTMLLegendAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-05-31 12:04:41 +04:00
|
|
|
HyperTextAccessibleWrap(aContent, aDoc)
|
2010-06-11 12:23:18 +04:00
|
|
|
{
|
2007-07-01 00:06:13 +04:00
|
|
|
}
|
|
|
|
|
2011-08-10 05:44:00 +04:00
|
|
|
Relation
|
2013-10-19 22:19:50 +04:00
|
|
|
HTMLLegendAccessible::RelationByType(RelationType aType)
|
2004-05-26 17:01:13 +04:00
|
|
|
{
|
2012-05-31 12:04:41 +04:00
|
|
|
Relation rel = HyperTextAccessibleWrap::RelationByType(aType);
|
2013-10-19 22:19:50 +04:00
|
|
|
if (aType != RelationType::LABEL_FOR)
|
2011-08-10 05:44:00 +04:00
|
|
|
return rel;
|
2004-05-26 17:01:13 +04:00
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* groupbox = Parent();
|
2012-01-12 07:07:35 +04:00
|
|
|
if (groupbox && groupbox->Role() == roles::GROUPING)
|
2011-08-10 05:44:00 +04:00
|
|
|
rel.AppendTarget(groupbox);
|
2007-07-01 00:06:13 +04:00
|
|
|
|
2011-08-10 05:44:00 +04:00
|
|
|
return rel;
|
2004-05-26 17:01:13 +04:00
|
|
|
}
|
2009-03-07 18:38:58 +03:00
|
|
|
|
2011-12-05 10:04:06 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 15:11:40 +04:00
|
|
|
// HTMLFigureAccessible
|
2011-12-05 10:04:06 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-04-12 15:11:40 +04:00
|
|
|
HTMLFigureAccessible::
|
2012-05-27 13:01:40 +04:00
|
|
|
HTMLFigureAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-05-31 12:04:41 +04:00
|
|
|
HyperTextAccessibleWrap(aContent, aDoc)
|
2011-12-05 10:04:06 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-10-14 08:18:39 +04:00
|
|
|
ENameValueFlag
|
|
|
|
HTMLFigureAccessible::NativeName(nsString& aName)
|
2011-12-05 10:04:06 +04:00
|
|
|
{
|
2012-10-17 10:38:16 +04:00
|
|
|
ENameValueFlag nameFlag = HyperTextAccessibleWrap::NativeName(aName);
|
2011-12-05 10:04:06 +04:00
|
|
|
if (!aName.IsEmpty())
|
2012-10-17 10:38:16 +04:00
|
|
|
return nameFlag;
|
2011-12-05 10:04:06 +04:00
|
|
|
|
|
|
|
nsIContent* captionContent = Caption();
|
2012-10-14 08:18:39 +04:00
|
|
|
if (captionContent)
|
|
|
|
nsTextEquivUtils::AppendTextEquivFromContent(this, captionContent, &aName);
|
2011-12-05 10:04:06 +04:00
|
|
|
|
2012-10-14 08:18:39 +04:00
|
|
|
return eNameOK;
|
2011-12-05 10:04:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
Relation
|
2013-10-19 22:19:50 +04:00
|
|
|
HTMLFigureAccessible::RelationByType(RelationType aType)
|
2011-12-05 10:04:06 +04:00
|
|
|
{
|
2012-05-31 12:04:41 +04:00
|
|
|
Relation rel = HyperTextAccessibleWrap::RelationByType(aType);
|
2013-10-19 22:19:50 +04:00
|
|
|
if (aType == RelationType::LABELLED_BY)
|
2012-05-08 04:00:29 +04:00
|
|
|
rel.AppendTarget(mDoc, Caption());
|
2011-12-05 10:04:06 +04:00
|
|
|
|
|
|
|
return rel;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIContent*
|
2012-04-12 15:11:40 +04:00
|
|
|
HTMLFigureAccessible::Caption() const
|
2011-12-05 10:04:06 +04:00
|
|
|
{
|
|
|
|
for (nsIContent* childContent = mContent->GetFirstChild(); childContent;
|
|
|
|
childContent = childContent->GetNextSibling()) {
|
|
|
|
if (childContent->NodeInfo()->Equals(nsGkAtoms::figcaption,
|
|
|
|
mContent->GetNameSpaceID())) {
|
|
|
|
return childContent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2011-12-05 10:04:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 15:11:40 +04:00
|
|
|
// HTMLFigcaptionAccessible
|
2011-12-05 10:04:06 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-04-12 15:11:40 +04:00
|
|
|
HTMLFigcaptionAccessible::
|
2012-05-27 13:01:40 +04:00
|
|
|
HTMLFigcaptionAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-05-31 12:04:41 +04:00
|
|
|
HyperTextAccessibleWrap(aContent, aDoc)
|
2011-12-05 10:04:06 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Relation
|
2013-10-19 22:19:50 +04:00
|
|
|
HTMLFigcaptionAccessible::RelationByType(RelationType aType)
|
2011-12-05 10:04:06 +04:00
|
|
|
{
|
2012-05-31 12:04:41 +04:00
|
|
|
Relation rel = HyperTextAccessibleWrap::RelationByType(aType);
|
2013-10-19 22:19:50 +04:00
|
|
|
if (aType != RelationType::LABEL_FOR)
|
2011-12-05 10:04:06 +04:00
|
|
|
return rel;
|
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* figure = Parent();
|
2011-12-05 10:04:06 +04:00
|
|
|
if (figure &&
|
|
|
|
figure->GetContent()->NodeInfo()->Equals(nsGkAtoms::figure,
|
|
|
|
mContent->GetNameSpaceID())) {
|
|
|
|
rel.AppendTarget(figure);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rel;
|
|
|
|
}
|