Bug 703186 Use system event listener for focus/blur event handling for <area> element r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Sat, 26 Nov 2011 10:33:09 +0900
changeset 82440 5c6903c68234a2a290861eaa9cf921989281d2bf
parent 82439 0408a35a67f9537ae901b787928fc877d184e8b8
child 82441 dad793c1b1437c83315fda28289228767a0a7a92
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs703186
milestone11.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 703186 Use system event listener for focus/blur event handling for <area> element r=smaug
layout/generic/nsImageMap.cpp
layout/reftests/bugs/703186-1-ref.html
layout/reftests/bugs/703186-1.html
layout/reftests/bugs/703186-2-ref.html
layout/reftests/bugs/703186-2.html
layout/reftests/bugs/reftest.list
--- a/layout/generic/nsImageMap.cpp
+++ b/layout/generic/nsImageMap.cpp
@@ -733,20 +733,20 @@ nsImageMap::FreeAreas()
 {
   PRUint32 i, n = mAreas.Length();
   for (i = 0; i < n; i++) {
     Area* area = mAreas.ElementAt(i);
     NS_ASSERTION(area->mArea->GetPrimaryFrame() == mImageFrame,
                  "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();
 }
 
 nsresult
 nsImageMap::Init(nsImageFrame* aImageFrame, nsIContent* aMap)
 {
@@ -854,20 +854,20 @@ nsImageMap::AddArea(nsIContent* aArea)
   default:
     NS_NOTREACHED("FindAttrValueIn returned an unexpected value.");
     break;
   }
   if (!area)
     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,
   // nsCSSFrameConstructor::ContentRemoved (both hacks there), and
   // nsCSSFrameConstructor::ProcessRestyledFrames to work around this issue can
   // be removed.
   aArea->SetPrimaryFrame(mImageFrame);
 
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/703186-1-ref.html
@@ -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>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/703186-1.html
@@ -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>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/703186-2-ref.html
@@ -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>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/703186-2.html
@@ -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>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -1668,8 +1668,11 @@ fails-if(layersGPUAccelerated&&cocoaWidg
 == 668319-1.xul about:blank
 == 670442-1.html 670442-1-ref.html
 == 670467-1.html 670467-1-ref.html
 == 670467-2.html 670467-2-ref.html
 != 691087-1.html 691087-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