Bug 770106. nsDisplayButtonBorderBackground should use the button's border-box for hit-testing, not its visual overflow area. r=mattwoodrow
authorRobert O'Callahan <robert@ocallahan.org>
Fri, 28 Sep 2012 23:19:38 +1200
changeset 108574 d60fa8d54dc4b9134dd93237a15932a3e86928c7
parent 108573 035ed3e2d9d4c031f6e8fdc1ef70b559d94d83bb
child 108575 8c751f940ba150abffd769eff7bb8c8ac8142776
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewersmattwoodrow
bugs770106
milestone18.0a1
Bug 770106. nsDisplayButtonBorderBackground should use the button's border-box for hit-testing, not its visual overflow area. r=mattwoodrow
layout/base/tests/Makefile.in
layout/base/tests/test_bug770106.html
layout/forms/nsButtonFrameRenderer.cpp
--- a/layout/base/tests/Makefile.in
+++ b/layout/base/tests/Makefile.in
@@ -142,16 +142,17 @@ MOCHITEST_FILES =	\
 		test_bug582771.html \
 		test_bug603550.html \
 		test_bug629838.html \
 		test_bug646757.html \
 		test_bug718809.html \
 		test_bug725426.html \
 		test_bug731777.html \
 		test_bug761572.html \
+		test_bug770106.html \
 		test_maxLineBoxWidth.html \
 		$(NULL)
 
 # Tests for bugs 441782, 467672 and 570378 don't pass reliably on Windows, because of bug 469208
 ifeq (,$(filter windows,$(MOZ_WIDGET_TOOLKIT)))
 # THESE TESTS (BELOW) DO NOT RUN ON WINDOWS
 MOCHITEST_FILES += \
 		bidi_numeral_test.js \
new file mode 100644
--- /dev/null
+++ b/layout/base/tests/test_bug770106.html
@@ -0,0 +1,24 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test for Bug 770106</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<span id="s">Hello</span>
+<button><div style="pointer-events:none; position:relative; width:100px; background:yellow; left:-100px;">Kitty</div></button>
+
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 770106 **/
+
+var sRect = s.getBoundingClientRect();
+is(document.elementFromPoint(sRect.left + sRect.width/2, sRect.top + sRect.height/2),
+   document.getElementById("s"), "Correct object selected");
+
+</script>
+</pre>
+</body>
+</html>
--- a/layout/forms/nsButtonFrameRenderer.cpp
+++ b/layout/forms/nsButtonFrameRenderer.cpp
@@ -121,17 +121,18 @@ public:
   NS_DISPLAY_DECL_NAME("ButtonBorderBackground", TYPE_BUTTON_BORDER_BACKGROUND)
 private:
   nsButtonFrameRenderer* mBFR;
 };
 
 nsRect
 nsDisplayButtonBorderBackground::GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) {
   *aSnap = false;
-  return mFrame->GetVisualOverflowRectRelativeToSelf() + ToReferenceFrame();
+  return aBuilder->IsForEventDelivery() ? nsRect(ToReferenceFrame(), mFrame->GetSize())
+          : mFrame->GetVisualOverflowRectRelativeToSelf() + ToReferenceFrame();
 }
 
 class nsDisplayButtonForeground : public nsDisplayItem {
 public:
   nsDisplayButtonForeground(nsDisplayListBuilder* aBuilder,
                             nsButtonFrameRenderer* aRenderer)
     : nsDisplayItem(aBuilder, aRenderer->GetFrame()), mBFR(aRenderer) {
     MOZ_COUNT_CTOR(nsDisplayButtonForeground);