diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-02-18 13:56:18 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-02-18 14:56:31 +0100 |
commit | a24398e42d2f300b5979d1fb45a481e2912fd4f3 (patch) | |
tree | 82c15ba37726971108f6b92c15a70e9f57950846 /widget/windows/nsNativeThemeWin.cpp | |
parent | b55f0e7f0d3c66b609ac8979265c62bd1fa85bb6 (diff) | |
download | UXP-a24398e42d2f300b5979d1fb45a481e2912fd4f3.tar UXP-a24398e42d2f300b5979d1fb45a481e2912fd4f3.tar.gz UXP-a24398e42d2f300b5979d1fb45a481e2912fd4f3.tar.lz UXP-a24398e42d2f300b5979d1fb45a481e2912fd4f3.tar.xz UXP-a24398e42d2f300b5979d1fb45a481e2912fd4f3.zip |
Remove unnecessary code in /widget.
- Remove numerous blocklist entries that no longer apply.
- Remove CanComputeVirtualKeyCodeFromScanCode(), because it's always true.
- Remove ShowXP{Folder,File}Picker(), since we have native pickers on supported Windows versions.
- Remove the config.trim_on_minimize preference, which is pointless on NT6+ and will just cause problems if used.
Tag #22.
Diffstat (limited to 'widget/windows/nsNativeThemeWin.cpp')
-rw-r--r-- | widget/windows/nsNativeThemeWin.cpp | 463 |
1 files changed, 126 insertions, 337 deletions
diff --git a/widget/windows/nsNativeThemeWin.cpp b/widget/windows/nsNativeThemeWin.cpp index 4ff6b0af9..8950dcf90 100644 --- a/widget/windows/nsNativeThemeWin.cpp +++ b/widget/windows/nsNativeThemeWin.cpp @@ -39,7 +39,6 @@ #include "nsUXThemeConstants.h" #include <algorithm> -using mozilla::IsVistaOrLater; using namespace mozilla; using namespace mozilla::widget; @@ -301,10 +300,6 @@ DrawThemeBGRTLAware(HANDLE aTheme, HDC aHdc, int aPart, int aState, * aero basic max 0 2 1 2 * aero basic close 1 2 1 2 * - * xp theme min 0 2 0 2 - * xp theme max 0 2 1 2 - * xp theme close 1 2 2 2 - * * 'cold' button padding - generic button padding, should * be handled in css. * left top right bottom @@ -315,16 +310,11 @@ DrawThemeBGRTLAware(HANDLE aTheme, HDC aHdc, int aPart, int aState, * aero basic min 0 0 1 0 * aero basic max 1 0 0 0 * aero basic close 0 0 0 0 - * - * xp theme min 0 0 1 0 - * xp theme max 1 0 0 0 - * xp theme close 0 0 0 0 */ enum CaptionDesktopTheme { CAPTION_CLASSIC = 0, CAPTION_BASIC, - CAPTION_XPTHEME, }; enum CaptionButton { @@ -358,8 +348,6 @@ AddPaddingRect(LayoutDeviceIntSize* aSize, CaptionButton button) { RECT offset; if (!IsAppThemed()) offset = buttonData[CAPTION_CLASSIC].hotPadding[button]; - else if (!IsVistaOrLater()) - offset = buttonData[CAPTION_XPTHEME].hotPadding[button]; else offset = buttonData[CAPTION_BASIC].hotPadding[button]; aSize->width += offset.left + offset.right; @@ -373,8 +361,6 @@ OffsetBackgroundRect(RECT& rect, CaptionButton button) { RECT offset; if (!IsAppThemed()) offset = buttonData[CAPTION_CLASSIC].hotPadding[button]; - else if (!IsVistaOrLater()) - offset = buttonData[CAPTION_XPTHEME].hotPadding[button]; else offset = buttonData[CAPTION_BASIC].hotPadding[button]; rect.left += offset.left; @@ -419,9 +405,7 @@ OffsetBackgroundRect(RECT& rect, CaptionButton button) { static const double kProgressDeterminateTimeSpan = 3.0; static const double kProgressIndeterminateTimeSpan = 5.0; // The width of the overlay used to animate the horizontal progress bar (Vista and later). -static const int32_t kProgressHorizontalVistaOverlaySize = 120; -// The width of the overlay used for the horizontal indeterminate progress bars on XP. -static const int32_t kProgressHorizontalXPOverlaySize = 55; +static const int32_t kProgressHorizontalOverlaySize = 120; // The height of the overlay used to animate the vertical progress bar (Vista and later). static const int32_t kProgressVerticalOverlaySize = 45; // The height of the overlay used for the vertical indeterminate progress bar (Vista and later). @@ -435,18 +419,8 @@ static const int32_t kProgressClassicOverlaySize = 40; */ static int32_t GetProgressOverlayStyle(bool aIsVertical) -{ - if (aIsVertical) { - if (IsVistaOrLater()) { - return PP_MOVEOVERLAYVERT; - } - return PP_CHUNKVERT; - } else { - if (IsVistaOrLater()) { - return PP_MOVEOVERLAY; - } - return PP_CHUNK; - } +{ + return aIsVertical ? PP_MOVEOVERLAYVERT : PP_MOVEOVERLAY; } /* @@ -457,14 +431,11 @@ GetProgressOverlayStyle(bool aIsVertical) static int32_t GetProgressOverlaySize(bool aIsVertical, bool aIsIndeterminate) { - if (IsVistaOrLater()) { - if (aIsVertical) { - return aIsIndeterminate ? kProgressVerticalIndeterminateOverlaySize - : kProgressVerticalOverlaySize; - } - return kProgressHorizontalVistaOverlaySize; + if (aIsVertical) { + return aIsIndeterminate ? kProgressVerticalIndeterminateOverlaySize + : kProgressVerticalOverlaySize; } - return kProgressHorizontalXPOverlaySize; + return kProgressHorizontalOverlaySize; } /* @@ -554,87 +525,6 @@ nsNativeThemeWin::CalculateProgressOverlayRect(nsIFrame* aFrame, } /* - * DrawChunkProgressMeter - renders an xp style chunked progress meter. Called - * by DrawProgressMeter. - * - * @param aTheme progress theme handle - * @param aHdc hdc returned by gfxWindowsNativeDrawing - * @param aPart the PP_X progress part - * @param aState the theme state - * @param aFrame the elements frame - * @param aWidgetRect bounding rect for the widget - * @param aClipRect dirty rect that needs drawing. - * @param aAppUnits app units per device pixel - * @param aIsIndeterm is an indeterminate progress? - * @param aIsVertical render a vertical progress? - * @param aIsRtl direction is rtl - */ -static void -DrawChunkProgressMeter(HTHEME aTheme, HDC aHdc, int aPart, - int aState, nsIFrame* aFrame, RECT* aWidgetRect, - RECT* aClipRect, gfxFloat aAppUnits, bool aIsIndeterm, - bool aIsVertical, bool aIsRtl) -{ - NS_ASSERTION(aTheme, "Bad theme."); - NS_ASSERTION(aHdc, "Bad hdc."); - NS_ASSERTION(aWidgetRect, "Bad rect."); - NS_ASSERTION(aClipRect, "Bad clip rect."); - NS_ASSERTION(aFrame, "Bad frame."); - - // For horizontal meters, the theme lib paints the right graphic but doesn't - // paint the chunks, so we do that manually. For vertical meters, the theme - // library draws everything correctly. - if (aIsVertical) { - DrawThemeBackground(aTheme, aHdc, aPart, aState, aWidgetRect, aClipRect); - return; - } - - // query for the proper chunk metrics - int chunkSize, spaceSize; - if (FAILED(GetThemeMetric(aTheme, aHdc, aPart, aState, - TMT_PROGRESSCHUNKSIZE, &chunkSize)) || - FAILED(GetThemeMetric(aTheme, aHdc, aPart, aState, - TMT_PROGRESSSPACESIZE, &spaceSize))) { - DrawThemeBackground(aTheme, aHdc, aPart, aState, aWidgetRect, aClipRect); - return; - } - - // render chunks - if (!aIsRtl || aIsIndeterm) { - for (int chunk = aWidgetRect->left; chunk <= aWidgetRect->right; - chunk += (chunkSize+spaceSize)) { - if (!aIsIndeterm && ((chunk + chunkSize) > aWidgetRect->right)) { - // aWidgetRect->right represents the end of the meter. Partial blocks - // don't get rendered with one exception, so exit here if we don't have - // a full chunk to draw. - // The above is true *except* when the meter is at 100% fill, in which - // case Windows renders any remaining partial block. Query the parent - // frame to find out if we're at 100%. - if (!IsProgressMeterFilled(aFrame)) { - break; - } - } - RECT bounds = - { chunk, aWidgetRect->top, chunk + chunkSize, aWidgetRect->bottom }; - DrawThemeBackground(aTheme, aHdc, aPart, aState, &bounds, aClipRect); - } - } else { - // rtl needs to grow in the opposite direction to look right. - for (int chunk = aWidgetRect->right; chunk >= aWidgetRect->left; - chunk -= (chunkSize+spaceSize)) { - if ((chunk - chunkSize) < aWidgetRect->left) { - if (!IsProgressMeterFilled(aFrame)) { - break; - } - } - RECT bounds = - { chunk - chunkSize, aWidgetRect->top, chunk, aWidgetRect->bottom }; - DrawThemeBackground(aTheme, aHdc, aPart, aState, &bounds, aClipRect); - } - } -} - -/* * DrawProgressMeter - render an appropriate progress meter based on progress * meter style, orientation, and os. Note, this does not render the underlying * progress track. @@ -653,8 +543,7 @@ void nsNativeThemeWin::DrawThemedProgressMeter(nsIFrame* aFrame, int aWidgetType, HANDLE aTheme, HDC aHdc, int aPart, int aState, - RECT* aWidgetRect, RECT* aClipRect, - gfxFloat aAppUnits) + RECT* aWidgetRect, RECT* aClipRect) { if (!aFrame || !aTheme || !aHdc) return; @@ -665,12 +554,6 @@ nsNativeThemeWin::DrawThemedProgressMeter(nsIFrame* aFrame, int aWidgetType, RECT adjWidgetRect, adjClipRect; adjWidgetRect = *aWidgetRect; adjClipRect = *aClipRect; - if (!IsVistaOrLater()) { - // Adjust clipping out by one pixel. XP progress meters are inset, - // Vista+ are not. - InflateRect(&adjWidgetRect, 1, 1); - InflateRect(&adjClipRect, 1, 1); - } nsIFrame* parentFrame = aFrame->GetParent(); if (!parentFrame) { @@ -685,20 +568,13 @@ nsNativeThemeWin::DrawThemedProgressMeter(nsIFrame* aFrame, int aWidgetType, bool indeterminate = IsIndeterminateProgress(parentFrame, eventStates); bool animate = indeterminate; - if (IsVistaOrLater()) { - // Vista and up progress meter is fill style, rendered here. We render - // the pulse overlay in the follow up section below. - DrawThemeBackground(aTheme, aHdc, aPart, aState, - &adjWidgetRect, &adjClipRect); - if (!IsProgressMeterFilled(aFrame)) { - animate = true; - } - } else if (!indeterminate) { - // XP progress meters are 'chunk' style. - DrawChunkProgressMeter(aTheme, aHdc, aPart, aState, aFrame, - &adjWidgetRect, &adjClipRect, aAppUnits, - indeterminate, vertical, IsFrameRTL(aFrame)); - } + // Vista and up progress meter is fill style, rendered here. We render + // the pulse overlay in the follow up section below. + DrawThemeBackground(aTheme, aHdc, aPart, aState, + &adjWidgetRect, &adjClipRect); + if (!IsProgressMeterFilled(aFrame)) { + animate = true; + } if (animate) { // Indeterminate rendering @@ -706,14 +582,8 @@ nsNativeThemeWin::DrawThemedProgressMeter(nsIFrame* aFrame, int aWidgetType, RECT overlayRect = CalculateProgressOverlayRect(aFrame, &adjWidgetRect, vertical, indeterminate, false); - if (IsVistaOrLater()) { - DrawThemeBackground(aTheme, aHdc, overlayPart, aState, &overlayRect, - &adjClipRect); - } else { - DrawChunkProgressMeter(aTheme, aHdc, overlayPart, aState, aFrame, - &overlayRect, &adjClipRect, aAppUnits, - indeterminate, vertical, IsFrameRTL(aFrame)); - } + DrawThemeBackground(aTheme, aHdc, overlayPart, aState, &overlayRect, + &adjClipRect); if (!QueueAnimatedContentForRefresh(aFrame->GetContent(), 60)) { NS_WARNING("unable to animate progress widget!"); @@ -724,15 +594,6 @@ nsNativeThemeWin::DrawThemedProgressMeter(nsIFrame* aFrame, int aWidgetType, HANDLE nsNativeThemeWin::GetTheme(uint8_t aWidgetType) { - if (!IsVistaOrLater()) { - // On XP or earlier, render dropdowns as textfields; - // doing it the right way works fine with the MS themes, - // but breaks on a lot of custom themes (presumably because MS - // apps do the textfield border business as well). - if (aWidgetType == NS_THEME_MENULIST) - aWidgetType = NS_THEME_TEXTFIELD; - } - switch (aWidgetType) { case NS_THEME_BUTTON: case NS_THEME_RADIO: @@ -745,9 +606,7 @@ nsNativeThemeWin::GetTheme(uint8_t aWidgetType) case NS_THEME_FOCUS_OUTLINE: return nsUXThemeData::GetTheme(eUXEdit); case NS_THEME_TOOLTIP: - // XP/2K3 should force a classic treatment of tooltips - return !IsVistaOrLater() ? - nullptr : nsUXThemeData::GetTheme(eUXTooltip); + return nsUXThemeData::GetTheme(eUXTooltip); case NS_THEME_TOOLBOX: return nsUXThemeData::GetTheme(eUXRebar); case NS_THEME_WIN_MEDIA_TOOLBOX: @@ -874,12 +733,6 @@ nsresult nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType, int32_t& aPart, int32_t& aState) { - if (!IsVistaOrLater()) { - // See GetTheme - if (aWidgetType == NS_THEME_MENULIST) - aWidgetType = NS_THEME_TEXTFIELD; - } - switch (aWidgetType) { case NS_THEME_BUTTON: { aPart = BP_BUTTON; @@ -952,63 +805,43 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType, case NS_THEME_TEXTFIELD_MULTILINE: { EventStates eventState = GetContentState(aFrame, aWidgetType); - if (IsVistaOrLater()) { - /* Note: the NOSCROLL type has a rounded corner in each - * corner. The more specific HSCROLL, VSCROLL, HVSCROLL types - * have side and/or top/bottom edges rendered as straight - * horizontal lines with sharp corners to accommodate a - * scrollbar. However, the scrollbar gets rendered on top of - * this for us, so we don't care, and can just use NOSCROLL - * here. - */ - aPart = TFP_EDITBORDER_NOSCROLL; - - if (!aFrame) { - aState = TFS_EDITBORDER_NORMAL; - } else if (IsDisabled(aFrame, eventState)) { - aState = TFS_EDITBORDER_DISABLED; - } else if (IsReadOnly(aFrame)) { - /* no special read-only state */ - aState = TFS_EDITBORDER_NORMAL; - } else { - nsIContent* content = aFrame->GetContent(); + /* Note: the NOSCROLL type has a rounded corner in each corner. The more + * specific HSCROLL, VSCROLL, HVSCROLL types have side and/or top/bottom + * edges rendered as straight horizontal lines with sharp corners to + * accommodate a scrollbar. However, the scrollbar gets rendered on top + * of this for us, so we don't care, and can just use NOSCROLL here. + */ + aPart = TFP_EDITBORDER_NOSCROLL; - /* XUL textboxes don't get focused themselves, because they have child - * html:input.. but we can check the XUL focused attributes on them - */ - if (content && content->IsXULElement() && IsFocused(aFrame)) - aState = TFS_EDITBORDER_FOCUSED; - else if (eventState.HasAtLeastOneOfStates(NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_FOCUS)) - aState = TFS_EDITBORDER_FOCUSED; - else if (eventState.HasState(NS_EVENT_STATE_HOVER)) - aState = TFS_EDITBORDER_HOVER; - else - aState = TFS_EDITBORDER_NORMAL; - } + if (!aFrame) { + aState = TFS_EDITBORDER_NORMAL; + } else if (IsDisabled(aFrame, eventState)) { + aState = TFS_EDITBORDER_DISABLED; + } else if (IsReadOnly(aFrame)) { + /* no special read-only state */ + aState = TFS_EDITBORDER_NORMAL; } else { - aPart = TFP_TEXTFIELD; - - if (!aFrame) - aState = TS_NORMAL; - else if (IsDisabled(aFrame, eventState)) - aState = TS_DISABLED; - else if (IsReadOnly(aFrame)) - aState = TFS_READONLY; + nsIContent* content = aFrame->GetContent(); + + /* XUL textboxes don't get focused themselves, because they have child + * html:input.. but we can check the XUL focused attributes on them + */ + if (content && content->IsXULElement() && IsFocused(aFrame)) + aState = TFS_EDITBORDER_FOCUSED; + else if (eventState.HasAtLeastOneOfStates(NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_FOCUS)) + aState = TFS_EDITBORDER_FOCUSED; + else if (eventState.HasState(NS_EVENT_STATE_HOVER)) + aState = TFS_EDITBORDER_HOVER; else - aState = StandardGetState(aFrame, aWidgetType, true); + aState = TFS_EDITBORDER_NORMAL; } return NS_OK; } case NS_THEME_FOCUS_OUTLINE: { - if (IsVistaOrLater()) { - // XXX the EDITBORDER values don't respect DTBG_OMITCONTENT - aPart = TFP_TEXTFIELD; //TFP_EDITBORDER_NOSCROLL; - aState = TS_FOCUSED; //TFS_EDITBORDER_FOCUSED; - } else { - aPart = TFP_TEXTFIELD; - aState = TS_FOCUSED; - } + // XXX the EDITBORDER values don't respect DTBG_OMITCONTENT + aPart = TFP_TEXTFIELD; //TFP_EDITBORDER_NOSCROLL; + aState = TS_FOCUSED; //TFS_EDITBORDER_FOCUSED; return NS_OK; } case NS_THEME_TOOLTIP: { @@ -1032,11 +865,9 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType, nsIFrame* parentFrame = aFrame->GetParent(); if (aWidgetType == NS_THEME_PROGRESSCHUNK_VERTICAL || IsVerticalProgress(parentFrame)) { - aPart = IsVistaOrLater() ? - PP_FILLVERT : PP_CHUNKVERT; + aPart = PP_FILLVERT; } else { - aPart = IsVistaOrLater() ? - PP_FILL : PP_CHUNK; + aPart = PP_FILL; } aState = PBBVS_NORMAL; @@ -1100,8 +931,7 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType, aState += TS_ACTIVE; else if (eventState.HasState(NS_EVENT_STATE_HOVER)) aState += TS_HOVER; - else if (IsVistaOrLater() && - parentState.HasState(NS_EVENT_STATE_HOVER)) + else if (parentState.HasState(NS_EVENT_STATE_HOVER)) aState = (aWidgetType - NS_THEME_SCROLLBARBUTTON_UP) + SP_BUTTON_IMPLICIT_HOVER_BASE; else aState += TS_NORMAL; @@ -1204,14 +1034,7 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType, case NS_THEME_SCROLLBAR: case NS_THEME_SCROLLBAR_SMALL: { aState = 0; - if (IsVistaOrLater()) { - // On vista, they have a part - aPart = RP_BACKGROUND; - } else { - // Otherwise, they don't. (But I bet - // RP_BACKGROUND would work here, too); - aPart = 0; - } + aPart = RP_BACKGROUND; return NS_OK; } case NS_THEME_TOOLBAR: { @@ -1336,8 +1159,7 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType, aFrame = parentFrame; EventStates eventState = GetContentState(aFrame, aWidgetType); - aPart = IsVistaOrLater() ? - CBP_DROPMARKER_VISTA : CBP_DROPMARKER; + aPart = CBP_DROPMARKER_VISTA; // For HTML controls with author styling, we should fall // back to the old dropmarker style to avoid clashes with @@ -1357,28 +1179,25 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType, else isOpen = IsOpenButton(aFrame); - if (IsVistaOrLater()) { - if (isHTML || IsMenuListEditable(aFrame)) { - if (isOpen) { - /* Hover is propagated, but we need to know whether we're - * hovering just the combobox frame, not the dropdown frame. - * But, we can't get that information, since hover is on the - * content node, and they share the same content node. So, - * instead, we cheat -- if the dropdown is open, we always - * show the hover state. This looks fine in practice. - */ - aState = TS_HOVER; - return NS_OK; - } - } else { - /* On Vista, the dropdown indicator on a menulist button in - * chrome is not given a hover effect. When the frame isn't - * isn't HTML content, we cheat and force the dropdown state - * to be normal. (Bug 430434) + if (isHTML || IsMenuListEditable(aFrame)) { + if (isOpen) { + /* Hover is propagated, but we need to know whether we're hovering + * just the combobox frame, not the dropdown frame. But, we can't get + * that information, since hover is on the content node, and they + * share the same content node. So, instead, we cheat -- if the + * dropdown is open, we always show the hover state. This looks fine + * in practice. */ - aState = TS_NORMAL; + aState = TS_HOVER; return NS_OK; } + } else { + /* The dropdown indicator on a menulist button in chrome is not given a + * hover effect. When the frame isn't isn't HTML content, we cheat and + * force the dropdown state to be normal. (Bug 430434) + */ + aState = TS_NORMAL; + return NS_OK; } aState = TS_NORMAL; @@ -1879,7 +1698,7 @@ RENDER_AGAIN: else if (aWidgetType == NS_THEME_PROGRESSCHUNK || aWidgetType == NS_THEME_PROGRESSCHUNK_VERTICAL) { DrawThemedProgressMeter(aFrame, aWidgetType, theme, hdc, part, state, - &widgetRect, &clipRect, p2a); + &widgetRect, &clipRect); } else if (aWidgetType == NS_THEME_FOCUS_OUTLINE) { // Inflate 'widgetRect' with the focus outline size. @@ -2145,41 +1964,39 @@ nsNativeThemeWin::GetWidgetPadding(nsDeviceContext* aContext, return ok; } - if (IsVistaOrLater()) { - if (aWidgetType == NS_THEME_NUMBER_INPUT || - aWidgetType == NS_THEME_TEXTFIELD || - aWidgetType == NS_THEME_TEXTFIELD_MULTILINE || - aWidgetType == NS_THEME_MENULIST) - { - /* If we have author-specified padding for these elements, don't do the fixups below */ - if (aFrame->PresContext()->HasAuthorSpecifiedRules(aFrame, NS_AUTHOR_SPECIFIED_PADDING)) - return false; - } + if (aWidgetType == NS_THEME_NUMBER_INPUT || + aWidgetType == NS_THEME_TEXTFIELD || + aWidgetType == NS_THEME_TEXTFIELD_MULTILINE || + aWidgetType == NS_THEME_MENULIST) + { + // If we have author-specified padding for these elements, don't do the + // fixups below. + if (aFrame->PresContext()->HasAuthorSpecifiedRules(aFrame, NS_AUTHOR_SPECIFIED_PADDING)) + return false; + } - /* textfields need extra pixels on all sides, otherwise they - * wrap their content too tightly. The actual border is drawn 1px - * inside the specified rectangle, so Gecko will end up making the - * contents look too small. Instead, we add 2px padding for the - * contents and fix this. (Used to be 1px added, see bug 430212) + /* textfields need extra pixels on all sides, otherwise they wrap their + * content too tightly. The actual border is drawn 1px inside the specified + * rectangle, so Gecko will end up making the contents look too small. + * Instead, we add 2px padding for the contents and fix this. (Used to be 1px + * added, see bug 430212) + */ + if (aWidgetType == NS_THEME_NUMBER_INPUT || + aWidgetType == NS_THEME_TEXTFIELD || + aWidgetType == NS_THEME_TEXTFIELD_MULTILINE) { + aResult->top = aResult->bottom = 2; + aResult->left = aResult->right = 2; + ScaleForFrameDPI(aResult, aFrame); + return ok; + } else if (IsHTMLContent(aFrame) && aWidgetType == NS_THEME_MENULIST) { + /* For content menulist controls, we need an extra pixel so that we have + * room to draw our focus rectangle stuff. Otherwise, the focus rect might + * overlap the control's border. */ - if (aWidgetType == NS_THEME_NUMBER_INPUT || - aWidgetType == NS_THEME_TEXTFIELD || - aWidgetType == NS_THEME_TEXTFIELD_MULTILINE) { - aResult->top = aResult->bottom = 2; - aResult->left = aResult->right = 2; - ScaleForFrameDPI(aResult, aFrame); - return ok; - } else if (IsHTMLContent(aFrame) && aWidgetType == NS_THEME_MENULIST) { - /* For content menulist controls, we need an extra pixel so - * that we have room to draw our focus rectangle stuff. - * Otherwise, the focus rect might overlap the control's - * border. - */ - aResult->top = aResult->bottom = 1; - aResult->left = aResult->right = 1; - ScaleForFrameDPI(aResult, aFrame); - return ok; - } + aResult->top = aResult->bottom = 1; + aResult->left = aResult->right = 1; + ScaleForFrameDPI(aResult, aFrame); + return ok; } int32_t right, left, top, bottom; @@ -2244,23 +2061,21 @@ nsNativeThemeWin::GetWidgetOverflow(nsDeviceContext* aContext, * a border only shows up if the widget is being hovered. */ #if 0 - if (IsVistaOrLater()) { - /* We explicitly draw dropdown buttons in HTML content 1px bigger - * up, right, and bottom so that they overlap the dropdown's border - * like they're supposed to. - */ - if (aWidgetType == NS_THEME_MENULIST_BUTTON && - IsHTMLContent(aFrame) && - !IsWidgetStyled(aFrame->GetParent()->PresContext(), - aFrame->GetParent(), - NS_THEME_MENULIST)) - { - int32_t p2a = aContext->AppUnitsPerDevPixel(); - /* Note: no overflow on the left */ - nsMargin m(p2a, p2a, p2a, 0); - aOverflowRect->Inflate (m); - return true; - } + /* We explicitly draw dropdown buttons in HTML content 1px bigger up, right, + * and bottom so that they overlap the dropdown's border like they're + * supposed to. + */ + if (aWidgetType == NS_THEME_MENULIST_BUTTON && + IsHTMLContent(aFrame) && + !IsWidgetStyled(aFrame->GetParent()->PresContext(), + aFrame->GetParent(), + NS_THEME_MENULIST)) + { + int32_t p2a = aContext->AppUnitsPerDevPixel(); + /* Note: no overflow on the left */ + nsMargin m(p2a, p2a, p2a, 0); + aOverflowRect->Inflate (m); + return true; } #endif @@ -2384,22 +2199,18 @@ nsNativeThemeWin::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aF case NS_THEME_SCALETHUMB_VERTICAL: { *aIsOverridable = false; - // on Vista, GetThemePartAndState returns odd values for + // On Vista, GetThemePartAndState returns odd values for // scale thumbs, so use a hardcoded size instead. - if (IsVistaOrLater()) { - if (aWidgetType == NS_THEME_SCALETHUMB_HORIZONTAL || - (aWidgetType == NS_THEME_RANGE_THUMB && IsRangeHorizontal(aFrame))) { - aResult->width = 12; - aResult->height = 20; - } - else { - aResult->width = 20; - aResult->height = 12; - } - ScaleForFrameDPI(aResult, aFrame); - return rv; + if (aWidgetType == NS_THEME_SCALETHUMB_HORIZONTAL || + (aWidgetType == NS_THEME_RANGE_THUMB && IsRangeHorizontal(aFrame))) { + aResult->width = 12; + aResult->height = 20; + } else { + aResult->width = 20; + aResult->height = 12; } - break; + ScaleForFrameDPI(aResult, aFrame); + return rv; } case NS_THEME_SCROLLBAR: @@ -2438,11 +2249,6 @@ nsNativeThemeWin::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aF // stores that info in nsUXThemeData. aResult->width = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_RESTORE].cx; aResult->height = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_RESTORE].cy; - // For XP, subtract 4 from system metrics dimensions. - if (!IsVistaOrLater()) { - aResult->width -= 4; - aResult->height -= 4; - } AddPaddingRect(aResult, CAPTIONBUTTON_RESTORE); *aIsOverridable = false; return rv; @@ -2450,10 +2256,6 @@ nsNativeThemeWin::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aF case NS_THEME_WINDOW_BUTTON_MINIMIZE: aResult->width = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_MINIMIZE].cx; aResult->height = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_MINIMIZE].cy; - if (!IsVistaOrLater()) { - aResult->width -= 4; - aResult->height -= 4; - } AddPaddingRect(aResult, CAPTIONBUTTON_MINIMIZE); *aIsOverridable = false; return rv; @@ -2461,10 +2263,6 @@ nsNativeThemeWin::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aF case NS_THEME_WINDOW_BUTTON_CLOSE: aResult->width = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_CLOSE].cx; aResult->height = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_CLOSE].cy; - if (!IsVistaOrLater()) { - aResult->width -= 4; - aResult->height -= 4; - } AddPaddingRect(aResult, CAPTIONBUTTON_CLOSE); *aIsOverridable = false; return rv; @@ -2594,18 +2392,9 @@ nsNativeThemeWin::WidgetStateChanged(nsIFrame* aFrame, uint8_t aWidgetType, return NS_OK; } - // On Vista, the scrollbar buttons need to change state when the track has/doesn't have hover - if (!IsVistaOrLater() && - (aWidgetType == NS_THEME_SCROLLBAR_VERTICAL || - aWidgetType == NS_THEME_SCROLLBAR_HORIZONTAL)) { - *aShouldRepaint = false; - return NS_OK; - } - // We need to repaint the dropdown arrow in vista HTML combobox controls when // the control is closed to get rid of the hover effect. - if (IsVistaOrLater() && - (aWidgetType == NS_THEME_MENULIST || aWidgetType == NS_THEME_MENULIST_BUTTON) && + if ((aWidgetType == NS_THEME_MENULIST || aWidgetType == NS_THEME_MENULIST_BUTTON) && IsHTMLContent(aFrame)) { *aShouldRepaint = true; |