Allow WebViews to disable system appearance
authormegan_gardner@apple.com <megan_gardner@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Mar 2018 04:55:22 +0000 (04:55 +0000)
committermegan_gardner@apple.com <megan_gardner@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Mar 2018 04:55:22 +0000 (04:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=183418
<rdar://problem/36975642>

Reviewed by Tim Horton.
Source/WebCore:

Not currently testable, tests will be added in a later patch.

Allow webviews to choose whether or not to follow the default system appearance.

* css/StyleColor.cpp:
(WebCore::StyleColor::colorFromKeyword):
* css/StyleColor.h:
* css/StyleResolver.cpp:
(WebCore::StyleResolver::colorFromPrimitiveValue const):
* css/parser/CSSParser.cpp:
(WebCore::CSSParser::parseSystemColor):
* css/parser/CSSParser.h:
* css/parser/CSSParserMode.h:
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::drawFocusIfNeededInternal):
* html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::setStrokeColor):
(WebCore::CanvasRenderingContext2DBase::setFillColor):
* html/canvas/CanvasStyle.cpp:
(WebCore::parseColor):
(WebCore::parseColorOrCurrentColor):
(WebCore::CanvasStyle::createFromString):
(WebCore::CanvasStyle::createFromStringWithOverrideAlpha):
* html/canvas/CanvasStyle.h:
* page/Page.h:
(WebCore::Page::useSystemAppearance const):
(WebCore::Page::setUseSystemAppearance):
* platform/Theme.cpp:
(WebCore::Theme::paint):
* platform/Theme.h:
* platform/mac/LocalDefaultSystemAppearance.h:
* platform/mac/LocalDefaultSystemAppearance.mm:
(WebCore::LocalDefaultSystemAppearance::LocalDefaultSystemAppearance):
(WebCore::LocalDefaultSystemAppearance::~LocalDefaultSystemAppearance):
* platform/mac/ThemeMac.h:
* platform/mac/ThemeMac.mm:
(-[WebCoreThemeView initWithUseSystemAppearance:]):
(WebCore::paintToggleButton):
(WebCore::paintButton):
(WebCore::ThemeMac::ensuredView):
(WebCore::ThemeMac::drawCellOrFocusRingWithViewIntoContext):
(WebCore::ThemeMac::paint):
(-[WebCoreThemeView init]): Deleted.
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::paint):
(WebCore::RenderTheme::systemColor const):
(WebCore::RenderTheme::focusRingColor):
* rendering/RenderTheme.h:
(WebCore::RenderTheme::platformFocusRingColor const):
* rendering/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::systemColor const):
* rendering/RenderThemeMac.h:
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::documentViewFor const):
(WebCore::RenderThemeMac::platformFocusRingColor const):
(WebCore::RenderThemeMac::systemColor const):
(WebCore::RenderThemeMac::paintCellAndSetFocusedElementNeedsRepaintIfNecessary):
(WebCore::RenderThemeMac::paintSliderThumb):
* rendering/TextPaintStyle.cpp:
(WebCore::computeTextPaintStyle):

Source/WebKit:

Allow webviews to choose whether or not to follow the default system appearance.

* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode const):
(WebKit::WebPageCreationParameters::decode):
* Shared/WebPageCreationParameters.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _useSystemAppearance]):
(-[WKWebView _setUseSystemAppearance:]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::creationParameters):
(WebKit::WebPageProxy::setUseSystemAppearance):
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::useSystemAppearance const):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::setUseSystemAppearance):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

Source/WebKitLegacy/mac:

Allow webviews to choose whether or not to follow the default system appearance.

* WebView/WebView.mm:
(-[WebView _setUseSystemAppearance:]):
(-[WebView _useSystemAppearance]):
* WebView/WebViewPrivate.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229448 268f45cc-cd09-0410-ab3c-d52691b4dbfc

45 files changed:
Source/WebCore/ChangeLog
Source/WebCore/css/StyleColor.cpp
Source/WebCore/css/StyleColor.h
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/css/parser/CSSParser.cpp
Source/WebCore/css/parser/CSSParser.h
Source/WebCore/css/parser/CSSParserMode.h
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
Source/WebCore/html/canvas/CanvasStyle.cpp
Source/WebCore/page/Page.h
Source/WebCore/platform/Theme.cpp
Source/WebCore/platform/Theme.h
Source/WebCore/platform/mac/LocalDefaultSystemAppearance.h
Source/WebCore/platform/mac/LocalDefaultSystemAppearance.mm
Source/WebCore/platform/mac/ThemeMac.h
Source/WebCore/platform/mac/ThemeMac.mm
Source/WebCore/platform/wpe/ThemeWPE.cpp
Source/WebCore/platform/wpe/ThemeWPE.h
Source/WebCore/rendering/RenderListBox.cpp
Source/WebCore/rendering/RenderTheme.cpp
Source/WebCore/rendering/RenderTheme.h
Source/WebCore/rendering/RenderThemeGtk.cpp
Source/WebCore/rendering/RenderThemeGtk.h
Source/WebCore/rendering/RenderThemeIOS.h
Source/WebCore/rendering/RenderThemeIOS.mm
Source/WebCore/rendering/RenderThemeMac.h
Source/WebCore/rendering/RenderThemeMac.mm
Source/WebCore/rendering/RenderThemeWin.cpp
Source/WebCore/rendering/RenderThemeWin.h
Source/WebCore/rendering/TextPaintStyle.cpp
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebPageCreationParameters.cpp
Source/WebKit/Shared/WebPageCreationParameters.h
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/WebPage.messages.in
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebView/WebView.mm
Source/WebKitLegacy/mac/WebView/WebViewPrivate.h

index 5261cc6..2e6a192 100644 (file)
@@ -1,5 +1,74 @@
 2018-03-08  Megan Gardner  <megan_gardner@apple.com>
 
