Bug 1881488 - Use a static pref for tooltip delay. r=masayuki,dom-core

It's 500 everywhere.

Differential Revision: https://phabricator.services.mozilla.com/D202419
This commit is contained in:
Emilio Cobos Álvarez 2024-02-22 12:59:41 +00:00
parent b8466106c7
commit a56f40eee5
16 changed files with 17 additions and 41 deletions

View File

@ -18,7 +18,7 @@
#include "nsAtom.h"
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
#include "mozilla/LookAndFeel.h"
#include "mozilla/StaticPrefs_ui.h"
// Interfaces needed to be included
#include "nsPresContext.h"
@ -1184,9 +1184,8 @@ nsresult ChromeTooltipListener::MouseMove(Event* aMouseEvent) {
if (mPossibleTooltipNode) {
nsresult rv = NS_NewTimerWithFuncCallback(
getter_AddRefs(mTooltipTimer), sTooltipCallback, this,
LookAndFeel::GetInt(LookAndFeel::IntID::TooltipDelay, 500),
nsITimer::TYPE_ONE_SHOT, "ChromeTooltipListener::MouseMove",
GetMainThreadSerialEventTarget());
StaticPrefs::ui_tooltip_delay_ms(), nsITimer::TYPE_ONE_SHOT,
"ChromeTooltipListener::MouseMove", GetMainThreadSerialEventTarget());
if (NS_FAILED(rv)) {
mPossibleTooltipNode = nullptr;
NS_WARNING("Could not create a timer for tooltip tracking");

View File

@ -208,9 +208,8 @@ void nsXULTooltipListener::MouseMove(Event* aEvent) {
if (mTargetNode) {
nsresult rv = NS_NewTimerWithFuncCallback(
getter_AddRefs(mTooltipTimer), sTooltipCallback, this,
LookAndFeel::GetInt(LookAndFeel::IntID::TooltipDelay, 500),
nsITimer::TYPE_ONE_SHOT, "sTooltipCallback",
GetMainThreadSerialEventTarget());
StaticPrefs::ui_tooltip_delay_ms(), nsITimer::TYPE_ONE_SHOT,
"sTooltipCallback", GetMainThreadSerialEventTarget());
if (NS_FAILED(rv)) {
mTargetNode = nullptr;
mSourceNode = nullptr;

View File

@ -6,9 +6,7 @@ add_task(async function () {
"data:text/html," + html
);
await new Promise(resolve => {
SpecialPowers.pushPrefEnv({ set: [["ui.tooltipDelay", 0]] }, resolve);
});
await SpecialPowers.pushPrefEnv({ set: [["ui.tooltip.delay_ms", 0]] });
await BrowserTestUtils.synthesizeMouseAtCenter(
"#p1",

View File

@ -10,9 +10,7 @@ add_task(async function () {
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, url);
let browser = gBrowser.selectedBrowser;
await new Promise(resolve => {
SpecialPowers.pushPrefEnv({ set: [["ui.tooltipDelay", 0]] }, resolve);
});
await SpecialPowers.pushPrefEnv({ set: [["ui.tooltip.delay_ms", 0]] });
let popupShownPromise = BrowserTestUtils.waitForEvent(
document,

View File

@ -8,9 +8,7 @@ add_task(async function () {
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, url);
let browser = gBrowser.selectedBrowser;
await new Promise(resolve => {
SpecialPowers.pushPrefEnv({ set: [["ui.tooltipDelay", 0]] }, resolve);
});
await SpecialPowers.pushPrefEnv({ set: [["ui.tooltip.delay_ms", 0]] });
// Send a mousemove at a known position to start the test.
await BrowserTestUtils.synthesizeMouse(

View File

@ -15051,6 +15051,12 @@
value: @IS_ANDROID@
mirror: always
# Delay in milliseconds for tooltips
- name: ui.tooltip.delay_ms
type: uint32_t
value: 500
mirror: always
# If the user puts a finger down on an element and we think the user might be
# executing a pan gesture, how long do we wait before tentatively deciding the
# gesture is actually a tap and activating the target element?

View File

@ -412,7 +412,7 @@ add_task(async function testPaginatorAfterSettingsUpdate() {
});
add_task(async function testTooltips() {
await SpecialPowers.pushPrefEnv({ set: [["ui.tooltipDelay", 0]] });
await SpecialPowers.pushPrefEnv({ set: [["ui.tooltip.delay_ms", 0]] });
const mockPrinterName = "Fake Printer";
await PrintHelper.withTestPage(async helper => {
helper.addMockPrinter(mockPrinterName);

View File

@ -2,7 +2,7 @@
let tempFile;
add_setup(async function () {
await SpecialPowers.pushPrefEnv({ set: [["ui.tooltipDelay", 0]] });
await SpecialPowers.pushPrefEnv({ set: [["ui.tooltip.delay_ms", 0]] });
tempFile = createTempFile();
registerCleanupFunction(function () {
tempFile.remove(true);

View File

@ -1,7 +1,7 @@
/* eslint-disable mozilla/no-arbitrary-setTimeout */
add_setup(async function () {
await SpecialPowers.pushPrefEnv({ set: [["ui.tooltipDelay", 0]] });
await SpecialPowers.pushPrefEnv({ set: [["ui.tooltip.delay_ms", 0]] });
});
add_task(async function test_title_in_shadow_dom() {

View File

@ -163,10 +163,6 @@ class LookAndFeel {
* 1: scrollbar button repeats to scroll even if cursor is outside of it.
*/
ScrollbarButtonAutoRepeatBehavior,
/**
* Delay before showing a tooltip.
*/
TooltipDelay,
/*
* A Boolean value to determine whether swipe animations should be used.
*/

View File

@ -312,10 +312,6 @@ nsresult nsLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) {
aResult = 200;
break;
case IntID::TooltipDelay:
aResult = 500;
break;
case IntID::MenusCanOverlapOSBar:
// we want XUL popups to be able to overlap the task bar.
aResult = 1;

View File

@ -366,9 +366,6 @@ nsresult nsLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) {
case IntID::SubmenuDelay:
aResult = 200;
break;
case IntID::TooltipDelay:
aResult = 500;
break;
case IntID::MenusCanOverlapOSBar:
// xul popups are not allowed to overlap the menubar.
aResult = 0;

View File

@ -905,10 +905,6 @@ nsresult nsLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) {
aResult = (int32_t)delay;
break;
}
case IntID::TooltipDelay: {
aResult = 500;
break;
}
case IntID::MenusCanOverlapOSBar:
// we want XUL popups to be able to overlap the task bar.
aResult = 1;

View File

@ -118,9 +118,6 @@ nsresult HeadlessLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) {
case IntID::ScrollbarButtonAutoRepeatBehavior:
aResult = 0;
break;
case IntID::TooltipDelay:
aResult = 500;
break;
case IntID::SwipeAnimationEnabled:
aResult = 0;
break;

View File

@ -161,7 +161,6 @@ static const char sIntPrefs[][45] = {
"ui.SpellCheckerUnderlineStyle",
"ui.menuBarDrag",
"ui.scrollbarButtonAutoRepeatBehavior",
"ui.tooltipDelay",
"ui.swipeAnimationEnabled",
"ui.scrollbarDisplayOnMouseMove",
"ui.scrollbarFadeBeginDelay",

View File

@ -409,9 +409,6 @@ nsresult nsLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) {
// (400ms) on error.
aResult = GetSystemParam(SPI_GETMENUSHOWDELAY, 400);
break;
case IntID::TooltipDelay:
aResult = 500;
break;
case IntID::MenusCanOverlapOSBar:
// we want XUL popups to be able to overlap the task bar.
aResult = 1;