From 2f12e52126155531d2766fccd1dfdc4f74ba5d6d Mon Sep 17 00:00:00 2001 From: Markus Stange Date: Wed, 4 Feb 2015 17:25:18 -0500 Subject: [PATCH] Bug 1045213 - Add nsITheme::ThemeGeometryTypeForWidget. r=roc --- gfx/src/nsITheme.h | 33 ++++++++++++++-- layout/base/nsDisplayList.cpp | 34 +++++++---------- widget/cocoa/nsChildView.h | 8 ++-- widget/cocoa/nsChildView.mm | 58 ++++++++++++++--------------- widget/cocoa/nsNativeThemeCocoa.h | 14 +++++++ widget/cocoa/nsNativeThemeCocoa.mm | 47 +++++++++++++++++++---- widget/nsIWidget.h | 12 +++--- widget/windows/nsNativeThemeWin.cpp | 13 +++++++ widget/windows/nsNativeThemeWin.h | 6 +++ widget/windows/nsWindow.cpp | 3 +- 10 files changed, 154 insertions(+), 74 deletions(-) diff --git a/gfx/src/nsITheme.h b/gfx/src/nsITheme.h index 063eb68a2c83..9263251a2b95 100644 --- a/gfx/src/nsITheme.h +++ b/gfx/src/nsITheme.h @@ -28,10 +28,10 @@ class nsIAtom; class nsIWidget; // IID for the nsITheme interface -// {cc3a6c72-50c2-414d-b9f2-b778a5e0f136} +// {a21dd936-5960-46da-a724-7c114e421b41} #define NS_ITHEME_IID \ -{ 0xcc3a6c72, 0x50c2, 0x414d, \ - { 0xb9, 0xf2, 0xb7, 0x78, 0xa5, 0xe0, 0xf1, 0x36 } } +{ 0xa21dd936, 0x5960, 0x46da, \ + { 0xa7, 0x24, 0x7c, 0x11, 0x4e, 0x42, 0x1b, 0x41 } } // {0ae05515-cf7a-45a8-9e02-6556de7685b1} #define NS_THEMERENDERER_CID \ { 0x0ae05515, 0xcf7a, 0x45a8, \ @@ -147,6 +147,33 @@ public: uint8_t aWidgetType, nscolor* aColor) { return false; } + /** + * ThemeGeometryType values are used for describing themed nsIFrames in + * calls to nsIWidget::UpdateThemeGeometries. We don't simply pass the + * -moz-appearance value ("widget type") of the frame because the widget may + * want to treat different frames with the same -moz-appearance differently + * based on other properties of the frame. So we give the theme a first look + * at the frame in nsITheme::ThemeGeometryTypeForWidget and pass the + * returned ThemeGeometryType along to the widget. + * Each theme backend defines the ThemeGeometryType values it needs in its + * own nsITheme subclass. eThemeGeometryTypeUnknown is the only value that's + * shared between backends. + */ + typedef uint8_t ThemeGeometryType; + enum { + eThemeGeometryTypeUnknown = 0 + }; + + /** + * Returns the theme geometry type that should be used in the ThemeGeometry + * array that's passed to the widget using nsIWidget::UpdateThemeGeometries. + * A return value of eThemeGeometryTypeUnknown means that this frame will + * not be included in the ThemeGeometry array. + */ + virtual ThemeGeometryType ThemeGeometryTypeForWidget(nsIFrame* aFrame, + uint8_t aWidgetType) + { return eThemeGeometryTypeUnknown; } + /** * Can the nsITheme implementation handle this widget? */ diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index ad00feac1c17..d3cdbbcabe31 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -2114,12 +2114,13 @@ nsDisplaySolidColor::WriteDebugInfo(std::stringstream& aStream) } static void -RegisterThemeGeometry(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame) +RegisterThemeGeometry(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, + nsITheme::ThemeGeometryType aType) { if (aBuilder->IsInRootChromeDocument() && !aBuilder->IsInTransform()) { nsIFrame* displayRoot = nsLayoutUtils::GetDisplayRootFrame(aFrame); nsRect borderBox(aFrame->GetOffsetTo(displayRoot), aFrame->GetSize()); - aBuilder->RegisterThemeGeometry(aFrame->StyleDisplay()->mAppearance, + aBuilder->RegisterThemeGeometry(aType, borderBox.ToNearestPixels(aFrame->PresContext()->AppUnitsPerDevPixel())); } } @@ -2792,25 +2793,16 @@ nsDisplayThemedBackground::nsDisplayThemedBackground(nsDisplayListBuilder* aBuil mFrame->IsThemed(disp, &mThemeTransparency); // Perform necessary RegisterThemeGeometry - switch (disp->mAppearance) { - case NS_THEME_MOZ_MAC_UNIFIED_TOOLBAR: - case NS_THEME_TOOLBAR: - case NS_THEME_TOOLTIP: - case NS_THEME_MENUPOPUP: - case NS_THEME_MENUITEM: - case NS_THEME_CHECKMENUITEM: - case NS_THEME_WINDOW_TITLEBAR: - case NS_THEME_WINDOW_BUTTON_BOX: - case NS_THEME_MOZ_MAC_FULLSCREEN_BUTTON: - case NS_THEME_WINDOW_BUTTON_BOX_MAXIMIZED: - case NS_THEME_MAC_VIBRANCY_LIGHT: - case NS_THEME_MAC_VIBRANCY_DARK: - RegisterThemeGeometry(aBuilder, aFrame); - break; - case NS_THEME_WIN_BORDERLESS_GLASS: - case NS_THEME_WIN_GLASS: - aBuilder->SetGlassDisplayItem(this); - break; + nsITheme* theme = mFrame->PresContext()->GetTheme(); + nsITheme::ThemeGeometryType type = + theme->ThemeGeometryTypeForWidget(mFrame, disp->mAppearance); + if (type != nsITheme::eThemeGeometryTypeUnknown) { + RegisterThemeGeometry(aBuilder, aFrame, type); + } + + if (disp->mAppearance == NS_THEME_WIN_BORDERLESS_GLASS || + disp->mAppearance == NS_THEME_WIN_GLASS) { + aBuilder->SetGlassDisplayItem(this); } mBounds = GetBoundsInternal(); diff --git a/widget/cocoa/nsChildView.h b/widget/cocoa/nsChildView.h index a1be2604df40..3a979b43d172 100644 --- a/widget/cocoa/nsChildView.h +++ b/widget/cocoa/nsChildView.h @@ -277,8 +277,8 @@ typedef NSInteger NSEventGestureAxis; - (BOOL)isCoveringTitlebar; -- (NSColor*)vibrancyFillColorForWidgetType:(uint8_t)aWidgetType; -- (NSColor*)vibrancyFontSmoothingBackgroundColorForWidgetType:(uint8_t)aWidgetType; +- (NSColor*)vibrancyFillColorForThemeGeometryType:(nsITheme::ThemeGeometryType)aThemeGeometryType; +- (NSColor*)vibrancyFontSmoothingBackgroundColorForThemeGeometryType:(nsITheme::ThemeGeometryType)aThemeGeometryType; // Simple gestures support // @@ -502,8 +502,8 @@ public: } void ClearVibrantAreas(); - NSColor* VibrancyFillColorForWidgetType(uint8_t aWidgetType); - NSColor* VibrancyFontSmoothingBackgroundColorForWidgetType(uint8_t aWidgetType); + NSColor* VibrancyFillColorForThemeGeometryType(nsITheme::ThemeGeometryType aThemeGeometryType); + NSColor* VibrancyFontSmoothingBackgroundColorForThemeGeometryType(nsITheme::ThemeGeometryType aThemeGeometryType); // unit conversion convenience functions int32_t CocoaPointsToDevPixels(CGFloat aPts) const { diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index 5b46f7a1c8da..9a9cf93678ae 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -88,6 +88,7 @@ #include "nsLayoutUtils.h" #include "InputData.h" #include "VibrancyManager.h" +#include "nsNativeThemeCocoa.h" using namespace mozilla; using namespace mozilla::layers; @@ -2276,7 +2277,7 @@ FindTitlebarBottom(const nsTArray& aThemeGeometries, int32_t titlebarBottom = 0; for (uint32_t i = 0; i < aThemeGeometries.Length(); ++i) { const nsIWidget::ThemeGeometry& g = aThemeGeometries[i]; - if ((g.mWidgetType == NS_THEME_WINDOW_TITLEBAR) && + if ((g.mType == nsNativeThemeCocoa::eThemeGeometryTypeTitlebar) && g.mRect.X() <= 0 && g.mRect.XMost() >= aWindowWidth && g.mRect.Y() <= 0) { @@ -2293,8 +2294,7 @@ FindUnifiedToolbarBottom(const nsTArray& aThemeGeometr int32_t unifiedToolbarBottom = aTitlebarBottom; for (uint32_t i = 0; i < aThemeGeometries.Length(); ++i) { const nsIWidget::ThemeGeometry& g = aThemeGeometries[i]; - if ((g.mWidgetType == NS_THEME_MOZ_MAC_UNIFIED_TOOLBAR || - g.mWidgetType == NS_THEME_TOOLBAR) && + if ((g.mType == nsNativeThemeCocoa::eThemeGeometryTypeToolbar) && g.mRect.X() <= 0 && g.mRect.XMost() >= aWindowWidth && g.mRect.Y() <= aTitlebarBottom) { @@ -2306,11 +2306,11 @@ FindUnifiedToolbarBottom(const nsTArray& aThemeGeometr static nsIntRect FindFirstRectOfType(const nsTArray& aThemeGeometries, - uint8_t aWidgetType) + nsITheme::ThemeGeometryType aThemeGeometryType) { for (uint32_t i = 0; i < aThemeGeometries.Length(); ++i) { const nsIWidget::ThemeGeometry& g = aThemeGeometries[i]; - if (g.mWidgetType == aWidgetType) { + if (g.mType == aThemeGeometryType) { return g.mRect; } } @@ -2342,20 +2342,20 @@ nsChildView::UpdateThemeGeometries(const nsTArray& aThemeGeometri [win setUnifiedToolbarHeight:DevPixelsToCocoaPoints(devUnifiedHeight)]; // Update titlebar control offsets. - nsIntRect windowButtonRect = FindFirstRectOfType(aThemeGeometries, NS_THEME_WINDOW_BUTTON_BOX); + nsIntRect windowButtonRect = FindFirstRectOfType(aThemeGeometries, nsNativeThemeCocoa::eThemeGeometryTypeWindowButtons); [win placeWindowButtons:[mView convertRect:DevPixelsToCocoaPoints(windowButtonRect) toView:nil]]; - nsIntRect fullScreenButtonRect = FindFirstRectOfType(aThemeGeometries, NS_THEME_MOZ_MAC_FULLSCREEN_BUTTON); + nsIntRect fullScreenButtonRect = FindFirstRectOfType(aThemeGeometries, nsNativeThemeCocoa::eThemeGeometryTypeFullscreenButton); [win placeFullScreenButton:[mView convertRect:DevPixelsToCocoaPoints(fullScreenButtonRect) toView:nil]]; } static nsIntRegion GatherThemeGeometryRegion(const nsTArray& aThemeGeometries, - uint8_t aWidgetType) + nsITheme::ThemeGeometryType aThemeGeometryType) { nsIntRegion region; for (size_t i = 0; i < aThemeGeometries.Length(); ++i) { const nsIWidget::ThemeGeometry& g = aThemeGeometries[i]; - if (g.mWidgetType == aWidgetType) { + if (g.mType == aThemeGeometryType) { region.OrWith(g.mRect); } } @@ -2370,15 +2370,13 @@ nsChildView::UpdateVibrancy(const nsTArray& aThemeGeometries) } nsIntRegion vibrantLightRegion = - GatherThemeGeometryRegion(aThemeGeometries, NS_THEME_MAC_VIBRANCY_LIGHT); + GatherThemeGeometryRegion(aThemeGeometries, nsNativeThemeCocoa::eThemeGeometryTypeVibrancyLight); nsIntRegion vibrantDarkRegion = - GatherThemeGeometryRegion(aThemeGeometries, NS_THEME_MAC_VIBRANCY_DARK); + GatherThemeGeometryRegion(aThemeGeometries, nsNativeThemeCocoa::eThemeGeometryTypeVibrancyDark); nsIntRegion menuRegion = - GatherThemeGeometryRegion(aThemeGeometries, NS_THEME_MENUPOPUP).OrWith( - GatherThemeGeometryRegion(aThemeGeometries, NS_THEME_MENUITEM).OrWith( - GatherThemeGeometryRegion(aThemeGeometries, NS_THEME_CHECKMENUITEM))); + GatherThemeGeometryRegion(aThemeGeometries, nsNativeThemeCocoa::eThemeGeometryTypeMenu); nsIntRegion tooltipRegion = - GatherThemeGeometryRegion(aThemeGeometries, NS_THEME_TOOLTIP); + GatherThemeGeometryRegion(aThemeGeometries, nsNativeThemeCocoa::eThemeGeometryTypeTooltip); vibrantDarkRegion.SubOut(vibrantLightRegion); vibrantDarkRegion.SubOut(menuRegion); @@ -2403,18 +2401,16 @@ nsChildView::ClearVibrantAreas() } static VibrancyType -WidgetTypeToVibrancyType(uint8_t aWidgetType) +ThemeGeometryTypeToVibrancyType(nsITheme::ThemeGeometryType aThemeGeometryType) { - switch (aWidgetType) { - case NS_THEME_MAC_VIBRANCY_LIGHT: + switch (aThemeGeometryType) { + case nsNativeThemeCocoa::eThemeGeometryTypeVibrancyLight: return VibrancyType::LIGHT; - case NS_THEME_MAC_VIBRANCY_DARK: + case nsNativeThemeCocoa::eThemeGeometryTypeVibrancyDark: return VibrancyType::DARK; - case NS_THEME_TOOLTIP: + case nsNativeThemeCocoa::eThemeGeometryTypeTooltip: return VibrancyType::TOOLTIP; - case NS_THEME_MENUPOPUP: - case NS_THEME_MENUITEM: - case NS_THEME_CHECKMENUITEM: + case nsNativeThemeCocoa::eThemeGeometryTypeMenu: return VibrancyType::MENU; default: MOZ_CRASH(); @@ -2422,21 +2418,21 @@ WidgetTypeToVibrancyType(uint8_t aWidgetType) } NSColor* -nsChildView::VibrancyFillColorForWidgetType(uint8_t aWidgetType) +nsChildView::VibrancyFillColorForThemeGeometryType(nsITheme::ThemeGeometryType aThemeGeometryType) { if (VibrancyManager::SystemSupportsVibrancy()) { return EnsureVibrancyManager().VibrancyFillColorForType( - WidgetTypeToVibrancyType(aWidgetType)); + ThemeGeometryTypeToVibrancyType(aThemeGeometryType)); } return [NSColor whiteColor]; } NSColor* -nsChildView::VibrancyFontSmoothingBackgroundColorForWidgetType(uint8_t aWidgetType) +nsChildView::VibrancyFontSmoothingBackgroundColorForThemeGeometryType(nsITheme::ThemeGeometryType aThemeGeometryType) { if (VibrancyManager::SystemSupportsVibrancy()) { return EnsureVibrancyManager().VibrancyFontSmoothingBackgroundColorForType( - WidgetTypeToVibrancyType(aWidgetType)); + ThemeGeometryTypeToVibrancyType(aThemeGeometryType)); } return [NSColor clearColor]; } @@ -3256,20 +3252,20 @@ NSEvent* gLastDragMouseDownEvent = nil; [(BaseWindow*)[self window] drawsContentsIntoWindowFrame]; } -- (NSColor*)vibrancyFillColorForWidgetType:(uint8_t)aWidgetType +- (NSColor*)vibrancyFillColorForThemeGeometryType:(nsITheme::ThemeGeometryType)aThemeGeometryType { if (!mGeckoChild) { return [NSColor whiteColor]; } - return mGeckoChild->VibrancyFillColorForWidgetType(aWidgetType); + return mGeckoChild->VibrancyFillColorForThemeGeometryType(aThemeGeometryType); } -- (NSColor*)vibrancyFontSmoothingBackgroundColorForWidgetType:(uint8_t)aWidgetType +- (NSColor*)vibrancyFontSmoothingBackgroundColorForThemeGeometryType:(nsITheme::ThemeGeometryType)aThemeGeometryType { if (!mGeckoChild) { return [NSColor clearColor]; } - return mGeckoChild->VibrancyFontSmoothingBackgroundColorForWidgetType(aWidgetType); + return mGeckoChild->VibrancyFontSmoothingBackgroundColorForThemeGeometryType(aThemeGeometryType); } - (nsIntRegion)nativeDirtyRegionWithBoundingRect:(NSRect)aRect diff --git a/widget/cocoa/nsNativeThemeCocoa.h b/widget/cocoa/nsNativeThemeCocoa.h index 344d5db6d12b..4889f166ed4a 100644 --- a/widget/cocoa/nsNativeThemeCocoa.h +++ b/widget/cocoa/nsNativeThemeCocoa.h @@ -28,6 +28,18 @@ class nsNativeThemeCocoa : private nsNativeTheme, public nsITheme { public: + enum { + eThemeGeometryTypeTitlebar = eThemeGeometryTypeUnknown + 1, + eThemeGeometryTypeToolbar, + eThemeGeometryTypeWindowButtons, + eThemeGeometryTypeFullscreenButton, + eThemeGeometryTypeMenu, + eThemeGeometryTypeHighlightedMenuItem, + eThemeGeometryTypeVibrancyLight, + eThemeGeometryTypeVibrancyDark, + eThemeGeometryTypeTooltip, + }; + nsNativeThemeCocoa(); NS_DECL_ISUPPORTS_INHERITED @@ -65,6 +77,8 @@ public: virtual bool NeedToClearBackgroundBehindWidget(uint8_t aWidgetType) MOZ_OVERRIDE; virtual bool WidgetProvidesFontSmoothingBackgroundColor(nsIFrame* aFrame, uint8_t aWidgetType, nscolor* aColor) MOZ_OVERRIDE; + virtual ThemeGeometryType ThemeGeometryTypeForWidget(nsIFrame* aFrame, + uint8_t aWidgetType) MOZ_OVERRIDE; virtual Transparency GetWidgetTransparency(nsIFrame* aFrame, uint8_t aWidgetType) MOZ_OVERRIDE; void DrawProgress(CGContextRef context, const HIRect& inBoxRect, diff --git a/widget/cocoa/nsNativeThemeCocoa.mm b/widget/cocoa/nsNativeThemeCocoa.mm index 59e8614de95f..b005e22999b1 100644 --- a/widget/cocoa/nsNativeThemeCocoa.mm +++ b/widget/cocoa/nsNativeThemeCocoa.mm @@ -2256,7 +2256,7 @@ nsNativeThemeCocoa::DrawResizer(CGContextRef cgContext, const HIRect& aRect, static void DrawVibrancyBackground(CGContextRef cgContext, CGRect inBoxRect, - nsIFrame* aFrame, uint8_t aWidgetType, + nsIFrame* aFrame, nsITheme::ThemeGeometryType aThemeGeometryType, int aCornerRadius = 0) { ChildView* childView = ChildViewForFrame(aFrame); @@ -2270,7 +2270,7 @@ DrawVibrancyBackground(CGContextRef cgContext, CGRect inBoxRect, [[NSBezierPath bezierPathWithRoundedRect:rect xRadius:aCornerRadius yRadius:aCornerRadius] addClip]; } - [[childView vibrancyFillColorForWidgetType:aWidgetType] set]; + [[childView vibrancyFillColorForThemeGeometryType:aThemeGeometryType] set]; NSRectFill(rect); [NSGraphicsContext restoreGraphicsState]; @@ -2391,7 +2391,7 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsRenderingContext* aContext, case NS_THEME_MENUPOPUP: if (VibrancyManager::SystemSupportsVibrancy()) { - DrawVibrancyBackground(cgContext, macRect, aFrame, aWidgetType, 4); + DrawVibrancyBackground(cgContext, macRect, aFrame, eThemeGeometryTypeMenu, 4); } else { HIThemeMenuDrawInfo mdi; memset(&mdi, 0, sizeof(mdi)); @@ -2424,7 +2424,7 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsRenderingContext* aContext, bool isDisabled = IsDisabled(aFrame, eventState); bool isSelected = !isDisabled && CheckBooleanAttr(aFrame, nsGkAtoms::menuactive); if (!isSelected && VibrancyManager::SystemSupportsVibrancy()) { - DrawVibrancyBackground(cgContext, macRect, aFrame, aWidgetType); + DrawVibrancyBackground(cgContext, macRect, aFrame, eThemeGeometryTypeMenu); } else { // maybe use kThemeMenuItemHierBackground or PopUpBackground instead of just Plain? HIThemeMenuItemDrawInfo drawInfo; @@ -2472,7 +2472,7 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsRenderingContext* aContext, case NS_THEME_TOOLTIP: if (VibrancyManager::SystemSupportsVibrancy()) { - DrawVibrancyBackground(cgContext, macRect, aFrame, aWidgetType); + DrawVibrancyBackground(cgContext, macRect, aFrame, ThemeGeometryTypeForWidget(aFrame, aWidgetType)); } else { CGContextSetRGBFillColor(cgContext, 0.996, 1.000, 0.792, 0.950); CGContextFillRect(cgContext, macRect); @@ -2909,9 +2909,11 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsRenderingContext* aContext, break; case NS_THEME_MAC_VIBRANCY_LIGHT: - case NS_THEME_MAC_VIBRANCY_DARK: - DrawVibrancyBackground(cgContext, macRect, aFrame, aWidgetType); + case NS_THEME_MAC_VIBRANCY_DARK: { + ThemeGeometryType type = ThemeGeometryTypeForWidget(aFrame, aWidgetType); + DrawVibrancyBackground(cgContext, macRect, aFrame, type); break; + } } if (hidpi) { @@ -3793,7 +3795,8 @@ nsNativeThemeCocoa::WidgetProvidesFontSmoothingBackgroundColor(nsIFrame* aFrame, { ChildView* childView = ChildViewForFrame(aFrame); if (childView) { - NSColor* color = [childView vibrancyFontSmoothingBackgroundColorForWidgetType:aWidgetType]; + ThemeGeometryType type = ThemeGeometryTypeForWidget(aFrame, aWidgetType); + NSColor* color = [childView vibrancyFontSmoothingBackgroundColorForThemeGeometryType:type]; *aColor = ConvertNSColor(color); return true; } @@ -3804,6 +3807,34 @@ nsNativeThemeCocoa::WidgetProvidesFontSmoothingBackgroundColor(nsIFrame* aFrame, } } +nsITheme::ThemeGeometryType +nsNativeThemeCocoa::ThemeGeometryTypeForWidget(nsIFrame* aFrame, uint8_t aWidgetType) +{ + switch (aWidgetType) { + case NS_THEME_WINDOW_TITLEBAR: + return eThemeGeometryTypeTitlebar; + case NS_THEME_TOOLBAR: + case NS_THEME_MOZ_MAC_UNIFIED_TOOLBAR: + return eThemeGeometryTypeToolbar; + case NS_THEME_WINDOW_BUTTON_BOX: + return eThemeGeometryTypeWindowButtons; + case NS_THEME_MOZ_MAC_FULLSCREEN_BUTTON: + return eThemeGeometryTypeFullscreenButton; + case NS_THEME_MAC_VIBRANCY_LIGHT: + return eThemeGeometryTypeVibrancyLight; + case NS_THEME_MAC_VIBRANCY_DARK: + return eThemeGeometryTypeVibrancyDark; + case NS_THEME_TOOLTIP: + return eThemeGeometryTypeTooltip; + case NS_THEME_MENUPOPUP: + case NS_THEME_MENUITEM: + case NS_THEME_CHECKMENUITEM: + return eThemeGeometryTypeMenu; + default: + return eThemeGeometryTypeUnknown; + } +} + nsITheme::Transparency nsNativeThemeCocoa::GetWidgetTransparency(nsIFrame* aFrame, uint8_t aWidgetType) { diff --git a/widget/nsIWidget.h b/widget/nsIWidget.h index 2983a6158bb9..e1e09f8b5c32 100644 --- a/widget/nsIWidget.h +++ b/widget/nsIWidget.h @@ -15,6 +15,7 @@ #include "nsAutoPtr.h" #include "nsWidgetInitData.h" #include "nsTArray.h" +#include "nsITheme.h" #include "nsITimer.h" #include "nsXULAppAPI.h" #include "mozilla/EventForwards.h" @@ -740,14 +741,15 @@ class nsIWidget : public nsISupports { // Used in UpdateThemeGeometries. struct ThemeGeometry { - // The -moz-appearance value for the themed widget - uint8_t mWidgetType; + // The ThemeGeometryType value for the themed widget, see + // nsITheme::ThemeGeometryTypeForWidget. + nsITheme::ThemeGeometryType mType; // The device-pixel rect within the window for the themed widget nsIntRect mRect; - ThemeGeometry(uint8_t aWidgetType, const nsIntRect& aRect) - : mWidgetType(aWidgetType) - , mRect(aRect) + ThemeGeometry(nsITheme::ThemeGeometryType aType, const nsIntRect& aRect) + : mType(aType) + , mRect(aRect) { } }; diff --git a/widget/windows/nsNativeThemeWin.cpp b/widget/windows/nsNativeThemeWin.cpp index 51dc155e415e..a77ec5f04e88 100644 --- a/widget/windows/nsNativeThemeWin.cpp +++ b/widget/windows/nsNativeThemeWin.cpp @@ -2664,6 +2664,19 @@ nsNativeThemeWin::WidgetAppearanceDependsOnWindowFocus(uint8_t aWidgetType) } } +nsITheme::ThemeGeometryType +nsNativeThemeWin::ThemeGeometryTypeForWidget(nsIFrame* aFrame, + uint8_t aWidgetType) +{ + switch (aWidgetType) { + case NS_THEME_WINDOW_BUTTON_BOX: + case NS_THEME_WINDOW_BUTTON_BOX_MAXIMIZED: + return eThemeGeometryTypeWindowButtons; + default: + return eThemeGeometryTypeUnknown; + } +} + bool nsNativeThemeWin::ShouldHideScrollbars() { diff --git a/widget/windows/nsNativeThemeWin.h b/widget/windows/nsNativeThemeWin.h index 07ef3363d839..5c2672163ddb 100644 --- a/widget/windows/nsNativeThemeWin.h +++ b/widget/windows/nsNativeThemeWin.h @@ -74,6 +74,12 @@ public: virtual bool WidgetAppearanceDependsOnWindowFocus(uint8_t aWidgetType) MOZ_OVERRIDE; + enum { + eThemeGeometryTypeWindowButtons = eThemeGeometryTypeUnknown + 1 + }; + virtual ThemeGeometryType ThemeGeometryTypeForWidget(nsIFrame* aFrame, + uint8_t aWidgetType) MOZ_OVERRIDE; + virtual bool ShouldHideScrollbars() MOZ_OVERRIDE; nsNativeThemeWin(); diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index 46340afd430a..d9edbc9c464d 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -3531,8 +3531,7 @@ nsWindow::UpdateThemeGeometries(const nsTArray& aThemeGeometries) { nsIntRegion clearRegion; for (size_t i = 0; i < aThemeGeometries.Length(); i++) { - if ((aThemeGeometries[i].mWidgetType == NS_THEME_WINDOW_BUTTON_BOX || - aThemeGeometries[i].mWidgetType == NS_THEME_WINDOW_BUTTON_BOX_MAXIMIZED) && + if (aThemeGeometries[i].mType == nsNativeThemeWin::eThemeGeometryTypeWindowButtons && nsUXThemeData::CheckForCompositor()) { nsIntRect bounds = aThemeGeometries[i].mRect;