2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 2; tab-width: 20; indent-tabs-mode: nil; -*-
|
2018-10-11 19:20:54 +03: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/. */
|
|
|
|
|
|
|
|
#include "ProxyAccessibleWrap.h"
|
2019-11-05 16:05:06 +03:00
|
|
|
#include "Accessible-inl.h"
|
2019-09-24 02:42:49 +03:00
|
|
|
|
2018-10-11 19:21:09 +03:00
|
|
|
#include "nsPersistentProperties.h"
|
2018-10-11 19:20:54 +03:00
|
|
|
|
2019-09-24 02:42:49 +03:00
|
|
|
#include "mozilla/a11y/DocAccessiblePlatformExtParent.h"
|
|
|
|
|
2018-10-11 19:20:54 +03:00
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
|
|
|
ProxyAccessibleWrap::ProxyAccessibleWrap(ProxyAccessible* aProxy)
|
|
|
|
: AccessibleWrap(nullptr, nullptr) {
|
|
|
|
mType = eProxyType;
|
|
|
|
mBits.proxy = aProxy;
|
|
|
|
|
|
|
|
if (aProxy->mHasValue) {
|
|
|
|
mStateFlags |= eHasNumericValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aProxy->mIsSelection) {
|
|
|
|
mGenericTypes |= eSelect;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aProxy->mIsHyperText) {
|
|
|
|
mGenericTypes |= eHyperText;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto doc = reinterpret_cast<DocProxyAccessibleWrap*>(
|
|
|
|
Proxy()->Document()->GetWrapper());
|
|
|
|
if (doc) {
|
|
|
|
mID = AcquireID();
|
|
|
|
doc->AddID(mID, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProxyAccessibleWrap::Shutdown() {
|
|
|
|
auto doc = reinterpret_cast<DocProxyAccessibleWrap*>(
|
|
|
|
Proxy()->Document()->GetWrapper());
|
|
|
|
if (mID && doc) {
|
|
|
|
doc->RemoveID(mID);
|
|
|
|
ReleaseID(mID);
|
|
|
|
mID = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
mBits.proxy = nullptr;
|
|
|
|
mStateFlags |= eIsDefunct;
|
|
|
|
}
|
2018-10-11 19:21:09 +03:00
|
|
|
|
|
|
|
// Accessible
|
|
|
|
|
|
|
|
already_AddRefed<nsIPersistentProperties> ProxyAccessibleWrap::Attributes() {
|
|
|
|
AutoTArray<Attribute, 10> attrs;
|
|
|
|
Proxy()->Attributes(&attrs);
|
2018-11-12 19:41:33 +03:00
|
|
|
return AttributeArrayToProperties(attrs);
|
2018-10-11 19:21:09 +03:00
|
|
|
}
|
|
|
|
|
2018-10-11 19:22:11 +03:00
|
|
|
uint32_t ProxyAccessibleWrap::ChildCount() const {
|
|
|
|
return Proxy()->ChildrenCount();
|
|
|
|
}
|
|
|
|
|
2018-10-22 21:15:27 +03:00
|
|
|
Accessible* ProxyAccessibleWrap::GetChildAt(uint32_t aIndex) const {
|
|
|
|
ProxyAccessible* child = Proxy()->ChildAt(aIndex);
|
|
|
|
return child ? WrapperFor(child) : nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
ENameValueFlag ProxyAccessibleWrap::Name(nsString& aName) const {
|
|
|
|
Proxy()->Name(aName);
|
|
|
|
return eNameOK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProxyAccessibleWrap::Value(nsString& aValue) const {
|
|
|
|
Proxy()->Value(aValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t ProxyAccessibleWrap::State() { return Proxy()->State(); }
|
|
|
|
|
|
|
|
nsIntRect ProxyAccessibleWrap::Bounds() const { return Proxy()->Bounds(); }
|
|
|
|
|
2018-10-11 19:22:11 +03:00
|
|
|
void ProxyAccessibleWrap::ScrollTo(uint32_t aHow) const {
|
|
|
|
Proxy()->ScrollTo(aHow);
|
|
|
|
}
|
|
|
|
|
2018-12-05 18:37:24 +03:00
|
|
|
uint8_t ProxyAccessibleWrap::ActionCount() const {
|
|
|
|
return Proxy()->ActionCount();
|
|
|
|
}
|
|
|
|
|
2018-12-05 19:08:01 +03:00
|
|
|
bool ProxyAccessibleWrap::DoAction(uint8_t aIndex) const {
|
|
|
|
return Proxy()->DoAction(aIndex);
|
|
|
|
}
|
|
|
|
|
2018-10-11 19:21:09 +03:00
|
|
|
// Other
|
|
|
|
|
|
|
|
void ProxyAccessibleWrap::SetTextContents(const nsAString& aText) {
|
|
|
|
Proxy()->ReplaceText(PromiseFlatString(aText));
|
|
|
|
}
|
|
|
|
|
2018-10-11 19:22:11 +03:00
|
|
|
void ProxyAccessibleWrap::GetTextContents(nsAString& aText) {
|
|
|
|
nsAutoString text;
|
|
|
|
Proxy()->TextSubstring(0, -1, text);
|
|
|
|
aText.Assign(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ProxyAccessibleWrap::GetSelectionBounds(int32_t* aStartOffset,
|
|
|
|
int32_t* aEndOffset) {
|
|
|
|
nsAutoString unused;
|
|
|
|
return Proxy()->SelectionBoundsAt(0, unused, aStartOffset, aEndOffset);
|
|
|
|
}
|
|
|
|
|
2019-09-24 02:42:49 +03:00
|
|
|
void ProxyAccessibleWrap::Pivot(int32_t aGranularity, bool aForward,
|
|
|
|
bool aInclusive) {
|
|
|
|
Unused << Proxy()->Document()->GetPlatformExtension()->SendPivot(
|
|
|
|
Proxy()->ID(), aGranularity, aForward, aInclusive);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProxyAccessibleWrap::ExploreByTouch(float aX, float aY) {
|
|
|
|
Unused << Proxy()->Document()->GetPlatformExtension()->SendExploreByTouch(
|
|
|
|
Proxy()->ID(), aX, aY);
|
|
|
|
}
|
|
|
|
|
2019-09-24 02:42:47 +03:00
|
|
|
void ProxyAccessibleWrap::NavigateText(int32_t aGranularity,
|
|
|
|
int32_t aStartOffset, int32_t aEndOffset,
|
|
|
|
bool aForward, bool aSelect) {
|
|
|
|
Unused << Proxy()->Document()->GetPlatformExtension()->SendNavigateText(
|
|
|
|
Proxy()->ID(), aGranularity, aStartOffset, aEndOffset, aForward, aSelect);
|
|
|
|
}
|
|
|
|
|
2019-09-24 02:42:40 +03:00
|
|
|
void ProxyAccessibleWrap::SetSelection(int32_t aStart, int32_t aEnd) {
|
|
|
|
Unused << Proxy()->Document()->GetPlatformExtension()->SendSetSelection(
|
|
|
|
Proxy()->ID(), aStart, aEnd);
|
|
|
|
}
|
|
|
|
|
2019-09-24 02:42:38 +03:00
|
|
|
void ProxyAccessibleWrap::Cut() {
|
|
|
|
Unused << Proxy()->Document()->GetPlatformExtension()->SendCut(Proxy()->ID());
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProxyAccessibleWrap::Copy() {
|
|
|
|
Unused << Proxy()->Document()->GetPlatformExtension()->SendCopy(
|
|
|
|
Proxy()->ID());
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProxyAccessibleWrap::Paste() {
|
|
|
|
Unused << Proxy()->Document()->GetPlatformExtension()->SendPaste(
|
|
|
|
Proxy()->ID());
|
|
|
|
}
|
|
|
|
|
2018-10-22 21:15:27 +03:00
|
|
|
role ProxyAccessibleWrap::WrapperRole() { return Proxy()->Role(); }
|
2018-10-20 04:22:52 +03:00
|
|
|
|
2018-10-22 21:15:27 +03:00
|
|
|
AccessibleWrap* ProxyAccessibleWrap::WrapperParent() {
|
|
|
|
return Proxy()->Parent() ? WrapperFor(Proxy()->Parent()) : nullptr;
|
|
|
|
}
|
2018-10-20 04:22:52 +03:00
|
|
|
|
2018-10-22 21:15:27 +03:00
|
|
|
bool ProxyAccessibleWrap::WrapperRangeInfo(double* aCurVal, double* aMinVal,
|
|
|
|
double* aMaxVal, double* aStep) {
|
|
|
|
if (HasNumericValue()) {
|
|
|
|
ProxyAccessible* proxy = Proxy();
|
|
|
|
*aCurVal = proxy->CurValue();
|
|
|
|
*aMinVal = proxy->MinValue();
|
|
|
|
*aMaxVal = proxy->MaxValue();
|
|
|
|
*aStep = proxy->Step();
|
|
|
|
return true;
|
2018-10-20 04:22:52 +03:00
|
|
|
}
|
|
|
|
|
2018-10-22 21:15:27 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProxyAccessibleWrap::WrapperDOMNodeID(nsString& aDOMNodeID) {
|
|
|
|
Proxy()->DOMNodeID(aDOMNodeID);
|
2018-10-11 19:21:09 +03:00
|
|
|
}
|