Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Mullvad Browser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
The Tor Project
Applications
Mullvad Browser
Commits
2872d3cc
Commit
2872d3cc
authored
13 years ago
by
Masayuki Nakano
Browse files
Options
Downloads
Patches
Plain Diff
Bug 706743 tooltip listener should ignore mousemove and mouseout events during drag r=enndeakin
parent
a17c3dda
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
layout/xul/base/src/nsXULTooltipListener.cpp
+31
-5
31 additions, 5 deletions
layout/xul/base/src/nsXULTooltipListener.cpp
layout/xul/test/Makefile.in
+1
-0
1 addition, 0 deletions
layout/xul/test/Makefile.in
layout/xul/test/browser_bug706743.js
+150
-0
150 additions, 0 deletions
layout/xul/test/browser_bug706743.js
with
182 additions
and
5 deletions
layout/xul/base/src/nsXULTooltipListener.cpp
+
31
−
5
View file @
2872d3cc
...
...
@@ -48,6 +48,8 @@
#include
"nsIPopupBoxObject.h"
#include
"nsMenuPopupFrame.h"
#include
"nsIServiceManager.h"
#include
"nsIDragService.h"
#include
"nsIDragSession.h"
#ifdef MOZ_XUL
#include
"nsITreeView.h"
#endif
...
...
@@ -267,14 +269,38 @@ nsXULTooltipListener::HandleEvent(nsIDOMEvent* aEvent)
type
.
EqualsLiteral
(
"keydown"
)
||
type
.
EqualsLiteral
(
"mousedown"
)
||
type
.
EqualsLiteral
(
"mouseup"
)
||
type
.
EqualsLiteral
(
"dragstart"
))
type
.
EqualsLiteral
(
"dragstart"
))
{
HideTooltip
();
else
if
(
type
.
EqualsLiteral
(
"mousemove"
))
return
NS_OK
;
}
if
(
type
.
EqualsLiteral
(
"popuphiding"
))
{
DestroyTooltip
();
return
NS_OK
;
}
// Note that mousemove, mouseover and mouseout might be
// fired even during dragging due to widget's bug.
nsCOMPtr
<
nsIDragService
>
dragService
=
do_GetService
(
"@mozilla.org/widget/dragservice;1"
);
NS_ENSURE_TRUE
(
dragService
,
NS_OK
);
nsCOMPtr
<
nsIDragSession
>
dragSession
;
dragService
->
GetCurrentSession
(
getter_AddRefs
(
dragSession
));
if
(
dragSession
)
{
return
NS_OK
;
}
// Not dragging.
if
(
type
.
EqualsLiteral
(
"mousemove"
))
{
MouseMove
(
aEvent
);
else
if
(
type
.
EqualsLiteral
(
"mouseout"
))
return
NS_OK
;
}
if
(
type
.
EqualsLiteral
(
"mouseout"
))
{
MouseOut
(
aEvent
);
else
if
(
type
.
EqualsLiteral
(
"popuphiding"
))
DestroyTooltip
();
return
NS_OK
;
}
return
NS_OK
;
}
...
...
This diff is collapsed.
Click to expand it.
layout/xul/test/Makefile.in
+
1
−
0
View file @
2872d3cc
...
...
@@ -67,6 +67,7 @@ libs:: $(_CHROME_FILES)
ifneq
(mobile,$(MOZ_BUILD_APP))
_BROWSER_FILES
=
\
browser_bug703210.js
\
browser_bug706743.js
\
$(
NULL
)
libs
::
$(_BROWSER_FILES)
...
...
This diff is collapsed.
Click to expand it.
layout/xul/test/browser_bug706743.js
0 → 100644
+
150
−
0
View file @
2872d3cc
function
test
()
{
waitForExplicitFinish
();
gBrowser
.
selectedTab
=
gBrowser
.
addTab
();
let
target
;
let
doc
;
let
win
;
let
callbackOnPopupShown
;
let
callbackOnPopupHidden
;
let
dragService
=
Components
.
classes
[
"
@mozilla.org/widget/dragservice;1
"
].
getService
(
Components
.
interfaces
.
nsIDragService
);
let
onPopupHidden
=
function
(
aEvent
)
{
if
(
aEvent
.
originalTarget
.
localName
!=
"
tooltip
"
)
{
return
;
}
if
(
callbackOnPopupHidden
)
{
setTimeout
(
callbackOnPopupHidden
,
0
);
}
}
let
onPopupShown
=
function
(
aEvent
)
{
if
(
aEvent
.
originalTarget
.
localName
!=
"
tooltip
"
)
{
return
;
}
if
(
callbackOnPopupShown
)
{
setTimeout
(
callbackOnPopupShown
,
0
);
}
}
let
finishTest
=
function
()
{
document
.
removeEventListener
(
"
popupshown
"
,
onPopupShown
,
true
);
document
.
removeEventListener
(
"
popuphidden
"
,
onPopupHidden
,
true
);
gBrowser
.
removeCurrentTab
();
finish
();
}
let
testHideTooltipByMouseDown
=
function
()
{
callbackOnPopupShown
=
function
()
{
callbackOnPopupShown
=
null
;
ok
(
true
,
"
tooltip is shown before testing mousedown
"
);
// hide tooltip by mousemove to outside.
callbackOnPopupHidden
=
function
()
{
callbackOnPopupHidden
=
null
;
ok
(
true
,
"
The tooltip is hidden by mousedown
"
);
EventUtils
.
synthesizeMouse
(
target
,
5
,
15
,
{
type
:
"
mouseup
"
},
win
);
EventUtils
.
synthesizeMouse
(
target
,
-
5
,
15
,
{
type
:
"
mousemove
"
},
win
);
setTimeout
(
finishTest
,
0
);
}
EventUtils
.
synthesizeMouse
(
target
,
5
,
15
,
{
type
:
"
mousedown
"
},
win
);
}
EventUtils
.
synthesizeMouse
(
target
,
5
,
15
,
{
type
:
"
mousemove
"
},
win
);
}
let
testShowTooltipAgain
=
function
()
{
// If tooltip listener used a flag for managing D&D state, we would need
// to test if the tooltip is shown after drag.
callbackOnPopupShown
=
function
()
{
callbackOnPopupShown
=
null
;
ok
(
true
,
"
tooltip is shown after drag
"
);
// hide tooltip by mousemove to outside.
callbackOnPopupHidden
=
function
()
{
callbackOnPopupHidden
=
null
;
ok
(
true
,
"
The tooltip is hidden again
"
);
setTimeout
(
testHideTooltipByMouseDown
,
0
);
}
EventUtils
.
synthesizeMouse
(
target
,
-
5
,
15
,
{
type
:
"
mousemove
"
},
win
);
}
EventUtils
.
synthesizeMouse
(
target
,
5
,
15
,
{
type
:
"
mousemove
"
},
win
);
}
let
testDuringDnD
=
function
()
{
// mousemove into the target and start drag by emulation via nsIDragService.
// Note that on some platforms, we cannot actually start the drag by
// synthesized events. E.g., Windows waits an actual mousemove event after
// dragstart.
callbackOnPopupShown
=
function
()
{
callbackOnPopupShown
=
null
;
ok
(
false
,
"
tooltip is shown during drag
"
);
}
dragService
.
startDragSession
();
// Emulate a buggy mousemove event. widget might dispatch mousemove event
// during drag.
EventUtils
.
synthesizeMouse
(
target
,
5
,
15
,
{
type
:
"
mousemove
"
},
win
);
setTimeout
(
function
()
{
callbackOnPopupShown
=
null
;
ok
(
true
,
"
tooltip isn't shown during drag
"
);
dragService
.
endDragSession
(
true
);
EventUtils
.
synthesizeMouse
(
target
,
-
5
,
-
5
,
{
type
:
"
mousemove
"
},
win
);
setTimeout
(
testShowTooltipAgain
,
0
);
},
600
);
}
let
onLoad
=
function
(
aEvent
)
{
doc
=
gBrowser
.
contentDocument
;
win
=
gBrowser
.
contentWindow
;
target
=
doc
.
getElementById
(
"
target
"
);
document
.
addEventListener
(
"
popupshown
"
,
onPopupShown
,
true
);
document
.
addEventListener
(
"
popuphidden
"
,
onPopupHidden
,
true
);
EventUtils
.
synthesizeMouse
(
target
,
-
5
,
-
5
,
{
type
:
"
mousemove
"
},
win
);
// show tooltip by mousemove into target.
callbackOnPopupShown
=
function
()
{
callbackOnPopupShown
=
null
;
ok
(
true
,
"
The tooltip is shown
"
);
// hide tooltip by mousemove to outside.
callbackOnPopupHidden
=
function
()
{
callbackOnPopupHidden
=
null
;
ok
(
true
,
"
The tooltip is hidden
"
);
setTimeout
(
testDuringDnD
,
0
);
}
EventUtils
.
synthesizeMouse
(
target
,
-
5
,
15
,
{
type
:
"
mousemove
"
},
win
);
}
EventUtils
.
synthesizeMouse
(
target
,
5
,
15
,
{
type
:
"
mousemove
"
},
win
);
}
gBrowser
.
selectedBrowser
.
addEventListener
(
"
load
"
,
function
()
{
gBrowser
.
selectedBrowser
.
removeEventListener
(
"
load
"
,
arguments
.
callee
,
true
);
setTimeout
(
onLoad
,
0
);
},
true
);
content
.
location
=
"
data:text/html,<html><head></head><body>
"
+
"
<a id=
\"
target
\"
href=
\"
about:blank
\"
title=
\"
This is tooltip text
\"
"
+
"
style=
\"
display:block;height:20px;margin:10px;
\"
"
+
"
onclick=
\"
return false;
\"
>here is an anchor element</a></body></html>
"
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment