diff --git a/AppKit/CPCursor.j b/AppKit/CPCursor.j index ce7e47b24..f5e67f692 100755 --- a/AppKit/CPCursor.j +++ b/AppKit/CPCursor.j @@ -12,6 +12,8 @@ Implemented class methods: Opera : All except resizeLeftRightCursor resizeUpDownCursor operationNotAllowedCursor dragCopyCursor dragLinkCursor contextualMenuCursor openHandCursor closedHandCursor disappearingItemCursor // Opera does not support url cursors so these won't work with images */ +#include "Platform/Platform.h" + var currentCursor = nil, cursorStack = [], cursors = {}, @@ -186,12 +188,12 @@ var currentCursor = nil, + (void)hide { - document.body.style.cursor = 'none'; // Not supported in IE + [self _setCursorCSS:"none"]; // Not supported in IE } + (void)unhide { - document.body.style.cursor = [currentCursor _cssString]; + [self _setCursorCSS:[currentCursor _cssString]] } + (void)setHiddenUntilMouseMoves:(BOOL)flag @@ -217,17 +219,25 @@ var currentCursor = nil, - (void)set { - document.body.style.cursor = _cssString; currentCursor = self; #if PLATFORM(DOM) - var platformWindows = [[CPPlatformWindow visiblePlatformWindows] allObjects]; - for (var i = 0, count = [platformWindows count]; i < count; i++) - platformWindows[i]._DOMWindow.document.body.style.cursor = _cssString; + [[self class] _setCursorCSS:_cssString]; #endif } ++ (void)_setCursorCSS:(CPString)aString +{ +#if PLATFORM(DOM) + [CPPlatformWindow primaryPlatformWindow]._DOMBodyElement.style.cursor = aString; + + var platformWindows = [[CPPlatformWindow visiblePlatformWindows] allObjects]; + for (var i = 0, count = [platformWindows count]; i < count; i++) + platformWindows[i]._DOMBodyElement.style.cursor = aString; +#endif +} + - (void)push { currentCursor = cursorStack.push(self); diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index 619c12d08..e647e542f 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -501,11 +501,11 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); if (document.attachEvent) { - CPTextFieldCachedSelectStartFunction = document.body.onselectstart; - CPTextFieldCachedDragFunction = document.body.ondrag; + CPTextFieldCachedSelectStartFunction = [[self window] platformWindow]._DOMBodyElement.onselectstart; + CPTextFieldCachedDragFunction = [[self window] platformWindow]._DOMBodyElement.ondrag; - document.body.ondrag = function () {}; - document.body.onselectstart = function () {}; + [[self window] platformWindow]._DOMBodyElement.ondrag = function () {}; + [[self window] platformWindow]._DOMBodyElement.onselectstart = function () {}; } [self textDidFocus:[CPNotification notificationWithName:CPTextFieldDidFocusNotification object:self userInfo:nil]]; @@ -548,8 +548,8 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); CPTextFieldCachedSelectStartFunction = nil; CPTextFieldCachedDragFunction = nil; - document.body.ondrag = CPTextFieldCachedDragFunction - document.body.onselectstart = CPTextFieldCachedSelectStartFunction + [[self window] platformWindow]._DOMBodyElement.ondrag = CPTextFieldCachedDragFunction; + [[self window] platformWindow]._DOMBodyElement.onselectstart = CPTextFieldCachedSelectStartFunction; } #endif diff --git a/AppKit/Jakefile b/AppKit/Jakefile index bed91b589..169c19d20 100644 --- a/AppKit/Jakefile +++ b/AppKit/Jakefile @@ -6,6 +6,9 @@ $BUILD_PATH = FILE.join($BUILD_DIR, $CONFIGURATION, 'AppKit'); AppKitFiles = new FileList("**/*.j").exclude('CoreGraphics/CGContextCanvas.j', 'CoreGraphics/CGContextVML.j', 'Themes/**/*', 'Tools/**/*', "Platform/DOM/CPPlatform.j", "Platform/DOM/CPPlatformString.j"); +FIXME_fileDependency (FILE.join("Platform", "CPPlatform.j"), FILE.join("Platform", "DOM", "CPPlatform.j")); +FIXME_fileDependency (FILE.join("Platform", "CPPlatformString.j"), FILE.join("Platform", "DOM", "CPPlatformString.j")); + appKitTask = framework ("AppKit", function(appKitTask) { appKitTask.setBuildIntermediatesPath(FILE.join($BUILD_DIR, "AppKit.build", $CONFIGURATION)) diff --git a/AppKit/Platform/DOM/CPPlatform.j b/AppKit/Platform/DOM/CPPlatform.j index e22819943..535644ea2 100644 --- a/AppKit/Platform/DOM/CPPlatform.j +++ b/AppKit/Platform/DOM/CPPlatform.j @@ -22,7 +22,8 @@ CPPlatformDidClearBodyElementNotification = @"CPPlatformDidClearBodyElementNotification"; -var screenNeedsInitialization = NO; +var screenNeedsInitialization = NO, + mainBodyElement = nil; @implementation CPPlatform : CPBasePlatform { @@ -75,6 +76,14 @@ var screenNeedsInitialization = NO; window.cpHide(); } ++ (DOMElement)mainBodyElement +{ + if (!mainBodyElement) + mainBodyElement = document.getElementById("cappuccino-body") || document.body; + + return mainBodyElement; +} + + (void)initializeScreenIfNecessary { if (!screenNeedsInitialization) @@ -82,11 +91,11 @@ var screenNeedsInitialization = NO; screenNeedsInitialization = NO; - var DOMBodyElement = document.body; + var bodyElement = [self mainBodyElement]; // Get rid of any of the original contents of the page. - DOMBodyElement.innerHTML = ""; - DOMBodyElement.style.overflow = "hidden"; + bodyElement.innerHTML = ""; + bodyElement.style.overflow = "hidden"; if (document.documentElement) document.documentElement.style.overflow = "hidden"; diff --git a/AppKit/Platform/DOM/CPPlatformString.j b/AppKit/Platform/DOM/CPPlatformString.j index 595ae184c..0e44f17d7 100644 --- a/AppKit/Platform/DOM/CPPlatformString.j +++ b/AppKit/Platform/DOM/CPPlatformString.j @@ -56,7 +56,9 @@ var DOMSpanElement = nil, DOMIFrameElement.style.overflow = "hidden"; DOMIFrameElement.style.zIndex = 100000000000; - document.body.appendChild(DOMIFrameElement); + var bodyElement = [CPPlatform mainBodyElement]; + + bodyElement.appendChild(DOMIFrameElement); var DOMIFrameDocument = (DOMIFrameElement.contentDocument || DOMIFrameElement.contentWindow.document); diff --git a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j index 4184247c6..152373698 100644 --- a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j +++ b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j @@ -264,7 +264,7 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop]; { var theDocument = _DOMWindow.document; - _DOMBodyElement = theDocument.body; + _DOMBodyElement = theDocument.getElementById("cappuccino-body") || theDocument.body; // FIXME: Always do this? if ([CPPlatform supportsDragAndDrop]) @@ -401,8 +401,8 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop]; _DOMWindow.onmousewheel = scrollEventCallback; theDocument.onmousewheel = scrollEventCallback; - theDocument.body.ondrag = function () { return NO; }; - theDocument.body.onselectstart = function () { return _DOMWindow.event.srcElement === _DOMPasteboardElement; }; + _DOMBodyElement.ondrag = function () { return NO; }; + _DOMBodyElement.onselectstart = function () { return _DOMWindow.event.srcElement === _DOMPasteboardElement; }; _DOMWindow.attachEvent("onbeforeunload", function() { @@ -423,8 +423,8 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop]; _DOMWindow.onmousewheel = NULL; theDocument.onmousewheel = NULL; - theDocument.body.ondrag = NULL; - theDocument.body.onselectstart = NULL; + _DOMBodyElement.ondrag = NULL; + _DOMBodyElement.onselectstart = NULL; //_DOMWindow.removeEvent("beforeunload", this); @@ -462,7 +462,7 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop]; _DOMWindow.cpSetShadowStyle(_shadowStyle); } - _DOMWindow.document.body.style.cursor = [[CPCursor currentCursor] _cssString]; + _DOMBodyElement.style.cursor = [[CPCursor currentCursor] _cssString]; [self registerDOMWindow]; } @@ -497,7 +497,7 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop]; DOMDragElement.style.left = -_CGRectGetWidth(draggedWindowFrame) + "px"; DOMDragElement.style.top = -_CGRectGetHeight(draggedWindowFrame) + "px"; - document.body.appendChild(DOMDragElement); + _DOMBodyElement.appendChild(DOMDragElement); var draggingOffset = [dragServer draggingOffset]; diff --git a/Tests/Manual/CPCursor/index.html b/Tests/Manual/CPCursor/index.html index ffac21241..6d8fd04a1 100644 --- a/Tests/Manual/CPCursor/index.html +++ b/Tests/Manual/CPCursor/index.html @@ -39,29 +39,31 @@
-