forked from mirrors/gecko-dev
Bug 1870783 part 2: Expose ispopup object attribute. r=eeejay
Differential Revision: https://phabricator.services.mozilla.com/D197038
This commit is contained in:
parent
1c409d8fcf
commit
4f57a512d7
5 changed files with 61 additions and 1 deletions
|
|
@ -194,6 +194,9 @@ class CacheKey {
|
|||
// as returned by LocalAccessible::ParentRelativeBounds.
|
||||
static constexpr nsStaticAtom* ParentRelativeBounds =
|
||||
nsGkAtoms::relativeBounds;
|
||||
// nsAtom, CacheUpdateType::Initial
|
||||
// The type of a popup (used for HTML popover).
|
||||
static constexpr nsStaticAtom* PopupType = nsGkAtoms::ispopup;
|
||||
// nsAtom, CacheDomain::Actions
|
||||
static constexpr nsStaticAtom* PrimaryAction = nsGkAtoms::action;
|
||||
// float, no domain
|
||||
|
|
|
|||
|
|
@ -1212,11 +1212,16 @@ already_AddRefed<AccAttributes> LocalAccessible::NativeAttributes() {
|
|||
// Expose tag.
|
||||
attributes->SetAttribute(nsGkAtoms::tag, mContent->NodeInfo()->NameAtom());
|
||||
|
||||
// Expose draggable object attribute.
|
||||
if (auto htmlElement = nsGenericHTMLElement::FromNode(mContent)) {
|
||||
// Expose draggable object attribute.
|
||||
if (htmlElement->Draggable()) {
|
||||
attributes->SetAttribute(nsGkAtoms::draggable, true);
|
||||
}
|
||||
nsString popover;
|
||||
htmlElement->GetPopover(popover);
|
||||
if (!popover.IsEmpty()) {
|
||||
attributes->SetAttribute(nsGkAtoms::ispopup, std::move(popover));
|
||||
}
|
||||
}
|
||||
|
||||
// Don't calculate CSS-based object attributes when:
|
||||
|
|
@ -3902,6 +3907,17 @@ already_AddRefed<AccAttributes> LocalAccessible::BundleFieldsForCache(
|
|||
fields->SetAttribute(CacheKey::ARIARole, std::move(role));
|
||||
}
|
||||
}
|
||||
|
||||
if (auto* htmlEl = nsGenericHTMLElement::FromNode(mContent)) {
|
||||
// Changing popover recreates the Accessible, so it's immutable in the
|
||||
// cache.
|
||||
nsAutoString popover;
|
||||
htmlEl->GetPopover(popover);
|
||||
if (!popover.IsEmpty()) {
|
||||
fields->SetAttribute(CacheKey::PopupType,
|
||||
RefPtr{NS_Atomize(popover)});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (frame) {
|
||||
|
|
|
|||
|
|
@ -1573,6 +1573,12 @@ already_AddRefed<AccAttributes> RemoteAccessible::Attributes() {
|
|||
attributes->Remove(nsGkAtoms::aria_placeholder);
|
||||
}
|
||||
}
|
||||
|
||||
nsString popupType;
|
||||
mCachedFields->GetAttribute(CacheKey::PopupType, popupType);
|
||||
if (!popupType.IsEmpty()) {
|
||||
attributes->SetAttribute(nsGkAtoms::ispopup, std::move(popupType));
|
||||
}
|
||||
}
|
||||
|
||||
nsAutoString name;
|
||||
|
|
|
|||
|
|
@ -727,3 +727,37 @@ addAccessibleTask(
|
|||
},
|
||||
{ chrome: true, topLevel: true }
|
||||
);
|
||||
|
||||
/**
|
||||
* Test the ispopup attribute.
|
||||
*/
|
||||
addAccessibleTask(
|
||||
`<div id="popover" popover>popover</div>`,
|
||||
async function testIspopup(browser, docAcc) {
|
||||
info("Showing popover");
|
||||
let shown = waitForEvent(EVENT_SHOW, "popover");
|
||||
await invokeContentTask(browser, [], () => {
|
||||
content.document.getElementById("popover").showPopover();
|
||||
});
|
||||
let popover = (await shown).accessible;
|
||||
testAttrs(popover, { ispopup: "auto" }, true);
|
||||
info("Setting popover to null");
|
||||
// Setting popover causes the Accessible to be recreated.
|
||||
shown = waitForEvent(EVENT_SHOW, "popover");
|
||||
await invokeContentTask(browser, [], () => {
|
||||
content.document.getElementById("popover").popover = null;
|
||||
});
|
||||
popover = (await shown).accessible;
|
||||
testAbsentAttrs(popover, { ispopup: "" });
|
||||
info("Setting popover to manual and showing");
|
||||
shown = waitForEvent(EVENT_SHOW, "popover");
|
||||
await invokeContentTask(browser, [], () => {
|
||||
const popoverDom = content.document.getElementById("popover");
|
||||
popoverDom.popover = "manual";
|
||||
popoverDom.showPopover();
|
||||
});
|
||||
popover = (await shown).accessible;
|
||||
testAttrs(popover, { ispopup: "manual" }, true);
|
||||
},
|
||||
{ chrome: true, topLevel: true }
|
||||
);
|
||||
|
|
|
|||
|
|
@ -573,6 +573,7 @@ STATIC_ATOMS = [
|
|||
Atom("invokeaction", "invokeaction"),
|
||||
Atom("is", "is"),
|
||||
Atom("ismap", "ismap"),
|
||||
Atom("ispopup", "ispopup"),
|
||||
Atom("itemid", "itemid"),
|
||||
Atom("itemprop", "itemprop"),
|
||||
Atom("itemref", "itemref"),
|
||||
|
|
|
|||
Loading…
Reference in a new issue