Skip to content

Commit

Permalink
Backed out changeset e2d6154400a7 (bug 1833403) for causing reftest f…
Browse files Browse the repository at this point in the history
…ailures on resizer-bottomend.xhtml
  • Loading branch information
Norisz Fay committed May 22, 2023
1 parent 2fc1fdf commit 52188d9
Show file tree
Hide file tree
Showing 11 changed files with 237 additions and 7 deletions.
9 changes: 9 additions & 0 deletions devtools/shared/css/generated/properties-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ exports.CSS_PROPERTIES = {
"radiomenuitem",
"range",
"range-thumb",
"resizer",
"resizerpanel",
"revert",
"revert-layer",
"scrollbar-horizontal",
Expand All @@ -286,6 +288,7 @@ exports.CSS_PROPERTIES = {
"spinner-upbutton",
"splitter",
"statusbar",
"statusbarpanel",
"tab",
"tab-scroll-arrow-back",
"tab-scroll-arrow-forward",
Expand Down Expand Up @@ -1535,6 +1538,8 @@ exports.CSS_PROPERTIES = {
"radiomenuitem",
"range",
"range-thumb",
"resizer",
"resizerpanel",
"revert",
"revert-layer",
"scrollbar-horizontal",
Expand All @@ -1556,6 +1561,7 @@ exports.CSS_PROPERTIES = {
"spinner-upbutton",
"splitter",
"statusbar",
"statusbarpanel",
"tab",
"tab-scroll-arrow-back",
"tab-scroll-arrow-forward",
Expand Down Expand Up @@ -3586,6 +3592,8 @@ exports.CSS_PROPERTIES = {
"radiomenuitem",
"range",
"range-thumb",
"resizer",
"resizerpanel",
"revert",
"revert-layer",
"scrollbar-horizontal",
Expand All @@ -3607,6 +3615,7 @@ exports.CSS_PROPERTIES = {
"spinner-upbutton",
"splitter",
"statusbar",
"statusbarpanel",
"tab",
"tab-scroll-arrow-back",
"tab-scroll-arrow-forward",
Expand Down
13 changes: 11 additions & 2 deletions layout/style/res/scrollbars.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ scrollbar, scrollbarbutton, scrollcorner, slider, thumb, resizer {
resizer {
position: relative;
z-index: 2147483647;
/* Widget gets decide on its own whether or not the native theme should apply,
based on the context/OS theme. If it does not, SVG background will kick in. */
appearance: auto;
-moz-default-appearance: resizer;

background: url("chrome://global/skin/icons/resizer.svg") no-repeat;
background-size: 100% 100%;
Expand All @@ -90,12 +94,17 @@ resizer {
height: 15px;
}

/* bottomstart/bottomend is supported in XUL window only */
resizer[dir="bottom"][flip],
resizer[dir="bottomleft"] {
resizer[dir="bottomleft"],
resizer[dir="bottomstart"]:-moz-locale-dir(ltr),
resizer[dir="bottomend"]:-moz-locale-dir(rtl) {
transform: scaleX(-1);
}

resizer[dir="bottomleft"] {
resizer[dir="bottomleft"],
resizer[dir="bottomstart"]:-moz-locale-dir(ltr),
resizer[dir="bottomend"]:-moz-locale-dir(rtl) {
cursor: sw-resize;
}

Expand Down
10 changes: 10 additions & 0 deletions servo/components/style/values/specified/box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,13 @@ pub enum Appearance {
Range,
#[parse(condition = "ParserContext::in_ua_or_chrome_sheet")]
RangeThumb,
/// The resizer background area in a status bar for the resizer widget in
/// the corner of a window.
#[parse(condition = "ParserContext::in_ua_or_chrome_sheet")]
Resizerpanel,
/// The resizer itself.
#[parse(condition = "ParserContext::in_ua_or_chrome_sheet")]
Resizer,
/// The scrollbar slider
#[parse(condition = "ParserContext::in_ua_or_chrome_sheet")]
ScrollbarHorizontal,
Expand Down Expand Up @@ -1566,6 +1573,9 @@ pub enum Appearance {
/// A status bar in a main application window.
#[parse(condition = "ParserContext::in_ua_or_chrome_sheet")]
Statusbar,
/// A single pane of a status bar.
#[parse(condition = "ParserContext::in_ua_or_chrome_sheet")]
Statusbarpanel,
/// A single tab in a tab widget.
#[parse(condition = "ParserContext::in_ua_or_chrome_sheet")]
Tab,
Expand Down
1 change: 1 addition & 0 deletions widget/ScrollbarDrawingWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ Maybe<nsITheme::Transparency> ScrollbarDrawingWin::GetScrollbarPartTransparency(
case StyleAppearance::ScrollbarHorizontal:
case StyleAppearance::ScrollbarVertical:
case StyleAppearance::Scrollcorner:
case StyleAppearance::Statusbar:
// Knowing that scrollbars and statusbars are opaque improves
// performance, because we create layers for them. This better be
// true across all Windows themes! If it's not true, we should
Expand Down
3 changes: 3 additions & 0 deletions widget/cocoa/nsNativeThemeCocoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ class nsNativeThemeCocoa : public mozilla::widget::ThemeCocoa {
eActiveSourceListSelection, // bool
eInactiveSourceListSelection, // bool
eTabPanel,
eResizer
};

struct WidgetInfo {
Expand Down Expand Up @@ -266,6 +267,7 @@ class nsNativeThemeCocoa : public mozilla::widget::ThemeCocoa {
return WidgetInfo(Widget::eInactiveSourceListSelection, aParams);
}
static WidgetInfo TabPanel(bool aParams) { return WidgetInfo(Widget::eTabPanel, aParams); }
static WidgetInfo Resizer(bool aParams) { return WidgetInfo(Widget::eResizer, aParams); }

template <typename T>
T Params() const {
Expand Down Expand Up @@ -391,6 +393,7 @@ class nsNativeThemeCocoa : public mozilla::widget::ThemeCocoa {
const SpinButtonParams& aParams);
void DrawToolbar(CGContextRef cgContext, const CGRect& inBoxRect, bool aIsMain);
void DrawStatusBar(CGContextRef cgContext, const HIRect& inBoxRect, bool aIsMain);
void DrawResizer(CGContextRef cgContext, const HIRect& aRect, bool aIsRTL);
void DrawMultilineTextField(CGContextRef cgContext, const CGRect& inBoxRect, bool aIsFocused);
void DrawSourceListSelection(CGContextRef aContext, const CGRect& aRect, bool aWindowIsActive,
bool aSelectionIsActive);
Expand Down
59 changes: 59 additions & 0 deletions widget/cocoa/nsNativeThemeCocoa.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2169,6 +2169,26 @@ static bool ToolbarCanBeUnified(const gfx::Rect& aRect, NSWindow* aWindow) {
NS_OBJC_END_TRY_IGNORE_BLOCK;
}

static void RenderResizer(CGContextRef cgContext, const HIRect& aRenderRect, void* aData) {
HIThemeGrowBoxDrawInfo* drawInfo = (HIThemeGrowBoxDrawInfo*)aData;
HIThemeDrawGrowBox(&CGPointZero, drawInfo, cgContext, kHIThemeOrientationNormal);
}

void nsNativeThemeCocoa::DrawResizer(CGContextRef cgContext, const HIRect& aRect, bool aIsRTL) {
NS_OBJC_BEGIN_TRY_IGNORE_BLOCK;

HIThemeGrowBoxDrawInfo drawInfo;
drawInfo.version = 0;
drawInfo.state = kThemeStateActive;
drawInfo.kind = kHIThemeGrowBoxKindNormal;
drawInfo.direction = kThemeGrowRight | kThemeGrowDown;
drawInfo.size = kHIThemeGrowBoxSizeNormal;

RenderTransformedHIThemeControl(cgContext, aRect, RenderResizer, &drawInfo, aIsRTL);

NS_OBJC_END_TRY_IGNORE_BLOCK;
}

void nsNativeThemeCocoa::DrawMultilineTextField(CGContextRef cgContext, const CGRect& inBoxRect,
bool aIsFocused) {
mTextFieldCell.enabled = YES;
Expand Down Expand Up @@ -2511,6 +2531,9 @@ static bool IsHiDPIContext(nsDeviceContext* aContext) {
case StyleAppearance::Tabpanels:
return Some(WidgetInfo::TabPanel(FrameIsInActiveWindow(aFrame)));

case StyleAppearance::Resizer:
return Some(WidgetInfo::Resizer(IsFrameRTL(aFrame)));

default:
break;
}
Expand Down Expand Up @@ -2749,6 +2772,11 @@ static bool IsWidgetNonNative(StyleAppearance aAppearance) {
DrawTabPanel(cgContext, macRect, isInsideActiveWindow);
break;
}
case Widget::eResizer: {
bool isRTL = aWidgetInfo.Params<bool>();
DrawResizer(cgContext, macRect, isRTL);
break;
}
}

// Reset the base CTM.
Expand Down Expand Up @@ -2820,6 +2848,7 @@ static bool IsWidgetNonNative(StyleAppearance aAppearance) {
case StyleAppearance::Listbox:
case StyleAppearance::Tab:
case StyleAppearance::Tabpanels:
case StyleAppearance::Resizer:
return false;

default:
Expand Down Expand Up @@ -3154,6 +3183,19 @@ static bool IsWidgetNonNative(StyleAppearance aAppearance) {
case StyleAppearance::MozMenulistArrowButton:
return ThemeCocoa::GetMinimumWidgetSize(aPresContext, aFrame, aAppearance);

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);
result.SizeTo(bounds.size.width, bounds.size.height);
break;
}
default:
break;
}
Expand All @@ -3177,6 +3219,8 @@ static bool IsWidgetNonNative(StyleAppearance aAppearance) {
case StyleAppearance::Toolbox:
case StyleAppearance::Toolbar:
case StyleAppearance::Statusbar:
case StyleAppearance::Statusbarpanel:
case StyleAppearance::Resizerpanel:
case StyleAppearance::Tooltip:
case StyleAppearance::Tabpanels:
case StyleAppearance::Tabpanel:
Expand Down Expand Up @@ -3302,6 +3346,20 @@ static bool IsWidgetNonNative(StyleAppearance aAppearance) {
case StyleAppearance::Range:
return !IsWidgetStyled(aPresContext, aFrame, aAppearance);

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 (!LookAndFeel::UseOverlayScrollbars() && scrollFrame &&
(!scrollFrame->GetScrollbarVisibility().isEmpty()));
}

default:
break;
}
Expand Down Expand Up @@ -3375,6 +3433,7 @@ static bool IsWidgetNonNative(StyleAppearance aAppearance) {
case StyleAppearance::Treeline:
case StyleAppearance::Textarea:
case StyleAppearance::Listbox:
case StyleAppearance::Resizer:
return false;
default:
return true;
Expand Down
18 changes: 18 additions & 0 deletions widget/gtk/nsNativeThemeGTK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ bool nsNativeThemeGTK::GetGtkWidgetAndState(StyleAppearance aAppearance,
case StyleAppearance::Toolbargripper:
aGtkWidgetType = MOZ_GTK_GRIPPER;
break;
case StyleAppearance::Resizer:
aGtkWidgetType = MOZ_GTK_RESIZER;
break;
case StyleAppearance::NumberInput:
case StyleAppearance::Textfield:
aGtkWidgetType = MOZ_GTK_ENTRY;
Expand Down Expand Up @@ -412,6 +415,10 @@ bool nsNativeThemeGTK::GetGtkWidgetAndState(StyleAppearance aAppearance,
case StyleAppearance::Tooltip:
aGtkWidgetType = MOZ_GTK_TOOLTIP;
break;
case StyleAppearance::Statusbarpanel:
case StyleAppearance::Resizerpanel:
aGtkWidgetType = MOZ_GTK_FRAME;
break;
case StyleAppearance::ProgressBar:
aGtkWidgetType = MOZ_GTK_PROGRESSBAR;
break;
Expand Down Expand Up @@ -1231,6 +1238,10 @@ LayoutDeviceIntSize nsNativeThemeGTK::GetMinimumWidgetSize(
result.width = 14;
result.height = 13;
break;
case StyleAppearance::Resizer:
// same as Windows to make our lives easier
result.width = result.height = 15;
break;
case StyleAppearance::Treetwisty:
case StyleAppearance::Treetwistyopen: {
gint expander_size;
Expand Down Expand Up @@ -1260,6 +1271,9 @@ nsNativeThemeGTK::WidgetStateChanged(nsIFrame* aFrame,
// Some widget types just never change state.
if (aAppearance == StyleAppearance::Toolbox ||
aAppearance == StyleAppearance::Toolbar ||
aAppearance == StyleAppearance::Statusbar ||
aAppearance == StyleAppearance::Statusbarpanel ||
aAppearance == StyleAppearance::Resizerpanel ||
aAppearance == StyleAppearance::Progresschunk ||
aAppearance == StyleAppearance::ProgressBar ||
aAppearance == StyleAppearance::Menubar ||
Expand Down Expand Up @@ -1346,6 +1360,10 @@ nsNativeThemeGTK::ThemeSupportsWidget(nsPresContext* aPresContext,
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::Treeview:
// case StyleAppearance::Treeitem:
Expand Down
25 changes: 25 additions & 0 deletions widget/nsNativeTheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,31 @@ bool nsNativeTheme::IsWidgetStyled(nsPresContext* aPresContext,
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 (aAppearance == 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.
//
// note that the condition below looks a bit suspect but it's the right
// one. If there's no valid appearance, then we should return true, it's
// effectively the same as if it had overridden the appearance.
parentFrame = parentFrame->GetParent();
if (!parentFrame) {
return false;
}
auto parentAppearance =
parentFrame->StyleDisplay()->EffectiveAppearance();
return parentAppearance == StyleAppearance::None ||
IsWidgetStyled(aPresContext, parentFrame, parentAppearance);
}
}

/**
* 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.
Expand Down
Loading

0 comments on commit 52188d9

Please sign in to comment.