Bug 1249927 - devirtualize CanHavaAnonymousChildren, r=davdib

This commit is contained in:
Alexander Surkov 2016-02-22 12:32:03 -05:00
parent 27795d6f6e
commit 58922d0029
11 changed files with 26 additions and 59 deletions

View File

@ -27,8 +27,8 @@ TreeWalker::
{
NS_ASSERTION(aContent, "No node for the accessible tree walker!");
mChildFilter = mContext->CanHaveAnonChildren() ?
nsIContent::eAllChildren : nsIContent::eAllButXBL;
mChildFilter = mContext->NoXBLKids() ?
nsIContent::eAllButXBL : nsIContent::eAllChildren;
mChildFilter |= nsIContent::eSkipPlaceholderContent;
if (aContent)

View File

@ -302,12 +302,6 @@ Accessible::KeyboardShortcut() const
return KeyBinding();
}
bool
Accessible::CanHaveAnonChildren()
{
return true;
}
void
Accessible::TranslateString(const nsString& aKey, nsAString& aStringOut)
{

View File

@ -494,11 +494,6 @@ public:
*/
virtual nsresult HandleAccEvent(AccEvent* aAccEvent);
/**
* Return true if this accessible allows accessible children from anonymous subtree.
*/
virtual bool CanHaveAnonChildren();
/**
* Return true if the accessible is an acceptable child.
*/
@ -930,6 +925,12 @@ public:
mStateFlags &= ~eRelocated;
}
/**
* Return true if the accessible doesn't allow accessible children from XBL
* anonymous subtree.
*/
bool NoXBLKids() { return mStateFlags & eNoXBLKids; }
/**
* Return true if this accessible has a parent whose name depends on this
* accessible.
@ -1021,8 +1022,9 @@ protected:
eIgnoreDOMUIEvent = 1 << 7, // don't process DOM UI events for a11y events
eSurvivingInUpdate = 1 << 8, // parent drops children to recollect them
eRelocated = 1 << 9, // accessible was moved in tree
eNoXBLKids = 1 << 10, // accessible don't allows XBL children
eLastStateFlag = eRelocated
eLastStateFlag = eNoXBLKids
};
/**
@ -1137,7 +1139,7 @@ protected:
int32_t mIndexInParent;
static const uint8_t kChildrenFlagsBits = 2;
static const uint8_t kStateFlagsBits = 10;
static const uint8_t kStateFlagsBits = 11;
static const uint8_t kContextFlagsBits = 2;
static const uint8_t kTypeBits = 6;
static const uint8_t kGenericTypesBits = 14;

View File

@ -31,6 +31,15 @@ XULComboboxAccessible::
mGenericTypes |= eAutoComplete;
else
mGenericTypes |= eCombobox;
// Both the XUL <textbox type="autocomplete"> and <menulist editable="true">
// widgets use XULComboboxAccessible. We need to walk the anonymous children
// for these so that the entry field is a child. Otherwise no XBL children.
if (!mContent->NodeInfo()->Equals(nsGkAtoms::textbox, kNameSpaceID_XUL) &&
!mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::editable,
nsGkAtoms::_true, eIgnoreCase)) {
mStateFlags |= eNoXBLKids;
}
}
role
@ -96,23 +105,6 @@ XULComboboxAccessible::Value(nsString& aValue)
menuList->GetLabel(aValue);
}
bool
XULComboboxAccessible::CanHaveAnonChildren()
{
if (mContent->NodeInfo()->Equals(nsGkAtoms::textbox, kNameSpaceID_XUL) ||
mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::editable,
nsGkAtoms::_true, eIgnoreCase)) {
// Both the XUL <textbox type="autocomplete"> and <menulist editable="true"> widgets
// use XULComboboxAccessible. We need to walk the anonymous children for these
// so that the entry field is a child
return true;
}
// Argument of false indicates we don't walk anonymous children for
// menuitems
return false;
}
uint8_t
XULComboboxAccessible::ActionCount()
{

View File

@ -26,7 +26,6 @@ public:
virtual void Value(nsString& aValue) override;
virtual a11y::role NativeRole() override;
virtual uint64_t NativeState() override;
virtual bool CanHaveAnonChildren() override;
// ActionAccessible
virtual uint8_t ActionCount() override;

View File

@ -544,6 +544,10 @@ XULListitemAccessible::
nsGkAtoms::checkbox,
eCaseMatters);
mType = eXULListItemType;
// Walk XBL anonymous children for list items. Overrides the flag value from
// base XULMenuitemAccessible class.
mStateFlags &= ~eNoXBLKids;
}
XULListitemAccessible::~XULListitemAccessible()
@ -668,13 +672,6 @@ XULListitemAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
}
}
bool
XULListitemAccessible::CanHaveAnonChildren()
{
// That indicates we should walk anonymous children for listitems
return true;
}
////////////////////////////////////////////////////////////////////////////////
// XULListitemAccessible: Widgets

View File

@ -115,7 +115,6 @@ public:
virtual a11y::role NativeRole() override;
virtual uint64_t NativeState() override;
virtual uint64_t NativeInteractiveState() const override;
virtual bool CanHaveAnonChildren() override;
// Actions
virtual void ActionNameAt(uint8_t index, nsAString& aName) override;

View File

@ -41,6 +41,7 @@ XULMenuitemAccessible::
XULMenuitemAccessible(nsIContent* aContent, DocAccessible* aDoc) :
AccessibleWrap(aContent, aDoc)
{
mStateFlags |= eNoXBLKids;
}
uint64_t
@ -267,13 +268,6 @@ XULMenuitemAccessible::GetLevelInternal()
return nsAccUtils::GetLevelForXULContainerItem(mContent);
}
bool
XULMenuitemAccessible::CanHaveAnonChildren()
{
// That indicates we don't walk anonymous children for menuitems
return false;
}
bool
XULMenuitemAccessible::DoAction(uint8_t index)
{

View File

@ -30,8 +30,6 @@ public:
virtual uint64_t NativeInteractiveState() const override;
virtual int32_t GetLevelInternal() override;
virtual bool CanHaveAnonChildren() override;
// ActionAccessible
virtual uint8_t ActionCount() override;
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override;

View File

@ -23,7 +23,7 @@ XULSliderAccessible::
XULSliderAccessible(nsIContent* aContent, DocAccessible* aDoc) :
AccessibleWrap(aContent, aDoc)
{
mStateFlags |= eHasNumericValue;
mStateFlags |= eHasNumericValue | eNoXBLKids;
}
// Accessible
@ -127,13 +127,6 @@ XULSliderAccessible::SetCurValue(double aValue)
return SetSliderAttr(nsGkAtoms::curpos, aValue);
}
bool
XULSliderAccessible::CanHaveAnonChildren()
{
// Do not allow anonymous xul:slider be accessible.
return false;
}
// Utils
nsIContent*

View File

@ -26,7 +26,6 @@ public:
virtual a11y::role NativeRole() override;
virtual uint64_t NativeInteractiveState() const override;
virtual bool NativelyUnavailable() const override;
virtual bool CanHaveAnonChildren() override;
// Value
virtual double MaxValue() const override;