33
33
#include " InputTypeNames.h"
34
34
#include " NotImplemented.h"
35
35
#include " PaintInfo.h"
36
+ #include " RenderBox.h"
36
37
#include " RenderElement.h"
37
38
#include " UserAgentScripts.h"
38
39
#include " UserAgentStyleSheets.h"
39
40
#include < ControlLook.h>
40
41
#include < View.h>
42
+ #include < private/interface/DefaultColors.h>
41
43
42
44
#include < wtf/text/StringBuilder.h>
43
45
@@ -80,7 +82,7 @@ bool RenderThemeHaiku::supportsFocusRing(const RenderStyle& style) const
80
82
81
83
bool RenderThemeHaiku::paintSliderTrack (const RenderObject& object, const PaintInfo& info, const IntRect& intRect)
82
84
{
83
- rgb_color base = ui_color (B_PANEL_BACKGROUND_COLOR );
85
+ rgb_color base = colorForValue (B_CONTROL_BACKGROUND_COLOR, object. useDarkAppearance () );
84
86
rgb_color background = base;
85
87
// TODO: From PaintInfo?
86
88
BRect rect = intRect;
@@ -156,7 +158,7 @@ bool RenderThemeHaiku::supportsDataListUI(const AtomString& type) const
156
158
157
159
bool RenderThemeHaiku::paintSliderThumb (const RenderObject& object, const PaintInfo& info, const IntRect& intRect)
158
160
{
159
- rgb_color base = ui_color (B_PANEL_BACKGROUND_COLOR );
161
+ rgb_color base = colorForValue (B_CONTROL_BACKGROUND_COLOR, object. useDarkAppearance () );
160
162
BRect rect = intRect;
161
163
BView* view = info.context ().platformContext ();
162
164
unsigned flags = flagsForObject (object);
@@ -201,7 +203,7 @@ bool RenderThemeHaiku::paintCheckbox(const RenderObject& object, const PaintInfo
201
203
if (!be_control_look)
202
204
return true ;
203
205
204
- rgb_color base = ui_color (B_PANEL_BACKGROUND_COLOR );
206
+ rgb_color base = colorForValue (B_CONTROL_BACKGROUND_COLOR, object. useDarkAppearance () );
205
207
BRect rect = floatRect;
206
208
BView* view = info.context ().platformContext ();
207
209
unsigned flags = flagsForObject (object);
@@ -237,7 +239,7 @@ bool RenderThemeHaiku::paintRadio(const RenderObject& object, const PaintInfo& i
237
239
if (!be_control_look)
238
240
return true ;
239
241
240
- rgb_color base = ui_color (B_PANEL_BACKGROUND_COLOR );
242
+ rgb_color base = colorForValue (B_CONTROL_BACKGROUND_COLOR, object. useDarkAppearance () );
241
243
BRect rect = floatRect;
242
244
BView* view = info.context ().platformContext ();
243
245
unsigned flags = flagsForObject (object);
@@ -262,7 +264,7 @@ bool RenderThemeHaiku::paintButton(const RenderObject& object, const PaintInfo&
262
264
if (!be_control_look)
263
265
return true ;
264
266
265
- rgb_color base = ui_color (B_PANEL_BACKGROUND_COLOR );
267
+ rgb_color base = colorForValue (B_CONTROL_BACKGROUND_COLOR, object. useDarkAppearance () );
266
268
rgb_color background = base;
267
269
// TODO: From PaintInfo?
268
270
BRect rect = intRect;
@@ -293,7 +295,7 @@ bool RenderThemeHaiku::paintTextField(const RenderObject& object, const PaintInf
293
295
if (!be_control_look)
294
296
return true ;
295
297
296
- rgb_color base = ui_color (B_PANEL_BACKGROUND_COLOR );
298
+ rgb_color base = colorForValue (B_CONTROL_BACKGROUND_COLOR, object. useDarkAppearance () );
297
299
// rgb_color background = base;
298
300
// TODO: From PaintInfo?
299
301
BRect rect (intRect);
@@ -321,7 +323,7 @@ void RenderThemeHaiku::adjustMenuListStyle(RenderStyle& style, const Element* el
321
323
adjustMenuListButtonStyle (style, element);
322
324
}
323
325
324
- void RenderThemeHaiku::adjustMenuListButtonStyle (RenderStyle& style, const Element* element ) const
326
+ void RenderThemeHaiku::adjustMenuListButtonStyle (RenderStyle& style, const Element*) const
325
327
{
326
328
style.resetBorder ();
327
329
style.resetBorderRadius ();
@@ -352,21 +354,19 @@ void RenderThemeHaiku::paintMenuListButtonDecorations(const RenderBox& object, c
352
354
if (!be_control_look)
353
355
return ;
354
356
355
- rgb_color base = ui_color (B_PANEL_BACKGROUND_COLOR );
357
+ rgb_color base = colorForValue (B_CONTROL_BACKGROUND_COLOR, object. firstChild ()-> useDarkAppearance () );
356
358
// TODO get the color from PaintInfo?
357
359
BRect rect = floatRect;
358
360
BView* view = info.context ().platformContext ();
359
- unsigned flags = BControlLook::B_BLEND_FRAME;
360
- // TODO unfortunately we don't get access to the RenderObject here so
361
- // we can't use flagsForObject(object) & ~BControlLook::B_CLICKED;
362
-
361
+ unsigned flags = flagsForObject (*object.firstChild ()) & ~BControlLook::B_CLICKED;
362
+
363
363
view->PushState ();
364
364
be_control_look->DrawMenuFieldFrame (view, rect, rect, base, base, flags);
365
365
be_control_look->DrawMenuFieldBackground (view, rect, rect, base, true , flags);
366
366
view->PopState ();
367
367
}
368
368
369
- bool RenderThemeHaiku::paintMenuList (const RenderObject& object , const PaintInfo& info , const FloatRect& intRect )
369
+ bool RenderThemeHaiku::paintMenuList (const RenderObject&, const PaintInfo&, const FloatRect&)
370
370
{
371
371
// This is never called: the list is handled natively as a BMenu.
372
372
return true ;
@@ -383,7 +383,79 @@ unsigned RenderThemeHaiku::flagsForObject(const RenderObject& object) const
383
383
flags |= BControlLook::B_CLICKED;
384
384
if (isChecked (object))
385
385
flags |= BControlLook::B_ACTIVATED;
386
+ if (isHovered (object))
387
+ flags |= BControlLook::B_HOVER;
386
388
return flags;
387
389
}
388
390
391
+
392
+ rgb_color RenderThemeHaiku::colorForValue (color_which colorConstant, bool useDarkAppearance) const
393
+ {
394
+ rgb_color systemColor = ui_color (B_DOCUMENT_BACKGROUND_COLOR);
395
+ if (useDarkAppearance) {
396
+ if (systemColor.Brightness () > 127 ) // system is in light mode, but we need a dark color
397
+ return BPrivate::GetSystemColor (colorConstant, true );
398
+ } else {
399
+ if (systemColor.Brightness () < 127 ) // system is in dark mode but we need a light color
400
+ return BPrivate::GetSystemColor (colorConstant, false );
401
+ }
402
+ return ui_color (colorConstant);
403
+ }
404
+
405
+
406
+ Color RenderThemeHaiku::systemColor (CSSValueID cssValueID, OptionSet<StyleColorOptions> options) const
407
+ {
408
+ const bool useDarkAppearance = options.contains (StyleColorOptions::UseDarkAppearance);
409
+
410
+ switch (cssValueID) {
411
+ case CSSValueButtonface:
412
+ return colorForValue (B_CONTROL_BACKGROUND_COLOR, useDarkAppearance);
413
+
414
+ // Doesn't exist?
415
+ // case CSSValueButtonborder:
416
+ // return colorForValue(B_CONTROL_BORDER_COLOR, useDarkAppearence);
417
+
418
+ case CSSValueActivebuttontext:
419
+ case CSSValueButtontext:
420
+ return colorForValue (B_CONTROL_TEXT_COLOR, useDarkAppearance);
421
+
422
+ case CSSValueField:
423
+ case CSSValueCanvas:
424
+ case CSSValueWindow:
425
+ return colorForValue (B_DOCUMENT_BACKGROUND_COLOR, useDarkAppearance);
426
+
427
+ case CSSValueCanvastext:
428
+ case CSSValueFieldtext:
429
+ return colorForValue (B_DOCUMENT_TEXT_COLOR, useDarkAppearance);
430
+
431
+ case CSSValueWebkitFocusRingColor:
432
+ case CSSValueActiveborder:
433
+ case CSSValueHighlight:
434
+ return colorForValue (B_CONTROL_HIGHLIGHT_COLOR, useDarkAppearance);
435
+
436
+ case CSSValueHighlighttext:
437
+ return colorForValue (B_CONTROL_TEXT_COLOR, useDarkAppearance);
438
+
439
+ case CSSValueWebkitLink:
440
+ case CSSValueLinktext:
441
+ return colorForValue (B_LINK_TEXT_COLOR, useDarkAppearance);
442
+
443
+ case CSSValueVisitedtext:
444
+ return colorForValue (B_LINK_VISITED_COLOR, useDarkAppearance);
445
+
446
+ // case CSSValueWebkitActivetext:
447
+ case CSSValueWebkitActivelink:
448
+ return colorForValue (B_LINK_ACTIVE_COLOR, useDarkAppearance);
449
+
450
+ /* is there any haiku colors that make sense to use here?
451
+ case CSSValueSelecteditem:
452
+ case CSSValueSelecteditemtext:
453
+ case CSSValueMark:
454
+ case CSSValueMarkText:
455
+ */
456
+ default :
457
+ return RenderTheme::systemColor (cssValueID, options);
458
+ }
459
+ }
460
+
389
461
} // namespace WebCore
0 commit comments