tdf#152486 unreadable infobar buttons in macOS dark mode

These are the buttons in infobars where the infobar has a custom
background color and on these platforms the buttons blend with their
background. On other platforms the buttons typically are opaque
and the issue doesn't arise.

Change-Id: Idfc4bbf291953bbf27e73cd5dd7654fd1ce4b051
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144104
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index 3021980..46d7b51 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -895,6 +895,25 @@ void PushButton::ImplDrawPushButtonContent(OutputDevice *pDev, SystemTextColorFl
            else
                aColor = rStyleSettings.GetButtonTextColor();

#if defined(MACOSX) || defined(IOS)
    // tdf#152486 These are the buttons in infobars where the infobar has a custom
    // background color and on these platforms the buttons blend with
    // their background.
    vcl::Window* pParent = GetParent();
    if (pParent->get_id() == "ExtraButton")
    {
        while (pParent && !pParent->IsControlBackground())
            pParent = pParent->GetParent();
        if (pParent)
        {
            if (aColor.IsBright() && !pParent->GetControlBackground().IsDark())
                aColor = COL_BLACK;
            else if (aColor.IsDark() && !pParent->GetControlBackground().IsBright())
                aColor = COL_WHITE;
        }
    }
#endif

    pDev->SetTextColor(aColor);

    if ( IsEnabled() )