Fixed: method addObservers and removeObservers were not call all the time when ordering or not a window

This commit is contained in:
Alexandre Wilhelm committed 2014-12-01 16:07:48 -08:00
1 parent e4bfd0ef5e
commit 1df0da7509
2 files changed
+32 -5

No files matched your search

+24 -5
View File
@@ -907,18 +907,21 @@ CPTexturedBackgroundWindowMask
- (void)_orderFront
{
[[self contentView] _addObservers];
#if PLATFORM(DOM)
// -dw- if a sheet is clicked, the parent window should come up too
if (_isSheet)
[_parentView orderFront:self];
if (!_isVisible)
[self _setFrame:_frame display:YES animate:NO constrainWidth:YES constrainHeight:YES];
// Save the boolean since it will be updated in the method order:window:relativeTo:
var isVisible = _isVisible;
[_platformWindow orderFront:self];
[_platformWindow order:CPWindowAbove window:self relativeTo:nil];
// setFrame is set after ordering the window as this method can send some notifications
if (isVisible)
[self _setFrame:_frame display:YES animate:NO constrainWidth:YES constrainHeight:YES];
#endif
if (!CPApp._keyWindow)
@@ -937,8 +940,26 @@ CPTexturedBackgroundWindowMask
*/
- (void)_parentDidOrderInChild
{
}
/*
Called when the window is displayed in the DOM
*/
- (void)_windowWillBeAddedInTheDOM
{
[[self contentView] _addObservers];
}
/*
Called when the window is removed in the DOM
*/
- (void)_windowWillBeRemovedFromTheDOM
{
[[self contentView] _removeObservers];
}
/*
Makes the receiver the last window in the screen ordering.
@param aSender the object that requested this
@@ -968,8 +989,6 @@ CPTexturedBackgroundWindowMask
if (!_isVisible)
return;
[[self contentView] _removeObservers];
if ([self isSheet])
{
// -dw- as in Cocoa, orderOut: detaches the sheet and animates out
@@ -1299,7 +1299,10 @@ var PreventScroll = true;
// When ordering out, ignore otherWindow, simply remove aWindow from its level.
// If layer is nil, this will be a no-op.
if (orderingMode === CPWindowOut)
{
[aWindow _windowWillBeRemovedFromTheDOM];
return [layer removeWindow:aWindow];
}
/*
If aWindow is a child of otherWindow and is not yet visible,
@@ -1345,6 +1348,8 @@ var PreventScroll = true;
if (otherWindow)
insertionIndex = orderingMode === CPWindowAbove ? otherWindow._index + 1 : otherWindow._index;
[aWindow _windowWillBeAddedInTheDOM];
// Place the window at the appropriate index.
[layer insertWindow:aWindow atIndex:insertionIndex];
@@ -1395,6 +1400,9 @@ var PreventScroll = true;
var index = ordering === CPWindowAbove ? parent._index + 1 : parent._index;
if (!childWasVisible)
[child _windowWillBeAddInTheDOM];
[aLayer insertWindow:child atIndex:index];
if (!childWasVisible)