forked from ImSwordQueen/firefox-native-controls
-
Notifications
You must be signed in to change notification settings - Fork 1
/
native-controls-esr-115.3.1.diff
428 lines (420 loc) · 16.8 KB
/
native-controls-esr-115.3.1.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
# HG changeset patch
# User daylin <[email protected]>
# Date 1697093022 25200
# Wed Oct 11 23:43:42 2023 -0700
# Branch FIREFOX_ESR_115_3_X_RELBRANCH
# Node ID 232d6e70ef3246869f0c005227cec4f74eabcfb7
# Parent 749617c4473c65f8aebb2e3254777ae99dc17cce
Native scrollbars ESR 115.3.1
diff --git a/widget/windows/nsNativeThemeWin.cpp b/widget/windows/nsNativeThemeWin.cpp
--- a/widget/windows/nsNativeThemeWin.cpp
+++ b/widget/windows/nsNativeThemeWin.cpp
@@ -40,6 +40,7 @@
#include "nsWindow.h"
#include "prinrval.h"
#include "WinUtils.h"
+#include "ScrollbarDrawingWin.h"
using namespace mozilla;
using namespace mozilla::gfx;
@@ -68,8 +69,11 @@ nsNativeThemeWin::~nsNativeThemeWin() {
auto nsNativeThemeWin::IsWidgetNonNative(nsIFrame* aFrame,
StyleAppearance aAppearance)
-> NonNative {
- if (IsWidgetScrollbarPart(aAppearance) ||
- aAppearance == StyleAppearance::FocusOutline) {
+ if (IsWidgetScrollbarPart(aAppearance)) {
+ return NonNative::No;
+ }
+
+ if (aAppearance == StyleAppearance::FocusOutline) {
return NonNative::Always;
}
@@ -718,6 +722,16 @@ mozilla::Maybe<nsUXThemeClass> nsNativeT
case StyleAppearance::Tabpanel:
case StyleAppearance::Tabpanels:
return Some(eUXTab);
+ 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 StyleAppearance::Range:
case StyleAppearance::RangeThumb:
return Some(eUXTrackbar);
@@ -967,6 +981,66 @@ nsresult nsNativeThemeWin::GetThemePartA
aState = TS_NORMAL;
return NS_OK;
}
+ case StyleAppearance::ScrollbarbuttonUp:
+ case StyleAppearance::ScrollbarbuttonDown:
+ case StyleAppearance::ScrollbarbuttonLeft:
+ case StyleAppearance::ScrollbarbuttonRight: {
+ aPart = SP_BUTTON;
+ aState = (int(aAppearance) - int(StyleAppearance::ScrollbarbuttonUp)) * 4;
+ ElementState eventState = GetContentState(aFrame, aAppearance);
+ if (!aFrame)
+ aState += TS_NORMAL;
+ else if (eventState.HasState(ElementState::DISABLED))
+ aState += TS_DISABLED;
+ else {
+ nsIFrame* parent = aFrame->GetParent();
+ ElementState parentState = GetContentState(
+ parent, parent->StyleDisplay()->EffectiveAppearance());
+ if (eventState.HasAllStates(ElementState::HOVER | ElementState::ACTIVE))
+ aState += TS_ACTIVE;
+ else if (eventState.HasState(ElementState::HOVER))
+ aState += TS_HOVER;
+ else if (parentState.HasState(ElementState::HOVER))
+ aState =
+ (int(aAppearance) - int(StyleAppearance::ScrollbarbuttonUp)) +
+ SP_BUTTON_IMPLICIT_HOVER_BASE;
+ else
+ aState += TS_NORMAL;
+ }
+ return NS_OK;
+ }
+ case StyleAppearance::ScrollbarHorizontal:
+ case StyleAppearance::ScrollbarVertical: {
+ aPart = (aAppearance == StyleAppearance::ScrollbarHorizontal)
+ ? SP_TRACKSTARTHOR
+ : SP_TRACKSTARTVERT;
+ aState = TS_NORMAL;
+ return NS_OK;
+ }
+ case StyleAppearance::ScrollbarthumbHorizontal:
+ case StyleAppearance::ScrollbarthumbVertical: {
+ aPart = (aAppearance == StyleAppearance::ScrollbarthumbHorizontal)
+ ? SP_THUMBHOR
+ : SP_THUMBVERT;
+ ElementState eventState = GetContentState(aFrame, aAppearance);
+ if (!aFrame)
+ aState = TS_NORMAL;
+ else if (eventState.HasState(ElementState::DISABLED))
+ aState = TS_DISABLED;
+ else {
+ if (eventState.HasState(
+ ElementState::ACTIVE)) // Hover is not also a requirement for
+ // the thumb, since the drag is not
+ // canceled when you move outside the
+ // thumb.
+ aState = TS_ACTIVE;
+ else if (eventState.HasState(ElementState::HOVER))
+ aState = TS_HOVER;
+ else
+ aState = TS_NORMAL;
+ }
+ return NS_OK;
+ }
case StyleAppearance::Range: {
if (IsRangeHorizontal(aFrame)) {
aPart = TKP_TRACK;
@@ -1004,6 +1078,11 @@ nsresult nsNativeThemeWin::GetThemePartA
}
return NS_OK;
}
+ case StyleAppearance::Scrollcorner: {
+ aState = 0;
+ aPart = RP_BACKGROUND;
+ return NS_OK;
+ }
case StyleAppearance::SpinnerUpbutton:
case StyleAppearance::SpinnerDownbutton: {
aPart = (aAppearance == StyleAppearance::SpinnerUpbutton) ? SPNP_UP
@@ -1696,6 +1775,26 @@ RENDER_AGAIN:
widgetRect.bottom = widgetRect.top + TB_SEPARATOR_HEIGHT;
DrawThemeEdge(theme, hdc, RP_BAND, 0, &widgetRect, EDGE_ETCHED, BF_TOP,
nullptr);
+ } else if (aAppearance == StyleAppearance::ScrollbarthumbHorizontal ||
+ aAppearance == StyleAppearance::ScrollbarthumbVertical) {
+ // Draw the decorative gripper for the scrollbar thumb button, if it fits
+
+ SIZE gripSize;
+ MARGINS thumbMgns;
+ int gripPart = (aAppearance == 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);
+ }
}
nativeDrawing.EndNativeDrawing();
@@ -1745,7 +1844,11 @@ LayoutDeviceIntMargin nsNativeThemeWin::
if (!themeClass.isNothing()) {
theme = nsUXThemeData::GetTheme(themeClass.value());
}
- if (!theme) {
+
+ // Classic scrollbar thumbs require classic borders. The theme procedure will
+ // break horizontal scrollbar thumbs otherwise.
+ if (aAppearance == StyleAppearance::ScrollbarthumbVertical ||
+ aAppearance == StyleAppearance::ScrollbarthumbHorizontal || !theme) {
result = ClassicGetWidgetBorder(aContext, aFrame, aAppearance);
ScaleForFrameDPI(&result, aFrame);
return result;
@@ -1757,6 +1860,9 @@ LayoutDeviceIntMargin nsNativeThemeWin::
aAppearance == StyleAppearance::MozWinCommunicationsToolbox ||
aAppearance == StyleAppearance::MozWinBrowsertabbarToolbox ||
aAppearance == StyleAppearance::Tabpanel ||
+ aAppearance == StyleAppearance::ScrollbarHorizontal ||
+ aAppearance == StyleAppearance::ScrollbarVertical ||
+ aAppearance == StyleAppearance::Scrollcorner ||
aAppearance == StyleAppearance::Menuitem ||
aAppearance == StyleAppearance::Checkmenuitem ||
aAppearance == StyleAppearance::Radiomenuitem ||
@@ -2051,6 +2157,14 @@ LayoutDeviceIntSize nsNativeThemeWin::Ge
// Windows appears to always use metrics when drawing standard scrollbars)
THEMESIZE sizeReq = TS_TRUE; // Best-fit size
switch (aAppearance) {
+ case StyleAppearance::ScrollbarthumbHorizontal:
+ case StyleAppearance::ScrollbarthumbVertical:
+ case StyleAppearance::ScrollbarbuttonUp:
+ case StyleAppearance::ScrollbarbuttonDown:
+ case StyleAppearance::ScrollbarbuttonLeft:
+ case StyleAppearance::ScrollbarbuttonRight:
+ case StyleAppearance::ScrollbarHorizontal:
+ case StyleAppearance::ScrollbarVertical:
case StyleAppearance::MozMenulistArrowButton: {
auto result = ClassicGetMinimumWidgetSize(aFrame, aAppearance);
ScaleForFrameDPI(&result, aFrame);
@@ -2095,6 +2209,17 @@ LayoutDeviceIntSize nsNativeThemeWin::Ge
return result;
}
+ case StyleAppearance::Scrollcorner: {
+ if (nsLookAndFeel::GetInt(nsLookAndFeel::IntID::UseOverlayScrollbars) !=
+ 0) {
+ LayoutDeviceIntSize result(::GetSystemMetrics(SM_CXHSCROLL),
+ ::GetSystemMetrics(SM_CYVSCROLL));
+ ScaleForFrameDPI(&result, aFrame);
+ return result;
+ }
+ break;
+ }
+
case StyleAppearance::Separator: {
// that's 2px left margin, 2px right margin and 2px separator
// (the margin is drawn as part of the separator, though)
@@ -2400,6 +2525,15 @@ bool nsNativeThemeWin::ClassicThemeSuppo
case StyleAppearance::Range:
case StyleAppearance::RangeThumb:
case StyleAppearance::Groupbox:
+ case StyleAppearance::ScrollbarbuttonUp:
+ case StyleAppearance::ScrollbarbuttonDown:
+ case StyleAppearance::ScrollbarbuttonLeft:
+ case StyleAppearance::ScrollbarbuttonRight:
+ case StyleAppearance::ScrollbarthumbVertical:
+ case StyleAppearance::ScrollbarthumbHorizontal:
+ case StyleAppearance::ScrollbarVertical:
+ case StyleAppearance::ScrollbarHorizontal:
+ case StyleAppearance::Scrollcorner:
case StyleAppearance::Menulist:
case StyleAppearance::MenulistButton:
case StyleAppearance::MozMenulistArrowButton:
@@ -2526,6 +2660,25 @@ LayoutDeviceIntSize nsNativeThemeWin::Cl
result.width = ::GetSystemMetrics(SM_CXVSCROLL);
result.height = 8; // No good metrics available for this
break;
+ case StyleAppearance::ScrollbarbuttonUp:
+ case StyleAppearance::ScrollbarbuttonDown:
+ result.width = ::GetSystemMetrics(SM_CXVSCROLL);
+ result.height = ::GetSystemMetrics(SM_CYVSCROLL);
+ break;
+ case StyleAppearance::ScrollbarbuttonLeft:
+ case StyleAppearance::ScrollbarbuttonRight:
+ // For scrollbar-width:thin, we don't display the buttons.
+ if (!ScrollbarDrawing::IsScrollbarWidthThin(aFrame)) {
+ result.width = ::GetSystemMetrics(SM_CXHSCROLL);
+ result.height = ::GetSystemMetrics(SM_CYHSCROLL);
+ }
+ break;
+ case StyleAppearance::ScrollbarVertical:
+ case StyleAppearance::ScrollbarHorizontal:
+ // Sizing code needed after removal of XUL layout (around ESR 115)
+ result.width = ::GetSystemMetrics(SM_CYHSCROLL);
+ result.height = ::GetSystemMetrics(SM_CYHSCROLL);
+ break;
case StyleAppearance::RangeThumb: {
if (IsRangeHorizontal(aFrame)) {
result.width = 12;
@@ -2536,6 +2689,35 @@ LayoutDeviceIntSize nsNativeThemeWin::Cl
}
break;
}
+ case StyleAppearance::ScrollbarthumbVertical:
+ result.width = ::GetSystemMetrics(SM_CXVSCROLL);
+ result.height = ::GetSystemMetrics(SM_CYVTHUMB);
+ // Without theming, divide the thumb size by two in order to look more
+ // native
+ if (!GetTheme(aAppearance)) {
+ result.height >>= 1;
+ }
+ // If scrollbar-width is thin, divide the thickness by two to make
+ // it look more compact.
+ if (ScrollbarDrawing::IsScrollbarWidthThin(aFrame)) {
+ result.width >>= 1;
+ }
+ break;
+ case StyleAppearance::ScrollbarthumbHorizontal:
+ result.width = ::GetSystemMetrics(SM_CXHTHUMB);
+ result.height = ::GetSystemMetrics(SM_CYHSCROLL);
+ // Without theming, divide the thumb size by two in order to look more
+ // native
+ if (TRUE || !GetTheme(aAppearance)) {
+ result.width >>= 1;
+ }
+ // If scrollbar-width is thin, divide the thickness by two to make
+ // it look more compact.
+ if (ScrollbarDrawing::IsScrollbarWidthThin(aFrame)) {
+ result.height >>= 1;
+ }
+
+ break;
case StyleAppearance::MozMenulistArrowButton:
result.width = ::GetSystemMetrics(SM_CXVSCROLL);
break;
@@ -2732,6 +2914,11 @@ nsresult nsNativeThemeWin::ClassicGetThe
case StyleAppearance::MenulistButton:
case StyleAppearance::Range:
case StyleAppearance::RangeThumb:
+ case StyleAppearance::ScrollbarthumbVertical:
+ case StyleAppearance::ScrollbarthumbHorizontal:
+ case StyleAppearance::ScrollbarVertical:
+ case StyleAppearance::ScrollbarHorizontal:
+ case StyleAppearance::Scrollcorner:
case StyleAppearance::Progresschunk:
case StyleAppearance::ProgressBar:
case StyleAppearance::Tab:
@@ -2777,6 +2964,39 @@ nsresult nsNativeThemeWin::ClassicGetThe
return NS_OK;
}
+ case StyleAppearance::ScrollbarbuttonUp:
+ case StyleAppearance::ScrollbarbuttonDown:
+ case StyleAppearance::ScrollbarbuttonLeft:
+ case StyleAppearance::ScrollbarbuttonRight: {
+ ElementState contentState = GetContentState(aFrame, aAppearance);
+
+ aPart = DFC_SCROLL;
+ switch (aAppearance) {
+ case StyleAppearance::ScrollbarbuttonUp:
+ aState = DFCS_SCROLLUP;
+ break;
+ case StyleAppearance::ScrollbarbuttonDown:
+ aState = DFCS_SCROLLDOWN;
+ break;
+ case StyleAppearance::ScrollbarbuttonLeft:
+ aState = DFCS_SCROLLLEFT;
+ break;
+ case StyleAppearance::ScrollbarbuttonRight:
+ aState = DFCS_SCROLLRIGHT;
+ break;
+ default:
+ break;
+ }
+
+ if (contentState.HasState(ElementState::DISABLED)) {
+ aState |= DFCS_INACTIVE;
+ } else if (contentState.HasAllStates(ElementState::HOVER |
+ ElementState::ACTIVE)) {
+ aState |= DFCS_PUSHED | DFCS_FLAT;
+ }
+
+ return NS_OK;
+ }
case StyleAppearance::SpinnerUpbutton:
case StyleAppearance::SpinnerDownbutton: {
ElementState contentState = GetContentState(aFrame, aAppearance);
@@ -3055,6 +3275,10 @@ RENDER_AGAIN:
// Draw controls supported by DrawFrameControl
case StyleAppearance::Checkbox:
case StyleAppearance::Radio:
+ case StyleAppearance::ScrollbarbuttonUp:
+ case StyleAppearance::ScrollbarbuttonDown:
+ case StyleAppearance::ScrollbarbuttonLeft:
+ case StyleAppearance::ScrollbarbuttonRight:
case StyleAppearance::SpinnerUpbutton:
case StyleAppearance::SpinnerDownbutton:
case StyleAppearance::MozMenulistArrowButton: {
@@ -3110,6 +3334,12 @@ RENDER_AGAIN:
::FillRect(hdc, &widgetRect, (HBRUSH)(COLOR_BTNFACE + 1));
break;
}
+ // Draw scrollbar thumb
+ case StyleAppearance::ScrollbarthumbVertical:
+ case StyleAppearance::ScrollbarthumbHorizontal:
+ ::DrawEdge(hdc, &widgetRect, EDGE_RAISED, BF_RECT | BF_MIDDLE);
+
+ break;
case StyleAppearance::RangeThumb: {
ElementState elementState = GetContentState(aFrame, aAppearance);
@@ -3147,6 +3377,37 @@ RENDER_AGAIN:
break;
}
+ // Draw scrollbar track background
+ case StyleAppearance::ScrollbarVertical:
+ case StyleAppearance::ScrollbarHorizontal: {
+ // Windows fills in the scrollbar track differently
+ // depending on whether these are equal
+ DWORD color3D, colorScrollbar, colorWindow;
+
+ color3D = ::GetSysColor(COLOR_3DFACE);
+ colorWindow = ::GetSysColor(COLOR_WINDOW);
+ colorScrollbar = ::GetSysColor(COLOR_SCROLLBAR);
+
+ if ((color3D != colorScrollbar) && (colorWindow != colorScrollbar))
+ // Use solid brush
+ ::FillRect(hdc, &widgetRect, (HBRUSH)(COLOR_SCROLLBAR + 1));
+ else {
+ DrawCheckedRect(hdc, widgetRect, COLOR_3DHILIGHT, COLOR_3DFACE,
+ (HBRUSH)COLOR_SCROLLBAR + 1);
+ }
+ // XXX should invert the part of the track being clicked here
+ // but the track is never :active
+
+ break;
+ }
+ case StyleAppearance::Scrollcorner: {
+ ::FillRect(hdc, &widgetRect, (HBRUSH)(COLOR_SCROLLBAR + 1));
+
+ // Are Mozilla fucking retarded? They added this in 2018
+ // (https://github.com/mozilla/gecko-dev/blob/7038d5f94456dcb558f7c7f6fe66d913070001c5/widget/windows/nsNativeThemeWin.cpp#L3793-L3795)
+ // and never fixed this fallthrough.
+ break;
+ }
case StyleAppearance::Progresschunk: {
nsIFrame* stateFrame = aFrame->GetParent();
ElementState elementState = GetContentState(stateFrame, aAppearance);
diff --git a/widget/windows/nsUXThemeData.cpp b/widget/windows/nsUXThemeData.cpp
--- a/widget/windows/nsUXThemeData.cpp
+++ b/widget/windows/nsUXThemeData.cpp
@@ -94,6 +94,8 @@ const wchar_t* nsUXThemeData::GetClassNa
return L"Communications::Rebar";
case eUXBrowserTabBarRebar:
return L"BrowserTabBar::Rebar";
+ case eUXScrollbar:
+ return L"Scrollbar";
case eUXToolbar:
return L"Toolbar";
case eUXMediaToolbar:
diff --git a/widget/windows/nsUXThemeData.h b/widget/windows/nsUXThemeData.h
--- a/widget/windows/nsUXThemeData.h
+++ b/widget/windows/nsUXThemeData.h
@@ -28,6 +28,7 @@ enum nsUXThemeClass {
eUXCommunicationsToolbar,
eUXProgress,
eUXTab,
+ eUXScrollbar,
eUXTrackbar,
eUXSpin,
eUXCombobox,