mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1834006 part 1: Remove several unnecessary differentiations between local and remote Accessibles in platform specific code. r=morgan
Differential Revision: https://phabricator.services.mozilla.com/D178609
This commit is contained in:
parent
63148715c6
commit
bfb493f67d
@ -708,38 +708,20 @@ AtkObject* refChildCB(AtkObject* aAtkObj, gint aChildIndex) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AtkObject* childAtkObj = nullptr;
|
||||
AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj);
|
||||
if (accWrap) {
|
||||
if (nsAccUtils::MustPrune(accWrap)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
LocalAccessible* accChild = accWrap->EmbeddedChildAt(aChildIndex);
|
||||
if (accChild) {
|
||||
childAtkObj = AccessibleWrap::GetAtkObject(accChild);
|
||||
} else {
|
||||
OuterDocAccessible* docOwner = accWrap->AsOuterDoc();
|
||||
if (docOwner) {
|
||||
RemoteAccessible* proxyDoc = docOwner->RemoteChildDoc();
|
||||
if (proxyDoc) childAtkObj = GetWrapperFor(proxyDoc);
|
||||
}
|
||||
}
|
||||
} else if (RemoteAccessible* proxy = GetProxy(aAtkObj)) {
|
||||
if (nsAccUtils::MustPrune(proxy)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Accessible* child = proxy->EmbeddedChildAt(aChildIndex);
|
||||
if (child) {
|
||||
childAtkObj = GetWrapperFor(child->AsRemote());
|
||||
}
|
||||
} else {
|
||||
Accessible* acc = GetInternalObj(aAtkObj);
|
||||
if (!acc || nsAccUtils::MustPrune(acc)) {
|
||||
return nullptr;
|
||||
}
|
||||
Accessible* accChild = acc->EmbeddedChildAt(aChildIndex);
|
||||
if (!accChild) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AtkObject* childAtkObj = GetWrapperFor(accChild);
|
||||
NS_ASSERTION(childAtkObj, "Fail to get AtkObj");
|
||||
if (!childAtkObj) return nullptr;
|
||||
if (!childAtkObj) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
g_object_ref(childAtkObj);
|
||||
|
||||
@ -797,11 +779,8 @@ AtkStateSet* refStateSetCB(AtkObject* aAtkObj) {
|
||||
AtkStateSet* state_set = nullptr;
|
||||
state_set = ATK_OBJECT_CLASS(parent_class)->ref_state_set(aAtkObj);
|
||||
|
||||
AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj);
|
||||
if (accWrap) {
|
||||
TranslateStates(accWrap->State(), accWrap->Role(), state_set);
|
||||
} else if (RemoteAccessible* proxy = GetProxy(aAtkObj)) {
|
||||
TranslateStates(proxy->State(), proxy->Role(), state_set);
|
||||
if (Accessible* acc = GetInternalObj(aAtkObj)) {
|
||||
TranslateStates(acc->State(), acc->Role(), state_set);
|
||||
} else {
|
||||
TranslateStates(states::DEFUNCT, roles::NOTHING, state_set);
|
||||
}
|
||||
|
@ -30,19 +30,6 @@ class MaiHyperlink {
|
||||
|
||||
public:
|
||||
AtkHyperlink* GetAtkHyperlink() const { return mMaiAtkHyperlink; }
|
||||
LocalAccessible* GetAccHyperlink() {
|
||||
if (!mHyperlink || !mHyperlink->IsLocal()) return nullptr;
|
||||
|
||||
LocalAccessible* link = mHyperlink->AsLocal();
|
||||
|
||||
NS_ASSERTION(link->IsLink(), "Why isn't it a link!");
|
||||
return link;
|
||||
}
|
||||
|
||||
RemoteAccessible* Proxy() const {
|
||||
return mHyperlink ? mHyperlink->AsRemote() : nullptr;
|
||||
}
|
||||
|
||||
Accessible* Acc() {
|
||||
if (!mHyperlink) {
|
||||
return nullptr;
|
||||
|
@ -77,7 +77,7 @@ static gboolean scrollToPointCB(AtkComponent* aComponent, AtkCoordType coords,
|
||||
AtkObject* refAccessibleAtPointHelper(AtkObject* aAtkObj, gint aX, gint aY,
|
||||
AtkCoordType aCoordType) {
|
||||
Accessible* acc = GetInternalObj(aAtkObj);
|
||||
if (!acc || (acc->IsLocal() && acc->AsLocal()->IsDefunct())) {
|
||||
if (!acc) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ void getExtentsHelper(AtkObject* aAtkObj, gint* aX, gint* aY, gint* aWidth,
|
||||
*aX = *aY = *aWidth = *aHeight = -1;
|
||||
|
||||
Accessible* acc = GetInternalObj(aAtkObj);
|
||||
if (!acc || (acc->IsLocal() && acc->AsLocal()->IsDefunct())) {
|
||||
if (!acc) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -13,10 +13,12 @@ using namespace mozilla::a11y;
|
||||
|
||||
extern "C" {
|
||||
static AtkHyperlink* getHyperlinkCB(AtkHyperlinkImpl* aImpl) {
|
||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aImpl));
|
||||
if (!accWrap && !GetProxy(ATK_OBJECT(aImpl))) return nullptr;
|
||||
Accessible* acc = GetInternalObj(ATK_OBJECT(aImpl));
|
||||
if (!acc) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (accWrap) NS_ASSERTION(accWrap->IsLink(), "why isn't it a link!");
|
||||
NS_ASSERTION(acc->IsLink(), "why isn't it a link!");
|
||||
|
||||
return MAI_ATK_OBJECT(aImpl)->GetAtkHyperlink();
|
||||
}
|
||||
|
@ -487,20 +487,15 @@ static gboolean removeTextSelectionCB(AtkText* aText, gint aSelectionNum) {
|
||||
|
||||
static gboolean setTextSelectionCB(AtkText* aText, gint aSelectionNum,
|
||||
gint aStartOffset, gint aEndOffset) {
|
||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
||||
if (accWrap) {
|
||||
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||
if (!text || !text->IsTextRole()) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return text->SetSelectionBoundsAt(aSelectionNum, aStartOffset, aEndOffset);
|
||||
Accessible* acc = GetInternalObj(ATK_OBJECT(aText));
|
||||
if (!acc || !acc->IsTextRole()) {
|
||||
return FALSE;
|
||||
}
|
||||
if (RemoteAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
|
||||
return proxy->SetSelectionBoundsAt(aSelectionNum, aStartOffset, aEndOffset);
|
||||
HyperTextAccessibleBase* text = acc->AsHyperTextBase();
|
||||
if (!text) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return text->SetSelectionBoundsAt(aSelectionNum, aStartOffset, aEndOffset);
|
||||
}
|
||||
|
||||
static gboolean setCaretOffsetCB(AtkText* aText, gint aOffset) {
|
||||
|
@ -76,8 +76,6 @@ enum CheckedState {
|
||||
// allows for gecko accessible access outside of the class
|
||||
- (mozilla::a11y::Accessible*)geckoAccessible;
|
||||
|
||||
- (mozilla::a11y::Accessible*)geckoDocument;
|
||||
|
||||
// override
|
||||
- (void)dealloc;
|
||||
|
||||
|
@ -140,30 +140,11 @@ using namespace mozilla::a11y;
|
||||
return mGeckoAccessible;
|
||||
}
|
||||
|
||||
- (mozilla::a11y::Accessible*)geckoDocument {
|
||||
MOZ_ASSERT(mGeckoAccessible);
|
||||
|
||||
if (mGeckoAccessible->IsLocal()) {
|
||||
if (mGeckoAccessible->AsLocal()->IsDoc()) {
|
||||
return mGeckoAccessible;
|
||||
}
|
||||
return mGeckoAccessible->AsLocal()->Document();
|
||||
}
|
||||
|
||||
if (mGeckoAccessible->AsRemote()->IsDoc()) {
|
||||
return mGeckoAccessible;
|
||||
}
|
||||
|
||||
return mGeckoAccessible->AsRemote()->Document();
|
||||
}
|
||||
|
||||
#pragma mark - MOXAccessible protocol
|
||||
|
||||
- (BOOL)moxBlockSelector:(SEL)selector {
|
||||
if (selector == @selector(moxPerformPress)) {
|
||||
uint8_t actionCount = mGeckoAccessible->IsLocal()
|
||||
? mGeckoAccessible->AsLocal()->ActionCount()
|
||||
: mGeckoAccessible->AsRemote()->ActionCount();
|
||||
uint8_t actionCount = mGeckoAccessible->ActionCount();
|
||||
|
||||
// If we have no action, we don't support press, so return YES.
|
||||
return actionCount == 0;
|
||||
@ -206,13 +187,8 @@ using namespace mozilla::a11y;
|
||||
- (id<MOXTextMarkerSupport>)moxTextMarkerDelegate {
|
||||
MOZ_ASSERT(mGeckoAccessible);
|
||||
|
||||
if (mGeckoAccessible->IsLocal()) {
|
||||
return [MOXTextMarkerDelegate
|
||||
getOrCreateForDoc:mGeckoAccessible->AsLocal()->Document()];
|
||||
}
|
||||
|
||||
return [MOXTextMarkerDelegate
|
||||
getOrCreateForDoc:mGeckoAccessible->AsRemote()->Document()];
|
||||
getOrCreateForDoc:nsAccUtils::DocumentFor(mGeckoAccessible)];
|
||||
}
|
||||
|
||||
- (BOOL)moxIsLiveRegion {
|
||||
@ -342,14 +318,11 @@ using namespace mozilla::a11y;
|
||||
- (NSString*)moxSubrole {
|
||||
MOZ_ASSERT(mGeckoAccessible);
|
||||
|
||||
LocalAccessible* acc = mGeckoAccessible->AsLocal();
|
||||
RemoteAccessible* proxy = mGeckoAccessible->AsRemote();
|
||||
|
||||
// Deal with landmarks first
|
||||
// macOS groups the specific landmark types of DPub ARIA into two broad
|
||||
// categories with corresponding subroles: Navigation and region/container.
|
||||
if (mRole == roles::LANDMARK) {
|
||||
nsAtom* landmark = acc ? acc->LandmarkRole() : proxy->LandmarkRole();
|
||||
nsAtom* landmark = mGeckoAccessible->LandmarkRole();
|
||||
// HTML Elements treated as landmarks, and ARIA landmarks.
|
||||
if (landmark) {
|
||||
if (landmark == nsGkAtoms::banner) return @"AXLandmarkBanner";
|
||||
@ -618,9 +591,7 @@ struct RoleDescrComparator {
|
||||
- (NSValue*)moxFrame {
|
||||
MOZ_ASSERT(mGeckoAccessible);
|
||||
|
||||
LayoutDeviceIntRect rect = mGeckoAccessible->IsLocal()
|
||||
? mGeckoAccessible->AsLocal()->Bounds()
|
||||
: mGeckoAccessible->AsRemote()->Bounds();
|
||||
LayoutDeviceIntRect rect = mGeckoAccessible->Bounds();
|
||||
NSScreen* mainView = [[NSScreen screens] objectAtIndex:0];
|
||||
CGFloat scaleFactor = nsCocoaUtils::GetBackingScaleFactor(mainView);
|
||||
|
||||
@ -697,7 +668,7 @@ struct RoleDescrComparator {
|
||||
}
|
||||
|
||||
- (mozAccessible*)topWebArea {
|
||||
Accessible* doc = [self geckoDocument];
|
||||
Accessible* doc = nsAccUtils::DocumentFor(mGeckoAccessible);
|
||||
while (doc) {
|
||||
if (doc->IsLocal()) {
|
||||
DocAccessible* docAcc = doc->AsLocal()->AsDoc();
|
||||
@ -823,9 +794,7 @@ struct RoleDescrComparator {
|
||||
|
||||
// We don't need to convert this rect into mac coordinates because the
|
||||
// mouse event synthesizer expects layout (gecko) coordinates.
|
||||
LayoutDeviceIntRect bounds = mGeckoAccessible->IsLocal()
|
||||
? mGeckoAccessible->AsLocal()->Bounds()
|
||||
: mGeckoAccessible->AsRemote()->Bounds();
|
||||
LayoutDeviceIntRect bounds = mGeckoAccessible->Bounds();
|
||||
|
||||
LocalAccessible* rootAcc = mGeckoAccessible->IsLocal()
|
||||
? mGeckoAccessible->AsLocal()->RootAccessible()
|
||||
@ -846,11 +815,7 @@ struct RoleDescrComparator {
|
||||
- (void)moxPerformPress {
|
||||
MOZ_ASSERT(mGeckoAccessible);
|
||||
|
||||
if (mGeckoAccessible->IsLocal()) {
|
||||
mGeckoAccessible->AsLocal()->DoAction(0);
|
||||
} else {
|
||||
mGeckoAccessible->AsRemote()->DoAction(0);
|
||||
}
|
||||
mGeckoAccessible->DoAction(0);
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
Loading…
Reference in New Issue
Block a user