mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1062801 - Fill vibrant window regions with the correct vibrancy fill color. r=smichaud
This commit is contained in:
parent
603aed5594
commit
eece1584e2
@ -75,6 +75,14 @@ public:
|
||||
*/
|
||||
void ClearVibrantAreas() const;
|
||||
|
||||
/**
|
||||
* Return the fill color that should be drawn on top of the cleared window
|
||||
* parts. Usually this would be drawn by -[NSVisualEffectView drawRect:].
|
||||
* The returned color is opaque if the system-wide "Reduce transparency"
|
||||
* preference is set.
|
||||
*/
|
||||
NSColor* VibrancyFillColorForType(VibrancyType aType);
|
||||
|
||||
/**
|
||||
* Check whether the operating system supports vibrancy at all.
|
||||
* You may only create a VibrancyManager instance if this returns true.
|
||||
|
@ -83,6 +83,26 @@ VibrancyManager::ClearVibrantRegion(const VibrantRegion& aVibrantRegion) const
|
||||
}
|
||||
}
|
||||
|
||||
@interface NSView(CurrentFillColor)
|
||||
- (NSColor*)_currentFillColor;
|
||||
@end
|
||||
|
||||
NSColor*
|
||||
VibrancyManager::VibrancyFillColorForType(VibrancyType aType)
|
||||
{
|
||||
const nsTArray<NSView*>& views =
|
||||
mVibrantRegions.LookupOrAdd(uint32_t(aType))->effectViews;
|
||||
|
||||
if (!views.IsEmpty() &&
|
||||
[views[0] respondsToSelector:@selector(_currentFillColor)]) {
|
||||
// -[NSVisualEffectView _currentFillColor] is the color that our view
|
||||
// would draw during its drawRect implementation, if we hadn't
|
||||
// disabled that.
|
||||
return [views[0] _currentFillColor];
|
||||
}
|
||||
return [NSColor whiteColor];
|
||||
}
|
||||
|
||||
static void
|
||||
DrawRectNothing(id self, SEL _cmd, NSRect aRect)
|
||||
{
|
||||
|
@ -329,6 +329,8 @@ typedef NSInteger NSEventGestureAxis;
|
||||
|
||||
- (BOOL)isCoveringTitlebar;
|
||||
|
||||
- (NSColor*)vibrancyFillColorForWidgetType:(uint8_t)aWidgetType;
|
||||
|
||||
// Simple gestures support
|
||||
//
|
||||
// XXX - The swipeWithEvent, beginGestureWithEvent, magnifyWithEvent,
|
||||
@ -573,6 +575,7 @@ public:
|
||||
|
||||
void NotifyDirtyRegion(const nsIntRegion& aDirtyRegion);
|
||||
void ClearVibrantAreas();
|
||||
NSColor* VibrancyFillColorForWidgetType(uint8_t aWidgetType);
|
||||
|
||||
// unit conversion convenience functions
|
||||
int32_t CocoaPointsToDevPixels(CGFloat aPts) const {
|
||||
|
@ -2656,6 +2656,17 @@ nsChildView::ClearVibrantAreas()
|
||||
}
|
||||
}
|
||||
|
||||
NSColor*
|
||||
nsChildView::VibrancyFillColorForWidgetType(uint8_t aWidgetType)
|
||||
{
|
||||
if (VibrancyManager::SystemSupportsVibrancy()) {
|
||||
return EnsureVibrancyManager().VibrancyFillColorForType(
|
||||
aWidgetType == NS_THEME_MAC_VIBRANCY_LIGHT
|
||||
? VibrancyType::LIGHT : VibrancyType::DARK);
|
||||
}
|
||||
return [NSColor whiteColor];
|
||||
}
|
||||
|
||||
mozilla::VibrancyManager&
|
||||
nsChildView::EnsureVibrancyManager()
|
||||
{
|
||||
@ -3639,6 +3650,14 @@ NSEvent* gLastDragMouseDownEvent = nil;
|
||||
[(BaseWindow*)[self window] drawsContentsIntoWindowFrame];
|
||||
}
|
||||
|
||||
- (NSColor*)vibrancyFillColorForWidgetType:(uint8_t)aWidgetType
|
||||
{
|
||||
if (!mGeckoChild) {
|
||||
return [NSColor whiteColor];
|
||||
}
|
||||
return mGeckoChild->VibrancyFillColorForWidgetType(aWidgetType);
|
||||
}
|
||||
|
||||
- (nsIntRegion)nativeDirtyRegionWithBoundingRect:(NSRect)aRect
|
||||
{
|
||||
nsIntRect boundingRect = mGeckoChild->CocoaPointsToDevPixels(aRect);
|
||||
|
@ -2858,6 +2858,23 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsRenderingContext* aContext,
|
||||
case NS_THEME_RESIZER:
|
||||
DrawResizer(cgContext, macRect, aFrame);
|
||||
break;
|
||||
|
||||
case NS_THEME_MAC_VIBRANCY_LIGHT:
|
||||
case NS_THEME_MAC_VIBRANCY_DARK:
|
||||
{
|
||||
NSWindow* win = NativeWindowForFrame(aFrame);
|
||||
if ([win isKindOfClass:[ToolbarWindow class]]) {
|
||||
NSGraphicsContext* savedContext = [NSGraphicsContext currentContext];
|
||||
[NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithGraphicsPort:cgContext flipped:YES]];
|
||||
|
||||
ChildView* childView = [(ToolbarWindow*)win mainChildView];
|
||||
[[childView vibrancyFillColorForWidgetType:aWidgetType] set];
|
||||
NSRectFill(NSRectFromCGRect(macRect));
|
||||
|
||||
[NSGraphicsContext setCurrentContext:savedContext];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (hidpi) {
|
||||
|
Loading…
Reference in New Issue
Block a user