From 4afbfc6e570106e3788c95462df5b9f0b1632084 Mon Sep 17 00:00:00 2001 From: Martin Carlberg Date: Wed, 11 Jul 2018 09:20:49 +0200 Subject: [PATCH 1/2] Revert "Removed: dead code and dom clutter from nativehost (#2608)" This reverts commit 5bfafaf241a4789d4fe143efbbc657faddb0c0f8. --- AppKit/Platform/CPPlatformWindow.j | 23 ++++++++++++++++++++++ AppKit/Platform/DOM/CPPlatformPasteboard.j | 1 + AppKit/Platform/DOM/CPPlatformString.j | 4 ++++ AppKit/Platform/DOM/CPPlatformWindow+DOM.j | 19 ++++++++++++++++++ 4 files changed, 47 insertions(+) diff --git a/AppKit/Platform/CPPlatformWindow.j b/AppKit/Platform/CPPlatformWindow.j index bf39de81a..16b1a4954 100644 --- a/AppKit/Platform/CPPlatformWindow.j +++ b/AppKit/Platform/CPPlatformWindow.j @@ -224,10 +224,18 @@ var PrimaryPlatformWindow = NULL; - (void)deminiaturize:(id)sender { +#if PLATFORM(DOM) + if (_DOMWindow && typeof _DOMWindow["cpDeminiaturize"] === "function") + _DOMWindow.cpDeminiaturize(); +#endif } - (void)miniaturize:(id)sender { +#if PLATFORM(DOM) + if (_DOMWindow && typeof _DOMWindow["cpMiniaturize"] === "function") + _DOMWindow.cpMiniaturize(); +#endif } - (void)moveWindow:(CPWindow)aWindow fromLevel:(int)fromLevel toLevel:(int)toLevel @@ -247,16 +255,31 @@ var PrimaryPlatformWindow = NULL; - (void)setLevel:(CPInteger)aLevel { _level = aLevel; + +#if PLATFORM(DOM) + if (_DOMWindow && _DOMWindow.cpSetLevel) + _DOMWindow.cpSetLevel(aLevel); +#endif } - (void)setHasShadow:(BOOL)shouldHaveShadow { _hasShadow = shouldHaveShadow; + +#if PLATFORM(DOM) + if (_DOMWindow && _DOMWindow.cpSetHasShadow) + _DOMWindow.cpSetHasShadow(shouldHaveShadow); +#endif } - (void)setShadowStyle:(int)aStyle { _shadowStyle = aStyle; + +#if PLATFORM(DOM) + if (_DOMWindow && _DOMWindow.cpSetShadowStyle) + _shadowStyle.cpSetShadowStyle(aStyle); +#endif } - (BOOL)supportsFullPlatformWindows diff --git a/AppKit/Platform/DOM/CPPlatformPasteboard.j b/AppKit/Platform/DOM/CPPlatformPasteboard.j index b1c57cb32..8d32fbccb 100644 --- a/AppKit/Platform/DOM/CPPlatformPasteboard.j +++ b/AppKit/Platform/DOM/CPPlatformPasteboard.j @@ -118,6 +118,7 @@ var hasEditableTarget = function(aDOMEvent) _DOMPasteboardElement.style.position = "absolute"; _DOMPasteboardElement.style.top = "-10000px"; _DOMPasteboardElement.style.zIndex = "999"; + _DOMPasteboardElement.className = "cpdontremove"; _DOMBodyElement.appendChild(_DOMPasteboardElement); diff --git a/AppKit/Platform/DOM/CPPlatformString.j b/AppKit/Platform/DOM/CPPlatformString.j index 98aca9178..fb440d36d 100644 --- a/AppKit/Platform/DOM/CPPlatformString.j +++ b/AppKit/Platform/DOM/CPPlatformString.j @@ -49,6 +49,7 @@ var DOMFixedWidthSpanElement = nil, bodyElement = [CPPlatform mainBodyElement]; DOMFlexibleWidthSpanElement = document.createElement("span"); + DOMFlexibleWidthSpanElement.className = "cpdontremove"; style = DOMFlexibleWidthSpanElement.style; style.position = "absolute"; style.left = "-100000px"; @@ -59,6 +60,7 @@ var DOMFixedWidthSpanElement = nil, style.whiteSpace = "pre"; DOMFixedWidthSpanElement = document.createElement("span"); + DOMFixedWidthSpanElement.className = "cpdontremove"; style = DOMFixedWidthSpanElement.style; style.display = "block"; style.position = "absolute"; @@ -94,6 +96,7 @@ var DOMFixedWidthSpanElement = nil, bodyElement = [CPPlatform mainBodyElement]; DOMMetricsDivElement = document.createElement("div"); + DOMMetricsDivElement.className = "cpdontremove"; style = DOMMetricsDivElement.style; style.position = "absolute"; style.left = "-100000px"; @@ -110,6 +113,7 @@ var DOMFixedWidthSpanElement = nil, var imgPath = [[CPBundle bundleForClass:[CPView class]] pathForResource:@"empty.png"]; DOMMetricsImgElement = document.createElement("img"); + DOMMetricsImgElement.className = "cpdontremove"; DOMMetricsImgElement.setAttribute("src", imgPath); DOMMetricsImgElement.setAttribute("width", "1"); DOMMetricsImgElement.setAttribute("height", "1"); diff --git a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j index c2c97bb26..d3784af63 100644 --- a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j +++ b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j @@ -247,6 +247,9 @@ _CPPlatformWindowWillCloseNotification = @"_CPPlatformWindowWillCloseNotificatio if (!_DOMWindow) return [self contentRect]; + if (_DOMWindow.cpFrame) + return _DOMWindow.cpFrame(); + var contentRect = CGRectMakeZero(); if (window.screenTop) @@ -275,6 +278,9 @@ _CPPlatformWindowWillCloseNotification = @"_CPPlatformWindowWillCloseNotificatio if (!_DOMWindow) return; + if (typeof _DOMWindow["cpSetFrame"] === "function") + return _DOMWindow.cpSetFrame([self contentRect]); + var origin = [self contentRect].origin, nativeOrigin = [self nativeContentRect].origin; @@ -309,6 +315,7 @@ _CPPlatformWindowWillCloseNotification = @"_CPPlatformWindowWillCloseNotificatio _DOMFocusElement.style.zIndex = "-1000"; _DOMFocusElement.style.opacity = "0"; _DOMFocusElement.style.filter = "alpha(opacity=0)"; + _DOMFocusElement.className = "cpdontremove"; _DOMBodyElement.appendChild(_DOMFocusElement); @@ -323,6 +330,7 @@ _CPPlatformWindowWillCloseNotification = @"_CPPlatformWindowWillCloseNotificatio _DOMEventGuard.style.height = "100%"; _DOMEventGuard.style.zIndex = "999"; _DOMEventGuard.style.display = "none"; + _DOMEventGuard.className = "cpdontremove"; _DOMBodyElement.appendChild(_DOMEventGuard); // We get scrolling deltas from this element @@ -336,6 +344,7 @@ _CPPlatformWindowWillCloseNotification = @"_CPPlatformWindowWillCloseNotificatio //_DOMScrollingElement.style.backgroundColor = "rgba(0,0,0,1.0)"; // debug help. _DOMScrollingElement.style.opacity = "0"; _DOMScrollingElement.style.filter = "alpha(opacity=0)"; + _DOMScrollingElement.className = "cpdontremove"; _DOMBodyElement.appendChild(_DOMScrollingElement); var _DOMInnerScrollingElement = theDocument.createElement("div"); @@ -567,12 +576,22 @@ _CPPlatformWindowWillCloseNotification = @"_CPPlatformWindowWillCloseNotificatio [PlatformWindows addObject:self]; + // FIXME: cpSetFrame? _DOMWindow.document.write(''); _DOMWindow.document.close(); if (self != [CPPlatformWindow primaryPlatformWindow]) _DOMWindow.document.title = _title; + if (![CPPlatform isBrowser]) + { + _DOMWindow.cpWindowNumber = [self._only windowNumber]; + _DOMWindow.cpSetFrame(_contentRect); + _DOMWindow.cpSetLevel(_level); + _DOMWindow.cpSetHasShadow(_hasShadow); + _DOMWindow.cpSetShadowStyle(_shadowStyle); + } + [self registerDOMWindow]; _DOMBodyElement.style.cursor = [[CPCursor currentCursor] _cssString]; From 53a52da70981f80d01df700a150f9d51041d6500 Mon Sep 17 00:00:00 2001 From: bedalton Date: Thu, 2 Aug 2018 23:28:05 -0700 Subject: [PATCH 2/2] Fixed: _CPObjectAnimator initialize method did not match superclass return (#2743) * Fixed: _CPObjectAnimator initialize method did not match superclass return _CPObject animator labeled return type as BOOL, not only is this value not returned, but the super class CPProxy's initialize method returns void. Changed return type to void in _CPObject animator, to match superclass --- AppKit/CoreAnimation/_CPObjectAnimator.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppKit/CoreAnimation/_CPObjectAnimator.j b/AppKit/CoreAnimation/_CPObjectAnimator.j index 944327057..192735f42 100644 --- a/AppKit/CoreAnimation/_CPObjectAnimator.j +++ b/AppKit/CoreAnimation/_CPObjectAnimator.j @@ -20,7 +20,7 @@ var _supportsCSSAnimations = null; id _target; } -+ (BOOL)initialize ++ (void)initialize { if ([self class] !== [_CPObjectAnimator class]) return;