diff --git a/Source/WTF/wtf/PlatformHave.h b/Source/WTF/wtf/PlatformHave.h index c278203012e7..76d66f603229 100644 --- a/Source/WTF/wtf/PlatformHave.h +++ b/Source/WTF/wtf/PlatformHave.h @@ -418,7 +418,7 @@ #define HAVE_FOUNDATION_WITH_SAME_SITE_COOKIE_SUPPORT 1 #endif -#if PLATFORM(MAC) || PLATFORM(IOS) || PLATFORM(MACCATALYST) || PLATFORM(GTK) || PLATFORM(WPE) +#if PLATFORM(MAC) || PLATFORM(IOS) || PLATFORM(MACCATALYST) || PLATFORM(GTK) || PLATFORM(WPE) || PLATFORM(HAIKU) #define HAVE_OS_DARK_MODE_SUPPORT 1 #endif diff --git a/Source/WebCore/PlatformHaiku.cmake b/Source/WebCore/PlatformHaiku.cmake index d6ab348ecd5d..bf371d056dcc 100644 --- a/Source/WebCore/PlatformHaiku.cmake +++ b/Source/WebCore/PlatformHaiku.cmake @@ -351,3 +351,5 @@ list(APPEND WebCore_PRIVATE_FRAMEWORK_HEADERS platform/graphics/haiku/ImageBufferDataHaiku.h platform/graphics/Image.h ) + +set(CSS_VALUE_PLATFORM_DEFINES "HAVE_OS_DARK_MODE_SUPPORT=1") diff --git a/Source/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp b/Source/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp index 7cbb447fef31..3f2d97bf4f1c 100644 --- a/Source/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp +++ b/Source/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp @@ -48,6 +48,13 @@ #include #include +//#define TRACE_GRAPHICS_HAIKU +#ifdef TRACE_GRAPHICS_HAIKU +# define HGTRACE(x) printf x +#else +# define HGTRACE(x) ; +#endif + namespace WebCore { @@ -74,6 +81,7 @@ GraphicsContextHaiku::~GraphicsContextHaiku() // Draws a filled rectangle with a stroked border. void GraphicsContextHaiku::drawRect(const FloatRect& rect, float borderThickness) { + HGTRACE(("drawRect: [%f:%f] [%f:%f]\n", rect.x(), rect.y(), rect.width(), rect.height())); if (m_state.fillBrush().pattern()) notImplemented(); else if (m_state.fillBrush().gradient()) { @@ -87,11 +95,15 @@ void GraphicsContextHaiku::drawRect(const FloatRect& rect, float borderThickness void GraphicsContextHaiku::drawNativeImage(NativeImage& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) { + HGTRACE(("drawNativeImage: src([%f:%f] [%f:%f])\n", srcRect.x(), srcRect.y(), srcRect.width(), srcRect.height())); + HGTRACE((" dest([%f:%f] [%f:%f])\n", destRect.x(), destRect.y(), destRect.width(), destRect.height())); drawBitmap(image.platformImage().get(), imageSize, destRect, srcRect, options); } void GraphicsContextHaiku::drawBitmap(BBitmap* image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) { + HGTRACE(("drawBitmap: src([%f:%f] [%f:%f])\n", srcRect.x(), srcRect.y(), srcRect.width(), srcRect.height())); + HGTRACE((" dest([%f:%f] [%f:%f])\n", destRect.x(), destRect.y(), destRect.width(), destRect.height())); m_view->PushState(); setCompositeOperation(options.compositeOperator()); @@ -115,6 +127,7 @@ void GraphicsContextHaiku::drawBitmap(BBitmap* image, const FloatSize& imageSize // the edges, but opposite corners of the rectangle containing the line. void GraphicsContextHaiku::drawLine(const FloatPoint& point1, const FloatPoint& point2) { + HGTRACE(("drawline: [%f:%f] [%f:%f])\n", point1.x(), point1.y(), point2.x(), point2.y())); if (strokeStyle() == NoStroke || !strokeColor().isVisible()) return; @@ -137,6 +150,7 @@ void GraphicsContextHaiku::drawLine(const FloatPoint& point1, const FloatPoint& // This method is only used to draw the little circles used in lists. void GraphicsContextHaiku::drawEllipse(const FloatRect& rect) { + HGTRACE(("drawEllipse: [%f:%f] [%f:%f]\n", rect.x(), rect.y(), rect.width(), rect.height())); if (m_state.fillBrush().pattern() || m_state.fillBrush().gradient() || fillColor().isVisible()) { // TODO: What's this shadow business? if (m_state.fillBrush().pattern()) @@ -155,6 +169,7 @@ void GraphicsContextHaiku::drawEllipse(const FloatRect& rect) void GraphicsContextHaiku::strokeRect(const FloatRect& rect, float width) { + HGTRACE(("strokeRect: [%f:%f] [%f:%f] width:%f\n", rect.x(), rect.y(), rect.width(), rect.height(), width)); if (strokeStyle() == NoStroke || width <= 0.0f || !strokeColor().isVisible()) return; @@ -167,6 +182,7 @@ void GraphicsContextHaiku::strokeRect(const FloatRect& rect, float width) void GraphicsContextHaiku::strokePath(const Path& path) { + HGTRACE(("strokePath: (--todo print values)\n")); m_view->MovePenTo(B_ORIGIN); // TODO: stroke the shadow (cf shadowAndStrokeCurrentCairoPath) @@ -189,6 +205,7 @@ void GraphicsContextHaiku::strokePath(const Path& path) void GraphicsContextHaiku::fillRect(const FloatRect& rect, const Color& color) { + HGTRACE(("fillRect(color): [%f:%f] [%f:%f]\n", rect.x(), rect.y(), rect.width(), rect.height())); rgb_color previousColor = m_view->HighColor(); #if 0 @@ -207,12 +224,14 @@ void GraphicsContextHaiku::fillRect(const FloatRect& rect, const Color& color) void GraphicsContextHaiku::fillRect(const FloatRect& rect) { + HGTRACE(("fillRect: [%f:%f] [%f:%f]\n", rect.x(), rect.y(), rect.width(), rect.height())); // TODO fill the shadow m_view->FillRect(rect, B_SOLID_LOW); } void GraphicsContextHaiku::fillRoundedRectImpl(const FloatRoundedRect& roundRect, const Color& color) { + HGTRACE(("fillRoundedRectImpl: (--todo print values)\n")); if (!color.isVisible()) return; @@ -276,6 +295,7 @@ void GraphicsContextHaiku::fillRoundedRectImpl(const FloatRoundedRect& roundRect void GraphicsContextHaiku::fillPath(const Path& path) { + HGTRACE(("fillPath: (--todo print values)\n")); m_view->SetFillRule(fillRule() == WindRule::NonZero ? B_NONZERO : B_EVEN_ODD); m_view->MovePenTo(B_ORIGIN); @@ -300,11 +320,13 @@ void GraphicsContextHaiku::fillPath(const Path& path) void GraphicsContextHaiku::clip(const FloatRect& rect) { + HGTRACE(("clip: [%f:%f] [%f:%f]\n", rect.x(), rect.y(), rect.width(), rect.height())); m_view->ClipToRect(rect); } void GraphicsContextHaiku::clipPath(const Path& path, WindRule windRule) { + HGTRACE(("clipPath: (--todo print values)\n")); int32 fillRule = m_view->FillRule(); m_view->SetFillRule(windRule == WindRule::EvenOdd ? B_EVEN_ODD : B_NONZERO); @@ -318,6 +340,7 @@ void GraphicsContextHaiku::drawPattern(NativeImage& image, const FloatRect& dest const FloatRect& tileRect, const AffineTransform& transform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& options) { + HGTRACE(("drawPattern: (--todo print values)\n")); drawBitmap(image.platformImage().get(), image.size(), destRect, tileRect, transform, phase, spacing, options); } @@ -325,6 +348,7 @@ void GraphicsContextHaiku::drawBitmap(BBitmap* image, const WebCore::FloatSize& const FloatRect& tileRect, const AffineTransform&, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions&) { + HGTRACE(("drawBitmap: (--todo print values)\n")); if (!image->IsValid()) // If the image hasn't fully loaded. return; @@ -365,6 +389,7 @@ void GraphicsContextHaiku::drawBitmap(BBitmap* image, const WebCore::FloatSize& void GraphicsContextHaiku::clipOut(const Path& path) { + HGTRACE(("clipOut(path): (--todo print values)\n")); if (path.isEmpty()) return; @@ -373,11 +398,13 @@ void GraphicsContextHaiku::clipOut(const Path& path) void GraphicsContextHaiku::clipOut(const FloatRect& rect) { + HGTRACE(("clipOut: [%f:%f] [%f:%f]\n", rect.x(), rect.y(), rect.width(), rect.height())); m_view->ClipToInverseRect(rect); } void GraphicsContextHaiku::drawFocusRing(const Path& path, float width, float /*offset*/, const Color& color) { + HGTRACE(("drawFocusRing(path): (--todo print values)\n")); if (width <= 0 || !color.isVisible()) return; @@ -394,6 +421,7 @@ void GraphicsContextHaiku::drawFocusRing(const Path& path, float width, float /* void GraphicsContextHaiku::drawFocusRing(const Vector& rects, float width, float /* offset */, const Color& color) { + HGTRACE(("drawFocusRing(rects): (--todo print values)\n")); if (width <= 0 || !color.isVisible()) return; @@ -422,6 +450,7 @@ void GraphicsContextHaiku::drawLinesForText(const FloatPoint& point, float thickness, const DashArray& widths, bool printing, bool doubleUnderlines, WebCore::StrokeStyle style) { + HGTRACE(("drawLinesForText: (--todo print values)\n")); if (widths.isEmpty() || style == NoStroke) return; @@ -451,12 +480,14 @@ void GraphicsContextHaiku::drawLinesForText(const FloatPoint& point, void GraphicsContextHaiku::drawDotsForDocumentMarker(WebCore::FloatRect const&, WebCore::DocumentMarkerLineStyle) { + HGTRACE(("drawDotsForDocumentMarker: Not Implemented\n")); notImplemented(); } /* Used by canvas.clearRect. Must clear the given rectangle with transparent black. */ void GraphicsContextHaiku::clearRect(const FloatRect& rect) { + HGTRACE(("clearRect: [%f:%f] [%f:%f]\n", rect.x(), rect.y(), rect.width(), rect.height())); m_view->PushState(); m_view->SetHighColor(0, 0, 0, 0); m_view->SetDrawingMode(B_OP_COPY); @@ -466,6 +497,7 @@ void GraphicsContextHaiku::clearRect(const FloatRect& rect) void GraphicsContextHaiku::setLineCap(LineCap lineCap) { + HGTRACE(("setLineCap: (--todo print values)\n")); cap_mode mode = B_BUTT_CAP; switch (lineCap) { case LineCap::Round: @@ -484,12 +516,14 @@ void GraphicsContextHaiku::setLineCap(LineCap lineCap) void GraphicsContextHaiku::setLineDash(const DashArray& /*dashes*/, float /*dashOffset*/) { + HGTRACE(("setLineDash: Not Implemented\n")); // TODO this is used to draw dashed strokes in SVG, but we need app_server support notImplemented(); } void GraphicsContextHaiku::setLineJoin(LineJoin lineJoin) { + HGTRACE(("setLineJoin: (--todo print values)\n")); join_mode mode = B_MITER_JOIN; switch (lineJoin) { case LineJoin::Round: @@ -508,11 +542,13 @@ void GraphicsContextHaiku::setLineJoin(LineJoin lineJoin) void GraphicsContextHaiku::setMiterLimit(float limit) { + HGTRACE(("setMiterLimit: %f\n", limit)); m_view->SetLineMode(m_view->LineCapMode(), m_view->LineJoinMode(), limit); } AffineTransform GraphicsContextHaiku::getCTM(IncludeDeviceScale) const { + HGTRACE(("getCTM: no values used\n")); BAffineTransform t = m_view->Transform(); // TODO: we actually need to use the combined transform here? AffineTransform matrix(t.sx, t.shy, t.shx, t.sy, t.tx, t.ty); @@ -521,6 +557,7 @@ AffineTransform GraphicsContextHaiku::getCTM(IncludeDeviceScale) const void GraphicsContextHaiku::translate(float x, float y) { + HGTRACE(("translate: %f, %f\n", x, y)); if (x == 0.f && y == 0.f) return; @@ -529,6 +566,7 @@ void GraphicsContextHaiku::translate(float x, float y) void GraphicsContextHaiku::rotate(float radians) { + HGTRACE(("rotate: %f\n", radians)); if (radians == 0.f) return; @@ -537,11 +575,13 @@ void GraphicsContextHaiku::rotate(float radians) void GraphicsContextHaiku::scale(const FloatSize& size) { + HGTRACE(("scale: %f %f\n", size.width(), size.height())); m_view->ScaleBy(size.width(), size.height()); } void GraphicsContextHaiku::concatCTM(const AffineTransform& transform) { + HGTRACE(("concatCTM: (--todo print values)\n")); BAffineTransform current = m_view->Transform(); current.Multiply(transform); m_view->SetTransform(current); @@ -549,11 +589,13 @@ void GraphicsContextHaiku::concatCTM(const AffineTransform& transform) void GraphicsContextHaiku::setCTM(const AffineTransform& transform) { + HGTRACE(("setCTM: (--todo print values)\n")); m_view->SetTransform(transform); } void GraphicsContextHaiku::didUpdateState(GraphicsContextState& state) { + HGTRACE(("didUpdateState: (--todo print values)\n")); #if 0 StrokeGradientChange = 1 << 0, StrokePatternChange = 1 << 1, @@ -702,18 +744,21 @@ void GraphicsContextHaiku::set3DTransform(const TransformationMatrix& transform) void GraphicsContextHaiku::beginTransparencyLayer(float opacity) { + HGTRACE(("beginTransparencyLayer: %f\n", opacity)); GraphicsContext::beginTransparencyLayer(opacity); m_view->BeginLayer(static_cast(opacity * 255.0)); } void GraphicsContextHaiku::endTransparencyLayer() { + HGTRACE(("endTransparencyLayer: no values\n")); GraphicsContext::endTransparencyLayer(); m_view->EndLayer(); } IntRect GraphicsContextHaiku::clipBounds() const { + HGTRACE(("clipBounds: no values\n")); // This can be used by drawing code to do some early clipping (for example // the SVG code may skip complete parts of the image which are outside // the bounds). @@ -744,12 +789,14 @@ IntRect GraphicsContextHaiku::clipBounds() const void GraphicsContextHaiku::save() { + HGTRACE(("save: no values\n")); m_view->PushState(); GraphicsContext::save(); } void GraphicsContextHaiku::restore() { + HGTRACE(("restore: no values\n")); GraphicsContext::restore(); m_view->PopState(); } diff --git a/Source/WebCore/platform/haiku/RenderThemeHaiku.cpp b/Source/WebCore/platform/haiku/RenderThemeHaiku.cpp index 05d8a04c4f8b..bea1520ca345 100644 --- a/Source/WebCore/platform/haiku/RenderThemeHaiku.cpp +++ b/Source/WebCore/platform/haiku/RenderThemeHaiku.cpp @@ -33,11 +33,13 @@ #include "InputTypeNames.h" #include "NotImplemented.h" #include "PaintInfo.h" +#include "RenderBox.h" #include "RenderElement.h" #include "UserAgentScripts.h" #include "UserAgentStyleSheets.h" #include #include +#include #include @@ -80,7 +82,7 @@ bool RenderThemeHaiku::supportsFocusRing(const RenderStyle& style) const bool RenderThemeHaiku::paintSliderTrack(const RenderObject& object, const PaintInfo& info, const IntRect& intRect) { - rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); + rgb_color base = colorForValue(B_CONTROL_BACKGROUND_COLOR, object.useDarkAppearance()); rgb_color background = base; // TODO: From PaintInfo? BRect rect = intRect; @@ -156,7 +158,7 @@ bool RenderThemeHaiku::supportsDataListUI(const AtomString& type) const bool RenderThemeHaiku::paintSliderThumb(const RenderObject& object, const PaintInfo& info, const IntRect& intRect) { - rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); + rgb_color base = colorForValue(B_CONTROL_BACKGROUND_COLOR, object.useDarkAppearance()); BRect rect = intRect; BView* view = info.context().platformContext(); unsigned flags = flagsForObject(object); @@ -201,7 +203,7 @@ bool RenderThemeHaiku::paintCheckbox(const RenderObject& object, const PaintInfo if (!be_control_look) return true; - rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); + rgb_color base = colorForValue(B_CONTROL_BACKGROUND_COLOR, object.useDarkAppearance()); BRect rect = floatRect; BView* view = info.context().platformContext(); unsigned flags = flagsForObject(object); @@ -237,7 +239,7 @@ bool RenderThemeHaiku::paintRadio(const RenderObject& object, const PaintInfo& i if (!be_control_look) return true; - rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); + rgb_color base = colorForValue(B_CONTROL_BACKGROUND_COLOR, object.useDarkAppearance()); BRect rect = floatRect; BView* view = info.context().platformContext(); unsigned flags = flagsForObject(object); @@ -262,7 +264,7 @@ bool RenderThemeHaiku::paintButton(const RenderObject& object, const PaintInfo& if (!be_control_look) return true; - rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); + rgb_color base = colorForValue(B_CONTROL_BACKGROUND_COLOR, object.useDarkAppearance()); rgb_color background = base; // TODO: From PaintInfo? BRect rect = intRect; @@ -293,7 +295,7 @@ bool RenderThemeHaiku::paintTextField(const RenderObject& object, const PaintInf if (!be_control_look) return true; - rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); + rgb_color base = colorForValue(B_CONTROL_BACKGROUND_COLOR, object.useDarkAppearance()); //rgb_color background = base; // TODO: From PaintInfo? BRect rect(intRect); @@ -321,7 +323,7 @@ void RenderThemeHaiku::adjustMenuListStyle(RenderStyle& style, const Element* el adjustMenuListButtonStyle(style, element); } -void RenderThemeHaiku::adjustMenuListButtonStyle(RenderStyle& style, const Element* element) const +void RenderThemeHaiku::adjustMenuListButtonStyle(RenderStyle& style, const Element*) const { style.resetBorder(); style.resetBorderRadius(); @@ -352,21 +354,19 @@ void RenderThemeHaiku::paintMenuListButtonDecorations(const RenderBox& object, c if (!be_control_look) return; - rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); + rgb_color base = colorForValue(B_CONTROL_BACKGROUND_COLOR, object.firstChild()->useDarkAppearance()); // TODO get the color from PaintInfo? BRect rect = floatRect; BView* view = info.context().platformContext(); - unsigned flags = BControlLook::B_BLEND_FRAME; - // TODO unfortunately we don't get access to the RenderObject here so - // we can't use flagsForObject(object) & ~BControlLook::B_CLICKED; - + unsigned flags = flagsForObject(*object.firstChild()) & ~BControlLook::B_CLICKED; + view->PushState(); be_control_look->DrawMenuFieldFrame(view, rect, rect, base, base, flags); be_control_look->DrawMenuFieldBackground(view, rect, rect, base, true, flags); view->PopState(); } -bool RenderThemeHaiku::paintMenuList(const RenderObject& object, const PaintInfo& info, const FloatRect& intRect) +bool RenderThemeHaiku::paintMenuList(const RenderObject&, const PaintInfo&, const FloatRect&) { // This is never called: the list is handled natively as a BMenu. return true; @@ -383,7 +383,79 @@ unsigned RenderThemeHaiku::flagsForObject(const RenderObject& object) const flags |= BControlLook::B_CLICKED; if (isChecked(object)) flags |= BControlLook::B_ACTIVATED; + if (isHovered(object)) + flags |= BControlLook::B_HOVER; return flags; } + +rgb_color RenderThemeHaiku::colorForValue(color_which colorConstant, bool useDarkAppearance) const +{ + rgb_color systemColor = ui_color(B_DOCUMENT_BACKGROUND_COLOR); + if (useDarkAppearance) { + if (systemColor.Brightness() > 127) // system is in light mode, but we need a dark color + return BPrivate::GetSystemColor(colorConstant, true); + } else { + if (systemColor.Brightness() < 127) // system is in dark mode but we need a light color + return BPrivate::GetSystemColor(colorConstant, false); + } + return ui_color(colorConstant); +} + + +Color RenderThemeHaiku::systemColor(CSSValueID cssValueID, OptionSet options) const +{ + const bool useDarkAppearance = options.contains(StyleColorOptions::UseDarkAppearance); + + switch (cssValueID) { + case CSSValueButtonface: + return colorForValue(B_CONTROL_BACKGROUND_COLOR, useDarkAppearance); + + // Doesn't exist? + //case CSSValueButtonborder: + // return colorForValue(B_CONTROL_BORDER_COLOR, useDarkAppearence); + + case CSSValueActivebuttontext: + case CSSValueButtontext: + return colorForValue(B_CONTROL_TEXT_COLOR, useDarkAppearance); + + case CSSValueField: + case CSSValueCanvas: + case CSSValueWindow: + return colorForValue(B_DOCUMENT_BACKGROUND_COLOR, useDarkAppearance); + + case CSSValueCanvastext: + case CSSValueFieldtext: + return colorForValue(B_DOCUMENT_TEXT_COLOR, useDarkAppearance); + + case CSSValueWebkitFocusRingColor: + case CSSValueActiveborder: + case CSSValueHighlight: + return colorForValue(B_CONTROL_HIGHLIGHT_COLOR, useDarkAppearance); + + case CSSValueHighlighttext: + return colorForValue(B_CONTROL_TEXT_COLOR, useDarkAppearance); + + case CSSValueWebkitLink: + case CSSValueLinktext: + return colorForValue(B_LINK_TEXT_COLOR, useDarkAppearance); + + case CSSValueVisitedtext: + return colorForValue(B_LINK_VISITED_COLOR, useDarkAppearance); + + // case CSSValueWebkitActivetext: + case CSSValueWebkitActivelink: + return colorForValue(B_LINK_ACTIVE_COLOR, useDarkAppearance); + + /* is there any haiku colors that make sense to use here? + case CSSValueSelecteditem: + case CSSValueSelecteditemtext: + case CSSValueMark: + case CSSValueMarkText: + */ + default: + return RenderTheme::systemColor(cssValueID, options); + } +} + } // namespace WebCore diff --git a/Source/WebCore/platform/haiku/RenderThemeHaiku.h b/Source/WebCore/platform/haiku/RenderThemeHaiku.h index 50ccc71c41d1..d74d264366d2 100644 --- a/Source/WebCore/platform/haiku/RenderThemeHaiku.h +++ b/Source/WebCore/platform/haiku/RenderThemeHaiku.h @@ -91,8 +91,13 @@ class RenderThemeHaiku : public RenderTheme { bool paintSliderThumb(const RenderObject&, const PaintInfo&, const IntRect&) override; + Color systemColor(CSSValueID, OptionSet) const override; + private: unsigned flagsForObject(const RenderObject&) const; + rgb_color colorForControl(const RenderObject&) const; + rgb_color colorForValue(color_which, bool useDarkAppearance) const; + }; } // namespace WebCore diff --git a/Source/WebCore/platform/haiku/ScrollbarThemeHaiku.cpp b/Source/WebCore/platform/haiku/ScrollbarThemeHaiku.cpp index 595027de5c2a..7c85a3ee0b38 100644 --- a/Source/WebCore/platform/haiku/ScrollbarThemeHaiku.cpp +++ b/Source/WebCore/platform/haiku/ScrollbarThemeHaiku.cpp @@ -30,9 +30,11 @@ #include "GraphicsContext.h" #include "Scrollbar.h" +#include "ScrollableArea.h" #include #include #include +#include static int buttonWidth(int scrollbarWidth, int thickness) @@ -126,7 +128,7 @@ IntRect ScrollbarThemeHaiku::trackRect(Scrollbar& scrollbar, bool) return IntRect(scrollbar.x(), scrollbar.y() + thickness, thickness, scrollbar.height() - 2 * thickness - 1); } -void ScrollbarThemeHaiku::paintScrollCorner(ScrollableArea&, GraphicsContext& context, const IntRect& rect) +void ScrollbarThemeHaiku::paintScrollCorner(ScrollableArea& scrollArea, GraphicsContext& context, const IntRect& rect) { if (rect.width() == 0 || rect.height() == 0) return; @@ -134,7 +136,9 @@ void ScrollbarThemeHaiku::paintScrollCorner(ScrollableArea&, GraphicsContext& co BRect drawRect = BRect(rect); BView* view = context.platformContext(); view->PushState(); - rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); + rgb_color base = colorForScrollbar(B_CONTROL_BACKGROUND_COLOR, + scrollArea.useDarkAppearanceForScrollbars()); + if (!m_drawOuterFrame) { view->SetHighColor(tint_color(base, B_DARKEN_2_TINT)); view->StrokeLine(drawRect.LeftBottom(), drawRect.LeftTop()); @@ -153,7 +157,8 @@ void ScrollbarThemeHaiku::paintScrollbarBackground(GraphicsContext& context, Scr if (!be_control_look) return; - rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); + rgb_color base = colorForScrollbar(B_CONTROL_BACKGROUND_COLOR, + scrollbar.scrollableArea().useDarkAppearanceForScrollbars()); BRect rect = trackRect(scrollbar, false); BView* view = context.platformContext(); view->SetHighColor(tint_color(base, B_DARKEN_2_TINT)); @@ -196,7 +201,8 @@ void ScrollbarThemeHaiku::paintButton(GraphicsContext& context, Scrollbar& scrol BView* view = context.platformContext(); bool down = scrollbar.pressedPart() == part; - rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); + rgb_color base = colorForScrollbar(B_CONTROL_BACKGROUND_COLOR, + scrollbar.scrollableArea().useDarkAppearanceForScrollbars()); rgb_color dark2 = tint_color(base, B_DARKEN_2_TINT); enum orientation orientation; @@ -236,7 +242,8 @@ void ScrollbarThemeHaiku::paintThumb(GraphicsContext& context, Scrollbar& scroll BRect drawRect = BRect(rect); BView* view = context.platformContext(); - rgb_color base = ui_color(B_SCROLL_BAR_THUMB_COLOR); + rgb_color base = colorForScrollbar(B_SCROLL_BAR_THUMB_COLOR, + scrollbar.scrollableArea().useDarkAppearanceForScrollbars()); rgb_color dark2 = tint_color(base, B_DARKEN_2_TINT); rgb_color dark3 = tint_color(base, B_DARKEN_3_TINT); @@ -274,6 +281,18 @@ void ScrollbarThemeHaiku::paintThumb(GraphicsContext& context, Scrollbar& scroll view->PopState(); } +rgb_color ScrollbarThemeHaiku::colorForScrollbar(color_which controlColor, bool darkMode) const +{ + rgb_color systemColor = ui_color(B_DOCUMENT_BACKGROUND_COLOR); + if (darkMode) { + if (systemColor.Brightness() > 127) // system is in light mode, but we need dark + return BPrivate::GetSystemColor(controlColor, true); + } else { + if (systemColor.Brightness() < 127) // system is in dark mode but we need light + return BPrivate::GetSystemColor(controlColor, false); + } + return ui_color(controlColor); +} } // namespace WebCore diff --git a/Source/WebCore/platform/haiku/ScrollbarThemeHaiku.h b/Source/WebCore/platform/haiku/ScrollbarThemeHaiku.h index b26860ee7dd4..d9edc642c9f4 100644 --- a/Source/WebCore/platform/haiku/ScrollbarThemeHaiku.h +++ b/Source/WebCore/platform/haiku/ScrollbarThemeHaiku.h @@ -55,6 +55,7 @@ class ScrollbarThemeHaiku : public ScrollbarThemeComposite { private: bool m_drawOuterFrame; + rgb_color colorForScrollbar(color_which base, const bool darkMode) const; }; } diff --git a/Source/WebKitLegacy/haiku/API/WebView.cpp b/Source/WebKitLegacy/haiku/API/WebView.cpp index 956fc9361520..47707bc34569 100644 --- a/Source/WebKitLegacy/haiku/API/WebView.cpp +++ b/Source/WebKitLegacy/haiku/API/WebView.cpp @@ -94,6 +94,10 @@ BWebView::BWebView(const char* name, BPrivate::Network::BUrlContext* urlContext) rgb_color background = ui_color(B_DOCUMENT_BACKGROUND_COLOR); if (background.Brightness() < 127) fWebPage->page()->effectiveAppearanceDidChange(true, false); + + // doesn't seem to affect the "background" for css, but it does fix the glaring + // white screen between page loads (or when no page is open) + fWebPage->page()->mainFrame().view()->setBaseBackgroundColor(background); } BWebView::~BWebView()