зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1826851 - Unify IsSearchbox in Accessible and use cache when available. r=morgan
Differential Revision: https://phabricator.services.mozilla.com/D174970
This commit is contained in:
Родитель
099c7dcb49
Коммит
04e98136b0
|
@ -363,6 +363,16 @@ void Accessible::GetPositionAndSetSize(int32_t* aPosInSet, int32_t* aSetSize) {
|
|||
}
|
||||
}
|
||||
|
||||
bool Accessible::IsSearchbox() const {
|
||||
const nsRoleMapEntry* roleMapEntry = ARIARoleMap();
|
||||
if ((roleMapEntry && roleMapEntry->Is(nsGkAtoms::searchbox)) ||
|
||||
InputType() == nsGkAtoms::search) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef A11Y_LOG
|
||||
void Accessible::DebugDescription(nsCString& aDesc) const {
|
||||
aDesc.Truncate();
|
||||
|
|
|
@ -366,6 +366,11 @@ class Accessible {
|
|||
*/
|
||||
virtual nsAtom* TagName() const = 0;
|
||||
|
||||
/**
|
||||
* Return input `type` attribute
|
||||
*/
|
||||
virtual nsAtom* InputType() const = 0;
|
||||
|
||||
/**
|
||||
* Return a landmark role if applied.
|
||||
*/
|
||||
|
@ -558,6 +563,8 @@ class Accessible {
|
|||
|
||||
bool IsDateTimeField() const { return mType == eHTMLDateTimeFieldType; }
|
||||
|
||||
virtual bool IsSearchbox() const;
|
||||
|
||||
virtual bool HasNumericValue() const = 0;
|
||||
|
||||
// Remote/Local types
|
||||
|
|
|
@ -43,14 +43,6 @@ inline void LocalAccessible::SetRoleMapEntry(
|
|||
mRoleMapEntryIndex = aria::GetIndexFromRoleMap(aRoleMapEntry);
|
||||
}
|
||||
|
||||
inline bool LocalAccessible::IsSearchbox() const {
|
||||
const nsRoleMapEntry* roleMapEntry = ARIARoleMap();
|
||||
return (roleMapEntry && roleMapEntry->Is(nsGkAtoms::searchbox)) ||
|
||||
(mContent->IsHTMLElement(nsGkAtoms::input) &&
|
||||
mContent->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
||||
nsGkAtoms::search, eCaseMatters));
|
||||
}
|
||||
|
||||
inline bool LocalAccessible::NativeHasNumericValue() const {
|
||||
return mGenericTypes & eNumericValue;
|
||||
}
|
||||
|
|
|
@ -3891,6 +3891,19 @@ nsAtom* LocalAccessible::TagName() const {
|
|||
: nullptr;
|
||||
}
|
||||
|
||||
nsAtom* LocalAccessible::InputType() const {
|
||||
if (!IsTextField() && !IsDateTimeField()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
dom::Element* el = mContent->AsElement();
|
||||
if (const nsAttrValue* attr = el->GetParsedAttr(nsGkAtoms::type)) {
|
||||
return attr->GetAtomValue();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
already_AddRefed<nsAtom> LocalAccessible::DisplayStyle() const {
|
||||
if (dom::Element* elm = Elm()) {
|
||||
if (elm->IsHTMLElement(nsGkAtoms::area)) {
|
||||
|
|
|
@ -469,8 +469,6 @@ class LocalAccessible : public nsISupports, public Accessible {
|
|||
|
||||
a11y::RootAccessible* AsRoot();
|
||||
|
||||
bool IsSearchbox() const;
|
||||
|
||||
virtual TableAccessible* AsTable() { return nullptr; }
|
||||
|
||||
virtual TableCellAccessible* AsTableCell() { return nullptr; }
|
||||
|
@ -768,6 +766,8 @@ class LocalAccessible : public nsISupports, public Accessible {
|
|||
|
||||
virtual nsAtom* TagName() const override;
|
||||
|
||||
virtual nsAtom* InputType() const override;
|
||||
|
||||
virtual already_AddRefed<nsAtom> DisplayStyle() const override;
|
||||
|
||||
virtual float Opacity() const override;
|
||||
|
|
|
@ -1429,6 +1429,18 @@ nsAtom* RemoteAccessibleBase<Derived>::TagName() const {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
template <class Derived>
|
||||
nsAtom* RemoteAccessibleBase<Derived>::InputType() const {
|
||||
if (mCachedFields) {
|
||||
if (auto inputType = mCachedFields->GetAttribute<RefPtr<nsAtom>>(
|
||||
nsGkAtoms::textInputType)) {
|
||||
return *inputType;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <class Derived>
|
||||
already_AddRefed<nsAtom> RemoteAccessibleBase<Derived>::DisplayStyle() const {
|
||||
if (mCachedFields) {
|
||||
|
|
|
@ -202,6 +202,8 @@ class RemoteAccessibleBase : public Accessible, public HyperTextAccessibleBase {
|
|||
|
||||
virtual nsAtom* TagName() const override;
|
||||
|
||||
virtual nsAtom* InputType() const override;
|
||||
|
||||
virtual already_AddRefed<nsAtom> DisplayStyle() const override;
|
||||
|
||||
virtual float Opacity() const override;
|
||||
|
|
|
@ -50,8 +50,6 @@ virtual already_AddRefed<AccAttributes> Attributes() override;
|
|||
|
||||
virtual Relation RelationByType(RelationType aType) const override;
|
||||
|
||||
bool IsSearchbox() const;
|
||||
|
||||
virtual mozilla::a11y::GroupPos GroupPosition() override;
|
||||
void ScrollToPoint(uint32_t aScrollType, int32_t aX, int32_t aY);
|
||||
|
||||
|
|
|
@ -118,6 +118,10 @@ void RemoteAccessible::Relations(
|
|||
}
|
||||
|
||||
bool RemoteAccessible::IsSearchbox() const {
|
||||
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
|
||||
return RemoteAccessibleBase<RemoteAccessible>::IsSearchbox();
|
||||
}
|
||||
|
||||
bool retVal = false;
|
||||
Unused << mDoc->SendIsSearchbox(mID, &retVal);
|
||||
return retVal;
|
||||
|
|
|
@ -75,6 +75,8 @@ class RemoteAccessible : public RemoteAccessibleBase<RemoteAccessible> {
|
|||
|
||||
virtual nsAtom* LandmarkRole() const override;
|
||||
|
||||
virtual bool IsSearchbox() const override;
|
||||
|
||||
virtual int32_t SelectionCount() override;
|
||||
|
||||
using RemoteAccessibleBase<RemoteAccessible>::SelectionBoundsAt;
|
||||
|
|
|
@ -125,12 +125,8 @@ inline NSString* ToNSString(id aValue) {
|
|||
return NSAccessibilitySecureTextFieldSubrole;
|
||||
}
|
||||
|
||||
if (mRole == roles::ENTRY) {
|
||||
LocalAccessible* acc = mGeckoAccessible->AsLocal();
|
||||
RemoteAccessible* proxy = mGeckoAccessible->AsRemote();
|
||||
if ((acc && acc->IsSearchbox()) || (proxy && proxy->IsSearchbox())) {
|
||||
return @"AXSearchField";
|
||||
}
|
||||
if (mRole == roles::ENTRY && mGeckoAccessible->IsSearchbox()) {
|
||||
return @"AXSearchField";
|
||||
}
|
||||
|
||||
return nil;
|
||||
|
|
Загрузка…
Ссылка в новой задаче