Bug 889085 - Make our sheets semi-transparent. r=mstange.
authorstefanh@inbox.com
Sat, 18 Jan 2014 12:52:22 +0100
changeset 164136 f8c14bd80676f6f845f739782fb273b739e0e266
parent 164135 dddfd63f1414f6f5742ed90d7ded0968a45b38e4
child 164137 103c0b6c135d5b0ad65d018b2054165bae2a9532
push id26026
push userphilringnalda@gmail.com
push dateSat, 18 Jan 2014 23:17:27 +0000
treeherdermozilla-central@61fd0f987cf2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs889085
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 889085 - Make our sheets semi-transparent. r=mstange.
widget/cocoa/nsNativeThemeCocoa.h
widget/cocoa/nsNativeThemeCocoa.mm
--- a/widget/cocoa/nsNativeThemeCocoa.h
+++ b/widget/cocoa/nsNativeThemeCocoa.h
@@ -66,16 +66,17 @@ public:
                     double inValue, double inMaxValue, nsIFrame* aFrame);
 
 protected:  
 
   nsIntMargin RTLAwareMargin(const nsIntMargin& aMargin, nsIFrame* aFrame);
   nsIFrame* SeparatorResponsibility(nsIFrame* aBefore, nsIFrame* aAfter);
   CGRect SeparatorAdjustedRect(CGRect aRect, nsIFrame* aLeft,
                                nsIFrame* aCurrent, nsIFrame* aRight);
+  bool IsWindowSheet(nsIFrame* aFrame);
 
   // HITheme drawing routines
   void DrawFrame(CGContextRef context, HIThemeFrameKind inKind,
                  const HIRect& inBoxRect, bool inReadOnly,
                  nsEventStates inState);
   void DrawMeter(CGContextRef context, const HIRect& inBoxRect,
                  nsIFrame* aFrame);
   void DrawSegment(CGContextRef cgContext, const HIRect& inBoxRect,
--- a/widget/cocoa/nsNativeThemeCocoa.mm
+++ b/widget/cocoa/nsNativeThemeCocoa.mm
@@ -2095,17 +2095,24 @@ nsNativeThemeCocoa::DrawWidgetBackground
   //CGContextSetRGBFillColor(cgContext, 0.0, 0.0, 1.0, 0.1);
   //CGContextFillRect(cgContext, bounds);
 #endif
 
   nsEventStates eventState = GetContentState(aFrame, aWidgetType);
 
   switch (aWidgetType) {
     case NS_THEME_DIALOG: {
-      HIThemeSetFill(kThemeBrushDialogBackgroundActive, NULL, cgContext, HITHEME_ORIENTATION);
+      CGContextClearRect(cgContext, macRect);
+      if (IsWindowSheet(aFrame)) {
+        HIThemeSetFill(kThemeBrushSheetBackgroundTransparent, NULL, cgContext, HITHEME_ORIENTATION);
+      }
+      else {
+        HIThemeSetFill(kThemeBrushDialogBackgroundActive, NULL, cgContext, HITHEME_ORIENTATION);
+      }
+
       CGContextFillRect(cgContext, macRect);
     }
       break;
 
     case NS_THEME_MENUPOPUP: {
       HIThemeMenuDrawInfo mdi;
       memset(&mdi, 0, sizeof(mdi));
       mdi.version = 0;
@@ -3350,24 +3357,41 @@ nsNativeThemeCocoa::WidgetAppearanceDepe
     case NS_THEME_LISTBOX:
     case NS_THEME_RESIZER:
       return false;
     default:
       return true;
   }
 }
 
+bool
+nsNativeThemeCocoa::IsWindowSheet(nsIFrame* aFrame)
+{
+  NSWindow* win = NativeWindowForFrame(aFrame);
+  id winDelegate = [win delegate];
+  nsIWidget* widget = [(WindowDelegate *)winDelegate geckoWidget];
+  if (!widget) {
+    return false;
+  }
+  nsWindowType windowType;
+  widget->GetWindowType(windowType);
+  return (windowType == eWindowType_sheet);
+}
+
 nsITheme::Transparency
 nsNativeThemeCocoa::GetWidgetTransparency(nsIFrame* aFrame, uint8_t aWidgetType)
 {
   switch (aWidgetType) {
   case NS_THEME_MENUPOPUP:
   case NS_THEME_TOOLTIP:
     return eTransparent;
 
+  case NS_THEME_DIALOG:
+    return IsWindowSheet(aFrame) ? eTransparent : eOpaque;
+
   case NS_THEME_SCROLLBAR_SMALL:
   case NS_THEME_SCROLLBAR:
     return nsLookAndFeel::UseOverlayScrollbars() ? eTransparent : eOpaque;
 
   case NS_THEME_STATUSBAR:
     // Knowing that scrollbars and statusbars are opaque improves
     // performance, because we create layers for them.
     return eOpaque;