Skip to content

Commit

Permalink
Bug 1765651 - Put DOMNodeID in Accessible. r=morgan
Browse files Browse the repository at this point in the history
  • Loading branch information
eeejay committed Apr 22, 2022
1 parent 24097d7 commit 395df0c
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 18 deletions.
7 changes: 1 addition & 6 deletions accessible/android/AccessibleWrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,12 +645,7 @@ int32_t AccessibleWrap::GetInputType(const nsString& aInputTypeAttr) {
}

void AccessibleWrap::WrapperDOMNodeID(nsString& aDOMNodeID) {
if (mContent) {
nsAtom* id = mContent->GetID();
if (id) {
id->ToString(aDOMNodeID);
}
}
DOMNodeID(aDOMNodeID);
}

bool AccessibleWrap::WrapperRangeInfo(double* aCurVal, double* aMinVal,
Expand Down
5 changes: 5 additions & 0 deletions accessible/basetypes/Accessible.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@ class Accessible {
*/
virtual nsAtom* LandmarkRole() const;

/**
* Return the id of the dom node this accessible represents.
*/
virtual void DOMNodeID(nsString& aID) const = 0;

//////////////////////////////////////////////////////////////////////////////
// ActionAccessible

Expand Down
9 changes: 9 additions & 0 deletions accessible/generic/LocalAccessible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3516,6 +3516,15 @@ Maybe<float> LocalAccessible::Opacity() const {
return Nothing();
}

void LocalAccessible::DOMNodeID(nsString& aID) const {
aID.Truncate();
if (mContent) {
if (nsAtom* id = mContent->GetID()) {
id->ToString(aID);
}
}
}

void LocalAccessible::StaticAsserts() const {
static_assert(
eLastStateFlag <= (1 << kStateFlagsBits) - 1,
Expand Down
2 changes: 2 additions & 0 deletions accessible/generic/LocalAccessible.h
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,8 @@ class LocalAccessible : public nsISupports, public Accessible {

virtual Maybe<float> Opacity() const override;

virtual void DOMNodeID(nsString& aID) const override;

protected:
virtual ~LocalAccessible();

Expand Down
6 changes: 1 addition & 5 deletions accessible/ipc/RemoteAccessibleBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,7 @@ class RemoteAccessibleBase : public Accessible, public HyperTextAccessibleBase {
virtual TableAccessibleBase* AsTableBase() override;
virtual TableCellAccessibleBase* AsTableCellBase() override;

/**
* Return the id of the dom node this accessible represents. Note this
* should probably only be used for testing.
*/
virtual void DOMNodeID(nsString& aID) const;
virtual void DOMNodeID(nsString& aID) const override;

// HyperTextAccessibleBase
virtual already_AddRefed<AccAttributes> DefaultTextAttributes() override;
Expand Down
8 changes: 1 addition & 7 deletions accessible/mac/mozAccessible.mm
Original file line number Diff line number Diff line change
Expand Up @@ -741,13 +741,7 @@ - (NSString*)moxDOMIdentifier {
MOZ_ASSERT(mGeckoAccessible);

nsAutoString id;
if (LocalAccessible* acc = mGeckoAccessible->AsLocal()) {
if (acc->GetContent()) {
nsCoreUtils::GetID(acc->GetContent(), id);
}
} else {
mGeckoAccessible->AsRemote()->DOMNodeID(id);
}
mGeckoAccessible->DOMNodeID(id);

return nsCocoaUtils::ToNSString(id);
}
Expand Down

0 comments on commit 395df0c

Please sign in to comment.