mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-18 15:55:36 +00:00
Bug 1491445 - Wrap vibrancy and nondraggable views inside container views. r=spohl
NSView hierarchy before: - window contentView - ChildView - NonDraggableView 1 - NonDraggableView 2 - EffectViewWithoutForegroundVibrancy 1 - EffectViewWithoutForegroundVibrancy 2 NSView hierarchy after: - window contentView - ChildView - ViewRegionContainerView - NonDraggableView 1 - NonDraggableView 2 - ViewRegionContainerView - EffectViewWithoutForegroundVibrancy 1 - EffectViewWithoutForegroundVibrancy 2 This allows us to give those container views a new sibling view which stays fixed in z-order with respect to the NSViews that get created by mNonDraggableRegion and mVibrancyManager. More specifically, I'm going to add a view for the drawing of our ChildView ("PixelHostingView") which is going to be a direct child of the Gecko "ChildView" and a sibling of the ViewRegionContainerViews; the PixelHostingView needs to always stay on top of the vibrancy views. Without the wrapper around the vibrancy views, whenever the vibrant region changes, a vibrant view would be placed on top of the PixelHostingView and the order would be wrong. Differential Revision: https://phabricator.services.mozilla.com/D19598 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
6c3be1079f
commit
5adfba9115
@ -201,6 +201,11 @@ class WidgetRenderingContext;
|
||||
// CGContext painting (i.e. non-accelerated).
|
||||
CGImageRef mTopLeftCornerMask;
|
||||
|
||||
// Subviews of self, which act as container views for vibrancy views and
|
||||
// non-draggable views.
|
||||
NSView* mVibrancyViewsContainer; // [STRONG]
|
||||
NSView* mNonDraggableViewsContainer; // [STRONG]
|
||||
|
||||
// Last pressure stage by trackpad's force click
|
||||
NSInteger mLastPressureStage;
|
||||
}
|
||||
@ -229,6 +234,9 @@ class WidgetRenderingContext;
|
||||
- (bool)preRender:(NSOpenGLContext*)aGLContext;
|
||||
- (void)postRender:(NSOpenGLContext*)aGLContext;
|
||||
|
||||
- (NSView*)vibrancyViewsContainer;
|
||||
- (NSView*)nonDraggableViewsContainer;
|
||||
|
||||
- (BOOL)isCoveringTitlebar;
|
||||
|
||||
- (void)viewWillStartLiveResize;
|
||||
|
@ -2327,7 +2327,7 @@ NSColor* nsChildView::VibrancyFillColorForThemeGeometryType(
|
||||
mozilla::VibrancyManager& nsChildView::EnsureVibrancyManager() {
|
||||
MOZ_ASSERT(mView, "Only call this once we have a view!");
|
||||
if (!mVibrancyManager) {
|
||||
mVibrancyManager = MakeUnique<VibrancyManager>(*this, mView);
|
||||
mVibrancyManager = MakeUnique<VibrancyManager>(*this, [mView vibrancyViewsContainer]);
|
||||
}
|
||||
return *mVibrancyManager;
|
||||
}
|
||||
@ -2481,9 +2481,10 @@ void nsChildView::UpdateWindowDraggingRegion(const LayoutDeviceIntRegion& aRegio
|
||||
|
||||
// Suppress calls to setNeedsDisplay during NSView geometry changes.
|
||||
ManipulateViewWithoutNeedingDisplay(mView, ^() {
|
||||
changed = mNonDraggableRegion.UpdateRegion(nonDraggable, *this, mView, ^() {
|
||||
return [[NonDraggableView alloc] initWithFrame:NSZeroRect];
|
||||
});
|
||||
changed = mNonDraggableRegion.UpdateRegion(
|
||||
nonDraggable, *this, [mView nonDraggableViewsContainer], ^() {
|
||||
return [[NonDraggableView alloc] initWithFrame:NSZeroRect];
|
||||
});
|
||||
});
|
||||
|
||||
if (changed) {
|
||||
@ -2847,6 +2848,31 @@ class WidgetsReleaserRunnable final : public mozilla::Runnable {
|
||||
|
||||
#pragma mark -
|
||||
|
||||
// ViewRegionContainerView is a view class for certain subviews of ChildView
|
||||
// which contain the NSViews created for ViewRegions (see ViewRegion.h).
|
||||
// It doesn't do anything interesting, it only acts as a container so that it's
|
||||
// easier for ChildView to control the z order of its children.
|
||||
@interface ViewRegionContainerView : NSView {
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation ViewRegionContainerView
|
||||
|
||||
- (NSView*)hitTest:(NSPoint)aPoint {
|
||||
return nil; // Be transparent to mouse events.
|
||||
}
|
||||
|
||||
- (BOOL)isFlipped {
|
||||
return [[self superview] isFlipped];
|
||||
}
|
||||
|
||||
- (BOOL)mouseDownCanMoveWindow {
|
||||
return [[self superview] mouseDownCanMoveWindow];
|
||||
}
|
||||
|
||||
@end
|
||||
;
|
||||
|
||||
@implementation ChildView
|
||||
|
||||
// globalDragPboard is non-null during native drag sessions that did not originate
|
||||
@ -2918,6 +2944,15 @@ NSEvent* gLastDragMouseDownEvent = nil;
|
||||
mCancelSwipeAnimation = nil;
|
||||
#endif
|
||||
|
||||
mNonDraggableViewsContainer = [[ViewRegionContainerView alloc] initWithFrame:[self bounds]];
|
||||
mVibrancyViewsContainer = [[ViewRegionContainerView alloc] initWithFrame:[self bounds]];
|
||||
|
||||
[mNonDraggableViewsContainer setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
||||
[mVibrancyViewsContainer setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
||||
|
||||
[self addSubview:mNonDraggableViewsContainer];
|
||||
[self addSubview:mVibrancyViewsContainer];
|
||||
|
||||
mTopLeftCornerMask = NULL;
|
||||
mLastPressureStage = 0;
|
||||
}
|
||||
@ -3049,6 +3084,14 @@ NSEvent* gLastDragMouseDownEvent = nil;
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
||||
- (NSView*)vibrancyViewsContainer {
|
||||
return mVibrancyViewsContainer;
|
||||
}
|
||||
|
||||
- (NSView*)nonDraggableViewsContainer {
|
||||
return mNonDraggableViewsContainer;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||
|
||||
@ -3061,6 +3104,10 @@ NSEvent* gLastDragMouseDownEvent = nil;
|
||||
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
[[NSDistributedNotificationCenter defaultCenter] removeObserver:self];
|
||||
[mVibrancyViewsContainer removeFromSuperview];
|
||||
[mVibrancyViewsContainer release];
|
||||
[mNonDraggableViewsContainer removeFromSuperview];
|
||||
[mNonDraggableViewsContainer release];
|
||||
|
||||
[super dealloc];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user