From 0fff3bade6d0868d8a04712c10e6f8fe967dfaa1 Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Sat, 30 May 2009 23:18:48 -0700 Subject: [PATCH] Support for new CPEvent mechanism. Reviewed by me. --- AppKit/Platform/DOM/CPDOMWindowBridge.j | 28 ++++++++++--------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/AppKit/Platform/DOM/CPDOMWindowBridge.j b/AppKit/Platform/DOM/CPDOMWindowBridge.j index 3a8d46b14..e86944001 100644 --- a/AppKit/Platform/DOM/CPDOMWindowBridge.j +++ b/AppKit/Platform/DOM/CPDOMWindowBridge.j @@ -351,7 +351,7 @@ var CPDOMWindowGetFrame, theWindow = candidateWindow; } } - + return theWindow; } @@ -462,7 +462,7 @@ var CTRL_KEY_CODE = 17; var theType = _overriddenEventType || aDOMEvent.type; // IE's event order is down, up, up, dblclick, so we have create these events artificially. - if (theType == CPDOMEventDoubleClick) + if (theType === CPDOMEventDoubleClick) { _overriddenEventType = CPDOMEventMouseDown; [self _bridgeMouseEvent:aDOMEvent]; @@ -495,7 +495,7 @@ var CTRL_KEY_CODE = 17; { var theWindow = [self hitTest:location]; - if (aDOMEvent.type == CPDOMEventMouseDown && theWindow) + if ((aDOMEvent.type === CPDOMEventMouseDown) && theWindow) _mouseDownWindow = theWindow; windowNumber = [theWindow windowNumber]; @@ -510,12 +510,10 @@ var CTRL_KEY_CODE = 17; } switch (theType) - { + { case CPDOMEventMouseUp: if(_mouseIsDown) { - event = [CPEvent mouseEventWithType:CPLeftMouseUp location:location modifierFlags:modifierFlags - timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:-1 - clickCount:CPDOMEventGetClickCount(_lastMouseUp, timestamp, location) pressure:0]; + event = _CPEventFromNativeMouseEvent(aDOMEvent, CPLeftMouseUp, location, modifierFlags, timestamp, windowNumber, nil, -1, CPDOMEventGetClickCount(_lastMouseUp, timestamp, location), 0); _mouseIsDown = NO; _lastMouseUp = event; @@ -547,9 +545,7 @@ var CTRL_KEY_CODE = 17; return; } - event = [CPEvent mouseEventWithType:CPLeftMouseDown location:location modifierFlags:modifierFlags - timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:-1 - clickCount:CPDOMEventGetClickCount(_lastMouseDown, timestamp, location) pressure:0]; + event = _CPEventFromNativeMouseEvent(aDOMEvent, CPLeftMouseDown, location, modifierFlags, timestamp, windowNumber, nil, -1, CPDOMEventGetClickCount(_lastMouseDown, timestamp, location), 0); _mouseIsDown = YES; _lastMouseDown = event; @@ -558,10 +554,8 @@ var CTRL_KEY_CODE = 17; case CPDOMEventMouseMoved: if (_DOMEventMode) return; - - event = [CPEvent mouseEventWithType:_mouseIsDown ? CPLeftMouseDragged : CPMouseMoved - location:location modifierFlags:modifierFlags timestamp:timestamp - windowNumber:windowNumber context:nil eventNumber:-1 clickCount:1 pressure:0]; + + event = _CPEventFromNativeMouseEvent(aDOMEvent, _mouseIsDown ? CPLeftMouseDragged : CPMouseMoved, location, modifierFlags, timestamp, windowNumber, nil, -1, 1, 0); break; } @@ -988,15 +982,15 @@ var CPDOMEventStop = function(aDOMEvent) // IE Model aDOMEvent.cancelBubble = true; aDOMEvent.returnValue = false; - + // W3C Model if (aDOMEvent.preventDefault) aDOMEvent.preventDefault(); - + if (aDOMEvent.stopPropagation) aDOMEvent.stopPropagation(); - if (aDOMEvent.type == CPDOMEventMouseDown) + if (aDOMEvent.type === CPDOMEventMouseDown) { CPSharedDOMWindowBridge._DOMFocusElement.focus(); CPSharedDOMWindowBridge._DOMFocusElement.blur();