From 22c931729b03e55fc3bbacb2f2d99cb67de494da Mon Sep 17 00:00:00 2001 From: Randall Luecke Date: Fri, 22 Jan 2010 10:50:29 -0500 Subject: [PATCH 1/4] Removed additional references to disabled HUD scrollbar knobs. --- AppKit/Themes/Aristo/ThemeDescriptors.j | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AppKit/Themes/Aristo/ThemeDescriptors.j b/AppKit/Themes/Aristo/ThemeDescriptors.j index 7554c0562..d709b2142 100644 --- a/AppKit/Themes/Aristo/ThemeDescriptors.j +++ b/AppKit/Themes/Aristo/ThemeDescriptors.j @@ -882,16 +882,16 @@ ] isVertical:NO]); - var knobDisabledColor = PatternColor([[CPThreePartImage alloc] initWithImageSlices: + /*var knobDisabledColor = PatternColor([[CPThreePartImage alloc] initWithImageSlices: [ [_CPCibCustomResource imageResourceWithName:"HUD/scroller-horizontal-knob-disabled-left.png" size:CGSizeMake(10.0, 15.0)], [_CPCibCustomResource imageResourceWithName:"HUD/scroller-horizontal-knob-disabled-center.png" size:CGSizeMake(1.0, 15.0)], [_CPCibCustomResource imageResourceWithName:"HUD/scroller-horizontal-knob-disabled-right.png" size:CGSizeMake(10.0, 15.0)] ] - isVertical:NO]); + isVertical:NO]);*/ [scroller setValue:knobColor forThemeAttribute:@"knob-color"]; - [scroller setValue:knobDisabledColor forThemeAttribute:@"knob-color" inState:CPThemeStateDisabled]; + //[scroller setValue:knobDisabledColor forThemeAttribute:@"knob-color" inState:CPThemeStateDisabled]; [scroller setFloatValue:0.1]; [scroller setKnobProportion:0.5]; From cf8989938cec69f2284a49423a3d41b191cdff51 Mon Sep 17 00:00:00 2001 From: Tom Robinson Date: Fri, 22 Jan 2010 18:38:25 -0800 Subject: [PATCH 2/4] Improved sizeOfString IE workaround --- AppKit/Platform/DOM/CPPlatformString.j | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/AppKit/Platform/DOM/CPPlatformString.j b/AppKit/Platform/DOM/CPPlatformString.j index 595ae184c..8219f6a59 100644 --- a/AppKit/Platform/DOM/CPPlatformString.j +++ b/AppKit/Platform/DOM/CPPlatformString.j @@ -44,14 +44,13 @@ var DOMSpanElement = nil, + (void)createDOMElements { var DOMIFrameElement = document.createElement("iframe"); - - DOMIFrameElement.name = name = "iframe_" + FLOOR(RAND() * 10000); + // necessary for Safari caching bug: + DOMIFrameElement.name = "iframe_" + FLOOR(RAND() * 10000); DOMIFrameElement.style.position = "absolute"; - DOMIFrameElement.style.left = "-1000px"; - DOMIFrameElement.style.top = "-1000px"; - // TODO: investigate a better way to make this work in IE: - DOMIFrameElement.style.width = "1000px"; - DOMIFrameElement.style.height = "1000px"; + DOMIFrameElement.style.left = "-100px"; + DOMIFrameElement.style.top = "-100px"; + DOMIFrameElement.style.width = "1px"; + DOMIFrameElement.style.height = "1px"; DOMIFrameElement.style.borderWidth = "0px"; DOMIFrameElement.style.overflow = "hidden"; DOMIFrameElement.style.zIndex = 100000000000; @@ -59,19 +58,24 @@ var DOMSpanElement = nil, document.body.appendChild(DOMIFrameElement); var DOMIFrameDocument = (DOMIFrameElement.contentDocument || DOMIFrameElement.contentWindow.document); - DOMIFrameDocument.write(""); DOMIFrameDocument.close(); - DOMSpanElement = DOMIFrameDocument.createElement("span"); + // IE needs this wide
to prevent unwanted text wrapping: + var DOMDivElement = DOMIFrameDocument.createElement("div"); + DOMDivElement.style.position = "absolute"; + DOMDivElement.style.width = "100000px"; + DOMIFrameDocument.body.appendChild(DOMDivElement); + + DOMSpanElement = DOMIFrameDocument.createElement("span"); DOMSpanElement.style.position = "absolute"; DOMSpanElement.style.whiteSpace = "pre"; DOMSpanElement.style.visibility = "visible"; DOMSpanElement.style.padding = "0px"; DOMSpanElement.style.margin = "0px"; - DOMIFrameDocument.body.appendChild(DOMSpanElement); + DOMDivElement.appendChild(DOMSpanElement); } + (void)platformDidClearBodyElement:(CPNotification)aNotification From 7ce72a31c566c164ca3ab526dc117d7254d1c6ed Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Fri, 22 Jan 2010 19:40:33 -0800 Subject: [PATCH 3/4] Rather than throwing out the entire cappuccino body, throw out a specific div if that div is available. ("cappuccino-body"). This let's external libraries, esp. flash ones, add things to the body without Cappuccino getting rid of them as soon as the page loads. Closes #421. --- AppKit/CPCursor.j | 22 ++++++--- AppKit/CPTextField.j | 12 ++--- AppKit/Jakefile | 3 ++ AppKit/Platform/DOM/CPPlatform.j | 17 +++++-- AppKit/Platform/DOM/CPPlatformString.j | 4 +- AppKit/Platform/DOM/CPPlatformWindow+DOM.j | 14 +++--- Tests/Manual/CPCursor/index.html | 46 ++++++++++--------- Tests/Manual/TableTest/index.html | 46 ++++++++++--------- .../Templates/Application/index-debug.html | 46 ++++++++++--------- .../Templates/Application/index.html | 46 ++++++++++--------- .../Templates/NibApplication/index-debug.html | 46 ++++++++++--------- .../Templates/NibApplication/index.html | 46 ++++++++++--------- .../ThemeDescriptor/index-debug.html | 46 ++++++++++--------- .../Templates/ThemeDescriptor/index.html | 46 ++++++++++--------- common.jake | 9 +++- 15 files changed, 247 insertions(+), 202 deletions(-) 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 @@ -
- - -