+        Allow WebViews to disable system appearance
+        https://bugs.webkit.org/show_bug.cgi?id=183418
+        <rdar://problem/36975642>
+
+        Reviewed by Tim Horton.
+
+        Not currently testable, tests will be added in a later patch.
+
+        Allow webviews to choose whether or not to follow the default system appearance.
+
+        * css/StyleColor.cpp:
+        (WebCore::StyleColor::colorFromKeyword):
+        * css/StyleColor.h:
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::colorFromPrimitiveValue const):
+        * css/parser/CSSParser.cpp:
+        (WebCore::CSSParser::parseSystemColor):
+        * css/parser/CSSParser.h:
+        * css/parser/CSSParserMode.h:
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::drawFocusIfNeededInternal):
+        * html/canvas/CanvasRenderingContext2DBase.cpp:
+        (WebCore::CanvasRenderingContext2DBase::setStrokeColor):
+        (WebCore::CanvasRenderingContext2DBase::setFillColor):
+        * html/canvas/CanvasStyle.cpp:
+        (WebCore::parseColor):
+        (WebCore::parseColorOrCurrentColor):
+        (WebCore::CanvasStyle::createFromString):
+        (WebCore::CanvasStyle::createFromStringWithOverrideAlpha):
+        * html/canvas/CanvasStyle.h:
+        * page/Page.h:
+        (WebCore::Page::useSystemAppearance const):
+        (WebCore::Page::setUseSystemAppearance):
+        * platform/Theme.cpp:
+        (WebCore::Theme::paint):
+        * platform/Theme.h:
+        * platform/mac/LocalDefaultSystemAppearance.h:
+        * platform/mac/LocalDefaultSystemAppearance.mm:
+        (WebCore::LocalDefaultSystemAppearance::LocalDefaultSystemAppearance):
+        (WebCore::LocalDefaultSystemAppearance::~LocalDefaultSystemAppearance):
+        * platform/mac/ThemeMac.h:
+        * platform/mac/ThemeMac.mm:
+        (-[WebCoreThemeView initWithUseSystemAppearance:]):
+        (WebCore::paintToggleButton):
+        (WebCore::paintButton):
+        (WebCore::ThemeMac::ensuredView):
+        (WebCore::ThemeMac::drawCellOrFocusRingWithViewIntoContext):
+        (WebCore::ThemeMac::paint):
+        (-[WebCoreThemeView init]): Deleted.
+        * rendering/RenderTheme.cpp:
+        (WebCore::RenderTheme::paint):
+        (WebCore::RenderTheme::systemColor const):
+        (WebCore::RenderTheme::focusRingColor):
+        * rendering/RenderTheme.h:
+        (WebCore::RenderTheme::platformFocusRingColor const):
+        * rendering/RenderThemeIOS.mm:
+        (WebCore::RenderThemeIOS::systemColor const):
+        * rendering/RenderThemeMac.h:
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::documentViewFor const):
+        (WebCore::RenderThemeMac::platformFocusRingColor const):
+        (WebCore::RenderThemeMac::systemColor const):
+        (WebCore::RenderThemeMac::paintCellAndSetFocusedElementNeedsRepaintIfNecessary):
+        (WebCore::RenderThemeMac::paintSliderThumb):
+        * rendering/TextPaintStyle.cpp:
+        (WebCore::computeTextPaintStyle):
+
+2018-03-08  Megan Gardner  <megan_gardner@apple.com>
+
         Ensure default appearance for selection form control
         https://bugs.webkit.org/show_bug.cgi?id=183482
         <rdar://problem/38274894>
index ba869ad..490fbea 100644 (file)
 
 namespace WebCore {
 
-Color StyleColor::colorFromKeyword(CSSValueID keyword)
+Color StyleColor::colorFromKeyword(CSSValueID keyword, bool useSystemAppearance)
 {
     if (const char* valueName = getValueName(keyword)) {
         if (const NamedColor* namedColor = findColor(valueName, strlen(valueName)))
             return Color(namedColor->ARGBValue);
     }
-    return RenderTheme::singleton().systemColor(keyword);
+    return RenderTheme::singleton().systemColor(keyword, useSystemAppearance);
 }
 
 bool StyleColor::isColorKeyword(CSSValueID id)
index 1d18ce1..fb59b61 100644 (file)
@@ -50,7 +50,7 @@ public:
 
     const Color& resolve(const Color& currentColor) const { return m_currentColor ? currentColor : m_color; }
 
-    static Color colorFromKeyword(CSSValueID);
+    static Color colorFromKeyword(CSSValueID, bool useSystemAppearance);
     static bool isColorKeyword(CSSValueID);
     static bool isSystemColor(CSSValueID);
 
index 6a68ade..14ffe99 100644 (file)
@@ -1822,14 +1822,14 @@ Color StyleResolver::colorFromPrimitiveValue(const CSSPrimitiveValue& value, boo
     case CSSValueWebkitActivelink:
         return document().activeLinkColor();
     case CSSValueWebkitFocusRingColor:
-        return RenderTheme::focusRingColor();
+        return RenderTheme::focusRingColor(document().useSystemAppearance());
     case CSSValueCurrentcolor:
         // Color is an inherited property so depending on it effectively makes the property inherited.
         // FIXME: Setting the flag as a side effect of calling this function is a bit oblique. Can we do better?
         m_state.style()->setHasExplicitlyInheritedProperties();
         return m_state.style()->color();
     default:
-        return StyleColor::colorFromKeyword(identifier);
+        return StyleColor::colorFromKeyword(identifier, document().useSystemAppearance());
     }
 }
 
index 8314d74..d6c2caa 100644 (file)
@@ -176,13 +176,14 @@ Color CSSParser::parseColor(const String& string, bool strict)
     return primitiveValue.color();
 }
 
-Color CSSParser::parseSystemColor(const String& string)
+Color CSSParser::parseSystemColor(const String& string, std::optional<const CSSParserContext&> context)
 {
     CSSValueID id = cssValueKeywordID(string);
     if (!StyleColor::isSystemColor(id))
         return Color();
-    
-    return RenderTheme::singleton().systemColor(id);
+    if (context)
+        return RenderTheme::singleton().systemColor(id, context.value().useSystemAppearance);
+    return RenderTheme::singleton().systemColor(id, false);
 }
 
 RefPtr<CSSValue> CSSParser::parseSingleValue(CSSPropertyID propertyID, const String& string, const CSSParserContext& context)
index 93f1b17..d92fa5a 100644 (file)
@@ -78,7 +78,7 @@ public:
     RefPtr<CSSValue> parseValueWithVariableReferences(CSSPropertyID, const CSSValue&, const CustomPropertyValueMap& customProperties, TextDirection, WritingMode);
 
     static Color parseColor(const String&, bool strict = false);
-    static Color parseSystemColor(const String&);
+    static Color parseSystemColor(const String&, std::optional<const CSSParserContext&>);
 
 private:
     ParseResult parseValue(MutableStyleProperties&, CSSPropertyID, const String&, bool important);
index e1258b9..e8c3bae 100644 (file)
@@ -111,6 +111,8 @@ public:
     
     // This is only needed to support getMatchedCSSRules.
     bool hasDocumentSecurityOrigin { false };
+    
+    bool useSystemAppearance { false };
 
     URL completeURL(const String& url) const
     {
index f860b6f..5520b4b 100644 (file)
@@ -7028,6 +7028,15 @@ float Document::deviceScaleFactor() const
         deviceScaleFactor = documentPage->deviceScaleFactor();
     return deviceScaleFactor;
 }
+    
+bool Document::useSystemAppearance() const
+{
+    bool useSystemAppearance = false;
+    if (Page* documentPage = page())
+        useSystemAppearance = documentPage->useSystemAppearance();
+    return useSystemAppearance;
+}
+    
 void Document::didAssociateFormControl(Element* element)
 {
     if (!frame() || !frame()->page() || !frame()->page()->chrome().client().shouldNotifyOnFormChanges())
index 3a00149..192d32b 100644 (file)
@@ -544,6 +544,8 @@ public:
     Settings& mutableSettings() { return m_settings.get(); }
 
     float deviceScaleFactor() const;
+        
+    bool useSystemAppearance() const;
 
     WEBCORE_EXPORT Ref<Range> createRange();
 
index 48cd412..ca3d0d4 100644 (file)
@@ -84,7 +84,7 @@ void CanvasRenderingContext2D::drawFocusIfNeededInternal(const Path& path, Eleme
     auto* context = drawingContext();
     if (!element.focused() || !state().hasInvertibleTransform || path.isEmpty() || !element.isDescendantOf(canvas()) || !context)
         return;
-    context->drawFocusRing(path, 1, 1, RenderTheme::focusRingColor());
+    context->drawFocusRing(path, 1, 1, RenderTheme::focusRingColor(element.document().useSystemAppearance()));
 }
 
 String CanvasRenderingContext2D::font() const
index 791568c..ff49ad1 100644 (file)
@@ -53,7 +53,7 @@ static Color parseColor(const String& colorString)
     Color color = CSSParser::parseColor(colorString);
     if (color.isValid())
         return color;
-    return CSSParser::parseSystemColor(colorString);
+    return CSSParser::parseSystemColor(colorString, std::nullopt);
 }
 
 Color currentColor(HTMLCanvasElement* canvas)
