From 9dfdde674feb091c044f0efb8c7370de8fbdf187 Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Fri, 13 Nov 2009 17:39:16 -0800 Subject: [PATCH] Fix for off by one error in HTML 5 Safari drag and drop, as well as error when building with Rhino Narwhal. Reviewed by me. --- AppKit/CPCompatibility.j | 4 ++++ AppKit/CPWindow/CPWindow.j | 24 +++++++++++++++++++ AppKit/Platform/DOM/CPPlatformWindow+DOM.j | 9 ++++++- .../lib/objective-j/jake/bundletask.js | 4 ++-- 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/AppKit/CPCompatibility.j b/AppKit/CPCompatibility.j index b2636811d..685197808 100644 --- a/AppKit/CPCompatibility.j +++ b/AppKit/CPCompatibility.j @@ -56,6 +56,7 @@ CPOpacityRequiresFilterFeature = 1 << 24; //Internet explorer does not allow dynamically changing the type of an input element CPInputTypeCanBeChangedFeature = 1 << 25; +CPHTML5DragAndDropSourceYOffBy1 = 1 << 26; @@ -116,6 +117,9 @@ else if (USER_AGENT.indexOf("AppleWebKit/") != -1) if((USER_AGENT.indexOf("Safari") !== CPNotFound && (majorVersion > 525 || (majorVersion === 525 && minorVersion > 14))) || USER_AGENT.indexOf("Chrome") !== CPNotFound) PLATFORM_FEATURES |= CPJavascriptRemedialKeySupport; + + if (majorVersion < 532 || (majorVersion === 532 && minorVersion < 6)) + PLATFORM_FEATURES |= CPHTML5DragAndDropSourceYOffBy1; } // KHTML diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index 42c8426f7..b1039f76d 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -606,6 +606,30 @@ CPTexturedBackgroundWindowMask */ - (void)setFrame:(CGRect)aFrame display:(BOOL)shouldDisplay animate:(BOOL)shouldAnimate { + var value = aFrame.origin.x, + delta = value - FLOOR(value); + + if (delta) + aFrame.origin.x = value > 0.879 ? CEIL(value) : FLOOR(value); + + value = aFrame.origin.y; + delta = value - FLOOR(value); + + if (delta) + aFrame.origin.y = value > 0.879 ? CEIL(value) : FLOOR(value); + + value = aFrame.size.width; + delta = value - FLOOR(value); + + if (delta) + aFrame.size.width = value > 0.15 ? CEIL(value) : FLOOR(value); + + value = aFrame.size.height; + delta = value - FLOOR(value); + + if (delta) + aFrame.size.height = value > 0.15 ? CEIL(value) : FLOOR(value); + if (shouldAnimate) { var animation = [[_CPWindowFrameAnimation alloc] initWithWindow:self targetFrame:aFrame]; diff --git a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j index b8020c837..4b84cce51 100644 --- a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j +++ b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j @@ -381,7 +381,14 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop]; } else if (type === "drag") - [dragServer draggingSourceUpdatedWithGlobalLocation:[CPPlatform isBrowser] ? location : _CGPointMake(aDOMEvent.screenX, aDOMEvent.screenY)]; + { + var y = aDOMEvent.screenY; + + if (CPFeatureIsCompatible(CPHTML5DragAndDropSourceYOffBy1)) + y -= 1; + + [dragServer draggingSourceUpdatedWithGlobalLocation:[CPPlatform isBrowser] ? location : _CGPointMake(aDOMEvent.screenX, y)]; + } else if (type === "dragover" || type === "dragleave") { diff --git a/Objective-J/CommonJS/lib/objective-j/jake/bundletask.js b/Objective-J/CommonJS/lib/objective-j/jake/bundletask.js index cb1b6147c..0e0e3fa6b 100644 --- a/Objective-J/CommonJS/lib/objective-j/jake/bundletask.js +++ b/Objective-J/CommonJS/lib/objective-j/jake/bundletask.js @@ -627,10 +627,10 @@ BundleTask.prototype.defineStaticTask = function() } }, this); - fileStream.write("e;", { charset:"UTF-8" }); + fileStream.write("e;"); if (MHTMLContents.length > 0) - fileStream.write(MHTMLContents + "*/", { charset:"UTF-8" }); + fileStream.write(MHTMLContents + "*/"); fileStream.close(); });