Bug 646757. Don't snap display item bounds during hit-testing. r=tnikkel,a=johnath
authorRobert O'Callahan <robert@ocallahan.org>
Tue, 31 May 2011 09:44:10 +1200
changeset 70263 e72be6ba64dd7a1df23f033941f444a4cccd67fe
parent 70262 c4328146645193e9db33d942f5be0f8e05e24890
child 70264 436da90e737a8df7823ce5b101f2634300bd733b
push id120
push userrocallahan@mozilla.com
push dateWed, 01 Jun 2011 23:56:22 +0000
treeherdermozilla-aurora@e72be6ba64dd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel, johnath
bugs646757
milestone6.0a2
Bug 646757. Don't snap display item bounds during hit-testing. r=tnikkel,a=johnath
content/html/document/test/test_bug463104.html
layout/base/nsDisplayList.cpp
layout/base/tests/Makefile.in
layout/base/tests/test_bug646757.html
--- a/content/html/document/test/test_bug463104.html
+++ b/content/html/document/test/test_bug463104.html
@@ -8,18 +8,18 @@
 </head>
 <body>
 <div id="a" style="position: fixed; left: 5.5px; top: 5.5px; width: 100px; height: 100px; background: blue"></div>
 <p style="margin-top: 110px">
 <script>
 var a = document.getElementById("a");
 isnot(a, document.elementFromPoint(5, 5), "a shouldn't be found");
 isnot(a, document.elementFromPoint(5.25, 5.25), "a shouldn't be found");
-isnot(a, document.elementFromPoint(5.5, 5.5), "a shouldn't be found");
-isnot(a, document.elementFromPoint(5.75, 5.75), "a shouldn't be found");
+is(a, document.elementFromPoint(5.5, 5.5), "a should be found");
+is(a, document.elementFromPoint(5.75, 5.75), "a should be found");
 is(a, document.elementFromPoint(6, 6), "a should be found");
 is(a, document.elementFromPoint(105, 105), "a should be found");
 is(a, document.elementFromPoint(105.25, 105.25), "a should be found");
 isnot(a, document.elementFromPoint(105.5, 105.5), "a shouldn't be found");
 isnot(a, document.elementFromPoint(105.75, 105.75), "a shouldn't be found");
 isnot(a, document.elementFromPoint(106, 106), "a shouldn't be found");
 </script>
 </body>
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -83,17 +83,17 @@ nsDisplayListBuilder::nsDisplayListBuild
       mHadToIgnoreSuppression(PR_FALSE),
       mIsAtRootOfPseudoStackingContext(PR_FALSE),
       mIncludeAllOutOfFlows(PR_FALSE),
       mSelectedFramesOnly(PR_FALSE),
       mAccurateVisibleRegions(PR_FALSE),
       mInTransform(PR_FALSE),
       mSyncDecodeImages(PR_FALSE),
       mIsPaintingToWindow(PR_FALSE),
-      mSnappingEnabled(PR_TRUE),
+      mSnappingEnabled(mMode != EVENT_DELIVERY),
       mHasDisplayPort(PR_FALSE),
       mHasFixedItems(PR_FALSE)
 {
   MOZ_COUNT_CTOR(nsDisplayListBuilder);
   PL_InitArenaPool(&mPool, "displayListArena", 1024,
                    NS_MAX(NS_ALIGNMENT_OF(void*),NS_ALIGNMENT_OF(double))-1);
 
   nsPresContext* pc = aReferenceFrame->PresContext();
--- a/layout/base/tests/Makefile.in
+++ b/layout/base/tests/Makefile.in
@@ -151,16 +151,17 @@ DEFINES += -D_IMPL_NS_LAYOUT
 		test_mozPaintCount.html \
 		test_scroll_selection_into_view.html \
 		test_bug583889.html \
 		bug583889_inner1.html \
 		bug583889_inner2.html \
 		test_bug582771.html \
 		test_bug603550.html \
 		test_bug629838.html \
+		test_bug646757.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)))
 _TEST_FILES += \
 		bidi_numeral_test.js \
 		test_bug332655-1.html \
 		test_bug332655-2.html \
new file mode 100644
--- /dev/null
+++ b/layout/base/tests/test_bug646757.html
@@ -0,0 +1,44 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=646757
+-->
+<head>
+  <title>Test for Bug 646757</title>
+  <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" />
+</head>
+<body style="margin:0" id="body">
+<div style="height:20.3px; width:400px; background:pink" id="d1"></div>
+<div style="height:20px; width:400px; background:yellow" id="d2"></div>
+<div style="height:9.7px; width:400px;" id="space1"></div>
+<div style="height:20.7px; width:400px; background:pink" id="d3"></div>
+<div style="height:20px; width:400px; background:yellow" id="d4"></div>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=646757">Mozilla Bug 646757</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+function testPoint(x, y, id) {
+  is(document.elementFromPoint(x, y).id, id,
+     "checking element at " + x + "," + y);
+}
+
+/** Test for Bug 646757 **/
+testPoint(200, 20, "d1");
+testPoint(200, 20.2, "d1");
+testPoint(200, 20.4, "d2");
+testPoint(200, 21, "d2");
+
+testPoint(200, 70, "d3");
+testPoint(200, 70.6, "d3");
+testPoint(200, 70.8, "d4");
+testPoint(200, 71, "d4");
+</script>
+</pre>
+</body>
+</html>
+