mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 986054 - Fire name change event on XUL richlistitem when children change, r=surkov.
This commit is contained in:
parent
22919c6d0e
commit
f361cd150f
@ -55,6 +55,7 @@ enum AccType {
|
||||
eProgressType,
|
||||
eRootType,
|
||||
eXULLabelType,
|
||||
eXULListItemType,
|
||||
eXULTabpanelsType,
|
||||
eXULTreeType,
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "nsEventShell.h"
|
||||
#include "DocAccessible.h"
|
||||
#include "nsAccessibilityService.h"
|
||||
#include "nsTextEquivUtils.h"
|
||||
#ifdef A11Y_LOG
|
||||
#include "Logging.h"
|
||||
#endif
|
||||
@ -37,6 +38,38 @@ EventQueue::PushEvent(AccEvent* aEvent)
|
||||
// Filter events.
|
||||
CoalesceEvents();
|
||||
|
||||
// Fire name change event on parent given that this event hasn't been
|
||||
// coalesced, the parent's name was calculated from its subtree, and the
|
||||
// subtree was changed.
|
||||
Accessible* target = aEvent->mAccessible;
|
||||
if (aEvent->mEventRule != AccEvent::eDoNotEmit &&
|
||||
target->HasNameDependentParent() &&
|
||||
(aEvent->mEventType == nsIAccessibleEvent::EVENT_NAME_CHANGE ||
|
||||
aEvent->mEventType == nsIAccessibleEvent::EVENT_TEXT_REMOVED ||
|
||||
aEvent->mEventType == nsIAccessibleEvent::EVENT_TEXT_INSERTED ||
|
||||
aEvent->mEventType == nsIAccessibleEvent::EVENT_SHOW ||
|
||||
aEvent->mEventType == nsIAccessibleEvent::EVENT_HIDE)) {
|
||||
// Only continue traversing up the tree if it's possible that the parent
|
||||
// accessible's name can depend on this accessible's name.
|
||||
Accessible* parent = target->Parent();
|
||||
while (parent &&
|
||||
nsTextEquivUtils::HasNameRule(parent, eNameFromSubtreeIfReqRule)) {
|
||||
// Test possible name dependent parent.
|
||||
if (nsTextEquivUtils::HasNameRule(parent, eNameFromSubtreeRule)) {
|
||||
nsAutoString name;
|
||||
ENameValueFlag nameFlag = parent->Name(name);
|
||||
// If name is obtained from subtree, fire name change event.
|
||||
if (nameFlag == eNameFromSubtree) {
|
||||
nsRefPtr<AccEvent> nameChangeEvent =
|
||||
new AccEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE, parent);
|
||||
PushEvent(nameChangeEvent);
|
||||
}
|
||||
break;
|
||||
}
|
||||
parent = parent->Parent();
|
||||
}
|
||||
}
|
||||
|
||||
// Associate text change with hide event if it wasn't stolen from hiding
|
||||
// siblings during coalescence.
|
||||
AccMutationEvent* showOrHideEvent = downcast_accEvent(aEvent);
|
||||
|
@ -344,7 +344,7 @@ nsTextEquivUtils::AppendString(nsAString *aString,
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
uint32_t
|
||||
nsTextEquivUtils::GetRoleRule(role aRole)
|
||||
{
|
||||
#define ROLE(geckoRole, stringRole, atkRole, \
|
||||
@ -360,4 +360,3 @@ nsTextEquivUtils::GetRoleRule(role aRole)
|
||||
|
||||
#undef ROLE
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,18 @@ class nsTextEquivUtils
|
||||
public:
|
||||
typedef mozilla::a11y::Accessible Accessible;
|
||||
|
||||
/**
|
||||
* Determines if the accessible has a given name rule.
|
||||
*
|
||||
* @param aAccessible [in] the given accessible
|
||||
* @param aRule [in] a given name rule
|
||||
* @return true if the accessible has the rule
|
||||
*/
|
||||
static inline bool HasNameRule(Accessible* aAccessible, ETextEquivRule aRule)
|
||||
{
|
||||
return (GetRoleRule(aAccessible->Role()) & aRule) == aRule;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the name from accessible subtree if allowed.
|
||||
*
|
||||
|
@ -111,8 +111,8 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_DESTROY(Accessible, LastRelease())
|
||||
Accessible::Accessible(nsIContent* aContent, DocAccessible* aDoc) :
|
||||
mContent(aContent), mDoc(aDoc),
|
||||
mParent(nullptr), mIndexInParent(-1), mChildrenFlags(eChildrenUninitialized),
|
||||
mStateFlags(0), mType(0), mGenericTypes(0), mIndexOfEmbeddedChild(-1),
|
||||
mRoleMapEntry(nullptr)
|
||||
mStateFlags(0), mContextFlags(0), mType(0), mGenericTypes(0),
|
||||
mIndexOfEmbeddedChild(-1), mRoleMapEntry(nullptr)
|
||||
{
|
||||
#ifdef NS_DEBUG_X
|
||||
{
|
||||
@ -2533,6 +2533,12 @@ Accessible::BindToParent(Accessible* aParent, uint32_t aIndexInParent)
|
||||
mIndexInParent = aIndexInParent;
|
||||
|
||||
mParent->InvalidateChildrenGroupInfo();
|
||||
|
||||
// Note: this is currently only used for richlistitems and their children.
|
||||
if (mParent->HasNameDependentParent() || mParent->IsXULListItem())
|
||||
mContextFlags |= eHasNameDependentParent;
|
||||
else
|
||||
mContextFlags &= ~eHasNameDependentParent;
|
||||
}
|
||||
|
||||
// Accessible protected
|
||||
@ -2544,6 +2550,7 @@ Accessible::UnbindFromParent()
|
||||
mIndexInParent = -1;
|
||||
mIndexOfEmbeddedChild = -1;
|
||||
mGroupInfo = nullptr;
|
||||
mContextFlags &= ~eHasNameDependentParent;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -3241,6 +3248,8 @@ Accessible::StaticAsserts() const
|
||||
"Accessible::mStateFlags was oversized by eLastStateFlag!");
|
||||
static_assert(eLastAccType <= (1 << kTypeBits) - 1,
|
||||
"Accessible::mType was oversized by eLastAccType!");
|
||||
static_assert(eLastContextFlag <= (1 << kContextFlagsBits) - 1,
|
||||
"Accessible::mContextFlags was oversized by eLastContextFlag!");
|
||||
static_assert(eLastAccGenericType <= (1 << kGenericTypesBits) - 1,
|
||||
"Accessible::mGenericType was oversized by eLastAccGenericType!");
|
||||
}
|
||||
|
@ -579,6 +579,8 @@ public:
|
||||
bool IsXULLabel() const { return mType == eXULLabelType; }
|
||||
XULLabelAccessible* AsXULLabel();
|
||||
|
||||
bool IsXULListItem() const { return mType == eXULListItemType; }
|
||||
|
||||
bool IsXULTabpanels() const { return mType == eXULTabpanelsType; }
|
||||
|
||||
bool IsXULTree() const { return mType == eXULTreeType; }
|
||||
@ -790,6 +792,13 @@ public:
|
||||
bool NeedsDOMUIEvent() const
|
||||
{ return !(mStateFlags & eIgnoreDOMUIEvent); }
|
||||
|
||||
/**
|
||||
* Return true if this accessible has a parent whose name depends on this
|
||||
* accessible.
|
||||
*/
|
||||
bool HasNameDependentParent() const
|
||||
{ return mContextFlags & eHasNameDependentParent; }
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
@ -867,6 +876,15 @@ protected:
|
||||
eLastStateFlag = eGroupInfoDirty
|
||||
};
|
||||
|
||||
/**
|
||||
* Flags used for contextual information about the accessible.
|
||||
*/
|
||||
enum ContextFlags {
|
||||
eHasNameDependentParent = 1 << 0, // Parent's name depends on this accessible.
|
||||
|
||||
eLastContextFlag = eHasNameDependentParent
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@ -970,14 +988,16 @@ protected:
|
||||
|
||||
static const uint8_t kChildrenFlagsBits = 2;
|
||||
static const uint8_t kStateFlagsBits = 6;
|
||||
static const uint8_t kContextFlagsBits = 1;
|
||||
static const uint8_t kTypeBits = 6;
|
||||
static const uint8_t kGenericTypesBits = 12;
|
||||
|
||||
/**
|
||||
* Keep in sync with ChildrenFlags, StateFlags and AccTypes.
|
||||
* Keep in sync with ChildrenFlags, StateFlags, ContextFlags, and AccTypes.
|
||||
*/
|
||||
uint32_t mChildrenFlags : kChildrenFlagsBits;
|
||||
uint32_t mStateFlags : kStateFlagsBits;
|
||||
uint32_t mContextFlags : kContextFlagsBits;
|
||||
uint32_t mType : kTypeBits;
|
||||
uint32_t mGenericTypes : kGenericTypesBits;
|
||||
|
||||
|
@ -582,6 +582,7 @@ XULListitemAccessible::
|
||||
nsGkAtoms::type,
|
||||
nsGkAtoms::checkbox,
|
||||
eCaseMatters);
|
||||
mType = eXULListItemType;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED0(XULListitemAccessible, Accessible)
|
||||
|
@ -41,6 +41,7 @@ skip-if = os == 'win' || os == 'linux'
|
||||
[test_menu.xul]
|
||||
[test_mutation.html]
|
||||
[test_mutation.xhtml]
|
||||
[test_name.xul]
|
||||
[test_scroll.xul]
|
||||
[test_selection.html]
|
||||
[test_selection.xul]
|
||||
|
92
accessible/tests/mochitest/events/test_name.xul
Normal file
92
accessible/tests/mochitest/events/test_name.xul
Normal file
@ -0,0 +1,92 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
|
||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
||||
type="text/css"?>
|
||||
|
||||
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/chrome-harness.js"/>
|
||||
|
||||
<script type="application/javascript"
|
||||
src="../common.js" />
|
||||
<script type="application/javascript"
|
||||
src="../events.js" />
|
||||
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
|
||||
/**
|
||||
* Check name changed a11y event.
|
||||
*/
|
||||
function nameChangeChecker(aMsg, aID)
|
||||
{
|
||||
this.type = EVENT_NAME_CHANGE;
|
||||
|
||||
function targetGetter()
|
||||
{
|
||||
return getAccessible(aID);
|
||||
}
|
||||
Object.defineProperty(this, "target", { get: targetGetter });
|
||||
|
||||
this.getID = function getID()
|
||||
{
|
||||
return aMsg + " name changed";
|
||||
}
|
||||
}
|
||||
|
||||
function changeRichListItemChild()
|
||||
{
|
||||
this.invoke = function changeRichListItemChild_invoke()
|
||||
{
|
||||
getNode('childcontent').setAttribute('value', 'Changed.');
|
||||
}
|
||||
|
||||
this.eventSeq =
|
||||
[
|
||||
new nameChangeChecker("changeRichListItemChild: ", "listitem")
|
||||
];
|
||||
|
||||
this.getID = function changeRichListItemChild_getID()
|
||||
{
|
||||
return "changeRichListItemChild";
|
||||
}
|
||||
}
|
||||
|
||||
function doTest()
|
||||
{
|
||||
var queue = new eventQueue();
|
||||
queue.push(new changeRichListItemChild());
|
||||
queue.invoke();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addA11yLoadEvent(doTest);
|
||||
]]>
|
||||
</script>
|
||||
|
||||
<vbox flex="1" style="overflow: auto;">
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=986054"
|
||||
title="Propagate name change events">
|
||||
Mozilla Bug 986054
|
||||
</a>
|
||||
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
|
||||
<richlistbox>
|
||||
<richlistitem id="listitem">
|
||||
<description id="childcontent" value="This will be changed."/>
|
||||
</richlistitem>
|
||||
</richlistbox>
|
||||
</vbox>
|
||||
</window>
|
Loading…
Reference in New Issue
Block a user