diff --git a/AppKit/CPWebView.j b/AppKit/CPWebView.j index d8c7dff81..9da31436e 100644 --- a/AppKit/CPWebView.j +++ b/AppKit/CPWebView.j @@ -171,7 +171,32 @@ CPWebViewScrollNative = 2; [self _resizeWebFrame]; } -- (BOOL)_resizeWebFrame +- (void)_attachScrollEventIfNecessary +{ + if (_scrollMode !== CPWebViewScrollAppKit) + return; + + var win = null; + try { win = [self DOMWindow]; } catch (e) {} + + if (win && win.addEventListener) + { + var scrollEventHandler = function(anEvent) + { + var frameBounds = [self bounds], + frameCenter = CGPointMake(CGRectGetMidX(frameBounds), CGRectGetMidY(frameBounds)), + windowOrigin = [self convertPoint:frameCenter toView:nil], + globalOrigin = [[self window] convertBaseToBridge:windowOrigin]; + + anEvent._overrideLocation = globalOrigin; + [[[self window] platformWindow] scrollEvent:anEvent]; + }; + + win.addEventListener("DOMMouseScroll", scrollEventHandler, false); + } +} + +- (void)_resizeWebFrame { if (_scrollMode === CPWebViewScrollAppKit) { @@ -320,7 +345,8 @@ CPWebViewScrollNative = 2; - (void)_finishedLoading { [self _resizeWebFrame]; - + [self _attachScrollEventIfNecessary]; + [[CPNotificationCenter defaultCenter] postNotificationName:CPWebViewProgressFinishedNotification object:self]; if ([_frameLoadDelegate respondsToSelector:@selector(webView:didFinishLoadForFrame:)]) diff --git a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j index 96c542885..a0b9403bb 100644 --- a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j +++ b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j @@ -851,12 +851,13 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop]; if(!aDOMEvent) aDOMEvent = window.event; + var location = nil; if (CPFeatureIsCompatible(CPJavaScriptMouseWheelValues_8_15)) { - var x = 0.0, - y = 0.0, + var x = aDOMEvent._offsetX || 0.0, + y = aDOMEvent._offsetY || 0.0, element = aDOMEvent.target; - + while (element.nodeType !== 1) element = element.parentNode; @@ -870,11 +871,13 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop]; } while (element = element.offsetParent); } - var location = _CGPointMake((x + ((aDOMEvent.clientX - 8) / 15)), (y + ((aDOMEvent.clientY - 8) / 15))); + location = _CGPointMake((x + ((aDOMEvent.clientX - 8) / 15)), (y + ((aDOMEvent.clientY - 8) / 15))); } + else if (aDOMEvent._overrideLocation) + location = aDOMEvent._overrideLocation; else - var location = _CGPointMake(aDOMEvent.clientX, aDOMEvent.clientY); - + location = _CGPointMake(aDOMEvent.clientX, aDOMEvent.clientY); + var deltaX = 0.0, deltaY = 0.0, windowNumber = 0, @@ -883,7 +886,7 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop]; (aDOMEvent.ctrlKey ? CPControlKeyMask : 0) | (aDOMEvent.altKey ? CPAlternateKeyMask : 0) | (aDOMEvent.metaKey ? CPCommandKeyMask : 0); - + StopDOMEventPropagation = YES; var theWindow = [self hitTest:location];