diff --git a/AppKit/CPClipView.j b/AppKit/CPClipView.j index 655d3c36c..93f8aacd6 100644 --- a/AppKit/CPClipView.j +++ b/AppKit/CPClipView.j @@ -46,56 +46,12 @@ return; if (_documentView) - { - [self _removeObserverDocumentView:_documentView]; [_documentView removeFromSuperview]; - } _documentView = aView; if (_documentView) - { [self addSubview:_documentView]; - [self _observeDocumentView]; - } -} - -- (void)_observeDocumentView -{ - if (!_documentView) - return; - - var defaultCenter = [CPNotificationCenter defaultCenter]; - - [_documentView setPostsFrameChangedNotifications:YES]; - [_documentView setPostsBoundsChangedNotifications:YES]; - - [defaultCenter - addObserver:self - selector:@selector(viewFrameChanged:) - name:CPViewFrameDidChangeNotification - object:_documentView]; - - [defaultCenter - addObserver:self - selector:@selector(viewBoundsChanged:) - name:CPViewBoundsDidChangeNotification - object:_documentView]; -} - -- (void)_removeObserverDocumentView:(CPView)aDocumentView -{ - var defaultCenter = [CPNotificationCenter defaultCenter]; - - [defaultCenter - removeObserver:self - name:CPViewFrameDidChangeNotification - object:aDocumentView]; - - [defaultCenter - removeObserver:self - name:CPViewBoundsDidChangeNotification - object:aDocumentView]; } /*! @@ -256,7 +212,6 @@ var CPClipViewDocumentViewKey = @"CPScrollViewDocumentView"; // Don't call setDocumentView: here. It calls addSubview:, but it's A) not necessary since the // view hierarchy is fully encoded and B) dangerous if the subview is not fully decoded. _documentView = [aCoder decodeObjectForKey:CPClipViewDocumentViewKey]; - [self _observeDocumentView]; } return self; diff --git a/AppKit/CPView.j b/AppKit/CPView.j index 1a600667c..7649b45ca 100644 --- a/AppKit/CPView.j +++ b/AppKit/CPView.j @@ -172,6 +172,7 @@ var CPViewFlags = { }, BOOL _postsBoundsChangedNotifications; BOOL _inhibitFrameAndBoundsChangedNotifications; BOOL _inLiveResize; + BOOL _isSuperviewAClipView; #if PLATFORM(DOM) DOMElement _DOMElement; @@ -821,6 +822,8 @@ var CPViewFlags = { }, */ - (void)viewWillMoveToSuperview:(CPView)aView { + _isSuperviewAClipView = [aView isKindOfClass:[CPClipView class]]; + [self _removeObservers]; if (aView) @@ -952,6 +955,9 @@ var CPViewFlags = { }, if (_postsFrameChangedNotifications) [CachedNotificationCenter postNotificationName:CPViewFrameDidChangeNotification object:self]; + + if (_isSuperviewAClipView) + [[self superview] viewFrameChanged:[[CPNotification alloc] initWithName:CPViewFrameDidChangeNotification object:self userInfo:nil]]; } /*! @@ -1014,6 +1020,9 @@ var CPViewFlags = { }, if (_postsFrameChangedNotifications && !_inhibitFrameAndBoundsChangedNotifications) [CachedNotificationCenter postNotificationName:CPViewFrameDidChangeNotification object:self]; + if (_isSuperviewAClipView && !_inhibitFrameAndBoundsChangedNotifications) + [[self superview] viewFrameChanged:[[CPNotification alloc] initWithName:CPViewFrameDidChangeNotification object:self userInfo:nil]]; + #if PLATFORM(DOM) var transform = _superview ? _superview._boundsTransform : NULL; @@ -1173,6 +1182,9 @@ var CPViewFlags = { }, if (_postsFrameChangedNotifications && !_inhibitFrameAndBoundsChangedNotifications) [CachedNotificationCenter postNotificationName:CPViewFrameDidChangeNotification object:self]; + + if (_isSuperviewAClipView && !_inhibitFrameAndBoundsChangedNotifications) + [[self superview] viewFrameChanged:[[CPNotification alloc] initWithName:CPViewFrameDidChangeNotification object:self userInfo:nil]]; } /*! @@ -1207,6 +1219,9 @@ var CPViewFlags = { }, if (_postsBoundsChangedNotifications) [CachedNotificationCenter postNotificationName:CPViewBoundsDidChangeNotification object:self]; + + if (_isSuperviewAClipView) + [[self superview] viewBoundsChanged:[[CPNotification alloc] initWithName:CPViewBoundsDidChangeNotification object:self userInfo:nil]]; } /*! @@ -1269,6 +1284,9 @@ var CPViewFlags = { }, if (_postsBoundsChangedNotifications && !_inhibitFrameAndBoundsChangedNotifications) [CachedNotificationCenter postNotificationName:CPViewBoundsDidChangeNotification object:self]; + + if (_isSuperviewAClipView && !_inhibitFrameAndBoundsChangedNotifications) + [[self superview] viewBoundsChanged:[[CPNotification alloc] initWithName:CPViewBoundsDidChangeNotification object:self userInfo:nil]]; } /*! @@ -1307,6 +1325,9 @@ var CPViewFlags = { }, if (_postsBoundsChangedNotifications && !_inhibitFrameAndBoundsChangedNotifications) [CachedNotificationCenter postNotificationName:CPViewBoundsDidChangeNotification object:self]; + + if (_isSuperviewAClipView && !_inhibitFrameAndBoundsChangedNotifications) + [[self superview] viewBoundsChanged:[[CPNotification alloc] initWithName:CPViewBoundsDidChangeNotification object:self userInfo:nil]]; }