зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1652211 - Create and destroy xul tooltips as they appear and go away. r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D83408
This commit is contained in:
Родитель
c52528ea6f
Коммит
c43598ec97
|
@ -5,7 +5,6 @@
|
|||
XULMAP_TYPE(browser, OuterDocAccessible)
|
||||
XULMAP_TYPE(button, XULButtonAccessible)
|
||||
XULMAP_TYPE(checkbox, CheckboxAccessible)
|
||||
XULMAP_TYPE(description, XULLabelAccessible)
|
||||
XULMAP_TYPE(dropMarker, XULDropmarkerAccessible)
|
||||
XULMAP_TYPE(editor, OuterDocAccessible)
|
||||
XULMAP_TYPE(findbar, XULToolbarAccessible)
|
||||
|
@ -35,7 +34,34 @@ XULMAP_TYPE(treecolpicker, XULButtonAccessible)
|
|||
XULMAP_TYPE(treecols, XULTreeColumAccessible)
|
||||
XULMAP_TYPE(toolbar, XULToolbarAccessible)
|
||||
XULMAP_TYPE(toolbarbutton, XULToolbarButtonAccessible)
|
||||
XULMAP_TYPE(tooltip, XULTooltipAccessible)
|
||||
|
||||
XULMAP(description, [](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
if (aElement->ClassList()->Contains(u"tooltip-label"_ns)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new XULLabelAccessible(aElement, aContext->Document());
|
||||
})
|
||||
|
||||
XULMAP(tooltip, [](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
nsIFrame* frame = aElement->GetPrimaryFrame();
|
||||
if (!frame) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsMenuPopupFrame* popupFrame = do_QueryFrame(frame);
|
||||
if (!popupFrame) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsPopupState popupState = popupFrame->PopupState();
|
||||
if (popupState == ePopupHiding || popupState == ePopupInvisible ||
|
||||
popupState == ePopupClosed) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new XULTooltipAccessible(aElement, aContext->Document());
|
||||
})
|
||||
|
||||
XULMAP(label, [](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
if (aElement->ClassList()->Contains(u"text-link"_ns)) {
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
#include "nsImageFrame.h"
|
||||
#include "nsINamed.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsMenuPopupFrame.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "nsPluginFrame.h"
|
||||
#include "nsTreeBodyFrame.h"
|
||||
|
|
|
@ -270,6 +270,13 @@ void RootAccessible::ProcessDOMEvent(Event* aDOMEvent, nsINode* aTarget) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (eventType.EqualsLiteral("popupshown") &&
|
||||
aTarget->IsXULElement(nsGkAtoms::tooltip)) {
|
||||
targetDocument->ContentInserted(aTarget->AsContent(),
|
||||
aTarget->GetNextSibling()->AsContent());
|
||||
return;
|
||||
}
|
||||
|
||||
Accessible* accessible = targetDocument->GetAccessibleOrContainer(aTarget);
|
||||
if (!accessible) return;
|
||||
|
||||
|
@ -492,15 +499,6 @@ void RootAccessible::HandlePopupShownEvent(Accessible* aAccessible) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (role == roles::TOOLTIP) {
|
||||
// There is a single <xul:tooltip> node which Mozilla moves around.
|
||||
// The accessible for it stays the same no matter where it moves.
|
||||
// AT's expect to get an EVENT_SHOW for the tooltip.
|
||||
// In event callback the tooltip's accessible will be ready.
|
||||
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_SHOW, aAccessible);
|
||||
return;
|
||||
}
|
||||
|
||||
if (role == roles::COMBOBOX_LIST) {
|
||||
// Fire expanded state change event for comboboxes and autocompeletes.
|
||||
Accessible* combobox = aAccessible->Parent();
|
||||
|
@ -534,12 +532,17 @@ void RootAccessible::HandlePopupShownEvent(Accessible* aAccessible) {
|
|||
}
|
||||
|
||||
void RootAccessible::HandlePopupHidingEvent(nsINode* aPopupNode) {
|
||||
// Get popup accessible. There are cases when popup element isn't accessible
|
||||
// but an underlying widget is and behaves like popup, an example is
|
||||
// autocomplete popups.
|
||||
DocAccessible* document = nsAccUtils::GetDocAccessibleFor(aPopupNode);
|
||||
if (!document) return;
|
||||
|
||||
if (aPopupNode->IsXULElement(nsGkAtoms::tooltip)) {
|
||||
document->ContentRemoved(aPopupNode->AsContent());
|
||||
return;
|
||||
}
|
||||
|
||||
// Get popup accessible. There are cases when popup element isn't accessible
|
||||
// but an underlying widget is and behaves like popup, an example is
|
||||
// autocomplete popups.
|
||||
Accessible* popup = document->GetAccessible(aPopupNode);
|
||||
if (!popup) {
|
||||
Accessible* popupContainer = document->GetContainerAccessible(aPopupNode);
|
||||
|
|
|
@ -34,9 +34,7 @@
|
|||
<pre id="test">
|
||||
</pre>
|
||||
|
||||
<!-- Use an http url so the document is loaded with content privileges to
|
||||
avoid a tooltip node from automatically being created. -->
|
||||
<iframe id="iframe" src="http://mochi.test:8888/a11y/accessible/tests/mochitest/text/doc.html"></iframe>
|
||||
<iframe id="iframe" src="doc.html"></iframe>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -63,9 +63,7 @@
|
|||
turnCaretBrowsing(true);
|
||||
|
||||
// test caret offsets
|
||||
// This is one higher than expected because system principal documents
|
||||
// automatically create a tooltip node.
|
||||
testCaretOffset(document, 16);
|
||||
testCaretOffset(document, 15);
|
||||
testCaretOffset("textbox", -1);
|
||||
testCaretOffset("textarea", -1);
|
||||
testCaretOffset("p", -1);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="next" href="http://mochi.test:8888">
|
||||
<link rel="next" href="http://www.mozilla.org">
|
||||
<style>
|
||||
head, link, a { display: block; }
|
||||
link:after { content: "Link to " attr(href); }
|
||||
|
|
|
@ -57,8 +57,6 @@
|
|||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
<!-- Use an http url so the document is loaded with content privileges to
|
||||
avoid a tooltip node from automatically being created. -->
|
||||
<iframe src="http://mochi.test:8888/a11y/accessible/tests/mochitest/tree/dockids.html" id="iframe"></iframe>
|
||||
<iframe src="dockids.html" id="iframe"></iframe>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -39,5 +39,6 @@ support-files = test_bug1276857_subframe.html
|
|||
[test_shutdown.xhtml]
|
||||
[test_table.html]
|
||||
[test_textleaf.html]
|
||||
[test_tooltip.xhtml]
|
||||
[test_visibility.html]
|
||||
[test_whitespace.html]
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
<?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"
|
||||
title="Accessible XUL tooltip test">
|
||||
|
||||
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
|
||||
<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js" />
|
||||
|
||||
<script type="application/javascript"
|
||||
src="../common.js" />
|
||||
<script type="application/javascript"
|
||||
src="../role.js" />
|
||||
<script type="application/javascript"
|
||||
src="../promisified-events.js" />
|
||||
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
|
||||
async function doTest() {
|
||||
let tooltip = document.getElementById("tooltip");
|
||||
|
||||
testAccessibleTree("tooltip-container", { GROUPING: [] });
|
||||
|
||||
let shown = waitForEvent(EVENT_SHOW, tooltip);
|
||||
tooltip.openPopup();
|
||||
await shown;
|
||||
|
||||
testAccessibleTree("tooltip-container",
|
||||
{ GROUPING: [ { TOOLTIP: [] }] });
|
||||
|
||||
let hidden = waitForEvent(EVENT_HIDE, tooltip);
|
||||
tooltip.hidePopup();
|
||||
await hidden;
|
||||
|
||||
testAccessibleTree("tooltip-container", { GROUPING: [] });
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addA11yLoadEvent(doTest);
|
||||
]]>
|
||||
</script>
|
||||
|
||||
<hbox 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=1652211"
|
||||
title="Added anonymous tooltip to mochitest docs messes with text">
|
||||
Bug 1652211
|
||||
</a>
|
||||
<br/>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
|
||||
<vbox flex="1" role="group" id="tooltip-container">
|
||||
<tooltip id="tooltip">
|
||||
<description class="tooltip-label" value="hello world"/>
|
||||
</tooltip>
|
||||
</vbox>
|
||||
</hbox>
|
||||
|
||||
</window>
|
||||
|
Загрузка…
Ссылка в новой задаче