index 1c8ec47..26eb74e 100644 (file)
@@ -324,6 +324,9 @@ public:
     bool enclosedInScrollableAncestorView() const { return m_enclosedInScrollableAncestorView; }
     void setEnclosedInScrollableAncestorView(bool f) { m_enclosedInScrollableAncestorView = f; }
 #endif
+    
+    bool useSystemAppearance() const { return m_useSystemAppearance; }
+    void setUseSystemAppearance(bool a) { m_useSystemAppearance = a; }
 
 #if ENABLE(TEXT_AUTOSIZING)
     float textAutosizingWidth() const { return m_textAutosizingWidth; }
@@ -699,6 +702,8 @@ private:
 #if PLATFORM(IOS)
     bool m_enclosedInScrollableAncestorView { false };
 #endif
+    
+    bool m_useSystemAppearance { false };
 
 #if ENABLE(TEXT_AUTOSIZING)
     float m_textAutosizingWidth { 0 };
index 8229f1c..07426e1 100644 (file)
@@ -57,7 +57,7 @@ bool Theme::controlRequiresPreWhiteSpace(ControlPart) const
     return false;
 }
 
-void Theme::paint(ControlPart, ControlStates&, GraphicsContext&, const FloatRect&, float, ScrollView*, float, float)
+void Theme::paint(ControlPart, ControlStates&, GraphicsContext&, const FloatRect&, float, ScrollView*, float, float, bool)
 {
 }
 
index be4b4c9..163f35b 100644 (file)
@@ -67,7 +67,7 @@ public:
     virtual bool controlRequiresPreWhiteSpace(ControlPart) const;
 
     // Method for painting a control. The rect is in zoomed coordinates.
-    virtual void paint(ControlPart, ControlStates&, GraphicsContext&, const FloatRect& zoomedRect, float zoomFactor, ScrollView*, float deviceScaleFactor, float pageScaleFactor);
+    virtual void paint(ControlPart, ControlStates&, GraphicsContext&, const FloatRect& zoomedRect, float zoomFactor, ScrollView*, float deviceScaleFactor, float pageScaleFactor, bool useSystemAppearance);
 
     // Some controls may spill out of their containers (e.g., the check on an OS X checkbox).  When these controls repaint,
     // the theme needs to communicate this inflated rect to the engine so that it can invalidate the whole control.
index 3baf5b4..aab5b84 100644 (file)
@@ -30,7 +30,7 @@
 
 #if USE(APPKIT)
 
