Skip to content

Commit

Permalink
bug 1074917 - teach atk to get states from proxies r=surkov, davidb, …
Browse files Browse the repository at this point in the history
…mrbkap

We need to implement things like
https://developer.gnome.org/atk/unstable/AtkObject.html#atk-object-ref-state-set
and the same basic thing on windows.  That API is fundamentally sync,
but the information necessary to implement it is only available in the
child process.  That seems to leave us with two options, either we can
use sync ipc or we can use async ipc but spin a nested event loop.  If
we were to spin nested event loops we'd have to be careful to make sure
a11y didn't do anything until the nested event loop was done, and then
a11y would have to deal with whatever changed.  I'm not sure that will
work, and since the system is probably waiting for the accessibility
information anyway I don't think we get much out of spinning the event
loop.  So I think its somewhat less bad to use sync ipc here.
  • Loading branch information
Trevor Saunders committed Sep 23, 2014
1 parent fe3266d commit ae9ecfb
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 11 deletions.
19 changes: 9 additions & 10 deletions accessible/atk/AccessibleWrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -892,19 +892,18 @@ TranslateStates(uint64_t aState, AtkStateSet* aStateSet)
AtkStateSet *
refStateSetCB(AtkObject *aAtkObj)
{
AtkStateSet *state_set = nullptr;
state_set = ATK_OBJECT_CLASS(parent_class)->ref_state_set(aAtkObj);
AtkStateSet *state_set = nullptr;
state_set = ATK_OBJECT_CLASS(parent_class)->ref_state_set(aAtkObj);

AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj);
if (!accWrap) {
TranslateStates(states::DEFUNCT, state_set);
return state_set;
}

// Map states
AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj);
if (accWrap)
TranslateStates(accWrap->State(), state_set);
else if (ProxyAccessible* proxy = GetProxy(aAtkObj))
TranslateStates(proxy->State(), state_set);
else
TranslateStates(states::DEFUNCT, state_set);

return state_set;
return state_set;
}

static void
Expand Down
14 changes: 14 additions & 0 deletions accessible/ipc/DocAccessibleChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,19 @@ DocAccessibleChild::ShowEvent(AccShowEvent* aShowEvent)
SerializeTree(aShowEvent->GetAccessible(), data.NewTree());
SendShowEvent(data);
}

bool
DocAccessibleChild::RecvState(const uint64_t& aID, uint64_t* aState)
{
Accessible* acc = mDoc->GetAccessibleByUniqueID((void*)aID);
if (!acc) {
*aState = states::DEFUNCT;
return true;
}

*aState = acc->State();

return true;
}
}
}
5 changes: 5 additions & 0 deletions accessible/ipc/DocAccessibleChild.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ class DocAccessibleChild : public PDocAccessibleChild

void ShowEvent(AccShowEvent* aShowEvent);

/*
* Return the state for the accessible with given ID.
*/
virtual bool RecvState(const uint64_t& aID, uint64_t* aState) MOZ_OVERRIDE;

private:
DocAccessible* mDoc;
};
Expand Down
5 changes: 4 additions & 1 deletion accessible/ipc/PDocAccessible.ipdl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct ShowEventData
AccessibleData[] NewTree;
};

protocol PDocAccessible
prio(normal upto high) sync protocol PDocAccessible
{
manager PContent;

Expand All @@ -38,6 +38,9 @@ parent:
Event(uint32_t type);
ShowEvent(ShowEventData data);
HideEvent(uint64_t aRootID);

child:
prio(high) sync State(uint64_t aID) returns(uint64_t states);
};

}
Expand Down
9 changes: 9 additions & 0 deletions accessible/ipc/ProxyAccessible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "ProxyAccessible.h"
#include "DocAccessibleParent.h"
#include "mozilla/unused.h"
#include "mozilla/a11y/Platform.h"

namespace mozilla {
Expand Down Expand Up @@ -38,5 +39,13 @@ ProxyAccessible::SetChildDoc(DocAccessibleParent* aParent)
mOuterDoc = false;
}
}

uint64_t
ProxyAccessible::State() const
{
uint64_t state = 0;
unused << mDoc->SendState(mID, &state);
return state;
}
}
}
5 changes: 5 additions & 0 deletions accessible/ipc/ProxyAccessible.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ class ProxyAccessible
*/
role Role() const { return mRole; }

/*
* Return the states for the proxied accessible.
*/
uint64_t State() const;

/**
* Allow the platform to store a pointers worth of data on us.
*/
Expand Down

0 comments on commit ae9ecfb

Please sign in to comment.