author | Emilio Cobos Álvarez <emilio@crisal.io> |
Wed, 25 Jul 2018 15:03:45 +0200 | |
changeset 428605 | ced9b3994cf4316a57e1777bb3738cc350a1196d |
parent 428604 | 4b1c6659a5f5a28a54de6ee00caa09265050e8a7 |
child 428606 | 162e063abd54c9f29c21a6f0878f8d43434b8904 |
push id | 34337 |
push user | ncsoregi@mozilla.com |
push date | Thu, 26 Jul 2018 21:58:45 +0000 |
treeherder | mozilla-central@8f2f847b2f9d [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jwatt |
bugs | 1478391, 1428676, 1478385 |
milestone | 63.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
|
--- a/gfx/src/moz.build +++ b/gfx/src/moz.build @@ -30,17 +30,16 @@ EXPORTS += [ 'nsITheme.h', 'nsMargin.h', 'nsPoint.h', 'nsRect.h', 'nsRectAbsolute.h', 'nsRegion.h', 'nsRegionFwd.h', 'nsSize.h', - 'nsThemeConstants.h', 'nsTransform2D.h', 'RegionBuilder.h', 'X11UndefineNone.h' ] EXPORTS.mozilla += [ 'AppUnits.h', 'ArrayView.h',
--- a/gfx/src/nsITheme.h +++ b/gfx/src/nsITheme.h @@ -20,16 +20,17 @@ class nsAttrValue; class nsPresContext; class nsDeviceContext; class nsIFrame; class nsAtom; class nsIWidget; namespace mozilla { class ComputedStyle; +enum class StyleAppearance : uint8_t; namespace layers { class StackingContextHelper; class WebRenderLayerManager; } namespace wr { class DisplayListBuilder; class IpcResourceUpdateQueue; } @@ -53,138 +54,138 @@ class IpcResourceUpdateQueue; * * All the methods on nsITheme take a rendering context or device * context, a frame (the rendering object), and a widget type (one of * the constants in nsThemeConstants.h). */ class nsITheme: public nsISupports { protected: using LayoutDeviceIntMargin = mozilla::LayoutDeviceIntMargin; + using WidgetType = mozilla::StyleAppearance; public: NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITHEME_IID) /** * Draw the actual theme background. * @param aContext the context to draw into * @param aFrame the frame for the widget that we're drawing * @param aWidgetType the -moz-appearance value to draw * @param aRect the rectangle defining the area occupied by the widget * @param aDirtyRect the rectangle that needs to be drawn */ NS_IMETHOD DrawWidgetBackground(gfxContext* aContext, nsIFrame* aFrame, - uint8_t aWidgetType, + WidgetType aWidgetType, const nsRect& aRect, const nsRect& aDirtyRect) = 0; /** * Get the used color of the given widget when it's specified as auto. * It's currently only used for scrollbar-*-color properties. */ virtual nscolor GetWidgetAutoColor(mozilla::ComputedStyle* aStyle, - uint8_t aWidgetType) + WidgetType aWidgetType) { return NS_RGB(0, 0, 0); } /** * Create WebRender commands for the theme background. * @return true if the theme knows how to create WebRender commands for the * given widget type, false if DrawWidgetBackground need sto be called * instead. */ virtual bool CreateWebRenderCommandsForWidget(mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const mozilla::layers::StackingContextHelper& aSc, mozilla::layers::WebRenderLayerManager* aManager, nsIFrame* aFrame, - uint8_t aWidgetType, + WidgetType aWidgetType, const nsRect& aRect) { return false; } /** * Return the border for the widget, in device pixels. */ virtual MOZ_MUST_USE LayoutDeviceIntMargin GetWidgetBorder(nsDeviceContext* aContext, nsIFrame* aFrame, - uint8_t aWidgetType) = 0; + WidgetType aWidgetType) = 0; /** * This method can return false to indicate that the CSS padding * value should be used. Otherwise, it will fill in aResult with the * computed padding, in pixels, and return true. * * XXXldb This ought to be required to return true for non-containers * so that we don't let specified padding that has no effect change * the computed padding and potentially the size. */ virtual bool GetWidgetPadding(nsDeviceContext* aContext, - nsIFrame* aFrame, - uint8_t aWidgetType, - LayoutDeviceIntMargin* aResult) = 0; + nsIFrame* aFrame, + WidgetType aWidgetType, + LayoutDeviceIntMargin* aResult) = 0; /** * On entry, *aResult is positioned at 0,0 and sized to the new size * of aFrame (aFrame->GetSize() may be stale and should not be used). * This method can return false to indicate that no special * overflow area is required by the native widget. Otherwise it will * fill in aResult with the desired overflow area, in appunits, relative * to the frame origin, and return true. * * This overflow area is used to determine what area needs to be * repainted when the widget changes. However, it does not affect the * widget's size or what area is reachable by scrollbars. (In other * words, in layout terms, it affects visual overflow but not * scrollable overflow.) */ virtual bool GetWidgetOverflow(nsDeviceContext* aContext, - nsIFrame* aFrame, - uint8_t aWidgetType, - /*INOUT*/ nsRect* aOverflowRect) + nsIFrame* aFrame, + WidgetType aWidgetType, + /*INOUT*/ nsRect* aOverflowRect) { return false; } /** * Get the minimum border-box size of a widget, in *pixels* (in * |aResult|). If |aIsOverridable| is set to true, this size is a * minimum size; if false, this size is the only valid size for the * widget. */ NS_IMETHOD GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aFrame, - uint8_t aWidgetType, + WidgetType aWidgetType, mozilla::LayoutDeviceIntSize* aResult, bool* aIsOverridable)=0; enum Transparency { eOpaque = 0, eTransparent, eUnknownTransparency }; /** * Returns what we know about the transparency of the widget. */ - virtual Transparency GetWidgetTransparency(nsIFrame* aFrame, uint8_t aWidgetType) + virtual Transparency GetWidgetTransparency(nsIFrame* aFrame, WidgetType aWidgetType) { return eUnknownTransparency; } /** * Sets |*aShouldRepaint| to indicate whether an attribute or content state * change should trigger a repaint. Call with null |aAttribute| (and * null |aOldValue|) for content state changes. */ - NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, uint8_t aWidgetType, + NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, WidgetType aWidgetType, nsAtom* aAttribute, bool* aShouldRepaint, const nsAttrValue* aOldValue)=0; NS_IMETHOD ThemeChanged()=0; - virtual bool WidgetAppearanceDependsOnWindowFocus(uint8_t aWidgetType) + virtual bool WidgetAppearanceDependsOnWindowFocus(WidgetType aWidgetType) { return false; } - virtual bool NeedToClearBackgroundBehindWidget(nsIFrame* aFrame, - uint8_t aWidgetType) + virtual bool NeedToClearBackgroundBehindWidget(nsIFrame* aFrame, WidgetType aWidgetType) { 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 @@ -201,37 +202,37 @@ public: /** * 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) + WidgetType aWidgetType) { return eThemeGeometryTypeUnknown; } /** * Can the nsITheme implementation handle this widget? */ virtual bool ThemeSupportsWidget(nsPresContext* aPresContext, - nsIFrame* aFrame, - uint8_t aWidgetType)=0; + nsIFrame* aFrame, + WidgetType aWidgetType) = 0; - virtual bool WidgetIsContainer(uint8_t aWidgetType)=0; + virtual bool WidgetIsContainer(WidgetType aWidgetType) = 0; /** * Does the nsITheme implementation draw its own focus ring for this widget? */ - virtual bool ThemeDrawsFocusForWidget(uint8_t aWidgetType)=0; + virtual bool ThemeDrawsFocusForWidget(WidgetType aWidgetType) = 0; /** * Should we insert a dropmarker inside of combobox button? */ - virtual bool ThemeNeedsComboboxDropmarker()=0; + virtual bool ThemeNeedsComboboxDropmarker() = 0; }; NS_DEFINE_STATIC_IID_ACCESSOR(nsITheme, NS_ITHEME_IID) // Creator function extern nsresult NS_NewNativeTheme(nsISupports *aOuter, REFNSIID aIID, void **aResult); #endif
deleted file mode 100644 --- a/gfx/src/nsThemeConstants.h +++ /dev/null @@ -1,316 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef nsThemeConstants_h_ -#define nsThemeConstants_h_ - -enum ThemeWidgetType : uint8_t { - - // No appearance at all. - NS_THEME_NONE, - - // A typical dialog button. - NS_THEME_BUTTON, - - // A radio element within a radio group. - NS_THEME_RADIO, - - // A checkbox element. - NS_THEME_CHECKBOX, - - // A rectangular button that contains complex content - // like images (e.g. HTML <button> elements) - NS_THEME_BUTTON_BEVEL, - - // A themed focus outline (for outline:auto) - NS_THEME_FOCUS_OUTLINE, - - // The toolbox that contains the toolbars. - NS_THEME_TOOLBOX, - - // A toolbar in an application window. - NS_THEME_TOOLBAR, - - // A single toolbar button (with no associated dropdown) - NS_THEME_TOOLBARBUTTON, - - // A dual toolbar button (e.g., a Back button with a dropdown) - NS_THEME_DUALBUTTON, - - // The dropdown portion of a toolbar button - NS_THEME_TOOLBARBUTTON_DROPDOWN, - - // Various arrows that go in buttons - NS_THEME_BUTTON_ARROW_UP, - NS_THEME_BUTTON_ARROW_DOWN, - NS_THEME_BUTTON_ARROW_NEXT, - NS_THEME_BUTTON_ARROW_PREVIOUS, - - // A separator. Can be horizontal or vertical. - NS_THEME_SEPARATOR, - - // The gripper for a toolbar. - NS_THEME_TOOLBARGRIPPER, - - // A splitter. Can be horizontal or vertical. - NS_THEME_SPLITTER, - - // A status bar in a main application window. - NS_THEME_STATUSBAR, - - // A single pane of a status bar. - NS_THEME_STATUSBARPANEL, - - // The resizer background area in a status bar - // for the resizer widget in the corner of a window. - NS_THEME_RESIZERPANEL, - - // The resizer itself. - NS_THEME_RESIZER, - - // List boxes - NS_THEME_LISTBOX, - - // A listbox item - NS_THEME_LISTITEM, - - // A tree widget - NS_THEME_TREEVIEW, - - // A tree item - NS_THEME_TREEITEM, - - // A tree widget twisty - NS_THEME_TREETWISTY, - - // A tree widget branch line - NS_THEME_TREELINE, - - // A listbox or tree widget header - NS_THEME_TREEHEADER, - - // An individual header cell - NS_THEME_TREEHEADERCELL, - - // The sort arrow for a header. - NS_THEME_TREEHEADERSORTARROW, - - // Open tree widget twisty - NS_THEME_TREETWISTYOPEN, - - // A horizontal progress bar. - NS_THEME_PROGRESSBAR, - - // The progress bar's progress indicator - NS_THEME_PROGRESSCHUNK, - - // A vertical progress bar. - NS_THEME_PROGRESSBAR_VERTICAL, - - // A vertical progress chunk - NS_THEME_PROGRESSCHUNK_VERTICAL, - - // A horizontal meter bar. - NS_THEME_METERBAR, - - // The meter bar's meter indicator - NS_THEME_METERCHUNK, - - // A single tab in a tab widget. - NS_THEME_TAB, - - // A single pane (inside the tabpanels container) - NS_THEME_TABPANEL, - - // The tab panels container. - NS_THEME_TABPANELS, - - // The tabs scroll arrows (left/right) - NS_THEME_TAB_SCROLL_ARROW_BACK, - NS_THEME_TAB_SCROLL_ARROW_FORWARD, - - // A tooltip - NS_THEME_TOOLTIP, - - // A inner-spin control - NS_THEME_INNER_SPIN_BUTTON, - - // A spin control (up/down control for time/date pickers) - NS_THEME_SPINNER, - - // The up button of a spin control - NS_THEME_SPINNER_UPBUTTON, - - // The down button of a spin control - NS_THEME_SPINNER_DOWNBUTTON, - - // The textfield of a spin control - NS_THEME_SPINNER_TEXTFIELD, - - // For HTML's <input type=number> - NS_THEME_NUMBER_INPUT, - - // A scrollbar. - NS_THEME_SCROLLBAR, - - // A small scrollbar. - NS_THEME_SCROLLBAR_SMALL, - - // The scrollbar slider - NS_THEME_SCROLLBAR_HORIZONTAL, - NS_THEME_SCROLLBAR_VERTICAL, - - // A scrollbar button (up/down/left/right) - NS_THEME_SCROLLBARBUTTON_UP, - NS_THEME_SCROLLBARBUTTON_DOWN, - NS_THEME_SCROLLBARBUTTON_LEFT, - NS_THEME_SCROLLBARBUTTON_RIGHT, - - // The scrollbar track - NS_THEME_SCROLLBARTRACK_HORIZONTAL, - NS_THEME_SCROLLBARTRACK_VERTICAL, - - // The scrollbar thumb - NS_THEME_SCROLLBARTHUMB_HORIZONTAL, - NS_THEME_SCROLLBARTHUMB_VERTICAL, - - // A non-disappearing scrollbar. - NS_THEME_SCROLLBAR_NON_DISAPPEARING, - - // The scroll corner - NS_THEME_SCROLLCORNER, - - // A textfield or text area - NS_THEME_TEXTFIELD, - - // The caret of a text area - NS_THEME_CARET, - - // A multiline text field - NS_THEME_TEXTFIELD_MULTILINE, - - // A searchfield - NS_THEME_SEARCHFIELD, - - // A dropdown list. - NS_THEME_MENULIST, - - // The dropdown button(s) that open up a dropdown list. - NS_THEME_MENULIST_BUTTON, - - // The text part of a dropdown list, to left of button - NS_THEME_MENULIST_TEXT, - - // An editable textfield with a dropdown list (a combobox) - NS_THEME_MENULIST_TEXTFIELD, - - // A slider - NS_THEME_SCALE_HORIZONTAL, - NS_THEME_SCALE_VERTICAL, - - // A slider's thumb - NS_THEME_SCALETHUMB_HORIZONTAL, - NS_THEME_SCALETHUMB_VERTICAL, - - // If the platform supports it, the left/right chunks - // of the slider thumb - NS_THEME_SCALETHUMBSTART, - NS_THEME_SCALETHUMBEND, - - // The ticks for a slider. - NS_THEME_SCALETHUMBTICK, - - // nsRangeFrame and its subparts - NS_THEME_RANGE, - NS_THEME_RANGE_THUMB, - - // A groupbox - NS_THEME_GROUPBOX, - - // A generic container that always repaints on state - // changes. This is a hack to make checkboxes and - // radio buttons work. - NS_THEME_CHECKBOX_CONTAINER, - NS_THEME_RADIO_CONTAINER, - - // The label part of a checkbox or radio button, used for painting - // a focus outline. - NS_THEME_CHECKBOX_LABEL, - NS_THEME_RADIO_LABEL, - - // The focus outline box inside of a button - NS_THEME_BUTTON_FOCUS, - - // Window and dialog backgrounds - NS_THEME_WINDOW, - NS_THEME_DIALOG, - - // Menu Bar background - NS_THEME_MENUBAR, - // Menu Popup background - NS_THEME_MENUPOPUP, - // <menu> and <menuitem> appearances - NS_THEME_MENUITEM, - NS_THEME_CHECKMENUITEM, - NS_THEME_RADIOMENUITEM, - - // menu checkbox/radio appearances - NS_THEME_MENUCHECKBOX, - NS_THEME_MENURADIO, - NS_THEME_MENUSEPARATOR, - NS_THEME_MENUARROW, - // An image in the menu gutter, like in bookmarks or history - NS_THEME_MENUIMAGE, - // For text on non-iconic menuitems only - NS_THEME_MENUITEMTEXT, - - // Vista Rebars - NS_THEME_WIN_COMMUNICATIONS_TOOLBOX, - NS_THEME_WIN_MEDIA_TOOLBOX, - NS_THEME_WIN_BROWSERTABBAR_TOOLBOX, - - // Titlebar elements on the Mac - NS_THEME_MAC_FULLSCREEN_BUTTON, - - // Mac help button - NS_THEME_MAC_HELP_BUTTON, - - // Vista glass - NS_THEME_WIN_BORDERLESS_GLASS, - NS_THEME_WIN_GLASS, - - // Windows themed window frame elements - NS_THEME_WINDOW_TITLEBAR, - NS_THEME_WINDOW_TITLEBAR_MAXIMIZED, - NS_THEME_WINDOW_FRAME_LEFT, - NS_THEME_WINDOW_FRAME_RIGHT, - NS_THEME_WINDOW_FRAME_BOTTOM, - NS_THEME_WINDOW_BUTTON_CLOSE, - NS_THEME_WINDOW_BUTTON_MINIMIZE, - NS_THEME_WINDOW_BUTTON_MAXIMIZE, - NS_THEME_WINDOW_BUTTON_RESTORE, - NS_THEME_WINDOW_BUTTON_BOX, - NS_THEME_WINDOW_BUTTON_BOX_MAXIMIZED, - - // moz-apperance style used in setting proper glass margins - NS_THEME_WIN_EXCLUDE_GLASS, - - NS_THEME_MAC_VIBRANCY_LIGHT, - NS_THEME_MAC_VIBRANCY_DARK, - NS_THEME_MAC_VIBRANT_TITLEBAR_LIGHT, - NS_THEME_MAC_VIBRANT_TITLEBAR_DARK, - NS_THEME_MAC_DISCLOSURE_BUTTON_OPEN, - NS_THEME_MAC_DISCLOSURE_BUTTON_CLOSED, - - NS_THEME_GTK_INFO_BAR, - NS_THEME_MAC_SOURCE_LIST, - NS_THEME_MAC_SOURCE_LIST_SELECTION, - NS_THEME_MAC_ACTIVE_SOURCE_LIST_SELECTION, - - ThemeWidgetType_COUNT -}; - -#endif // nsThemeConstants_h_
--- a/layout/base/RestyleManager.cpp +++ b/layout/base/RestyleManager.cpp @@ -512,24 +512,25 @@ RestyleManager::ContentStateChangedInter // If it's generated content, ignore LOADING/etc state changes on it. if (!primaryFrame->IsGeneratedContentFrame() && aStateMask.HasAtLeastOneOfStates(NS_EVENT_STATE_BROKEN | NS_EVENT_STATE_USERDISABLED | NS_EVENT_STATE_SUPPRESSED | NS_EVENT_STATE_LOADING)) { *aOutChangeHint = nsChangeHint_ReconstructFrame; } else { - uint8_t app = primaryFrame->StyleDisplay()->mAppearance; - if (app) { + auto* disp = primaryFrame->StyleDisplay(); + if (disp->HasAppearance()) { nsITheme* theme = PresContext()->GetTheme(); if (theme && - theme->ThemeSupportsWidget(PresContext(), primaryFrame, app)) { + theme->ThemeSupportsWidget(PresContext(), primaryFrame, + disp->mAppearance)) { bool repaint = false; - theme->WidgetStateChanged(primaryFrame, app, nullptr, &repaint, - nullptr); + theme->WidgetStateChanged(primaryFrame, disp->mAppearance, nullptr, + &repaint, nullptr); if (repaint) { *aOutChangeHint |= nsChangeHint_RepaintFrame; } } } } primaryFrame->ContentStatesChanged(aStateMask); @@ -3301,17 +3302,17 @@ RestyleManager::AttributeChanged(Element restyleHint |= eRestyle_Subtree; } else if (aElement->IsAttributeMapped(aAttribute)) { restyleHint |= eRestyle_Self; } if (nsIFrame* primaryFrame = aElement->GetPrimaryFrame()) { // See if we have appearance information for a theme. const nsStyleDisplay* disp = primaryFrame->StyleDisplay(); - if (disp->mAppearance) { + if (disp->HasAppearance()) { nsITheme* theme = PresContext()->GetTheme(); if (theme && theme->ThemeSupportsWidget(PresContext(), primaryFrame, disp->mAppearance)) { bool repaint = false; theme->WidgetStateChanged(primaryFrame, disp->mAppearance, aAttribute, &repaint, aOldValue); if (repaint) { changeHint |= nsChangeHint_RepaintFrame;
--- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -100,17 +100,17 @@ #include "nsGfxScrollFrame.h" #include "nsPageFrame.h" #include "nsSimplePageSequenceFrame.h" #include "nsTableWrapperFrame.h" #include "nsIScrollableFrame.h" #include "nsBackdropFrame.h" #include "nsTransitionManager.h" #include "DetailsFrame.h" -#include "nsThemeConstants.h" +#include "nsStyleConsts.h" #ifdef MOZ_XUL #include "nsIPopupContainer.h" #endif #ifdef ACCESSIBILITY #include "nsAccessibilityService.h" #endif @@ -3698,20 +3698,20 @@ nsCSSFrameConstructor::FindInputData(con // display (in practice, none). }; auto controlType = HTMLInputElement::FromNode(aElement)->ControlType(); // radio and checkbox inputs with appearance:none should be constructed // by display type. (Note that we're not checking that appearance is - // not (respectively) NS_THEME_RADIO and NS_THEME_CHECKBOX.) + // not (respectively) StyleAppearance::Radio and StyleAppearance::Checkbox.) if ((controlType == NS_FORM_INPUT_CHECKBOX || controlType == NS_FORM_INPUT_RADIO) && - aStyle.StyleDisplay()->mAppearance == NS_THEME_NONE) { + !aStyle.StyleDisplay()->HasAppearance()) { return nullptr; } return FindDataByInt(controlType, aElement, aStyle, sInputData, ArrayLength(sInputData)); } /* static */
--- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -50,17 +50,17 @@ #include "ImageOps.h" #include "ImageRegion.h" #include "gfxRect.h" #include "gfxContext.h" #include "gfxContext.h" #include "nsIInterfaceRequestorUtils.h" #include "nsCSSRendering.h" #include "nsTextFragment.h" -#include "nsThemeConstants.h" +#include "nsStyleConsts.h" #include "nsPIDOMWindow.h" #include "nsIDocShell.h" #include "nsIWidget.h" #include "gfxMatrix.h" #include "gfxPrefs.h" #include "gfxTypes.h" #include "nsTArray.h" #include "mozilla/dom/HTMLCanvasElement.h" @@ -7247,20 +7247,20 @@ nsLayoutUtils::HasNonZeroCornerOnSide(co nsLayoutUtils::GetFrameTransparency(nsIFrame* aBackgroundFrame, nsIFrame* aCSSRootFrame) { if (aCSSRootFrame->StyleEffects()->mOpacity < 1.0f) return eTransparencyTransparent; if (HasNonZeroCorner(aCSSRootFrame->StyleBorder()->mBorderRadius)) return eTransparencyTransparent; - if (aCSSRootFrame->StyleDisplay()->mAppearance == NS_THEME_WIN_GLASS) + if (aCSSRootFrame->StyleDisplay()->mAppearance == StyleAppearance::MozWinGlass) return eTransparencyGlass; - if (aCSSRootFrame->StyleDisplay()->mAppearance == NS_THEME_WIN_BORDERLESS_GLASS) + if (aCSSRootFrame->StyleDisplay()->mAppearance == StyleAppearance::MozWinBorderlessGlass) return eTransparencyBorderlessGlass; nsITheme::Transparency transparency; if (aCSSRootFrame->IsThemed(&transparency)) return transparency == nsITheme::eTransparent ? eTransparencyTransparent : eTransparencyOpaque;
--- a/layout/forms/nsCheckboxRadioFrame.cpp +++ b/layout/forms/nsCheckboxRadioFrame.cpp @@ -8,17 +8,17 @@ #include "nsGkAtoms.h" #include "nsLayoutUtils.h" #include "mozilla/dom/HTMLInputElement.h" #include "mozilla/EventStateManager.h" #include "mozilla/LookAndFeel.h" #include "nsDeviceContext.h" #include "nsIContent.h" -#include "nsThemeConstants.h" +#include "nsStyleConsts.h" using namespace mozilla; using mozilla::dom::HTMLInputElement; //#define FCF_NOISY nsCheckboxRadioFrame* NS_NewCheckboxRadioFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) @@ -49,42 +49,42 @@ NS_QUERYFRAME_HEAD(nsCheckboxRadioFrame) NS_QUERYFRAME_ENTRY(nsIFormControlFrame) NS_QUERYFRAME_TAIL_INHERITING(nsAtomicContainerFrame) /* virtual */ nscoord nsCheckboxRadioFrame::GetMinISize(gfxContext *aRenderingContext) { nscoord result; DISPLAY_MIN_WIDTH(this, result); - result = StyleDisplay()->mAppearance == NS_THEME_NONE ? 0 : DefaultSize(); + result = StyleDisplay()->HasAppearance() ? DefaultSize() : 0; return result; } /* virtual */ nscoord nsCheckboxRadioFrame::GetPrefISize(gfxContext* aRenderingContext) { nscoord result; DISPLAY_PREF_WIDTH(this, result); - result = StyleDisplay()->mAppearance == NS_THEME_NONE ? 0 : DefaultSize(); + result = StyleDisplay()->HasAppearance() ? DefaultSize() : 0; return result; } /* virtual */ LogicalSize nsCheckboxRadioFrame::ComputeAutoSize(gfxContext* aRC, WritingMode aWM, const LogicalSize& aCBSize, nscoord aAvailableISize, const LogicalSize& aMargin, const LogicalSize& aBorder, const LogicalSize& aPadding, ComputeSizeFlags aFlags) { LogicalSize size(aWM, 0, 0); - if (StyleDisplay()->mAppearance == NS_THEME_NONE) { + if (!StyleDisplay()->HasAppearance()) { return size; } // Note: this call always set the BSize to NS_UNCONSTRAINEDSIZE. size = nsAtomicContainerFrame::ComputeAutoSize(aRC, aWM, aCBSize, aAvailableISize, aMargin, aBorder, aPadding, aFlags); size.BSize(aWM) = DefaultSize(); @@ -94,17 +94,17 @@ nsCheckboxRadioFrame::ComputeAutoSize(gf nscoord nsCheckboxRadioFrame::GetLogicalBaseline(WritingMode aWritingMode) const { NS_ASSERTION(!NS_SUBTREE_DIRTY(this), "frame must not be dirty"); // For appearance:none we use a standard CSS baseline, i.e. synthesized from // our margin-box. - if (StyleDisplay()->mAppearance == NS_THEME_NONE) { + if (!StyleDisplay()->HasAppearance()) { return nsAtomicContainerFrame::GetLogicalBaseline(aWritingMode); } // This is for compatibility with Chrome, Safari and Edge (Dec 2016). // Treat radio buttons and checkboxes as having an intrinsic baseline // at the block-end of the control (use the block-end content edge rather // than the margin edge). // For "inverted" lines (typically in writing-mode:vertical-lr), use the
--- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -34,17 +34,17 @@ #include "nsIScrollableFrame.h" #include "nsListControlFrame.h" #include "mozilla/ServoStyleSet.h" #include "nsNodeInfoManager.h" #include "nsContentCreatorFunctions.h" #include "nsLayoutUtils.h" #include "nsDisplayList.h" #include "nsITheme.h" -#include "nsThemeConstants.h" +#include "nsStyleConsts.h" #include "mozilla/Likely.h" #include <algorithm> #include "nsTextNode.h" #include "mozilla/AsyncEventDispatcher.h" #include "mozilla/EventStates.h" #include "mozilla/LookAndFeel.h" #include "mozilla/MouseEvents.h" #include "mozilla/Unused.h" @@ -756,17 +756,17 @@ static void printSize(char * aDesc, nsco //------------------------------------------------------------------- //-- Main Reflow for the Combobox //------------------------------------------------------------------- bool nsComboboxControlFrame::HasDropDownButton() const { const nsStyleDisplay* disp = StyleDisplay(); - return disp->mAppearance == NS_THEME_MENULIST && + return disp->mAppearance == StyleAppearance::Menulist && (!IsThemed(disp) || PresContext()->GetTheme()->ThemeNeedsComboboxDropmarker()); } nscoord nsComboboxControlFrame::GetIntrinsicISize(gfxContext* aRenderingContext, nsLayoutUtils::IntrinsicISizeType aType) {
--- a/layout/forms/nsMeterFrame.cpp +++ b/layout/forms/nsMeterFrame.cpp @@ -15,17 +15,17 @@ #include "nsNodeInfoManager.h" #include "nsContentCreatorFunctions.h" #include "nsContentUtils.h" #include "nsCheckboxRadioFrame.h" #include "nsFontMetrics.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/HTMLMeterElement.h" #include "nsCSSPseudoElements.h" -#include "nsThemeConstants.h" +#include "nsStyleConsts.h" #include <algorithm> using namespace mozilla; using mozilla::dom::Element; using mozilla::dom::HTMLMeterElement; nsIFrame* NS_NewMeterFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) @@ -258,16 +258,16 @@ bool nsMeterFrame::ShouldUseNativeStyle() const { nsIFrame* barFrame = mBarDiv->GetPrimaryFrame(); // Use the native style if these conditions are satisfied: // - both frames use the native appearance; // - neither frame has author specified rules setting the border or the // background. - return StyleDisplay()->mAppearance == NS_THEME_METERBAR && + return StyleDisplay()->mAppearance == StyleAppearance::Meterbar && !PresContext()->HasAuthorSpecifiedRules(this, NS_AUTHOR_SPECIFIED_BORDER | NS_AUTHOR_SPECIFIED_BACKGROUND) && barFrame && - barFrame->StyleDisplay()->mAppearance == NS_THEME_METERCHUNK && + barFrame->StyleDisplay()->mAppearance == StyleAppearance::Meterchunk && !PresContext()->HasAuthorSpecifiedRules(barFrame, NS_AUTHOR_SPECIFIED_BORDER | NS_AUTHOR_SPECIFIED_BACKGROUND); }
--- a/layout/forms/nsNumberControlFrame.cpp +++ b/layout/forms/nsNumberControlFrame.cpp @@ -10,17 +10,17 @@ #include "ICUUtils.h" #include "nsIFocusManager.h" #include "nsIPresShell.h" #include "nsFocusManager.h" #include "nsFontMetrics.h" #include "nsCheckboxRadioFrame.h" #include "nsGkAtoms.h" #include "nsNameSpaceManager.h" -#include "nsThemeConstants.h" +#include "nsStyleConsts.h" #include "mozilla/BasicEvents.h" #include "mozilla/EventStates.h" #include "nsContentUtils.h" #include "nsContentCreatorFunctions.h" #include "nsCSSPseudoElements.h" #include "nsThreadUtils.h" #include "mozilla/FloatingPoint.h" #include "mozilla/dom/MutationEventBinding.h" @@ -401,17 +401,17 @@ nsNumberControlFrame::CreateAnonymousCon } if (mContent->AsElement()->State().HasState(NS_EVENT_STATE_FOCUS)) { // We don't want to focus the frame but the text field. RefPtr<FocusTextField> focusJob = new FocusTextField(mContent, mTextField); nsContentUtils::AddScriptRunner(focusJob); } - if (StyleDisplay()->mAppearance == NS_THEME_TEXTFIELD) { + if (StyleDisplay()->mAppearance == StyleAppearance::Textfield) { // The author has elected to hide the spinner by setting this // -moz-appearance. We will reframe if it changes. return NS_OK; } // Create the ::-moz-number-spin-box pseudo-element: mSpinBox = MakeAnonymousElement(mOuterWrapper, nsGkAtoms::div, @@ -601,21 +601,21 @@ nsNumberControlFrame::ShouldUseNativeSty { MOZ_ASSERT(mSpinUp && mSpinDown, "We should not be called when we have no spinner"); nsIFrame* spinUpFrame = mSpinUp->GetPrimaryFrame(); nsIFrame* spinDownFrame = mSpinDown->GetPrimaryFrame(); return spinUpFrame && - spinUpFrame->StyleDisplay()->mAppearance == NS_THEME_SPINNER_UPBUTTON && + spinUpFrame->StyleDisplay()->mAppearance == StyleAppearance::SpinnerUpbutton && !PresContext()->HasAuthorSpecifiedRules(spinUpFrame, STYLES_DISABLING_NATIVE_THEMING) && spinDownFrame && - spinDownFrame->StyleDisplay()->mAppearance == NS_THEME_SPINNER_DOWNBUTTON && + spinDownFrame->StyleDisplay()->mAppearance == StyleAppearance::SpinnerDownbutton && !PresContext()->HasAuthorSpecifiedRules(spinDownFrame, STYLES_DISABLING_NATIVE_THEMING); } void nsNumberControlFrame::AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements, uint32_t aFilter) {
--- a/layout/forms/nsProgressFrame.cpp +++ b/layout/forms/nsProgressFrame.cpp @@ -15,17 +15,17 @@ #include "nsNodeInfoManager.h" #include "nsContentCreatorFunctions.h" #include "nsContentUtils.h" #include "nsCheckboxRadioFrame.h" #include "nsFontMetrics.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/HTMLProgressElement.h" #include "nsCSSPseudoElements.h" -#include "nsThemeConstants.h" +#include "nsStyleConsts.h" #include <algorithm> using namespace mozilla; using namespace mozilla::dom; nsIFrame* NS_NewProgressFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) { @@ -271,16 +271,16 @@ bool nsProgressFrame::ShouldUseNativeStyle() const { nsIFrame* barFrame = PrincipalChildList().FirstChild(); // Use the native style if these conditions are satisfied: // - both frames use the native appearance; // - neither frame has author specified rules setting the border or the // background. - return StyleDisplay()->mAppearance == NS_THEME_PROGRESSBAR && + return StyleDisplay()->mAppearance == StyleAppearance::Progressbar && !PresContext()->HasAuthorSpecifiedRules(this, NS_AUTHOR_SPECIFIED_BORDER | NS_AUTHOR_SPECIFIED_BACKGROUND) && barFrame && - barFrame->StyleDisplay()->mAppearance == NS_THEME_PROGRESSCHUNK && + barFrame->StyleDisplay()->mAppearance == StyleAppearance::Progresschunk && !PresContext()->HasAuthorSpecifiedRules(barFrame, NS_AUTHOR_SPECIFIED_BORDER | NS_AUTHOR_SPECIFIED_BACKGROUND); }
--- a/layout/forms/nsRangeFrame.cpp +++ b/layout/forms/nsRangeFrame.cpp @@ -20,17 +20,17 @@ #include "nsNameSpaceManager.h" #include "nsIPresShell.h" #include "nsGkAtoms.h" #include "mozilla/dom/HTMLInputElement.h" #include "nsPresContext.h" #include "nsNodeInfoManager.h" #include "mozilla/dom/Element.h" #include "mozilla/ServoStyleSet.h" -#include "nsThemeConstants.h" +#include "nsStyleConsts.h" #ifdef ACCESSIBILITY #include "nsAccessibilityService.h" #endif #define LONG_SIDE_TO_SHORT_SIDE_RATIO 10 using namespace mozilla; @@ -544,17 +544,17 @@ nsRangeFrame::GetValueAtEventPoint(Widge nsSize thumbSize; if (IsThemed()) { // We need to get the size of the thumb from the theme. nsPresContext *presContext = PresContext(); bool notUsedCanOverride; LayoutDeviceIntSize size; presContext->GetTheme()-> - GetMinimumWidgetSize(presContext, this, NS_THEME_RANGE_THUMB, &size, + GetMinimumWidgetSize(presContext, this, StyleAppearance::RangeThumb, &size, ¬UsedCanOverride); thumbSize.width = presContext->DevPixelsToAppUnits(size.width); thumbSize.height = presContext->DevPixelsToAppUnits(size.height); // For GTK, GetMinimumWidgetSize returns zero for the thumb dimension // perpendicular to the orientation of the slider. That's okay since we // only care about the dimension in the direction of the slider when using // |thumbSize| below, but it means this assertion need to check // IsHorizontal(). @@ -868,17 +868,17 @@ nsRangeFrame::GetValue() const bool nsRangeFrame::ShouldUseNativeStyle() const { nsIFrame* trackFrame = mTrackDiv->GetPrimaryFrame(); nsIFrame* progressFrame = mProgressDiv->GetPrimaryFrame(); nsIFrame* thumbFrame = mThumbDiv->GetPrimaryFrame(); - return (StyleDisplay()->mAppearance == NS_THEME_RANGE) && + return (StyleDisplay()->mAppearance == StyleAppearance::Range) && !PresContext()->HasAuthorSpecifiedRules(this, (NS_AUTHOR_SPECIFIED_BORDER | NS_AUTHOR_SPECIFIED_BACKGROUND)) && trackFrame && !PresContext()->HasAuthorSpecifiedRules(trackFrame, STYLES_DISABLING_NATIVE_THEMING) && progressFrame && !PresContext()->HasAuthorSpecifiedRules(progressFrame,
--- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -110,17 +110,17 @@ #include "mozilla/css/ImageLoader.h" #include "mozilla/dom/TouchEvent.h" #include "mozilla/gfx/Tools.h" #include "mozilla/layers/WebRenderUserData.h" #include "nsPrintfCString.h" #include "ActiveLayerTracker.h" #include "nsITheme.h" -#include "nsThemeConstants.h" +#include "nsStyleConsts.h" #include "ImageLoader.h" using namespace mozilla; using namespace mozilla::css; using namespace mozilla::dom; using namespace mozilla::gfx; using namespace mozilla::layers; @@ -2400,17 +2400,18 @@ bool nsFrame::DisplayBackgroundUnconditional(nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists, bool aForceBackground) { // Here we don't try to detect background propagation. Frames that might // receive a propagated background should just set aForceBackground to // true. if (aBuilder->IsForEventDelivery() || aForceBackground || - !StyleBackground()->IsTransparent(this) || StyleDisplay()->mAppearance) { + !StyleBackground()->IsTransparent(this) || + StyleDisplay()->HasAppearance()) { return nsDisplayBackgroundImage::AppendBackgroundItemsToTop( aBuilder, this, GetRectRelativeToSelf(), aLists.BorderBackground()); } return false; } void nsFrame::DisplayBorderBackgroundOutline(nsDisplayListBuilder* aBuilder, @@ -6245,17 +6246,17 @@ nsIFrame::ComputeTightBounds(DrawTarget* return GetVisualOverflowRect(); } nsRect nsFrame::ComputeSimpleTightBounds(DrawTarget* aDrawTarget) const { if (StyleOutline()->ShouldPaintOutline() || StyleBorder()->HasBorder() || !StyleBackground()->IsTransparent(this) || - StyleDisplay()->mAppearance) { + StyleDisplay()->HasAppearance()) { // Not necessarily tight, due to clipping, negative // outline-offset, and lots of other issues, but that's OK return GetVisualOverflowRect(); } nsRect r(0, 0, 0, 0); ChildListIterator lists(this); for (; !lists.IsDone(); lists.Next()) { @@ -9381,20 +9382,20 @@ ComputeAndIncludeOutlineArea(nsIFrame* a nsRect outerRect(innerRect); bool useOutlineAuto = false; if (nsLayoutUtils::IsOutlineStyleAutoEnabled()) { useOutlineAuto = outline->mOutlineStyle == NS_STYLE_BORDER_STYLE_AUTO; if (MOZ_UNLIKELY(useOutlineAuto)) { nsPresContext* presContext = aFrame->PresContext(); nsITheme* theme = presContext->GetTheme(); if (theme && theme->ThemeSupportsWidget(presContext, aFrame, - NS_THEME_FOCUS_OUTLINE)) { + StyleAppearance::FocusOutline)) { outerRect.Inflate(offset); theme->GetWidgetOverflow(presContext->DeviceContext(), aFrame, - NS_THEME_FOCUS_OUTLINE, &outerRect); + StyleAppearance::FocusOutline, &outerRect); } else { useOutlineAuto = false; } } } if (MOZ_LIKELY(!useOutlineAuto)) { nscoord width = outline->GetOutlineWidth(); outerRect.Inflate(width + offset);
--- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -48,17 +48,17 @@ #include "FrameLayerBuilder.h" #include "nsSMILKeySpline.h" #include "nsSubDocumentFrame.h" #include "nsSVGOuterSVGFrame.h" #include "nsIObjectLoadingContent.h" #include "mozilla/Attributes.h" #include "ScrollbarActivity.h" #include "nsRefreshDriver.h" -#include "nsThemeConstants.h" +#include "nsStyleConsts.h" #include "nsSVGIntegrationUtils.h" #include "nsIScrollPositionListener.h" #include "StickyScrollContainer.h" #include "nsIFrameInlines.h" #include "nsILayoutHistoryState.h" #include "gfxPlatform.h" #include "gfxPrefs.h" #include "ScrollAnimationPhysics.h" @@ -1268,23 +1268,23 @@ ScrollFrameHelper::GetNondisappearingScr if (LookAndFeel::GetInt(LookAndFeel::eIntID_UseOverlayScrollbars) != 0) { // We're using overlay scrollbars, so we need to get the width that // non-disappearing scrollbars would have. nsITheme* theme = aState->PresContext()->GetTheme(); if (theme && theme->ThemeSupportsWidget(aState->PresContext(), verticalWM ? mHScrollbarBox : mVScrollbarBox, - NS_THEME_SCROLLBAR_NON_DISAPPEARING)) { + StyleAppearance::ScrollbarNonDisappearing)) { LayoutDeviceIntSize size; bool canOverride = true; theme->GetMinimumWidgetSize(aState->PresContext(), verticalWM ? mHScrollbarBox : mVScrollbarBox, - NS_THEME_SCROLLBAR_NON_DISAPPEARING, + StyleAppearance::ScrollbarNonDisappearing, &size, &canOverride); return aState->PresContext()-> DevPixelsToAppUnits(verticalWM ? size.height : size.width); } } nsMargin sizes(GetDesiredScrollbarSizes(aState));
--- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -1685,22 +1685,23 @@ public: */ virtual nscolor GetCaretColorAt(int32_t aOffset); bool IsThemed(nsITheme::Transparency* aTransparencyState = nullptr) const { return IsThemed(StyleDisplay(), aTransparencyState); } bool IsThemed(const nsStyleDisplay* aDisp, - nsITheme::Transparency* aTransparencyState = nullptr) const { + nsITheme::Transparency* aTransparencyState = nullptr) const { + if (!aDisp->HasAppearance()) { + return false; + } nsIFrame* mutable_this = const_cast<nsIFrame*>(this); - if (!aDisp->mAppearance) - return false; nsPresContext* pc = PresContext(); - nsITheme *theme = pc->GetTheme(); + nsITheme* theme = pc->GetTheme(); if(!theme || !theme->ThemeSupportsWidget(pc, mutable_this, aDisp->mAppearance)) return false; if (aTransparencyState) { *aTransparencyState = theme->GetWidgetTransparency(mutable_this, aDisp->mAppearance); } return true;
--- a/layout/painting/nsCSSRendering.cpp +++ b/layout/painting/nsCSSRendering.cpp @@ -34,17 +34,17 @@ #include "nsIDocumentInlines.h" #include "nsIScrollableFrame.h" #include "imgIRequest.h" #include "imgIContainer.h" #include "ImageOps.h" #include "nsCSSRendering.h" #include "nsCSSColorUtils.h" #include "nsITheme.h" -#include "nsThemeConstants.h" +#include "nsStyleConsts.h" #include "nsLayoutUtils.h" #include "nsBlockFrame.h" #include "nsStyleStructInlines.h" #include "nsCSSFrameConstructor.h" #include "nsCSSProps.h" #include "nsContentUtils.h" #include "SVGObserverUtils.h" #include "nsSVGIntegrationUtils.h" @@ -901,17 +901,17 @@ nsCSSRendering::PaintBorderWithStyleBord DrawTarget& aDrawTarget = *aRenderingContext.GetDrawTarget(); PrintAsStringNewline("++ PaintBorder"); // Check to see if we have an appearance defined. If so, we let the theme // renderer draw the border. DO not get the data from aForFrame, since the // passed in ComputedStyle may be different! Always use |aComputedStyle|! const nsStyleDisplay* displayData = aComputedStyle->StyleDisplay(); - if (displayData->mAppearance) { + if (displayData->HasAppearance()) { nsITheme *theme = aPresContext->GetTheme(); if (theme && theme->ThemeSupportsWidget(aPresContext, aForFrame, displayData->mAppearance)) { return ImgDrawResult::SUCCESS; // Let the theme handle it. } } @@ -989,17 +989,17 @@ nsCSSRendering::CreateBorderRendererWith const nsRect& aDirtyRect, const nsRect& aBorderArea, const nsStyleBorder& aStyleBorder, ComputedStyle* aComputedStyle, bool* aOutBorderIsEmpty, Sides aSkipSides) { const nsStyleDisplay* displayData = aComputedStyle->StyleDisplay(); - if (displayData->mAppearance) { + if (displayData->HasAppearance()) { nsITheme *theme = aPresContext->GetTheme(); if (theme && theme->ThemeSupportsWidget(aPresContext, aForFrame, displayData->mAppearance)) { return Nothing(); } } @@ -1109,19 +1109,19 @@ nsCSSRendering::CreateBorderRendererForO RectCornerRadii outlineRadii; ComputePixelRadii(twipsRadii, oneDevPixel, &outlineRadii); uint8_t outlineStyle = ourOutline->mOutlineStyle; if (outlineStyle == NS_STYLE_BORDER_STYLE_AUTO) { if (nsLayoutUtils::IsOutlineStyleAutoEnabled()) { nsITheme* theme = aPresContext->GetTheme(); if (theme && theme->ThemeSupportsWidget(aPresContext, aForFrame, - NS_THEME_FOCUS_OUTLINE)) { + StyleAppearance::FocusOutline)) { theme->DrawWidgetBackground(aRenderingContext, aForFrame, - NS_THEME_FOCUS_OUTLINE, innerRect, + StyleAppearance::FocusOutline, innerRect, aDirtyRect); return Nothing(); } } if (width == 0) { return Nothing(); // empty outline } // http://dev.w3.org/csswg/css-ui/#outline @@ -2025,17 +2025,17 @@ nsCSSRendering::PaintStyleImageLayer(con ComputedStyle *sc; if (!FindBackground(aParams.frame, &sc)) { // We don't want to bail out if moz-appearance is set on a root // node. If it has a parent content node, bail because it's not // a root, otherwise keep going in order to let the theme stuff // draw the background. The canvas really should be drawing the // bg, but there's no way to hook that up via css. - if (!aParams.frame->StyleDisplay()->mAppearance) { + if (!aParams.frame->StyleDisplay()->HasAppearance()) { return ImgDrawResult::SUCCESS; } nsIContent* content = aParams.frame->GetContent(); if (!content || content->GetParent()) { return ImgDrawResult::SUCCESS; } @@ -2058,17 +2058,17 @@ nsCSSRendering::CanBuildWebRenderDisplay } MOZ_ASSERT(aFrame && aLayer >= 0 && (uint32_t)aLayer < aBackgroundStyle->mImage.mLayers.Length()); // We cannot draw native themed backgrounds const nsStyleDisplay* displayData = aFrame->StyleDisplay(); - if (displayData->mAppearance) { + if (displayData->HasAppearance()) { nsITheme *theme = aPresCtx.GetTheme(); if (theme && theme->ThemeSupportsWidget(&aPresCtx, aFrame, displayData->mAppearance)) { return false; } } @@ -2118,17 +2118,17 @@ nsCSSRendering::BuildWebRenderDisplayIte ComputedStyle *sc; if (!FindBackground(aParams.frame, &sc)) { // We don't want to bail out if moz-appearance is set on a root // node. If it has a parent content node, bail because it's not // a root, otherwise keep going in order to let the theme stuff // draw the background. The canvas really should be drawing the // bg, but there's no way to hook that up via css. - if (!aParams.frame->StyleDisplay()->mAppearance) { + if (!aParams.frame->StyleDisplay()->HasAppearance()) { return ImgDrawResult::SUCCESS; } nsIContent* content = aParams.frame->GetContent(); if (!content || content->GetParent()) { return ImgDrawResult::SUCCESS; } @@ -2622,17 +2622,17 @@ nsCSSRendering::PaintStyleImageLayerWith // it was left at its default value. MOZ_ASSERT(aParams.layer != -1 || aParams.compositionOp == CompositionOp::OP_OVER); // Check to see if we have an appearance defined. If so, we let the theme // renderer draw the background and bail out. // XXXzw this ignores aParams.bgClipRect. const nsStyleDisplay* displayData = aParams.frame->StyleDisplay(); - if (displayData->mAppearance) { + if (displayData->HasAppearance()) { nsITheme *theme = aParams.presCtx.GetTheme(); if (theme && theme->ThemeSupportsWidget(&aParams.presCtx, aParams.frame, displayData->mAppearance)) { nsRect drawing(aParams.borderArea); theme->GetWidgetOverflow(aParams.presCtx.DeviceContext(), aParams.frame, displayData->mAppearance, &drawing);
--- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -32,17 +32,17 @@ #include "nsStyleTransformMatrix.h" #include "gfxMatrix.h" #include "gfxPrefs.h" #include "nsSVGIntegrationUtils.h" #include "nsSVGUtils.h" #include "nsLayoutUtils.h" #include "nsIScrollableFrame.h" #include "nsIFrameInlines.h" -#include "nsThemeConstants.h" +#include "nsStyleConsts.h" #include "BorderConsts.h" #include "LayerTreeInvalidation.h" #include "mozilla/MathAlgorithms.h" #include "imgIContainer.h" #include "BasicLayers.h" #include "nsBoxFrame.h" #include "nsImageFrame.h" @@ -3538,17 +3538,17 @@ static nsIFrame* GetBackgroundComputedSt { nsIFrame* f; if (!nsCSSRendering::FindBackgroundFrame(aFrame, &f)) { // We don't want to bail out if moz-appearance is set on a root // node. If it has a parent content node, bail because it's not // a root, other wise keep going in order to let the theme stuff // draw the background. The canvas really should be drawing the // bg, but there's no way to hook that up via css. - if (!aFrame->StyleDisplay()->mAppearance) { + if (!aFrame->StyleDisplay()->HasAppearance()) { return nullptr; } nsIContent* content = aFrame->GetContent(); if (!content || content->GetParent()) { return nullptr; } @@ -4409,18 +4409,18 @@ nsDisplayThemedBackground::Init(nsDispla // Perform necessary RegisterThemeGeometry nsITheme* theme = StyleFrame()->PresContext()->GetTheme(); nsITheme::ThemeGeometryType type = theme->ThemeGeometryTypeForWidget(StyleFrame(), disp->mAppearance); if (type != nsITheme::eThemeGeometryTypeUnknown) { RegisterThemeGeometry(aBuilder, this, StyleFrame(), type); } - if (disp->mAppearance == NS_THEME_WIN_BORDERLESS_GLASS || - disp->mAppearance == NS_THEME_WIN_GLASS) { + if (disp->mAppearance == StyleAppearance::MozWinBorderlessGlass || + disp->mAppearance == StyleAppearance::MozWinGlass) { aBuilder->SetGlassDisplayItem(this); } mBounds = GetBoundsInternal(); } void nsDisplayThemedBackground::WriteDebugInfo(std::stringstream& aStream) @@ -4451,18 +4451,18 @@ nsDisplayThemedBackground::GetOpaqueRegi result = mBackgroundRect; } return result; } Maybe<nscolor> nsDisplayThemedBackground::IsUniform(nsDisplayListBuilder* aBuilder) const { - if (mAppearance == NS_THEME_WIN_BORDERLESS_GLASS || - mAppearance == NS_THEME_WIN_GLASS) { + if (mAppearance == StyleAppearance::MozWinBorderlessGlass || + mAppearance == StyleAppearance::MozWinGlass) { return Some(NS_RGBA(0,0,0,0)); } return Nothing(); } nsRect nsDisplayThemedBackground::GetPositioningArea() const { @@ -4980,17 +4980,17 @@ nsDisplayOutline::CreateWebRenderCommand nsDisplayListBuilder* aDisplayListBuilder) { ContainerLayerParameters parameter; uint8_t outlineStyle = mFrame->Style()->StyleOutline()->mOutlineStyle; if (outlineStyle == NS_STYLE_BORDER_STYLE_AUTO && nsLayoutUtils::IsOutlineStyleAutoEnabled()) { nsITheme* theme = mFrame->PresContext()->GetTheme(); if (theme && theme->ThemeSupportsWidget(mFrame->PresContext(), mFrame, - NS_THEME_FOCUS_OUTLINE)) { + StyleAppearance::FocusOutline)) { return false; } } nsPoint offset = ToReferenceFrame(); mozilla::Maybe<nsCSSBorderRenderer> borderRenderer = nsCSSRendering::CreateBorderRendererForOutline(mFrame->PresContext(),
--- a/layout/painting/nsDisplayList.h +++ b/layout/painting/nsDisplayList.h @@ -939,18 +939,18 @@ public: } return geometries; } /** * Notifies the builder that a particular themed widget exists * at the given rectangle within the currently built display list. - * For certain appearance values (currently only NS_THEME_TOOLBAR and - * NS_THEME_WINDOW_TITLEBAR) this gets called during every display list + * For certain appearance values (currently only StyleAppearance::Toolbar and + * StyleAppearance::WindowTitlebar) this gets called during every display list * construction, for every themed widget of the right type within the * display list, except for themed widgets which are transformed or have * effects applied to them (e.g. CSS opacity or filters). * * @param aWidgetType the -moz-appearance value for the themed widget * @param aItem the item associated with the theme geometry * @param aRect the device-pixel rect relative to the widget's displayRoot * for the themed widget @@ -4353,17 +4353,17 @@ protected: nsRect GetBoundsInternal(); void PaintInternal(nsDisplayListBuilder* aBuilder, gfxContext* aCtx, const nsRect& aBounds, nsRect* aClipRect); nsRect mBackgroundRect; nsRect mBounds; nsITheme::Transparency mThemeTransparency; - uint8_t mAppearance; + mozilla::StyleAppearance mAppearance; }; class nsDisplayTableThemedBackground : public nsDisplayThemedBackground { public: nsDisplayTableThemedBackground(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, const nsRect& aBackgroundRect, nsIFrame* aAncestorFrame) : nsDisplayThemedBackground(aBuilder, aFrame, aBackgroundRect)
--- a/layout/style/ServoBindings.toml +++ b/layout/style/ServoBindings.toml @@ -47,17 +47,17 @@ args = [ "arch=x86_64" = ["--target=x86_64-pc-win32"] [structs] headers = [ "nsStyleStruct.h", "mozilla/StyleAnimationValue.h", "gfxFontConstants.h", "gfxFontFeatures.h", - "nsThemeConstants.h", + "nsStyleConsts.h", "mozilla/css/Loader.h", "mozilla/css/SheetLoadData.h", "mozilla/DeclarationBlock.h", "mozilla/dom/AnimationEffectBinding.h", "mozilla/dom/HTMLSlotElement.h", "mozilla/dom/KeyframeEffectBinding.h", "mozilla/dom/MediaList.h", "mozilla/dom/ShadowRoot.h",
--- a/layout/style/ServoCSSPropList.mako.py +++ b/layout/style/ServoCSSPropList.mako.py @@ -69,16 +69,17 @@ def method(prop): return prop.camel_case # Colors, integers and lengths are easy as well. # # TODO(emilio): This will go away once the rest of the longhands have been # moved or perhaps using a blacklist for the ones with non-layout-dependence # but other non-trivial dependence like scrollbar colors. SERIALIZED_PREDEFINED_TYPES = [ + "Appearance", "Clear", "Color", "Content", "CounterIncrement", "CounterReset", "Float", "FontFamily", "FontFeatureSettings",
--- a/layout/style/ServoStyleConsts.h +++ b/layout/style/ServoStyleConsts.h @@ -11,16 +11,247 @@ * 2. Run `rustup run nightly cbindgen toolkit/library/rust/ --lockfile Cargo.lock --crate style -o layout/style/ServoStyleConsts.h` */ #include <cstdint> #include <cstdlib> namespace mozilla { +// The value for the `appearance` property. +// +// https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-appearance +// +// NOTE(emilio): When changing this you may want to regenerate the C++ bindings +// (see components/style/cbindgen.toml) +enum class StyleAppearance : uint8_t { + // No appearance at all. + None, + // A typical dialog button. + Button, + // Various arrows that go in buttons + ButtonArrowDown, + ButtonArrowNext, + ButtonArrowPrevious, + ButtonArrowUp, + // A rectangular button that contains complex content + // like images (e.g. HTML <button> elements) + ButtonBevel, + // The focus outline box inside of a button. + ButtonFocus, + // The caret of a text area + Caret, + // A dual toolbar button (e.g., a Back button with a dropdown) + Dualbutton, + // A groupbox. + Groupbox, + // A inner-spin button. + InnerSpinButton, + // List boxes. + Listbox, + // A listbox item. + Listitem, + // Menu Bar background + Menubar, + // <menu> and <menuitem> appearances + Menuitem, + Checkmenuitem, + Radiomenuitem, + // For text on non-iconic menuitems only + Menuitemtext, + // A dropdown list. + Menulist, + // The dropdown button(s) that open up a dropdown list. + MenulistButton, + // The text part of a dropdown list, to left of button. + MenulistText, + // An editable textfield with a dropdown list (a combobox). + MenulistTextfield, + // Menu Popup background. + Menupopup, + // menu checkbox/radio appearances + Menucheckbox, + Menuradio, + Menuseparator, + Menuarrow, + // An image in the menu gutter, like in bookmarks or history. + Menuimage, + // A horizontal meter bar. + Meterbar, + // The meter bar's meter indicator. + Meterchunk, + // For HTML's <input type=number> + NumberInput, + // A horizontal progress bar. + Progressbar, + // The progress bar's progress indicator + Progresschunk, + // A vertical progress bar. + ProgressbarVertical, + // A vertical progress chunk. + ProgresschunkVertical, + // A checkbox element. + Checkbox, + // A radio element within a radio group. + Radio, + // A generic container that always repaints on state changes. This is a + // hack to make XUL checkboxes and radio buttons work. + CheckboxContainer, + RadioContainer, + // The label part of a checkbox or radio button, used for painting a focus + // outline. + CheckboxLabel, + RadioLabel, + // nsRangeFrame and its subparts + Range, + RangeThumb, + // The resizer background area in a status bar for the resizer widget in + // the corner of a window. + Resizerpanel, + // The resizer itself. + Resizer, + // A slider. + ScaleHorizontal, + ScaleVertical, + // A slider's thumb. + ScalethumbHorizontal, + ScalethumbVertical, + // If the platform supports it, the left/right chunks of the slider thumb. + Scalethumbstart, + Scalethumbend, + // The ticks for a slider. + Scalethumbtick, + // A scrollbar. + Scrollbar, + // A small scrollbar. + ScrollbarSmall, + // The scrollbar slider + ScrollbarHorizontal, + ScrollbarVertical, + // A scrollbar button (up/down/left/right). + // Keep these in order (some code casts these values to `int` in order to + // compare them against each other). + ScrollbarbuttonDown, + ScrollbarbuttonLeft, + ScrollbarbuttonRight, + ScrollbarbuttonUp, + // The scrollbar thumb. + ScrollbarthumbHorizontal, + ScrollbarthumbVertical, + ScrollbartrackHorizontal, + ScrollbartrackVertical, + // The scroll corner + Scrollcorner, + // A searchfield. + Searchfield, + // A separator. Can be horizontal or vertical. + Separator, + // A spin control (up/down control for time/date pickers). + Spinner, + // The up button of a spin control. + SpinnerUpbutton, + // The down button of a spin control. + SpinnerDownbutton, + // The textfield of a spin control + SpinnerTextfield, + // A splitter. Can be horizontal or vertical. + Splitter, + // A status bar in a main application window. + Statusbar, + // A single pane of a status bar. + Statusbarpanel, + // A single tab in a tab widget. + Tab, + // A single pane (inside the tabpanels container). + Tabpanel, + // The tab panels container. + Tabpanels, + // The tabs scroll arrows (left/right). + TabScrollArrowBack, + TabScrollArrowForward, + // A textfield or text area. + Textfield, + // A multiline text field. + TextfieldMultiline, + // A toolbar in an application window. + Toolbar, + // A single toolbar button (with no associated dropdown). + Toolbarbutton, + // The dropdown portion of a toolbar button + ToolbarbuttonDropdown, + // The gripper for a toolbar. + Toolbargripper, + // The toolbox that contains the toolbars. + Toolbox, + // A tooltip. + Tooltip, + // A listbox or tree widget header + Treeheader, + // An individual header cell + Treeheadercell, + // The sort arrow for a header. + Treeheadersortarrow, + // A tree item. + Treeitem, + // A tree widget branch line + Treeline, + // A tree widget twisty. + Treetwisty, + // Open tree widget twisty. + Treetwistyopen, + // A tree widget. + Treeview, + // Window and dialog backgrounds. + Window, + Dialog, + // Vista Rebars. + MozWinCommunicationsToolbox, + MozWinMediaToolbox, + MozWinBrowsertabbarToolbox, + // Vista glass. + MozWinGlass, + MozWinBorderlessGlass, + // -moz-apperance style used in setting proper glass margins. + MozWinExcludeGlass, + // Titlebar elements on the Mac. + MozMacFullscreenButton, + // Mac help button. + MozMacHelpButton, + // Windows themed window frame elements. + MozWindowButtonBox, + MozWindowButtonBoxMaximized, + MozWindowButtonClose, + MozWindowButtonMaximize, + MozWindowButtonMinimize, + MozWindowButtonRestore, + MozWindowFrameBottom, + MozWindowFrameLeft, + MozWindowFrameRight, + MozWindowTitlebar, + MozWindowTitlebarMaximized, + MozGtkInfoBar, + MozMacActiveSourceListSelection, + MozMacDisclosureButtonClosed, + MozMacDisclosureButtonOpen, + MozMacSourceList, + MozMacSourceListSelection, + MozMacVibrancyDark, + MozMacVibrancyLight, + MozMacVibrantTitlebarDark, + MozMacVibrantTitlebarLight, + // A non-disappearing scrollbar. + ScrollbarNonDisappearing, + // A themed focus outline (for outline:auto). + // + // This isn't exposed to CSS at all, just here for convenience. + FocusOutline, + // A dummy variant that should be last to let the GTK widget do hackery. + Count, +}; + // Defines an element’s display type, which consists of // the two basic qualities of how an element generates boxes // <https://drafts.csswg.org/css-display/#propdef-display> // // // NOTE(emilio): Order is important in Gecko! // // If you change it, make sure to take a look at the
--- a/layout/style/nsCSSProps.cpp +++ b/layout/style/nsCSSProps.cpp @@ -13,17 +13,17 @@ #include "mozilla/ArrayUtils.h" #include "mozilla/Casting.h" #include "nsCSSKeywords.h" #include "nsLayoutUtils.h" #include "nsStyleConsts.h" #include "nsIWidget.h" -#include "nsThemeConstants.h" // For system widget appearance types +#include "nsStyleConsts.h" // For system widget appearance types #include "mozilla/dom/Animation.h" #include "mozilla/dom/AnimationEffectBinding.h" // for PlaybackDirection #include "mozilla/LookAndFeel.h" // for system colors #include "nsString.h" #include "nsStaticNameTable.h"
--- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -16,17 +16,17 @@ #include "nsError.h" #include "nsIFrame.h" #include "nsIFrameInlines.h" #include "mozilla/ComputedStyle.h" #include "nsIScrollableFrame.h" #include "nsContentUtils.h" #include "nsIContent.h" -#include "nsThemeConstants.h" +#include "nsStyleConsts.h" #include "nsDOMCSSRect.h" #include "nsDOMCSSRGBColor.h" #include "nsDOMCSSValueList.h" #include "nsFlexContainerFrame.h" #include "nsGridContainerFrame.h" #include "nsGkAtoms.h" #include "mozilla/ReflowInput.h" @@ -1144,17 +1144,17 @@ nsComputedDOMStyle::SetValueFromComplexC const StyleComplexColor& aColor) { SetToRGBAColor(aValue, aColor.CalcColor(mComputedStyle)); } void nsComputedDOMStyle::SetValueForWidgetColor(nsROCSSPrimitiveValue* aValue, const StyleComplexColor& aColor, - uint8_t aWidgetType) + StyleAppearance aWidgetType) { if (!aColor.IsAuto()) { SetToRGBAColor(aValue, aColor.CalcColor(mComputedStyle)); return; } nsPresContext* presContext = mPresShell->GetPresContext(); MOZ_ASSERT(presContext); if (nsContentUtils::ShouldResistFingerprinting(presContext->GetDocShell())) { @@ -2982,26 +2982,26 @@ nsComputedDOMStyle::DoGetScrollSnapCoord } } already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetScrollbarFaceColor() { RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue; SetValueForWidgetColor(val, StyleUserInterface()->mScrollbarFaceColor, - NS_THEME_SCROLLBARTHUMB_VERTICAL); + StyleAppearance::ScrollbarthumbVertical); return val.forget(); } already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetScrollbarTrackColor() { RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue; SetValueForWidgetColor(val, StyleUserInterface()->mScrollbarTrackColor, - NS_THEME_SCROLLBAR_VERTICAL); + StyleAppearance::ScrollbarVertical); return val.forget(); } already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetOutlineWidth() { RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
--- a/layout/style/nsComputedDOMStyle.h +++ b/layout/style/nsComputedDOMStyle.h @@ -484,17 +484,17 @@ private: already_AddRefed<CSSValue> DummyGetter(); /* Helper functions */ void SetToRGBAColor(nsROCSSPrimitiveValue* aValue, nscolor aColor); void SetValueFromComplexColor(nsROCSSPrimitiveValue* aValue, const mozilla::StyleComplexColor& aColor); void SetValueForWidgetColor(nsROCSSPrimitiveValue* aValue, const mozilla::StyleComplexColor& aColor, - uint8_t aWidgetType); + mozilla::StyleAppearance aWidgetType); void SetValueToStyleImage(const nsStyleImage& aStyleImage, nsROCSSPrimitiveValue* aValue); void SetValueToPositionCoord(const mozilla::Position::Coord& aCoord, nsROCSSPrimitiveValue* aValue); void SetValueToPosition(const mozilla::Position& aPosition, nsDOMCSSValueList* aValueList); void SetValueToURLValue(const mozilla::css::URLValueData* aURL, nsROCSSPrimitiveValue* aValue);
--- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -7,17 +7,17 @@ /* * structs that contain the data provided by ComputedStyle, the * internal API for computed style data for an element */ #include "nsStyleStruct.h" #include "nsStyleStructInlines.h" #include "nsStyleConsts.h" -#include "nsThemeConstants.h" +#include "nsStyleConsts.h" #include "nsString.h" #include "nsPresContext.h" #include "nsIAppShellService.h" #include "nsIWidget.h" #include "nsCRTGlue.h" #include "nsCSSProps.h" #include "nsDeviceContext.h" #include "nsStyleUtil.h" @@ -3479,17 +3479,17 @@ StyleAnimation::operator==(const StyleAn // -------------------- // nsStyleDisplay // nsStyleDisplay::nsStyleDisplay(const nsPresContext* aContext) : mDisplay(StyleDisplay::Inline) , mOriginalDisplay(StyleDisplay::Inline) , mContain(NS_STYLE_CONTAIN_NONE) - , mAppearance(NS_THEME_NONE) + , mAppearance(StyleAppearance::None) , mPosition(NS_STYLE_POSITION_STATIC) , mFloat(StyleFloat::None) , mOriginalFloat(StyleFloat::None) , mBreakType(StyleClear::None) , mBreakInside(NS_STYLE_PAGE_BREAK_AUTO) , mBreakBefore(false) , mBreakAfter(false) , mOverflowX(NS_STYLE_OVERFLOW_VISIBLE) @@ -3718,20 +3718,20 @@ nsStyleDisplay::CalcDifference(const nsS || mScrollSnapPointsX != aNewData.mScrollSnapPointsX || mScrollSnapPointsY != aNewData.mScrollSnapPointsY || mScrollSnapDestination != aNewData.mScrollSnapDestination || mTopLayer != aNewData.mTopLayer || mResize != aNewData.mResize) { return nsChangeHint_ReconstructFrame; } - if ((mAppearance == NS_THEME_TEXTFIELD && - aNewData.mAppearance != NS_THEME_TEXTFIELD) || - (mAppearance != NS_THEME_TEXTFIELD && - aNewData.mAppearance == NS_THEME_TEXTFIELD)) { + if ((mAppearance == StyleAppearance::Textfield && + aNewData.mAppearance != StyleAppearance::Textfield) || + (mAppearance != StyleAppearance::Textfield && + aNewData.mAppearance == StyleAppearance::Textfield)) { // This is for <input type=number> where we allow authors to specify a // |-moz-appearance:textfield| to get a control without a spinner. (The // spinner is present for |-moz-appearance:number-input| but also other // values such as 'none'.) We need to reframe since we want to use // nsTextControlFrame instead of nsNumberControlFrame if the author // specifies 'textfield'. return nsChangeHint_ReconstructFrame; }
--- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -2068,17 +2068,17 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt RefPtr<mozilla::css::URLValue> mBinding; mozilla::StyleDisplay mDisplay; mozilla::StyleDisplay mOriginalDisplay; // saved mDisplay for // position:absolute/fixed // and float:left/right; // otherwise equal to // mDisplay uint8_t mContain; // NS_STYLE_CONTAIN_* - uint8_t mAppearance; // NS_THEME_* + mozilla::StyleAppearance mAppearance; uint8_t mPosition; // NS_STYLE_POSITION_* mozilla::StyleFloat mFloat; // Save mFloat for position:absolute/fixed; otherwise equal to mFloat. mozilla::StyleFloat mOriginalFloat; mozilla::StyleClear mBreakType; uint8_t mBreakInside; // NS_STYLE_PAGE_BREAK_AUTO/AVOID @@ -2218,16 +2218,21 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt // The threshold used for extracting a shape from shape-outside: <image>. float mShapeImageThreshold = 0.0f; // The margin around a shape-outside: <image>. nsStyleCoord mShapeMargin; mozilla::StyleShapeSource mShapeOutside; + bool HasAppearance() const + { + return mAppearance != mozilla::StyleAppearance::None; + } + bool IsBlockInsideStyle() const { return mozilla::StyleDisplay::Block == mDisplay || mozilla::StyleDisplay::ListItem == mDisplay || mozilla::StyleDisplay::InlineBlock == mDisplay || mozilla::StyleDisplay::TableCaption == mDisplay || mozilla::StyleDisplay::FlowRoot == mDisplay; // Should TABLE_CELL be included here? They have // block frames nested inside of them.
--- a/layout/tables/nsTableCellFrame.cpp +++ b/layout/tables/nsTableCellFrame.cpp @@ -493,17 +493,17 @@ nsTableCellFrame::BuildDisplayList(nsDis if (hasBoxShadow) { aLists.BorderBackground()->AppendToTop( MakeDisplayItem<nsDisplayBoxShadowOuter>(aBuilder, this)); } // display background if we need to. if (aBuilder->IsForEventDelivery() || !StyleBackground()->IsTransparent(this) || - StyleDisplay()->mAppearance) { + StyleDisplay()->HasAppearance()) { nsDisplayBackgroundImage::AppendBackgroundItemsToTop(aBuilder, this, GetRectRelativeToSelf(), aLists.BorderBackground()); } // display inset box-shadows if we need to. if (hasBoxShadow) {
--- a/layout/xul/nsBox.cpp +++ b/layout/xul/nsBox.cpp @@ -165,17 +165,17 @@ nsIFrame::GetXULBorderAndPadding(nsMargi } nsresult nsBox::GetXULBorder(nsMargin& aMargin) { aMargin.SizeTo(0,0,0,0); const nsStyleDisplay* disp = StyleDisplay(); - if (disp->mAppearance && gTheme) { + if (disp->HasAppearance() && gTheme) { // Go to the theme for the border. nsPresContext *context = PresContext(); if (gTheme->ThemeSupportsWidget(context, this, disp->mAppearance)) { LayoutDeviceIntMargin margin = gTheme->GetWidgetBorder(context->DeviceContext(), this, disp->mAppearance); aMargin = LayoutDevicePixel::ToAppUnits(margin, context->AppUnitsPerDevPixel()); @@ -187,17 +187,17 @@ nsBox::GetXULBorder(nsMargin& aMargin) return NS_OK; } nsresult nsBox::GetXULPadding(nsMargin& aPadding) { const nsStyleDisplay *disp = StyleDisplay(); - if (disp->mAppearance && gTheme) { + if (disp->HasAppearance() && gTheme) { // Go to the theme for the padding. nsPresContext *context = PresContext(); if (gTheme->ThemeSupportsWidget(context, this, disp->mAppearance)) { LayoutDeviceIntMargin padding; bool useThemePadding = gTheme->GetWidgetPadding(context->DeviceContext(), this, disp->mAppearance, &padding); if (useThemePadding) { @@ -529,17 +529,17 @@ nsIFrame::AddXULMinSize(nsBoxLayoutState { aWidthSet = false; aHeightSet = false; bool canOverride = true; // See if a native theme wants to supply a minimum size. const nsStyleDisplay* display = aBox->StyleDisplay(); - if (display->mAppearance) { + if (display->HasAppearance()) { nsITheme *theme = aState.PresContext()->GetTheme(); if (theme && theme->ThemeSupportsWidget(aState.PresContext(), aBox, display->mAppearance)) { LayoutDeviceIntSize size; theme->GetMinimumWidgetSize(aState.PresContext(), aBox, display->mAppearance, &size, &canOverride); if (size.width) { aSize.width = aState.PresContext()->DevPixelsToAppUnits(size.width); aWidthSet = true;
--- a/layout/xul/nsBoxFrame.cpp +++ b/layout/xul/nsBoxFrame.cpp @@ -57,17 +57,17 @@ #include "nsWidgetsCID.h" #include "nsCSSAnonBoxes.h" #include "nsContainerFrame.h" #include "nsITheme.h" #include "nsTransform2D.h" #include "mozilla/EventStateManager.h" #include "nsDisplayList.h" #include "mozilla/Preferences.h" -#include "nsThemeConstants.h" +#include "nsStyleConsts.h" #include "nsLayoutUtils.h" #include "nsSliderFrame.h" #include <algorithm> // Needed for Print Preview #include "nsIURI.h" #include "mozilla/TouchEvents.h" @@ -1155,17 +1155,17 @@ nsBoxFrame::BuildDisplayList(nsDisplayLi if (GetContent()->IsXULElement()) { // forcelayer is only supported on XUL elements with box layout if (GetContent()->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::layer)) { forceLayer = true; } // Check for frames that are marked as a part of the region used // in calculating glass margins on Windows. const nsStyleDisplay* styles = StyleDisplay(); - if (styles && styles->mAppearance == NS_THEME_WIN_EXCLUDE_GLASS) { + if (styles && styles->mAppearance == StyleAppearance::MozWinExcludeGlass) { aBuilder->AddWindowExcludeGlassRegion( this, nsRect(aBuilder->ToReferenceFrame(this), GetSize())); } } nsDisplayListCollection tempLists(aBuilder); const nsDisplayListSet& destination = forceLayer ? tempLists : aLists;
--- a/layout/xul/nsImageBoxFrame.cpp +++ b/layout/xul/nsImageBoxFrame.cpp @@ -262,19 +262,19 @@ nsImageBoxFrame::UpdateImage() mImageRequest, &mRequestRegistered); } } } } else { // Only get the list-style-image if we aren't being drawn // by a native theme. - uint8_t appearance = StyleDisplay()->mAppearance; - if (!(appearance && nsBox::gTheme && - nsBox::gTheme->ThemeSupportsWidget(nullptr, this, appearance))) { + auto* display = StyleDisplay(); + if (!(display->HasAppearance() && nsBox::gTheme && + nsBox::gTheme->ThemeSupportsWidget(nullptr, this, display->mAppearance))) { // get the list-style-image imgRequestProxy *styleRequest = StyleList()->GetListStyleImage(); if (styleRequest) { styleRequest->SyncClone(mListener, mContent->GetComposedDoc(), getter_AddRefs(mImageRequest)); } } @@ -656,17 +656,17 @@ nsImageBoxFrame::DidSetComputedStyle(Com const nsStyleList* myList = StyleList(); mSubRect = myList->mImageRegion; // before |mSuppressStyleCheck| test! if (mUseSrcAttr || mSuppressStyleCheck) return; // No more work required, since the image isn't specified by style. // If we're using a native theme implementation, we shouldn't draw anything. const nsStyleDisplay* disp = StyleDisplay(); - if (disp->mAppearance && nsBox::gTheme && + if (disp->HasAppearance() && nsBox::gTheme && nsBox::gTheme->ThemeSupportsWidget(nullptr, this, disp->mAppearance)) return; // If list-style-image changes, we have a new image. nsCOMPtr<nsIURI> oldURI, newURI; if (mImageRequest) mImageRequest->GetURI(getter_AddRefs(oldURI)); if (myList->GetListStyleImage())
--- a/layout/xul/nsMenuPopupFrame.cpp +++ b/layout/xul/nsMenuPopupFrame.cpp @@ -36,17 +36,17 @@ #include "nsPIWindowRoot.h" #include "nsIReflowCallback.h" #include "nsBindingManager.h" #include "nsIDocShellTreeOwner.h" #include "nsIBaseWindow.h" #include "nsISound.h" #include "nsIScreenManager.h" #include "nsIServiceManager.h" -#include "nsThemeConstants.h" +#include "nsStyleConsts.h" #include "nsTransitionManager.h" #include "nsDisplayList.h" #include "nsIDOMXULSelectCntrlItemEl.h" #include "mozilla/EventDispatcher.h" #include "mozilla/EventStateManager.h" #include "mozilla/EventStates.h" #include "mozilla/Preferences.h" #include "mozilla/LookAndFeel.h" @@ -354,22 +354,23 @@ nsMenuPopupFrame::CreateWidgetForView(ns uint8_t nsMenuPopupFrame::GetShadowStyle() { uint8_t shadow = StyleUIReset()->mWindowShadow; if (shadow != NS_STYLE_WINDOW_SHADOW_DEFAULT) return shadow; switch (StyleDisplay()->mAppearance) { - case NS_THEME_TOOLTIP: + case StyleAppearance::Tooltip: return NS_STYLE_WINDOW_SHADOW_TOOLTIP; - case NS_THEME_MENUPOPUP: + case StyleAppearance::Menupopup: return NS_STYLE_WINDOW_SHADOW_MENU; + default: + return NS_STYLE_WINDOW_SHADOW_DEFAULT; } - return NS_STYLE_WINDOW_SHADOW_DEFAULT; } NS_IMETHODIMP nsXULPopupShownEvent::Run() { nsMenuPopupFrame* popup = do_QueryFrame(mPopup->GetPrimaryFrame()); // Set the state to visible if the popup is still open. if (popup && popup->IsOpen()) { popup->SetPopupState(ePopupShown);
--- a/layout/xul/nsScrollbarFrame.cpp +++ b/layout/xul/nsScrollbarFrame.cpp @@ -14,17 +14,17 @@ #include "nsScrollbarFrame.h" #include "nsSliderFrame.h" #include "nsScrollbarButtonFrame.h" #include "nsContentCreatorFunctions.h" #include "nsGkAtoms.h" #include "nsIScrollableFrame.h" #include "nsIScrollbarMediator.h" #include "mozilla/LookAndFeel.h" -#include "nsThemeConstants.h" +#include "nsStyleConsts.h" #include "nsIContent.h" #include "mozilla/dom/MutationEventBinding.h" using namespace mozilla; // // NS_NewScrollbarFrame // @@ -182,20 +182,20 @@ nsresult nsScrollbarFrame::GetXULMargin(nsMargin& aMargin) { nsresult rv = NS_ERROR_FAILURE; aMargin.SizeTo(0,0,0,0); if (LookAndFeel::GetInt(LookAndFeel::eIntID_UseOverlayScrollbars) != 0) { nsPresContext* presContext = PresContext(); nsITheme* theme = presContext->GetTheme(); - if (theme && theme->ThemeSupportsWidget(presContext, this, NS_THEME_SCROLLBAR)) { + if (theme && theme->ThemeSupportsWidget(presContext, this, StyleAppearance::Scrollbar)) { LayoutDeviceIntSize size; bool isOverridable; - theme->GetMinimumWidgetSize(presContext, this, NS_THEME_SCROLLBAR, &size, + theme->GetMinimumWidgetSize(presContext, this, StyleAppearance::Scrollbar, &size, &isOverridable); if (IsXULHorizontal()) { aMargin.top = -presContext->DevPixelsToAppUnits(size.height); } else { aMargin.left = -presContext->DevPixelsToAppUnits(size.width); } rv = NS_OK; }
--- a/layout/xul/tree/nsTreeBodyFrame.cpp +++ b/layout/xul/tree/nsTreeBodyFrame.cpp @@ -42,17 +42,17 @@ #include "nsViewManager.h" #include "nsVariant.h" #include "nsWidgetsCID.h" #include "nsBoxFrame.h" #include "nsIURL.h" #include "nsBoxLayoutState.h" #include "nsTreeContentView.h" #include "nsTreeUtils.h" -#include "nsThemeConstants.h" +#include "nsStyleConsts.h" #include "nsITheme.h" #include "imgIRequest.h" #include "imgIContainer.h" #include "imgILoader.h" #include "mozilla/dom/NodeInfo.h" #include "nsContentUtils.h" #include "nsLayoutUtils.h" #include "nsIScrollableFrame.h" @@ -1985,17 +1985,17 @@ nsTreeBodyFrame::GetTwistyRect(int32_t a if (aImageRect.width > aTwistyRect.width) aImageRect.width = aTwistyRect.width; else aTwistyRect.width = aImageRect.width; bool useTheme = false; nsITheme *theme = nullptr; const nsStyleDisplay* twistyDisplayData = aTwistyContext->StyleDisplay(); - if (twistyDisplayData->mAppearance) { + if (twistyDisplayData->mAppearance != StyleAppearance::None) { theme = aPresContext->GetTheme(); if (theme && theme->ThemeSupportsWidget(aPresContext, nullptr, twistyDisplayData->mAppearance)) useTheme = true; } if (useTheme) { LayoutDeviceIntSize minTwistySizePx; bool canOverride = true; @@ -2770,32 +2770,32 @@ nsTreeBodyFrame::BuildDisplayList(nsDisp nsCOMPtr<nsITreeSelection> selection; mView->GetSelection(getter_AddRefs(selection)); nsITheme* theme = PresContext()->GetTheme(); // On Mac, we support native theming of selected rows. On 10.10 and higher, // this means applying vibrancy which require us to register the theme // geometrics for the row. In order to make the vibrancy effect to work // properly, we also need the tree to be themed as a source list. if (selection && treeFrame && theme && - treeFrame->StyleDisplay()->mAppearance == NS_THEME_MAC_SOURCE_LIST) { + treeFrame->StyleDisplay()->mAppearance == StyleAppearance::MozMacSourceList) { // Loop through our onscreen rows. If the row is selected and a // -moz-appearance is provided, RegisterThemeGeometry might be necessary. const auto end = std::min(mRowCount, LastVisibleRow() + 1); for (auto i = FirstVisibleRow(); i < end; i++) { bool isSelected; selection->IsSelected(i, &isSelected); if (isSelected) { PrefillPropertyArray(i, nullptr); nsAutoString properties; mView->GetRowProperties(i, properties); nsTreeUtils::TokenizeProperties(properties, mScratchArray); ComputedStyle* rowContext = GetPseudoComputedStyle(nsCSSAnonBoxes::mozTreeRow); auto appearance = rowContext->StyleDisplay()->mAppearance; - if (appearance) { + if (appearance != StyleAppearance::None) { if (theme->ThemeSupportsWidget(PresContext(), this, appearance)) { nsITheme::ThemeGeometryType type = theme->ThemeGeometryTypeForWidget(this, appearance); if (type != nsITheme::eThemeGeometryTypeUnknown) { nsRect rowRect(mInnerBox.x, mInnerBox.y + mRowHeight * (i - FirstVisibleRow()), mInnerBox.width, mRowHeight); aBuilder->RegisterThemeGeometry(type, item, @@ -2963,17 +2963,17 @@ nsTreeBodyFrame::PaintRow(int32_t rowContext->StyleMargin()->GetMargin(rowMargin); rowRect.Deflate(rowMargin); ImgDrawResult result = ImgDrawResult::SUCCESS; // Paint our borders and background for our row rect. nsITheme* theme = nullptr; auto appearance = rowContext->StyleDisplay()->mAppearance; - if (appearance) { + if (appearance != StyleAppearance::None) { theme = aPresContext->GetTheme(); } if (theme && theme->ThemeSupportsWidget(aPresContext, nullptr, appearance)) { nsRect dirty; dirty.IntersectRect(rowRect, aDirtyRect); theme->DrawWidgetBackground(&aRenderingContext, this, appearance, rowRect, dirty); @@ -3093,17 +3093,17 @@ nsTreeBodyFrame::PaintSeparator(int32_t gfxContext& aRenderingContext, const nsRect& aDirtyRect) { // Resolve style for the separator. ComputedStyle* separatorContext = GetPseudoComputedStyle(nsCSSAnonBoxes::mozTreeSeparator); bool useTheme = false; nsITheme *theme = nullptr; const nsStyleDisplay* displayData = separatorContext->StyleDisplay(); - if ( displayData->mAppearance ) { + if (displayData->HasAppearance()) { theme = aPresContext->GetTheme(); if (theme && theme->ThemeSupportsWidget(aPresContext, nullptr, displayData->mAppearance)) useTheme = true; } ImgDrawResult result = ImgDrawResult::SUCCESS; // use -moz-appearance if provided.
--- a/servo/components/style/cbindgen.toml +++ b/servo/components/style/cbindgen.toml @@ -17,10 +17,10 @@ namespaces = ["mozilla"] [struct] derive_eq = true [enum] derive_helper_methods = true [export] prefix = "Style" -include = ["StyleDisplay"] +include = ["StyleDisplay", "StyleAppearance"] item_types = ["enums"]
--- a/servo/components/style/properties/gecko.mako.rs +++ b/servo/components/style/properties/gecko.mako.rs @@ -363,16 +363,44 @@ impl ${style_struct.gecko_struct_name} { <%! def get_gecko_property(ffi_name, self_param = "self"): return "%s.gecko.%s" % (self_param, ffi_name) def set_gecko_property(ffi_name, expr): return "self.gecko.%s = %s;" % (ffi_name, expr) %> +<%def name="impl_cbindgen_keyword(ident, gecko_ffi_name)"> + #[allow(non_snake_case)] + #[inline] + pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) { + // unsafe: cbindgen ensures the representations match. + ${set_gecko_property(gecko_ffi_name, "unsafe { transmute(v) }")} + } + + #[allow(non_snake_case)] + #[inline] + pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T { + // unsafe: cbindgen ensures the representations match. + unsafe { transmute(${get_gecko_property(gecko_ffi_name)}) } + } + + #[allow(non_snake_case)] + #[inline] + pub fn copy_${ident}_from(&mut self, other: &Self) { + self.gecko.${gecko_ffi_name} = other.gecko.${gecko_ffi_name}; + } + + #[allow(non_snake_case)] + #[inline] + pub fn reset_${ident}(&mut self, other: &Self) { + self.copy_${ident}_from(other) + } +</%def> + <%def name="impl_keyword_setter(ident, gecko_ffi_name, keyword, cast_type='u8', on_set=None)"> #[allow(non_snake_case)] pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) { use properties::longhands::${ident}::computed_value::T as Keyword; // FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts let result = match v { % for value in keyword.values_for('gecko'): Keyword::${to_camel_case(value)} => @@ -3010,17 +3038,17 @@ fn static_assert() { let list = unsafe { (*self.gecko.${gecko_ffi_name}.to_safe().get()).mHead.as_ref() }; let mut transform = clone_transform_from_list(list); debug_assert_eq!(transform.0.len(), 1); ${type}::from_transform_operation(&transform.0.pop().unwrap()) } </%def> -<% skip_box_longhands= """display overflow-y vertical-align +<% skip_box_longhands= """display -moz-appearance overflow-y vertical-align animation-name animation-delay animation-duration animation-direction animation-fill-mode animation-play-state animation-iteration-count animation-timing-function transition-duration transition-delay transition-timing-function transition-property page-break-before page-break-after rotate scroll-snap-points-x scroll-snap-points-y scroll-snap-type-x scroll-snap-type-y scroll-snap-coordinate @@ -3060,16 +3088,18 @@ fn static_assert() { } #[inline] pub fn clone_display(&self) -> longhands::display::computed_value::T { // unsafe: cbindgen ensures the representation is the same. unsafe { transmute(self.gecko.mDisplay) } } + ${impl_cbindgen_keyword('_moz_appearance', 'mAppearance')} + <% float_keyword = Keyword("float", "Left Right None", gecko_enum_prefix="StyleFloat") %> ${impl_keyword('float', 'mFloat', float_keyword)} <% clear_keyword = Keyword( "clear", "Left Right None Both", gecko_enum_prefix="StyleClear", gecko_inexhaustive=True,
--- a/servo/components/style/properties/longhands/box.mako.rs +++ b/servo/components/style/properties/longhands/box.mako.rs @@ -503,51 +503,26 @@ "specified::Contain::empty()", animation_value_type="discrete", products="gecko", flags="CREATES_STACKING_CONTEXT FIXPOS_CB", gecko_pref="layout.css.contain.enabled", spec="https://drafts.csswg.org/css-contain/#contain-property")} // Non-standard -${helpers.single_keyword("-moz-appearance", - """none button button-arrow-down button-arrow-next button-arrow-previous button-arrow-up - button-bevel button-focus caret checkbox checkbox-container checkbox-label checkmenuitem - dialog dualbutton groupbox inner-spin-button listbox listitem menuarrow menubar menucheckbox - menuimage menuitem menuitemtext menulist menulist-button menulist-text menulist-textfield - menupopup menuradio menuseparator meterbar meterchunk number-input progressbar - progressbar-vertical progresschunk progresschunk-vertical radio radio-container radio-label - radiomenuitem range range-thumb resizer resizerpanel scale-horizontal scalethumbend - scalethumb-horizontal scalethumbstart scalethumbtick scalethumb-vertical scale-vertical - scrollbar scrollbar-horizontal scrollbar-small scrollbar-vertical scrollbarbutton-down - scrollbarbutton-left scrollbarbutton-right scrollbarbutton-up scrollbarthumb-horizontal - scrollbarthumb-vertical scrollbartrack-horizontal scrollbartrack-vertical scrollcorner - searchfield separator - spinner spinner-downbutton spinner-textfield spinner-upbutton splitter statusbar - statusbarpanel tab tabpanel tabpanels tab-scroll-arrow-back tab-scroll-arrow-forward - textfield textfield-multiline toolbar toolbarbutton toolbarbutton-dropdown toolbargripper - toolbox tooltip treeheader treeheadercell treeheadersortarrow treeitem treeline treetwisty - treetwistyopen treeview window - -moz-gtk-info-bar -moz-mac-active-source-list-selection -moz-mac-disclosure-button-closed - -moz-mac-disclosure-button-open -moz-mac-fullscreen-button -moz-mac-help-button - -moz-mac-source-list -moz-mac-source-list-selection -moz-mac-vibrancy-dark - -moz-mac-vibrancy-light -moz-mac-vibrant-titlebar-light -moz-mac-vibrant-titlebar-dark - -moz-win-borderless-glass -moz-win-browsertabbar-toolbox - -moz-win-communications-toolbox -moz-win-exclude-glass -moz-win-glass -moz-win-media-toolbox - -moz-window-button-box -moz-window-button-box-maximized -moz-window-button-close - -moz-window-button-maximize -moz-window-button-minimize -moz-window-button-restore - -moz-window-frame-bottom -moz-window-frame-left -moz-window-frame-right -moz-window-titlebar - -moz-window-titlebar-maximized - """, - gecko_ffi_name="mAppearance", - gecko_constant_prefix="ThemeWidgetType_NS_THEME", - products="gecko", - alias="-webkit-appearance:layout.css.webkit-appearance.enabled", - spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-appearance)", - animation_value_type="discrete")} +${helpers.predefined_type( + "-moz-appearance", + "Appearance", + "computed::Appearance::None", + products="gecko", + alias="-webkit-appearance:layout.css.webkit-appearance.enabled", + spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-appearance)", + needs_context=False, + animation_value_type="discrete", +)} ${helpers.predefined_type("-moz-binding", "url::UrlOrNone", "computed::url::UrlOrNone::none()", products="gecko", animation_value_type="none", gecko_ffi_name="mBinding", spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-binding)")} ${helpers.single_keyword("-moz-orient",
--- a/servo/components/style/values/computed/box.rs +++ b/servo/components/style/values/computed/box.rs @@ -5,17 +5,17 @@ //! Computed types for box properties. use values::computed::{Context, Number, ToComputedValue}; use values::computed::length::{LengthOrPercentage, NonNegativeLength}; use values::generics::box_::AnimationIterationCount as GenericAnimationIterationCount; use values::generics::box_::Perspective as GenericPerspective; use values::generics::box_::VerticalAlign as GenericVerticalAlign; -pub use values::specified::box_::{AnimationName, Contain, Display, OverflowClipBox}; +pub use values::specified::box_::{AnimationName, Appearance, Contain, Display, OverflowClipBox}; pub use values::specified::box_::{Clear as SpecifiedClear, Float as SpecifiedFloat}; pub use values::specified::box_::{OverscrollBehavior, ScrollSnapType, TouchAction, TransitionProperty, WillChange}; /// A computed value for the `vertical-align` property. pub type VerticalAlign = GenericVerticalAlign<LengthOrPercentage>; /// A computed value for the `animation-iteration-count` property. pub type AnimationIterationCount = GenericAnimationIterationCount<Number>;
--- a/servo/components/style/values/computed/mod.rs +++ b/servo/components/style/values/computed/mod.rs @@ -38,17 +38,17 @@ pub use self::angle::Angle; pub use self::background::{BackgroundRepeat, BackgroundSize}; pub use self::border::{BorderImageRepeat, BorderImageSideWidth, BorderImageSlice, BorderImageWidth}; pub use self::border::{BorderCornerRadius, BorderRadius, BorderSpacing}; pub use self::font::{FontSize, FontSizeAdjust, FontStretch, FontSynthesis, FontVariantAlternates, FontWeight}; pub use self::font::{FontFamily, FontLanguageOverride, FontStyle, FontVariantEastAsian, FontVariationSettings}; pub use self::font::{FontFeatureSettings, FontVariantLigatures, FontVariantNumeric}; pub use self::font::{MozScriptLevel, MozScriptMinSize, MozScriptSizeMultiplier, XLang, XTextZoom}; pub use self::box_::{AnimationIterationCount, AnimationName, Contain, Display, TransitionProperty}; -pub use self::box_::{Clear, Float}; +pub use self::box_::{Appearance, Clear, Float}; pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective}; pub use self::box_::{ScrollSnapType, TouchAction, VerticalAlign, WillChange}; pub use self::color::{Color, ColorPropertyValue, RGBAColor}; pub use self::column::ColumnCount; pub use self::counters::{Content, ContentItem, CounterIncrement, CounterReset}; pub use self::effects::{BoxShadow, Filter, SimpleShadow}; pub use self::flex::FlexBasis; pub use self::image::{Gradient, GradientItem, Image, ImageLayer, LineDirection, MozImageRect};
--- a/servo/components/style/values/specified/box.rs +++ b/servo/components/style/values/specified/box.rs @@ -876,8 +876,254 @@ pub enum Clear { None, Left, Right, Both, // https://drafts.csswg.org/css-logical-props/#float-clear InlineStart, InlineEnd } + +/// The value for the `appearance` property. +/// +/// https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-appearance +/// +/// NOTE(emilio): When changing this you may want to regenerate the C++ bindings +/// (see components/style/cbindgen.toml) +#[allow(missing_docs)] +#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse, PartialEq, + SpecifiedValueInfo, ToCss, ToComputedValue)] +#[repr(u8)] +pub enum Appearance { + /// No appearance at all. + None, + /// A typical dialog button. + Button, + /// Various arrows that go in buttons + ButtonArrowDown, + ButtonArrowNext, + ButtonArrowPrevious, + ButtonArrowUp, + /// A rectangular button that contains complex content + /// like images (e.g. HTML <button> elements) + ButtonBevel, + /// The focus outline box inside of a button. + ButtonFocus, + /// The caret of a text area + Caret, + /// A dual toolbar button (e.g., a Back button with a dropdown) + Dualbutton, + /// A groupbox. + Groupbox, + /// A inner-spin button. + InnerSpinButton, + /// List boxes. + Listbox, + /// A listbox item. + Listitem, + /// Menu Bar background + Menubar, + /// <menu> and <menuitem> appearances + Menuitem, + Checkmenuitem, + Radiomenuitem, + /// For text on non-iconic menuitems only + Menuitemtext, + /// A dropdown list. + Menulist, + /// The dropdown button(s) that open up a dropdown list. + MenulistButton, + /// The text part of a dropdown list, to left of button. + MenulistText, + /// An editable textfield with a dropdown list (a combobox). + MenulistTextfield, + /// Menu Popup background. + Menupopup, + /// menu checkbox/radio appearances + Menucheckbox, + Menuradio, + Menuseparator, + Menuarrow, + /// An image in the menu gutter, like in bookmarks or history. + Menuimage, + /// A horizontal meter bar. + Meterbar, + /// The meter bar's meter indicator. + Meterchunk, + /// For HTML's <input type=number> + NumberInput, + /// A horizontal progress bar. + Progressbar, + /// The progress bar's progress indicator + Progresschunk, + /// A vertical progress bar. + ProgressbarVertical, + /// A vertical progress chunk. + ProgresschunkVertical, + /// A checkbox element. + Checkbox, + /// A radio element within a radio group. + Radio, + /// A generic container that always repaints on state changes. This is a + /// hack to make XUL checkboxes and radio buttons work. + CheckboxContainer, + RadioContainer, + /// The label part of a checkbox or radio button, used for painting a focus + /// outline. + CheckboxLabel, + RadioLabel, + /// nsRangeFrame and its subparts + Range, + RangeThumb, + /// The resizer background area in a status bar for the resizer widget in + /// the corner of a window. + Resizerpanel, + /// The resizer itself. + Resizer, + /// A slider. + ScaleHorizontal, + ScaleVertical, + /// A slider's thumb. + ScalethumbHorizontal, + ScalethumbVertical, + /// If the platform supports it, the left/right chunks of the slider thumb. + Scalethumbstart, + Scalethumbend, + /// The ticks for a slider. + Scalethumbtick, + /// A scrollbar. + Scrollbar, + /// A small scrollbar. + ScrollbarSmall, + /// The scrollbar slider + ScrollbarHorizontal, + ScrollbarVertical, + /// A scrollbar button (up/down/left/right). + /// Keep these in order (some code casts these values to `int` in order to + /// compare them against each other). + ScrollbarbuttonDown, + ScrollbarbuttonLeft, + ScrollbarbuttonRight, + ScrollbarbuttonUp, + /// The scrollbar thumb. + ScrollbarthumbHorizontal, + ScrollbarthumbVertical, + /// The scrollbar track. + ScrollbartrackHorizontal, + ScrollbartrackVertical, + /// The scroll corner + Scrollcorner, + /// A searchfield. + Searchfield, + /// A separator. Can be horizontal or vertical. + Separator, + /// A spin control (up/down control for time/date pickers). + Spinner, + /// The up button of a spin control. + SpinnerUpbutton, + /// The down button of a spin control. + SpinnerDownbutton, + /// The textfield of a spin control + SpinnerTextfield, + /// A splitter. Can be horizontal or vertical. + Splitter, + /// A status bar in a main application window. + Statusbar, + /// A single pane of a status bar. + Statusbarpanel, + /// A single tab in a tab widget. + Tab, + /// A single pane (inside the tabpanels container). + Tabpanel, + /// The tab panels container. + Tabpanels, + /// The tabs scroll arrows (left/right). + TabScrollArrowBack, + TabScrollArrowForward, + /// A textfield or text area. + Textfield, + /// A multiline text field. + TextfieldMultiline, + /// A toolbar in an application window. + Toolbar, + /// A single toolbar button (with no associated dropdown). + Toolbarbutton, + /// The dropdown portion of a toolbar button + ToolbarbuttonDropdown, + /// The gripper for a toolbar. + Toolbargripper, + /// The toolbox that contains the toolbars. + Toolbox, + /// A tooltip. + Tooltip, + /// A listbox or tree widget header + Treeheader, + /// An individual header cell + Treeheadercell, + /// The sort arrow for a header. + Treeheadersortarrow, + /// A tree item. + Treeitem, + /// A tree widget branch line + Treeline, + /// A tree widget twisty. + Treetwisty, + /// Open tree widget twisty. + Treetwistyopen, + /// A tree widget. + Treeview, + /// Window and dialog backgrounds. + Window, + Dialog, + + /// Vista Rebars. + MozWinCommunicationsToolbox, + MozWinMediaToolbox, + MozWinBrowsertabbarToolbox, + /// Vista glass. + MozWinGlass, + MozWinBorderlessGlass, + /// -moz-apperance style used in setting proper glass margins. + MozWinExcludeGlass, + + /// Titlebar elements on the Mac. + MozMacFullscreenButton, + /// Mac help button. + MozMacHelpButton, + + /// Windows themed window frame elements. + MozWindowButtonBox, + MozWindowButtonBoxMaximized, + MozWindowButtonClose, + MozWindowButtonMaximize, + MozWindowButtonMinimize, + MozWindowButtonRestore, + MozWindowFrameBottom, + MozWindowFrameLeft, + MozWindowFrameRight, + MozWindowTitlebar, + MozWindowTitlebarMaximized, + + MozGtkInfoBar, + MozMacActiveSourceListSelection, + MozMacDisclosureButtonClosed, + MozMacDisclosureButtonOpen, + MozMacSourceList, + MozMacSourceListSelection, + MozMacVibrancyDark, + MozMacVibrancyLight, + MozMacVibrantTitlebarDark, + MozMacVibrantTitlebarLight, + + /// A non-disappearing scrollbar. + #[css(skip)] + ScrollbarNonDisappearing, + + /// A themed focus outline (for outline:auto). + /// + /// This isn't exposed to CSS at all, just here for convenience. + #[css(skip)] + FocusOutline, + + /// A dummy variant that should be last to let the GTK widget do hackery. + #[css(skip)] + Count, +}
--- a/servo/components/style/values/specified/mod.rs +++ b/servo/components/style/values/specified/mod.rs @@ -33,17 +33,17 @@ pub use self::border::{BorderCornerRadiu pub use self::border::{BorderImageRepeat, BorderImageSideWidth}; pub use self::border::{BorderRadius, BorderSideWidth, BorderSpacing}; pub use self::column::ColumnCount; pub use self::font::{FontSize, FontSizeAdjust, FontStretch, FontSynthesis, FontVariantAlternates, FontWeight}; pub use self::font::{FontFamily, FontLanguageOverride, FontStyle, FontVariantEastAsian, FontVariationSettings}; pub use self::font::{FontFeatureSettings, FontVariantLigatures, FontVariantNumeric}; pub use self::font::{MozScriptLevel, MozScriptMinSize, MozScriptSizeMultiplier, XLang, XTextZoom}; pub use self::box_::{AnimationIterationCount, AnimationName, Contain, Display}; -pub use self::box_::{Clear, Float}; +pub use self::box_::{Appearance, Clear, Float}; pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective}; pub use self::box_::{ScrollSnapType, TouchAction, TransitionProperty, VerticalAlign, WillChange}; pub use self::color::{Color, ColorPropertyValue, RGBAColor}; pub use self::counters::{Content, ContentItem, CounterIncrement, CounterReset}; pub use self::effects::{BoxShadow, Filter, SimpleShadow}; pub use self::flex::FlexBasis; #[cfg(feature = "gecko")] pub use self::gecko::ScrollSnapPoint;
--- a/widget/android/nsNativeThemeAndroid.cpp +++ b/widget/android/nsNativeThemeAndroid.cpp @@ -1,16 +1,16 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsNativeThemeAndroid.h" #include "nsIFrame.h" -#include "nsThemeConstants.h" +#include "nsStyleConsts.h" #include "AndroidColors.h" #include "nsCSSRendering.h" #include "PathHelpers.h" NS_IMPL_ISUPPORTS_INHERITED(nsNativeThemeAndroid, nsNativeTheme, nsITheme) using namespace mozilla; using namespace mozilla::gfx; @@ -167,32 +167,32 @@ PaintCheckedRadioButton(nsIFrame* aFrame RefPtr<Path> ellipse = builder->Finish(); aDrawTarget->Fill(ellipse, ColorPattern(ToDeviceColor(mozilla::widget::sAndroidCheckColor))); } NS_IMETHODIMP nsNativeThemeAndroid::DrawWidgetBackground(gfxContext* aContext, nsIFrame* aFrame, - uint8_t aWidgetType, + WidgetType aWidgetType, const nsRect& aRect, const nsRect& aDirtyRect) { EventStates eventState = GetContentState(aFrame, aWidgetType); nsRect rect(aRect); ClampRectAndMoveToCenter(rect); switch (aWidgetType) { - case NS_THEME_RADIO: + case StyleAppearance::Radio: PaintRadioControl(aFrame, aContext->GetDrawTarget(), rect, eventState); if (IsSelected(aFrame)) { PaintCheckedRadioButton(aFrame, aContext->GetDrawTarget(), rect); } break; - case NS_THEME_CHECKBOX: + case StyleAppearance::Checkbox: PaintCheckboxControl(aFrame, aContext->GetDrawTarget(), rect, eventState); if (IsChecked(aFrame)) { PaintCheckMark(aFrame, aContext->GetDrawTarget(), rect); } if (GetIndeterminate(aFrame)) { PaintIndeterminateMark(aFrame, aContext->GetDrawTarget(), rect); } break; @@ -201,67 +201,68 @@ nsNativeThemeAndroid::DrawWidgetBackgrou return NS_ERROR_NOT_IMPLEMENTED; } return NS_OK; } LayoutDeviceIntMargin nsNativeThemeAndroid::GetWidgetBorder(nsDeviceContext* aContext, nsIFrame* aFrame, - uint8_t aWidgetType) + WidgetType aWidgetType) { return LayoutDeviceIntMargin(); } bool nsNativeThemeAndroid::GetWidgetPadding(nsDeviceContext* aContext, - nsIFrame* aFrame, uint8_t aWidgetType, + nsIFrame* aFrame, WidgetType aWidgetType, LayoutDeviceIntMargin* aResult) { switch (aWidgetType) { // Radios and checkboxes return a fixed size in GetMinimumWidgetSize // and have a meaningful baseline, so they can't have // author-specified padding. - case NS_THEME_CHECKBOX: - case NS_THEME_RADIO: + case StyleAppearance::Checkbox: + case StyleAppearance::Radio: aResult->SizeTo(0, 0, 0, 0); return true; + default: + return false; } - return false; } bool nsNativeThemeAndroid::GetWidgetOverflow(nsDeviceContext* aContext, - nsIFrame* aFrame, uint8_t aWidgetType, + nsIFrame* aFrame, WidgetType aWidgetType, nsRect* aOverflowRect) { return false; } NS_IMETHODIMP nsNativeThemeAndroid::GetMinimumWidgetSize(nsPresContext* aPresContext, - nsIFrame* aFrame, uint8_t aWidgetType, + nsIFrame* aFrame, WidgetType aWidgetType, LayoutDeviceIntSize* aResult, bool* aIsOverridable) { - if (aWidgetType == NS_THEME_RADIO || aWidgetType == NS_THEME_CHECKBOX) { + if (aWidgetType == StyleAppearance::Radio || aWidgetType == StyleAppearance::Checkbox) { // 9px + (1px padding + 1px border) * 2 aResult->width = aPresContext->CSSPixelsToDevPixels(13); aResult->height = aPresContext->CSSPixelsToDevPixels(13); } return NS_OK; } NS_IMETHODIMP -nsNativeThemeAndroid::WidgetStateChanged(nsIFrame* aFrame, uint8_t aWidgetType, +nsNativeThemeAndroid::WidgetStateChanged(nsIFrame* aFrame, WidgetType aWidgetType, nsAtom* aAttribute, bool* aShouldRepaint, const nsAttrValue* aOldValue) { - if (aWidgetType == NS_THEME_RADIO || aWidgetType == NS_THEME_CHECKBOX) { + if (aWidgetType == StyleAppearance::Radio || aWidgetType == StyleAppearance::Checkbox) { if (aAttribute == nsGkAtoms::active || aAttribute == nsGkAtoms::disabled || aAttribute == nsGkAtoms::hover) { *aShouldRepaint = true; return NS_OK; } } @@ -273,42 +274,42 @@ NS_IMETHODIMP nsNativeThemeAndroid::ThemeChanged() { return NS_OK; } NS_IMETHODIMP_(bool) nsNativeThemeAndroid::ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* aFrame, - uint8_t aWidgetType) + WidgetType aWidgetType) { switch (aWidgetType) { - case NS_THEME_RADIO: - case NS_THEME_CHECKBOX: + case StyleAppearance::Radio: + case StyleAppearance::Checkbox: return true; + default: + return false; } - - return false; } NS_IMETHODIMP_(bool) -nsNativeThemeAndroid::WidgetIsContainer(uint8_t aWidgetType) +nsNativeThemeAndroid::WidgetIsContainer(WidgetType aWidgetType) { return false; } bool -nsNativeThemeAndroid::ThemeDrawsFocusForWidget(uint8_t aWidgetType) +nsNativeThemeAndroid::ThemeDrawsFocusForWidget(WidgetType aWidgetType) { return false; } bool nsNativeThemeAndroid::ThemeNeedsComboboxDropmarker() { return false; } nsITheme::Transparency -nsNativeThemeAndroid::GetWidgetTransparency(nsIFrame* aFrame, uint8_t aWidgetType) +nsNativeThemeAndroid::GetWidgetTransparency(nsIFrame* aFrame, WidgetType aWidgetType) { return eUnknownTransparency; }
--- a/widget/android/nsNativeThemeAndroid.h +++ b/widget/android/nsNativeThemeAndroid.h @@ -11,58 +11,58 @@ class nsNativeThemeAndroid final: private nsNativeTheme, public nsITheme { public: NS_DECL_ISUPPORTS_INHERITED // The nsITheme interface. NS_IMETHOD DrawWidgetBackground(gfxContext* aContext, - nsIFrame* aFrame, uint8_t aWidgetType, + nsIFrame* aFrame, WidgetType aWidgetType, const nsRect& aRect, const nsRect& aDirtyRect) override; MOZ_MUST_USE LayoutDeviceIntMargin GetWidgetBorder(nsDeviceContext* aContext, nsIFrame* aFrame, - uint8_t aWidgetType) override; + WidgetType aWidgetType) override; bool GetWidgetPadding(nsDeviceContext* aContext, nsIFrame* aFrame, - uint8_t aWidgetType, + WidgetType aWidgetType, LayoutDeviceIntMargin* aResult) override; bool GetWidgetOverflow(nsDeviceContext* aContext, nsIFrame* aFrame, - uint8_t aWidgetType, + WidgetType aWidgetType, nsRect* aOverflowRect) override; NS_IMETHOD GetMinimumWidgetSize(nsPresContext* aPresContext, - nsIFrame* aFrame, uint8_t aWidgetType, + nsIFrame* aFrame, WidgetType aWidgetType, mozilla::LayoutDeviceIntSize* aResult, bool* aIsOverridable) override; - NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, uint8_t aWidgetType, + NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, WidgetType aWidgetType, nsAtom* aAttribute, bool* aShouldRepaint, const nsAttrValue* aOldValue) override; NS_IMETHOD ThemeChanged() override; NS_IMETHOD_(bool) ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* aFrame, - uint8_t aWidgetType) override; + WidgetType aWidgetType) override; - NS_IMETHOD_(bool) WidgetIsContainer(uint8_t aWidgetType) override; + NS_IMETHOD_(bool) WidgetIsContainer(WidgetType aWidgetType) override; - NS_IMETHOD_(bool) ThemeDrawsFocusForWidget(uint8_t aWidgetType) override; + NS_IMETHOD_(bool) ThemeDrawsFocusForWidget(WidgetType aWidgetType) override; bool ThemeNeedsComboboxDropmarker() override; Transparency GetWidgetTransparency(nsIFrame* aFrame, - uint8_t aWidgetType) override; + WidgetType aWidgetType) override; nsNativeThemeAndroid() {} protected: virtual ~nsNativeThemeAndroid() {} }; #endif // nsNativeThemeAndroid_h_
--- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -33,17 +33,17 @@ #include "nsFontMetrics.h" #include "nsIRollupListener.h" #include "nsViewManager.h" #include "nsIInterfaceRequestor.h" #include "nsIFile.h" #include "nsILocalFileMac.h" #include "nsGfxCIID.h" -#include "nsThemeConstants.h" +#include "nsStyleConsts.h" #include "nsIWidgetListener.h" #include "nsIPresShell.h" #include "nsIScreen.h" #include "nsDragService.h" #include "nsClipboard.h" #include "nsCursorManager.h" #include "nsWindowMap.h"
--- a/widget/cocoa/nsCocoaWindow.mm +++ b/widget/cocoa/nsCocoaWindow.mm @@ -3488,17 +3488,17 @@ static const NSString* kStateCollectionB // This class allows us to exercise control over the window's title bar. This // allows for a "unified toolbar" look without having to extend the content // area into the title bar. // // Drawing the unified gradient in the titlebar and the toolbar works like this: // 1) In the style sheet we set the toolbar's -moz-appearance to toolbar. // 2) When the toolbar is visible and we paint the application chrome // window, the array that Gecko passes nsChildView::UpdateThemeGeometries -// will contain an entry for the widget type NS_THEME_TOOLBAR. +// will contain an entry for the widget type StyleAppearance::Toolbar. // 3) nsChildView::UpdateThemeGeometries finds the toolbar frame's ToolbarWindow // and passes the toolbar frame's height to setUnifiedToolbarHeight. // 4) If the toolbar height has changed, a titlebar redraw is triggered and the // upper part of the unified gradient is drawn in the titlebar. // 5) The lower part of the unified gradient in the toolbar is drawn during // normal window content painting in nsNativeThemeCocoa::DrawUnifiedToolbar. // // Whenever the unified gradient is drawn in the titlebar or the toolbar, both
--- a/widget/cocoa/nsNativeThemeCocoa.h +++ b/widget/cocoa/nsNativeThemeCocoa.h @@ -371,57 +371,57 @@ public: nsNativeThemeCocoa(); NS_DECL_ISUPPORTS_INHERITED // The nsITheme interface. NS_IMETHOD DrawWidgetBackground(gfxContext* aContext, nsIFrame* aFrame, - uint8_t aWidgetType, + WidgetType aWidgetType, const nsRect& aRect, const nsRect& aDirtyRect) override; bool CreateWebRenderCommandsForWidget(mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const mozilla::layers::StackingContextHelper& aSc, mozilla::layers::WebRenderLayerManager* aManager, nsIFrame* aFrame, - uint8_t aWidgetType, + WidgetType aWidgetType, const nsRect& aRect) override; MOZ_MUST_USE LayoutDeviceIntMargin GetWidgetBorder(nsDeviceContext* aContext, nsIFrame* aFrame, - uint8_t aWidgetType) override; + WidgetType aWidgetType) override; bool GetWidgetPadding(nsDeviceContext* aContext, nsIFrame* aFrame, - uint8_t aWidgetType, + WidgetType aWidgetType, LayoutDeviceIntMargin* aResult) override; virtual bool GetWidgetOverflow(nsDeviceContext* aContext, nsIFrame* aFrame, - uint8_t aWidgetType, nsRect* aOverflowRect) override; + WidgetType aWidgetType, nsRect* aOverflowRect) override; NS_IMETHOD GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aFrame, - uint8_t aWidgetType, + WidgetType aWidgetType, mozilla::LayoutDeviceIntSize* aResult, bool* aIsOverridable) override; - NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, uint8_t aWidgetType, + NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, WidgetType aWidgetType, nsAtom* aAttribute, bool* aShouldRepaint, const nsAttrValue* aOldValue) override; NS_IMETHOD ThemeChanged() override; - bool ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* aFrame, uint8_t aWidgetType) override; - bool WidgetIsContainer(uint8_t aWidgetType) override; - bool ThemeDrawsFocusForWidget(uint8_t aWidgetType) override; + bool ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* aFrame, WidgetType aWidgetType) override; + bool WidgetIsContainer(WidgetType aWidgetType) override; + bool ThemeDrawsFocusForWidget(WidgetType aWidgetType) override; bool ThemeNeedsComboboxDropmarker() override; - virtual bool WidgetAppearanceDependsOnWindowFocus(uint8_t aWidgetType) override; + virtual bool WidgetAppearanceDependsOnWindowFocus(WidgetType aWidgetType) override; virtual bool NeedToClearBackgroundBehindWidget(nsIFrame* aFrame, - uint8_t aWidgetType) override; + WidgetType aWidgetType) override; virtual ThemeGeometryType ThemeGeometryTypeForWidget(nsIFrame* aFrame, - uint8_t aWidgetType) override; - virtual Transparency GetWidgetTransparency(nsIFrame* aFrame, uint8_t aWidgetType) override; + WidgetType aWidgetType) override; + virtual Transparency GetWidgetTransparency(nsIFrame* aFrame, WidgetType aWidgetType) override; mozilla::Maybe<WidgetInfo> ComputeWidgetInfo(nsIFrame* aFrame, - uint8_t aWidgetType, + WidgetType aWidgetType, const nsRect& aRect); void DrawProgress(CGContextRef context, const HIRect& inBoxRect, const ProgressParams& aParams); static void DrawNativeTitlebar(CGContextRef aContext, CGRect aTitlebarRect, CGFloat aUnifiedHeight, BOOL aIsMain, BOOL aIsFlipped); protected:
--- a/widget/cocoa/nsNativeThemeCocoa.mm +++ b/widget/cocoa/nsNativeThemeCocoa.mm @@ -10,17 +10,17 @@ #include "nsChildView.h" #include "nsDeviceContext.h" #include "nsLayoutUtils.h" #include "nsObjCExceptions.h" #include "nsNumberControlFrame.h" #include "nsRangeFrame.h" #include "nsRect.h" #include "nsSize.h" -#include "nsThemeConstants.h" +#include "nsStyleConsts.h" #include "nsIPresShell.h" #include "nsPresContext.h" #include "nsIContent.h" #include "nsIDocument.h" #include "nsIFrame.h" #include "nsAtom.h" #include "nsNameSpaceManager.h" #include "nsPresContext.h" @@ -467,17 +467,17 @@ static BOOL IsActive(nsIFrame* aFrame, B { if (aIsToolbarControl) return [NativeWindowForFrame(aFrame) isMainWindow]; return FrameIsInActiveWindow(aFrame); } static bool IsInSourceList(nsIFrame* aFrame) { for (nsIFrame* frame = aFrame->GetParent(); frame; frame = frame->GetParent()) { - if (frame->StyleDisplay()->mAppearance == NS_THEME_MAC_SOURCE_LIST) { + if (frame->StyleDisplay()->mAppearance == StyleAppearance::MozMacSourceList) { return true; } } return false; } NS_IMPL_ISUPPORTS_INHERITED(nsNativeThemeCocoa, nsNativeTheme, nsITheme) @@ -1073,18 +1073,18 @@ IsToolbarStyleContainer(nsIFrame* aFrame if (content->IsAnyOfXULElements(nsGkAtoms::toolbar, nsGkAtoms::toolbox, nsGkAtoms::statusbar)) { return true; } switch (aFrame->StyleDisplay()->mAppearance) { - case NS_THEME_TOOLBAR: - case NS_THEME_STATUSBAR: + case StyleAppearance::Toolbar: + case StyleAppearance::Statusbar: return true; default: return false; } } static bool IsInsideToolbar(nsIFrame* aFrame) @@ -1340,17 +1340,17 @@ nsNativeThemeCocoa::ComputeMenuItemParam EventStates aEventState, bool aIsChecked) { bool isDisabled = IsDisabled(aFrame, aEventState); MenuItemParams params; if (VibrancyManager::SystemSupportsVibrancy()) { ThemeGeometryType type = - ThemeGeometryTypeForWidget(aFrame, NS_THEME_MENUITEM); + ThemeGeometryTypeForWidget(aFrame, StyleAppearance::Menuitem); params.vibrancyColor = Some(VibrancyFillColor(aFrame, type)); } params.checked = aIsChecked; params.disabled = isDisabled; params.selected = !isDisabled && CheckBooleanAttr(aFrame, nsGkAtoms::menuactive); params.rtl = IsFrameRTL(aFrame); return params; @@ -2734,17 +2734,17 @@ nsNativeThemeCocoa::ScrollbarParams nsNativeThemeCocoa::ComputeScrollbarParams(nsIFrame* aFrame, bool aIsHorizontal) { ScrollbarParams params; params.overlay = nsLookAndFeel::UseOverlayScrollbars(); params.rolledOver = IsParentScrollbarRolledOver(aFrame); nsIFrame* scrollbarFrame = GetParentScrollbarFrame(aFrame); params.small = (scrollbarFrame && - scrollbarFrame->StyleDisplay()->mAppearance == NS_THEME_SCROLLBAR_SMALL); + scrollbarFrame->StyleDisplay()->mAppearance == StyleAppearance::ScrollbarSmall); params.rtl = IsFrameRTL(aFrame); params.horizontal = aIsHorizontal; params.onDarkBackground = IsDarkBackground(aFrame); // Don't use custom scrollbars for overlay scrollbars since they are // generally good enough for use cases of custom scrollbars. if (!params.overlay) { ComputedStyle* style = nsLayoutUtils::StyleForScrollbar(aFrame); if (style->StyleUserInterface()->HasCustomScrollbars()) { @@ -3047,29 +3047,29 @@ nsNativeThemeCocoa::DrawSourceList(CGCon } bool nsNativeThemeCocoa::IsParentScrollbarRolledOver(nsIFrame* aFrame) { nsIFrame* scrollbarFrame = GetParentScrollbarFrame(aFrame); return nsLookAndFeel::UseOverlayScrollbars() ? CheckBooleanAttr(scrollbarFrame, nsGkAtoms::hover) - : GetContentState(scrollbarFrame, NS_THEME_NONE).HasState(NS_EVENT_STATE_HOVER); + : GetContentState(scrollbarFrame, StyleAppearance::None).HasState(NS_EVENT_STATE_HOVER); } static bool IsHiDPIContext(nsDeviceContext* aContext) { return nsPresContext::AppUnitsPerCSSPixel() >= 2 * aContext->AppUnitsPerDevPixelAtUnitFullZoom(); } Maybe<nsNativeThemeCocoa::WidgetInfo> nsNativeThemeCocoa::ComputeWidgetInfo(nsIFrame* aFrame, - uint8_t aWidgetType, + WidgetType aWidgetType, const nsRect& aRect) { NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN; // setup to draw into the correct port int32_t p2a = aFrame->PresContext()->AppUnitsPerDevPixel(); gfx::Rect nativeWidgetRect(aRect.x, aRect.y, aRect.width, aRect.height); @@ -3085,81 +3085,81 @@ nsNativeThemeCocoa::ComputeWidgetInfo(ns // Use high-resolution drawing. nativeWidgetRect.Scale(0.5f); originalHeight *= 0.5f; } EventStates eventState = GetContentState(aFrame, aWidgetType); switch (aWidgetType) { - case NS_THEME_DIALOG: + case StyleAppearance::Dialog: if (IsWindowSheet(aFrame)) { if (VibrancyManager::SystemSupportsVibrancy()) { ThemeGeometryType type = ThemeGeometryTypeForWidget(aFrame, aWidgetType); return Some(WidgetInfo::ColorFill(VibrancyFillColor(aFrame, type))); } return Some(WidgetInfo::SheetBackground()); } return Some(WidgetInfo::DialogBackground()); - case NS_THEME_MENUPOPUP: + case StyleAppearance::Menupopup: return Some(WidgetInfo::MenuBackground( ComputeMenuBackgroundParams(aFrame, eventState))); - case NS_THEME_MENUARROW: + case StyleAppearance::Menuarrow: return Some(WidgetInfo::MenuIcon( ComputeMenuIconParams(aFrame, eventState, MenuIcon::eMenuArrow))); - case NS_THEME_MENUITEM: - case NS_THEME_CHECKMENUITEM: + case StyleAppearance::Menuitem: + case StyleAppearance::Checkmenuitem: return Some(WidgetInfo::MenuItem( ComputeMenuItemParams(aFrame, eventState, - aWidgetType == NS_THEME_CHECKMENUITEM))); - - case NS_THEME_MENUSEPARATOR: + aWidgetType == StyleAppearance::Checkmenuitem))); + + case StyleAppearance::Menuseparator: return Some(WidgetInfo::MenuSeparator( ComputeMenuItemParams(aFrame, eventState, false))); - case NS_THEME_BUTTON_ARROW_UP: - case NS_THEME_BUTTON_ARROW_DOWN: { + case StyleAppearance::ButtonArrowUp: + case StyleAppearance::ButtonArrowDown: { MenuIcon icon = - aWidgetType == NS_THEME_BUTTON_ARROW_UP ? MenuIcon::eMenuUpScrollArrow + aWidgetType == StyleAppearance::ButtonArrowUp ? MenuIcon::eMenuUpScrollArrow : MenuIcon::eMenuDownScrollArrow; return Some(WidgetInfo::MenuIcon( ComputeMenuIconParams(aFrame, eventState, icon))); } - case NS_THEME_TOOLTIP: + case StyleAppearance::Tooltip: if (VibrancyManager::SystemSupportsVibrancy()) { ThemeGeometryType type = ThemeGeometryTypeForWidget(aFrame, aWidgetType); return Some(WidgetInfo::ColorFill(VibrancyFillColor(aFrame, type))); } return Some(WidgetInfo::Tooltip()); - case NS_THEME_CHECKBOX: - case NS_THEME_RADIO: { - bool isCheckbox = (aWidgetType == NS_THEME_CHECKBOX); + case StyleAppearance::Checkbox: + case StyleAppearance::Radio: { + bool isCheckbox = (aWidgetType == StyleAppearance::Checkbox); CheckboxOrRadioParams params; params.state = CheckboxOrRadioState::eOff; if (isCheckbox && GetIndeterminate(aFrame)) { params.state = CheckboxOrRadioState::eIndeterminate; } else if (GetCheckedOrSelected(aFrame, !isCheckbox)) { params.state = CheckboxOrRadioState::eOn; } params.controlParams = ComputeControlParams(aFrame, eventState); params.verticalAlignFactor = VerticalAlignFactor(aFrame); if (isCheckbox) { return Some(WidgetInfo::Checkbox(params)); } return Some(WidgetInfo::Radio(params)); } - case NS_THEME_BUTTON: + case StyleAppearance::Button: if (IsDefaultButton(aFrame)) { // Check whether the default button is in a document that does not // match the :-moz-window-inactive pseudoclass. This activeness check // is different from the other "active window" checks in this file // because we absolutely need the button's default button appearance to // be in sync with its text color, and the text color is changed by // such a :-moz-window-inactive rule. (That's because on 10.10 and up, // default buttons in active windows have blue background and white @@ -3200,46 +3200,46 @@ nsNativeThemeCocoa::ComputeWidgetInfo(ns return Some(WidgetInfo::Button( ButtonParams{ComputeControlParams(aFrame, eventState), ButtonType::eSquareBezelPushButton})); } return Some(WidgetInfo::Button( ButtonParams{ComputeControlParams(aFrame, eventState), ButtonType::eRoundedBezelPushButton})); - case NS_THEME_FOCUS_OUTLINE: + case StyleAppearance::FocusOutline: return Some(WidgetInfo::FocusOutline()); - case NS_THEME_MAC_HELP_BUTTON: + case StyleAppearance::MozMacHelpButton: return Some(WidgetInfo::Button( ButtonParams{ComputeControlParams(aFrame, eventState), ButtonType::eHelpButton})); - case NS_THEME_MAC_DISCLOSURE_BUTTON_OPEN: - case NS_THEME_MAC_DISCLOSURE_BUTTON_CLOSED: { - ButtonType buttonType = (aWidgetType == NS_THEME_MAC_DISCLOSURE_BUTTON_CLOSED) + case StyleAppearance::MozMacDisclosureButtonOpen: + case StyleAppearance::MozMacDisclosureButtonClosed: { + ButtonType buttonType = (aWidgetType == StyleAppearance::MozMacDisclosureButtonClosed) ? ButtonType::eDisclosureButtonClosed : ButtonType::eDisclosureButtonOpen; return Some(WidgetInfo::Button( ButtonParams{ComputeControlParams(aFrame, eventState), buttonType})); } - case NS_THEME_BUTTON_BEVEL: { + case StyleAppearance::ButtonBevel: { bool isDefaultButton = IsDefaultButton(aFrame); ButtonType buttonType = isDefaultButton ? ButtonType::eDefaultBevelButton : ButtonType::eRegularBevelButton; return Some(WidgetInfo::Button( ButtonParams{ComputeControlParams(aFrame, eventState), buttonType})); } - case NS_THEME_INNER_SPIN_BUTTON: { - case NS_THEME_SPINNER: - bool isSpinner = (aWidgetType == NS_THEME_SPINNER); + case StyleAppearance::InnerSpinButton: { + case StyleAppearance::Spinner: + bool isSpinner = (aWidgetType == StyleAppearance::Spinner); nsIContent* content = aFrame->GetContent(); if (isSpinner && content->IsHTMLElement()) { // In HTML the theming for the spin buttons is drawn individually into // their own backgrounds instead of being drawn into the background of // their spinner parent as it is for XUL. break; } SpinButtonParams params; @@ -3253,272 +3253,274 @@ nsNativeThemeCocoa::ComputeWidgetInfo(ns } } params.disabled = IsDisabled(aFrame, eventState); params.insideActiveWindow = FrameIsInActiveWindow(aFrame); return Some(WidgetInfo::SpinButtons(params)); } - case NS_THEME_SPINNER_UPBUTTON: - case NS_THEME_SPINNER_DOWNBUTTON: { + case StyleAppearance::SpinnerUpbutton: + case StyleAppearance::SpinnerDownbutton: { nsNumberControlFrame* numberControlFrame = nsNumberControlFrame::GetNumberControlFrameForSpinButton(aFrame); if (numberControlFrame) { SpinButtonParams params; if (numberControlFrame->SpinnerUpButtonIsDepressed()) { params.pressedButton = Some(SpinButton::eUp); } else if (numberControlFrame->SpinnerDownButtonIsDepressed()) { params.pressedButton = Some(SpinButton::eDown); } params.disabled = IsDisabled(aFrame, eventState); params.insideActiveWindow = FrameIsInActiveWindow(aFrame); - if (aWidgetType == NS_THEME_SPINNER_UPBUTTON) { + if (aWidgetType == StyleAppearance::SpinnerUpbutton) { return Some(WidgetInfo::SpinButtonUp(params)); } return Some(WidgetInfo::SpinButtonDown(params)); } } break; - case NS_THEME_TOOLBARBUTTON: { + case StyleAppearance::Toolbarbutton: { SegmentParams params = ComputeSegmentParams(aFrame, eventState, SegmentType::eToolbarButton); params.insideActiveWindow = [NativeWindowForFrame(aFrame) isMainWindow]; return Some(WidgetInfo::Segment(params)); } - case NS_THEME_SEPARATOR: + case StyleAppearance::Separator: return Some(WidgetInfo::Separator()); - case NS_THEME_TOOLBAR: { + case StyleAppearance::Toolbar: { NSWindow* win = NativeWindowForFrame(aFrame); bool isMain = [win isMainWindow]; if (ToolbarCanBeUnified(nativeWidgetRect, win)) { float unifiedHeight = std::max(float([(ToolbarWindow*)win unifiedToolbarHeight]), nativeWidgetRect.Height()); return Some(WidgetInfo::UnifiedToolbar( UnifiedToolbarParams{unifiedHeight, isMain})); } return Some(WidgetInfo::Toolbar(isMain)); } - case NS_THEME_WINDOW_TITLEBAR: { + case StyleAppearance::MozWindowTitlebar: { NSWindow* win = NativeWindowForFrame(aFrame); bool isMain = [win isMainWindow]; float unifiedToolbarHeight = [win isKindOfClass:[ToolbarWindow class]] ? [(ToolbarWindow*)win unifiedToolbarHeight] : nativeWidgetRect.Height(); return Some(WidgetInfo::NativeTitlebar( UnifiedToolbarParams{unifiedToolbarHeight, isMain})); } - case NS_THEME_STATUSBAR: + case StyleAppearance::Statusbar: return Some(WidgetInfo::StatusBar(IsActive(aFrame, YES))); - case NS_THEME_MENULIST: - case NS_THEME_MENULIST_TEXTFIELD: { + case StyleAppearance::Menulist: + case StyleAppearance::MenulistTextfield: { ControlParams controlParams = ComputeControlParams(aFrame, eventState); controlParams.focused = controlParams.focused || IsFocused(aFrame); controlParams.pressed = IsOpenButton(aFrame); DropdownParams params; params.controlParams = controlParams; params.pullsDown = false; - params.editable = aWidgetType == NS_THEME_MENULIST_TEXTFIELD; + params.editable = aWidgetType == StyleAppearance::MenulistTextfield; return Some(WidgetInfo::Dropdown(params)); } - case NS_THEME_MENULIST_BUTTON: + case StyleAppearance::MenulistButton: return Some(WidgetInfo::Button( ButtonParams{ComputeControlParams(aFrame, eventState), ButtonType::eArrowButton})); - case NS_THEME_GROUPBOX: + case StyleAppearance::Groupbox: return Some(WidgetInfo::GroupBox()); - case NS_THEME_TEXTFIELD: - case NS_THEME_NUMBER_INPUT: { + case StyleAppearance::Textfield: + case StyleAppearance::NumberInput: { bool isFocused = eventState.HasState(NS_EVENT_STATE_FOCUS); // XUL textboxes set the native appearance on the containing box, while // concrete focus is set on the html:input element within it. We can // though, check the focused attribute of xul textboxes in this case. // On Mac, focus rings are always shown for textboxes, so we do not need // to check the window's focus ring state here if (aFrame->GetContent()->IsXULElement() && IsFocused(aFrame)) { isFocused = true; } bool isDisabled = IsDisabled(aFrame, eventState) || IsReadOnly(aFrame); return Some(WidgetInfo::TextBox(TextBoxParams{isDisabled, isFocused})); } - case NS_THEME_SEARCHFIELD: + case StyleAppearance::Searchfield: return Some(WidgetInfo::SearchField( ComputeSearchFieldParams(aFrame, eventState))); - case NS_THEME_PROGRESSBAR: + case StyleAppearance::Progressbar: { // Don't request repaints for scrollbars at 100% because those don't animate. if (GetProgressValue(aFrame) < GetProgressMaxValue(aFrame)) { if (!QueueAnimatedContentForRefresh(aFrame->GetContent(), 30)) { NS_WARNING("Unable to animate progressbar!"); } } return Some(WidgetInfo::ProgressBar( ComputeProgressParams(aFrame, eventState, !IsVerticalProgress(aFrame)))); } - case NS_THEME_PROGRESSBAR_VERTICAL: + case StyleAppearance::ProgressbarVertical: return Some(WidgetInfo::ProgressBar( ComputeProgressParams(aFrame, eventState, false))); - case NS_THEME_METERBAR: + case StyleAppearance::Meterbar: return Some(WidgetInfo::Meter(ComputeMeterParams(aFrame))); - case NS_THEME_PROGRESSCHUNK: - case NS_THEME_PROGRESSCHUNK_VERTICAL: - case NS_THEME_METERCHUNK: + case StyleAppearance::Progresschunk: + case StyleAppearance::ProgresschunkVertical: + case StyleAppearance::Meterchunk: // Do nothing: progress and meter bars cases will draw chunks. break; - case NS_THEME_TREETWISTY: + case StyleAppearance::Treetwisty: return Some(WidgetInfo::Button( ButtonParams{ComputeControlParams(aFrame, eventState), ButtonType::eTreeTwistyPointingRight})); - case NS_THEME_TREETWISTYOPEN: + case StyleAppearance::Treetwistyopen: return Some(WidgetInfo::Button( ButtonParams{ComputeControlParams(aFrame, eventState), ButtonType::eTreeTwistyPointingDown})); - case NS_THEME_TREEHEADERCELL: + case StyleAppearance::Treeheadercell: return Some(WidgetInfo::TreeHeaderCell( ComputeTreeHeaderCellParams(aFrame, eventState))); - case NS_THEME_TREEITEM: - case NS_THEME_TREEVIEW: + case StyleAppearance::Treeitem: + case StyleAppearance::Treeview: return Some(WidgetInfo::ColorFill(Color(1.0, 1.0, 1.0, 1.0))); - case NS_THEME_TREEHEADER: + case StyleAppearance::Treeheader: // do nothing, taken care of by individual header cells - case NS_THEME_TREEHEADERSORTARROW: + case StyleAppearance::Treeheadersortarrow: // do nothing, taken care of by treeview header - case NS_THEME_TREELINE: + case StyleAppearance::Treeline: // do nothing, these lines don't exist on macos break; - case NS_THEME_SCALE_HORIZONTAL: - case NS_THEME_SCALE_VERTICAL: + case StyleAppearance::ScaleHorizontal: + case StyleAppearance::ScaleVertical: return Some(WidgetInfo::Scale( ComputeXULScaleParams(aFrame, eventState, - aWidgetType == NS_THEME_SCALE_HORIZONTAL))); - - case NS_THEME_SCALETHUMB_HORIZONTAL: - case NS_THEME_SCALETHUMB_VERTICAL: + aWidgetType == StyleAppearance::ScaleHorizontal))); + + case StyleAppearance::ScalethumbHorizontal: + case StyleAppearance::ScalethumbVertical: // do nothing, drawn by scale break; - case NS_THEME_RANGE: { + case StyleAppearance::Range: { Maybe<ScaleParams> params = ComputeHTMLScaleParams(aFrame, eventState); if (params) { return Some(WidgetInfo::Scale(*params)); } break; } - case NS_THEME_SCROLLBAR_SMALL: - case NS_THEME_SCROLLBAR: + case StyleAppearance::ScrollbarSmall: + case StyleAppearance::Scrollbar: break; - case NS_THEME_SCROLLBARTHUMB_VERTICAL: - case NS_THEME_SCROLLBARTHUMB_HORIZONTAL: + case StyleAppearance::ScrollbarthumbVertical: + case StyleAppearance::ScrollbarthumbHorizontal: return Some(WidgetInfo::ScrollbarThumb( ComputeScrollbarParams( - aFrame, aWidgetType == NS_THEME_SCROLLBARTHUMB_HORIZONTAL))); - - case NS_THEME_SCROLLBARBUTTON_UP: - case NS_THEME_SCROLLBARBUTTON_LEFT: - case NS_THEME_SCROLLBARBUTTON_DOWN: - case NS_THEME_SCROLLBARBUTTON_RIGHT: + aFrame, aWidgetType == StyleAppearance::ScrollbarthumbHorizontal))); + + case StyleAppearance::ScrollbarbuttonUp: + case StyleAppearance::ScrollbarbuttonLeft: + case StyleAppearance::ScrollbarbuttonDown: + case StyleAppearance::ScrollbarbuttonRight: break; - case NS_THEME_SCROLLBARTRACK_HORIZONTAL: - case NS_THEME_SCROLLBARTRACK_VERTICAL: + case StyleAppearance::ScrollbartrackHorizontal: + case StyleAppearance::ScrollbartrackVertical: return Some(WidgetInfo::ScrollbarTrack( ComputeScrollbarParams( - aFrame, aWidgetType == NS_THEME_SCROLLBARTRACK_HORIZONTAL))); - - case NS_THEME_SCROLLCORNER: + aFrame, aWidgetType == StyleAppearance::ScrollbartrackHorizontal))); + + case StyleAppearance::Scrollcorner: return Some(WidgetInfo::ScrollCorner( ComputeScrollbarParams(aFrame, false))); - case NS_THEME_TEXTFIELD_MULTILINE: + case StyleAppearance::TextfieldMultiline: return Some(WidgetInfo::MultilineTextField( eventState.HasState(NS_EVENT_STATE_FOCUS))); - case NS_THEME_LISTBOX: + case StyleAppearance::Listbox: return Some(WidgetInfo::ListBox()); - case NS_THEME_MAC_SOURCE_LIST: { + case StyleAppearance::MozMacSourceList: { if (VibrancyManager::SystemSupportsVibrancy()) { ThemeGeometryType type = ThemeGeometryTypeForWidget(aFrame, aWidgetType); return Some(WidgetInfo::ColorFill(VibrancyFillColor(aFrame, type))); } return Some(WidgetInfo::SourceList(FrameIsInActiveWindow(aFrame))); } - case NS_THEME_MAC_SOURCE_LIST_SELECTION: - case NS_THEME_MAC_ACTIVE_SOURCE_LIST_SELECTION: { + case StyleAppearance::MozMacSourceListSelection: + case StyleAppearance::MozMacActiveSourceListSelection: { // If we're in XUL tree, we need to rely on the source list's clear // background display item. If we cleared the background behind the // selections, the source list would not pick up the right font // smoothing background. So, to simplify a bit, we only support vibrancy // if we're in a source list. if (VibrancyManager::SystemSupportsVibrancy() && IsInSourceList(aFrame)) { ThemeGeometryType type = ThemeGeometryTypeForWidget(aFrame, aWidgetType); return Some(WidgetInfo::ColorFill(VibrancyFillColor(aFrame, type))); } bool isInActiveWindow = FrameIsInActiveWindow(aFrame); - if (aWidgetType == NS_THEME_MAC_ACTIVE_SOURCE_LIST_SELECTION) { + if (aWidgetType == StyleAppearance::MozMacActiveSourceListSelection) { return Some(WidgetInfo::ActiveSourceListSelection(isInActiveWindow)); } return Some(WidgetInfo::InactiveSourceListSelection(isInActiveWindow)); } - case NS_THEME_TAB: { + case StyleAppearance::Tab: { SegmentParams params = ComputeSegmentParams(aFrame, eventState, SegmentType::eTab); params.pressed = params.pressed && !params.selected; return Some(WidgetInfo::Segment(params)); } - case NS_THEME_TABPANELS: + case StyleAppearance::Tabpanels: return Some(WidgetInfo::TabPanel(FrameIsInActiveWindow(aFrame))); - case NS_THEME_RESIZER: + case StyleAppearance::Resizer: return Some(WidgetInfo::Resizer(IsFrameRTL(aFrame))); - case NS_THEME_MAC_VIBRANCY_LIGHT: - case NS_THEME_MAC_VIBRANCY_DARK: - case NS_THEME_MAC_VIBRANT_TITLEBAR_LIGHT: - case NS_THEME_MAC_VIBRANT_TITLEBAR_DARK: { + case StyleAppearance::MozMacVibrancyLight: + case StyleAppearance::MozMacVibrancyDark: + case StyleAppearance::MozMacVibrantTitlebarLight: + case StyleAppearance::MozMacVibrantTitlebarDark: { ThemeGeometryType type = ThemeGeometryTypeForWidget(aFrame, aWidgetType); return Some(WidgetInfo::ColorFill(VibrancyFillColor(aFrame, type))); } + default: + break; } return Nothing(); NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(Nothing()); } NS_IMETHODIMP nsNativeThemeCocoa::DrawWidgetBackground(gfxContext* aContext, nsIFrame* aFrame, - uint8_t aWidgetType, + WidgetType aWidgetType, const nsRect& aRect, const nsRect& aDirtyRect) { NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT; Maybe<WidgetInfo> widgetInfo = ComputeWidgetInfo(aFrame, aWidgetType, aRect); if (!widgetInfo) { @@ -3794,17 +3796,17 @@ nsNativeThemeCocoa::RenderWidget(const W } bool nsNativeThemeCocoa::CreateWebRenderCommandsForWidget(mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const mozilla::layers::StackingContextHelper& aSc, mozilla::layers::WebRenderLayerManager* aManager, nsIFrame* aFrame, - uint8_t aWidgetType, + WidgetType aWidgetType, const nsRect& aRect) { nsPresContext* presContext = aFrame->PresContext(); wr::LayoutRect bounds = wr::ToRoundedLayoutRect( LayoutDeviceRect::FromAppUnits(aRect, presContext->AppUnitsPerDevPixel())); EventStates eventState = GetContentState(aFrame, aWidgetType); @@ -3813,96 +3815,96 @@ nsNativeThemeCocoa::CreateWebRenderComma // - If the case in DrawWidgetBackground draws nothing for the given widget // type, then don't list it here. We will hit the "default: return true;" // case. // - If the case in DrawWidgetBackground draws something simple for the given // widget type, imitate that drawing using WebRender commands. // - If the case in DrawWidgetBackground draws something complicated for the // given widget type, return false here. switch (aWidgetType) { - case NS_THEME_DIALOG: + case StyleAppearance::Dialog: if (IsWindowSheet(aFrame) && VibrancyManager::SystemSupportsVibrancy()) { ThemeGeometryType type = ThemeGeometryTypeForWidget(aFrame, aWidgetType); aBuilder.PushRect(bounds, bounds, true, wr::ToColorF(VibrancyFillColor(aFrame, type))); return true; } return false; - case NS_THEME_MENUPOPUP: - case NS_THEME_MENUARROW: - case NS_THEME_MENUITEM: - case NS_THEME_CHECKMENUITEM: - case NS_THEME_MENUSEPARATOR: - case NS_THEME_BUTTON_ARROW_UP: - case NS_THEME_BUTTON_ARROW_DOWN: + case StyleAppearance::Menupopup: + case StyleAppearance::Menuarrow: + case StyleAppearance::Menuitem: + case StyleAppearance::Checkmenuitem: + case StyleAppearance::Menuseparator: + case StyleAppearance::ButtonArrowUp: + case StyleAppearance::ButtonArrowDown: return false; - case NS_THEME_TOOLTIP: + case StyleAppearance::Tooltip: if (VibrancyManager::SystemSupportsVibrancy()) { ThemeGeometryType type = ThemeGeometryTypeForWidget(aFrame, aWidgetType); aBuilder.PushRect(bounds, bounds, true, wr::ToColorF(VibrancyFillColor(aFrame, type))); } else { aBuilder.PushRect(bounds, bounds, true, wr::ToColorF(kTooltipBackgroundColor)); } return true; - case NS_THEME_CHECKBOX: - case NS_THEME_RADIO: - case NS_THEME_BUTTON: - case NS_THEME_FOCUS_OUTLINE: - case NS_THEME_MAC_HELP_BUTTON: - case NS_THEME_MAC_DISCLOSURE_BUTTON_OPEN: - case NS_THEME_MAC_DISCLOSURE_BUTTON_CLOSED: - case NS_THEME_BUTTON_BEVEL: - case NS_THEME_SPINNER: - case NS_THEME_SPINNER_UPBUTTON: - case NS_THEME_SPINNER_DOWNBUTTON: - case NS_THEME_TOOLBARBUTTON: - case NS_THEME_SEPARATOR: - case NS_THEME_TOOLBAR: - case NS_THEME_WINDOW_TITLEBAR: - case NS_THEME_STATUSBAR: - case NS_THEME_MENULIST: - case NS_THEME_MENULIST_TEXTFIELD: - case NS_THEME_MENULIST_BUTTON: - case NS_THEME_GROUPBOX: - case NS_THEME_TEXTFIELD: - case NS_THEME_NUMBER_INPUT: - case NS_THEME_SEARCHFIELD: - case NS_THEME_PROGRESSBAR: - case NS_THEME_PROGRESSBAR_VERTICAL: - case NS_THEME_METERBAR: - case NS_THEME_TREETWISTY: - case NS_THEME_TREETWISTYOPEN: - case NS_THEME_TREEHEADERCELL: - case NS_THEME_TREEITEM: - case NS_THEME_TREEVIEW: - case NS_THEME_SCALE_HORIZONTAL: - case NS_THEME_SCALE_VERTICAL: - case NS_THEME_RANGE: - case NS_THEME_SCROLLBARTHUMB_VERTICAL: - case NS_THEME_SCROLLBARTHUMB_HORIZONTAL: + case StyleAppearance::Checkbox: + case StyleAppearance::Radio: + case StyleAppearance::Button: + case StyleAppearance::FocusOutline: + case StyleAppearance::MozMacHelpButton: + case StyleAppearance::MozMacDisclosureButtonOpen: + case StyleAppearance::MozMacDisclosureButtonClosed: + case StyleAppearance::ButtonBevel: + case StyleAppearance::Spinner: + case StyleAppearance::SpinnerUpbutton: + case StyleAppearance::SpinnerDownbutton: + case StyleAppearance::Toolbarbutton: + case StyleAppearance::Separator: + case StyleAppearance::Toolbar: + case StyleAppearance::MozWindowTitlebar: + case StyleAppearance::Statusbar: + case StyleAppearance::Menulist: + case StyleAppearance::MenulistTextfield: + case StyleAppearance::MenulistButton: + case StyleAppearance::Groupbox: + case StyleAppearance::Textfield: + case StyleAppearance::NumberInput: + case StyleAppearance::Searchfield: + case StyleAppearance::Progressbar: + case StyleAppearance::ProgressbarVertical: + case StyleAppearance::Meterbar: + case StyleAppearance::Treetwisty: + case StyleAppearance::Treetwistyopen: + case StyleAppearance::Treeheadercell: + case StyleAppearance::Treeitem: + case StyleAppearance::Treeview: + case StyleAppearance::ScaleHorizontal: + case StyleAppearance::ScaleVertical: + case StyleAppearance::Range: + case StyleAppearance::ScrollbarthumbVertical: + case StyleAppearance::ScrollbarthumbHorizontal: return false; - case NS_THEME_SCROLLCORNER: - case NS_THEME_SCROLLBARTRACK_HORIZONTAL: - case NS_THEME_SCROLLBARTRACK_VERTICAL: { + case StyleAppearance::Scrollcorner: + case StyleAppearance::ScrollbartrackHorizontal: + case StyleAppearance::ScrollbartrackVertical: { BOOL isOverlay = nsLookAndFeel::UseOverlayScrollbars(); if (isOverlay && !IsParentScrollbarRolledOver(aFrame)) { // There is no scrollbar track, draw nothing and return true. return true; } // There is a scrollbar track and it needs to be drawn using fallback. return false; } - case NS_THEME_TEXTFIELD_MULTILINE: { + case StyleAppearance::TextfieldMultiline: { if (eventState.HasState(NS_EVENT_STATE_FOCUS)) { // We can't draw the focus ring using webrender, so fall back to regular // drawing if we're focused. return false; } // White background aBuilder.PushRect(bounds, bounds, true, @@ -3921,17 +3923,17 @@ nsNativeThemeCocoa::CreateWebRenderComma wr::ToBorderWidths(borderWidth, borderWidth, borderWidth, borderWidth); mozilla::Range<const wr::BorderSide> wrsides(side, 4); aBuilder.PushBorder(bounds, bounds, true, borderWidths, wrsides, borderRadius); return true; } - case NS_THEME_LISTBOX: { + case StyleAppearance::Listbox: { // White background aBuilder.PushRect(bounds, bounds, true, wr::ToColorF(Color(1.0, 1.0, 1.0, 1.0))); wr::BorderSide side[4] = { wr::ToBorderSide(kListboxTopBorderColor, NS_STYLE_BORDER_STYLE_SOLID), wr::ToBorderSide(kListBoxSidesAndBottomBorderColor, NS_STYLE_BORDER_STYLE_SOLID), wr::ToBorderSide(kListBoxSidesAndBottomBorderColor, NS_STYLE_BORDER_STYLE_SOLID), @@ -3943,38 +3945,38 @@ nsNativeThemeCocoa::CreateWebRenderComma wr::BorderWidths borderWidths = wr::ToBorderWidths(borderWidth, borderWidth, borderWidth, borderWidth); mozilla::Range<const wr::BorderSide> wrsides(side, 4); aBuilder.PushBorder(bounds, bounds, true, borderWidths, wrsides, borderRadius); return true; } - case NS_THEME_MAC_SOURCE_LIST: + case StyleAppearance::MozMacSourceList: if (VibrancyManager::SystemSupportsVibrancy()) { ThemeGeometryType type = ThemeGeometryTypeForWidget(aFrame, aWidgetType); aBuilder.PushRect(bounds, bounds, true, wr::ToColorF(VibrancyFillColor(aFrame, type))); return true; } return false; - case NS_THEME_MAC_VIBRANCY_LIGHT: - case NS_THEME_MAC_VIBRANCY_DARK: - case NS_THEME_MAC_VIBRANT_TITLEBAR_LIGHT: - case NS_THEME_MAC_VIBRANT_TITLEBAR_DARK: { + case StyleAppearance::MozMacVibrancyLight: + case StyleAppearance::MozMacVibrancyDark: + case StyleAppearance::MozMacVibrantTitlebarLight: + case StyleAppearance::MozMacVibrantTitlebarDark: { ThemeGeometryType type = ThemeGeometryTypeForWidget(aFrame, aWidgetType); aBuilder.PushRect(bounds, bounds, true, wr::ToColorF(VibrancyFillColor(aFrame, type))); return true; } - case NS_THEME_TAB: - case NS_THEME_TABPANELS: - case NS_THEME_RESIZER: + case StyleAppearance::Tab: + case StyleAppearance::Tabpanels: + case StyleAppearance::Resizer: return false; default: return true; } } LayoutDeviceIntMargin @@ -3992,92 +3994,92 @@ nsNativeThemeCocoa::DirectionAwareMargin static const LayoutDeviceIntMargin kAquaDropdownBorder(1, 22, 2, 5); static const LayoutDeviceIntMargin kAquaComboboxBorder(3, 20, 3, 4); static const LayoutDeviceIntMargin kAquaSearchfieldBorder(3, 5, 2, 19); LayoutDeviceIntMargin nsNativeThemeCocoa::GetWidgetBorder(nsDeviceContext* aContext, nsIFrame* aFrame, - uint8_t aWidgetType) + WidgetType aWidgetType) { LayoutDeviceIntMargin result; NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN; switch (aWidgetType) { - case NS_THEME_BUTTON: + case StyleAppearance::Button: { if (IsButtonTypeMenu(aFrame)) { result = DirectionAwareMargin(kAquaDropdownBorder, aFrame); } else { result = DirectionAwareMargin(LayoutDeviceIntMargin(1, 7, 3, 7), aFrame); } break; } - case NS_THEME_TOOLBARBUTTON: + case StyleAppearance::Toolbarbutton: { result = DirectionAwareMargin(LayoutDeviceIntMargin(1, 4, 1, 4), aFrame); break; } - case NS_THEME_CHECKBOX: - case NS_THEME_RADIO: + case StyleAppearance::Checkbox: + case StyleAppearance::Radio: { // nsCheckboxRadioFrame::GetIntrinsicWidth and nsCheckboxRadioFrame::GetIntrinsicHeight // assume a border width of 2px. result.SizeTo(2, 2, 2, 2); break; } - case NS_THEME_MENULIST: - case NS_THEME_MENULIST_BUTTON: + case StyleAppearance::Menulist: + case StyleAppearance::MenulistButton: result = DirectionAwareMargin(kAquaDropdownBorder, aFrame); break; - case NS_THEME_MENULIST_TEXTFIELD: + case StyleAppearance::MenulistTextfield: result = DirectionAwareMargin(kAquaComboboxBorder, aFrame); break; - case NS_THEME_NUMBER_INPUT: - case NS_THEME_TEXTFIELD: + case StyleAppearance::NumberInput: + case StyleAppearance::Textfield: { SInt32 frameOutset = 0; ::GetThemeMetric(kThemeMetricEditTextFrameOutset, &frameOutset); SInt32 textPadding = 0; ::GetThemeMetric(kThemeMetricEditTextWhitespace, &textPadding); frameOutset += textPadding; result.SizeTo(frameOutset, frameOutset, frameOutset, frameOutset); break; } - case NS_THEME_TEXTFIELD_MULTILINE: + case StyleAppearance::TextfieldMultiline: result.SizeTo(1, 1, 1, 1); break; - case NS_THEME_SEARCHFIELD: + case StyleAppearance::Searchfield: result = DirectionAwareMargin(kAquaSearchfieldBorder, aFrame); break; - case NS_THEME_LISTBOX: + case StyleAppearance::Listbox: { SInt32 frameOutset = 0; ::GetThemeMetric(kThemeMetricListBoxFrameOutset, &frameOutset); result.SizeTo(frameOutset, frameOutset, frameOutset, frameOutset); break; } - case NS_THEME_SCROLLBARTRACK_HORIZONTAL: - case NS_THEME_SCROLLBARTRACK_VERTICAL: + case StyleAppearance::ScrollbartrackHorizontal: + case StyleAppearance::ScrollbartrackVertical: { - bool isHorizontal = (aWidgetType == NS_THEME_SCROLLBARTRACK_HORIZONTAL); + bool isHorizontal = (aWidgetType == StyleAppearance::ScrollbartrackHorizontal); if (nsLookAndFeel::UseOverlayScrollbars()) { if (!nsCocoaFeatures::OnYosemiteOrLater()) { // Pre-10.10, we have to center the thumb rect in the middle of the // scrollbar. Starting with 10.10, the expected rect for thumb // rendering is the full width of the scrollbar. if (isHorizontal) { result.top = 2; result.bottom = 1; @@ -4094,94 +4096,101 @@ nsNativeThemeCocoa::GetWidgetBorder(nsDe result.top = 1; result.bottom = 1; } } break; } - case NS_THEME_STATUSBAR: + case StyleAppearance::Statusbar: result.SizeTo(1, 0, 0, 0); break; + + default: + break; } if (IsHiDPIContext(aContext)) { result = result + result; // doubled } NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(result); } // Return false here to indicate that CSS padding values should be used. There is // no reason to make a distinction between padding and border values, just specify // whatever values you want in GetWidgetBorder and only use this to return true // if you want to override CSS padding values. bool nsNativeThemeCocoa::GetWidgetPadding(nsDeviceContext* aContext, nsIFrame* aFrame, - uint8_t aWidgetType, + WidgetType aWidgetType, LayoutDeviceIntMargin* aResult) { // We don't want CSS padding being used for certain widgets. // See bug 381639 for an example of why. switch (aWidgetType) { // Radios and checkboxes return a fixed size in GetMinimumWidgetSize // and have a meaningful baseline, so they can't have // author-specified padding. - case NS_THEME_CHECKBOX: - case NS_THEME_RADIO: + case StyleAppearance::Checkbox: + case StyleAppearance::Radio: aResult->SizeTo(0, 0, 0, 0); return true; + default: + break; } return false; } bool nsNativeThemeCocoa::GetWidgetOverflow(nsDeviceContext* aContext, nsIFrame* aFrame, - uint8_t aWidgetType, nsRect* aOverflowRect) + WidgetType aWidgetType, nsRect* aOverflowRect) { nsIntMargin overflow; switch (aWidgetType) { - case NS_THEME_BUTTON: - case NS_THEME_MAC_DISCLOSURE_BUTTON_OPEN: - case NS_THEME_MAC_DISCLOSURE_BUTTON_CLOSED: - case NS_THEME_MAC_HELP_BUTTON: - case NS_THEME_TOOLBARBUTTON: - case NS_THEME_NUMBER_INPUT: - case NS_THEME_TEXTFIELD: - case NS_THEME_TEXTFIELD_MULTILINE: - case NS_THEME_SEARCHFIELD: - case NS_THEME_LISTBOX: - case NS_THEME_MENULIST: - case NS_THEME_MENULIST_BUTTON: - case NS_THEME_MENULIST_TEXTFIELD: - case NS_THEME_CHECKBOX: - case NS_THEME_RADIO: - case NS_THEME_TAB: - case NS_THEME_FOCUS_OUTLINE: + case StyleAppearance::Button: + case StyleAppearance::MozMacDisclosureButtonOpen: + case StyleAppearance::MozMacDisclosureButtonClosed: + case StyleAppearance::MozMacHelpButton: + case StyleAppearance::Toolbarbutton: + case StyleAppearance::NumberInput: + case StyleAppearance::Textfield: + case StyleAppearance::TextfieldMultiline: + case StyleAppearance::Searchfield: + case StyleAppearance::Listbox: + case StyleAppearance::Menulist: + case StyleAppearance::MenulistButton: + case StyleAppearance::MenulistTextfield: + case StyleAppearance::Checkbox: + case StyleAppearance::Radio: + case StyleAppearance::Tab: + case StyleAppearance::FocusOutline: { overflow.SizeTo(kMaxFocusRingWidth, kMaxFocusRingWidth, kMaxFocusRingWidth, kMaxFocusRingWidth); break; } - case NS_THEME_PROGRESSBAR: + case StyleAppearance::Progressbar: { // Progress bars draw a 2 pixel white shadow under their progress indicators. overflow.bottom = 2; break; } - case NS_THEME_METERBAR: + case StyleAppearance::Meterbar: { // Meter bars overflow their boxes by about 2 pixels. overflow.SizeTo(2, 2, 2, 2); break; } + default: + break; } if (IsHiDPIContext(aContext)) { // Double the number of device pixels. overflow += overflow; } if (overflow != nsIntMargin()) { @@ -4197,173 +4206,173 @@ nsNativeThemeCocoa::GetWidgetOverflow(ns } static const int32_t kRegularScrollbarThumbMinSize = 26; static const int32_t kSmallScrollbarThumbMinSize = 26; NS_IMETHODIMP nsNativeThemeCocoa::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aFrame, - uint8_t aWidgetType, + WidgetType aWidgetType, LayoutDeviceIntSize* aResult, bool* aIsOverridable) { NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT; aResult->SizeTo(0,0); *aIsOverridable = true; switch (aWidgetType) { - case NS_THEME_BUTTON: + case StyleAppearance::Button: { aResult->SizeTo(pushButtonSettings.minimumSizes[miniControlSize].width, pushButtonSettings.naturalSizes[miniControlSize].height); break; } - case NS_THEME_BUTTON_ARROW_UP: - case NS_THEME_BUTTON_ARROW_DOWN: + case StyleAppearance::ButtonArrowUp: + case StyleAppearance::ButtonArrowDown: { aResult->SizeTo(kMenuScrollArrowSize.width, kMenuScrollArrowSize.height); *aIsOverridable = false; break; } - case NS_THEME_MENUARROW: + case StyleAppearance::Menuarrow: { aResult->SizeTo(kMenuarrowSize.width, kMenuarrowSize.height); *aIsOverridable = false; break; } - case NS_THEME_MAC_DISCLOSURE_BUTTON_OPEN: - case NS_THEME_MAC_DISCLOSURE_BUTTON_CLOSED: + case StyleAppearance::MozMacDisclosureButtonOpen: + case StyleAppearance::MozMacDisclosureButtonClosed: { aResult->SizeTo(kDisclosureButtonSize.width, kDisclosureButtonSize.height); *aIsOverridable = false; break; } - case NS_THEME_MAC_HELP_BUTTON: + case StyleAppearance::MozMacHelpButton: { aResult->SizeTo(kHelpButtonSize.width, kHelpButtonSize.height); *aIsOverridable = false; break; } - case NS_THEME_TOOLBARBUTTON: + case StyleAppearance::Toolbarbutton: { aResult->SizeTo(0, toolbarButtonHeights[miniControlSize]); break; } - case NS_THEME_INNER_SPIN_BUTTON: - case NS_THEME_SPINNER: - case NS_THEME_SPINNER_UPBUTTON: - case NS_THEME_SPINNER_DOWNBUTTON: + case StyleAppearance::InnerSpinButton: + case StyleAppearance::Spinner: + case StyleAppearance::SpinnerUpbutton: + case StyleAppearance::SpinnerDownbutton: { SInt32 buttonHeight = 0, buttonWidth = 0; if (aFrame->GetContent()->IsXULElement()) { ::GetThemeMetric(kThemeMetricLittleArrowsWidth, &buttonWidth); ::GetThemeMetric(kThemeMetricLittleArrowsHeight, &buttonHeight); } else { NSSize size = spinnerSettings.minimumSizes[EnumSizeForCocoaSize(NSMiniControlSize)]; buttonWidth = size.width; buttonHeight = size.height; - if (aWidgetType != NS_THEME_SPINNER) { + if (aWidgetType != StyleAppearance::Spinner) { // the buttons are half the height of the spinner buttonHeight /= 2; } } aResult->SizeTo(buttonWidth, buttonHeight); *aIsOverridable = true; break; } - case NS_THEME_MENULIST: - case NS_THEME_MENULIST_BUTTON: + case StyleAppearance::Menulist: + case StyleAppearance::MenulistButton: { SInt32 popupHeight = 0; ::GetThemeMetric(kThemeMetricPopupButtonHeight, &popupHeight); aResult->SizeTo(0, popupHeight); break; } - case NS_THEME_NUMBER_INPUT: - case NS_THEME_TEXTFIELD: - case NS_THEME_TEXTFIELD_MULTILINE: - case NS_THEME_SEARCHFIELD: + case StyleAppearance::NumberInput: + case StyleAppearance::Textfield: + case StyleAppearance::TextfieldMultiline: + case StyleAppearance::Searchfield: { // at minimum, we should be tall enough for 9pt text. // I'm using hardcoded values here because the appearance manager // values for the frame size are incorrect. aResult->SizeTo(0, (2 + 2) /* top */ + 9 + (1 + 1) /* bottom */); break; } - case NS_THEME_WINDOW_BUTTON_BOX: { + case StyleAppearance::MozWindowButtonBox: { NSSize size = WindowButtonsSize(aFrame); aResult->SizeTo(size.width, size.height); *aIsOverridable = false; break; } - case NS_THEME_MAC_FULLSCREEN_BUTTON: { + case StyleAppearance::MozMacFullscreenButton: { if ([NativeWindowForFrame(aFrame) respondsToSelector:@selector(toggleFullScreen:)] && !nsCocoaFeatures::OnYosemiteOrLater()) { // This value is hardcoded because it's needed before we can measure the // position and size of the fullscreen button. aResult->SizeTo(16, 17); } *aIsOverridable = false; break; } - case NS_THEME_PROGRESSBAR: + case StyleAppearance::Progressbar: { SInt32 barHeight = 0; ::GetThemeMetric(kThemeMetricNormalProgressBarThickness, &barHeight); aResult->SizeTo(0, barHeight); break; } - case NS_THEME_SEPARATOR: + case StyleAppearance::Separator: { aResult->SizeTo(1, 1); break; } - case NS_THEME_TREETWISTY: - case NS_THEME_TREETWISTYOPEN: + case StyleAppearance::Treetwisty: + case StyleAppearance::Treetwistyopen: { SInt32 twistyHeight = 0, twistyWidth = 0; ::GetThemeMetric(kThemeMetricDisclosureButtonWidth, &twistyWidth); ::GetThemeMetric(kThemeMetricDisclosureButtonHeight, &twistyHeight); aResult->SizeTo(twistyWidth, twistyHeight); *aIsOverridable = false; break; } - case NS_THEME_TREEHEADER: - case NS_THEME_TREEHEADERCELL: + case StyleAppearance::Treeheader: + case StyleAppearance::Treeheadercell: { SInt32 headerHeight = 0; ::GetThemeMetric(kThemeMetricListHeaderHeight, &headerHeight); aResult->SizeTo(0, headerHeight - 1); // We don't need the top border. break; } - case NS_THEME_TAB: + case StyleAppearance::Tab: { aResult->SizeTo(0, tabHeights[miniControlSize]); break; } - case NS_THEME_RANGE: + case StyleAppearance::Range: { // The Mac Appearance Manager API (the old API we're currently using) // doesn't define constants to obtain a minimum size for sliders. We use // the "thickness" of a slider that has default dimensions for both the // minimum width and height to get something sane and so that paint // invalidation works. SInt32 size = 0; if (IsRangeHorizontal(aFrame)) { @@ -4371,201 +4380,205 @@ nsNativeThemeCocoa::GetMinimumWidgetSize } else { ::GetThemeMetric(kThemeMetricVSliderWidth, &size); } aResult->SizeTo(size, size); *aIsOverridable = true; break; } - case NS_THEME_RANGE_THUMB: + case StyleAppearance::RangeThumb: { SInt32 width = 0; SInt32 height = 0; ::GetThemeMetric(kThemeMetricSliderMinThumbWidth, &width); ::GetThemeMetric(kThemeMetricSliderMinThumbHeight, &height); aResult->SizeTo(width, height); *aIsOverridable = false; break; } - case NS_THEME_SCALE_HORIZONTAL: + case StyleAppearance::ScaleHorizontal: { SInt32 scaleHeight = 0; ::GetThemeMetric(kThemeMetricHSliderHeight, &scaleHeight); aResult->SizeTo(scaleHeight, scaleHeight); *aIsOverridable = false; break; } - case NS_THEME_SCALE_VERTICAL: + case StyleAppearance::ScaleVertical: { SInt32 scaleWidth = 0; ::GetThemeMetric(kThemeMetricVSliderWidth, &scaleWidth); aResult->SizeTo(scaleWidth, scaleWidth); *aIsOverridable = false; break; } - case NS_THEME_SCROLLBARTHUMB_HORIZONTAL: - case NS_THEME_SCROLLBARTHUMB_VERTICAL: + case StyleAppearance::ScrollbarthumbHorizontal: + case StyleAppearance::ScrollbarthumbVertical: { // Find our parent scrollbar frame in order to find out whether we're in // a small or a large scrollbar. nsIFrame *scrollbarFrame = GetParentScrollbarFrame(aFrame); if (!scrollbarFrame) return NS_ERROR_FAILURE; - bool isSmall = (scrollbarFrame->StyleDisplay()->mAppearance == NS_THEME_SCROLLBAR_SMALL); - bool isHorizontal = (aWidgetType == NS_THEME_SCROLLBARTHUMB_HORIZONTAL); + bool isSmall = (scrollbarFrame->StyleDisplay()->mAppearance == StyleAppearance::ScrollbarSmall); + bool isHorizontal = (aWidgetType == StyleAppearance::ScrollbarthumbHorizontal); int32_t& minSize = isHorizontal ? aResult->width : aResult->height; minSize = isSmall ? kSmallScrollbarThumbMinSize : kRegularScrollbarThumbMinSize; break; } - case NS_THEME_SCROLLBAR: - case NS_THEME_SCROLLBAR_SMALL: - case NS_THEME_SCROLLBARTRACK_VERTICAL: - case NS_THEME_SCROLLBARTRACK_HORIZONTAL: + case StyleAppearance::Scrollbar: + case StyleAppearance::ScrollbarSmall: + case StyleAppearance::ScrollbartrackVertical: + case StyleAppearance::ScrollbartrackHorizontal: { *aIsOverridable = false; if (nsLookAndFeel::UseOverlayScrollbars()) { nsIFrame* scrollbarFrame = GetParentScrollbarFrame(aFrame); if (scrollbarFrame && scrollbarFrame->StyleDisplay()->mAppearance == - NS_THEME_SCROLLBAR_SMALL) { + StyleAppearance::ScrollbarSmall) { aResult->SizeTo(14, 14); } else { aResult->SizeTo(16, 16); } break; } // yeah, i know i'm cheating a little here, but i figure that it // really doesn't matter if the scrollbar is vertical or horizontal // and the width metric is a really good metric for every piece // of the scrollbar. nsIFrame *scrollbarFrame = GetParentScrollbarFrame(aFrame); if (!scrollbarFrame) return NS_ERROR_FAILURE; - int32_t themeMetric = (scrollbarFrame->StyleDisplay()->mAppearance == NS_THEME_SCROLLBAR_SMALL) ? + int32_t themeMetric = (scrollbarFrame->StyleDisplay()->mAppearance == StyleAppearance::ScrollbarSmall) ? kThemeMetricSmallScrollBarWidth : kThemeMetricScrollBarWidth; SInt32 scrollbarWidth = 0; ::GetThemeMetric(themeMetric, &scrollbarWidth); aResult->SizeTo(scrollbarWidth, scrollbarWidth); break; } - case NS_THEME_SCROLLBAR_NON_DISAPPEARING: + case StyleAppearance::ScrollbarNonDisappearing: { int32_t themeMetric = kThemeMetricScrollBarWidth; if (aFrame) { nsIFrame* scrollbarFrame = GetParentScrollbarFrame(aFrame); if (scrollbarFrame && scrollbarFrame->StyleDisplay()->mAppearance == - NS_THEME_SCROLLBAR_SMALL) { + StyleAppearance::ScrollbarSmall) { // XXX We're interested in the width of non-disappearing scrollbars // to leave enough space for a dropmarker in non-native styled // comboboxes (bug 869314). It isn't clear to me if comboboxes can // ever have small scrollbars. themeMetric = kThemeMetricSmallScrollBarWidth; } } SInt32 scrollbarWidth = 0; ::GetThemeMetric(themeMetric, &scrollbarWidth); aResult->SizeTo(scrollbarWidth, scrollbarWidth); break; } - case NS_THEME_SCROLLBARBUTTON_UP: - case NS_THEME_SCROLLBARBUTTON_DOWN: - case NS_THEME_SCROLLBARBUTTON_LEFT: - case NS_THEME_SCROLLBARBUTTON_RIGHT: + case StyleAppearance::ScrollbarbuttonUp: + case StyleAppearance::ScrollbarbuttonDown: + case StyleAppearance::ScrollbarbuttonLeft: + case StyleAppearance::ScrollbarbuttonRight: { nsIFrame *scrollbarFrame = GetParentScrollbarFrame(aFrame); if (!scrollbarFrame) return NS_ERROR_FAILURE; - // Since there is no NS_THEME_SCROLLBARBUTTON_UP_SMALL we need to ask the parent what appearance style it has. - int32_t themeMetric = (scrollbarFrame->StyleDisplay()->mAppearance == NS_THEME_SCROLLBAR_SMALL) ? + // Since there is no StyleAppearance::ScrollbarbuttonUpSmall we need to ask the parent what appearance style it has. + int32_t themeMetric = (scrollbarFrame->StyleDisplay()->mAppearance == StyleAppearance::ScrollbarSmall) ? kThemeMetricSmallScrollBarWidth : kThemeMetricScrollBarWidth; SInt32 scrollbarWidth = 0; ::GetThemeMetric(themeMetric, &scrollbarWidth); // It seems that for both sizes of scrollbar, the buttons are one pixel "longer". - if (aWidgetType == NS_THEME_SCROLLBARBUTTON_LEFT || aWidgetType == NS_THEME_SCROLLBARBUTTON_RIGHT) + if (aWidgetType == StyleAppearance::ScrollbarbuttonLeft || aWidgetType == StyleAppearance::ScrollbarbuttonRight) aResult->SizeTo(scrollbarWidth+1, scrollbarWidth); else aResult->SizeTo(scrollbarWidth, scrollbarWidth+1); *aIsOverridable = false; break; } - case NS_THEME_RESIZER: + case StyleAppearance::Resizer: { HIThemeGrowBoxDrawInfo drawInfo; drawInfo.version = 0; drawInfo.state = kThemeStateActive; drawInfo.kind = kHIThemeGrowBoxKindNormal; drawInfo.direction = kThemeGrowRight | kThemeGrowDown; drawInfo.size = kHIThemeGrowBoxSizeNormal; HIPoint pnt = { 0, 0 }; HIRect bounds; HIThemeGetGrowBoxBounds(&pnt, &drawInfo, &bounds); aResult->SizeTo(bounds.size.width, bounds.size.height); *aIsOverridable = false; } + default: + break; } if (IsHiDPIContext(aPresContext->DeviceContext())) { *aResult = *aResult * 2; } return NS_OK; NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT; } NS_IMETHODIMP -nsNativeThemeCocoa::WidgetStateChanged(nsIFrame* aFrame, uint8_t aWidgetType, +nsNativeThemeCocoa::WidgetStateChanged(nsIFrame* aFrame, WidgetType aWidgetType, nsAtom* aAttribute, bool* aShouldRepaint, const nsAttrValue* aOldValue) { // Some widget types just never change state. switch (aWidgetType) { - case NS_THEME_WINDOW_TITLEBAR: - case NS_THEME_TOOLBOX: - case NS_THEME_TOOLBAR: - case NS_THEME_STATUSBAR: - case NS_THEME_STATUSBARPANEL: - case NS_THEME_RESIZERPANEL: - case NS_THEME_TOOLTIP: - case NS_THEME_TABPANELS: - case NS_THEME_TABPANEL: - case NS_THEME_DIALOG: - case NS_THEME_MENUPOPUP: - case NS_THEME_GROUPBOX: - case NS_THEME_PROGRESSCHUNK: - case NS_THEME_PROGRESSCHUNK_VERTICAL: - case NS_THEME_PROGRESSBAR: - case NS_THEME_PROGRESSBAR_VERTICAL: - case NS_THEME_METERBAR: - case NS_THEME_METERCHUNK: - case NS_THEME_MAC_VIBRANCY_LIGHT: - case NS_THEME_MAC_VIBRANCY_DARK: - case NS_THEME_MAC_VIBRANT_TITLEBAR_LIGHT: - case NS_THEME_MAC_VIBRANT_TITLEBAR_DARK: + case StyleAppearance::MozWindowTitlebar: + case StyleAppearance::Toolbox: + case StyleAppearance::Toolbar: + case StyleAppearance::Statusbar: + case StyleAppearance::Statusbarpanel: + case StyleAppearance::Resizerpanel: + case StyleAppearance::Tooltip: + case StyleAppearance::Tabpanels: + case StyleAppearance::Tabpanel: + case StyleAppearance::Dialog: + case StyleAppearance::Menupopup: + case StyleAppearance::Groupbox: + case StyleAppearance::Progresschunk: + case StyleAppearance::ProgresschunkVertical: + case StyleAppearance::Progressbar: + case StyleAppearance::ProgressbarVertical: + case StyleAppearance::Meterbar: + case StyleAppearance::Meterchunk: + case StyleAppearance::MozMacVibrancyLight: + case StyleAppearance::MozMacVibrancyDark: + case StyleAppearance::MozMacVibrantTitlebarLight: + case StyleAppearance::MozMacVibrantTitlebarDark: *aShouldRepaint = false; return NS_OK; + default: + break; } // XXXdwh Not sure what can really be done here. Can at least guess for // specific widgets that they're highly unlikely to have certain states. // For example, a toolbar doesn't care about any states. if (!aAttribute) { // Hover/focus/active changed. Always repaint. *aShouldRepaint = true; @@ -4595,220 +4608,224 @@ nsNativeThemeCocoa::ThemeChanged() // This is unimplemented because we don't care if gecko changes its theme // and macOS system appearance changes are handled by // nsLookAndFeel::SystemWantsDarkTheme. return NS_OK; } bool nsNativeThemeCocoa::ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* aFrame, - uint8_t aWidgetType) + WidgetType aWidgetType) { // if this is a dropdown button in a combobox the answer is always no - if (aWidgetType == NS_THEME_MENULIST_BUTTON) { + if (aWidgetType == StyleAppearance::MenulistButton) { nsIFrame* parentFrame = aFrame->GetParent(); if (parentFrame && parentFrame->IsComboboxControlFrame()) return false; } switch (aWidgetType) { // Combobox dropdowns don't support native theming in vertical mode. - case NS_THEME_MENULIST: - case NS_THEME_MENULIST_BUTTON: - case NS_THEME_MENULIST_TEXT: - case NS_THEME_MENULIST_TEXTFIELD: + case StyleAppearance::Menulist: + case StyleAppearance::MenulistButton: + case StyleAppearance::MenulistText: + case StyleAppearance::MenulistTextfield: if (aFrame && aFrame->GetWritingMode().IsVertical()) { return false; } MOZ_FALLTHROUGH; - case NS_THEME_LISTBOX: - - case NS_THEME_DIALOG: - case NS_THEME_WINDOW: - case NS_THEME_WINDOW_BUTTON_BOX: - case NS_THEME_WINDOW_TITLEBAR: - case NS_THEME_CHECKMENUITEM: - case NS_THEME_MENUPOPUP: - case NS_THEME_MENUARROW: - case NS_THEME_MENUITEM: - case NS_THEME_MENUSEPARATOR: - case NS_THEME_MAC_FULLSCREEN_BUTTON: - case NS_THEME_TOOLTIP: - - case NS_THEME_CHECKBOX: - case NS_THEME_CHECKBOX_CONTAINER: - case NS_THEME_RADIO: - case NS_THEME_RADIO_CONTAINER: - case NS_THEME_GROUPBOX: - case NS_THEME_MAC_HELP_BUTTON: - case NS_THEME_MAC_DISCLOSURE_BUTTON_OPEN: - case NS_THEME_MAC_DISCLOSURE_BUTTON_CLOSED: - case NS_THEME_BUTTON: - case NS_THEME_BUTTON_ARROW_UP: - case NS_THEME_BUTTON_ARROW_DOWN: - case NS_THEME_BUTTON_BEVEL: - case NS_THEME_TOOLBARBUTTON: - case NS_THEME_INNER_SPIN_BUTTON: - case NS_THEME_SPINNER: - case NS_THEME_SPINNER_UPBUTTON: - case NS_THEME_SPINNER_DOWNBUTTON: - case NS_THEME_TOOLBAR: - case NS_THEME_STATUSBAR: - case NS_THEME_NUMBER_INPUT: - case NS_THEME_TEXTFIELD: - case NS_THEME_TEXTFIELD_MULTILINE: - case NS_THEME_SEARCHFIELD: - case NS_THEME_TOOLBOX: - //case NS_THEME_TOOLBARBUTTON: - case NS_THEME_PROGRESSBAR: - case NS_THEME_PROGRESSBAR_VERTICAL: - case NS_THEME_PROGRESSCHUNK: - case NS_THEME_PROGRESSCHUNK_VERTICAL: - case NS_THEME_METERBAR: - case NS_THEME_METERCHUNK: - case NS_THEME_SEPARATOR: - - case NS_THEME_TABPANELS: - case NS_THEME_TAB: - - case NS_THEME_TREETWISTY: - case NS_THEME_TREETWISTYOPEN: - case NS_THEME_TREEVIEW: - case NS_THEME_TREEHEADER: - case NS_THEME_TREEHEADERCELL: - case NS_THEME_TREEHEADERSORTARROW: - case NS_THEME_TREEITEM: - case NS_THEME_TREELINE: - case NS_THEME_MAC_SOURCE_LIST: - case NS_THEME_MAC_SOURCE_LIST_SELECTION: - case NS_THEME_MAC_ACTIVE_SOURCE_LIST_SELECTION: - - case NS_THEME_RANGE: - - case NS_THEME_SCALE_HORIZONTAL: - case NS_THEME_SCALETHUMB_HORIZONTAL: - case NS_THEME_SCALE_VERTICAL: - case NS_THEME_SCALETHUMB_VERTICAL: - - case NS_THEME_SCROLLBAR: - case NS_THEME_SCROLLBAR_SMALL: - case NS_THEME_SCROLLBARBUTTON_UP: - case NS_THEME_SCROLLBARBUTTON_DOWN: - case NS_THEME_SCROLLBARBUTTON_LEFT: - case NS_THEME_SCROLLBARBUTTON_RIGHT: - case NS_THEME_SCROLLBARTHUMB_HORIZONTAL: - case NS_THEME_SCROLLBARTHUMB_VERTICAL: - case NS_THEME_SCROLLBARTRACK_VERTICAL: - case NS_THEME_SCROLLBARTRACK_HORIZONTAL: - case NS_THEME_SCROLLBAR_NON_DISAPPEARING: + case StyleAppearance::Listbox: + + case StyleAppearance::Dialog: + case StyleAppearance::Window: + case StyleAppearance::MozWindowButtonBox: + case StyleAppearance::MozWindowTitlebar: + case StyleAppearance::Checkmenuitem: + case StyleAppearance::Menupopup: + case StyleAppearance::Menuarrow: + case StyleAppearance::Menuitem: + case StyleAppearance::Menuseparator: + case StyleAppearance::MozMacFullscreenButton: + case StyleAppearance::Tooltip: + + case StyleAppearance::Checkbox: + case StyleAppearance::CheckboxContainer: + case StyleAppearance::Radio: + case StyleAppearance::RadioContainer: + case StyleAppearance::Groupbox: + case StyleAppearance::MozMacHelpButton: + case StyleAppearance::MozMacDisclosureButtonOpen: + case StyleAppearance::MozMacDisclosureButtonClosed: + case StyleAppearance::Button: + case StyleAppearance::ButtonArrowUp: + case StyleAppearance::ButtonArrowDown: + case StyleAppearance::ButtonBevel: + case StyleAppearance::Toolbarbutton: + case StyleAppearance::InnerSpinButton: + case StyleAppearance::Spinner: + case StyleAppearance::SpinnerUpbutton: + case StyleAppearance::SpinnerDownbutton: + case StyleAppearance::Toolbar: + case StyleAppearance::Statusbar: + case StyleAppearance::NumberInput: + case StyleAppearance::Textfield: + case StyleAppearance::TextfieldMultiline: + case StyleAppearance::Searchfield: + case StyleAppearance::Toolbox: + //case StyleAppearance::Toolbarbutton: + case StyleAppearance::Progressbar: + case StyleAppearance::ProgressbarVertical: + case StyleAppearance::Progresschunk: + case StyleAppearance::ProgresschunkVertical: + case StyleAppearance::Meterbar: + case StyleAppearance::Meterchunk: + case StyleAppearance::Separator: + + case StyleAppearance::Tabpanels: + case StyleAppearance::Tab: + + case StyleAppearance::Treetwisty: + case StyleAppearance::Treetwistyopen: + case StyleAppearance::Treeview: + case StyleAppearance::Treeheader: + case StyleAppearance::Treeheadercell: + case StyleAppearance::Treeheadersortarrow: + case StyleAppearance::Treeitem: + case StyleAppearance::Treeline: + case StyleAppearance::MozMacSourceList: + case StyleAppearance::MozMacSourceListSelection: + case StyleAppearance::MozMacActiveSourceListSelection: + + case StyleAppearance::Range: + + case StyleAppearance::ScaleHorizontal: + case StyleAppearance::ScalethumbHorizontal: + case StyleAppearance::ScaleVertical: + case StyleAppearance::ScalethumbVertical: + + case StyleAppearance::Scrollbar: + case StyleAppearance::ScrollbarSmall: + case StyleAppearance::ScrollbarbuttonUp: + case StyleAppearance::ScrollbarbuttonDown: + case StyleAppearance::ScrollbarbuttonLeft: + case StyleAppearance::ScrollbarbuttonRight: + case StyleAppearance::ScrollbarthumbHorizontal: + case StyleAppearance::ScrollbarthumbVertical: + case StyleAppearance::ScrollbartrackVertical: + case StyleAppearance::ScrollbartrackHorizontal: + case StyleAppearance::ScrollbarNonDisappearing: return !IsWidgetStyled(aPresContext, aFrame, aWidgetType); - case NS_THEME_SCROLLCORNER: + case StyleAppearance::Scrollcorner: return true; - case NS_THEME_RESIZER: + case StyleAppearance::Resizer: { nsIFrame* parentFrame = aFrame->GetParent(); if (!parentFrame || !parentFrame->IsScrollFrame()) return true; // Note that IsWidgetStyled is not called for resizers on Mac. This is // because for scrollable containers, the native resizer looks better // when (non-overlay) scrollbars are present even when the style is // overriden, and the custom transparent resizer looks better when // scrollbars are not present. nsIScrollableFrame* scrollFrame = do_QueryFrame(parentFrame); return (!nsLookAndFeel::UseOverlayScrollbars() && scrollFrame && scrollFrame->GetScrollbarVisibility()); } - case NS_THEME_FOCUS_OUTLINE: + case StyleAppearance::FocusOutline: return true; - case NS_THEME_MAC_VIBRANCY_LIGHT: - case NS_THEME_MAC_VIBRANCY_DARK: - case NS_THEME_MAC_VIBRANT_TITLEBAR_LIGHT: - case NS_THEME_MAC_VIBRANT_TITLEBAR_DARK: + case StyleAppearance::MozMacVibrancyLight: + case StyleAppearance::MozMacVibrancyDark: + case StyleAppearance::MozMacVibrantTitlebarLight: + case StyleAppearance::MozMacVibrantTitlebarDark: return VibrancyManager::SystemSupportsVibrancy(); + default: + break; } return false; } bool -nsNativeThemeCocoa::WidgetIsContainer(uint8_t aWidgetType) +nsNativeThemeCocoa::WidgetIsContainer(WidgetType aWidgetType) { // flesh this out at some point switch (aWidgetType) { - case NS_THEME_MENULIST_BUTTON: - case NS_THEME_RADIO: - case NS_THEME_CHECKBOX: - case NS_THEME_PROGRESSBAR: - case NS_THEME_METERBAR: - case NS_THEME_RANGE: - case NS_THEME_MAC_HELP_BUTTON: - case NS_THEME_MAC_DISCLOSURE_BUTTON_OPEN: - case NS_THEME_MAC_DISCLOSURE_BUTTON_CLOSED: + case StyleAppearance::MenulistButton: + case StyleAppearance::Radio: + case StyleAppearance::Checkbox: + case StyleAppearance::Progressbar: + case StyleAppearance::Meterbar: + case StyleAppearance::Range: + case StyleAppearance::MozMacHelpButton: + case StyleAppearance::MozMacDisclosureButtonOpen: + case StyleAppearance::MozMacDisclosureButtonClosed: return false; + default: + break; } return true; } bool -nsNativeThemeCocoa::ThemeDrawsFocusForWidget(uint8_t aWidgetType) +nsNativeThemeCocoa::ThemeDrawsFocusForWidget(WidgetType aWidgetType) { - if (aWidgetType == NS_THEME_MENULIST || - aWidgetType == NS_THEME_MENULIST_TEXTFIELD || - aWidgetType == NS_THEME_BUTTON || - aWidgetType == NS_THEME_MAC_HELP_BUTTON || - aWidgetType == NS_THEME_MAC_DISCLOSURE_BUTTON_OPEN || - aWidgetType == NS_THEME_MAC_DISCLOSURE_BUTTON_CLOSED || - aWidgetType == NS_THEME_RADIO || - aWidgetType == NS_THEME_RANGE || - aWidgetType == NS_THEME_CHECKBOX) + if (aWidgetType == StyleAppearance::Menulist || + aWidgetType == StyleAppearance::MenulistTextfield || + aWidgetType == StyleAppearance::Button || + aWidgetType == StyleAppearance::MozMacHelpButton || + aWidgetType == StyleAppearance::MozMacDisclosureButtonOpen || + aWidgetType == StyleAppearance::MozMacDisclosureButtonClosed || + aWidgetType == StyleAppearance::Radio || + aWidgetType == StyleAppearance::Range || + aWidgetType == StyleAppearance::Checkbox) return true; return false; } bool nsNativeThemeCocoa::ThemeNeedsComboboxDropmarker() { return false; } bool -nsNativeThemeCocoa::WidgetAppearanceDependsOnWindowFocus(uint8_t aWidgetType) +nsNativeThemeCocoa::WidgetAppearanceDependsOnWindowFocus(WidgetType aWidgetType) { switch (aWidgetType) { - case NS_THEME_DIALOG: - case NS_THEME_GROUPBOX: - case NS_THEME_TABPANELS: - case NS_THEME_BUTTON_ARROW_UP: - case NS_THEME_BUTTON_ARROW_DOWN: - case NS_THEME_CHECKMENUITEM: - case NS_THEME_MENUPOPUP: - case NS_THEME_MENUARROW: - case NS_THEME_MENUITEM: - case NS_THEME_MENUSEPARATOR: - case NS_THEME_TOOLTIP: - case NS_THEME_INNER_SPIN_BUTTON: - case NS_THEME_SPINNER: - case NS_THEME_SPINNER_UPBUTTON: - case NS_THEME_SPINNER_DOWNBUTTON: - case NS_THEME_SEPARATOR: - case NS_THEME_TOOLBOX: - case NS_THEME_NUMBER_INPUT: - case NS_THEME_TEXTFIELD: - case NS_THEME_TREEVIEW: - case NS_THEME_TREELINE: - case NS_THEME_TEXTFIELD_MULTILINE: - case NS_THEME_LISTBOX: - case NS_THEME_RESIZER: + case StyleAppearance::Dialog: + case StyleAppearance::Groupbox: + case StyleAppearance::Tabpanels: + case StyleAppearance::ButtonArrowUp: + case StyleAppearance::ButtonArrowDown: + case StyleAppearance::Checkmenuitem: + case StyleAppearance::Menupopup: + case StyleAppearance::Menuarrow: + case StyleAppearance::Menuitem: + case StyleAppearance::Menuseparator: + case StyleAppearance::Tooltip: + case StyleAppearance::InnerSpinButton: + case StyleAppearance::Spinner: + case StyleAppearance::SpinnerUpbutton: + case StyleAppearance::SpinnerDownbutton: + case StyleAppearance::Separator: + case StyleAppearance::Toolbox: + case StyleAppearance::NumberInput: + case StyleAppearance::Textfield: + case StyleAppearance::Treeview: + case StyleAppearance::Treeline: + case StyleAppearance::TextfieldMultiline: + case StyleAppearance::Listbox: + case StyleAppearance::Resizer: return false; default: return true; } } bool nsNativeThemeCocoa::IsWindowSheet(nsIFrame* aFrame) @@ -4819,110 +4836,110 @@ nsNativeThemeCocoa::IsWindowSheet(nsIFra if (!widget) { return false; } return (widget->WindowType() == eWindowType_sheet); } bool nsNativeThemeCocoa::NeedToClearBackgroundBehindWidget(nsIFrame* aFrame, - uint8_t aWidgetType) + WidgetType aWidgetType) { switch (aWidgetType) { - case NS_THEME_MAC_SOURCE_LIST: + case StyleAppearance::MozMacSourceList: // If we're in a XUL tree, we don't want to clear the background behind the // selections below, since that would make our source list to not pick up // the right font smoothing background. But since we don't call this method // in nsTreeBodyFrame::BuildDisplayList, we never get here. - case NS_THEME_MAC_SOURCE_LIST_SELECTION: - case NS_THEME_MAC_ACTIVE_SOURCE_LIST_SELECTION: - case NS_THEME_MAC_VIBRANCY_LIGHT: - case NS_THEME_MAC_VIBRANCY_DARK: - case NS_THEME_MAC_VIBRANT_TITLEBAR_LIGHT: - case NS_THEME_MAC_VIBRANT_TITLEBAR_DARK: - case NS_THEME_TOOLTIP: - case NS_THEME_MENUPOPUP: - case NS_THEME_MENUITEM: - case NS_THEME_CHECKMENUITEM: + case StyleAppearance::MozMacSourceListSelection: + case StyleAppearance::MozMacActiveSourceListSelection: + case StyleAppearance::MozMacVibrancyLight: + case StyleAppearance::MozMacVibrancyDark: + case StyleAppearance::MozMacVibrantTitlebarLight: + case StyleAppearance::MozMacVibrantTitlebarDark: + case StyleAppearance::Tooltip: + case StyleAppearance::Menupopup: + case StyleAppearance::Menuitem: + case StyleAppearance::Checkmenuitem: return true; - case NS_THEME_DIALOG: + case StyleAppearance::Dialog: return IsWindowSheet(aFrame); default: return false; } } nsITheme::ThemeGeometryType -nsNativeThemeCocoa::ThemeGeometryTypeForWidget(nsIFrame* aFrame, uint8_t aWidgetType) +nsNativeThemeCocoa::ThemeGeometryTypeForWidget(nsIFrame* aFrame, WidgetType aWidgetType) { switch (aWidgetType) { - case NS_THEME_WINDOW_TITLEBAR: + case StyleAppearance::MozWindowTitlebar: return eThemeGeometryTypeTitlebar; - case NS_THEME_TOOLBAR: + case StyleAppearance::Toolbar: return eThemeGeometryTypeToolbar; - case NS_THEME_TOOLBOX: + case StyleAppearance::Toolbox: return eThemeGeometryTypeToolbox; - case NS_THEME_WINDOW_BUTTON_BOX: + case StyleAppearance::MozWindowButtonBox: return eThemeGeometryTypeWindowButtons; - case NS_THEME_MAC_FULLSCREEN_BUTTON: + case StyleAppearance::MozMacFullscreenButton: return eThemeGeometryTypeFullscreenButton; - case NS_THEME_MAC_VIBRANCY_LIGHT: + case StyleAppearance::MozMacVibrancyLight: return eThemeGeometryTypeVibrancyLight; - case NS_THEME_MAC_VIBRANCY_DARK: + case StyleAppearance::MozMacVibrancyDark: return eThemeGeometryTypeVibrancyDark; - case NS_THEME_MAC_VIBRANT_TITLEBAR_LIGHT: + case StyleAppearance::MozMacVibrantTitlebarLight: return eThemeGeometryTypeVibrantTitlebarLight; - case NS_THEME_MAC_VIBRANT_TITLEBAR_DARK: + case StyleAppearance::MozMacVibrantTitlebarDark: return eThemeGeometryTypeVibrantTitlebarDark; - case NS_THEME_TOOLTIP: + case StyleAppearance::Tooltip: return eThemeGeometryTypeTooltip; - case NS_THEME_MENUPOPUP: + case StyleAppearance::Menupopup: return eThemeGeometryTypeMenu; - case NS_THEME_MENUITEM: - case NS_THEME_CHECKMENUITEM: { + case StyleAppearance::Menuitem: + case StyleAppearance::Checkmenuitem: { EventStates eventState = GetContentState(aFrame, aWidgetType); bool isDisabled = IsDisabled(aFrame, eventState); bool isSelected = !isDisabled && CheckBooleanAttr(aFrame, nsGkAtoms::menuactive); return isSelected ? eThemeGeometryTypeHighlightedMenuItem : eThemeGeometryTypeMenu; } - case NS_THEME_DIALOG: + case StyleAppearance::Dialog: return IsWindowSheet(aFrame) ? eThemeGeometryTypeSheet : eThemeGeometryTypeUnknown; - case NS_THEME_MAC_SOURCE_LIST: + case StyleAppearance::MozMacSourceList: return eThemeGeometryTypeSourceList; - case NS_THEME_MAC_SOURCE_LIST_SELECTION: + case StyleAppearance::MozMacSourceListSelection: return IsInSourceList(aFrame) ? eThemeGeometryTypeSourceListSelection : eThemeGeometryTypeUnknown; - case NS_THEME_MAC_ACTIVE_SOURCE_LIST_SELECTION: + case StyleAppearance::MozMacActiveSourceListSelection: return IsInSourceList(aFrame) ? eThemeGeometryTypeActiveSourceListSelection : eThemeGeometryTypeUnknown; default: return eThemeGeometryTypeUnknown; } } nsITheme::Transparency -nsNativeThemeCocoa::GetWidgetTransparency(nsIFrame* aFrame, uint8_t aWidgetType) +nsNativeThemeCocoa::GetWidgetTransparency(nsIFrame* aFrame, WidgetType aWidgetType) { switch (aWidgetType) { - case NS_THEME_MENUPOPUP: - case NS_THEME_TOOLTIP: + case StyleAppearance::Menupopup: + case StyleAppearance::Tooltip: return eTransparent; - case NS_THEME_DIALOG: + case StyleAppearance::Dialog: return IsWindowSheet(aFrame) ? eTransparent : eOpaque; - case NS_THEME_SCROLLBAR_SMALL: - case NS_THEME_SCROLLBAR: - case NS_THEME_SCROLLCORNER: + case StyleAppearance::ScrollbarSmall: + case StyleAppearance::Scrollbar: + case StyleAppearance::Scrollcorner: return nsLookAndFeel::UseOverlayScrollbars() ? eTransparent : eOpaque; - case NS_THEME_STATUSBAR: + case StyleAppearance::Statusbar: // Knowing that scrollbars and statusbars are opaque improves // performance, because we create layers for them. return eOpaque; - case NS_THEME_TOOLBAR: + case StyleAppearance::Toolbar: return eOpaque; default: return eUnknownTransparency; } }
--- a/widget/gtk/gtk3drawing.cpp +++ b/widget/gtk/gtk3drawing.cpp @@ -1236,17 +1236,17 @@ moz_gtk_vpaned_paint(cairo_t *cr, GdkRec // See gtk_entry_draw() for reference. static gint moz_gtk_entry_paint(cairo_t *cr, GdkRectangle* rect, GtkWidgetState* state, GtkStyleContext* style) { gint x = rect->x, y = rect->y, width = rect->width, height = rect->height; - int draw_focus_outline_only = state->depressed; // NS_THEME_FOCUS_OUTLINE + int draw_focus_outline_only = state->depressed; // StyleAppearance::FocusOutline if (draw_focus_outline_only) { // Inflate the given 'rect' with the focus outline size. gint h, v; moz_gtk_get_focus_outline_size(style, &h, &v); rect->x -= h; rect->width += 2 * h; rect->y -= v;
--- a/widget/gtk/nsNativeThemeGTK.cpp +++ b/widget/gtk/nsNativeThemeGTK.cpp @@ -1,15 +1,15 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsNativeThemeGTK.h" -#include "nsThemeConstants.h" +#include "nsStyleConsts.h" #include "gtkdrawing.h" #include "ScreenHelperGTK.h" #include "gfx2DGlue.h" #include "nsIObserverService.h" #include "nsIServiceManager.h" #include "nsIFrame.h" #include "nsIPresShell.h" @@ -145,51 +145,53 @@ nsNativeThemeGTK::RefreshWidgetWindow(ns static bool IsFrameContentNodeInNamespace(nsIFrame *aFrame, uint32_t aNamespace) { nsIContent *content = aFrame ? aFrame->GetContent() : nullptr; if (!content) return false; return content->IsInNamespace(aNamespace); } -static bool IsWidgetTypeDisabled(uint8_t* aDisabledVector, uint8_t aWidgetType) { - MOZ_ASSERT(aWidgetType < ThemeWidgetType_COUNT); - return (aDisabledVector[aWidgetType >> 3] & (1 << (aWidgetType & 7))) != 0; +static bool IsWidgetTypeDisabled(uint8_t* aDisabledVector, StyleAppearance aWidgetType) { + auto type = static_cast<size_t>(aWidgetType); + MOZ_ASSERT(type < static_cast<size_t>(mozilla::StyleAppearance::Count)); + return (aDisabledVector[type >> 3] & (1 << (type & 7))) != 0; } -static void SetWidgetTypeDisabled(uint8_t* aDisabledVector, uint8_t aWidgetType) { - MOZ_ASSERT(aWidgetType < ThemeWidgetType_COUNT); - aDisabledVector[aWidgetType >> 3] |= (1 << (aWidgetType & 7)); +static void SetWidgetTypeDisabled(uint8_t* aDisabledVector, StyleAppearance aWidgetType) { + auto type = static_cast<size_t>(aWidgetType); + MOZ_ASSERT(type < static_cast<size_t>(mozilla::StyleAppearance::Count)); + aDisabledVector[type >> 3] |= (1 << (type & 7)); } static inline uint16_t -GetWidgetStateKey(uint8_t aWidgetType, GtkWidgetState *aWidgetState) +GetWidgetStateKey(StyleAppearance aWidgetType, GtkWidgetState *aWidgetState) { return (aWidgetState->active | aWidgetState->focused << 1 | aWidgetState->inHover << 2 | aWidgetState->disabled << 3 | aWidgetState->isDefault << 4 | - aWidgetType << 5); + static_cast<uint16_t>(aWidgetType) << 5); } static bool IsWidgetStateSafe(uint8_t* aSafeVector, - uint8_t aWidgetType, - GtkWidgetState *aWidgetState) + StyleAppearance aWidgetType, + GtkWidgetState *aWidgetState) { - MOZ_ASSERT(aWidgetType < ThemeWidgetType_COUNT); + MOZ_ASSERT(static_cast<size_t>(aWidgetType) < static_cast<size_t>(mozilla::StyleAppearance::Count)); uint16_t key = GetWidgetStateKey(aWidgetType, aWidgetState); return (aSafeVector[key >> 3] & (1 << (key & 7))) != 0; } static void SetWidgetStateSafe(uint8_t *aSafeVector, - uint8_t aWidgetType, + StyleAppearance aWidgetType, GtkWidgetState *aWidgetState) { - MOZ_ASSERT(aWidgetType < ThemeWidgetType_COUNT); + MOZ_ASSERT(static_cast<size_t>(aWidgetType) < static_cast<size_t>(mozilla::StyleAppearance::Count)); uint16_t key = GetWidgetStateKey(aWidgetType, aWidgetState); aSafeVector[key >> 3] |= (1 << (key & 7)); } /* static */ GtkTextDirection nsNativeThemeGTK::GetTextDirection(nsIFrame* aFrame) { // IsFrameRTL() treats vertical-rl modes as right-to-left (in addition to @@ -209,155 +211,155 @@ nsNativeThemeGTK::GetTabMarginPixels(nsI : aFrame->GetUsedMargin().bottom; return std::min<gint>(MOZ_GTK_TAB_MARGIN_MASK, std::max(0, aFrame->PresContext()->AppUnitsToDevPixels(-margin))); } static bool ShouldScrollbarButtonBeDisabled(int32_t aCurpos, int32_t aMaxpos, - uint8_t aWidgetType) + StyleAppearance aWidgetType) { - return ((aCurpos == 0 && (aWidgetType == NS_THEME_SCROLLBARBUTTON_UP || - aWidgetType == NS_THEME_SCROLLBARBUTTON_LEFT)) - || (aCurpos == aMaxpos && (aWidgetType == NS_THEME_SCROLLBARBUTTON_DOWN || - aWidgetType == NS_THEME_SCROLLBARBUTTON_RIGHT))); + return ((aCurpos == 0 && (aWidgetType == StyleAppearance::ScrollbarbuttonUp || + aWidgetType == StyleAppearance::ScrollbarbuttonLeft)) + || (aCurpos == aMaxpos && (aWidgetType == StyleAppearance::ScrollbarbuttonDown || + aWidgetType == StyleAppearance::ScrollbarbuttonRight))); } bool -nsNativeThemeGTK::GetGtkWidgetAndState(uint8_t aWidgetType, nsIFrame* aFrame, +nsNativeThemeGTK::GetGtkWidgetAndState(StyleAppearance aWidgetType, nsIFrame* aFrame, WidgetNodeType& aGtkWidgetType, GtkWidgetState* aState, gint* aWidgetFlags) { if (aState) { // For XUL checkboxes and radio buttons, the state of the parent // determines our state. nsIFrame *stateFrame = aFrame; - if (aFrame && ((aWidgetFlags && (aWidgetType == NS_THEME_CHECKBOX || - aWidgetType == NS_THEME_RADIO)) || - aWidgetType == NS_THEME_CHECKBOX_LABEL || - aWidgetType == NS_THEME_RADIO_LABEL)) { + if (aFrame && ((aWidgetFlags && (aWidgetType == StyleAppearance::Checkbox || + aWidgetType == StyleAppearance::Radio)) || + aWidgetType == StyleAppearance::CheckboxLabel || + aWidgetType == StyleAppearance::RadioLabel)) { nsAtom* atom = nullptr; if (IsFrameContentNodeInNamespace(aFrame, kNameSpaceID_XUL)) { - if (aWidgetType == NS_THEME_CHECKBOX_LABEL || - aWidgetType == NS_THEME_RADIO_LABEL) { + if (aWidgetType == StyleAppearance::CheckboxLabel || + aWidgetType == StyleAppearance::RadioLabel) { // Adjust stateFrame so GetContentState finds the correct state. stateFrame = aFrame = aFrame->GetParent()->GetParent(); } else { // GetContentState knows to look one frame up for radio/checkbox // widgets, so don't adjust stateFrame here. aFrame = aFrame->GetParent(); } if (aWidgetFlags) { if (!atom) { - atom = (aWidgetType == NS_THEME_CHECKBOX || - aWidgetType == NS_THEME_CHECKBOX_LABEL) ? nsGkAtoms::checked + atom = (aWidgetType == StyleAppearance::Checkbox || + aWidgetType == StyleAppearance::CheckboxLabel) ? nsGkAtoms::checked : nsGkAtoms::selected; } *aWidgetFlags = CheckBooleanAttr(aFrame, atom); } } else { if (aWidgetFlags) { *aWidgetFlags = 0; HTMLInputElement* inputElt = HTMLInputElement::FromNode(aFrame->GetContent()); if (inputElt && inputElt->Checked()) *aWidgetFlags |= MOZ_GTK_WIDGET_CHECKED; if (GetIndeterminate(aFrame)) *aWidgetFlags |= MOZ_GTK_WIDGET_INCONSISTENT; } } - } else if (aWidgetType == NS_THEME_TOOLBARBUTTON_DROPDOWN || - aWidgetType == NS_THEME_TREEHEADERSORTARROW || - aWidgetType == NS_THEME_BUTTON_ARROW_PREVIOUS || - aWidgetType == NS_THEME_BUTTON_ARROW_NEXT || - aWidgetType == NS_THEME_BUTTON_ARROW_UP || - aWidgetType == NS_THEME_BUTTON_ARROW_DOWN) { + } else if (aWidgetType == StyleAppearance::ToolbarbuttonDropdown || + aWidgetType == StyleAppearance::Treeheadersortarrow || + aWidgetType == StyleAppearance::ButtonArrowPrevious || + aWidgetType == StyleAppearance::ButtonArrowNext || + aWidgetType == StyleAppearance::ButtonArrowUp || + aWidgetType == StyleAppearance::ButtonArrowDown) { // The state of an arrow comes from its parent. stateFrame = aFrame = aFrame->GetParent(); } EventStates eventState = GetContentState(stateFrame, aWidgetType); aState->disabled = IsDisabled(aFrame, eventState) || IsReadOnly(aFrame); aState->active = eventState.HasState(NS_EVENT_STATE_ACTIVE); aState->focused = eventState.HasState(NS_EVENT_STATE_FOCUS); aState->selected = FALSE; aState->inHover = eventState.HasState(NS_EVENT_STATE_HOVER); aState->isDefault = IsDefaultButton(aFrame); aState->canDefault = FALSE; // XXX fix me aState->depressed = FALSE; - if (aWidgetType == NS_THEME_FOCUS_OUTLINE) { + if (aWidgetType == StyleAppearance::FocusOutline) { aState->disabled = FALSE; aState->active = FALSE; aState->inHover = FALSE; aState->isDefault = FALSE; aState->canDefault = FALSE; aState->focused = TRUE; aState->depressed = TRUE; // see moz_gtk_entry_paint() - } else if (aWidgetType == NS_THEME_BUTTON || - aWidgetType == NS_THEME_TOOLBARBUTTON || - aWidgetType == NS_THEME_DUALBUTTON || - aWidgetType == NS_THEME_TOOLBARBUTTON_DROPDOWN || - aWidgetType == NS_THEME_MENULIST || - aWidgetType == NS_THEME_MENULIST_BUTTON) { + } else if (aWidgetType == StyleAppearance::Button || + aWidgetType == StyleAppearance::Toolbarbutton || + aWidgetType == StyleAppearance::Dualbutton || + aWidgetType == StyleAppearance::ToolbarbuttonDropdown || + aWidgetType == StyleAppearance::Menulist || + aWidgetType == StyleAppearance::MenulistButton) { aState->active &= aState->inHover; - } else if (aWidgetType == NS_THEME_TREETWISTY || - aWidgetType == NS_THEME_TREETWISTYOPEN) { + } else if (aWidgetType == StyleAppearance::Treetwisty || + aWidgetType == StyleAppearance::Treetwistyopen) { nsTreeBodyFrame *treeBodyFrame = do_QueryFrame(aFrame); if (treeBodyFrame) { const mozilla::AtomArray& atoms = treeBodyFrame->GetPropertyArrayForCurrentDrawingItem(); aState->selected = atoms.Contains(nsGkAtoms::selected); aState->inHover = atoms.Contains(nsGkAtoms::hover); } } if (IsFrameContentNodeInNamespace(aFrame, kNameSpaceID_XUL)) { // For these widget types, some element (either a child or parent) // actually has element focus, so we check the focused attribute // to see whether to draw in the focused state. - if (aWidgetType == NS_THEME_NUMBER_INPUT || - aWidgetType == NS_THEME_TEXTFIELD || - aWidgetType == NS_THEME_TEXTFIELD_MULTILINE || - aWidgetType == NS_THEME_MENULIST_TEXTFIELD || - aWidgetType == NS_THEME_SPINNER_TEXTFIELD || - aWidgetType == NS_THEME_RADIO_CONTAINER || - aWidgetType == NS_THEME_RADIO_LABEL) { + if (aWidgetType == StyleAppearance::NumberInput || + aWidgetType == StyleAppearance::Textfield || + aWidgetType == StyleAppearance::TextfieldMultiline || + aWidgetType == StyleAppearance::MenulistTextfield || + aWidgetType == StyleAppearance::SpinnerTextfield || + aWidgetType == StyleAppearance::RadioContainer || + aWidgetType == StyleAppearance::RadioLabel) { aState->focused = IsFocused(aFrame); - } else if (aWidgetType == NS_THEME_RADIO || - aWidgetType == NS_THEME_CHECKBOX) { + } else if (aWidgetType == StyleAppearance::Radio || + aWidgetType == StyleAppearance::Checkbox) { // In XUL, checkboxes and radios shouldn't have focus rings, their labels do aState->focused = FALSE; } - if (aWidgetType == NS_THEME_SCROLLBARTHUMB_VERTICAL || - aWidgetType == NS_THEME_SCROLLBARTHUMB_HORIZONTAL) { + if (aWidgetType == StyleAppearance::ScrollbarthumbVertical || + aWidgetType == StyleAppearance::ScrollbarthumbHorizontal) { // for scrollbars we need to go up two to go from the thumb to // the slider to the actual scrollbar object nsIFrame *tmpFrame = aFrame->GetParent()->GetParent(); aState->curpos = CheckIntAttr(tmpFrame, nsGkAtoms::curpos, 0); aState->maxpos = CheckIntAttr(tmpFrame, nsGkAtoms::maxpos, 100); if (CheckBooleanAttr(aFrame, nsGkAtoms::active)) { aState->active = TRUE; // Set hover state to emulate Gtk style of active scrollbar thumb aState->inHover = TRUE; } } - if (aWidgetType == NS_THEME_SCROLLBARBUTTON_UP || - aWidgetType == NS_THEME_SCROLLBARBUTTON_DOWN || - aWidgetType == NS_THEME_SCROLLBARBUTTON_LEFT || - aWidgetType == NS_THEME_SCROLLBARBUTTON_RIGHT) { + if (aWidgetType == StyleAppearance::ScrollbarbuttonUp || + aWidgetType == StyleAppearance::ScrollbarbuttonDown || + aWidgetType == StyleAppearance::ScrollbarbuttonLeft || + aWidgetType == StyleAppearance::ScrollbarbuttonRight) { // set the state to disabled when the scrollbar is scrolled to // the beginning or the end, depending on the button type. int32_t curpos = CheckIntAttr(aFrame, nsGkAtoms::curpos, 0); int32_t maxpos = CheckIntAttr(aFrame, nsGkAtoms::maxpos, 100); if (ShouldScrollbarButtonBeDisabled(curpos, maxpos, aWidgetType)) { aState->disabled = true; } @@ -365,226 +367,227 @@ nsNativeThemeGTK::GetGtkWidgetAndState(u // we set the active attribute on the element to true if it's // pressed with any mouse button. // This allows us to show that it's active without setting :active else if (CheckBooleanAttr(aFrame, nsGkAtoms::active)) aState->active = true; if (aWidgetFlags) { *aWidgetFlags = GetScrollbarButtonType(aFrame); - if (aWidgetType - NS_THEME_SCROLLBARBUTTON_UP < 2) + if (static_cast<uint8_t>(aWidgetType) - + static_cast<uint8_t>(StyleAppearance::ScrollbarbuttonUp) < 2) *aWidgetFlags |= MOZ_GTK_STEPPER_VERTICAL; } } // menu item state is determined by the attribute "_moz-menuactive", // and not by the mouse hovering (accessibility). as a special case, // menus which are children of a menu bar are only marked as prelight // if they are open, not on normal hover. - if (aWidgetType == NS_THEME_MENUITEM || - aWidgetType == NS_THEME_CHECKMENUITEM || - aWidgetType == NS_THEME_RADIOMENUITEM || - aWidgetType == NS_THEME_MENUSEPARATOR || - aWidgetType == NS_THEME_MENUARROW) { + if (aWidgetType == StyleAppearance::Menuitem || + aWidgetType == StyleAppearance::Checkmenuitem || + aWidgetType == StyleAppearance::Radiomenuitem || + aWidgetType == StyleAppearance::Menuseparator || + aWidgetType == StyleAppearance::Menuarrow) { bool isTopLevel = false; nsMenuFrame *menuFrame = do_QueryFrame(aFrame); if (menuFrame) { isTopLevel = menuFrame->IsOnMenuBar(); } if (isTopLevel) { aState->inHover = menuFrame->IsOpen(); } else { aState->inHover = CheckBooleanAttr(aFrame, nsGkAtoms::menuactive); } aState->active = FALSE; - if (aWidgetType == NS_THEME_CHECKMENUITEM || - aWidgetType == NS_THEME_RADIOMENUITEM) { + if (aWidgetType == StyleAppearance::Checkmenuitem || + aWidgetType == StyleAppearance::Radiomenuitem) { *aWidgetFlags = 0; if (aFrame && aFrame->GetContent() && aFrame->GetContent()->IsElement()) { *aWidgetFlags = aFrame->GetContent()->AsElement()-> AttrValueIs(kNameSpaceID_None, nsGkAtoms::checked, nsGkAtoms::_true, eIgnoreCase); } } } // A button with drop down menu open or an activated toggle button // should always appear depressed. - if (aWidgetType == NS_THEME_BUTTON || - aWidgetType == NS_THEME_TOOLBARBUTTON || - aWidgetType == NS_THEME_DUALBUTTON || - aWidgetType == NS_THEME_TOOLBARBUTTON_DROPDOWN || - aWidgetType == NS_THEME_MENULIST || - aWidgetType == NS_THEME_MENULIST_BUTTON) { + if (aWidgetType == StyleAppearance::Button || + aWidgetType == StyleAppearance::Toolbarbutton || + aWidgetType == StyleAppearance::Dualbutton || + aWidgetType == StyleAppearance::ToolbarbuttonDropdown || + aWidgetType == StyleAppearance::Menulist || + aWidgetType == StyleAppearance::MenulistButton) { bool menuOpen = IsOpenButton(aFrame); aState->depressed = IsCheckedButton(aFrame) || menuOpen; // we must not highlight buttons with open drop down menus on hover. aState->inHover = aState->inHover && !menuOpen; } // When the input field of the drop down button has focus, some themes // should draw focus for the drop down button as well. - if (aWidgetType == NS_THEME_MENULIST_BUTTON && aWidgetFlags) { + if (aWidgetType == StyleAppearance::MenulistButton && aWidgetFlags) { *aWidgetFlags = CheckBooleanAttr(aFrame, nsGkAtoms::parentfocused); } } } switch (aWidgetType) { - case NS_THEME_BUTTON: + case StyleAppearance::Button: if (aWidgetFlags) *aWidgetFlags = GTK_RELIEF_NORMAL; aGtkWidgetType = MOZ_GTK_BUTTON; break; - case NS_THEME_TOOLBARBUTTON: - case NS_THEME_DUALBUTTON: + case StyleAppearance::Toolbarbutton: + case StyleAppearance::Dualbutton: if (aWidgetFlags) *aWidgetFlags = GTK_RELIEF_NONE; aGtkWidgetType = MOZ_GTK_TOOLBAR_BUTTON; break; - case NS_THEME_FOCUS_OUTLINE: + case StyleAppearance::FocusOutline: aGtkWidgetType = MOZ_GTK_ENTRY; break; - case NS_THEME_CHECKBOX: - case NS_THEME_RADIO: - aGtkWidgetType = (aWidgetType == NS_THEME_RADIO) ? MOZ_GTK_RADIOBUTTON : MOZ_GTK_CHECKBUTTON; + case StyleAppearance::Checkbox: + case StyleAppearance::Radio: + aGtkWidgetType = (aWidgetType == StyleAppearance::Radio) ? MOZ_GTK_RADIOBUTTON : MOZ_GTK_CHECKBUTTON; break; - case NS_THEME_SCROLLBARBUTTON_UP: - case NS_THEME_SCROLLBARBUTTON_DOWN: - case NS_THEME_SCROLLBARBUTTON_LEFT: - case NS_THEME_SCROLLBARBUTTON_RIGHT: + case StyleAppearance::ScrollbarbuttonUp: + case StyleAppearance::ScrollbarbuttonDown: + case StyleAppearance::ScrollbarbuttonLeft: + case StyleAppearance::ScrollbarbuttonRight: aGtkWidgetType = MOZ_GTK_SCROLLBAR_BUTTON; break; - case NS_THEME_SCROLLBAR_VERTICAL: + case StyleAppearance::ScrollbarVertical: aGtkWidgetType = MOZ_GTK_SCROLLBAR_VERTICAL; if (GetWidgetTransparency(aFrame, aWidgetType) == eOpaque) *aWidgetFlags = MOZ_GTK_TRACK_OPAQUE; else *aWidgetFlags = 0; break; - case NS_THEME_SCROLLBAR_HORIZONTAL: + case StyleAppearance::ScrollbarHorizontal: aGtkWidgetType = MOZ_GTK_SCROLLBAR_HORIZONTAL; if (GetWidgetTransparency(aFrame, aWidgetType) == eOpaque) *aWidgetFlags = MOZ_GTK_TRACK_OPAQUE; else *aWidgetFlags = 0; break; - case NS_THEME_SCROLLBARTRACK_HORIZONTAL: + case StyleAppearance::ScrollbartrackHorizontal: aGtkWidgetType = MOZ_GTK_SCROLLBAR_TROUGH_HORIZONTAL; break; - case NS_THEME_SCROLLBARTRACK_VERTICAL: + case StyleAppearance::ScrollbartrackVertical: aGtkWidgetType = MOZ_GTK_SCROLLBAR_TROUGH_VERTICAL; break; - case NS_THEME_SCROLLBARTHUMB_VERTICAL: + case StyleAppearance::ScrollbarthumbVertical: aGtkWidgetType = MOZ_GTK_SCROLLBAR_THUMB_VERTICAL; break; - case NS_THEME_SCROLLBARTHUMB_HORIZONTAL: + case StyleAppearance::ScrollbarthumbHorizontal: aGtkWidgetType = MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL; break; - case NS_THEME_INNER_SPIN_BUTTON: + case StyleAppearance::InnerSpinButton: aGtkWidgetType = MOZ_GTK_INNER_SPIN_BUTTON; break; - case NS_THEME_SPINNER: + case StyleAppearance::Spinner: aGtkWidgetType = MOZ_GTK_SPINBUTTON; break; - case NS_THEME_SPINNER_UPBUTTON: + case StyleAppearance::SpinnerUpbutton: aGtkWidgetType = MOZ_GTK_SPINBUTTON_UP; break; - case NS_THEME_SPINNER_DOWNBUTTON: + case StyleAppearance::SpinnerDownbutton: aGtkWidgetType = MOZ_GTK_SPINBUTTON_DOWN; break; - case NS_THEME_SPINNER_TEXTFIELD: + case StyleAppearance::SpinnerTextfield: aGtkWidgetType = MOZ_GTK_SPINBUTTON_ENTRY; break; - case NS_THEME_RANGE: + case StyleAppearance::Range: { if (IsRangeHorizontal(aFrame)) { if (aWidgetFlags) *aWidgetFlags = GTK_ORIENTATION_HORIZONTAL; aGtkWidgetType = MOZ_GTK_SCALE_HORIZONTAL; } else { if (aWidgetFlags) *aWidgetFlags = GTK_ORIENTATION_VERTICAL; aGtkWidgetType = MOZ_GTK_SCALE_VERTICAL; } break; } - case NS_THEME_RANGE_THUMB: + case StyleAppearance::RangeThumb: { if (IsRangeHorizontal(aFrame)) { if (aWidgetFlags) *aWidgetFlags = GTK_ORIENTATION_HORIZONTAL; aGtkWidgetType = MOZ_GTK_SCALE_THUMB_HORIZONTAL; } else { if (aWidgetFlags) *aWidgetFlags = GTK_ORIENTATION_VERTICAL; aGtkWidgetType = MOZ_GTK_SCALE_THUMB_VERTICAL; } break; } - case NS_THEME_SCALE_HORIZONTAL: + case StyleAppearance::ScaleHorizontal: if (aWidgetFlags) *aWidgetFlags = GTK_ORIENTATION_HORIZONTAL; aGtkWidgetType = MOZ_GTK_SCALE_HORIZONTAL; break; - case NS_THEME_SCALETHUMB_HORIZONTAL: + case StyleAppearance::ScalethumbHorizontal: if (aWidgetFlags) *aWidgetFlags = GTK_ORIENTATION_HORIZONTAL; aGtkWidgetType = MOZ_GTK_SCALE_THUMB_HORIZONTAL; break; - case NS_THEME_SCALE_VERTICAL: + case StyleAppearance::ScaleVertical: if (aWidgetFlags) *aWidgetFlags = GTK_ORIENTATION_VERTICAL; aGtkWidgetType = MOZ_GTK_SCALE_VERTICAL; break; - case NS_THEME_SEPARATOR: + case StyleAppearance::Separator: aGtkWidgetType = MOZ_GTK_TOOLBAR_SEPARATOR; break; - case NS_THEME_SCALETHUMB_VERTICAL: + case StyleAppearance::ScalethumbVertical: if (aWidgetFlags) *aWidgetFlags = GTK_ORIENTATION_VERTICAL; aGtkWidgetType = MOZ_GTK_SCALE_THUMB_VERTICAL; break; - case NS_THEME_TOOLBARGRIPPER: + case StyleAppearance::Toolbargripper: aGtkWidgetType = MOZ_GTK_GRIPPER; break; - case NS_THEME_RESIZER: + case StyleAppearance::Resizer: aGtkWidgetType = MOZ_GTK_RESIZER; break; - case NS_THEME_NUMBER_INPUT: - case NS_THEME_TEXTFIELD: + case StyleAppearance::NumberInput: + case StyleAppearance::Textfield: aGtkWidgetType = MOZ_GTK_ENTRY; break; - case NS_THEME_TEXTFIELD_MULTILINE: + case StyleAppearance::TextfieldMultiline: #ifdef MOZ_WIDGET_GTK aGtkWidgetType = MOZ_GTK_TEXT_VIEW; #else aGtkWidgetType = MOZ_GTK_ENTRY; #endif break; - case NS_THEME_LISTBOX: - case NS_THEME_TREEVIEW: + case StyleAppearance::Listbox: + case StyleAppearance::Treeview: aGtkWidgetType = MOZ_GTK_TREEVIEW; break; - case NS_THEME_TREEHEADERCELL: + case StyleAppearance::Treeheadercell: if (aWidgetFlags) { // In this case, the flag denotes whether the header is the sorted one or not if (GetTreeSortDirection(aFrame) == eTreeSortDirection_Natural) *aWidgetFlags = false; else *aWidgetFlags = true; } aGtkWidgetType = MOZ_GTK_TREE_HEADER_CELL; break; - case NS_THEME_TREEHEADERSORTARROW: + case StyleAppearance::Treeheadersortarrow: if (aWidgetFlags) { switch (GetTreeSortDirection(aFrame)) { case eTreeSortDirection_Ascending: *aWidgetFlags = GTK_ARROW_DOWN; break; case eTreeSortDirection_Descending: *aWidgetFlags = GTK_ARROW_UP; break; @@ -594,106 +597,106 @@ nsNativeThemeGTK::GetGtkWidgetAndState(u * and wider when switching sort direction off and on * */ *aWidgetFlags = GTK_ARROW_NONE; break; } } aGtkWidgetType = MOZ_GTK_TREE_HEADER_SORTARROW; break; - case NS_THEME_TREETWISTY: + case StyleAppearance::Treetwisty: aGtkWidgetType = MOZ_GTK_TREEVIEW_EXPANDER; if (aWidgetFlags) *aWidgetFlags = GTK_EXPANDER_COLLAPSED; break; - case NS_THEME_TREETWISTYOPEN: + case StyleAppearance::Treetwistyopen: aGtkWidgetType = MOZ_GTK_TREEVIEW_EXPANDER; if (aWidgetFlags) *aWidgetFlags = GTK_EXPANDER_EXPANDED; break; - case NS_THEME_MENULIST: + case StyleAppearance::Menulist: aGtkWidgetType = MOZ_GTK_DROPDOWN; if (aWidgetFlags) *aWidgetFlags = IsFrameContentNodeInNamespace(aFrame, kNameSpaceID_XHTML); break; - case NS_THEME_MENULIST_TEXT: + case StyleAppearance::MenulistText: return false; // nothing to do, but prevents the bg from being drawn - case NS_THEME_MENULIST_TEXTFIELD: + case StyleAppearance::MenulistTextfield: aGtkWidgetType = MOZ_GTK_DROPDOWN_ENTRY; break; - case NS_THEME_MENULIST_BUTTON: + case StyleAppearance::MenulistButton: aGtkWidgetType = MOZ_GTK_DROPDOWN_ARROW; break; - case NS_THEME_TOOLBARBUTTON_DROPDOWN: - case NS_THEME_BUTTON_ARROW_DOWN: - case NS_THEME_BUTTON_ARROW_UP: - case NS_THEME_BUTTON_ARROW_NEXT: - case NS_THEME_BUTTON_ARROW_PREVIOUS: + case StyleAppearance::ToolbarbuttonDropdown: + case StyleAppearance::ButtonArrowDown: + case StyleAppearance::ButtonArrowUp: + case StyleAppearance::ButtonArrowNext: + case StyleAppearance::ButtonArrowPrevious: aGtkWidgetType = MOZ_GTK_TOOLBARBUTTON_ARROW; if (aWidgetFlags) { *aWidgetFlags = GTK_ARROW_DOWN; - if (aWidgetType == NS_THEME_BUTTON_ARROW_UP) + if (aWidgetType == StyleAppearance::ButtonArrowUp) *aWidgetFlags = GTK_ARROW_UP; - else if (aWidgetType == NS_THEME_BUTTON_ARROW_NEXT) + else if (aWidgetType == StyleAppearance::ButtonArrowNext) *aWidgetFlags = GTK_ARROW_RIGHT; - else if (aWidgetType == NS_THEME_BUTTON_ARROW_PREVIOUS) + else if (aWidgetType == StyleAppearance::ButtonArrowPrevious) *aWidgetFlags = GTK_ARROW_LEFT; } break; - case NS_THEME_CHECKBOX_CONTAINER: + case StyleAppearance::CheckboxContainer: aGtkWidgetType = MOZ_GTK_CHECKBUTTON_CONTAINER; break; - case NS_THEME_RADIO_CONTAINER: + case StyleAppearance::RadioContainer: aGtkWidgetType = MOZ_GTK_RADIOBUTTON_CONTAINER; break; - case NS_THEME_CHECKBOX_LABEL: + case StyleAppearance::CheckboxLabel: aGtkWidgetType = MOZ_GTK_CHECKBUTTON_LABEL; break; - case NS_THEME_RADIO_LABEL: + case StyleAppearance::RadioLabel: aGtkWidgetType = MOZ_GTK_RADIOBUTTON_LABEL; break; - case NS_THEME_TOOLBAR: + case StyleAppearance::Toolbar: aGtkWidgetType = MOZ_GTK_TOOLBAR; break; - case NS_THEME_TOOLTIP: + case StyleAppearance::Tooltip: aGtkWidgetType = MOZ_GTK_TOOLTIP; break; - case NS_THEME_STATUSBARPANEL: - case NS_THEME_RESIZERPANEL: + case StyleAppearance::Statusbarpanel: + case StyleAppearance::Resizerpanel: aGtkWidgetType = MOZ_GTK_FRAME; break; - case NS_THEME_PROGRESSBAR: - case NS_THEME_PROGRESSBAR_VERTICAL: + case StyleAppearance::Progressbar: + case StyleAppearance::ProgressbarVertical: aGtkWidgetType = MOZ_GTK_PROGRESSBAR; break; - case NS_THEME_PROGRESSCHUNK: - case NS_THEME_PROGRESSCHUNK_VERTICAL: + case StyleAppearance::Progresschunk: + case StyleAppearance::ProgresschunkVertical: { nsIFrame* stateFrame = aFrame->GetParent(); EventStates eventStates = GetContentState(stateFrame, aWidgetType); aGtkWidgetType = IsIndeterminateProgress(stateFrame, eventStates) ? IsVerticalProgress(stateFrame) ? MOZ_GTK_PROGRESS_CHUNK_VERTICAL_INDETERMINATE : MOZ_GTK_PROGRESS_CHUNK_INDETERMINATE : MOZ_GTK_PROGRESS_CHUNK; } break; - case NS_THEME_TAB_SCROLL_ARROW_BACK: - case NS_THEME_TAB_SCROLL_ARROW_FORWARD: + case StyleAppearance::TabScrollArrowBack: + case StyleAppearance::TabScrollArrowForward: if (aWidgetFlags) - *aWidgetFlags = aWidgetType == NS_THEME_TAB_SCROLL_ARROW_BACK ? + *aWidgetFlags = aWidgetType == StyleAppearance::TabScrollArrowBack ? GTK_ARROW_LEFT : GTK_ARROW_RIGHT; aGtkWidgetType = MOZ_GTK_TAB_SCROLLARROW; break; - case NS_THEME_TABPANELS: + case StyleAppearance::Tabpanels: aGtkWidgetType = MOZ_GTK_TABPANELS; break; - case NS_THEME_TAB: + case StyleAppearance::Tab: { if (IsBottomTab(aFrame)) { aGtkWidgetType = MOZ_GTK_TAB_BOTTOM; } else { aGtkWidgetType = MOZ_GTK_TAB_TOP; } if (aWidgetFlags) { @@ -705,73 +708,73 @@ nsNativeThemeGTK::GetGtkWidgetAndState(u if (IsSelectedTab(aFrame)) *aWidgetFlags |= MOZ_GTK_TAB_SELECTED; if (IsFirstTab(aFrame)) *aWidgetFlags |= MOZ_GTK_TAB_FIRST; } } break; - case NS_THEME_SPLITTER: + case StyleAppearance::Splitter: if (IsHorizontal(aFrame)) aGtkWidgetType = MOZ_GTK_SPLITTER_VERTICAL; else aGtkWidgetType = MOZ_GTK_SPLITTER_HORIZONTAL; break; - case NS_THEME_MENUBAR: + case StyleAppearance::Menubar: aGtkWidgetType = MOZ_GTK_MENUBAR; break; - case NS_THEME_MENUPOPUP: + case StyleAppearance::Menupopup: aGtkWidgetType = MOZ_GTK_MENUPOPUP; break; - case NS_THEME_MENUITEM: + case StyleAppearance::Menuitem: { nsMenuFrame *menuFrame = do_QueryFrame(aFrame); if (menuFrame && menuFrame->IsOnMenuBar()) { aGtkWidgetType = MOZ_GTK_MENUBARITEM; break; } } aGtkWidgetType = MOZ_GTK_MENUITEM; break; - case NS_THEME_MENUSEPARATOR: + case StyleAppearance::Menuseparator: aGtkWidgetType = MOZ_GTK_MENUSEPARATOR; break; - case NS_THEME_MENUARROW: + case StyleAppearance::Menuarrow: aGtkWidgetType = MOZ_GTK_MENUARROW; break; - case NS_THEME_CHECKMENUITEM: + case StyleAppearance::Checkmenuitem: aGtkWidgetType = MOZ_GTK_CHECKMENUITEM; break; - case NS_THEME_RADIOMENUITEM: + case StyleAppearance::Radiomenuitem: aGtkWidgetType = MOZ_GTK_RADIOMENUITEM; break; - case NS_THEME_WINDOW: - case NS_THEME_DIALOG: + case StyleAppearance::Window: + case StyleAppearance::Dialog: aGtkWidgetType = MOZ_GTK_WINDOW; break; - case NS_THEME_GTK_INFO_BAR: + case StyleAppearance::MozGtkInfoBar: aGtkWidgetType = MOZ_GTK_INFO_BAR; break; - case NS_THEME_WINDOW_TITLEBAR: + case StyleAppearance::MozWindowTitlebar: aGtkWidgetType = MOZ_GTK_HEADER_BAR; break; - case NS_THEME_WINDOW_TITLEBAR_MAXIMIZED: + case StyleAppearance::MozWindowTitlebarMaximized: aGtkWidgetType = MOZ_GTK_HEADER_BAR_MAXIMIZED; break; - case NS_THEME_WINDOW_BUTTON_CLOSE: + case StyleAppearance::MozWindowButtonClose: aGtkWidgetType = MOZ_GTK_HEADER_BAR_BUTTON_CLOSE; break; - case NS_THEME_WINDOW_BUTTON_MINIMIZE: + case StyleAppearance::MozWindowButtonMinimize: aGtkWidgetType = MOZ_GTK_HEADER_BAR_BUTTON_MINIMIZE; break; - case NS_THEME_WINDOW_BUTTON_MAXIMIZE: + case StyleAppearance::MozWindowButtonMaximize: aGtkWidgetType = MOZ_GTK_HEADER_BAR_BUTTON_MAXIMIZE; break; - case NS_THEME_WINDOW_BUTTON_RESTORE: + case StyleAppearance::MozWindowButtonRestore: aGtkWidgetType = MOZ_GTK_HEADER_BAR_BUTTON_MAXIMIZE_RESTORE; break; default: return false; } return true; } @@ -1021,54 +1024,55 @@ DrawThemeWithCairo(gfxContext* aContext, if (surf) { cairo_surface_destroy(surf); } } } } bool -nsNativeThemeGTK::GetExtraSizeForWidget(nsIFrame* aFrame, uint8_t aWidgetType, +nsNativeThemeGTK::GetExtraSizeForWidget(nsIFrame* aFrame, + StyleAppearance aWidgetType, nsIntMargin* aExtra) { *aExtra = nsIntMargin(0,0,0,0); // Allow an extra one pixel above and below the thumb for certain // GTK2 themes (Ximian Industrial, Bluecurve, Misty, at least); // We modify the frame's overflow area. See bug 297508. switch (aWidgetType) { - case NS_THEME_SCROLLBARTHUMB_VERTICAL: + case StyleAppearance::ScrollbarthumbVertical: aExtra->top = aExtra->bottom = 1; break; - case NS_THEME_SCROLLBARTHUMB_HORIZONTAL: + case StyleAppearance::ScrollbarthumbHorizontal: aExtra->left = aExtra->right = 1; break; - case NS_THEME_BUTTON : + case StyleAppearance::Button : { if (IsDefaultButton(aFrame)) { // Some themes draw a default indicator outside the widget, // include that in overflow gint top, left, bottom, right; moz_gtk_button_get_default_overflow(&top, &left, &bottom, &right); aExtra->top = top; aExtra->right = right; aExtra->bottom = bottom; aExtra->left = left; break; } return false; } - case NS_THEME_FOCUS_OUTLINE: + case StyleAppearance::FocusOutline: { moz_gtk_get_focus_outline_size(&aExtra->left, &aExtra->top); aExtra->right = aExtra->left; aExtra->bottom = aExtra->top; break; } - case NS_THEME_TAB : + case StyleAppearance::Tab : { if (!IsSelectedTab(aFrame)) return false; gint gap_height = moz_gtk_get_tab_thickness(IsBottomTab(aFrame) ? MOZ_GTK_TAB_BOTTOM : MOZ_GTK_TAB_TOP); if (!gap_height) return false; @@ -1093,17 +1097,17 @@ nsNativeThemeGTK::GetExtraSizeForWidget( aExtra->bottom *= scale; aExtra->left *= scale; return true; } NS_IMETHODIMP nsNativeThemeGTK::DrawWidgetBackground(gfxContext* aContext, nsIFrame* aFrame, - uint8_t aWidgetType, + StyleAppearance aWidgetType, const nsRect& aRect, const nsRect& aDirtyRect) { GtkWidgetState state; WidgetNodeType gtkWidgetType; GtkTextDirection direction = GetTextDirection(aFrame); gint flags; if (!GetGtkWidgetAndState(aWidgetType, aFrame, gtkWidgetType, &state, @@ -1187,18 +1191,18 @@ nsNativeThemeGTK::DrawWidgetBackground(g gdk_flush(); } gLastGdkError = gdk_error_trap_pop (); if (gLastGdkError) { #ifdef DEBUG printf("GTK theme failed for widget type %d, error was %d, state was " "[active=%d,focused=%d,inHover=%d,disabled=%d]\n", - aWidgetType, gLastGdkError, state.active, state.focused, - state.inHover, state.disabled); + static_cast<int>(aWidgetType), gLastGdkError, state.active, + state.focused, state.inHover, state.disabled); #endif NS_WARNING("GTK theme failed; disabling unsafe widget"); SetWidgetTypeDisabled(mDisabledWidgetTypes, aWidgetType); // force refresh of the window, because the widget was not // successfully drawn it must be redrawn using the default look RefreshWidgetWindow(aFrame); } else { SetWidgetStateSafe(mSafeWidgetStates, aWidgetType, &state); @@ -1217,54 +1221,55 @@ nsNativeThemeGTK::DrawWidgetBackground(g } bool nsNativeThemeGTK::CreateWebRenderCommandsForWidget(mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const mozilla::layers::StackingContextHelper& aSc, mozilla::layers::WebRenderLayerManager* aManager, nsIFrame* aFrame, - uint8_t aWidgetType, + StyleAppearance aWidgetType, const nsRect& aRect) { nsPresContext* presContext = aFrame->PresContext(); wr::LayoutRect bounds = wr::ToRoundedLayoutRect( LayoutDeviceRect::FromAppUnits(aRect, presContext->AppUnitsPerDevPixel())); switch (aWidgetType) { - case NS_THEME_WINDOW: - case NS_THEME_DIALOG: + case StyleAppearance::Window: + case StyleAppearance::Dialog: aBuilder.PushRect(bounds, bounds, true, wr::ToColorF(Color::FromABGR( LookAndFeel::GetColor(LookAndFeel::eColorID_WindowBackground, NS_RGBA(0, 0, 0, 0))))); return true; default: return false; } } WidgetNodeType -nsNativeThemeGTK::NativeThemeToGtkTheme(uint8_t aWidgetType, nsIFrame* aFrame) +nsNativeThemeGTK::NativeThemeToGtkTheme(StyleAppearance aWidgetType, nsIFrame* aFrame) { WidgetNodeType gtkWidgetType; gint unusedFlags; if (!GetGtkWidgetAndState(aWidgetType, aFrame, gtkWidgetType, nullptr, &unusedFlags)) { MOZ_ASSERT_UNREACHABLE("Unknown native widget to gtk widget mapping"); return MOZ_GTK_WINDOW; } return gtkWidgetType; } void -nsNativeThemeGTK::GetCachedWidgetBorder(nsIFrame* aFrame, uint8_t aWidgetType, +nsNativeThemeGTK::GetCachedWidgetBorder(nsIFrame* aFrame, + StyleAppearance aWidgetType, GtkTextDirection aDirection, LayoutDeviceIntMargin* aResult) { aResult->SizeTo(0, 0, 0, 0); WidgetNodeType gtkWidgetType; gint unusedFlags; if (GetGtkWidgetAndState(aWidgetType, aFrame, gtkWidgetType, nullptr, @@ -1282,84 +1287,85 @@ nsNativeThemeGTK::GetCachedWidgetBorder( mBorderCacheValid[cacheIndex] |= cacheBit; mBorderCache[gtkWidgetType] = *aResult; } } } } LayoutDeviceIntMargin -nsNativeThemeGTK::GetWidgetBorder(nsDeviceContext* aContext, nsIFrame* aFrame, - uint8_t aWidgetType) +nsNativeThemeGTK::GetWidgetBorder(nsDeviceContext* aContext, + nsIFrame* aFrame, + StyleAppearance aWidgetType) { LayoutDeviceIntMargin result; GtkTextDirection direction = GetTextDirection(aFrame); switch (aWidgetType) { - case NS_THEME_SCROLLBAR_HORIZONTAL: - case NS_THEME_SCROLLBAR_VERTICAL: + case StyleAppearance::ScrollbarHorizontal: + case StyleAppearance::ScrollbarVertical: { GtkOrientation orientation = - aWidgetType == NS_THEME_SCROLLBAR_HORIZONTAL ? + aWidgetType == StyleAppearance::ScrollbarHorizontal ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL; const ScrollbarGTKMetrics* metrics = GetActiveScrollbarMetrics(orientation); const GtkBorder& border = metrics->border.scrollbar; result.top = border.top; result.right = border.right; result.bottom = border.bottom; result.left = border.left; } break; - case NS_THEME_SCROLLBARTRACK_HORIZONTAL: - case NS_THEME_SCROLLBARTRACK_VERTICAL: + case StyleAppearance::ScrollbartrackHorizontal: + case StyleAppearance::ScrollbartrackVertical: { GtkOrientation orientation = - aWidgetType == NS_THEME_SCROLLBARTRACK_HORIZONTAL ? + aWidgetType == StyleAppearance::ScrollbartrackHorizontal ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL; const ScrollbarGTKMetrics* metrics = GetActiveScrollbarMetrics(orientation); const GtkBorder& border = metrics->border.track; result.top = border.top; result.right = border.right; result.bottom = border.bottom; result.left = border.left; } break; - case NS_THEME_TOOLBOX: + case StyleAppearance::Toolbox: // gtk has no toolbox equivalent. So, although we map toolbox to // gtk's 'toolbar' for purposes of painting the widget background, // we don't use the toolbar border for toolbox. break; - case NS_THEME_DUALBUTTON: + case StyleAppearance::Dualbutton: // TOOLBAR_DUAL_BUTTON is an interesting case. We want a border to draw // around the entire button + dropdown, and also an inner border if you're // over the button part. But, we want the inner button to be right up // against the edge of the outer button so that the borders overlap. // To make this happen, we draw a button border for the outer button, // but don't reserve any space for it. break; - case NS_THEME_TAB: + case StyleAppearance::Tab: { WidgetNodeType gtkWidgetType; gint flags; if (!GetGtkWidgetAndState(aWidgetType, aFrame, gtkWidgetType, nullptr, &flags)) { return result; } moz_gtk_get_tab_border(&result.left, &result.top, &result.right, &result.bottom, direction, (GtkTabFlags)flags, gtkWidgetType); } break; - case NS_THEME_MENUITEM: - case NS_THEME_CHECKMENUITEM: - case NS_THEME_RADIOMENUITEM: + case StyleAppearance::Menuitem: + case StyleAppearance::Checkmenuitem: + case StyleAppearance::Radiomenuitem: // For regular menuitems, we will be using GetWidgetPadding instead of // GetWidgetBorder to pad up the widget's internals; other menuitems // will need to fall through and use the default case as before. if (IsRegularMenuItem(aFrame)) break; MOZ_FALLTHROUGH; default: { @@ -1372,79 +1378,83 @@ nsNativeThemeGTK::GetWidgetBorder(nsDevi result.right *= scale; result.bottom *= scale; result.left *= scale; return result; } bool nsNativeThemeGTK::GetWidgetPadding(nsDeviceContext* aContext, - nsIFrame* aFrame, uint8_t aWidgetType, + nsIFrame* aFrame, + StyleAppearance aWidgetType, LayoutDeviceIntMargin* aResult) { switch (aWidgetType) { - case NS_THEME_BUTTON_FOCUS: - case NS_THEME_TOOLBARBUTTON: - case NS_THEME_WINDOW_BUTTON_CLOSE: - case NS_THEME_WINDOW_BUTTON_MINIMIZE: - case NS_THEME_WINDOW_BUTTON_MAXIMIZE: - case NS_THEME_WINDOW_BUTTON_RESTORE: - case NS_THEME_DUALBUTTON: - case NS_THEME_TAB_SCROLL_ARROW_BACK: - case NS_THEME_TAB_SCROLL_ARROW_FORWARD: - case NS_THEME_MENULIST_BUTTON: - case NS_THEME_TOOLBARBUTTON_DROPDOWN: - case NS_THEME_BUTTON_ARROW_UP: - case NS_THEME_BUTTON_ARROW_DOWN: - case NS_THEME_BUTTON_ARROW_NEXT: - case NS_THEME_BUTTON_ARROW_PREVIOUS: - case NS_THEME_RANGE_THUMB: + case StyleAppearance::ButtonFocus: + case StyleAppearance::Toolbarbutton: + case StyleAppearance::MozWindowButtonClose: + case StyleAppearance::MozWindowButtonMinimize: + case StyleAppearance::MozWindowButtonMaximize: + case StyleAppearance::MozWindowButtonRestore: + case StyleAppearance::Dualbutton: + case StyleAppearance::TabScrollArrowBack: + case StyleAppearance::TabScrollArrowForward: + case StyleAppearance::MenulistButton: + case StyleAppearance::ToolbarbuttonDropdown: + case StyleAppearance::ButtonArrowUp: + case StyleAppearance::ButtonArrowDown: + case StyleAppearance::ButtonArrowNext: + case StyleAppearance::ButtonArrowPrevious: + case StyleAppearance::RangeThumb: // Radios and checkboxes return a fixed size in GetMinimumWidgetSize // and have a meaningful baseline, so they can't have // author-specified padding. - case NS_THEME_CHECKBOX: - case NS_THEME_RADIO: + case StyleAppearance::Checkbox: + case StyleAppearance::Radio: aResult->SizeTo(0, 0, 0, 0); return true; - case NS_THEME_MENUITEM: - case NS_THEME_CHECKMENUITEM: - case NS_THEME_RADIOMENUITEM: + case StyleAppearance::Menuitem: + case StyleAppearance::Checkmenuitem: + case StyleAppearance::Radiomenuitem: { // Menubar and menulist have their padding specified in CSS. if (!IsRegularMenuItem(aFrame)) return false; GetCachedWidgetBorder(aFrame, aWidgetType, GetTextDirection(aFrame), aResult); gint horizontal_padding; - if (aWidgetType == NS_THEME_MENUITEM) + if (aWidgetType == StyleAppearance::Menuitem) moz_gtk_menuitem_get_horizontal_padding(&horizontal_padding); else moz_gtk_checkmenuitem_get_horizontal_padding(&horizontal_padding); aResult->left += horizontal_padding; aResult->right += horizontal_padding; gint scale = GetMonitorScaleFactor(aFrame); aResult->top *= scale; aResult->right *= scale; aResult->bottom *= scale; aResult->left *= scale; return true; } + default: + break; } return false; } bool nsNativeThemeGTK::GetWidgetOverflow(nsDeviceContext* aContext, - nsIFrame* aFrame, uint8_t aWidgetType, + nsIFrame* aFrame, + StyleAppearance aWidgetType, nsRect* aOverflowRect) { nsIntMargin extraSize; if (!GetExtraSizeForWidget(aFrame, aWidgetType, &extraSize)) return false; int32_t p2a = aContext->AppUnitsPerDevPixel(); nsMargin m(NSIntPixelsToAppUnits(extraSize.top, p2a), @@ -1453,319 +1463,323 @@ nsNativeThemeGTK::GetWidgetOverflow(nsDe NSIntPixelsToAppUnits(extraSize.left, p2a)); aOverflowRect->Inflate(m); return true; } NS_IMETHODIMP nsNativeThemeGTK::GetMinimumWidgetSize(nsPresContext* aPresContext, - nsIFrame* aFrame, uint8_t aWidgetType, + nsIFrame* aFrame, + StyleAppearance aWidgetType, LayoutDeviceIntSize* aResult, bool* aIsOverridable) { aResult->width = aResult->height = 0; *aIsOverridable = true; switch (aWidgetType) { - case NS_THEME_SCROLLBARBUTTON_UP: - case NS_THEME_SCROLLBARBUTTON_DOWN: + case StyleAppearance::ScrollbarbuttonUp: + case StyleAppearance::ScrollbarbuttonDown: { const ScrollbarGTKMetrics* metrics = GetActiveScrollbarMetrics(GTK_ORIENTATION_VERTICAL); aResult->width = metrics->size.button.width; aResult->height = metrics->size.button.height; *aIsOverridable = false; } break; - case NS_THEME_SCROLLBARBUTTON_LEFT: - case NS_THEME_SCROLLBARBUTTON_RIGHT: + case StyleAppearance::ScrollbarbuttonLeft: + case StyleAppearance::ScrollbarbuttonRight: { const ScrollbarGTKMetrics* metrics = GetActiveScrollbarMetrics(GTK_ORIENTATION_HORIZONTAL); aResult->width = metrics->size.button.width; aResult->height = metrics->size.button.height; *aIsOverridable = false; } break; - case NS_THEME_SPLITTER: + case StyleAppearance::Splitter: { gint metrics; if (IsHorizontal(aFrame)) { moz_gtk_splitter_get_metrics(GTK_ORIENTATION_HORIZONTAL, &metrics); aResult->width = metrics; aResult->height = 0; } else { moz_gtk_splitter_get_metrics(GTK_ORIENTATION_VERTICAL, &metrics); aResult->width = 0; aResult->height = metrics; } *aIsOverridable = false; } break; - case NS_THEME_SCROLLBAR_HORIZONTAL: - case NS_THEME_SCROLLBAR_VERTICAL: + case StyleAppearance::ScrollbarHorizontal: + case StyleAppearance::ScrollbarVertical: { /* While we enforce a minimum size for the thumb, this is ignored * for the some scrollbars if buttons are hidden (bug 513006) because * the thumb isn't a direct child of the scrollbar, unlike the buttons * or track. So add a minimum size to the track as well to prevent a * 0-width scrollbar. */ GtkOrientation orientation = - aWidgetType == NS_THEME_SCROLLBAR_HORIZONTAL ? + aWidgetType == StyleAppearance::ScrollbarHorizontal ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL; const ScrollbarGTKMetrics* metrics = GetActiveScrollbarMetrics(orientation); aResult->width = metrics->size.scrollbar.width; aResult->height = metrics->size.scrollbar.height; } break; - case NS_THEME_SCROLLBARTHUMB_VERTICAL: - case NS_THEME_SCROLLBARTHUMB_HORIZONTAL: + case StyleAppearance::ScrollbarthumbVertical: + case StyleAppearance::ScrollbarthumbHorizontal: { GtkOrientation orientation = - aWidgetType == NS_THEME_SCROLLBARTHUMB_HORIZONTAL ? + aWidgetType == StyleAppearance::ScrollbarthumbHorizontal ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL; const ScrollbarGTKMetrics* metrics = GetActiveScrollbarMetrics(orientation); aResult->width = metrics->size.thumb.width; aResult->height = metrics->size.thumb.height; *aIsOverridable = false; } break; - case NS_THEME_RANGE_THUMB: + case StyleAppearance::RangeThumb: { gint thumb_length, thumb_height; if (IsRangeHorizontal(aFrame)) { moz_gtk_get_scalethumb_metrics(GTK_ORIENTATION_HORIZONTAL, &thumb_length, &thumb_height); } else { moz_gtk_get_scalethumb_metrics(GTK_ORIENTATION_VERTICAL, &thumb_height, &thumb_length); } aResult->width = thumb_length; aResult->height = thumb_height; *aIsOverridable = false; } break; - case NS_THEME_RANGE: + case StyleAppearance::Range: { gint scale_width, scale_height; moz_gtk_get_scale_metrics(IsRangeHorizontal(aFrame) ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL, &scale_width, &scale_height); aResult->width = scale_width; aResult->height = scale_height; *aIsOverridable = true; } break; - case NS_THEME_SCALETHUMB_HORIZONTAL: - case NS_THEME_SCALETHUMB_VERTICAL: + case StyleAppearance::ScalethumbHorizontal: + case StyleAppearance::ScalethumbVertical: { gint thumb_length, thumb_height; - if (aWidgetType == NS_THEME_SCALETHUMB_VERTICAL) { + if (aWidgetType == StyleAppearance::ScalethumbVertical) { moz_gtk_get_scalethumb_metrics(GTK_ORIENTATION_VERTICAL, &thumb_length, &thumb_height); aResult->width = thumb_height; aResult->height = thumb_length; } else { moz_gtk_get_scalethumb_metrics(GTK_ORIENTATION_HORIZONTAL, &thumb_length, &thumb_height); aResult->width = thumb_length; aResult->height = thumb_height; } *aIsOverridable = false; } break; - case NS_THEME_TAB_SCROLL_ARROW_BACK: - case NS_THEME_TAB_SCROLL_ARROW_FORWARD: + case StyleAppearance::TabScrollArrowBack: + case StyleAppearance::TabScrollArrowForward: { moz_gtk_get_tab_scroll_arrow_size(&aResult->width, &aResult->height); *aIsOverridable = false; } break; - case NS_THEME_MENULIST_BUTTON: + case StyleAppearance::MenulistButton: { moz_gtk_get_combo_box_entry_button_size(&aResult->width, &aResult->height); *aIsOverridable = false; } break; - case NS_THEME_MENUSEPARATOR: + case StyleAppearance::Menuseparator: { gint separator_height; moz_gtk_get_menu_separator_height(&separator_height); aResult->height = separator_height; *aIsOverridable = false; } break; - case NS_THEME_CHECKBOX: - case NS_THEME_RADIO: + case StyleAppearance::Checkbox: + case StyleAppearance::Radio: { - const ToggleGTKMetrics* metrics = GetToggleMetrics(aWidgetType == NS_THEME_RADIO); + const ToggleGTKMetrics* metrics = GetToggleMetrics(aWidgetType == StyleAppearance::Radio); aResult->width = metrics->minSizeWithBorder.width; aResult->height = metrics->minSizeWithBorder.height; } break; - case NS_THEME_TOOLBARBUTTON_DROPDOWN: - case NS_THEME_BUTTON_ARROW_UP: - case NS_THEME_BUTTON_ARROW_DOWN: - case NS_THEME_BUTTON_ARROW_NEXT: - case NS_THEME_BUTTON_ARROW_PREVIOUS: + case StyleAppearance::ToolbarbuttonDropdown: + case StyleAppearance::ButtonArrowUp: + case StyleAppearance::ButtonArrowDown: + case StyleAppearance::ButtonArrowNext: + case StyleAppearance::ButtonArrowPrevious: { moz_gtk_get_arrow_size(MOZ_GTK_TOOLBARBUTTON_ARROW, &aResult->width, &aResult->height); *aIsOverridable = false; } break; - case NS_THEME_WINDOW_BUTTON_CLOSE: + case StyleAppearance::MozWindowButtonClose: { const ToolbarButtonGTKMetrics* metrics = GetToolbarButtonMetrics(MOZ_GTK_HEADER_BAR_BUTTON_CLOSE); aResult->width = metrics->minSizeWithBorderMargin.width; aResult->height = metrics->minSizeWithBorderMargin.height; break; } - case NS_THEME_WINDOW_BUTTON_MINIMIZE: + case StyleAppearance::MozWindowButtonMinimize: { const ToolbarButtonGTKMetrics* metrics = GetToolbarButtonMetrics(MOZ_GTK_HEADER_BAR_BUTTON_MINIMIZE); aResult->width = metrics->minSizeWithBorderMargin.width; aResult->height = metrics->minSizeWithBorderMargin.height; break; } - case NS_THEME_WINDOW_BUTTON_MAXIMIZE: - case NS_THEME_WINDOW_BUTTON_RESTORE: + case StyleAppearance::MozWindowButtonMaximize: + case StyleAppearance::MozWindowButtonRestore: { const ToolbarButtonGTKMetrics* metrics = GetToolbarButtonMetrics(MOZ_GTK_HEADER_BAR_BUTTON_MAXIMIZE); aResult->width = metrics->minSizeWithBorderMargin.width; aResult->height = metrics->minSizeWithBorderMargin.height; break; } - case NS_THEME_CHECKBOX_CONTAINER: - case NS_THEME_RADIO_CONTAINER: - case NS_THEME_CHECKBOX_LABEL: - case NS_THEME_RADIO_LABEL: - case NS_THEME_BUTTON: - case NS_THEME_MENULIST: - case NS_THEME_TOOLBARBUTTON: - case NS_THEME_TREEHEADERCELL: + case StyleAppearance::CheckboxContainer: + case StyleAppearance::RadioContainer: + case StyleAppearance::CheckboxLabel: + case StyleAppearance::RadioLabel: + case StyleAppearance::Button: + case StyleAppearance::Menulist: + case StyleAppearance::Toolbarbutton: + case StyleAppearance::Treeheadercell: { - if (aWidgetType == NS_THEME_MENULIST) { + if (aWidgetType == StyleAppearance::Menulist) { // Include the arrow size. moz_gtk_get_arrow_size(MOZ_GTK_DROPDOWN, &aResult->width, &aResult->height); } // else the minimum size is missing consideration of container // descendants; the value returned here will not be helpful, but the // box model may consider border and padding with child minimum sizes. LayoutDeviceIntMargin border; GetCachedWidgetBorder(aFrame, aWidgetType, GetTextDirection(aFrame), &border); aResult->width += border.left + border.right; aResult->height += border.top + border.bottom; } break; #ifdef MOZ_WIDGET_GTK - case NS_THEME_NUMBER_INPUT: - case NS_THEME_TEXTFIELD: + case StyleAppearance::NumberInput: + case StyleAppearance::Textfield: { moz_gtk_get_entry_min_height(&aResult->height); } break; #endif - case NS_THEME_SEPARATOR: + case StyleAppearance::Separator: { gint separator_width; moz_gtk_get_toolbar_separator_width(&separator_width); aResult->width = separator_width; } break; - case NS_THEME_INNER_SPIN_BUTTON: - case NS_THEME_SPINNER: + case StyleAppearance::InnerSpinButton: + case StyleAppearance::Spinner: // hard code these sizes aResult->width = 14; aResult->height = 26; break; - case NS_THEME_TREEHEADERSORTARROW: - case NS_THEME_SPINNER_UPBUTTON: - case NS_THEME_SPINNER_DOWNBUTTON: + case StyleAppearance::Treeheadersortarrow: + case StyleAppearance::SpinnerUpbutton: + case StyleAppearance::SpinnerDownbutton: // hard code these sizes aResult->width = 14; aResult->height = 13; break; - case NS_THEME_RESIZER: + case StyleAppearance::Resizer: // same as Windows to make our lives easier aResult->width = aResult->height = 15; *aIsOverridable = false; break; - case NS_THEME_TREETWISTY: - case NS_THEME_TREETWISTYOPEN: + case StyleAppearance::Treetwisty: + case StyleAppearance::Treetwistyopen: { gint expander_size; moz_gtk_get_treeview_expander_size(&expander_size); aResult->width = aResult->height = expander_size; *aIsOverridable = false; } break; + default: + break; } *aResult = *aResult * GetMonitorScaleFactor(aFrame); return NS_OK; } NS_IMETHODIMP -nsNativeThemeGTK::WidgetStateChanged(nsIFrame* aFrame, uint8_t aWidgetType, +nsNativeThemeGTK::WidgetStateChanged(nsIFrame* aFrame, + StyleAppearance aWidgetType, nsAtom* aAttribute, bool* aShouldRepaint, const nsAttrValue* aOldValue) { // Some widget types just never change state. - if (aWidgetType == NS_THEME_TOOLBOX || - aWidgetType == NS_THEME_TOOLBAR || - aWidgetType == NS_THEME_STATUSBAR || - aWidgetType == NS_THEME_STATUSBARPANEL || - aWidgetType == NS_THEME_RESIZERPANEL || - aWidgetType == NS_THEME_PROGRESSCHUNK || - aWidgetType == NS_THEME_PROGRESSCHUNK_VERTICAL || - aWidgetType == NS_THEME_PROGRESSBAR || - aWidgetType == NS_THEME_PROGRESSBAR_VERTICAL || - aWidgetType == NS_THEME_MENUBAR || - aWidgetType == NS_THEME_MENUPOPUP || - aWidgetType == NS_THEME_TOOLTIP || - aWidgetType == NS_THEME_MENUSEPARATOR || - aWidgetType == NS_THEME_WINDOW || - aWidgetType == NS_THEME_DIALOG) { + if (aWidgetType == StyleAppearance::Toolbox || + aWidgetType == StyleAppearance::Toolbar || + aWidgetType == StyleAppearance::Statusbar || + aWidgetType == StyleAppearance::Statusbarpanel || + aWidgetType == StyleAppearance::Resizerpanel || + aWidgetType == StyleAppearance::Progresschunk || + aWidgetType == StyleAppearance::ProgresschunkVertical || + aWidgetType == StyleAppearance::Progressbar || + aWidgetType == StyleAppearance::ProgressbarVertical || + aWidgetType == StyleAppearance::Menubar || + aWidgetType == StyleAppearance::Menupopup || + aWidgetType == StyleAppearance::Tooltip || + aWidgetType == StyleAppearance::Menuseparator || + aWidgetType == StyleAppearance::Window || + aWidgetType == StyleAppearance::Dialog) { *aShouldRepaint = false; return NS_OK; } - if ((aWidgetType == NS_THEME_SCROLLBARTHUMB_VERTICAL || - aWidgetType == NS_THEME_SCROLLBARTHUMB_HORIZONTAL) && + if ((aWidgetType == StyleAppearance::ScrollbarthumbVertical || + aWidgetType == StyleAppearance::ScrollbarthumbHorizontal) && aAttribute == nsGkAtoms::active) { *aShouldRepaint = true; return NS_OK; } - if ((aWidgetType == NS_THEME_SCROLLBARBUTTON_UP || - aWidgetType == NS_THEME_SCROLLBARBUTTON_DOWN || - aWidgetType == NS_THEME_SCROLLBARBUTTON_LEFT || - aWidgetType == NS_THEME_SCROLLBARBUTTON_RIGHT) && + if ((aWidgetType == StyleAppearance::ScrollbarbuttonUp || + aWidgetType == StyleAppearance::ScrollbarbuttonDown || + aWidgetType == StyleAppearance::ScrollbarbuttonLeft || + aWidgetType == StyleAppearance::ScrollbarbuttonRight) && (aAttribute == nsGkAtoms::curpos || aAttribute == nsGkAtoms::maxpos)) { // If 'curpos' has changed and we are passed its old value, we can // determine whether the button's enablement actually needs to change. if (aAttribute == nsGkAtoms::curpos && aOldValue) { int32_t curpos = CheckIntAttr(aFrame, nsGkAtoms::curpos, 0); int32_t maxpos = CheckIntAttr(aFrame, nsGkAtoms::maxpos, 0); nsAutoString str; @@ -1819,200 +1833,204 @@ nsNativeThemeGTK::ThemeChanged() memset(mSafeWidgetStates, 0, sizeof(mSafeWidgetStates)); memset(mBorderCacheValid, 0, sizeof(mBorderCacheValid)); return NS_OK; } NS_IMETHODIMP_(bool) nsNativeThemeGTK::ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* aFrame, - uint8_t aWidgetType) + StyleAppearance aWidgetType) { if (IsWidgetTypeDisabled(mDisabledWidgetTypes, aWidgetType)) return false; switch (aWidgetType) { // Combobox dropdowns don't support native theming in vertical mode. - case NS_THEME_MENULIST: - case NS_THEME_MENULIST_TEXT: - case NS_THEME_MENULIST_TEXTFIELD: + case StyleAppearance::Menulist: + case StyleAppearance::MenulistText: + case StyleAppearance::MenulistTextfield: if (aFrame && aFrame->GetWritingMode().IsVertical()) { return false; } MOZ_FALLTHROUGH; - case NS_THEME_BUTTON: - case NS_THEME_BUTTON_FOCUS: - case NS_THEME_RADIO: - case NS_THEME_CHECKBOX: - case NS_THEME_TOOLBOX: // N/A - case NS_THEME_TOOLBAR: - case NS_THEME_TOOLBARBUTTON: - case NS_THEME_DUALBUTTON: // so we can override the border with 0 - case NS_THEME_TOOLBARBUTTON_DROPDOWN: - case NS_THEME_BUTTON_ARROW_UP: - case NS_THEME_BUTTON_ARROW_DOWN: - case NS_THEME_BUTTON_ARROW_NEXT: - case NS_THEME_BUTTON_ARROW_PREVIOUS: - case NS_THEME_SEPARATOR: - case NS_THEME_TOOLBARGRIPPER: - case NS_THEME_STATUSBAR: - case NS_THEME_STATUSBARPANEL: - case NS_THEME_RESIZERPANEL: - case NS_THEME_RESIZER: - case NS_THEME_LISTBOX: - // case NS_THEME_LISTITEM: - case NS_THEME_TREEVIEW: - // case NS_THEME_TREEITEM: - case NS_THEME_TREETWISTY: - // case NS_THEME_TREELINE: - // case NS_THEME_TREEHEADER: - case NS_THEME_TREEHEADERCELL: - case NS_THEME_TREEHEADERSORTARROW: - case NS_THEME_TREETWISTYOPEN: - case NS_THEME_PROGRESSBAR: - case NS_THEME_PROGRESSCHUNK: - case NS_THEME_PROGRESSBAR_VERTICAL: - case NS_THEME_PROGRESSCHUNK_VERTICAL: - case NS_THEME_TAB: - // case NS_THEME_TABPANEL: - case NS_THEME_TABPANELS: - case NS_THEME_TAB_SCROLL_ARROW_BACK: - case NS_THEME_TAB_SCROLL_ARROW_FORWARD: - case NS_THEME_TOOLTIP: - case NS_THEME_INNER_SPIN_BUTTON: - case NS_THEME_SPINNER: - case NS_THEME_SPINNER_UPBUTTON: - case NS_THEME_SPINNER_DOWNBUTTON: - case NS_THEME_SPINNER_TEXTFIELD: - // case NS_THEME_SCROLLBAR: (n/a for gtk) - // case NS_THEME_SCROLLBAR_SMALL: (n/a for gtk) - case NS_THEME_SCROLLBARBUTTON_UP: - case NS_THEME_SCROLLBARBUTTON_DOWN: - case NS_THEME_SCROLLBARBUTTON_LEFT: - case NS_THEME_SCROLLBARBUTTON_RIGHT: - case NS_THEME_SCROLLBAR_HORIZONTAL: - case NS_THEME_SCROLLBAR_VERTICAL: - case NS_THEME_SCROLLBARTRACK_HORIZONTAL: - case NS_THEME_SCROLLBARTRACK_VERTICAL: - case NS_THEME_SCROLLBARTHUMB_HORIZONTAL: - case NS_THEME_SCROLLBARTHUMB_VERTICAL: - case NS_THEME_NUMBER_INPUT: - case NS_THEME_TEXTFIELD: - case NS_THEME_TEXTFIELD_MULTILINE: - case NS_THEME_RANGE: - case NS_THEME_RANGE_THUMB: - case NS_THEME_SCALE_HORIZONTAL: - case NS_THEME_SCALETHUMB_HORIZONTAL: - case NS_THEME_SCALE_VERTICAL: - case NS_THEME_SCALETHUMB_VERTICAL: - // case NS_THEME_SCALETHUMBSTART: - // case NS_THEME_SCALETHUMBEND: - // case NS_THEME_SCALETHUMBTICK: - case NS_THEME_CHECKBOX_CONTAINER: - case NS_THEME_RADIO_CONTAINER: - case NS_THEME_CHECKBOX_LABEL: - case NS_THEME_RADIO_LABEL: - case NS_THEME_MENUBAR: - case NS_THEME_MENUPOPUP: - case NS_THEME_MENUITEM: - case NS_THEME_MENUARROW: - case NS_THEME_MENUSEPARATOR: - case NS_THEME_CHECKMENUITEM: - case NS_THEME_RADIOMENUITEM: - case NS_THEME_SPLITTER: - case NS_THEME_WINDOW: - case NS_THEME_DIALOG: + case StyleAppearance::Button: + case StyleAppearance::ButtonFocus: + case StyleAppearance::Radio: + case StyleAppearance::Checkbox: + case StyleAppearance::Toolbox: // N/A + case StyleAppearance::Toolbar: + case StyleAppearance::Toolbarbutton: + case StyleAppearance::Dualbutton: // so we can override the border with 0 + case StyleAppearance::ToolbarbuttonDropdown: + case StyleAppearance::ButtonArrowUp: + case StyleAppearance::ButtonArrowDown: + case StyleAppearance::ButtonArrowNext: + case StyleAppearance::ButtonArrowPrevious: + case StyleAppearance::Separator: + case StyleAppearance::Toolbargripper: + case StyleAppearance::Statusbar: + case StyleAppearance::Statusbarpanel: + case StyleAppearance::Resizerpanel: + case StyleAppearance::Resizer: + case StyleAppearance::Listbox: + // case StyleAppearance::Listitem: + case StyleAppearance::Treeview: + // case StyleAppearance::Treeitem: + case StyleAppearance::Treetwisty: + // case StyleAppearance::Treeline: + // case StyleAppearance::Treeheader: + case StyleAppearance::Treeheadercell: + case StyleAppearance::Treeheadersortarrow: + case StyleAppearance::Treetwistyopen: + case StyleAppearance::Progressbar: + case StyleAppearance::Progresschunk: + case StyleAppearance::ProgressbarVertical: + case StyleAppearance::ProgresschunkVertical: + case StyleAppearance::Tab: + // case StyleAppearance::Tabpanel: + case StyleAppearance::Tabpanels: + case StyleAppearance::TabScrollArrowBack: + case StyleAppearance::TabScrollArrowForward: + case StyleAppearance::Tooltip: + case StyleAppearance::InnerSpinButton: + case StyleAppearance::Spinner: + case StyleAppearance::SpinnerUpbutton: + case StyleAppearance::SpinnerDownbutton: + case StyleAppearance::SpinnerTextfield: + // case StyleAppearance::Scrollbar: (n/a for gtk) + // case StyleAppearance::ScrollbarSmall: (n/a for gtk) + case StyleAppearance::ScrollbarbuttonUp: + case StyleAppearance::ScrollbarbuttonDown: + case StyleAppearance::ScrollbarbuttonLeft: + case StyleAppearance::ScrollbarbuttonRight: + case StyleAppearance::ScrollbarHorizontal: + case StyleAppearance::ScrollbarVertical: + case StyleAppearance::ScrollbartrackHorizontal: + case StyleAppearance::ScrollbartrackVertical: + case StyleAppearance::ScrollbarthumbHorizontal: + case StyleAppearance::ScrollbarthumbVertical: + case StyleAppearance::NumberInput: + case StyleAppearance::Textfield: + case StyleAppearance::TextfieldMultiline: + case StyleAppearance::Range: + case StyleAppearance::RangeThumb: + case StyleAppearance::ScaleHorizontal: + case StyleAppearance::ScalethumbHorizontal: + case StyleAppearance::ScaleVertical: + case StyleAppearance::ScalethumbVertical: + // case StyleAppearance::Scalethumbstart: + // case StyleAppearance::Scalethumbend: + // case StyleAppearance::Scalethumbtick: + case StyleAppearance::CheckboxContainer: + case StyleAppearance::RadioContainer: + case StyleAppearance::CheckboxLabel: + case StyleAppearance::RadioLabel: + case StyleAppearance::Menubar: + case StyleAppearance::Menupopup: + case StyleAppearance::Menuitem: + case StyleAppearance::Menuarrow: + case StyleAppearance::Menuseparator: + case StyleAppearance::Checkmenuitem: + case StyleAppearance::Radiomenuitem: + case StyleAppearance::Splitter: + case StyleAppearance::Window: + case StyleAppearance::Dialog: #ifdef MOZ_WIDGET_GTK - case NS_THEME_GTK_INFO_BAR: + case StyleAppearance::MozGtkInfoBar: #endif return !IsWidgetStyled(aPresContext, aFrame, aWidgetType); - case NS_THEME_WINDOW_BUTTON_CLOSE: - case NS_THEME_WINDOW_BUTTON_MINIMIZE: - case NS_THEME_WINDOW_BUTTON_MAXIMIZE: - case NS_THEME_WINDOW_BUTTON_RESTORE: - case NS_THEME_WINDOW_TITLEBAR: - case NS_THEME_WINDOW_TITLEBAR_MAXIMIZED: + case StyleAppearance::MozWindowButtonClose: + case StyleAppearance::MozWindowButtonMinimize: + case StyleAppearance::MozWindowButtonMaximize: + case StyleAppearance::MozWindowButtonRestore: + case StyleAppearance::MozWindowTitlebar: + case StyleAppearance::MozWindowTitlebarMaximized: // GtkHeaderBar is available on GTK 3.10+, which is used for styling // title bars and title buttons. return gtk_check_version(3, 10, 0) == nullptr && !IsWidgetStyled(aPresContext, aFrame, aWidgetType); - case NS_THEME_MENULIST_BUTTON: + case StyleAppearance::MenulistButton: if (aFrame && aFrame->GetWritingMode().IsVertical()) { return false; } // "Native" dropdown buttons cause padding and margin problems, but only // in HTML so allow them in XUL. return (!aFrame || IsFrameContentNodeInNamespace(aFrame, kNameSpaceID_XUL)) && !IsWidgetStyled(aPresContext, aFrame, aWidgetType); - case NS_THEME_FOCUS_OUTLINE: + case StyleAppearance::FocusOutline: return true; + default: + break; } return false; } NS_IMETHODIMP_(bool) -nsNativeThemeGTK::WidgetIsContainer(uint8_t aWidgetType) +nsNativeThemeGTK::WidgetIsContainer(StyleAppearance aWidgetType) { // XXXdwh At some point flesh all of this out. - if (aWidgetType == NS_THEME_MENULIST_BUTTON || - aWidgetType == NS_THEME_RADIO || - aWidgetType == NS_THEME_RANGE_THUMB || - aWidgetType == NS_THEME_CHECKBOX || - aWidgetType == NS_THEME_TAB_SCROLL_ARROW_BACK || - aWidgetType == NS_THEME_TAB_SCROLL_ARROW_FORWARD || - aWidgetType == NS_THEME_BUTTON_ARROW_UP || - aWidgetType == NS_THEME_BUTTON_ARROW_DOWN || - aWidgetType == NS_THEME_BUTTON_ARROW_NEXT || - aWidgetType == NS_THEME_BUTTON_ARROW_PREVIOUS) + if (aWidgetType == StyleAppearance::MenulistButton || + aWidgetType == StyleAppearance::Radio || + aWidgetType == StyleAppearance::RangeThumb || + aWidgetType == StyleAppearance::Checkbox || + aWidgetType == StyleAppearance::TabScrollArrowBack || + aWidgetType == StyleAppearance::TabScrollArrowForward || + aWidgetType == StyleAppearance::ButtonArrowUp || + aWidgetType == StyleAppearance::ButtonArrowDown || + aWidgetType == StyleAppearance::ButtonArrowNext || + aWidgetType == StyleAppearance::ButtonArrowPrevious) return false; return true; } bool -nsNativeThemeGTK::ThemeDrawsFocusForWidget(uint8_t aWidgetType) +nsNativeThemeGTK::ThemeDrawsFocusForWidget(StyleAppearance aWidgetType) { - if (aWidgetType == NS_THEME_MENULIST || - aWidgetType == NS_THEME_BUTTON || - aWidgetType == NS_THEME_TREEHEADERCELL) + if (aWidgetType == StyleAppearance::Menulist || + aWidgetType == StyleAppearance::Button || + aWidgetType == StyleAppearance::Treeheadercell) return true; return false; } bool nsNativeThemeGTK::ThemeNeedsComboboxDropmarker() { return false; } nsITheme::Transparency -nsNativeThemeGTK::GetWidgetTransparency(nsIFrame* aFrame, uint8_t aWidgetType) +nsNativeThemeGTK::GetWidgetTransparency(nsIFrame* aFrame, + StyleAppearance aWidgetType) { switch (aWidgetType) { // These widgets always draw a default background. - case NS_THEME_MENUPOPUP: - case NS_THEME_WINDOW: - case NS_THEME_DIALOG: + case StyleAppearance::Menupopup: + case StyleAppearance::Window: + case StyleAppearance::Dialog: return eOpaque; - case NS_THEME_SCROLLBAR_VERTICAL: - case NS_THEME_SCROLLBAR_HORIZONTAL: + case StyleAppearance::ScrollbarVertical: + case StyleAppearance::ScrollbarHorizontal: #ifdef MOZ_WIDGET_GTK // Make scrollbar tracks opaque on the window's scroll frame to prevent // leaf layers from overlapping. See bug 1179780. if (!(CheckBooleanAttr(aFrame, nsGkAtoms::root_) && aFrame->PresContext()->IsRootContentDocument() && IsFrameContentNodeInNamespace(aFrame, kNameSpaceID_XUL))) return eTransparent; #endif return eOpaque; // Tooltips use gtk_paint_flat_box() on Gtk2 // but are shaped on Gtk3 - case NS_THEME_TOOLTIP: + case StyleAppearance::Tooltip: return eTransparent; + default: + return eUnknownTransparency; } - return eUnknownTransparency; }
--- a/widget/gtk/nsNativeThemeGTK.h +++ b/widget/gtk/nsNativeThemeGTK.h @@ -6,105 +6,105 @@ #ifndef _GTK_NSNATIVETHEMEGTK_H_ #define _GTK_NSNATIVETHEMEGTK_H_ #include "nsITheme.h" #include "nsCOMPtr.h" #include "nsAtom.h" #include "nsIObserver.h" #include "nsNativeTheme.h" -#include "nsThemeConstants.h" +#include "nsStyleConsts.h" #include <gtk/gtk.h> #include "gtkdrawing.h" class nsNativeThemeGTK final : private nsNativeTheme, public nsITheme, public nsIObserver { public: NS_DECL_ISUPPORTS_INHERITED NS_DECL_NSIOBSERVER // The nsITheme interface. NS_IMETHOD DrawWidgetBackground(gfxContext* aContext, - nsIFrame* aFrame, uint8_t aWidgetType, + nsIFrame* aFrame, WidgetType aWidgetType, const nsRect& aRect, const nsRect& aDirtyRect) override; bool CreateWebRenderCommandsForWidget(mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const mozilla::layers::StackingContextHelper& aSc, mozilla::layers::WebRenderLayerManager* aManager, nsIFrame* aFrame, - uint8_t aWidgetType, + WidgetType aWidgetType, const nsRect& aRect) override; MOZ_MUST_USE LayoutDeviceIntMargin GetWidgetBorder(nsDeviceContext* aContext, nsIFrame* aFrame, - uint8_t aWidgetType) override; + WidgetType aWidgetType) override; bool GetWidgetPadding(nsDeviceContext* aContext, nsIFrame* aFrame, - uint8_t aWidgetType, + WidgetType aWidgetType, LayoutDeviceIntMargin* aResult) override; virtual bool GetWidgetOverflow(nsDeviceContext* aContext, nsIFrame* aFrame, - uint8_t aWidgetType, + WidgetType aWidgetType, nsRect* aOverflowRect) override; NS_IMETHOD GetMinimumWidgetSize(nsPresContext* aPresContext, - nsIFrame* aFrame, uint8_t aWidgetType, + nsIFrame* aFrame, WidgetType aWidgetType, mozilla::LayoutDeviceIntSize* aResult, bool* aIsOverridable) override; - NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, uint8_t aWidgetType, + NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, WidgetType aWidgetType, nsAtom* aAttribute, bool* aShouldRepaint, const nsAttrValue* aOldValue) override; NS_IMETHOD ThemeChanged() override; NS_IMETHOD_(bool) ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* aFrame, - uint8_t aWidgetType) override; + WidgetType aWidgetType) override; - NS_IMETHOD_(bool) WidgetIsContainer(uint8_t aWidgetType) override; + NS_IMETHOD_(bool) WidgetIsContainer(WidgetType aWidgetType) override; - NS_IMETHOD_(bool) ThemeDrawsFocusForWidget(uint8_t aWidgetType) override; + NS_IMETHOD_(bool) ThemeDrawsFocusForWidget(WidgetType aWidgetType) override; virtual bool ThemeNeedsComboboxDropmarker() override; virtual Transparency GetWidgetTransparency(nsIFrame* aFrame, - uint8_t aWidgetType) override; + WidgetType aWidgetType) override; nsNativeThemeGTK(); protected: virtual ~nsNativeThemeGTK(); private: GtkTextDirection GetTextDirection(nsIFrame* aFrame); gint GetTabMarginPixels(nsIFrame* aFrame); - bool GetGtkWidgetAndState(uint8_t aWidgetType, nsIFrame* aFrame, + bool GetGtkWidgetAndState(WidgetType aWidgetType, nsIFrame* aFrame, WidgetNodeType& aGtkWidgetType, GtkWidgetState* aState, gint* aWidgetFlags); - bool GetExtraSizeForWidget(nsIFrame* aFrame, uint8_t aWidgetType, + bool GetExtraSizeForWidget(nsIFrame* aFrame, WidgetType aWidgetType, nsIntMargin* aExtra); void RefreshWidgetWindow(nsIFrame* aFrame); - WidgetNodeType NativeThemeToGtkTheme(uint8_t aWidgetType, nsIFrame* aFrame); + WidgetNodeType NativeThemeToGtkTheme(WidgetType aWidgetType, nsIFrame* aFrame); - uint8_t mDisabledWidgetTypes[(ThemeWidgetType_COUNT + 7) / 8]; - uint8_t mSafeWidgetStates[ThemeWidgetType_COUNT * 4]; // 32 bits per widget + uint8_t mDisabledWidgetTypes[(static_cast<size_t>(mozilla::StyleAppearance::Count) + 7) / 8]; + uint8_t mSafeWidgetStates[static_cast<size_t>(mozilla::StyleAppearance::Count) * 4]; // 32 bits per widget static const char* sDisabledEngines[]; // Because moz_gtk_get_widget_border can be slow, we cache its results // by widget type. Each bit in mBorderCacheValid says whether the // corresponding entry in mBorderCache is valid. - void GetCachedWidgetBorder(nsIFrame* aFrame, uint8_t aWidgetType, + void GetCachedWidgetBorder(nsIFrame* aFrame, WidgetType aWidgetType, GtkTextDirection aDirection, LayoutDeviceIntMargin* aResult); uint8_t mBorderCacheValid[(MOZ_GTK_WIDGET_NODE_COUNT + 7) / 8]; LayoutDeviceIntMargin mBorderCache[MOZ_GTK_WIDGET_NODE_COUNT]; }; #endif
--- a/widget/headless/HeadlessThemeGTK.cpp +++ b/widget/headless/HeadlessThemeGTK.cpp @@ -1,308 +1,314 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "HeadlessThemeGTK.h" -#include "nsThemeConstants.h" +#include "nsStyleConsts.h" #include "nsIFrame.h" namespace mozilla { namespace widget { NS_IMPL_ISUPPORTS_INHERITED(HeadlessThemeGTK, nsNativeTheme, nsITheme) NS_IMETHODIMP HeadlessThemeGTK::DrawWidgetBackground(gfxContext* aContext, nsIFrame* aFrame, - uint8_t aWidgetType, + WidgetType aWidgetType, const nsRect& aRect, const nsRect& aDirtyRect) { return NS_OK; } LayoutDeviceIntMargin HeadlessThemeGTK::GetWidgetBorder(nsDeviceContext* aContext, nsIFrame* aFrame, - uint8_t aWidgetType) + WidgetType aWidgetType) { LayoutDeviceIntMargin result; // The following values are generated from the Ubuntu GTK theme. switch (aWidgetType) { - case NS_THEME_BUTTON: - case NS_THEME_TOOLBARBUTTON: + case StyleAppearance::Button: + case StyleAppearance::Toolbarbutton: result.top = 6; result.right = 7; result.bottom = 6; result.left = 7; break; - case NS_THEME_FOCUS_OUTLINE: - case NS_THEME_NUMBER_INPUT: - case NS_THEME_TEXTFIELD: + case StyleAppearance::FocusOutline: + case StyleAppearance::NumberInput: + case StyleAppearance::Textfield: result.top = 5; result.right = 7; result.bottom = 5; result.left = 7; break; - case NS_THEME_STATUSBARPANEL: - case NS_THEME_RESIZERPANEL: - case NS_THEME_LISTBOX: - case NS_THEME_TREEVIEW: - case NS_THEME_TREEHEADERSORTARROW: - case NS_THEME_PROGRESSBAR: - case NS_THEME_PROGRESSBAR_VERTICAL: - case NS_THEME_SPINNER_UPBUTTON: - case NS_THEME_SPINNER_DOWNBUTTON: - case NS_THEME_SPINNER_TEXTFIELD: - case NS_THEME_TEXTFIELD_MULTILINE: - case NS_THEME_MENUPOPUP: - case NS_THEME_GTK_INFO_BAR: + case StyleAppearance::Statusbarpanel: + case StyleAppearance::Resizerpanel: + case StyleAppearance::Listbox: + case StyleAppearance::Treeview: + case StyleAppearance::Treeheadersortarrow: + case StyleAppearance::Progressbar: + case StyleAppearance::ProgressbarVertical: + case StyleAppearance::SpinnerUpbutton: + case StyleAppearance::SpinnerDownbutton: + case StyleAppearance::SpinnerTextfield: + case StyleAppearance::TextfieldMultiline: + case StyleAppearance::Menupopup: + case StyleAppearance::MozGtkInfoBar: result.top = 1; result.right = 1; result.bottom = 1; result.left = 1; break; - case NS_THEME_TREEHEADERCELL: + case StyleAppearance::Treeheadercell: result.top = 5; result.right = 7; result.bottom = 6; result.left = 6; break; - case NS_THEME_TAB: + case StyleAppearance::Tab: result.top = 4; result.right = 7; result.bottom = 2; result.left = 7; break; - case NS_THEME_TOOLTIP: + case StyleAppearance::Tooltip: result.top = 6; result.right = 6; result.bottom = 6; result.left = 6; break; - case NS_THEME_MENULIST: + case StyleAppearance::Menulist: result.top = 6; result.right = 22; result.bottom = 6; result.left = 7; break; - case NS_THEME_MENULIST_BUTTON: + case StyleAppearance::MenulistButton: result.top = 1; result.right = 1; result.bottom = 1; result.left = 0; break; - case NS_THEME_MENULIST_TEXTFIELD: + case StyleAppearance::MenulistTextfield: result.top = 1; result.right = 0; result.bottom = 1; result.left = 1; break; - case NS_THEME_MENUITEM: - case NS_THEME_CHECKMENUITEM: - case NS_THEME_RADIOMENUITEM: + case StyleAppearance::Menuitem: + case StyleAppearance::Checkmenuitem: + case StyleAppearance::Radiomenuitem: if (IsRegularMenuItem(aFrame)) { break; } result.top = 3; result.right = 5; result.bottom = 3; result.left = 5; break; + default: + break; } return result; } bool HeadlessThemeGTK::GetWidgetPadding(nsDeviceContext* aContext, - nsIFrame* aFrame, uint8_t aWidgetType, + nsIFrame* aFrame, WidgetType aWidgetType, LayoutDeviceIntMargin* aResult) { // The following values are generated from the Ubuntu GTK theme. switch (aWidgetType) { - case NS_THEME_RADIO: - case NS_THEME_CHECKBOX: - case NS_THEME_TOOLBARBUTTON: - case NS_THEME_DUALBUTTON: - case NS_THEME_TOOLBARBUTTON_DROPDOWN: - case NS_THEME_BUTTON_ARROW_UP: - case NS_THEME_BUTTON_ARROW_DOWN: - case NS_THEME_BUTTON_ARROW_NEXT: - case NS_THEME_BUTTON_ARROW_PREVIOUS: - case NS_THEME_TAB_SCROLL_ARROW_BACK: - case NS_THEME_TAB_SCROLL_ARROW_FORWARD: - case NS_THEME_MENULIST_BUTTON: - case NS_THEME_RANGE_THUMB: - case NS_THEME_BUTTON_FOCUS: + case StyleAppearance::Radio: + case StyleAppearance::Checkbox: + case StyleAppearance::Toolbarbutton: + case StyleAppearance::Dualbutton: + case StyleAppearance::ToolbarbuttonDropdown: + case StyleAppearance::ButtonArrowUp: + case StyleAppearance::ButtonArrowDown: + case StyleAppearance::ButtonArrowNext: + case StyleAppearance::ButtonArrowPrevious: + case StyleAppearance::TabScrollArrowBack: + case StyleAppearance::TabScrollArrowForward: + case StyleAppearance::MenulistButton: + case StyleAppearance::RangeThumb: + case StyleAppearance::ButtonFocus: aResult->top = 0; aResult->right = 0; aResult->bottom = 0; aResult->left = 0; return true; - case NS_THEME_MENUITEM: - case NS_THEME_CHECKMENUITEM: - case NS_THEME_RADIOMENUITEM: + case StyleAppearance::Menuitem: + case StyleAppearance::Checkmenuitem: + case StyleAppearance::Radiomenuitem: if (!IsRegularMenuItem(aFrame)) { return false; } aResult->top = 3; aResult->right = 5; aResult->bottom = 3; aResult->left = 5; return true; + default: + break; } return false; } NS_IMETHODIMP HeadlessThemeGTK::GetMinimumWidgetSize(nsPresContext* aPresContext, - nsIFrame* aFrame, uint8_t aWidgetType, + nsIFrame* aFrame, WidgetType aWidgetType, LayoutDeviceIntSize* aResult, bool* aIsOverridable) { aResult->width = aResult->height = 0; *aIsOverridable = true; // The following values are generated from the Ubuntu GTK theme. switch (aWidgetType) { - case NS_THEME_SPLITTER: + case StyleAppearance::Splitter: if (IsHorizontal(aFrame)) { aResult->width = 6; aResult->height = 0; } else { aResult->width = 0; aResult->height = 6; } *aIsOverridable = false; break; - case NS_THEME_BUTTON: - case NS_THEME_TOOLBARBUTTON: + case StyleAppearance::Button: + case StyleAppearance::Toolbarbutton: aResult->width = 14; aResult->height = 12; break; - case NS_THEME_RADIO: - case NS_THEME_CHECKBOX: + case StyleAppearance::Radio: + case StyleAppearance::Checkbox: aResult->width = 18; aResult->height = 18; break; - case NS_THEME_TOOLBARBUTTON_DROPDOWN: - case NS_THEME_BUTTON_ARROW_UP: - case NS_THEME_BUTTON_ARROW_DOWN: - case NS_THEME_BUTTON_ARROW_NEXT: - case NS_THEME_BUTTON_ARROW_PREVIOUS: - case NS_THEME_RESIZER: + case StyleAppearance::ToolbarbuttonDropdown: + case StyleAppearance::ButtonArrowUp: + case StyleAppearance::ButtonArrowDown: + case StyleAppearance::ButtonArrowNext: + case StyleAppearance::ButtonArrowPrevious: + case StyleAppearance::Resizer: aResult->width = 15; aResult->height = 15; *aIsOverridable = false; break; - case NS_THEME_SEPARATOR: + case StyleAppearance::Separator: aResult->width = 12; aResult->height = 0; break; - case NS_THEME_TREETWISTY: - case NS_THEME_TREETWISTYOPEN: + case StyleAppearance::Treetwisty: + case StyleAppearance::Treetwistyopen: aResult->width = 8; aResult->height = 8; *aIsOverridable = false; break; - case NS_THEME_TREEHEADERCELL: + case StyleAppearance::Treeheadercell: aResult->width = 13; aResult->height = 11; break; - case NS_THEME_TREEHEADERSORTARROW: - case NS_THEME_SPINNER_UPBUTTON: - case NS_THEME_SPINNER_DOWNBUTTON: + case StyleAppearance::Treeheadersortarrow: + case StyleAppearance::SpinnerUpbutton: + case StyleAppearance::SpinnerDownbutton: aResult->width = 14; aResult->height = 13; break; - case NS_THEME_TAB_SCROLL_ARROW_BACK: - case NS_THEME_TAB_SCROLL_ARROW_FORWARD: + case StyleAppearance::TabScrollArrowBack: + case StyleAppearance::TabScrollArrowForward: aResult->width = 16; aResult->height = 16; *aIsOverridable = false; break; - case NS_THEME_INNER_SPIN_BUTTON: - case NS_THEME_SPINNER: + case StyleAppearance::InnerSpinButton: + case StyleAppearance::Spinner: aResult->width = 14; aResult->height = 26; break; - case NS_THEME_NUMBER_INPUT: - case NS_THEME_TEXTFIELD: + case StyleAppearance::NumberInput: + case StyleAppearance::Textfield: aResult->width = 0; aResult->height = 12; break; - case NS_THEME_SCROLLBAR_HORIZONTAL: + case StyleAppearance::ScrollbarHorizontal: aResult->width = 31; aResult->height = 10; break; - case NS_THEME_SCROLLBAR_VERTICAL: + case StyleAppearance::ScrollbarVertical: aResult->width = 10; aResult->height = 31; break; - case NS_THEME_SCROLLBARBUTTON_UP: - case NS_THEME_SCROLLBARBUTTON_DOWN: + case StyleAppearance::ScrollbarbuttonUp: + case StyleAppearance::ScrollbarbuttonDown: aResult->width = 10; aResult->height = 13; *aIsOverridable = false; break; - case NS_THEME_SCROLLBARBUTTON_LEFT: - case NS_THEME_SCROLLBARBUTTON_RIGHT: + case StyleAppearance::ScrollbarbuttonLeft: + case StyleAppearance::ScrollbarbuttonRight: aResult->width = 13; aResult->height = 10; *aIsOverridable = false; break; - case NS_THEME_SCROLLBARTHUMB_HORIZONTAL: + case StyleAppearance::ScrollbarthumbHorizontal: aResult->width = 31; aResult->height = 10; *aIsOverridable = false; break; - case NS_THEME_SCROLLBARTHUMB_VERTICAL: + case StyleAppearance::ScrollbarthumbVertical: aResult->width = 10; aResult->height = 31; *aIsOverridable = false; break; - case NS_THEME_MENULIST: + case StyleAppearance::Menulist: aResult->width = 44; aResult->height = 27; break; - case NS_THEME_MENULIST_BUTTON: + case StyleAppearance::MenulistButton: aResult->width = 29; aResult->height = 28; *aIsOverridable = false; break; - case NS_THEME_SCALETHUMB_HORIZONTAL: - case NS_THEME_RANGE_THUMB: + case StyleAppearance::ScalethumbHorizontal: + case StyleAppearance::RangeThumb: aResult->width = 14; aResult->height = 18; *aIsOverridable = false; break; - case NS_THEME_SCALETHUMB_VERTICAL: + case StyleAppearance::ScalethumbVertical: aResult->width = 18; aResult->height = 13; *aIsOverridable = false; break; - case NS_THEME_RANGE: + case StyleAppearance::Range: aResult->width = 14; aResult->height = 18; break; - case NS_THEME_MENUSEPARATOR: + case StyleAppearance::Menuseparator: aResult->width = 0; aResult->height = 8; *aIsOverridable = false; break; + default: + break; } return NS_OK; } NS_IMETHODIMP -HeadlessThemeGTK::WidgetStateChanged(nsIFrame* aFrame, uint8_t aWidgetType, +HeadlessThemeGTK::WidgetStateChanged(nsIFrame* aFrame, WidgetType aWidgetType, nsAtom* aAttribute, bool* aShouldRepaint, const nsAttrValue* aOldValue) { return NS_OK; } NS_IMETHODIMP HeadlessThemeGTK::ThemeChanged() @@ -316,129 +322,131 @@ static bool IsFrameContentNodeInNamespac if (!content) return false; return content->IsInNamespace(aNamespace); } NS_IMETHODIMP_(bool) HeadlessThemeGTK::ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* aFrame, - uint8_t aWidgetType) + WidgetType aWidgetType) { switch (aWidgetType) { - case NS_THEME_BUTTON: - case NS_THEME_RADIO: - case NS_THEME_CHECKBOX: - case NS_THEME_FOCUS_OUTLINE: - case NS_THEME_TOOLBOX: - case NS_THEME_TOOLBAR: - case NS_THEME_TOOLBARBUTTON: - case NS_THEME_DUALBUTTON: - case NS_THEME_TOOLBARBUTTON_DROPDOWN: - case NS_THEME_BUTTON_ARROW_UP: - case NS_THEME_BUTTON_ARROW_DOWN: - case NS_THEME_BUTTON_ARROW_NEXT: - case NS_THEME_BUTTON_ARROW_PREVIOUS: - case NS_THEME_SEPARATOR: - case NS_THEME_TOOLBARGRIPPER: - case NS_THEME_SPLITTER: - case NS_THEME_STATUSBAR: - case NS_THEME_STATUSBARPANEL: - case NS_THEME_RESIZERPANEL: - case NS_THEME_RESIZER: - case NS_THEME_LISTBOX: - case NS_THEME_TREEVIEW: - case NS_THEME_TREETWISTY: - case NS_THEME_TREEHEADERCELL: - case NS_THEME_TREEHEADERSORTARROW: - case NS_THEME_TREETWISTYOPEN: - case NS_THEME_PROGRESSBAR: - case NS_THEME_PROGRESSCHUNK: - case NS_THEME_PROGRESSBAR_VERTICAL: - case NS_THEME_PROGRESSCHUNK_VERTICAL: - case NS_THEME_TAB: - case NS_THEME_TABPANELS: - case NS_THEME_TAB_SCROLL_ARROW_BACK: - case NS_THEME_TAB_SCROLL_ARROW_FORWARD: - case NS_THEME_TOOLTIP: - case NS_THEME_INNER_SPIN_BUTTON: - case NS_THEME_SPINNER: - case NS_THEME_SPINNER_UPBUTTON: - case NS_THEME_SPINNER_DOWNBUTTON: - case NS_THEME_SPINNER_TEXTFIELD: - case NS_THEME_NUMBER_INPUT: - case NS_THEME_SCROLLBAR_HORIZONTAL: - case NS_THEME_SCROLLBAR_VERTICAL: - case NS_THEME_SCROLLBARBUTTON_UP: - case NS_THEME_SCROLLBARBUTTON_DOWN: - case NS_THEME_SCROLLBARBUTTON_LEFT: - case NS_THEME_SCROLLBARBUTTON_RIGHT: - case NS_THEME_SCROLLBARTRACK_HORIZONTAL: - case NS_THEME_SCROLLBARTRACK_VERTICAL: - case NS_THEME_SCROLLBARTHUMB_HORIZONTAL: - case NS_THEME_SCROLLBARTHUMB_VERTICAL: - case NS_THEME_TEXTFIELD: - case NS_THEME_TEXTFIELD_MULTILINE: - case NS_THEME_MENULIST: - case NS_THEME_MENULIST_TEXT: - case NS_THEME_MENULIST_TEXTFIELD: - case NS_THEME_SCALE_HORIZONTAL: - case NS_THEME_SCALE_VERTICAL: - case NS_THEME_SCALETHUMB_HORIZONTAL: - case NS_THEME_SCALETHUMB_VERTICAL: - case NS_THEME_RANGE: - case NS_THEME_RANGE_THUMB: - case NS_THEME_CHECKBOX_CONTAINER: - case NS_THEME_RADIO_CONTAINER: - case NS_THEME_CHECKBOX_LABEL: - case NS_THEME_RADIO_LABEL: - case NS_THEME_BUTTON_FOCUS: - case NS_THEME_WINDOW: - case NS_THEME_DIALOG: - case NS_THEME_MENUBAR: - case NS_THEME_MENUPOPUP: - case NS_THEME_MENUITEM: - case NS_THEME_CHECKMENUITEM: - case NS_THEME_RADIOMENUITEM: - case NS_THEME_MENUSEPARATOR: - case NS_THEME_MENUARROW: - case NS_THEME_GTK_INFO_BAR: + case StyleAppearance::Button: + case StyleAppearance::Radio: + case StyleAppearance::Checkbox: + case StyleAppearance::FocusOutline: + case StyleAppearance::Toolbox: + case StyleAppearance::Toolbar: + case StyleAppearance::Toolbarbutton: + case StyleAppearance::Dualbutton: + case StyleAppearance::ToolbarbuttonDropdown: + case StyleAppearance::ButtonArrowUp: + case StyleAppearance::ButtonArrowDown: + case StyleAppearance::ButtonArrowNext: + case StyleAppearance::ButtonArrowPrevious: + case StyleAppearance::Separator: + case StyleAppearance::Toolbargripper: + case StyleAppearance::Splitter: + case StyleAppearance::Statusbar: + case StyleAppearance::Statusbarpanel: + case StyleAppearance::Resizerpanel: + case StyleAppearance::Resizer: + case StyleAppearance::Listbox: + case StyleAppearance::Treeview: + case StyleAppearance::Treetwisty: + case StyleAppearance::Treeheadercell: + case StyleAppearance::Treeheadersortarrow: + case StyleAppearance::Treetwistyopen: + case StyleAppearance::Progressbar: + case StyleAppearance::Progresschunk: + case StyleAppearance::ProgressbarVertical: + case StyleAppearance::ProgresschunkVertical: + case StyleAppearance::Tab: + case StyleAppearance::Tabpanels: + case StyleAppearance::TabScrollArrowBack: + case StyleAppearance::TabScrollArrowForward: + case StyleAppearance::Tooltip: + case StyleAppearance::InnerSpinButton: + case StyleAppearance::Spinner: + case StyleAppearance::SpinnerUpbutton: + case StyleAppearance::SpinnerDownbutton: + case StyleAppearance::SpinnerTextfield: + case StyleAppearance::NumberInput: + case StyleAppearance::ScrollbarHorizontal: + case StyleAppearance::ScrollbarVertical: + case StyleAppearance::ScrollbarbuttonUp: + case StyleAppearance::ScrollbarbuttonDown: + case StyleAppearance::ScrollbarbuttonLeft: + case StyleAppearance::ScrollbarbuttonRight: + case StyleAppearance::ScrollbartrackHorizontal: + case StyleAppearance::ScrollbartrackVertical: + case StyleAppearance::ScrollbarthumbHorizontal: + case StyleAppearance::ScrollbarthumbVertical: + case StyleAppearance::Textfield: + case StyleAppearance::TextfieldMultiline: + case StyleAppearance::Menulist: + case StyleAppearance::MenulistText: + case StyleAppearance::MenulistTextfield: + case StyleAppearance::ScaleHorizontal: + case StyleAppearance::ScaleVertical: + case StyleAppearance::ScalethumbHorizontal: + case StyleAppearance::ScalethumbVertical: + case StyleAppearance::Range: + case StyleAppearance::RangeThumb: + case StyleAppearance::CheckboxContainer: + case StyleAppearance::RadioContainer: + case StyleAppearance::CheckboxLabel: + case StyleAppearance::RadioLabel: + case StyleAppearance::ButtonFocus: + case StyleAppearance::Window: + case StyleAppearance::Dialog: + case StyleAppearance::Menubar: + case StyleAppearance::Menupopup: + case StyleAppearance::Menuitem: + case StyleAppearance::Checkmenuitem: + case StyleAppearance::Radiomenuitem: + case StyleAppearance::Menuseparator: + case StyleAppearance::Menuarrow: + case StyleAppearance::MozGtkInfoBar: return !IsWidgetStyled(aPresContext, aFrame, aWidgetType); - case NS_THEME_MENULIST_BUTTON: + case StyleAppearance::MenulistButton: return (!aFrame || IsFrameContentNodeInNamespace(aFrame, kNameSpaceID_XUL)) && !IsWidgetStyled(aPresContext, aFrame, aWidgetType); + default: + break; } return false; } NS_IMETHODIMP_(bool) -HeadlessThemeGTK::WidgetIsContainer(uint8_t aWidgetType) +HeadlessThemeGTK::WidgetIsContainer(WidgetType aWidgetType) { - if (aWidgetType == NS_THEME_MENULIST_BUTTON || - aWidgetType == NS_THEME_RADIO || - aWidgetType == NS_THEME_RANGE_THUMB || - aWidgetType == NS_THEME_CHECKBOX || - aWidgetType == NS_THEME_TAB_SCROLL_ARROW_BACK || - aWidgetType == NS_THEME_TAB_SCROLL_ARROW_FORWARD || - aWidgetType == NS_THEME_BUTTON_ARROW_UP || - aWidgetType == NS_THEME_BUTTON_ARROW_DOWN || - aWidgetType == NS_THEME_BUTTON_ARROW_NEXT || - aWidgetType == NS_THEME_BUTTON_ARROW_PREVIOUS) { + if (aWidgetType == StyleAppearance::MenulistButton || + aWidgetType == StyleAppearance::Radio || + aWidgetType == StyleAppearance::RangeThumb || + aWidgetType == StyleAppearance::Checkbox || + aWidgetType == StyleAppearance::TabScrollArrowBack || + aWidgetType == StyleAppearance::TabScrollArrowForward || + aWidgetType == StyleAppearance::ButtonArrowUp || + aWidgetType == StyleAppearance::ButtonArrowDown || + aWidgetType == StyleAppearance::ButtonArrowNext || + aWidgetType == StyleAppearance::ButtonArrowPrevious) { return false; } return true; } bool -HeadlessThemeGTK::ThemeDrawsFocusForWidget(uint8_t aWidgetType) +HeadlessThemeGTK::ThemeDrawsFocusForWidget(WidgetType aWidgetType) { - if (aWidgetType == NS_THEME_MENULIST || - aWidgetType == NS_THEME_BUTTON || - aWidgetType == NS_THEME_TREEHEADERCELL) { + if (aWidgetType == StyleAppearance::Menulist || + aWidgetType == StyleAppearance::Button || + aWidgetType == StyleAppearance::Treeheadercell) { return true; } return false; } bool HeadlessThemeGTK::ThemeNeedsComboboxDropmarker() {
--- a/widget/headless/HeadlessThemeGTK.h +++ b/widget/headless/HeadlessThemeGTK.h @@ -14,47 +14,47 @@ namespace widget { class HeadlessThemeGTK final : private nsNativeTheme, public nsITheme { public: NS_DECL_ISUPPORTS_INHERITED HeadlessThemeGTK() = default; NS_IMETHOD DrawWidgetBackground(gfxContext* aContext, - nsIFrame* aFrame, uint8_t aWidgetType, + nsIFrame* aFrame, WidgetType aWidgetType, const nsRect& aRect, const nsRect& aDirtyRect) override; MOZ_MUST_USE LayoutDeviceIntMargin GetWidgetBorder(nsDeviceContext* aContext, nsIFrame* aFrame, - uint8_t aWidgetType) override; + WidgetType aWidgetType) override; bool GetWidgetPadding(nsDeviceContext* aContext, nsIFrame* aFrame, - uint8_t aWidgetType, + WidgetType aWidgetType, LayoutDeviceIntMargin* aResult) override; NS_IMETHOD GetMinimumWidgetSize(nsPresContext* aPresContext, - nsIFrame* aFrame, uint8_t aWidgetType, + nsIFrame* aFrame, WidgetType aWidgetType, mozilla::LayoutDeviceIntSize* aResult, bool* aIsOverridable) override; - NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, uint8_t aWidgetType, + NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, WidgetType aWidgetType, nsAtom* aAttribute, bool* aShouldRepaint, const nsAttrValue* aOldValue) override; NS_IMETHOD ThemeChanged() override; NS_IMETHOD_(bool) ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* aFrame, - uint8_t aWidgetType) override; + WidgetType aWidgetType) override; - NS_IMETHOD_(bool) WidgetIsContainer(uint8_t aWidgetType) override; + NS_IMETHOD_(bool) WidgetIsContainer(WidgetType aWidgetType) override; - NS_IMETHOD_(bool) ThemeDrawsFocusForWidget(uint8_t aWidgetType) override; + NS_IMETHOD_(bool) ThemeDrawsFocusForWidget(WidgetType aWidgetType) override; virtual bool ThemeNeedsComboboxDropmarker() override; protected: virtual ~HeadlessThemeGTK() { } }; } // namespace widget
--- a/widget/nsIWidget.h +++ b/widget/nsIWidget.h @@ -1300,17 +1300,17 @@ class nsIWidget : public nsISupports */ virtual void AddWindowOverlayWebRenderCommands(mozilla::layers::WebRenderBridgeChild* aWrBridge, mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources) {} /** * Called when Gecko knows which themed widgets exist in this window. * The passed array contains an entry for every themed widget of the right - * type (currently only NS_THEME_TOOLBAR) within the window, except for + * type (currently only StyleAppearance::Toolbar) within the window, except for * themed widgets which are transformed or have effects applied to them * (e.g. CSS opacity or filters). * This could sometimes be called during display list construction * outside of painting. * If called during painting, it will be called before we actually * paint anything. */ virtual void UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries) = 0;
--- a/widget/nsNativeTheme.cpp +++ b/widget/nsNativeTheme.cpp @@ -9,17 +9,17 @@ #include "nsIContent.h" #include "nsIFrame.h" #include "nsIPresShell.h" #include "nsNumberControlFrame.h" #include "nsPresContext.h" #include "nsString.h" #include "nsNameSpaceManager.h" #include "nsIDOMXULMenuListElement.h" -#include "nsThemeConstants.h" +#include "nsStyleConsts.h" #include "nsIComponentManager.h" #include "nsPIDOMWindow.h" #include "nsProgressFrame.h" #include "nsMeterFrame.h" #include "nsMenuFrame.h" #include "nsRangeFrame.h" #include "nsCSSRendering.h" #include "mozilla/EventStates.h" @@ -46,24 +46,24 @@ nsNativeTheme::GetPresShell(nsIFrame* aF if (!aFrame) return nullptr; nsPresContext* context = aFrame->PresContext(); return context ? context->GetPresShell() : nullptr; } EventStates -nsNativeTheme::GetContentState(nsIFrame* aFrame, uint8_t aWidgetType) +nsNativeTheme::GetContentState(nsIFrame* aFrame, StyleAppearance aWidgetType) { if (!aFrame) return EventStates(); - bool isXULCheckboxRadio = - (aWidgetType == NS_THEME_CHECKBOX || - aWidgetType == NS_THEME_RADIO) && + bool isXULCheckboxRadio = + (aWidgetType == StyleAppearance::Checkbox || + aWidgetType == StyleAppearance::Radio) && aFrame->GetContent()->IsXULElement(); if (isXULCheckboxRadio) aFrame = aFrame->GetParent(); if (!aFrame->GetContent()) return EventStates(); nsIPresShell *shell = GetPresShell(aFrame); @@ -72,54 +72,54 @@ nsNativeTheme::GetContentState(nsIFrame* nsIContent* frameContent = aFrame->GetContent(); EventStates flags; if (frameContent->IsElement()) { flags = frameContent->AsElement()->State(); // <input type=number> needs special handling since its nested native // anonymous <input type=text> takes focus for it. - if (aWidgetType == NS_THEME_NUMBER_INPUT && + if (aWidgetType == StyleAppearance::NumberInput && frameContent->IsHTMLElement(nsGkAtoms::input)) { nsNumberControlFrame *numberControlFrame = do_QueryFrame(aFrame); if (numberControlFrame && numberControlFrame->IsFocused()) { flags |= NS_EVENT_STATE_FOCUS; } } nsNumberControlFrame* numberControlFrame = nsNumberControlFrame::GetNumberControlFrameForSpinButton(aFrame); if (numberControlFrame && numberControlFrame->GetContent()->AsElement()->State(). HasState(NS_EVENT_STATE_DISABLED)) { flags |= NS_EVENT_STATE_DISABLED; } } - if (isXULCheckboxRadio && aWidgetType == NS_THEME_RADIO) { + if (isXULCheckboxRadio && aWidgetType == StyleAppearance::Radio) { if (IsFocused(aFrame)) flags |= NS_EVENT_STATE_FOCUS; } // On Windows and Mac, only draw focus rings if they should be shown. This // means that focus rings are only shown once the keyboard has been used to // focus something in the window. #if defined(XP_MACOSX) // Mac always draws focus rings for textboxes and lists. - if (aWidgetType == NS_THEME_NUMBER_INPUT || - aWidgetType == NS_THEME_TEXTFIELD || - aWidgetType == NS_THEME_TEXTFIELD_MULTILINE || - aWidgetType == NS_THEME_SEARCHFIELD || - aWidgetType == NS_THEME_LISTBOX) { + if (aWidgetType == StyleAppearance::NumberInput || + aWidgetType == StyleAppearance::Textfield || + aWidgetType == StyleAppearance::TextfieldMultiline || + aWidgetType == StyleAppearance::Searchfield || + aWidgetType == StyleAppearance::Listbox) { return flags; } #endif #if defined(XP_WIN) // On Windows, focused buttons are always drawn as such by the native theme. - if (aWidgetType == NS_THEME_BUTTON) + if (aWidgetType == StyleAppearance::Button) return flags; #endif #if defined(XP_MACOSX) || defined(XP_WIN) nsIDocument* doc = aFrame->GetContent()->OwnerDoc(); nsPIDOMWindowOuter* window = doc->GetWindow(); if (window && !window->ShouldShowFocusRing()) flags &= ~NS_EVENT_STATE_FOCUS; #endif @@ -231,17 +231,17 @@ nsNativeTheme::IsButtonTypeMenu(nsIFrame content->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type, NS_LITERAL_STRING("menu"), eCaseMatters); } bool nsNativeTheme::IsPressedButton(nsIFrame* aFrame) { - EventStates eventState = GetContentState(aFrame, NS_THEME_TOOLBARBUTTON); + EventStates eventState = GetContentState(aFrame, StyleAppearance::Toolbarbutton); if (IsDisabled(aFrame, eventState)) return false; return IsOpenButton(aFrame) || eventState.HasAllStates(NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_HOVER); } @@ -265,96 +265,96 @@ nsNativeTheme::GetIndeterminate(nsIFrame return inputElt->Indeterminate(); } return false; } bool nsNativeTheme::IsWidgetStyled(nsPresContext* aPresContext, nsIFrame* aFrame, - uint8_t aWidgetType) + StyleAppearance aWidgetType) { // Check for specific widgets to see if HTML has overridden the style. if (!aFrame) return false; // Resizers have some special handling, dependent on whether in a scrollable // container or not. If so, use the scrollable container's to determine // whether the style is overriden instead of the resizer. This allows a // non-native transparent resizer to be used instead. Otherwise, we just // fall through and return false. - if (aWidgetType == NS_THEME_RESIZER) { + if (aWidgetType == StyleAppearance::Resizer) { nsIFrame* parentFrame = aFrame->GetParent(); if (parentFrame && parentFrame->IsScrollFrame()) { // if the parent is a scrollframe, the resizer should be native themed // only if the scrollable area doesn't override the widget style. parentFrame = parentFrame->GetParent(); if (parentFrame) { return IsWidgetStyled(aPresContext, parentFrame, parentFrame->StyleDisplay()->mAppearance); } } } /** * Progress bar appearance should be the same for the bar and the container * frame. nsProgressFrame owns the logic and will tell us what we should do. */ - if (aWidgetType == NS_THEME_PROGRESSCHUNK || - aWidgetType == NS_THEME_PROGRESSBAR) { - nsProgressFrame* progressFrame = do_QueryFrame(aWidgetType == NS_THEME_PROGRESSCHUNK + if (aWidgetType == StyleAppearance::Progresschunk || + aWidgetType == StyleAppearance::Progressbar) { + nsProgressFrame* progressFrame = do_QueryFrame(aWidgetType == StyleAppearance::Progresschunk ? aFrame->GetParent() : aFrame); if (progressFrame) { return !progressFrame->ShouldUseNativeStyle(); } } /** * Meter bar appearance should be the same for the bar and the container * frame. nsMeterFrame owns the logic and will tell us what we should do. */ - if (aWidgetType == NS_THEME_METERCHUNK || - aWidgetType == NS_THEME_METERBAR) { - nsMeterFrame* meterFrame = do_QueryFrame(aWidgetType == NS_THEME_METERCHUNK + if (aWidgetType == StyleAppearance::Meterchunk || + aWidgetType == StyleAppearance::Meterbar) { + nsMeterFrame* meterFrame = do_QueryFrame(aWidgetType == StyleAppearance::Meterchunk ? aFrame->GetParent() : aFrame); if (meterFrame) { return !meterFrame->ShouldUseNativeStyle(); } } /** * An nsRangeFrame and its children are treated atomically when it * comes to native theming (either all parts, or no parts, are themed). * nsRangeFrame owns the logic and will tell us what we should do. */ - if (aWidgetType == NS_THEME_RANGE || - aWidgetType == NS_THEME_RANGE_THUMB) { + if (aWidgetType == StyleAppearance::Range || + aWidgetType == StyleAppearance::RangeThumb) { nsRangeFrame* rangeFrame = - do_QueryFrame(aWidgetType == NS_THEME_RANGE_THUMB + do_QueryFrame(aWidgetType == StyleAppearance::RangeThumb ? aFrame->GetParent() : aFrame); if (rangeFrame) { return !rangeFrame->ShouldUseNativeStyle(); } } - if (aWidgetType == NS_THEME_SPINNER_UPBUTTON || - aWidgetType == NS_THEME_SPINNER_DOWNBUTTON) { + if (aWidgetType == StyleAppearance::SpinnerUpbutton || + aWidgetType == StyleAppearance::SpinnerDownbutton) { nsNumberControlFrame* numberControlFrame = nsNumberControlFrame::GetNumberControlFrameForSpinButton(aFrame); if (numberControlFrame) { return !numberControlFrame->ShouldUseNativeStyleForSpinner(); } } - return (aWidgetType == NS_THEME_NUMBER_INPUT || - aWidgetType == NS_THEME_BUTTON || - aWidgetType == NS_THEME_TEXTFIELD || - aWidgetType == NS_THEME_TEXTFIELD_MULTILINE || - aWidgetType == NS_THEME_LISTBOX || - aWidgetType == NS_THEME_MENULIST) && + return (aWidgetType == StyleAppearance::NumberInput || + aWidgetType == StyleAppearance::Button || + aWidgetType == StyleAppearance::Textfield || + aWidgetType == StyleAppearance::TextfieldMultiline || + aWidgetType == StyleAppearance::Listbox || + aWidgetType == StyleAppearance::Menulist) && aFrame->GetContent()->IsHTMLElement() && aPresContext->HasAuthorSpecifiedRules(aFrame, NS_AUTHOR_SPECIFIED_BORDER | NS_AUTHOR_SPECIFIED_BACKGROUND); } bool nsNativeTheme::IsDisabled(nsIFrame* aFrame, EventStates aEventStates) @@ -806,30 +806,30 @@ nsNativeTheme::IsDarkBackground(nsIFrame // WebKit does, and we can improve it later if needed. return NS_GET_A(bgColor) > 127 && NS_GET_R(bgColor) + NS_GET_G(bgColor) + NS_GET_B(bgColor) < 384; } return false; } bool -nsNativeTheme::IsWidgetScrollbarPart(uint8_t aWidgetType) +nsNativeTheme::IsWidgetScrollbarPart(StyleAppearance aWidgetType) { switch (aWidgetType) { - case NS_THEME_SCROLLBAR: - case NS_THEME_SCROLLBAR_SMALL: - case NS_THEME_SCROLLBAR_VERTICAL: - case NS_THEME_SCROLLBAR_HORIZONTAL: - case NS_THEME_SCROLLBARBUTTON_UP: - case NS_THEME_SCROLLBARBUTTON_DOWN: - case NS_THEME_SCROLLBARBUTTON_LEFT: - case NS_THEME_SCROLLBARBUTTON_RIGHT: - case NS_THEME_SCROLLBARTHUMB_VERTICAL: - case NS_THEME_SCROLLBARTHUMB_HORIZONTAL: - case NS_THEME_SCROLLCORNER: + case StyleAppearance::Scrollbar: + case StyleAppearance::ScrollbarSmall: + case StyleAppearance::ScrollbarVertical: + case StyleAppearance::ScrollbarHorizontal: + case StyleAppearance::ScrollbarbuttonUp: + case StyleAppearance::ScrollbarbuttonDown: + case StyleAppearance::ScrollbarbuttonLeft: + case StyleAppearance::ScrollbarbuttonRight: + case StyleAppearance::ScrollbarthumbVertical: + case StyleAppearance::ScrollbarthumbHorizontal: + case StyleAppearance::Scrollcorner: return true; default: return false; } } static nscolor GetOpaqueBackgroundColor(ComputedStyle* aStyle)
--- a/widget/nsNativeTheme.h +++ b/widget/nsNativeTheme.h @@ -21,16 +21,17 @@ #include "nsIContent.h" class nsIFrame; class nsIPresShell; class nsPresContext; namespace mozilla { class ComputedStyle; +enum class StyleAppearance : uint8_t; class EventStates; } // namespace mozilla class nsNativeTheme : public nsITimerCallback, public nsINamed { protected: virtual ~nsNativeTheme() {} @@ -48,23 +49,24 @@ class nsNativeTheme : public nsITimerCal eTreeSortDirection_Descending, eTreeSortDirection_Natural, eTreeSortDirection_Ascending }; nsNativeTheme(); // Returns the content state (hover, focus, etc), see EventStateManager.h - mozilla::EventStates GetContentState(nsIFrame* aFrame, uint8_t aWidgetType); + mozilla::EventStates GetContentState(nsIFrame* aFrame, + mozilla::StyleAppearance aWidgetType); // Returns whether the widget is already styled by content // Normally called from ThemeSupportsWidget to turn off native theming // for elements that are already styled. bool IsWidgetStyled(nsPresContext* aPresContext, nsIFrame* aFrame, - uint8_t aWidgetType); + mozilla::StyleAppearance aWidgetType); // Accessors to widget-specific state information bool IsDisabled(nsIFrame* aFrame, mozilla::EventStates aEventStates); // RTL chrome direction static bool IsFrameRTL(nsIFrame* aFrame); @@ -182,17 +184,17 @@ class nsNativeTheme : public nsITimerCal bool aNextSibling); bool IsRangeHorizontal(nsIFrame* aFrame); // scrollbar bool IsDarkBackground(nsIFrame* aFrame); // custom scrollbar typedef nscolor (*AutoColorGetter)(mozilla::ComputedStyle*); - bool IsWidgetScrollbarPart(uint8_t aWidgetType); + bool IsWidgetScrollbarPart(mozilla::StyleAppearance aWidgetType); nscolor GetScrollbarFaceColor(mozilla::ComputedStyle* aStyle, AutoColorGetter aAutoGetter); nscolor GetScrollbarTrackColor(mozilla::ComputedStyle* aStyle, AutoColorGetter aAutoGetter); private: uint32_t mAnimatedContentTimeout; nsCOMPtr<nsITimer> mAnimatedContentTimer;
--- a/widget/windows/nsNativeThemeWin.cpp +++ b/widget/windows/nsNativeThemeWin.cpp @@ -9,17 +9,17 @@ #include "mozilla/Logging.h" #include "mozilla/RelativeLuminanceUtils.h" #include "mozilla/WindowsVersion.h" #include "nsColor.h" #include "nsDeviceContext.h" #include "nsRect.h" #include "nsSize.h" #include "nsTransform2D.h" -#include "nsThemeConstants.h" +#include "nsStyleConsts.h" #include "nsIPresShell.h" #include "nsPresContext.h" #include "nsIContent.h" #include "nsIContentInlines.h" #include "nsIFrame.h" #include "nsLayoutUtils.h" #include "nsNameSpaceManager.h" #include "nsLookAndFeel.h" @@ -555,17 +555,18 @@ nsNativeThemeWin::CalculateProgressOverl * @param aHdc hdc returned by gfxWindowsNativeDrawing * @param aPart the PP_X progress part * @param aState the theme state * @param aWidgetRect bounding rect for the widget * @param aClipRect dirty rect that needs drawing. * @param aAppUnits app units per device pixel */ void -nsNativeThemeWin::DrawThemedProgressMeter(nsIFrame* aFrame, int aWidgetType, +nsNativeThemeWin::DrawThemedProgressMeter(nsIFrame* aFrame, + WidgetType aWidgetType, HANDLE aTheme, HDC aHdc, int aPart, int aState, RECT* aWidgetRect, RECT* aClipRect) { if (!aFrame || !aTheme || !aHdc) return; NS_ASSERTION(aWidgetRect, "bad rect pointer"); @@ -579,17 +580,17 @@ nsNativeThemeWin::DrawThemedProgressMete if (!parentFrame) { // We have no parent to work with, just bail. NS_WARNING("No parent frame for progress rendering. Can't paint."); return; } EventStates eventStates = GetContentState(parentFrame, aWidgetType); bool vertical = IsVerticalProgress(parentFrame) || - aWidgetType == NS_THEME_PROGRESSCHUNK_VERTICAL; + aWidgetType == StyleAppearance::ProgresschunkVertical; bool indeterminate = IsIndeterminateProgress(parentFrame, eventStates); bool animate = indeterminate; // 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)) { @@ -609,17 +610,17 @@ nsNativeThemeWin::DrawThemedProgressMete NS_WARNING("unable to animate progress widget!"); } } } LayoutDeviceIntMargin nsNativeThemeWin::GetCachedWidgetBorder(HTHEME aTheme, nsUXThemeClass aThemeClass, - uint8_t aWidgetType, + WidgetType aWidgetType, int32_t aPart, int32_t aState) { int32_t cacheIndex = aThemeClass * THEME_PART_DISTINCT_VALUE_COUNT + aPart; int32_t cacheBitIndex = cacheIndex / 8; uint8_t cacheBit = 1u << (cacheIndex % 8); if (mBorderCacheValid[cacheBitIndex] & cacheBit) { @@ -647,24 +648,24 @@ nsNativeThemeWin::GetCachedWidgetBorder( mBorderCacheValid[cacheBitIndex] |= cacheBit; mBorderCache[cacheIndex] = result; return result; } nsresult nsNativeThemeWin::GetCachedMinimumWidgetSize(nsIFrame * aFrame, HANDLE aTheme, - nsUXThemeClass aThemeClass, uint8_t aWidgetType, + nsUXThemeClass aThemeClass, WidgetType aWidgetType, int32_t aPart, int32_t aState, THEMESIZE aSizeReq, mozilla::LayoutDeviceIntSize * aResult) { int32_t cachePart = aPart; - if (aWidgetType == NS_THEME_BUTTON && aSizeReq == TS_MIN) { - // In practice, NS_THEME_BUTTON is the only widget type which has an aSizeReq + if (aWidgetType == StyleAppearance::Button && aSizeReq == TS_MIN) { + // In practice, StyleAppearance::Button is the only widget type which has an aSizeReq // that varies for us, and it can only be TS_MIN or TS_TRUE. Just stuff that // extra bit into the aPart part of the cache, since BP_Count is well below // THEME_PART_DISTINCT_VALUE_COUNT anyway. cachePart = BP_Count; } MOZ_ASSERT(aPart < THEME_PART_DISTINCT_VALUE_COUNT); int32_t cacheIndex = aThemeClass * THEME_PART_DISTINCT_VALUE_COUNT + cachePart; @@ -682,180 +683,180 @@ nsresult nsNativeThemeWin::GetCachedMini } SIZE sz; GetThemePartSize(aTheme, hdc, aPart, aState, nullptr, aSizeReq, &sz); aResult->width = sz.cx; aResult->height = sz.cy; switch (aWidgetType) { - case NS_THEME_INNER_SPIN_BUTTON: - case NS_THEME_SPINNER_UPBUTTON: - case NS_THEME_SPINNER_DOWNBUTTON: + case StyleAppearance::InnerSpinButton: + case StyleAppearance::SpinnerUpbutton: + case StyleAppearance::SpinnerDownbutton: aResult->width++; aResult->height = aResult->height / 2 + 1; break; - case NS_THEME_MENUSEPARATOR: + case StyleAppearance::Menuseparator: { SIZE gutterSize(GetGutterSize(aTheme, hdc)); aResult->width += gutterSize.cx; break; } - case NS_THEME_MENUARROW: + case StyleAppearance::Menuarrow: { // Use the width of the arrow glyph as padding. See the drawing // code for details. aResult->width *= 2; break; } } ::ReleaseDC(nullptr, hdc); mMinimumWidgetSizeCacheValid[cacheBitIndex] |= cacheBit; mMinimumWidgetSizeCache[cacheIndex] = *aResult; return NS_OK; } -mozilla::Maybe<nsUXThemeClass> nsNativeThemeWin::GetThemeClass(uint8_t aWidgetType) +mozilla::Maybe<nsUXThemeClass> nsNativeThemeWin::GetThemeClass(WidgetType aWidgetType) { switch (aWidgetType) { - case NS_THEME_BUTTON: - case NS_THEME_RADIO: - case NS_THEME_CHECKBOX: - case NS_THEME_GROUPBOX: + case StyleAppearance::Button: + case StyleAppearance::Radio: + case StyleAppearance::Checkbox: + case StyleAppearance::Groupbox: return Some(eUXButton); - case NS_THEME_NUMBER_INPUT: - case NS_THEME_TEXTFIELD: - case NS_THEME_TEXTFIELD_MULTILINE: - case NS_THEME_FOCUS_OUTLINE: + case StyleAppearance::NumberInput: + case StyleAppearance::Textfield: + case StyleAppearance::TextfieldMultiline: + case StyleAppearance::FocusOutline: return Some(eUXEdit); - case NS_THEME_TOOLTIP: + case StyleAppearance::Tooltip: return Some(eUXTooltip); - case NS_THEME_TOOLBOX: + case StyleAppearance::Toolbox: return Some(eUXRebar); - case NS_THEME_WIN_MEDIA_TOOLBOX: + case StyleAppearance::MozWinMediaToolbox: return Some(eUXMediaRebar); - case NS_THEME_WIN_COMMUNICATIONS_TOOLBOX: + case StyleAppearance::MozWinCommunicationsToolbox: return Some(eUXCommunicationsRebar); - case NS_THEME_WIN_BROWSERTABBAR_TOOLBOX: + case StyleAppearance::MozWinBrowsertabbarToolbox: return Some(eUXBrowserTabBarRebar); - case NS_THEME_TOOLBAR: - case NS_THEME_TOOLBARBUTTON: - case NS_THEME_SEPARATOR: + case StyleAppearance::Toolbar: + case StyleAppearance::Toolbarbutton: + case StyleAppearance::Separator: return Some(eUXToolbar); - case NS_THEME_PROGRESSBAR: - case NS_THEME_PROGRESSBAR_VERTICAL: - case NS_THEME_PROGRESSCHUNK: - case NS_THEME_PROGRESSCHUNK_VERTICAL: + case StyleAppearance::Progressbar: + case StyleAppearance::ProgressbarVertical: + case StyleAppearance::Progresschunk: + case StyleAppearance::ProgresschunkVertical: return Some(eUXProgress); - case NS_THEME_TAB: - case NS_THEME_TABPANEL: - case NS_THEME_TABPANELS: + case StyleAppearance::Tab: + case StyleAppearance::Tabpanel: + case StyleAppearance::Tabpanels: return Some(eUXTab); - case NS_THEME_SCROLLBAR: - case NS_THEME_SCROLLBAR_SMALL: - case NS_THEME_SCROLLBAR_VERTICAL: - case NS_THEME_SCROLLBAR_HORIZONTAL: - case NS_THEME_SCROLLBARBUTTON_UP: - case NS_THEME_SCROLLBARBUTTON_DOWN: - case NS_THEME_SCROLLBARBUTTON_LEFT: - case NS_THEME_SCROLLBARBUTTON_RIGHT: - case NS_THEME_SCROLLBARTHUMB_VERTICAL: - case NS_THEME_SCROLLBARTHUMB_HORIZONTAL: - case NS_THEME_SCROLLCORNER: + case StyleAppearance::Scrollbar: + case StyleAppearance::ScrollbarSmall: + case StyleAppearance::ScrollbarVertical: + case StyleAppearance::ScrollbarHorizontal: + case StyleAppearance::ScrollbarbuttonUp: + case StyleAppearance::ScrollbarbuttonDown: + case StyleAppearance::ScrollbarbuttonLeft: + case StyleAppearance::ScrollbarbuttonRight: + case StyleAppearance::ScrollbarthumbVertical: + case StyleAppearance::ScrollbarthumbHorizontal: + case StyleAppearance::Scrollcorner: return Some(eUXScrollbar); - case NS_THEME_RANGE: - case NS_THEME_RANGE_THUMB: - case NS_THEME_SCALE_HORIZONTAL: - case NS_THEME_SCALE_VERTICAL: - case NS_THEME_SCALETHUMB_HORIZONTAL: - case NS_THEME_SCALETHUMB_VERTICAL: + case StyleAppearance::Range: + case StyleAppearance::RangeThumb: + case StyleAppearance::ScaleHorizontal: + case StyleAppearance::ScaleVertical: + case StyleAppearance::ScalethumbHorizontal: + case StyleAppearance::ScalethumbVertical: return Some(eUXTrackbar); - case NS_THEME_INNER_SPIN_BUTTON: - case NS_THEME_SPINNER_UPBUTTON: - case NS_THEME_SPINNER_DOWNBUTTON: + case StyleAppearance::InnerSpinButton: + case StyleAppearance::SpinnerUpbutton: + case StyleAppearance::SpinnerDownbutton: return Some(eUXSpin); - case NS_THEME_STATUSBAR: - case NS_THEME_STATUSBARPANEL: - case NS_THEME_RESIZERPANEL: - case NS_THEME_RESIZER: + case StyleAppearance::Statusbar: + case StyleAppearance::Statusbarpanel: + case StyleAppearance::Resizerpanel: + case StyleAppearance::Resizer: return Some(eUXStatus); - case NS_THEME_MENULIST: - case NS_THEME_MENULIST_BUTTON: + case StyleAppearance::Menulist: + case StyleAppearance::MenulistButton: return Some(eUXCombobox); - case NS_THEME_TREEHEADERCELL: - case NS_THEME_TREEHEADERSORTARROW: + case StyleAppearance::Treeheadercell: + case StyleAppearance::Treeheadersortarrow: return Some(eUXHeader); - case NS_THEME_LISTBOX: - case NS_THEME_LISTITEM: - case NS_THEME_TREEVIEW: - case NS_THEME_TREETWISTYOPEN: - case NS_THEME_TREEITEM: + case StyleAppearance::Listbox: + case StyleAppearance::Listitem: + case StyleAppearance::Treeview: + case StyleAppearance::Treetwistyopen: + case StyleAppearance::Treeitem: return Some(eUXListview); - case NS_THEME_MENUBAR: - case NS_THEME_MENUPOPUP: - case NS_THEME_MENUITEM: - case NS_THEME_CHECKMENUITEM: - case NS_THEME_RADIOMENUITEM: - case NS_THEME_MENUCHECKBOX: - case NS_THEME_MENURADIO: - case NS_THEME_MENUSEPARATOR: - case NS_THEME_MENUARROW: - case NS_THEME_MENUIMAGE: - case NS_THEME_MENUITEMTEXT: + case StyleAppearance::Menubar: + case StyleAppearance::Menupopup: + case StyleAppearance::Menuitem: + case StyleAppearance::Checkmenuitem: + case StyleAppearance::Radiomenuitem: + case StyleAppearance::Menucheckbox: + case StyleAppearance::Menuradio: + case StyleAppearance::Menuseparator: + case StyleAppearance::Menuarrow: + case StyleAppearance::Menuimage: + case StyleAppearance::Menuitemtext: return Some(eUXMenu); - case NS_THEME_WINDOW_TITLEBAR: - case NS_THEME_WINDOW_TITLEBAR_MAXIMIZED: - case NS_THEME_WINDOW_FRAME_LEFT: - case NS_THEME_WINDOW_FRAME_RIGHT: - case NS_THEME_WINDOW_FRAME_BOTTOM: - case NS_THEME_WINDOW_BUTTON_CLOSE: - case NS_THEME_WINDOW_BUTTON_MINIMIZE: - case NS_THEME_WINDOW_BUTTON_MAXIMIZE: - case NS_THEME_WINDOW_BUTTON_RESTORE: - case NS_THEME_WINDOW_BUTTON_BOX: - case NS_THEME_WINDOW_BUTTON_BOX_MAXIMIZED: - case NS_THEME_WIN_GLASS: - case NS_THEME_WIN_BORDERLESS_GLASS: + case StyleAppearance::MozWindowTitlebar: + case StyleAppearance::MozWindowTitlebarMaximized: + case StyleAppearance::MozWindowFrameLeft: + case StyleAppearance::MozWindowFrameRight: + case StyleAppearance::MozWindowFrameBottom: + case StyleAppearance::MozWindowButtonClose: + case StyleAppearance::MozWindowButtonMinimize: + case StyleAppearance::MozWindowButtonMaximize: + case StyleAppearance::MozWindowButtonRestore: + case StyleAppearance::MozWindowButtonBox: + case StyleAppearance::MozWindowButtonBoxMaximized: + case StyleAppearance::MozWinGlass: + case StyleAppearance::MozWinBorderlessGlass: return Some(eUXWindowFrame); } return Nothing(); } HANDLE -nsNativeThemeWin::GetTheme(uint8_t aWidgetType) +nsNativeThemeWin::GetTheme(WidgetType aWidgetType) { mozilla::Maybe<nsUXThemeClass> themeClass = GetThemeClass(aWidgetType); if (themeClass.isNothing()) { return nullptr; } return nsUXThemeData::GetTheme(themeClass.value()); } int32_t -nsNativeThemeWin::StandardGetState(nsIFrame* aFrame, uint8_t aWidgetType, +nsNativeThemeWin::StandardGetState(nsIFrame* aFrame, WidgetType aWidgetType, bool wantFocused) { EventStates eventState = GetContentState(aFrame, aWidgetType); if (eventState.HasAllStates(NS_EVENT_STATE_HOVER | NS_EVENT_STATE_ACTIVE)) return TS_ACTIVE; if (eventState.HasState(NS_EVENT_STATE_HOVER)) return TS_HOVER; if (wantFocused && eventState.HasState(NS_EVENT_STATE_FOCUS)) return TS_FOCUSED; return TS_NORMAL; } bool -nsNativeThemeWin::IsMenuActive(nsIFrame *aFrame, uint8_t aWidgetType) +nsNativeThemeWin::IsMenuActive(nsIFrame *aFrame, WidgetType aWidgetType) { nsIContent* content = aFrame->GetContent(); if (content->IsXULElement() && content->NodeInfo()->Equals(nsGkAtoms::richlistitem)) return CheckBooleanAttr(aFrame, nsGkAtoms::selected); return CheckBooleanAttr(aFrame, nsGkAtoms::menuactive); } @@ -863,21 +864,21 @@ nsNativeThemeWin::IsMenuActive(nsIFrame /** * aPart is filled in with the UXTheme part code. On return, values > 0 * are the actual UXTheme part code; -1 means the widget will be drawn by * us; 0 means that we should use part code 0, which isn't a real part code * but elicits some kind of default behaviour from UXTheme when drawing * (but isThemeBackgroundPartiallyTransparent may not work). */ nsresult -nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType, +nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, WidgetType aWidgetType, int32_t& aPart, int32_t& aState) { switch (aWidgetType) { - case NS_THEME_BUTTON: { + case StyleAppearance::Button: { aPart = BP_BUTTON; if (!aFrame) { aState = TS_NORMAL; return NS_OK; } EventStates eventState = GetContentState(aFrame, aWidgetType); if (IsDisabled(aFrame, eventState)) { @@ -892,19 +893,19 @@ nsNativeThemeWin::GetThemePartAndState(n aState = StandardGetState(aFrame, aWidgetType, true); // Check for default dialog buttons. These buttons should always look // focused. if (aState == TS_NORMAL && IsDefaultButton(aFrame)) aState = TS_FOCUSED; return NS_OK; } - case NS_THEME_CHECKBOX: - case NS_THEME_RADIO: { - bool isCheckbox = (aWidgetType == NS_THEME_CHECKBOX); + case StyleAppearance::Checkbox: + case StyleAppearance::Radio: { + bool isCheckbox = (aWidgetType == StyleAppearance::Checkbox); aPart = isCheckbox ? BP_CHECKBOX : BP_RADIO; enum InputState { UNCHECKED = 0, CHECKED, INDETERMINATE }; InputState inputState = UNCHECKED; bool isXULCheckboxRadio = false; @@ -926,26 +927,26 @@ nsNativeThemeWin::GetThemePartAndState(n aState = StandardGetState(aFrame, aWidgetType, false); } } // 4 unchecked states, 4 checked states, 4 indeterminate states. aState += inputState * 4; return NS_OK; } - case NS_THEME_GROUPBOX: { + case StyleAppearance::Groupbox: { aPart = BP_GROUPBOX; aState = TS_NORMAL; // Since we don't support groupbox disabled and GBS_DISABLED looks the // same as GBS_NORMAL don't bother supporting GBS_DISABLED. return NS_OK; } - case NS_THEME_NUMBER_INPUT: - case NS_THEME_TEXTFIELD: - case NS_THEME_TEXTFIELD_MULTILINE: { + case StyleAppearance::NumberInput: + case StyleAppearance::Textfield: + case StyleAppearance::TextfieldMultiline: { EventStates eventState = GetContentState(aFrame, aWidgetType); /* 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. */ @@ -971,52 +972,52 @@ nsNativeThemeWin::GetThemePartAndState(n else if (eventState.HasState(NS_EVENT_STATE_HOVER)) aState = TFS_EDITBORDER_HOVER; else aState = TFS_EDITBORDER_NORMAL; } return NS_OK; } - case NS_THEME_FOCUS_OUTLINE: { + case StyleAppearance::FocusOutline: { // 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: { + case StyleAppearance::Tooltip: { aPart = TTP_STANDARD; aState = TS_NORMAL; return NS_OK; } - case NS_THEME_PROGRESSBAR: - case NS_THEME_PROGRESSBAR_VERTICAL: { + case StyleAppearance::Progressbar: + case StyleAppearance::ProgressbarVertical: { // Note IsVerticalProgress only tests for orient css attrribute, - // NS_THEME_PROGRESSBAR_VERTICAL is dedicated to -moz-appearance: + // StyleAppearance::ProgressbarVertical is dedicated to -moz-appearance: // progressbar-vertical. bool vertical = IsVerticalProgress(aFrame) || - aWidgetType == NS_THEME_PROGRESSBAR_VERTICAL; + aWidgetType == StyleAppearance::ProgressbarVertical; aPart = vertical ? PP_BARVERT : PP_BAR; aState = PBBS_NORMAL; return NS_OK; } - case NS_THEME_PROGRESSCHUNK: - case NS_THEME_PROGRESSCHUNK_VERTICAL: { + case StyleAppearance::Progresschunk: + case StyleAppearance::ProgresschunkVertical: { nsIFrame* parentFrame = aFrame->GetParent(); - if (aWidgetType == NS_THEME_PROGRESSCHUNK_VERTICAL || + if (aWidgetType == StyleAppearance::ProgresschunkVertical || IsVerticalProgress(parentFrame)) { aPart = PP_FILLVERT; } else { aPart = PP_FILL; } aState = PBBVS_NORMAL; return NS_OK; } - case NS_THEME_TOOLBARBUTTON: { + case StyleAppearance::Toolbarbutton: { aPart = BP_BUTTON; if (!aFrame) { aState = TS_NORMAL; return NS_OK; } EventStates eventState = GetContentState(aFrame, aWidgetType); if (IsDisabled(aFrame, eventState)) { @@ -1040,57 +1041,57 @@ nsNativeThemeWin::GetThemePartAndState(n if (IsCheckedButton(aFrame)) aState = TB_CHECKED; else aState = TS_NORMAL; } return NS_OK; } - case NS_THEME_SEPARATOR: { + case StyleAppearance::Separator: { aPart = TP_SEPARATOR; aState = TS_NORMAL; return NS_OK; } - case NS_THEME_SCROLLBARBUTTON_UP: - case NS_THEME_SCROLLBARBUTTON_DOWN: - case NS_THEME_SCROLLBARBUTTON_LEFT: - case NS_THEME_SCROLLBARBUTTON_RIGHT: { + case StyleAppearance::ScrollbarbuttonUp: + case StyleAppearance::ScrollbarbuttonDown: + case StyleAppearance::ScrollbarbuttonLeft: + case StyleAppearance::ScrollbarbuttonRight: { aPart = SP_BUTTON; - aState = (aWidgetType - NS_THEME_SCROLLBARBUTTON_UP)*4; + aState = (int(aWidgetType) - int(StyleAppearance::ScrollbarbuttonDown))*4; EventStates eventState = GetContentState(aFrame, aWidgetType); if (!aFrame) aState += TS_NORMAL; else if (IsDisabled(aFrame, eventState)) aState += TS_DISABLED; else { nsIFrame *parent = aFrame->GetParent(); EventStates parentState = GetContentState(parent, parent->StyleDisplay()->mAppearance); if (eventState.HasAllStates(NS_EVENT_STATE_HOVER | NS_EVENT_STATE_ACTIVE)) aState += TS_ACTIVE; else if (eventState.HasState(NS_EVENT_STATE_HOVER)) aState += TS_HOVER; else if (parentState.HasState(NS_EVENT_STATE_HOVER)) - aState = (aWidgetType - NS_THEME_SCROLLBARBUTTON_UP) + SP_BUTTON_IMPLICIT_HOVER_BASE; + aState = (int(aWidgetType) - int(StyleAppearance::ScrollbarbuttonDown)) + SP_BUTTON_IMPLICIT_HOVER_BASE; else aState += TS_NORMAL; } return NS_OK; } - case NS_THEME_SCROLLBAR_HORIZONTAL: - case NS_THEME_SCROLLBAR_VERTICAL: { - aPart = (aWidgetType == NS_THEME_SCROLLBAR_HORIZONTAL) ? + case StyleAppearance::ScrollbarHorizontal: + case StyleAppearance::ScrollbarVertical: { + aPart = (aWidgetType == StyleAppearance::ScrollbarHorizontal) ? SP_TRACKSTARTHOR : SP_TRACKSTARTVERT; aState = TS_NORMAL; return NS_OK; } - case NS_THEME_SCROLLBARTHUMB_HORIZONTAL: - case NS_THEME_SCROLLBARTHUMB_VERTICAL: { - aPart = (aWidgetType == NS_THEME_SCROLLBARTHUMB_HORIZONTAL) ? + case StyleAppearance::ScrollbarthumbHorizontal: + case StyleAppearance::ScrollbarthumbVertical: { + aPart = (aWidgetType == StyleAppearance::ScrollbarthumbHorizontal) ? SP_THUMBHOR : SP_THUMBVERT; EventStates eventState = GetContentState(aFrame, aWidgetType); if (!aFrame) aState = TS_NORMAL; else if (IsDisabled(aFrame, eventState)) aState = TS_DISABLED; else { if (eventState.HasState(NS_EVENT_STATE_ACTIVE)) // Hover is not also a requirement for @@ -1099,41 +1100,41 @@ nsNativeThemeWin::GetThemePartAndState(n aState = TS_ACTIVE; else if (eventState.HasState(NS_EVENT_STATE_HOVER)) aState = TS_HOVER; else aState = TS_NORMAL; } return NS_OK; } - case NS_THEME_RANGE: - case NS_THEME_SCALE_HORIZONTAL: - case NS_THEME_SCALE_VERTICAL: { - if (aWidgetType == NS_THEME_SCALE_HORIZONTAL || - (aWidgetType == NS_THEME_RANGE && + case StyleAppearance::Range: + case StyleAppearance::ScaleHorizontal: + case StyleAppearance::ScaleVertical: { + if (aWidgetType == StyleAppearance::ScaleHorizontal || + (aWidgetType == StyleAppearance::Range && IsRangeHorizontal(aFrame))) { aPart = TKP_TRACK; aState = TRS_NORMAL; } else { aPart = TKP_TRACKVERT; aState = TRVS_NORMAL; } return NS_OK; } - case NS_THEME_RANGE_THUMB: - case NS_THEME_SCALETHUMB_HORIZONTAL: - case NS_THEME_SCALETHUMB_VERTICAL: { - if (aWidgetType == NS_THEME_RANGE_THUMB) { + case StyleAppearance::RangeThumb: + case StyleAppearance::ScalethumbHorizontal: + case StyleAppearance::ScalethumbVertical: { + if (aWidgetType == StyleAppearance::RangeThumb) { if (IsRangeHorizontal(aFrame)) { aPart = TKP_THUMBBOTTOM; } else { aPart = IsFrameRTL(aFrame) ? TKP_THUMBLEFT : TKP_THUMBRIGHT; } } else { - aPart = (aWidgetType == NS_THEME_SCALETHUMB_HORIZONTAL) ? + aPart = (aWidgetType == StyleAppearance::ScalethumbHorizontal) ? TKP_THUMB : TKP_THUMBVERT; } EventStates eventState = GetContentState(aFrame, aWidgetType); if (!aFrame) aState = TS_NORMAL; else if (IsDisabled(aFrame, eventState)) { aState = TKP_DISABLED; } @@ -1146,82 +1147,89 @@ nsNativeThemeWin::GetThemePartAndState(n aState = TKP_FOCUSED; else if (eventState.HasState(NS_EVENT_STATE_HOVER)) aState = TS_HOVER; else aState = TS_NORMAL; } return NS_OK; } - case NS_THEME_INNER_SPIN_BUTTON: - case NS_THEME_SPINNER_UPBUTTON: - case NS_THEME_SPINNER_DOWNBUTTON: { - aPart = (aWidgetType == NS_THEME_SPINNER_UPBUTTON) ? + case StyleAppearance::InnerSpinButton: + case StyleAppearance::SpinnerUpbutton: + case StyleAppearance::SpinnerDownbutton: { + aPart = (aWidgetType == StyleAppearance::SpinnerUpbutton) ? SPNP_UP : SPNP_DOWN; EventStates eventState = GetContentState(aFrame, aWidgetType); if (!aFrame) aState = TS_NORMAL; else if (IsDisabled(aFrame, eventState)) aState = TS_DISABLED; else aState = StandardGetState(aFrame, aWidgetType, false); return NS_OK; } - case NS_THEME_TOOLBOX: - case NS_THEME_WIN_MEDIA_TOOLBOX: - case NS_THEME_WIN_COMMUNICATIONS_TOOLBOX: - case NS_THEME_WIN_BROWSERTABBAR_TOOLBOX: - case NS_THEME_STATUSBAR: - case NS_THEME_SCROLLBAR: - case NS_THEME_SCROLLBAR_SMALL: - case NS_THEME_SCROLLCORNER: { + case StyleAppearance::Toolbox: + case StyleAppearance::MozWinMediaToolbox: + case StyleAppearance::MozWinCommunicationsToolbox: + case StyleAppearance::MozWinBrowsertabbarToolbox: + case StyleAppearance::Statusbar: + case StyleAppearance::Scrollbar: + case StyleAppearance::ScrollbarSmall: + case StyleAppearance::Scrollcorner: { aState = 0; aPart = RP_BACKGROUND; return NS_OK; } - case NS_THEME_TOOLBAR: { + case StyleAppearance::Toolbar: { // Use -1 to indicate we don't wish to have the theme background drawn // for this item. We will pass any nessessary information via aState, // and will render the item using separate code. aPart = -1; aState = 0; if (aFrame) { nsIContent* content = aFrame->GetContent(); nsIContent* parent = content->GetParent(); // XXXzeniko hiding the first toolbar will result in an unwanted margin if (parent && parent->GetFirstChild() == content) { aState = 1; } } return NS_OK; } - case NS_THEME_STATUSBARPANEL: - case NS_THEME_RESIZERPANEL: - case NS_THEME_RESIZER: { - aPart = (aWidgetType - NS_THEME_STATUSBARPANEL) + 1; + case StyleAppearance::Statusbarpanel: + case StyleAppearance::Resizerpanel: + case StyleAppearance::Resizer: { + switch (aWidgetType) { + case StyleAppearance::Statusbarpanel: aPart = 1; break; + case StyleAppearance::Resizerpanel: aPart = 2; break; + case StyleAppearance::Resizer: aPart = 3; break; + default: + MOZ_ASSERT_UNREACHABLE("Oops, we're missing a case"); + aPart = 1; // just something valid + } aState = TS_NORMAL; return NS_OK; } - case NS_THEME_TREEVIEW: - case NS_THEME_LISTBOX: { + case StyleAppearance::Treeview: + case StyleAppearance::Listbox: { aPart = TREEVIEW_BODY; aState = TS_NORMAL; return NS_OK; } - case NS_THEME_TABPANELS: { + case StyleAppearance::Tabpanels: { aPart = TABP_PANELS; aState = TS_NORMAL; return NS_OK; } - case NS_THEME_TABPANEL: { + case StyleAppearance::Tabpanel: { aPart = TABP_PANEL; aState = TS_NORMAL; return NS_OK; } - case NS_THEME_TAB: { + case StyleAppearance::Tab: { aPart = TABP_TAB; if (!aFrame) { aState = TS_NORMAL; return NS_OK; } EventStates eventState = GetContentState(aFrame, aWidgetType); if (IsDisabled(aFrame, eventState)) { @@ -1233,34 +1241,34 @@ nsNativeThemeWin::GetThemePartAndState(n aPart = TABP_TAB_SELECTED; aState = TS_ACTIVE; // The selected tab is always "pressed". } else aState = StandardGetState(aFrame, aWidgetType, true); return NS_OK; } - case NS_THEME_TREEHEADERSORTARROW: { + case StyleAppearance::Treeheadersortarrow: { // XXX Probably will never work due to a bug in the Luna theme. aPart = 4; aState = 1; return NS_OK; } - case NS_THEME_TREEHEADERCELL: { + case StyleAppearance::Treeheadercell: { aPart = 1; if (!aFrame) { aState = TS_NORMAL; return NS_OK; } aState = StandardGetState(aFrame, aWidgetType, true); return NS_OK; } - case NS_THEME_MENULIST: { + case StyleAppearance::Menulist: { nsIContent* content = aFrame->GetContent(); bool isHTML = content && content->IsHTMLElement(); bool isChrome = aFrame->GetContent()->IsInChromeDocument(); bool useDropBorder = isHTML || (isChrome && IsMenuListEditable(aFrame)); EventStates eventState = GetContentState(aFrame, aWidgetType); /* On Vista/Win7, we use CBP_DROPBORDER instead of DROPFRAME for HTML * content or for editable menulists; this gives us the thin outline, @@ -1284,33 +1292,33 @@ nsNativeThemeWin::GetThemePartAndState(n else if (eventState.HasState(NS_EVENT_STATE_HOVER)) aState = TS_HOVER; else aState = TS_NORMAL; } return NS_OK; } - case NS_THEME_MENULIST_BUTTON: { + case StyleAppearance::MenulistButton: { bool isHTML = IsHTMLContent(aFrame); nsIFrame* parentFrame = aFrame->GetParent(); bool isMenulist = !isHTML && parentFrame->IsMenuFrame(); bool isOpen = false; // HTML select and XUL menulist dropdown buttons get state from the parent. if (isHTML || isMenulist) aFrame = parentFrame; EventStates eventState = GetContentState(aFrame, aWidgetType); aPart = CBP_DROPMARKER_VISTA; // For HTML controls with author styling, we should fall // back to the old dropmarker style to avoid clashes with // author-specified backgrounds and borders (bug #441034) - if (isHTML && IsWidgetStyled(aFrame->PresContext(), aFrame, NS_THEME_MENULIST)) + if (isHTML && IsWidgetStyled(aFrame->PresContext(), aFrame, StyleAppearance::Menulist)) aPart = CBP_DROPMARKER; if (IsDisabled(aFrame, eventState)) { aState = TS_DISABLED; return NS_OK; } if (isHTML) { @@ -1360,24 +1368,24 @@ nsNativeThemeWin::GetThemePartAndState(n // XXX HTML select dropdown buttons should have the hover effect when // hovering the combobox frame, but not the popup frame. return NS_OK; } aState = TS_HOVER; } return NS_OK; } - case NS_THEME_MENUPOPUP: { + case StyleAppearance::Menupopup: { aPart = MENU_POPUPBACKGROUND; aState = MB_ACTIVE; return NS_OK; } - case NS_THEME_MENUITEM: - case NS_THEME_CHECKMENUITEM: - case NS_THEME_RADIOMENUITEM: { + case StyleAppearance::Menuitem: + case StyleAppearance::Checkmenuitem: + case StyleAppearance::Radiomenuitem: { bool isTopLevel = false; bool isOpen = false; bool isHover = false; nsMenuFrame *menuFrame = do_QueryFrame(aFrame); EventStates eventState = GetContentState(aFrame, aWidgetType); isTopLevel = IsTopLevelMenu(aFrame); @@ -1409,91 +1417,91 @@ nsNativeThemeWin::GetThemePartAndState(n // the disabled states are offset by 2 if (IsDisabled(aFrame, eventState)) aState += 2; } return NS_OK; } - case NS_THEME_MENUSEPARATOR: + case StyleAppearance::Menuseparator: aPart = MENU_POPUPSEPARATOR; aState = 0; return NS_OK; - case NS_THEME_MENUARROW: + case StyleAppearance::Menuarrow: { aPart = MENU_POPUPSUBMENU; EventStates eventState = GetContentState(aFrame, aWidgetType); aState = IsDisabled(aFrame, eventState) ? MSM_DISABLED : MSM_NORMAL; return NS_OK; } - case NS_THEME_MENUCHECKBOX: - case NS_THEME_MENURADIO: + case StyleAppearance::Menucheckbox: + case StyleAppearance::Menuradio: { EventStates eventState = GetContentState(aFrame, aWidgetType); aPart = MENU_POPUPCHECK; aState = MC_CHECKMARKNORMAL; // Radio states are offset by 2 - if (aWidgetType == NS_THEME_MENURADIO) + if (aWidgetType == StyleAppearance::Menuradio) aState += 2; // the disabled states are offset by 1 if (IsDisabled(aFrame, eventState)) aState += 1; return NS_OK; } - case NS_THEME_MENUITEMTEXT: - case NS_THEME_MENUIMAGE: + case StyleAppearance::Menuitemtext: + case StyleAppearance::Menuimage: aPart = -1; aState = 0; return NS_OK; - case NS_THEME_WINDOW_TITLEBAR: + case StyleAppearance::MozWindowTitlebar: aPart = mozilla::widget::themeconst::WP_CAPTION; aState = GetTopLevelWindowActiveState(aFrame); return NS_OK; - case NS_THEME_WINDOW_TITLEBAR_MAXIMIZED: + case StyleAppearance::MozWindowTitlebarMaximized: aPart = mozilla::widget::themeconst::WP_MAXCAPTION; aState = GetTopLevelWindowActiveState(aFrame); return NS_OK; - case NS_THEME_WINDOW_FRAME_LEFT: + case StyleAppearance::MozWindowFrameLeft: aPart = mozilla::widget::themeconst::WP_FRAMELEFT; aState = GetTopLevelWindowActiveState(aFrame); return NS_OK; - case NS_THEME_WINDOW_FRAME_RIGHT: + case StyleAppearance::MozWindowFrameRight: aPart = mozilla::widget::themeconst::WP_FRAMERIGHT; aState = GetTopLevelWindowActiveState(aFrame); return NS_OK; - case NS_THEME_WINDOW_FRAME_BOTTOM: + case StyleAppearance::MozWindowFrameBottom: aPart = mozilla::widget::themeconst::WP_FRAMEBOTTOM; aState = GetTopLevelWindowActiveState(aFrame); return NS_OK; - case NS_THEME_WINDOW_BUTTON_CLOSE: + case StyleAppearance::MozWindowButtonClose: aPart = mozilla::widget::themeconst::WP_CLOSEBUTTON; aState = GetWindowFrameButtonState(aFrame, GetContentState(aFrame, aWidgetType)); return NS_OK; - case NS_THEME_WINDOW_BUTTON_MINIMIZE: + case StyleAppearance::MozWindowButtonMinimize: aPart = mozilla::widget::themeconst::WP_MINBUTTON; aState = GetWindowFrameButtonState(aFrame, GetContentState(aFrame, aWidgetType)); return NS_OK; - case NS_THEME_WINDOW_BUTTON_MAXIMIZE: + case StyleAppearance::MozWindowButtonMaximize: aPart = mozilla::widget::themeconst::WP_MAXBUTTON; aState = GetWindowFrameButtonState(aFrame, GetContentState(aFrame, aWidgetType)); return NS_OK; - case NS_THEME_WINDOW_BUTTON_RESTORE: + case StyleAppearance::MozWindowButtonRestore: aPart = mozilla::widget::themeconst::WP_RESTOREBUTTON; aState = GetWindowFrameButtonState(aFrame, GetContentState(aFrame, aWidgetType)); return NS_OK; - case NS_THEME_WINDOW_BUTTON_BOX: - case NS_THEME_WINDOW_BUTTON_BOX_MAXIMIZED: - case NS_THEME_WIN_GLASS: - case NS_THEME_WIN_BORDERLESS_GLASS: + case StyleAppearance::MozWindowButtonBox: + case StyleAppearance::MozWindowButtonBoxMaximized: + case StyleAppearance::MozWinGlass: + case StyleAppearance::MozWinBorderlessGlass: aPart = -1; aState = 0; return NS_OK; } aPart = 0; aState = 0; return NS_ERROR_FAILURE; @@ -1525,17 +1533,17 @@ GetThemeDpiScaleFactor(nsIFrame* aFrame) } } return 1.0; } NS_IMETHODIMP nsNativeThemeWin::DrawWidgetBackground(gfxContext* aContext, nsIFrame* aFrame, - uint8_t aWidgetType, + WidgetType aWidgetType, const nsRect& aRect, const nsRect& aDirtyRect) { if (IsWidgetScrollbarPart(aWidgetType)) { ComputedStyle* style = nsLayoutUtils::StyleForScrollbar(aFrame); if (style->StyleUserInterface()->HasCustomScrollbars()) { return DrawCustomScrollbarPart(aContext, aFrame, style, aWidgetType, aRect, aDirtyRect); @@ -1544,40 +1552,40 @@ nsNativeThemeWin::DrawWidgetBackground(g HANDLE theme = GetTheme(aWidgetType); if (!theme) return ClassicDrawWidgetBackground(aContext, aFrame, aWidgetType, aRect, aDirtyRect); // ^^ without the right sdk, assume xp theming and fall through. if (nsUXThemeData::CheckForCompositor()) { switch (aWidgetType) { - case NS_THEME_WINDOW_TITLEBAR: - case NS_THEME_WINDOW_TITLEBAR_MAXIMIZED: - case NS_THEME_WINDOW_FRAME_LEFT: - case NS_THEME_WINDOW_FRAME_RIGHT: - case NS_THEME_WINDOW_FRAME_BOTTOM: + case StyleAppearance::MozWindowTitlebar: + case StyleAppearance::MozWindowTitlebarMaximized: + case StyleAppearance::MozWindowFrameLeft: + case StyleAppearance::MozWindowFrameRight: + case StyleAppearance::MozWindowFrameBottom: // Nothing to draw, these areas are glass. Minimum dimensions // should be set, so xul content should be layed out correctly. return NS_OK; break; - case NS_THEME_WINDOW_BUTTON_CLOSE: - case NS_THEME_WINDOW_BUTTON_MINIMIZE: - case NS_THEME_WINDOW_BUTTON_MAXIMIZE: - case NS_THEME_WINDOW_BUTTON_RESTORE: + case StyleAppearance::MozWindowButtonClose: + case StyleAppearance::MozWindowButtonMinimize: + case StyleAppearance::MozWindowButtonMaximize: + case StyleAppearance::MozWindowButtonRestore: // Not conventional bitmaps, can't be retrieved. If we fall // through here and call the theme library we'll get aero // basic bitmaps. return NS_OK; break; - case NS_THEME_WIN_GLASS: - case NS_THEME_WIN_BORDERLESS_GLASS: + case StyleAppearance::MozWinGlass: + case StyleAppearance::MozWinBorderlessGlass: // Nothing to draw, this is the glass background. return NS_OK; - case NS_THEME_WINDOW_BUTTON_BOX: - case NS_THEME_WINDOW_BUTTON_BOX_MAXIMIZED: + case StyleAppearance::MozWindowButtonBox: + case StyleAppearance::MozWindowButtonBoxMaximized: // We handle these through nsIWidget::UpdateThemeGeometries return NS_OK; break; } } int32_t part, state; nsresult rv = GetThemePartAndState(aFrame, aWidgetType, part, state); @@ -1623,27 +1631,27 @@ RENDER_AGAIN: m._31, m._32)); MOZ_LOG(gWindowsLog, LogLevel::Error, (stderr, "tr: [%d %d %d %d]\ndr: [%d %d %d %d]\noff: [%f %f]\n", tr.x, tr.y, tr.width, tr.height, dr.x, dr.y, dr.width, dr.height, offset.x, offset.y)); } #endif - if (aWidgetType == NS_THEME_WINDOW_TITLEBAR) { + if (aWidgetType == StyleAppearance::MozWindowTitlebar) { // Clip out the left and right corners of the frame, all we want in // is the middle section. widgetRect.left -= GetSystemMetrics(SM_CXFRAME); widgetRect.right += GetSystemMetrics(SM_CXFRAME); - } else if (aWidgetType == NS_THEME_WINDOW_TITLEBAR_MAXIMIZED) { + } else if (aWidgetType == StyleAppearance::MozWindowTitlebarMaximized) { // The origin of the window is off screen when maximized and windows // doesn't compensate for this in rendering the background. Push the // top of the bitmap down by SM_CYFRAME so we get the full graphic. widgetRect.top += GetSystemMetrics(SM_CYFRAME); - } else if (aWidgetType == NS_THEME_TAB) { + } else if (aWidgetType == StyleAppearance::Tab) { // For left edge and right edge tabs, we need to adjust the widget // rects and clip rects so that the edges don't get drawn. bool isLeft = IsLeftToSelectedTab(aFrame); bool isRight = !isLeft && IsRightToSelectedTab(aFrame); if (isLeft || isRight) { // HACK ALERT: There appears to be no way to really obtain this value, so we're forced // to just use the default value for Luna (which also happens to be correct for @@ -1656,59 +1664,59 @@ RENDER_AGAIN: if (isLeft) // The right edge should not be drawn. Extend our rect by the edge size. widgetRect.right += edgeSize; else // The left edge should not be drawn. Move the widget rect's left coord back. widgetRect.left -= edgeSize; } } - else if (aWidgetType == NS_THEME_WINDOW_BUTTON_MINIMIZE) { + else if (aWidgetType == StyleAppearance::MozWindowButtonMinimize) { OffsetBackgroundRect(widgetRect, CAPTIONBUTTON_MINIMIZE); } - else if (aWidgetType == NS_THEME_WINDOW_BUTTON_MAXIMIZE || - aWidgetType == NS_THEME_WINDOW_BUTTON_RESTORE) { + else if (aWidgetType == StyleAppearance::MozWindowButtonMaximize || + aWidgetType == StyleAppearance::MozWindowButtonRestore) { OffsetBackgroundRect(widgetRect, CAPTIONBUTTON_RESTORE); } - else if (aWidgetType == NS_THEME_WINDOW_BUTTON_CLOSE) { + else if (aWidgetType == StyleAppearance::MozWindowButtonClose) { OffsetBackgroundRect(widgetRect, CAPTIONBUTTON_CLOSE); } // widgetRect is the bounding box for a widget, yet the scale track is only // a small portion of this size, so the edges of the scale need to be // adjusted to the real size of the track. - if (aWidgetType == NS_THEME_RANGE || - aWidgetType == NS_THEME_SCALE_HORIZONTAL || - aWidgetType == NS_THEME_SCALE_VERTICAL) { + if (aWidgetType == StyleAppearance::Range || + aWidgetType == StyleAppearance::ScaleHorizontal || + aWidgetType == StyleAppearance::ScaleVertical) { RECT contentRect; GetThemeBackgroundContentRect(theme, hdc, part, state, &widgetRect, &contentRect); SIZE siz; GetThemePartSize(theme, hdc, part, state, &widgetRect, TS_TRUE, &siz); // When rounding is necessary, we round the position of the track // away from the chevron of the thumb to make it look better. - if (aWidgetType == NS_THEME_SCALE_HORIZONTAL || - (aWidgetType == NS_THEME_RANGE && IsRangeHorizontal(aFrame))) { + if (aWidgetType == StyleAppearance::ScaleHorizontal || + (aWidgetType == StyleAppearance::Range && IsRangeHorizontal(aFrame))) { contentRect.top += (contentRect.bottom - contentRect.top - siz.cy) / 2; contentRect.bottom = contentRect.top + siz.cy; } else { if (!IsFrameRTL(aFrame)) { contentRect.left += (contentRect.right - contentRect.left - siz.cx) / 2; contentRect.right = contentRect.left + siz.cx; } else { contentRect.right -= (contentRect.right - contentRect.left - siz.cx) / 2; contentRect.left = contentRect.right - siz.cx; } } DrawThemeBackground(theme, hdc, part, state, &contentRect, &clipRect); } - else if (aWidgetType == NS_THEME_MENUCHECKBOX || aWidgetType == NS_THEME_MENURADIO) + else if (aWidgetType == StyleAppearance::Menucheckbox || aWidgetType == StyleAppearance::Menuradio) { bool isChecked = false; isChecked = CheckBooleanAttr(aFrame, nsGkAtoms::checked); if (isChecked) { int bgState = MCB_NORMAL; EventStates eventState = GetContentState(aFrame, aWidgetType); @@ -1736,17 +1744,17 @@ RENDER_AGAIN: RECT checkRect = checkBGRect; checkRect.left += checkMargins.cxLeftWidth; checkRect.right -= checkMargins.cxRightWidth; checkRect.top += checkMargins.cyTopHeight; checkRect.bottom -= checkMargins.cyBottomHeight; DrawThemeBackground(theme, hdc, MENU_POPUPCHECK, state, &checkRect, &clipRect); } } - else if (aWidgetType == NS_THEME_MENUPOPUP) + else if (aWidgetType == StyleAppearance::Menupopup) { DrawThemeBackground(theme, hdc, MENU_POPUPBORDERS, /* state */ 0, &widgetRect, &clipRect); SIZE borderSize; GetThemePartSize(theme, hdc, MENU_POPUPBORDERS, 0, nullptr, TS_TRUE, &borderSize); RECT bgRect = widgetRect; bgRect.top += borderSize.cy; bgRect.bottom -= borderSize.cy; @@ -1766,33 +1774,33 @@ RENDER_AGAIN: } else { gutterRect.left = bgRect.left; gutterRect.right = gutterRect.left+gutterSize.cx; } DrawThemeBGRTLAware(theme, hdc, MENU_POPUPGUTTER, /* state */ 0, &gutterRect, &clipRect, IsFrameRTL(aFrame)); } - else if (aWidgetType == NS_THEME_MENUSEPARATOR) + else if (aWidgetType == StyleAppearance::Menuseparator) { SIZE gutterSize(GetGutterSize(theme,hdc)); RECT sepRect = widgetRect; if (IsFrameRTL(aFrame)) sepRect.right -= gutterSize.cx; else sepRect.left += gutterSize.cx; DrawThemeBackground(theme, hdc, MENU_POPUPSEPARATOR, /* state */ 0, &sepRect, &clipRect); } - else if (aWidgetType == NS_THEME_MENUARROW) + else if (aWidgetType == StyleAppearance::Menuarrow) { // We're dpi aware and as such on systems that have dpi > 96 set, the // theme library expects us to do proper positioning and scaling of glyphs. - // For NS_THEME_MENUARROW, layout may hand us a widget rect larger than the + // For StyleAppearance::Menuarrow, layout may hand us a widget rect larger than the // glyph rect we request in GetMinimumWidgetSize. To prevent distortion we // have to position and scale what we draw. SIZE glyphSize; GetThemePartSize(theme, hdc, part, state, nullptr, TS_TRUE, &glyphSize); int32_t widgetHeight = widgetRect.bottom - widgetRect.top; @@ -1814,50 +1822,50 @@ RENDER_AGAIN: } else { renderRect.left = glyphSize.cx; renderRect.right = renderRect.left + glyphSize.cx; } DrawThemeBGRTLAware(theme, hdc, part, state, &renderRect, &clipRect, IsFrameRTL(aFrame)); } // The following widgets need to be RTL-aware - else if (aWidgetType == NS_THEME_RESIZER || - aWidgetType == NS_THEME_MENULIST_BUTTON) + else if (aWidgetType == StyleAppearance::Resizer || + aWidgetType == StyleAppearance::MenulistButton) { DrawThemeBGRTLAware(theme, hdc, part, state, &widgetRect, &clipRect, IsFrameRTL(aFrame)); } - else if (aWidgetType == NS_THEME_NUMBER_INPUT || - aWidgetType == NS_THEME_TEXTFIELD || - aWidgetType == NS_THEME_TEXTFIELD_MULTILINE) { + else if (aWidgetType == StyleAppearance::NumberInput || + aWidgetType == StyleAppearance::Textfield || + aWidgetType == StyleAppearance::TextfieldMultiline) { DrawThemeBackground(theme, hdc, part, state, &widgetRect, &clipRect); if (state == TFS_EDITBORDER_DISABLED) { InflateRect(&widgetRect, -1, -1); ::FillRect(hdc, &widgetRect, reinterpret_cast<HBRUSH>(COLOR_BTNFACE+1)); } } - else if (aWidgetType == NS_THEME_PROGRESSBAR || - aWidgetType == NS_THEME_PROGRESSBAR_VERTICAL) { + else if (aWidgetType == StyleAppearance::Progressbar || + aWidgetType == StyleAppearance::ProgressbarVertical) { // DrawThemeBackground renders each corner with a solid white pixel. // Restore these pixels to the underlying color. Tracks are rendered // using alpha recovery, so this makes the corners transparent. COLORREF color; color = GetPixel(hdc, widgetRect.left, widgetRect.top); DrawThemeBackground(theme, hdc, part, state, &widgetRect, &clipRect); SetPixel(hdc, widgetRect.left, widgetRect.top, color); SetPixel(hdc, widgetRect.right-1, widgetRect.top, color); SetPixel(hdc, widgetRect.right-1, widgetRect.bottom-1, color); SetPixel(hdc, widgetRect.left, widgetRect.bottom-1, color); } - else if (aWidgetType == NS_THEME_PROGRESSCHUNK || - aWidgetType == NS_THEME_PROGRESSCHUNK_VERTICAL) { + else if (aWidgetType == StyleAppearance::Progresschunk || + aWidgetType == StyleAppearance::ProgresschunkVertical) { DrawThemedProgressMeter(aFrame, aWidgetType, theme, hdc, part, state, &widgetRect, &clipRect); } - else if (aWidgetType == NS_THEME_FOCUS_OUTLINE) { + else if (aWidgetType == StyleAppearance::FocusOutline) { // Inflate 'widgetRect' with the focus outline size. LayoutDeviceIntMargin border = GetWidgetBorder(aFrame->PresContext()->DeviceContext(), aFrame, aWidgetType); widgetRect.left -= border.left; widgetRect.right += border.right; widgetRect.top -= border.top; widgetRect.bottom += border.bottom; @@ -1872,19 +1880,19 @@ RENDER_AGAIN: // If part is negative, the element wishes us to not render a themed // background, instead opting to be drawn specially below. else if (part >= 0) { DrawThemeBackground(theme, hdc, part, state, &widgetRect, &clipRect); } // Draw focus rectangles for range and scale elements // XXX it'd be nice to draw these outside of the frame - if (aWidgetType == NS_THEME_RANGE || - aWidgetType == NS_THEME_SCALE_HORIZONTAL || - aWidgetType == NS_THEME_SCALE_VERTICAL) { + if (aWidgetType == StyleAppearance::Range || + aWidgetType == StyleAppearance::ScaleHorizontal || + aWidgetType == StyleAppearance::ScaleVertical) { EventStates contentState = GetContentState(aFrame, aWidgetType); if (contentState.HasState(NS_EVENT_STATE_FOCUS)) { POINT vpOrg; HPEN hPen = nullptr; uint8_t id = SaveDC(hdc); @@ -1894,34 +1902,34 @@ RENDER_AGAIN: ::SetTextColor(hdc, 0); ::DrawFocusRect(hdc, &widgetRect); ::RestoreDC(hdc, id); if (hPen) { ::DeleteObject(hPen); } } } - else if (aWidgetType == NS_THEME_TOOLBAR && state == 0) { + else if (aWidgetType == StyleAppearance::Toolbar && state == 0) { // Draw toolbar separator lines above all toolbars except the first one. - // The lines are part of the Rebar theme, which is loaded for NS_THEME_TOOLBOX. - theme = GetTheme(NS_THEME_TOOLBOX); + // The lines are part of the Rebar theme, which is loaded for StyleAppearance::Toolbox. + theme = GetTheme(StyleAppearance::Toolbox); if (!theme) return NS_ERROR_FAILURE; widgetRect.bottom = widgetRect.top + TB_SEPARATOR_HEIGHT; DrawThemeEdge(theme, hdc, RP_BAND, 0, &widgetRect, EDGE_ETCHED, BF_TOP, nullptr); } - else if (aWidgetType == NS_THEME_SCROLLBARTHUMB_HORIZONTAL || - aWidgetType == NS_THEME_SCROLLBARTHUMB_VERTICAL) + else if (aWidgetType == StyleAppearance::ScrollbarthumbHorizontal || + aWidgetType == StyleAppearance::ScrollbarthumbVertical) { // Draw the decorative gripper for the scrollbar thumb button, if it fits SIZE gripSize; MARGINS thumbMgns; - int gripPart = (aWidgetType == NS_THEME_SCROLLBARTHUMB_HORIZONTAL) ? + int gripPart = (aWidgetType == StyleAppearance::ScrollbarthumbHorizontal) ? SP_GRIPPERHOR : SP_GRIPPERVERT; if (GetThemePartSize(theme, hdc, gripPart, state, nullptr, TS_TRUE, &gripSize) == S_OK && GetThemeMargins(theme, hdc, part, state, TMT_CONTENTMARGINS, nullptr, &thumbMgns) == S_OK && gripSize.cx + thumbMgns.cxLeftWidth + thumbMgns.cxRightWidth <= widgetRect.right - widgetRect.left && gripSize.cy + thumbMgns.cyTopHeight + thumbMgns.cyBottomHeight <= widgetRect.bottom - widgetRect.top) { DrawThemeBackground(theme, hdc, gripPart, state, &widgetRect, &clipRect); @@ -1952,31 +1960,31 @@ static nscolor GetScrollbarTrackColorForAuto(ComputedStyle* aStyle) { // Fallback to background color for now. Do we want to derive from // scrollbar-face-color somehow? return aStyle->StyleBackground()->BackgroundColor(aStyle); } nscolor -nsNativeThemeWin::GetWidgetAutoColor(ComputedStyle* aStyle, uint8_t aWidgetType) +nsNativeThemeWin::GetWidgetAutoColor(ComputedStyle* aStyle, WidgetType aWidgetType) { switch (aWidgetType) { - case NS_THEME_SCROLLBAR: - case NS_THEME_SCROLLBAR_SMALL: - case NS_THEME_SCROLLBAR_VERTICAL: - case NS_THEME_SCROLLBAR_HORIZONTAL: - case NS_THEME_SCROLLBARBUTTON_UP: - case NS_THEME_SCROLLBARBUTTON_DOWN: - case NS_THEME_SCROLLBARBUTTON_LEFT: - case NS_THEME_SCROLLBARBUTTON_RIGHT: + case StyleAppearance::Scrollbar: + case StyleAppearance::ScrollbarSmall: + case StyleAppearance::ScrollbarVertical: + case StyleAppearance::ScrollbarHorizontal: + case StyleAppearance::ScrollbarbuttonUp: + case StyleAppearance::ScrollbarbuttonDown: + case StyleAppearance::ScrollbarbuttonLeft: + case StyleAppearance::ScrollbarbuttonRight: return GetScrollbarTrackColorForAuto(aStyle); - case NS_THEME_SCROLLBARTHUMB_VERTICAL: - case NS_THEME_SCROLLBARTHUMB_HORIZONTAL: + case StyleAppearance::ScrollbarthumbVertical: + case StyleAppearance::ScrollbarthumbHorizontal: return GetScrollbarFaceColorForAuto(aStyle); default: return nsITheme::GetWidgetAutoColor(aStyle, aWidgetType); } } static void @@ -2011,76 +2019,76 @@ ScaleForFrameDPI(LayoutDeviceIntSize* aS aSize->width = NSToIntRound(aSize->width * themeScale); aSize->height = NSToIntRound(aSize->height * themeScale); } } LayoutDeviceIntMargin nsNativeThemeWin::GetWidgetBorder(nsDeviceContext* aContext, nsIFrame* aFrame, - uint8_t aWidgetType) + WidgetType aWidgetType) { LayoutDeviceIntMargin result; mozilla::Maybe<nsUXThemeClass> themeClass = GetThemeClass(aWidgetType); HTHEME theme = NULL; if (!themeClass.isNothing()) { theme = nsUXThemeData::GetTheme(themeClass.value()); } if (!theme) { result = ClassicGetWidgetBorder(aContext, aFrame, aWidgetType); ScaleForFrameDPI(&result, aFrame); return result; } if (!WidgetIsContainer(aWidgetType) || - aWidgetType == NS_THEME_TOOLBOX || - aWidgetType == NS_THEME_WIN_MEDIA_TOOLBOX || - aWidgetType == NS_THEME_WIN_COMMUNICATIONS_TOOLBOX || - aWidgetType == NS_THEME_WIN_BROWSERTABBAR_TOOLBOX || - aWidgetType == NS_THEME_STATUSBAR || - aWidgetType == NS_THEME_RESIZER || aWidgetType == NS_THEME_TABPANEL || - aWidgetType == NS_THEME_SCROLLBAR_HORIZONTAL || - aWidgetType == NS_THEME_SCROLLBAR_VERTICAL || - aWidgetType == NS_THEME_SCROLLCORNER || - aWidgetType == NS_THEME_MENUITEM || aWidgetType == NS_THEME_CHECKMENUITEM || - aWidgetType == NS_THEME_RADIOMENUITEM || aWidgetType == NS_THEME_MENUPOPUP || - aWidgetType == NS_THEME_MENUIMAGE || aWidgetType == NS_THEME_MENUITEMTEXT || - aWidgetType == NS_THEME_SEPARATOR || - aWidgetType == NS_THEME_WINDOW_TITLEBAR || - aWidgetType == NS_THEME_WINDOW_TITLEBAR_MAXIMIZED || - aWidgetType == NS_THEME_WIN_GLASS || aWidgetType == NS_THEME_WIN_BORDERLESS_GLASS) + aWidgetType == StyleAppearance::Toolbox || + aWidgetType == StyleAppearance::MozWinMediaToolbox || + aWidgetType == StyleAppearance::MozWinCommunicationsToolbox || + aWidgetType == StyleAppearance::MozWinBrowsertabbarToolbox || + aWidgetType == StyleAppearance::Statusbar || + aWidgetType == StyleAppearance::Resizer || aWidgetType == StyleAppearance::Tabpanel || + aWidgetType == StyleAppearance::ScrollbarHorizontal || + aWidgetType == StyleAppearance::ScrollbarVertical || + aWidgetType == StyleAppearance::Scrollcorner || + aWidgetType == StyleAppearance::Menuitem || aWidgetType == StyleAppearance::Checkmenuitem || + aWidgetType == StyleAppearance::Radiomenuitem || aWidgetType == StyleAppearance::Menupopup || + aWidgetType == StyleAppearance::Menuimage || aWidgetType == StyleAppearance::Menuitemtext || + aWidgetType == StyleAppearance::Separator || + aWidgetType == StyleAppearance::MozWindowTitlebar || + aWidgetType == StyleAppearance::MozWindowTitlebarMaximized || + aWidgetType == StyleAppearance::MozWinGlass || aWidgetType == StyleAppearance::MozWinBorderlessGlass) return result; // Don't worry about it. int32_t part, state; nsresult rv = GetThemePartAndState(aFrame, aWidgetType, part, state); if (NS_FAILED(rv)) return result; - if (aWidgetType == NS_THEME_TOOLBAR) { + if (aWidgetType == StyleAppearance::Toolbar) { // make space for the separator line above all toolbars but the first if (state == 0) result.top = TB_SEPARATOR_HEIGHT; return result; } result = GetCachedWidgetBorder(theme, themeClass.value(), aWidgetType, part, state); // Remove the edges for tabs that are before or after the selected tab, - if (aWidgetType == NS_THEME_TAB) { + if (aWidgetType == StyleAppearance::Tab) { if (IsLeftToSelectedTab(aFrame)) // Remove the right edge, since we won't be drawing it. result.right = 0; else if (IsRightToSelectedTab(aFrame)) // Remove the left edge, since we won't be drawing it. result.left = 0; } - if (aFrame && (aWidgetType == NS_THEME_NUMBER_INPUT || - aWidgetType == NS_THEME_TEXTFIELD || - aWidgetType == NS_THEME_TEXTFIELD_MULTILINE)) { + if (aFrame && (aWidgetType == StyleAppearance::NumberInput || + aWidgetType == StyleAppearance::Textfield || + aWidgetType == StyleAppearance::TextfieldMultiline)) { nsIContent* content = aFrame->GetContent(); if (content && content->IsHTMLElement()) { // We need to pad textfields by 1 pixel, since the caret will draw // flush against the edge by default if we don't. result.top++; result.left++; result.bottom++; result.right++; @@ -2089,134 +2097,134 @@ nsNativeThemeWin::GetWidgetBorder(nsDevi ScaleForFrameDPI(&result, aFrame); return result; } bool nsNativeThemeWin::GetWidgetPadding(nsDeviceContext* aContext, nsIFrame* aFrame, - uint8_t aWidgetType, + WidgetType aWidgetType, LayoutDeviceIntMargin* aResult) { switch (aWidgetType) { // Radios and checkboxes return a fixed size in GetMinimumWidgetSize // and have a meaningful baseline, so they can't have // author-specified padding. - case NS_THEME_CHECKBOX: - case NS_THEME_RADIO: + case StyleAppearance::Checkbox: + case StyleAppearance::Radio: aResult->SizeTo(0, 0, 0, 0); return true; } bool ok = true; - if (aWidgetType == NS_THEME_WINDOW_BUTTON_BOX || - aWidgetType == NS_THEME_WINDOW_BUTTON_BOX_MAXIMIZED) { + if (aWidgetType == StyleAppearance::MozWindowButtonBox || + aWidgetType == StyleAppearance::MozWindowButtonBoxMaximized) { aResult->SizeTo(0, 0, 0, 0); // aero glass doesn't display custom buttons if (nsUXThemeData::CheckForCompositor()) return true; // button padding for standard windows - if (aWidgetType == NS_THEME_WINDOW_BUTTON_BOX) { + if (aWidgetType == StyleAppearance::MozWindowButtonBox) { aResult->top = GetSystemMetrics(SM_CXFRAME); } ScaleForFrameDPI(aResult, aFrame); return ok; } // Content padding - if (aWidgetType == NS_THEME_WINDOW_TITLEBAR || - aWidgetType == NS_THEME_WINDOW_TITLEBAR_MAXIMIZED) { + if (aWidgetType == StyleAppearance::MozWindowTitlebar || + aWidgetType == StyleAppearance::MozWindowTitlebarMaximized) { aResult->SizeTo(0, 0, 0, 0); // XXX Maximized windows have an offscreen offset equal to // the border padding. This should be addressed in nsWindow, // but currently can't be, see UpdateNonClientMargins. - if (aWidgetType == NS_THEME_WINDOW_TITLEBAR_MAXIMIZED) + if (aWidgetType == StyleAppearance::MozWindowTitlebarMaximized) aResult->top = GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXPADDEDBORDER); return ok; } HANDLE theme = GetTheme(aWidgetType); if (!theme) { ok = ClassicGetWidgetPadding(aContext, aFrame, aWidgetType, aResult); ScaleForFrameDPI(aResult, aFrame); return ok; } - if (aWidgetType == NS_THEME_MENUPOPUP) + if (aWidgetType == StyleAppearance::Menupopup) { SIZE popupSize; GetThemePartSize(theme, nullptr, MENU_POPUPBORDERS, /* state */ 0, nullptr, TS_TRUE, &popupSize); aResult->top = aResult->bottom = popupSize.cy; aResult->left = aResult->right = popupSize.cx; ScaleForFrameDPI(aResult, aFrame); return ok; } - if (aWidgetType == NS_THEME_NUMBER_INPUT || - aWidgetType == NS_THEME_TEXTFIELD || - aWidgetType == NS_THEME_TEXTFIELD_MULTILINE || - aWidgetType == NS_THEME_MENULIST) + if (aWidgetType == StyleAppearance::NumberInput || + aWidgetType == StyleAppearance::Textfield || + aWidgetType == StyleAppearance::TextfieldMultiline || + aWidgetType == StyleAppearance::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) */ - if (aWidgetType == NS_THEME_NUMBER_INPUT || - aWidgetType == NS_THEME_TEXTFIELD || - aWidgetType == NS_THEME_TEXTFIELD_MULTILINE) { + if (aWidgetType == StyleAppearance::NumberInput || + aWidgetType == StyleAppearance::Textfield || + aWidgetType == StyleAppearance::TextfieldMultiline) { aResult->top = aResult->bottom = 2; aResult->left = aResult->right = 2; ScaleForFrameDPI(aResult, aFrame); return ok; - } else if (IsHTMLContent(aFrame) && aWidgetType == NS_THEME_MENULIST) { + } else if (IsHTMLContent(aFrame) && aWidgetType == StyleAppearance::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; } int32_t right, left, top, bottom; right = left = top = bottom = 0; switch (aWidgetType) { - case NS_THEME_MENUIMAGE: + case StyleAppearance::Menuimage: right = 8; left = 3; break; - case NS_THEME_MENUCHECKBOX: - case NS_THEME_MENURADIO: + case StyleAppearance::Menucheckbox: + case StyleAppearance::Menuradio: right = 8; left = 0; break; - case NS_THEME_MENUITEMTEXT: + case StyleAppearance::Menuitemtext: // There seem to be exactly 4 pixels from the edge // of the gutter to the text: 2px margin (CSS) + 2px padding (here) { SIZE size(GetGutterSize(theme, nullptr)); left = size.cx + 2; } break; - case NS_THEME_MENUSEPARATOR: + case StyleAppearance::Menuseparator: { SIZE size(GetGutterSize(theme, nullptr)); left = size.cx + 5; top = 10; bottom = 7; } break; default: @@ -2236,63 +2244,63 @@ nsNativeThemeWin::GetWidgetPadding(nsDev ScaleForFrameDPI(aResult, aFrame); return ok; } bool nsNativeThemeWin::GetWidgetOverflow(nsDeviceContext* aContext, nsIFrame* aFrame, - uint8_t aWidgetType, + WidgetType aWidgetType, nsRect* aOverflowRect) { /* This is disabled for now, because it causes invalidation problems -- * see bug 420381. The effect of not updating the overflow area is that * for dropdown buttons in content areas, there is a 1px border on 3 sides * where, if invalidated, the dropdown control probably won't be repainted. * This is fairly minor, as by default there is nothing in that area, and * a border only shows up if the widget is being hovered. */ #if 0 /* 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 && + if (aWidgetType == StyleAppearance::MenulistButton && IsHTMLContent(aFrame) && !IsWidgetStyled(aFrame->GetParent()->PresContext(), aFrame->GetParent(), - NS_THEME_MENULIST)) + StyleAppearance::Menulist)) { int32_t p2a = aContext->AppUnitsPerDevPixel(); /* Note: no overflow on the left */ nsMargin m(p2a, p2a, p2a, 0); aOverflowRect->Inflate (m); return true; } #endif - if (aWidgetType == NS_THEME_FOCUS_OUTLINE) { + if (aWidgetType == StyleAppearance::FocusOutline) { LayoutDeviceIntMargin border = GetWidgetBorder(aContext, aFrame, aWidgetType); int32_t p2a = aContext->AppUnitsPerDevPixel(); nsMargin m(NSIntPixelsToAppUnits(border.top, p2a), NSIntPixelsToAppUnits(border.right, p2a), NSIntPixelsToAppUnits(border.bottom, p2a), NSIntPixelsToAppUnits(border.left, p2a)); aOverflowRect->Inflate(m); return true; } return false; } NS_IMETHODIMP nsNativeThemeWin::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aFrame, - uint8_t aWidgetType, + WidgetType aWidgetType, LayoutDeviceIntSize* aResult, bool* aIsOverridable) { aResult->width = aResult->height = 0; *aIsOverridable = true; nsresult rv = NS_OK; mozilla::Maybe<nsUXThemeClass> themeClass = GetThemeClass(aWidgetType); HTHEME theme = NULL; @@ -2301,208 +2309,208 @@ nsNativeThemeWin::GetMinimumWidgetSize(n } if (!theme) { rv = ClassicGetMinimumWidgetSize(aFrame, aWidgetType, aResult, aIsOverridable); ScaleForFrameDPI(aResult, aFrame); return rv; } switch (aWidgetType) { - case NS_THEME_GROUPBOX: - case NS_THEME_NUMBER_INPUT: - case NS_THEME_TEXTFIELD: - case NS_THEME_TOOLBOX: - case NS_THEME_WIN_MEDIA_TOOLBOX: - case NS_THEME_WIN_COMMUNICATIONS_TOOLBOX: - case NS_THEME_WIN_BROWSERTABBAR_TOOLBOX: - case NS_THEME_TOOLBAR: - case NS_THEME_STATUSBAR: - case NS_THEME_PROGRESSCHUNK: - case NS_THEME_PROGRESSCHUNK_VERTICAL: - case NS_THEME_TABPANELS: - case NS_THEME_TABPANEL: - case NS_THEME_LISTBOX: - case NS_THEME_TREEVIEW: - case NS_THEME_MENUITEMTEXT: - case NS_THEME_WIN_GLASS: - case NS_THEME_WIN_BORDERLESS_GLASS: + case StyleAppearance::Groupbox: + case StyleAppearance::NumberInput: + case StyleAppearance::Textfield: + case StyleAppearance::Toolbox: + case StyleAppearance::MozWinMediaToolbox: + case StyleAppearance::MozWinCommunicationsToolbox: + case StyleAppearance::MozWinBrowsertabbarToolbox: + case StyleAppearance::Toolbar: + case StyleAppearance::Statusbar: + case StyleAppearance::Progresschunk: + case StyleAppearance::ProgresschunkVertical: + case StyleAppearance::Tabpanels: + case StyleAppearance::Tabpanel: + case StyleAppearance::Listbox: + case StyleAppearance::Treeview: + case StyleAppearance::Menuitemtext: + case StyleAppearance::MozWinGlass: + case StyleAppearance::MozWinBorderlessGlass: return NS_OK; // Don't worry about it. } - if (aWidgetType == NS_THEME_MENUITEM && IsTopLevelMenu(aFrame)) + if (aWidgetType == StyleAppearance::Menuitem && IsTopLevelMenu(aFrame)) return NS_OK; // Don't worry about it for top level menus // Call GetSystemMetrics to determine size for WinXP scrollbars // (GetThemeSysSize API returns the optimal size for the theme, but // Windows appears to always use metrics when drawing standard scrollbars) THEMESIZE sizeReq = TS_TRUE; // Best-fit size switch (aWidgetType) { - case NS_THEME_SCROLLBARTHUMB_VERTICAL: - case NS_THEME_SCROLLBARTHUMB_HORIZONTAL: - case NS_THEME_SCROLLBARBUTTON_UP: - case NS_THEME_SCROLLBARBUTTON_DOWN: - case NS_THEME_SCROLLBARBUTTON_LEFT: - case NS_THEME_SCROLLBARBUTTON_RIGHT: - case NS_THEME_SCROLLBAR_HORIZONTAL: - case NS_THEME_SCROLLBAR_VERTICAL: - case NS_THEME_MENULIST_BUTTON: { + case StyleAppearance::ScrollbarthumbVertical: + case StyleAppearance::ScrollbarthumbHorizontal: + case StyleAppearance::ScrollbarbuttonUp: + case StyleAppearance::ScrollbarbuttonDown: + case StyleAppearance::ScrollbarbuttonLeft: + case StyleAppearance::ScrollbarbuttonRight: + case StyleAppearance::ScrollbarHorizontal: + case StyleAppearance::ScrollbarVertical: + case StyleAppearance::MenulistButton: { rv = ClassicGetMinimumWidgetSize(aFrame, aWidgetType, aResult, aIsOverridable); ScaleForFrameDPI(aResult, aFrame); return rv; } - case NS_THEME_MENUITEM: - case NS_THEME_CHECKMENUITEM: - case NS_THEME_RADIOMENUITEM: + case Style