зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 950e472e6ba5 (bug 1681941) for failures on browser_preview_navigation.js. CLOSED TREE
This commit is contained in:
Родитель
bf1b0ed525
Коммит
2ed153afb2
|
@ -144,26 +144,16 @@ void nsXULTooltipListener::MouseMove(Event* aEvent) {
|
|||
// filter out false win32 MouseMove event
|
||||
if (mMouseScreenX == newMouseX && mMouseScreenY == newMouseY) return;
|
||||
|
||||
nsCOMPtr<nsIContent> currentTooltip = do_QueryReferent(mCurrentTooltip);
|
||||
nsCOMPtr<EventTarget> eventTarget = aEvent->GetComposedTarget();
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(eventTarget);
|
||||
|
||||
bool isSameTarget = true;
|
||||
nsCOMPtr<nsIContent> tempContent = do_QueryReferent(mPreviousMouseMoveTarget);
|
||||
if (tempContent && tempContent != content) {
|
||||
isSameTarget = false;
|
||||
}
|
||||
|
||||
// filter out minor movements due to crappy optical mice and shaky hands
|
||||
// to prevent tooltips from hiding prematurely. Do not filter out movements
|
||||
// if we are changing targets, as they may register new tooltips.
|
||||
if ((currentTooltip && isSameTarget) &&
|
||||
// to prevent tooltips from hiding prematurely.
|
||||
nsCOMPtr<nsIContent> currentTooltip = do_QueryReferent(mCurrentTooltip);
|
||||
|
||||
if ((currentTooltip) &&
|
||||
(abs(mMouseScreenX - newMouseX) <= kTooltipMouseMoveTolerance) &&
|
||||
(abs(mMouseScreenY - newMouseY) <= kTooltipMouseMoveTolerance))
|
||||
return;
|
||||
mMouseScreenX = newMouseX;
|
||||
mMouseScreenY = newMouseY;
|
||||
mPreviousMouseMoveTarget = do_GetWeakReference(content);
|
||||
|
||||
nsCOMPtr<nsIContent> sourceContent =
|
||||
do_QueryInterface(aEvent->GetCurrentTarget());
|
||||
|
@ -178,20 +168,16 @@ void nsXULTooltipListener::MouseMove(Event* aEvent) {
|
|||
// the node.
|
||||
KillTooltipTimer();
|
||||
|
||||
// Hide the current tooltip if we change target nodes. If the new target
|
||||
// has the same tooltip, we will open it again. We cannot compare
|
||||
// the targets' tooltips because popupshowing events can set the tooltip.
|
||||
if (!isSameTarget) {
|
||||
HideTooltip();
|
||||
mTooltipShownOnce = false;
|
||||
}
|
||||
|
||||
// If the mouse moves while the tooltip is up, hide it. If nothing is
|
||||
// showing and the tooltip hasn't been displayed since the mouse entered
|
||||
// the node, then start the timer to show the tooltip.
|
||||
// If we have moved to a different target, we need to display the new tooltip,
|
||||
// as the previous target's tooltip will have just been hidden.
|
||||
if ((!currentTooltip && !mTooltipShownOnce) || !isSameTarget) {
|
||||
if (!currentTooltip && !mTooltipShownOnce) {
|
||||
nsCOMPtr<EventTarget> eventTarget = aEvent->GetComposedTarget();
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(eventTarget);
|
||||
if (content && !content->GetContainingShadow()) {
|
||||
eventTarget = aEvent->GetTarget();
|
||||
}
|
||||
|
||||
// don't show tooltips attached to elements outside of a menu popup
|
||||
// when hovering over an element inside it. The popupsinherittooltip
|
||||
// attribute may be used to disable this behaviour, which is useful for
|
||||
|
@ -230,13 +216,11 @@ void nsXULTooltipListener::MouseMove(Event* aEvent) {
|
|||
#ifdef MOZ_XUL
|
||||
if (mIsSourceTree) return;
|
||||
#endif
|
||||
// Hide the tooltip if it is currently showing.
|
||||
if (currentTooltip) {
|
||||
HideTooltip();
|
||||
// set a flag so that the tooltip is only displayed once until the mouse
|
||||
// leaves the node
|
||||
mTooltipShownOnce = true;
|
||||
}
|
||||
|
||||
HideTooltip();
|
||||
// set a flag so that the tooltip is only displayed once until the mouse
|
||||
// leaves the node
|
||||
mTooltipShownOnce = true;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -72,7 +72,6 @@ class nsXULTooltipListener final : public nsIDOMEventListener {
|
|||
nsWeakPtr mSourceNode;
|
||||
nsWeakPtr mTargetNode;
|
||||
nsWeakPtr mCurrentTooltip;
|
||||
nsWeakPtr mPreviousMouseMoveTarget;
|
||||
|
||||
// a timer for showing the tooltip
|
||||
nsCOMPtr<nsITimer> mTooltipTimer;
|
||||
|
|
|
@ -422,65 +422,3 @@ add_task(async function testPaginatorAfterSettingsUpdate() {
|
|||
await helper.closeDialog();
|
||||
}, "longerArticle.html");
|
||||
});
|
||||
|
||||
add_task(async function testTooltips() {
|
||||
await SpecialPowers.pushPrefEnv({ set: [["ui.tooltipDelay", 0]] });
|
||||
const mockPrinterName = "Fake Printer";
|
||||
await PrintHelper.withTestPage(async helper => {
|
||||
helper.addMockPrinter(mockPrinterName);
|
||||
await helper.startPrint();
|
||||
|
||||
let paginationElem = document.querySelector(".printPreviewNavigation");
|
||||
let paginationSheetIndicator = paginationElem.shadowRoot.querySelector(
|
||||
"#sheetIndicator"
|
||||
);
|
||||
// Wait for the first _updatePrintPreview before interacting with the preview
|
||||
await waitForPageStatusUpdate(
|
||||
paginationSheetIndicator,
|
||||
{ sheetNum: 1, sheetCount: 3 },
|
||||
"Paginator indicates the correct number of sheets"
|
||||
);
|
||||
|
||||
let awaitTooltipOpen = new Promise(resolve => {
|
||||
window.addEventListener(
|
||||
"popupshown",
|
||||
function(event) {
|
||||
resolve(event.originalTarget);
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
});
|
||||
|
||||
let navigateEnd = paginationElem.shadowRoot.querySelector("#navigateEnd");
|
||||
info("Initial mouse move to end navigation button");
|
||||
await EventUtils.synthesizeNativeMouseMove(navigateEnd, 1, 0);
|
||||
info("Waiting");
|
||||
await EventUtils.synthesizeNativeMouseMove(navigateEnd, 5, 0);
|
||||
|
||||
let tooltip = await awaitTooltipOpen;
|
||||
tooltip = await awaitTooltipOpen;
|
||||
is(tooltip.label, navigateEnd.title, "Tooltip shows correct text");
|
||||
awaitTooltipOpen = new Promise(resolve => {
|
||||
window.addEventListener(
|
||||
"popupshown",
|
||||
function(event) {
|
||||
resolve(event.originalTarget);
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
});
|
||||
|
||||
let navigateNext = paginationElem.shadowRoot.querySelector("#navigateNext");
|
||||
info("Initial mouse move to next navigation button");
|
||||
await EventUtils.synthesizeNativeMouseMove(navigateNext, 1, 0);
|
||||
info("Waiting");
|
||||
await EventUtils.synthesizeNativeMouseMove(navigateNext, 5, 0);
|
||||
tooltip = await awaitTooltipOpen;
|
||||
is(tooltip.label, navigateNext.title, "Tooltip shows correct text");
|
||||
|
||||
// move focus before closing the dialog
|
||||
helper.get("cancel-button").focus();
|
||||
await helper.awaitAnimationFrame();
|
||||
await helper.closeDialog();
|
||||
}, "longerArticle.html");
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче