зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1234121 - Remove sync calls for FocusedChild (Part 1) r=tbsaunde
This commit is contained in:
Родитель
ae7d2914fe
Коммит
4c94b38c77
|
@ -27,46 +27,6 @@ FocusManager::~FocusManager()
|
|||
{
|
||||
}
|
||||
|
||||
Accessible*
|
||||
FocusManager::FocusedAccessible() const
|
||||
{
|
||||
if (mActiveItem)
|
||||
return mActiveItem;
|
||||
|
||||
nsINode* focusedNode = FocusedDOMNode();
|
||||
if (focusedNode) {
|
||||
DocAccessible* doc =
|
||||
GetAccService()->GetDocAccessible(focusedNode->OwnerDoc());
|
||||
return doc ? doc->GetAccessibleEvenIfNotInMapOrContainer(focusedNode) : nullptr;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
FocusManager::IsFocused(const Accessible* aAccessible) const
|
||||
{
|
||||
if (mActiveItem)
|
||||
return mActiveItem == aAccessible;
|
||||
|
||||
nsINode* focusedNode = FocusedDOMNode();
|
||||
if (focusedNode) {
|
||||
// XXX: Before getting an accessible for node having a DOM focus make sure
|
||||
// they belong to the same document because it can trigger unwanted document
|
||||
// accessible creation for temporary about:blank document. Without this
|
||||
// peculiarity we would end up with plain implementation based on
|
||||
// FocusedAccessible() method call. Make sure this issue is fixed in
|
||||
// bug 638465.
|
||||
if (focusedNode->OwnerDoc() == aAccessible->GetNode()->OwnerDoc()) {
|
||||
DocAccessible* doc =
|
||||
GetAccService()->GetDocAccessible(focusedNode->OwnerDoc());
|
||||
return aAccessible ==
|
||||
(doc ? doc->GetAccessibleEvenIfNotInMapOrContainer(focusedNode) : nullptr);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
FocusManager::IsFocusWithin(const Accessible* aContainer) const
|
||||
{
|
||||
|
@ -193,9 +153,23 @@ FocusManager::ActiveItemChanged(Accessible* aItem, bool aCheckIfActive)
|
|||
// If active item is changed then fire accessible focus event on it, otherwise
|
||||
// if there's no an active item then fire focus event to accessible having
|
||||
// DOM focus.
|
||||
Accessible* target = FocusedAccessible();
|
||||
if (target)
|
||||
Accessible* target = nullptr;
|
||||
if (aItem) {
|
||||
target = aItem;
|
||||
} else {
|
||||
nsINode* focusedNode = FocusedDOMNode();
|
||||
if (focusedNode) {
|
||||
DocAccessible* doc =
|
||||
GetAccService()->GetDocAccessible(focusedNode->OwnerDoc());
|
||||
if (doc) {
|
||||
target = doc->GetAccessibleEvenIfNotInMapOrContainer(focusedNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (target) {
|
||||
DispatchFocusEvent(target->Document(), target);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -296,6 +270,9 @@ FocusManager::ProcessFocusEvent(AccEvent* aEvent)
|
|||
}
|
||||
}
|
||||
|
||||
mFocusedAcc = target;
|
||||
mFocusedProxy = nullptr;
|
||||
|
||||
// Fire menu start/end events for ARIA menus.
|
||||
if (target->IsARIARole(nsGkAtoms::menuitem)) {
|
||||
// The focus was moved into menu.
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace a11y {
|
|||
|
||||
class AccEvent;
|
||||
class Accessible;
|
||||
class ProxyAccessible;
|
||||
class DocAccessible;
|
||||
|
||||
/**
|
||||
|
@ -29,13 +30,18 @@ public:
|
|||
/**
|
||||
* Return a focused accessible.
|
||||
*/
|
||||
Accessible* FocusedAccessible() const;
|
||||
Accessible* FocusedAccessible() const { return mFocusedAcc; }
|
||||
|
||||
/**
|
||||
* Return remote focused accessible.
|
||||
*/
|
||||
ProxyAccessible* FocusedRemoteAccessible() const { return mFocusedProxy; }
|
||||
|
||||
/**
|
||||
* Return true if given accessible is focused.
|
||||
*/
|
||||
bool IsFocused(const Accessible* aAccessible) const;
|
||||
|
||||
bool IsFocused(const Accessible* aAccessible) const
|
||||
{ return aAccessible == mFocusedAcc; }
|
||||
/**
|
||||
* Return true if the given accessible is an active item, i.e. an item that
|
||||
* is current within the active widget.
|
||||
|
@ -85,6 +91,11 @@ public:
|
|||
*/
|
||||
void ActiveItemChanged(Accessible* aItem, bool aCheckIfActive = true);
|
||||
|
||||
/**
|
||||
* Called when focused item in child process is changed.
|
||||
*/
|
||||
void RemoteFocusChanged(ProxyAccessible* aProxy) { mFocusedProxy = aProxy; }
|
||||
|
||||
/**
|
||||
* Dispatch delayed focus event for the current focus accessible.
|
||||
*/
|
||||
|
@ -124,6 +135,8 @@ private:
|
|||
nsIDocument* FocusedDOMDocument() const;
|
||||
|
||||
private:
|
||||
RefPtr<Accessible> mFocusedAcc;
|
||||
ProxyAccessible* mFocusedProxy;
|
||||
RefPtr<Accessible> mActiveItem;
|
||||
RefPtr<Accessible> mActiveARIAMenubar;
|
||||
};
|
||||
|
|
|
@ -1888,24 +1888,6 @@ DocAccessibleChild::RecvEmbeddedChildAt(const uint64_t& aID,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
DocAccessibleChild::RecvFocusedChild(const uint64_t& aID,
|
||||
uint64_t* aChild,
|
||||
bool* aOk)
|
||||
{
|
||||
*aChild = 0;
|
||||
*aOk = false;
|
||||
Accessible* acc = IdToAccessible(aID);
|
||||
if (acc) {
|
||||
Accessible* child = acc->FocusedChild();
|
||||
if (child) {
|
||||
*aChild = reinterpret_cast<uint64_t>(child->UniqueID());
|
||||
*aOk = true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
DocAccessibleChild::RecvLanguage(const uint64_t& aID,
|
||||
nsString* aLocale)
|
||||
|
|
|
@ -464,10 +464,6 @@ public:
|
|||
virtual bool RecvEmbeddedChildAt(const uint64_t& aID, const uint32_t& aIdx,
|
||||
uint64_t* aChildID) override final;
|
||||
|
||||
virtual bool RecvFocusedChild(const uint64_t& aID,
|
||||
uint64_t* aChild,
|
||||
bool* aOk) override;
|
||||
|
||||
virtual bool RecvLanguage(const uint64_t& aID, nsString* aLocale) override;
|
||||
virtual bool RecvDocType(const uint64_t& aID, nsString* aType) override;
|
||||
virtual bool RecvTitle(const uint64_t& aID, nsString* aTitle) override;
|
||||
|
|
|
@ -147,6 +147,14 @@ DocAccessibleParent::RecvEvent(const uint64_t& aID, const uint32_t& aEventType)
|
|||
return true;
|
||||
}
|
||||
|
||||
switch(aEventType) {
|
||||
case nsIAccessibleEvent::EVENT_FOCUS:
|
||||
FocusMgr()->RemoteFocusChanged(proxy);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
ProxyEvent(proxy, aEventType);
|
||||
|
||||
if (!nsCoreUtils::AccEventObserversExist()) {
|
||||
|
|
|
@ -242,8 +242,6 @@ child:
|
|||
returns(uint32_t childIdx);
|
||||
prio(high) sync EmbeddedChildAt(uint64_t aID, uint32_t aChildIdx)
|
||||
returns(uint64_t aChild);
|
||||
prio(high) sync FocusedChild(uint64_t aID)
|
||||
returns(uint64_t aChild, bool aOk);
|
||||
|
||||
prio(high) sync Language(uint64_t aID) returns(nsString aLocale);
|
||||
prio(high) sync DocType(uint64_t aID) returns(nsString aType);
|
||||
|
|
|
@ -1068,10 +1068,16 @@ ProxyAccessible::EmbeddedChildAt(size_t aChildIdx)
|
|||
ProxyAccessible*
|
||||
ProxyAccessible::FocusedChild()
|
||||
{
|
||||
uint64_t childID = 0;
|
||||
bool ok = false;
|
||||
Unused << mDoc->SendFocusedChild(mID, &childID, &ok);
|
||||
return ok ? mDoc->GetAccessible(childID) : nullptr;
|
||||
ProxyAccessible* focus = FocusMgr()->FocusedRemoteAccessible();
|
||||
if (IsDoc()) {
|
||||
return focus;
|
||||
}
|
||||
|
||||
if (focus && (focus == this || focus->Parent() == this)) {
|
||||
return focus;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ProxyAccessible*
|
||||
|
|
Загрузка…
Ссылка в новой задаче