-OBJC_CLASS NSAppearence;
+OBJC_CLASS NSAppearance;
 
 namespace WebCore {
     
@@ -39,7 +39,7 @@ namespace WebCore {
 class LocalDefaultSystemAppearance {
     WTF_MAKE_NONCOPYABLE(LocalDefaultSystemAppearance);
 public:
-    LocalDefaultSystemAppearance();
+    LocalDefaultSystemAppearance(bool useSystemAppearance);
     ~LocalDefaultSystemAppearance();
 private:
     RetainPtr<NSAppearance> m_savedSystemAppearance;
index 6ed39e0..c742b4a 100644 (file)
 
 namespace WebCore {
     
-LocalDefaultSystemAppearance::LocalDefaultSystemAppearance()
+LocalDefaultSystemAppearance::LocalDefaultSystemAppearance(bool useSystemAppearance)
     : m_savedSystemAppearance()
 {
-    m_savedSystemAppearance = [NSAppearance currentAppearance];
-    NSAppearance *newAppearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua];
-    [NSAppearance setCurrentAppearance:newAppearance];
+    if (!useSystemAppearance) {
+        m_savedSystemAppearance = [NSAppearance currentAppearance];
+        [NSAppearance setCurrentAppearance:[NSAppearance appearanceNamed:NSAppearanceNameAqua]];
+    }
 }
 
 LocalDefaultSystemAppearance::~LocalDefaultSystemAppearance()
 {
-    [NSAppearance setCurrentAppearance:m_savedSystemAppearance.get()];
+    if (m_savedSystemAppearance)
+        [NSAppearance setCurrentAppearance:m_savedSystemAppearance.get()];
 }
     
 }
index 0fbec6f..cbe2cb9 100644 (file)
@@ -33,9 +33,9 @@ namespace WebCore {
 
 class ThemeMac final : public ThemeCocoa {
 public:
-    static NSView *ensuredView(ScrollView*, const ControlStates&, bool useUnparentedView = false);
+    static NSView *ensuredView(ScrollView*, const ControlStates&, bool useSystemAppearance, bool useUnparentedView = false);
     static void setFocusRingClipRect(const FloatRect&);
-    static bool drawCellOrFocusRingWithViewIntoContext(NSCell *, GraphicsContext&, const FloatRect&, NSView *, bool drawButtonCell, bool drawFocusRing, bool useImageBuffer, float deviceScaleFactor);
+    static bool drawCellOrFocusRingWithViewIntoContext(NSCell *, GraphicsContext&, const FloatRect&, NSView *, bool drawButtonCell, bool drawFocusRing, bool useImageBuffer, float deviceScaleFactor, bool useSystemAppearance);
 
 private:
     friend NeverDestroyed<ThemeMac>;
@@ -53,7 +53,7 @@ private:
 
     bool controlRequiresPreWhiteSpace(ControlPart part) const final { return part == PushButtonPart; }
 
-    void paint(ControlPart, ControlStates&, GraphicsContext&, const FloatRect&, float zoomFactor, ScrollView*, float deviceScaleFactor, float pageScaleFactor) final;
+    void paint(ControlPart, ControlStates&, GraphicsContext&, const FloatRect&, float zoomFactor, ScrollView*, float deviceScaleFactor, float pageScaleFactor, bool useSystemAppearance) final;
     void inflateControlPaintRect(ControlPart, const ControlStates&, FloatRect&, float zoomFactor) const final;
 
     bool userPrefersReducedMotion() const final;
index 38b903a..8736ef5 100644 (file)
@@ -68,12 +68,12 @@ static BOOL themeWindowHasKeyAppearance;
 
 @implementation WebCoreThemeView
 
-- (instancetype)init
+- (instancetype)initWithUseSystemAppearance:(BOOL)useSystemAppearance
 {
     if (!(self = [super init]))
         return nil;
     
-    WebCore::LocalDefaultSystemAppearance localAppearence;
+    WebCore::LocalDefaultSystemAppearance localAppearance(useSystemAppearance);
     [self setAppearance:[NSAppearance currentAppearance]];
     return self;
 }
@@ -394,7 +394,7 @@ static bool drawCellFocusRing(NSCell *cell, NSRect cellFrame, NSView *controlVie
     return false;
 }
 
-static void paintToggleButton(ControlPart buttonType, ControlStates& controlStates, GraphicsContext& context, const FloatRect& zoomedRect, float zoomFactor, ScrollView* scrollView, float deviceScaleFactor, float pageScaleFactor)
+static void paintToggleButton(ControlPart buttonType, ControlStates& controlStates, GraphicsContext& context, const FloatRect& zoomedRect, float zoomFactor, ScrollView* scrollView, float deviceScaleFactor, float pageScaleFactor, bool useSystemAppearance)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS
 
@@ -434,10 +434,9 @@ static void paintToggleButton(ControlPart buttonType, ControlStates& controlStat
         context.scale(zoomFactor);
         context.translate(-inflatedRect.location());
     }
-
     LocalCurrentGraphicsContext localContext(context);
 
-    NSView *view = ThemeMac::ensuredView(scrollView, controlStates, true /* useUnparentedView */);
+    NSView *view = ThemeMac::ensuredView(scrollView, controlStates, useSystemAppearance, true /* useUnparentedView */);
 
     bool needsRepaint = false;
     bool useImageBuffer = pageScaleFactor != 1.0f || zoomFactor != 1.0f;
@@ -450,9 +449,9 @@ static void paintToggleButton(ControlPart buttonType, ControlStates& controlStat
 
         [toggleButtonCell _renderCurrentAnimationFrameInContext:context.platformContext() atLocation:NSMakePoint(0, 0)];
         if (![toggleButtonCell _stateAnimationRunning] && isCellFocused)
-            needsRepaint = ThemeMac::drawCellOrFocusRingWithViewIntoContext(toggleButtonCell.get(), context, inflatedRect, view, false, true, useImageBuffer, deviceScaleFactor);
+            needsRepaint = ThemeMac::drawCellOrFocusRingWithViewIntoContext(toggleButtonCell.get(), context, inflatedRect, view, false, true, useImageBuffer, deviceScaleFactor, useSystemAppearance);
     } else
-        needsRepaint = ThemeMac::drawCellOrFocusRingWithViewIntoContext(toggleButtonCell.get(), context, inflatedRect, view, true, isCellFocused, useImageBuffer, deviceScaleFactor);
+        needsRepaint = ThemeMac::drawCellOrFocusRingWithViewIntoContext(toggleButtonCell.get(), context, inflatedRect, view, true, isCellFocused, useImageBuffer, deviceScaleFactor, useSystemAppearance);
 
     [toggleButtonCell setControlView:nil];
 
@@ -528,7 +527,7 @@ static NSButtonCell *button(ControlPart part, const ControlStates& controlStates
     return cell;
 }
     
-static void paintButton(ControlPart part, ControlStates& controlStates, GraphicsContext& context, const FloatRect& zoomedRect, float zoomFactor, ScrollView* scrollView, float deviceScaleFactor, float pageScaleFactor)
+static void paintButton(ControlPart part, ControlStates& controlStates, GraphicsContext& context, const FloatRect& zoomedRect, float zoomFactor, ScrollView* scrollView, float deviceScaleFactor, float pageScaleFactor, bool useSystemAppearance)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS
     
@@ -563,14 +562,14 @@ static void paintButton(ControlPart part, ControlStates& controlStates, Graphics
     
     LocalCurrentGraphicsContext localContext(context);
     
-    NSView *view = ThemeMac::ensuredView(scrollView, controlStates);
+    NSView *view = ThemeMac::ensuredView(scrollView, controlStates, useSystemAppearance);
     NSWindow *window = [view window];
-    LocalDefaultSystemAppearance localAppearence;
+    LocalDefaultSystemAppearance localAppearance(useSystemAppearance);
     [window setAppearance:[NSAppearance currentAppearance]];
     NSButtonCell *previousDefaultButtonCell = [window defaultButtonCell];
 
     bool useImageBuffer = pageScaleFactor != 1.0f || zoomFactor != 1.0f;
-    bool needsRepaint = ThemeMac::drawCellOrFocusRingWithViewIntoContext(buttonCell, context, inflatedRect, view, true, states & ControlStates::FocusState, useImageBuffer, deviceScaleFactor);
+    bool needsRepaint = ThemeMac::drawCellOrFocusRingWithViewIntoContext(buttonCell, context, inflatedRect, view, true, states & ControlStates::FocusState, useImageBuffer, deviceScaleFactor, useSystemAppearance);
     if (states & ControlStates::DefaultState)
         [window setDefaultButtonCell:buttonCell];
     else if ([previousDefaultButtonCell isEqual:buttonCell])
@@ -648,7 +647,7 @@ static void paintStepper(ControlStates& states, GraphicsContext& context, const
 
 // This will ensure that we always return a valid NSView, even if ScrollView doesn't have an associated document NSView.
 // If the ScrollView doesn't have an NSView, we will return a fake NSView set up in the way AppKit expects.
-NSView *ThemeMac::ensuredView(ScrollView* scrollView, const ControlStates& controlStates, bool useUnparentedView)
+NSView *ThemeMac::ensuredView(ScrollView* scrollView, const ControlStates& controlStates, bool useSystemAppearance, bool useUnparentedView)
 {
     if (!useUnparentedView) {
         if (NSView *documentView = scrollView->documentView())
@@ -656,7 +655,7 @@ NSView *ThemeMac::ensuredView(ScrollView* scrollView, const ControlStates& contr
     }
 
     // Use a fake view.
-    static WebCoreThemeView *themeView = [[WebCoreThemeView alloc] init];
+    static WebCoreThemeView *themeView = [[WebCoreThemeView alloc] initWithUseSystemAppearance:useSystemAppearance];
     [themeView setFrameSize:NSSizeFromCGSize(scrollView->totalContentsSize())];
 
     themeWindowHasKeyAppearance = !(controlStates.states() & ControlStates::WindowInactiveState);
@@ -686,10 +685,10 @@ static inline bool drawCellOrFocusRingIntoRectWithView(NSCell *cell, NSRect rect
     return false;
 }
 
-bool ThemeMac::drawCellOrFocusRingWithViewIntoContext(NSCell *cell, GraphicsContext& context, const FloatRect& rect, NSView *view, bool drawButtonCell, bool drawFocusRing, bool useImageBuffer, float deviceScaleFactor)
+bool ThemeMac::drawCellOrFocusRingWithViewIntoContext(NSCell *cell, GraphicsContext& context, const FloatRect& rect, NSView *view, bool drawButtonCell, bool drawFocusRing, bool useImageBuffer, float deviceScaleFactor, bool useSystemAppearance)
 {
     ASSERT(drawButtonCell || drawFocusRing);
-    LocalDefaultSystemAppearance localAppearence;
+    LocalDefaultSystemAppearance localAppearance(useSystemAppearance);
     bool needsRepaint = false;
     if (useImageBuffer) {
         NSRect imageBufferDrawRect = NSRect(FloatRect(buttonFocusRectOutlineWidth, buttonFocusRectOutlineWidth, rect.width(), rect.height()));
@@ -858,20 +857,20 @@ void ThemeMac::inflateControlPaintRect(ControlPart part, const ControlStates& st
     END_BLOCK_OBJC_EXCEPTIONS
 }
 
-void ThemeMac::paint(ControlPart part, ControlStates& states, GraphicsContext& context, const FloatRect& zoomedRect, float zoomFactor, ScrollView* scrollView, float deviceScaleFactor, float pageScaleFactor)
+void ThemeMac::paint(ControlPart part, ControlStates& states, GraphicsContext& context, const FloatRect& zoomedRect, float zoomFactor, ScrollView* scrollView, float deviceScaleFactor, float pageScaleFactor, bool useSystemAppearance)
 {
     switch (part) {
         case CheckboxPart:
-            paintToggleButton(part, states, context, zoomedRect, zoomFactor, scrollView, deviceScaleFactor, pageScaleFactor);
+            paintToggleButton(part, states, context, zoomedRect, zoomFactor, scrollView, deviceScaleFactor, pageScaleFactor, useSystemAppearance);
             break;
         case RadioPart:
-            paintToggleButton(part, states, context, zoomedRect, zoomFactor, scrollView, deviceScaleFactor, pageScaleFactor);
+            paintToggleButton(part, states, context, zoomedRect, zoomFactor, scrollView, deviceScaleFactor, pageScaleFactor, useSystemAppearance);
             break;
         case PushButtonPart:
         case DefaultButtonPart:
         case ButtonPart:
         case SquareButtonPart:
-            paintButton(part, states, context, zoomedRect, zoomFactor, scrollView, deviceScaleFactor, pageScaleFactor);
+            paintButton(part, states, context, zoomedRect, zoomFactor, scrollView, deviceScaleFactor, pageScaleFactor, useSystemAppearance);
             break;
         case InnerSpinButtonPart:
             paintStepper(states, context, zoomedRect, zoomFactor, scrollView);
index 271949a..a0b8b82 100644 (file)
@@ -57,7 +57,7 @@ LengthSize ThemeWPE::controlSize(ControlPart part, const FontCascade& fontCascad
     return Theme::controlSize(part, fontCascade, zoomedSize, zoomFactor);
 }
 
-void ThemeWPE::paint(ControlPart part, ControlStates& states, GraphicsContext& context, const FloatRect& zoomedRect, float zoomFactor, ScrollView*, float, float)
+void ThemeWPE::paint(ControlPart part, ControlStates& states, GraphicsContext& context, const FloatRect& zoomedRect, float zoomFactor, ScrollView*, float, float, bool)
 {
     switch (part) {
     case CheckboxPart:
index b524c48..f260089 100644 (file)
@@ -33,7 +33,7 @@ class ThemeWPE final : public Theme {
 private:
     LengthSize controlSize(ControlPart, const FontCascade&, const LengthSize&, float) const final;
 
-    void paint(ControlPart, ControlStates&, GraphicsContext&, const FloatRect&, float, ScrollView*, float, float) final;
+    void paint(ControlPart, ControlStates&, GraphicsContext&, const FloatRect&, float, ScrollView*, float, float, bool) final;
 
     void paintCheckbox(ControlStates&, GraphicsContext&, const FloatRect&, float);
     void paintRadio(ControlStates&, GraphicsContext&, const FloatRect&, float);
index 4c4d9ab..a63fbe7 100644 (file)
@@ -460,7 +460,7 @@ void RenderListBox::paintItemBackground(PaintInfo& paintInfo, const LayoutPoint&
         if (frame().selection().isFocusedAndActive() && document().focusedElement() == &selectElement())
             backColor = theme().activeListBoxSelectionBackgroundColor();
         else
-            backColor = theme().inactiveListBoxSelectionBackgroundColor();
+            backColor = theme().inactiveListBoxSelectionBackgroundColor(document().useSystemAppearance());
     } else
         backColor = itemStyle.visitedDependentColor(CSSPropertyBackgroundColor);
 
index ca3b3a4..07d7004 100644 (file)
@@ -290,10 +290,10 @@ bool RenderTheme::paint(const RenderBox& box, ControlStates& controlStates, cons
     IntRect integralSnappedRect = snappedIntRect(rect);
     float deviceScaleFactor = box.document().deviceScaleFactor();
     FloatRect devicePixelSnappedRect = snapRectToDevicePixels(rect, deviceScaleFactor);
-
+    
 #if USE(NEW_THEME)
     float pageScaleFactor = box.page().pageScaleFactor();
-    
+
     switch (part) {
     case CheckboxPart:
     case RadioPart:
@@ -303,7 +303,7 @@ bool RenderTheme::paint(const RenderBox& box, ControlStates& controlStates, cons
     case ButtonPart:
     case InnerSpinButtonPart:
         updateControlStatesForRenderer(box, controlStates);
-        Theme::singleton().paint(part, controlStates, paintInfo.context(), devicePixelSnappedRect, box.style().effectiveZoom(), &box.view().frameView(), deviceScaleFactor, pageScaleFactor);
+        Theme::singleton().paint(part, controlStates, paintInfo.context(), devicePixelSnappedRect, box.style().effectiveZoom(), &box.view().frameView(), deviceScaleFactor, pageScaleFactor, box.page().useSystemAppearance());
         return false;
     default:
         break;
@@ -614,10 +614,10 @@ Color RenderTheme::activeListBoxSelectionBackgroundColor() const
     return m_activeListBoxSelectionBackgroundColor;
 }
 
-Color RenderTheme::inactiveListBoxSelectionBackgroundColor() const
+Color RenderTheme::inactiveListBoxSelectionBackgroundColor(bool useSystemAppearance) const
 {
     if (!m_inactiveListBoxSelectionBackgroundColor.isValid())
-        m_inactiveListBoxSelectionBackgroundColor = platformInactiveListBoxSelectionBackgroundColor();
+        m_inactiveListBoxSelectionBackgroundColor = platformInactiveListBoxSelectionBackgroundColor(useSystemAppearance);
     return m_inactiveListBoxSelectionBackgroundColor;
 }
 
@@ -670,7 +670,7 @@ Color RenderTheme::platformActiveListBoxSelectionForegroundColor() const
     return platformActiveSelectionForegroundColor();
 }
 
-Color RenderTheme::platformInactiveListBoxSelectionBackgroundColor() const
+Color RenderTheme::platformInactiveListBoxSelectionBackgroundColor(bool) const
 {
     return platformInactiveSelectionBackgroundColor();
 }
@@ -1208,8 +1208,10 @@ void RenderTheme::systemFont(CSSValueID systemFontID, FontCascadeDescription& fo
     updateCachedSystemFontDescription(systemFontID, fontDescription);
 }
 
-Color RenderTheme::systemColor(CSSValueID cssValueId) const
+Color RenderTheme::systemColor(CSSValueID cssValueId, bool useSystemAppearance) const
 {
+    UNUSED_PARAM(useSystemAppearance);
+    
     switch (cssValueId) {
     case CSSValueActiveborder:
         return 0xFFFFFFFF;
@@ -1325,9 +1327,9 @@ void RenderTheme::setCustomFocusRingColor(const Color& color)
     customFocusRingColor() = color;
 }
 
-Color RenderTheme::focusRingColor()
+Color RenderTheme::focusRingColor(bool useSystemAppearance)
 {
-    return customFocusRingColor().isValid() ? customFocusRingColor() : RenderTheme::singleton().platformFocusRingColor();
+    return customFocusRingColor().isValid() ? customFocusRingColor() : RenderTheme::singleton().platformFocusRingColor(useSystemAppearance);
 }
 
 String RenderTheme::fileListDefaultLabel(bool multipleFilesAllowed) const
index de46672..0c655cf 100644 (file)
@@ -140,7 +140,7 @@ public:
     // List box selection colors
     Color activeListBoxSelectionBackgroundColor() const;
     Color activeListBoxSelectionForegroundColor() const;
-    Color inactiveListBoxSelectionBackgroundColor() const;
+    Color inactiveListBoxSelectionBackgroundColor(bool) const;
     Color inactiveListBoxSelectionForegroundColor() const;
 
     // Highlighting colors for TextMatches.
@@ -149,8 +149,8 @@ public:
 
     virtual Color disabledTextColor(const Color& textColor, const Color& backgroundColor) const;
 
-    static Color focusRingColor();
-    virtual Color platformFocusRingColor() const { return Color(0, 0, 0); }
+    static Color focusRingColor(bool useSystemAppearance);
+    virtual Color platformFocusRingColor(bool) const { return Color(0, 0, 0); }
     static void setCustomFocusRingColor(const Color&);
     static float platformFocusRingWidth() { return 3; }
     static float platformFocusRingOffset(float outlineWidth) { return std::max<float>(outlineWidth - platformFocusRingWidth(), 0); }
@@ -164,7 +164,7 @@ public:
 
     // System fonts and colors for CSS.
     void systemFont(CSSValueID, FontCascadeDescription&) const;
-    virtual Color systemColor(CSSValueID) const;
+    virtual Color systemColor(CSSValueID, bool useSystemAppearance) const;
 
     virtual int minimumMenuListSize(const RenderStyle&) const { return 0; }
 
@@ -256,7 +256,7 @@ protected:
     virtual Color platformInactiveSelectionForegroundColor() const;
 
     virtual Color platformActiveListBoxSelectionBackgroundColor() const;
-    virtual Color platformInactiveListBoxSelectionBackgroundColor() const;
+    virtual Color platformInactiveListBoxSelectionBackgroundColor(bool) const;
     virtual Color platformActiveListBoxSelectionForegroundColor() const;
     virtual Color platformInactiveListBoxSelectionForegroundColor() const;
 
index 9f7adeb..2b1de58 100644 (file)
@@ -1741,7 +1741,7 @@ Color RenderThemeGtk::platformActiveListBoxSelectionBackgroundColor() const
     return styleColor(ListBox, static_cast<GtkStateFlags>(GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_FOCUSED), StyleColorBackground);
 }
 
-Color RenderThemeGtk::platformInactiveListBoxSelectionBackgroundColor() const
+Color RenderThemeGtk::platformInactiveListBoxSelectionBackgroundColor(bool) const
 {
     return styleColor(ListBox, GTK_STATE_FLAG_SELECTED, StyleColorBackground);
 }
@@ -1756,7 +1756,7 @@ Color RenderThemeGtk::platformInactiveListBoxSelectionForegroundColor() const
     return styleColor(ListBox, GTK_STATE_FLAG_SELECTED, StyleColorForeground);
 }
 
-Color RenderThemeGtk::systemColor(CSSValueID cssValueId) const
+Color RenderThemeGtk::systemColor(CSSValueID cssValueId, bool) const
 {
     switch (cssValueId) {
     case CSSValueButtontext:
@@ -1764,7 +1764,7 @@ Color RenderThemeGtk::systemColor(CSSValueID cssValueId) const
     case CSSValueCaptiontext:
         return styleColor(Entry, GTK_STATE_FLAG_ACTIVE, StyleColorForeground);
     default:
-        return RenderTheme::systemColor(cssValueId);
+        return RenderTheme::systemColor(cssValueId, false);
     }
 }
 
index 63a2bb0..ab5b3d2 100644 (file)
@@ -78,7 +78,7 @@ public:
     // List Box selection color
     Color platformActiveListBoxSelectionBackgroundColor() const override;
     Color platformActiveListBoxSelectionForegroundColor() const override;
-    Color platformInactiveListBoxSelectionBackgroundColor() const override;
+    Color platformInactiveListBoxSelectionBackgroundColor(bool) const override;
     Color platformInactiveListBoxSelectionForegroundColor() const override;
 
     Seconds caretBlinkInterval() const override;
@@ -86,7 +86,7 @@ public:
     void platformColorsDidChange() override;
 
     // System colors.
-    Color systemColor(CSSValueID) const override;
+    Color systemColor(CSSValueID, bool) const override;
 
     bool popsMenuBySpaceOrReturn() const override { return true; }
 
index 961d60d..071700a 100644 (file)
@@ -135,7 +135,7 @@ private:
     const Color& shadowColor() const;
     FloatRect addRoundedBorderClip(const RenderObject& box, GraphicsContext&, const IntRect&);
 
-    Color systemColor(CSSValueID) const override;
+    Color systemColor(CSSValueID, bool) const override;
 
     String m_legacyMediaControlsScript;
     String m_mediaControlsScript;
index c7a5226..175a61e 100644 (file)
@@ -1397,7 +1397,7 @@ String RenderThemeIOS::mediaControlsBase64StringForIconNameAndType(const String&
 
 #endif // ENABLE(VIDEO)
 
-Color RenderThemeIOS::systemColor(CSSValueID cssValueID) const
+Color RenderThemeIOS::systemColor(CSSValueID cssValueID, bool) const
 {
     auto addResult = m_systemColorCache.add(cssValueID, Color());
     if (!addResult.isNewEntry)
@@ -1434,7 +1434,7 @@ Color RenderThemeIOS::systemColor(CSSValueID cssValueID) const
     }
 
     if (!color.isValid())
-        color = RenderTheme::systemColor(cssValueID);
+        color = RenderTheme::systemColor(cssValueID, false);
 
     addResult.iterator->value = color;
 
index 5dde57b..4b6de26 100644 (file)
@@ -57,9 +57,9 @@ public:
     Color platformInactiveSelectionBackgroundColor() const final;
     Color platformActiveListBoxSelectionBackgroundColor() const final;
     Color platformActiveListBoxSelectionForegroundColor() const final;
-    Color platformInactiveListBoxSelectionBackgroundColor() const final;
+    Color platformInactiveListBoxSelectionBackgroundColor(bool) const final;
     Color platformInactiveListBoxSelectionForegroundColor() const final;
-    Color platformFocusRingColor() const final;
+    Color platformFocusRingColor(bool useSystemAppearance) const final;
 
     ScrollbarControlSize scrollbarControlSizeForPart(ControlPart) final { return SmallScrollbar; }
 
@@ -169,7 +169,7 @@ private:
 private:
     String fileListNameForWidth(const FileList*, const FontCascade&, int width, bool multipleFilesAllowed) const final;
 
-    Color systemColor(CSSValueID) const final;
+    Color systemColor(CSSValueID, bool useSystemAppearance) const final;
 
     void purgeCaches() final;
 
index f480bce..d6de8a6 100644 (file)
@@ -202,7 +202,7 @@ RenderThemeMac::RenderThemeMac()
 NSView *RenderThemeMac::documentViewFor(const RenderObject& o) const
 {
     ControlStates states(extractControlStatesForRenderer(o));
-    return ThemeMac::ensuredView(&o.view().frameView(), states);
+    return ThemeMac::ensuredView(&o.view().frameView(), states, o.page().useSystemAppearance());
 }
 
 #if ENABLE(VIDEO)
@@ -327,17 +327,17 @@ Color RenderThemeMac::platformInactiveListBoxSelectionForegroundColor() const
     return Color::black;
 }
 
-Color RenderThemeMac::platformFocusRingColor() const
+Color RenderThemeMac::platformFocusRingColor(bool useSystemAppearance) const
 {
     if (usesTestModeFocusRingColor())
         return oldAquaFocusRingColor();
 
-    return systemColor(CSSValueWebkitFocusRingColor);
+    return systemColor(CSSValueWebkitFocusRingColor, useSystemAppearance);
 }
 
-Color RenderThemeMac::platformInactiveListBoxSelectionBackgroundColor() const
+Color RenderThemeMac::platformInactiveListBoxSelectionBackgroundColor(bool useSystemAppearance) const
 {
-    LocalDefaultSystemAppearance localAppearance;
+    LocalDefaultSystemAppearance localAppearance(useSystemAppearance);
     return platformInactiveSelectionBackgroundColor();
 }
 
@@ -494,10 +494,10 @@ void RenderThemeMac::platformColorsDidChange()
     RenderTheme::platformColorsDidChange();
 }
 
-Color RenderThemeMac::systemColor(CSSValueID cssValueID) const
+Color RenderThemeMac::systemColor(CSSValueID cssValueID, bool useSystemAppearance) const
 {
-    LocalDefaultSystemAppearance localAppearence;
-    return m_systemColorCache.ensure(cssValueID, [this, cssValueID] () -> Color {
+    LocalDefaultSystemAppearance localAppearance(useSystemAppearance);
+    return m_systemColorCache.ensure(cssValueID, [this, cssValueID, useSystemAppearance] () -> Color {
         auto selectCocoaColor = [cssValueID] () -> SEL {
             switch (cssValueID) {
             case CSSValueActiveborder:
@@ -596,7 +596,7 @@ Color RenderThemeMac::systemColor(CSSValueID cssValueID) const
             // Use platform-independent value returned by base class.
             FALLTHROUGH;
         default:
-            return RenderTheme::systemColor(cssValueID);
+            return RenderTheme::systemColor(cssValueID, useSystemAppearance);
         }
     }).iterator->value;
 }
@@ -1433,7 +1433,7 @@ void RenderThemeMac::paintCellAndSetFocusedElementNeedsRepaintIfNecessary(NSCell
     bool shouldDrawFocusRing = isFocused(renderer) && renderer.style().outlineStyleIsAuto();
     bool shouldUseImageBuffer = renderer.style().effectiveZoom() != 1 || renderer.page().pageScaleFactor() != 1;
     bool shouldDrawCell = true;
-    if (ThemeMac::drawCellOrFocusRingWithViewIntoContext(cell, paintInfo.context(), rect, documentViewFor(renderer), shouldDrawCell, shouldDrawFocusRing, shouldUseImageBuffer, renderer.page().deviceScaleFactor()))
+    if (ThemeMac::drawCellOrFocusRingWithViewIntoContext(cell, paintInfo.context(), rect, documentViewFor(renderer), shouldDrawCell, shouldDrawFocusRing, shouldUseImageBuffer, renderer.page().deviceScaleFactor(), renderer.page().useSystemAppearance()))
         renderer.page().focusController().setFocusedElementNeedsRepaint();
 }
 
@@ -1562,7 +1562,7 @@ bool RenderThemeMac::paintSliderThumb(const RenderObject& o, const PaintInfo& pa
     bool shouldDrawFocusRing = false;
     float deviceScaleFactor = o.page().deviceScaleFactor();
     bool shouldUseImageBuffer = deviceScaleFactor != 1 || zoomLevel != 1;
-    ThemeMac::drawCellOrFocusRingWithViewIntoContext(sliderThumbCell, paintInfo.context(), unzoomedRect, view, shouldDrawCell, shouldDrawFocusRing, shouldUseImageBuffer, deviceScaleFactor);
+    ThemeMac::drawCellOrFocusRingWithViewIntoContext(sliderThumbCell, paintInfo.context(), unzoomedRect, view, shouldDrawCell, shouldDrawFocusRing, shouldUseImageBuffer, deviceScaleFactor, o.page().useSystemAppearance());
     [sliderThumbCell setControlView:nil];
 
     return false;
index 33aec68..fa7e668 100644 (file)
@@ -1012,11 +1012,11 @@ static int cssValueIdToSysColorIndex(CSSValueID cssValueId)
     }
 }
 
-Color RenderThemeWin::systemColor(CSSValueID cssValueId) const
+Color RenderThemeWin::systemColor(CSSValueID cssValueId, bool) const
 {
     int sysColorIndex = cssValueIdToSysColorIndex(cssValueId);
     if (sysColorIndex == -1)
-        return RenderTheme::systemColor(cssValueId);
+        return RenderTheme::systemColor(cssValueId, false);
 
     COLORREF color = GetSysColor(sysColorIndex);
     return Color(GetRValue(color), GetGValue(color), GetBValue(color));
index 0db5545..8bcdd60 100644 (file)
@@ -59,7 +59,7 @@ public:
     Color platformActiveSelectionForegroundColor() const override;
     Color platformInactiveSelectionForegroundColor() const override;
 
-    Color systemColor(CSSValueID) const override;
+    Color systemColor(CSSValueID, bool) const override;
 
     bool paintCheckbox(const RenderObject& o, const PaintInfo& i, const IntRect& r) override
     { return paintButton(o, i, r); }
index ee05308..b06a8b2 100644 (file)
@@ -98,7 +98,7 @@ TextPaintStyle computeTextPaintStyle(const Frame& frame, const RenderStyle& line
     if (lineStyle.insideDefaultButton()) {
         Page* page = frame.page();
         if (page && page->focusController().isActive()) {
-            paintStyle.fillColor = RenderTheme::singleton().systemColor(CSSValueActivebuttontext);
+            paintStyle.fillColor = RenderTheme::singleton().systemColor(CSSValueActivebuttontext, page->useSystemAppearance());
             return paintStyle;
         }
     }
index 93dc262..91ec581 100644 (file)
@@ -1,3 +1,31 @@
+2018-03-08  Megan Gardner  <megan_gardner@apple.com>
+
+        Allow WebViews to disable system appearance
+        https://bugs.webkit.org/show_bug.cgi?id=183418
+        <rdar://problem/36975642>
+
+        Reviewed by Tim Horton.
+        
+        Allow webviews to choose whether or not to follow the default system appearance.
+
+        * Shared/WebPageCreationParameters.cpp:
+        (WebKit::WebPageCreationParameters::encode const):
+        (WebKit::WebPageCreationParameters::decode):
+        * Shared/WebPageCreationParameters.h:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _useSystemAppearance]):
+        (-[WKWebView _setUseSystemAppearance:]):
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::creationParameters):
+        (WebKit::WebPageProxy::setUseSystemAppearance):
+        * UIProcess/WebPageProxy.h:
+        (WebKit::WebPageProxy::useSystemAppearance const):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::setUseSystemAppearance):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+
 2018-03-08  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         Unreviewed, speculative attempt to fix CMake build after r229426
index 78f60e9..3280757 100644 (file)
@@ -81,6 +81,7 @@ void WebPageCreationParameters::encode(IPC::Encoder& encoder) const
 #endif
 #if PLATFORM(MAC)
     encoder << colorSpace;
+    encoder << useSystemAppearance;
 #endif
 #if PLATFORM(IOS)
     encoder << screenSize;
@@ -232,6 +233,8 @@ std::optional<WebPageCreationParameters> WebPageCreationParameters::decode(IPC::
 #if PLATFORM(MAC)
     if (!decoder.decode(parameters.colorSpace))
         return std::nullopt;
+    if (!decoder.decode(parameters.useSystemAppearance))
+        return std::nullopt;
 #endif
 
 #if PLATFORM(IOS)
index 04fe8c8..b0247b2 100644 (file)
@@ -138,6 +138,7 @@ struct WebPageCreationParameters {
 
 #if PLATFORM(MAC)
     ColorSpaceData colorSpace;
+    bool useSystemAppearance;
 #endif
 #if PLATFORM(IOS)
     WebCore::FloatSize screenSize;
index 8782602..f4f3c14 100644 (file)
@@ -6139,6 +6139,16 @@ static WebCore::UserInterfaceLayoutDirection toUserInterfaceLayoutDirection(UISe
     return _page->editorState().postLayoutData().selectionClipRect;
 }
 
+- (BOOL)_useSystemAppearance
+{
+    return _page->useSystemAppearance();
+}
+
+- (void)_setUseSystemAppearance:(BOOL)useSystemAppearance
+{
+    _page->setUseSystemAppearance(useSystemAppearance);
+}
+
 - (void)_setHeaderBannerHeight:(int)height
 {
     _page->setHeaderBannerHeightForTesting(height);
index a1ccce4..e63dd9f 100644 (file)
@@ -439,6 +439,7 @@ typedef NS_OPTIONS(NSUInteger, _WKRectEdge) {
 @property (nonatomic, readonly) BOOL _shouldRequestCandidates WK_API_AVAILABLE(macosx(10.12.3));
 - (void)_insertText:(id)string replacementRange:(NSRange)replacementRange WK_API_AVAILABLE(macosx(10.12.3));
 - (NSRect)_candidateRect WK_API_AVAILABLE(macosx(10.13));
+@property (nonatomic, readwrite, setter=_setUseSystemAppearance:) BOOL _useSystemAppearance WK_API_AVAILABLE(macosx(WK_MAC_TBA));
 
 - (void)_setHeaderBannerHeight:(int)height WK_API_AVAILABLE(macosx(10.12.3));
 - (void)_setFooterBannerHeight:(int)height WK_API_AVAILABLE(macosx(10.12.3));
index e3c9d79..4326a73 100644 (file)
@@ -5854,6 +5854,7 @@ WebPageCreationParameters WebPageProxy::creationParameters()
 #endif
 #if PLATFORM(MAC)
     parameters.colorSpace = m_pageClient.colorSpace();
+    parameters.useSystemAppearance = m_useSystemAppearance;
 #endif
 #if PLATFORM(IOS)
     parameters.screenSize = screenSize();
@@ -6951,6 +6952,18 @@ void WebPageProxy::didHandleAcceptedCandidate()
 {
     m_pageClient.didHandleAcceptedCandidate();
 }
+    
+void WebPageProxy::setUseSystemAppearance(bool useSystemAppearance)
+{
+    if (!isValid())
+        return;
+    
+    if (useSystemAppearance == m_useSystemAppearance)
+        return;
+    
+    m_useSystemAppearance = useSystemAppearance;
+    m_process->send(Messages::WebPage::SetUseSystemAppearance(useSystemAppearance), m_pageID);
+}
 
 void WebPageProxy::setHeaderBannerHeightForTesting(int height)
 {
index 19b8884..54a7488 100644 (file)
@@ -801,6 +801,11 @@ public:
     void setPaginationLineGridEnabled(bool);
     bool paginationLineGridEnabled() const { return m_paginationLineGridEnabled; }
     unsigned pageCount() const { return m_pageCount; }
+        
+#if PLATFORM(MAC)
+    void setUseSystemAppearance(bool);
+    bool useSystemAppearance() const { return m_useSystemAppearance; }
+#endif
 
 #if PLATFORM(COCOA)
     // Called by the web process through a message.
@@ -1789,6 +1794,10 @@ private:
     bool m_isKeyboardAnimatingIn { false };
     bool m_isScrollingOrZooming { false };
 #endif
+        
+#if PLATFORM(MAC)
+    bool m_useSystemAppearance { false };
+#endif
 
 #if ENABLE(APPLE_PAY)
     std::unique_ptr<WebPaymentCoordinatorProxy> m_paymentCoordinator;
index 374d830..0c83f9e 100644 (file)
@@ -4119,6 +4119,10 @@ RetainPtr<PDFDocument> WebPage::pdfDocumentForPrintingFrame(Frame* coreFrame)
     return pluginView->pdfDocumentForPrinting();
 }
 
+void WebPage::setUseSystemAppearance(bool useSystemAppearance)
+{
+    corePage()->setUseSystemAppearance(useSystemAppearance);
+}
 #endif
 
 void WebPage::beginPrinting(uint64_t frameID, const PrintInfo& printInfo)
index cc93510..cb69b70 100644 (file)
@@ -488,6 +488,8 @@ public:
 #if PLATFORM(MAC)
     void setTopOverhangImage(WebImage*);
     void setBottomOverhangImage(WebImage*);
+    
+    void setUseSystemAppearance(bool);
 #endif
 
     bool windowIsFocused() const;
index 2b07f80..d635389 100644 (file)
@@ -442,6 +442,8 @@ messages -> WebPage LegacyReceiver {
 
     HandleAcceptedCandidate(struct WebCore::TextCheckingResult acceptedCandidate)
 
+    SetUseSystemAppearance(bool useSystemAppearance);
+
     SetHeaderBannerHeightForTesting(int height);
     SetFooterBannerHeightForTesting(int height);
 #endif
index 61ba83e..61bd4b7 100644 (file)
@@ -1,3 +1,18 @@
+2018-03-08  Megan Gardner  <megan_gardner@apple.com>
+
+        Allow WebViews to disable system appearance
+        https://bugs.webkit.org/show_bug.cgi?id=183418
+        <rdar://problem/36975642>
+
+        Reviewed by Tim Horton.
+
+        Allow webviews to choose whether or not to follow the default system appearance.
+
+        * WebView/WebView.mm:
+        (-[WebView _setUseSystemAppearance:]):
+        (-[WebView _useSystemAppearance]):
+        * WebView/WebViewPrivate.h:
+
 2018-03-08  Youenn Fablet  <youenn@apple.com>
 
         libwebrtc update broke internal builds
index 435a597..3d983a2 100644 (file)
@@ -5190,6 +5190,19 @@ static Vector<String> toStringVector(NSArray* patterns)
     return insets;
 }
 
+- (void)_setUseSystemAppearance:(BOOL)useSystemAppearance
+{
+    if (auto page = _private->page)
+        page->setUseSystemAppearance(useSystemAppearance);
+}
+
+- (BOOL)_useSystemAppearance
+{
+    if (auto page = _private->page)
+        return page->useSystemAppearance();
+    return NO;
+}
+
 - (void)_setSourceApplicationAuditData:(NSData *)sourceApplicationAuditData
 {
     if (_private->sourceApplicationAuditData == sourceApplicationAuditData)
index 7be4c16..95c0837 100644 (file)
@@ -927,6 +927,8 @@ typedef struct WebEdgeInsets {
 
 @property (nonatomic, assign, setter=_setUnobscuredSafeAreaInsets:) WebEdgeInsets _unobscuredSafeAreaInsets;
 
+@property (nonatomic, assign, setter=_setUseSystemAppearance:) BOOL _useSystemAppearance;
+
 @end
 
 #if !TARGET_OS_IPHONE