Bug 703186 Use system event listener for focus/blur event handling for <area> element r=smaug

This commit is contained in:
Masayuki Nakano 2011-11-26 10:33:09 +09:00
parent f3899264c7
commit b65aeee9ac
6 changed files with 119 additions and 8 deletions

View File

@ -738,10 +738,10 @@ nsImageMap::FreeAreas()
"Unexpected primary frame");
area->mArea->SetPrimaryFrame(nsnull);
area->mArea->RemoveEventListener(NS_LITERAL_STRING("focus"), this,
false);
area->mArea->RemoveEventListener(NS_LITERAL_STRING("blur"), this,
false);
area->mArea->RemoveSystemEventListener(NS_LITERAL_STRING("focus"), this,
false);
area->mArea->RemoveSystemEventListener(NS_LITERAL_STRING("blur"), this,
false);
delete area;
}
mAreas.Clear();
@ -859,10 +859,10 @@ nsImageMap::AddArea(nsIContent* aArea)
return NS_ERROR_OUT_OF_MEMORY;
//Add focus listener to track area focus changes
aArea->AddEventListener(NS_LITERAL_STRING("focus"), this, false,
false);
aArea->AddEventListener(NS_LITERAL_STRING("blur"), this, false,
false);
aArea->AddSystemEventListener(NS_LITERAL_STRING("focus"), this, false,
false);
aArea->AddSystemEventListener(NS_LITERAL_STRING("blur"), this, false,
false);
// This is a nasty hack. It needs to go away: see bug 135040. Once this is
// removed, the code added to nsCSSFrameConstructor::RestyleElement,

View File

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<script type="text/javascript">
function init()
{
document.getElementById("link").focus();
setTimeout(finish, 0);
}
function finish()
{
document.documentElement.removeAttribute("class");
}
</script>
</head>
<body onload="setTimeout(init, 0);">
<img src="100x80-white-rect-top-right.png" usemap="#map">
<map name="map">
<area id="link" shape="rect" coords="10,10,30,30" href="about:blank">
</map>
</body>
</html>

View File

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<script type="text/javascript">
function init()
{
window.addEventListener("focus", function (e) { e.stopPropagation(); },
true);
document.getElementById("link").focus();
setTimeout(finish, 0);
}
function finish()
{
document.documentElement.removeAttribute("class");
}
</script>
</head>
<body onload="setTimeout(init, 0);">
<img src="100x80-white-rect-top-right.png" usemap="#map">
<map name="map">
<area id="link" shape="rect" coords="10,10,30,30" href="about:blank">
</map>
</body>
</html>

View File

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<script type="text/javascript">
function init()
{
document.getElementById("link").focus();
setTimeout(doTest, 0);
}
function doTest()
{
document.getElementById("link").blur();
setTimeout(finish, 0);
}
function finish()
{
document.documentElement.removeAttribute("class");
}
</script>
</head>
<body onload="setTimeout(init, 0);">
<img src="100x80-white-rect-top-right.png" usemap="#map">
<map name="map">
<area id="link" shape="rect" coords="10,10,30,30" href="about:blank">
</map>
</body>
</html>

View File

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<script type="text/javascript">
function init()
{
window.addEventListener("blur", function (e) { e.stopPropagation(); },
true);
document.getElementById("link").focus();
setTimeout(doTest, 0);
}
function doTest()
{
document.getElementById("link").blur();
setTimeout(finish, 0);
}
function finish()
{
document.documentElement.removeAttribute("class");
}
</script>
</head>
<body onload="setTimeout(init, 0);">
<img src="100x80-white-rect-top-right.png" usemap="#map">
<map name="map">
<area id="link" shape="rect" coords="10,10,30,30" href="about:blank">
</map>
</body>
</html>

View File

@ -1673,3 +1673,6 @@ fails-if(layersGPUAccelerated&&cocoaWidget) == 654950-1.html 654950-1-ref.html #
== 691571-1.html 691571-1-ref.html
== 696307-1.html 696307-1-ref.html
== 696739-1.html 696739-1-ref.html
needs-focus == 703186-1.html 703186-1-ref.html
needs-focus == 703186-2.html 703186-2-ref.html
needs-focus != 703186-1.html 703186-2.html