WebKit/mac:
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Aug 2008 00:50:13 +0000 (00:50 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Aug 2008 00:50:13 +0000 (00:50 +0000)
2008-08-27  Robert Kroeger  <rjkroege@liqui.org>

        Tweaked by Sam Weinig.

        Reviewed by Eric Seidel.

        Fix https://bugs.webkit.org/show_bug.cgi?id=6595
        <rdar://problem/4432150>
        Right-click does not fire mouseup event

        Adds a rightMouseUp handler to the WebHTMLView.

        The added method generates mouseup events for button 2.  The result
        is that webkit will deliver mousedown and mouseup events for button
        2 in a fashion identical to FireFox and will retain event ordering
        identical to Internet Explorer.

        Test: fast/events/mouseup-from-button2.html

        * WebView/WebHTMLView.mm:
        (-[WebHTMLView rightMouseUp:]):

LayoutTests:

2008-08-27  Robert Kroeger  <rjkroege@liqui.org>

        Reviewed by Eric Seidel.

        Test for https://bugs.webkit.org/show_bug.cgi?id=6595

        * fast/events/mouseup-from-button2-expected.txt: Added.
        * fast/events/mouseup-from-button2.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@35956 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/events/mouseup-from-button2-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/mouseup-from-button2.html [new file with mode: 0644]
WebKit/mac/ChangeLog
WebKit/mac/WebView/WebHTMLView.mm

index 01e1365..20681e3 100644 (file)
@@ -1,3 +1,12 @@
+2008-08-27  Robert Kroeger  <rjkroege@liqui.org>
+
+        Reviewed by Eric Seidel.
+
+        Test for https://bugs.webkit.org/show_bug.cgi?id=6595
+
+        * fast/events/mouseup-from-button2-expected.txt: Added.
+        * fast/events/mouseup-from-button2.html: Added.
+
 2008-08-26  Simon Fraser  <simon.fraser@apple.com>
 
         Reviewed by Eric Seidel
diff --git a/LayoutTests/fast/events/mouseup-from-button2-expected.txt b/LayoutTests/fast/events/mouseup-from-button2-expected.txt
new file mode 100644 (file)
index 0000000..c3d4079
--- /dev/null
@@ -0,0 +1,16 @@
+This test verifies that a right mousebutton click generates a mousedown, context and mouseup event.
+
+If the test passes, you'll see a PASS message below.
+
+To run this test in Safari:
+
+Right mouse down inside the box.
+Right mouse up.
+box
+
+type: mousedown, button: 0, 
+type: mouseup, button: 0, 
+type: click, button: 0, 
+type: mousedown, button: 2, 
+type: mouseup, button: 2, 
+type: mousedown, button: 2, 
diff --git a/LayoutTests/fast/events/mouseup-from-button2.html b/LayoutTests/fast/events/mouseup-from-button2.html
new file mode 100644 (file)
index 0000000..696f7bb
--- /dev/null
@@ -0,0 +1,104 @@
+<p>This test verifies that a right mousebutton click generates a mousedown, context and mouseup event.</p>
+
+</p>
+<p>If the test passes, you'll see a PASS message below.
+</p>
+
+<p>To run this test in Safari:
+<ol>
+    <li>Right mouse down inside the box.</li>
+    <li>Right mouse up.</li>
+</ol>
+</p>
+<hr>
+<style id="mystyle">
+  .test-box {
+    border: solid;
+  }
+</style>
+<div class="test-box" id="click_target-1">box</div>
+<pre id="log"></pre>
+
+<script id="cody">
+
+/**
+ * Base namespace for test
+ */
+var rlightclickbug = rlightclickbug || {}; 
+
+/**
+ * Swallows an event.
+ */
+rlightclickbug.swallow = function(event) {
+  event.preventDefault && event.preventDefault();
+  event.stopImmediatePropagation && event.stopImmediatePropagation();
+  event.stopPropagation && event.stopPropagation();
+  event.preventBubble && event.preventBubble();
+  return false;
+};
+
+/**
+ * Dumps out a single line summary of a mouse event
+ */
+rlightclickbug.dumpShortEvent = function(event) {
+  var values = []
+  var keys = ['type', 'button'];
+  for (var i = 0; i < keys.length; i++) {
+    values.push(keys[i]);
+    values.push(': ');
+    values.push(event[keys[i]]);
+    values.push(', ');
+  }
+  return values.join('');
+};
+
+/**
+ * Writes a log message to the screen.
+ */
+rlightclickbug.logme = function(m) {
+  var loggy = document.getElementById('log');
+  loggy.innerHTML += ('\n' + m);
+};
+
+var _captureMouseEvents = function(event) {
+  rlightclickbug.logme(rlightclickbug.dumpShortEvent(event));
+  return rlightclickbug.swallow(event);
+};
+
+
+function main()
+{
+  var targetBox = document.getElementById('click_target-1');
+  
+  targetBox.addEventListener("mouseup", _captureMouseEvents, false);
+  targetBox.addEventListener("mousedown", _captureMouseEvents, false);
+  targetBox.addEventListener("click", _captureMouseEvents, false);
+  targetBox.addEventListener("contextmenu", _captureMouseEvents, false);
+    
+  if (window.layoutTestController)
+      layoutTestController.dumpAsText();
+      
+  if (window.eventSender) {
+      // Confirm that left button works properly     
+      eventSender.mouseMoveTo(targetBox.offsetLeft + 5,
+          targetBox.offsetTop + 5); // in box
+      eventSender.mouseDown();
+      eventSender.mouseUp();
+      
+      // Confirm that right button works properly
+      eventSender.mouseDown(2);
+      eventSender.mouseUp(2);
+      
+      // Confirm that moving mouse while down outside of box 
+      // does not fire a mouseup event.
+      eventSender.mouseDown(2);
+      eventSender.mouseMoveTo(0, 0); // outside of box
+      eventSender.mouseUp(2);
+
+      // order in IE is mousedown contextmenu mouseup
+  }
+}
+
+
+main();
+</script>
index 1e4cf37..fb4128a 100644 (file)
@@ -1,3 +1,25 @@
+2008-08-27  Robert Kroeger  <rjkroege@liqui.org>
+
+        Tweaked by Sam Weinig.
+
+        Reviewed by Eric Seidel.
+
+        Fix https://bugs.webkit.org/show_bug.cgi?id=6595
+        <rdar://problem/4432150>
+        Right-click does not fire mouseup event
+
+        Adds a rightMouseUp handler to the WebHTMLView.
+
+        The added method generates mouseup events for button 2.  The result
+        is that webkit will deliver mousedown and mouseup events for button
+        2 in a fashion identical to FireFox and will retain event ordering
+        identical to Internet Explorer.
+
+        Test: fast/events/mouseup-from-button2.html
+
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView rightMouseUp:]):
+
 2008-08-27  Timothy Hatcher  <timothy@apple.com>
 
         Add support for support for -webkit-appearance: default-button on the Mac platform.
index 09fb3e1..1c79542 100644 (file)
@@ -2834,6 +2834,14 @@ static void _updateFocusedAndActiveStateTimerCallback(CFRunLoopTimerRef timer, v
     [self layoutToMinimumPageWidth:0.0f maximumPageWidth:0.0f adjustingViewSize:NO];
 }
 
+// Deliver mouseup events to the DOM for button 2.
+- (void)rightMouseUp:(NSEvent *)event
+{
+    [super rightMouseUp:event];
+    if (Frame* coreframe = core([self _frame]))
+        coreframe->eventHandler()->mouseUp(event);
+}
+
 - (NSMenu *)menuForEvent:(NSEvent *)event
 {
     [_private->compController endRevertingChange:NO moveLeft:NO];