Bug 119061. SVG elements to which the :hover pseudo class apply do not restyle when moved under the mouse pointer. r=roc

This commit is contained in:
Jonathan Watt 2009-06-11 21:49:34 +02:00
Родитель 849e48d014
Коммит a955b81011
5 изменённых файлов: 179 добавлений и 0 удалений

Просмотреть файл

@ -62,6 +62,7 @@ _TEST_FILES = \
test_valueLeaks.xhtml \
viewport-helper.svg \
test_viewport.html \
test_moveUnderMouse.xhtml \
$(NULL)
libs:: $(_TEST_FILES)

Просмотреть файл

@ -0,0 +1,97 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test :hover styling when an element is moved under the mouse</title>
<!--
From https://bugzilla.mozilla.org/show_bug.cgi?id=119061
This test checks whether an element to which the :hover pseudo class
applies is correctly restyled when it moves under the mouse pointer.
Note this is different to having the pointer move over the element.
-->
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<style type="text/css">
#target:hover { fill: lime; }
</style>
<script type="text/javascript">//<![CDATA[
SimpleTest.waitForExplicitFinish();
function synthesizeMouseEvent(type, // string
x, // float
y, // float
button, // long
clickCount, // long
modifiers, // long
ignoreWindowBounds) // boolean
{
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowUtils)
.sendMouseEvent(type, x, y, button, clickCount, modifiers, ignoreWindowBounds);
}
function check_mousemove(event)
{
if (event.clientX != x || event.clientY != y) {
document.getElementById('message2').setAttribute('display','block');
}
}
document.addEventListener('mousemove', check_mousemove, false);
var x, y;
function run_test()
{
var topLeft = document.getElementById('svg').getBoundingClientRect();
x = topLeft.left + 50;
y = topLeft.top + 90;
try {
synthesizeMouseEvent('mousemove', x, y, 0, 0, 0, false);
} catch(e) {
document.getElementById('message1').setAttribute('display','block');
}
document.getElementById('g').removeAttribute('display');
setTimeout(finish_test, 500);
}
function finish_test()
{
var target = document.getElementById('target');
var color = document.defaultView.getComputedStyle(target, '').getPropertyValue('fill');
ok(color == 'rgb(0, 255, 0)', 'Expected "rgb(0, 255, 0)", got "' + color + '"');
SimpleTest.finish();
}
//]]></script>
</head>
<body onload="run_test()">
<svg id="svg" xmlns="http://www.w3.org/2000/svg" width="500" height="500">
<rect width="100%" height="100%" fill="red"/>
<g id="g" display="none">
<rect width="100%" height="100%" fill="lime"/>
<rect id="target" width="100" height="500" fill="red"/>
</g>
<text id="message1" display="none" x="10" y="40">
You user-agent does not have the necessary support for synthesizing mouse events.
</text>
<text id="message2" display="none" x="10" y="80">
You moved your mouse! That can cause this test to appear to fail.
</text>
</svg>
<p id="display">
</p>
<div id="content">
</div>
<pre id="test">
</pre>
</body>
</html>

Просмотреть файл

@ -0,0 +1,71 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/licenses/publicdomain/
-->
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" class="reftest-wait">
<title>Test :hover styling when an element is moved under the mouse</title>
<!--
From https://bugzilla.mozilla.org/show_bug.cgi?id=119061
This test checks whether an element to which the :hover pseudo class
applies is correctly restyled when it moves under the mouse pointer.
Note this is different to having the pointer move over the element.
-->
<style type="text/css">
#target:hover { fill: lime; }
</style>
<script type="text/javascript">//<![CDATA[
function synthesizeMouseEvent(type, // string
x, // float
y, // float
button, // long
clickCount, // long
modifiers, // long
ignoreWindowBounds) // boolean
{
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowUtils)
.sendMouseEvent(type, x, y, button, clickCount, modifiers, ignoreWindowBounds);
}
function check_mousemove(event)
{
if (event.clientX != 51 || event.clientY != 51) {
document.getElementById('message2').setAttribute('display','block');
}
}
document.addEventListener('mousemove', check_mousemove, false);
function run_test()
{
try {
synthesizeMouseEvent('mousemove', 51, 51, 0, 0, 0, false);
} catch(e) {
document.getElementById('message1').setAttribute('display','block');
}
document.getElementById('g').removeAttribute('display');
document.documentElement.removeAttribute('class');
}
document.addEventListener("MozReftestInvalidate", run_test, false);
setTimeout(run_test, 1000); // for manual testing
//]]></script>
<rect width="100%" height="100%" fill="red"/>
<g id="g" display="none">
<rect width="100%" height="100%" fill="lime"/>
<rect id="target" width="100" height="100" fill="red"/>
</g>
<text id="message1" display="none" x="10" y="40">
You user-agent does not have the necessary support for synthesizing mouse events.
</text>
<text id="message2" display="none" x="10" y="80">
You moved your mouse! That can cause this test to appear to fail.
</text>
</svg>

После

Ширина:  |  Высота:  |  Размер: 2.5 KiB

Просмотреть файл

@ -30,6 +30,7 @@ include moz-only/reftest.list
== dynamic-link-style-01.svg pass.svg
== dynamic-marker-01.svg pass.svg
== dynamic-mask-contents-01.svg pass.svg
skip == dynamic-move-under-mouse.svg pass.svg # disabled for now - needs privileges
== dynamic-pattern-01.svg pass.svg
== dynamic-pattern-02.svg pass.svg
== dynamic-pattern-contents-01.svg pass.svg

Просмотреть файл

@ -53,6 +53,7 @@
#include "nsIObjectLoadingContent.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsSVGMatrix.h"
#include "nsIViewManager.h"
class nsSVGMutationObserver : public nsStubMutationObserver
{
@ -627,6 +628,10 @@ nsSVGOuterSVGFrame::GetType() const
void
nsSVGOuterSVGFrame::InvalidateCoveredRegion(nsIFrame *aFrame)
{
// Make sure elements styled by :hover get updated if they've moved under or
// out from under the mouse:
PresContext()->PresShell()->GetViewManager()->SynthesizeMouseMove(PR_FALSE);
nsISVGChildFrame *svgFrame = do_QueryFrame(aFrame);
if (!svgFrame)
return;
@ -638,6 +643,10 @@ nsSVGOuterSVGFrame::InvalidateCoveredRegion(nsIFrame *aFrame)
PRBool
nsSVGOuterSVGFrame::UpdateAndInvalidateCoveredRegion(nsIFrame *aFrame)
{
// Make sure elements styled by :hover get updated if they've moved under or
// out from under the mouse:
PresContext()->PresShell()->GetViewManager()->SynthesizeMouseMove(PR_FALSE);
nsISVGChildFrame *svgFrame = do_QueryFrame(aFrame);
if (!svgFrame)
return PR_FALSE;