Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Bug 562554 - "Toolbar buttons with drop-down menus are still busted i…

…n SeaMonkey Modern Theme" [r=roc] [a=Mossop]
  • Loading branch information...
commit 2d7c7e684c55ee42ff717dea1994c7b9c28d4c0b 1 parent 1d05e42
Felipe Gomes authored May 01, 2010
14  layout/xul/base/src/nsBoxFrame.cpp
@@ -2150,7 +2150,7 @@ void nsDisplayXULEventRedirector::HitTest(nsDisplayListBuilder* aBuilder,
2150 2150
   nsTArray<nsIFrame*> outFrames;
2151 2151
   mList.HitTest(aBuilder, aRect, aState, &outFrames);
2152 2152
 
2153  
-  PRUint32 originalLength = aOutFrames->Length();
  2153
+  PRBool topMostAdded = PR_FALSE;
2154 2154
   PRUint32 localLength = outFrames.Length();
2155 2155
 
2156 2156
   for (PRUint32 i = 0; i < localLength; i++) {
@@ -2162,12 +2162,20 @@ void nsDisplayXULEventRedirector::HitTest(nsDisplayListBuilder* aBuilder,
2162 2162
                                nsGkAtoms::_true, eCaseMatters)) {
2163 2163
         // Events are allowed on 'frame', so let it go.
2164 2164
         aOutFrames->AppendElement(outFrames.ElementAt(i));
  2165
+        topMostAdded = PR_TRUE;
2165 2166
       }
2166 2167
     }
2167 2168
 
  2169
+    // If there was no hit on the topmost frame or its ancestors,
  2170
+    // add the target frame itself as the first candidate (see bug 562554).
  2171
+    if (!topMostAdded) {
  2172
+      topMostAdded = PR_TRUE;
  2173
+      aOutFrames->AppendElement(mTargetFrame);
  2174
+    }
  2175
+
2168 2176
   }
2169  
-  // If no hits were found, treat it as a hit on the target frame itself
2170  
-  if (aOutFrames->Length() == originalLength) {
  2177
+  // If no hits were found, treat it as a hit on the target frame itself.
  2178
+  if (localLength == 0) {
2171 2179
     aOutFrames->AppendElement(mTargetFrame);
2172 2180
   }
2173 2181
 }
1  toolkit/content/tests/widgets/Makefile.in
@@ -52,6 +52,7 @@ _TEST_FILES = 	test_bug360220.xul \
52 52
 		test_bug460942.xul \
53 53
 		test_bug509732.xul \
54 54
 		test_bug557987.xul\
  55
+		test_bug562554.xul \
55 56
 		test_button.xul \
56 57
 		test_closemenu_attribute.xul \
57 58
 		test_colorpicker_popup.xul \
84  toolkit/content/tests/widgets/test_bug562554.xul
... ...
@@ -0,0 +1,84 @@
  1
+<?xml version="1.0"?>
  2
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
  3
+<?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
  4
+<!--
  5
+  XUL Widget Test for bug 562554
  6
+  -->
  7
+<window title="Bug 557987" width="400" height="400"
  8
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  9
+  <script type="application/javascript" src="/MochiKit/packed.js"></script>
  10
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>  
  11
+  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
  12
+
  13
+  <toolbarbutton type="menu" id="toolbarmenu" height="200px">
  14
+    <menupopup id="menupopup" onpopupshowing="eventReceived('popupshowing'); return false;"/>
  15
+    <stack>
  16
+       <button width="100px" left="0px" height="30px" id="button1"
  17
+        allowevents="true" onclick="eventReceived('clickbutton1'); return false;"/>
  18
+
  19
+       <button width="100px" left="70px" id="button2"
  20
+        onclick="eventReceived('clickbutton2'); return false;"/>
  21
+    </stack>
  22
+  </toolbarbutton>
  23
+
  24
+  <!-- test results are displayed in the html:body -->
  25
+  <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
  26
+
  27
+<script type="application/javascript">
  28
+<![CDATA[
  29
+
  30
+SimpleTest.waitForExplicitFinish();
  31
+SimpleTest.waitForFocus(test);
  32
+
  33
+// Tests that mouse events are correctly dispatched to <toolbarbutton type="menu"/>
  34
+function test() {
  35
+  disableNonTestMouseEvents(true);
  36
+  nextTest();
  37
+}
  38
+
  39
+let tests = [
  40
+  // Click on the toolbarbutton itself - should call popupshowing
  41
+  function() synthesizeMouse($("toolbarmenu"), 10, 50, {}, window),
  42
+
  43
+  // Click on button1 which has allowevents="true" - should call clickbutton1
  44
+  function() synthesizeMouse($("button1"), 10, 15, {}, window),
  45
+
  46
+  // Click on button2 where it intersects with button1 - should call popupshowing
  47
+  function() synthesizeMouse($("button2"), 5, 15, {}, window),
  48
+
  49
+  // Click on button2 outside of intersection - should call popupshowing
  50
+  function() synthesizeMouse($("button2"), 50, 15, {}, window)
  51
+];
  52
+
  53
+function nextTest() {
  54
+  if (tests.length) {
  55
+    let func = tests.shift();
  56
+    func();
  57
+    SimpleTest.executeSoon(nextTest);
  58
+  } else {
  59
+    disableNonTestMouseEvents(false);
  60
+    SimpleTest.executeSoon(finishTest);
  61
+  }
  62
+}
  63
+
  64
+function finishTest() {
  65
+  is(eventCount.clickbutton1, 1, "Correct number of clicks on button 1");
  66
+  is(eventCount.clickbutton2, 0, "Correct number of clicks on button 2");
  67
+  is(eventCount.popupshowing, 3, "Correct number of popupshowing events received");
  68
+
  69
+  SimpleTest.finish();
  70
+}
  71
+
  72
+let eventCount = {
  73
+  popupshowing: 0,
  74
+  clickbutton1: 0,
  75
+  clickbutton2: 0
  76
+};
  77
+
  78
+function eventReceived(eventName) {
  79
+  eventCount[eventName]++;
  80
+}
  81
+
  82
+]]>
  83
+</script>
  84
+</window>

0 notes on commit 2d7c7e6

Please sign in to comment.
Something went wrong with that request. Please try again.