Skip to content

Commit 4f57a51

Browse files
committed
Bug 1870783 part 2: Expose ispopup object attribute. r=eeejay
Differential Revision: https://phabricator.services.mozilla.com/D197038
1 parent 1c409d8 commit 4f57a51

File tree

5 files changed

+61
-1
lines changed

5 files changed

+61
-1
lines changed

accessible/base/CacheConstants.h

+3
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ class CacheKey {
194194
// as returned by LocalAccessible::ParentRelativeBounds.
195195
static constexpr nsStaticAtom* ParentRelativeBounds =
196196
nsGkAtoms::relativeBounds;
197+
// nsAtom, CacheUpdateType::Initial
198+
// The type of a popup (used for HTML popover).
199+
static constexpr nsStaticAtom* PopupType = nsGkAtoms::ispopup;
197200
// nsAtom, CacheDomain::Actions
198201
static constexpr nsStaticAtom* PrimaryAction = nsGkAtoms::action;
199202
// float, no domain

accessible/generic/LocalAccessible.cpp

+17-1
Original file line numberDiff line numberDiff line change
@@ -1212,11 +1212,16 @@ already_AddRefed<AccAttributes> LocalAccessible::NativeAttributes() {
12121212
// Expose tag.
12131213
attributes->SetAttribute(nsGkAtoms::tag, mContent->NodeInfo()->NameAtom());
12141214

1215-
// Expose draggable object attribute.
12161215
if (auto htmlElement = nsGenericHTMLElement::FromNode(mContent)) {
1216+
// Expose draggable object attribute.
12171217
if (htmlElement->Draggable()) {
12181218
attributes->SetAttribute(nsGkAtoms::draggable, true);
12191219
}
1220+
nsString popover;
1221+
htmlElement->GetPopover(popover);
1222+
if (!popover.IsEmpty()) {
1223+
attributes->SetAttribute(nsGkAtoms::ispopup, std::move(popover));
1224+
}
12201225
}
12211226

12221227
// Don't calculate CSS-based object attributes when:
@@ -3902,6 +3907,17 @@ already_AddRefed<AccAttributes> LocalAccessible::BundleFieldsForCache(
39023907
fields->SetAttribute(CacheKey::ARIARole, std::move(role));
39033908
}
39043909
}
3910+
3911+
if (auto* htmlEl = nsGenericHTMLElement::FromNode(mContent)) {
3912+
// Changing popover recreates the Accessible, so it's immutable in the
3913+
// cache.
3914+
nsAutoString popover;
3915+
htmlEl->GetPopover(popover);
3916+
if (!popover.IsEmpty()) {
3917+
fields->SetAttribute(CacheKey::PopupType,
3918+
RefPtr{NS_Atomize(popover)});
3919+
}
3920+
}
39053921
}
39063922

39073923
if (frame) {

accessible/ipc/RemoteAccessible.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -1573,6 +1573,12 @@ already_AddRefed<AccAttributes> RemoteAccessible::Attributes() {
15731573
attributes->Remove(nsGkAtoms::aria_placeholder);
15741574
}
15751575
}
1576+
1577+
nsString popupType;
1578+
mCachedFields->GetAttribute(CacheKey::PopupType, popupType);
1579+
if (!popupType.IsEmpty()) {
1580+
attributes->SetAttribute(nsGkAtoms::ispopup, std::move(popupType));
1581+
}
15761582
}
15771583

15781584
nsAutoString name;

accessible/tests/browser/e10s/browser_caching_attributes.js

+34
Original file line numberDiff line numberDiff line change
@@ -727,3 +727,37 @@ addAccessibleTask(
727727
},
728728
{ chrome: true, topLevel: true }
729729
);
730+
731+
/**
732+
* Test the ispopup attribute.
733+
*/
734+
addAccessibleTask(
735+
`<div id="popover" popover>popover</div>`,
736+
async function testIspopup(browser, docAcc) {
737+
info("Showing popover");
738+
let shown = waitForEvent(EVENT_SHOW, "popover");
739+
await invokeContentTask(browser, [], () => {
740+
content.document.getElementById("popover").showPopover();
741+
});
742+
let popover = (await shown).accessible;
743+
testAttrs(popover, { ispopup: "auto" }, true);
744+
info("Setting popover to null");
745+
// Setting popover causes the Accessible to be recreated.
746+
shown = waitForEvent(EVENT_SHOW, "popover");
747+
await invokeContentTask(browser, [], () => {
748+
content.document.getElementById("popover").popover = null;
749+
});
750+
popover = (await shown).accessible;
751+
testAbsentAttrs(popover, { ispopup: "" });
752+
info("Setting popover to manual and showing");
753+
shown = waitForEvent(EVENT_SHOW, "popover");
754+
await invokeContentTask(browser, [], () => {
755+
const popoverDom = content.document.getElementById("popover");
756+
popoverDom.popover = "manual";
757+
popoverDom.showPopover();
758+
});
759+
popover = (await shown).accessible;
760+
testAttrs(popover, { ispopup: "manual" }, true);
761+
},
762+
{ chrome: true, topLevel: true }
763+
);

xpcom/ds/StaticAtoms.py

+1
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@
573573
Atom("invokeaction", "invokeaction"),
574574
Atom("is", "is"),
575575
Atom("ismap", "ismap"),
576+
Atom("ispopup", "ispopup"),
576577
Atom("itemid", "itemid"),
577578
Atom("itemprop", "itemprop"),
578579
Atom("itemref", "itemref"),

0 commit comments

Comments
 (0)