Title: [229448] trunk/Source
Revision
229448
Author
megan_gard...@apple.com
Date
2018-03-08 20:55:22 -0800 (Thu, 08 Mar 2018)

Log Message

Allow WebViews to disable system appearance
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:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (229447 => 229448)


--- trunk/Source/WebCore/ChangeLog	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/ChangeLog	2018-03-09 04:55:22 UTC (rev 229448)
@@ -1,5 +1,74 @@
 2018-03-08  Megan Gardner  <megan_gard...@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_gard...@apple.com>
+
         Ensure default appearance for selection form control
         https://bugs.webkit.org/show_bug.cgi?id=183482
         <rdar://problem/38274894>

Modified: trunk/Source/WebCore/css/StyleColor.cpp (229447 => 229448)


--- trunk/Source/WebCore/css/StyleColor.cpp	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/css/StyleColor.cpp	2018-03-09 04:55:22 UTC (rev 229448)
@@ -37,13 +37,13 @@
 
 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)

Modified: trunk/Source/WebCore/css/StyleColor.h (229447 => 229448)


--- trunk/Source/WebCore/css/StyleColor.h	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/css/StyleColor.h	2018-03-09 04:55:22 UTC (rev 229448)
@@ -50,7 +50,7 @@
 
     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);
 

Modified: trunk/Source/WebCore/css/StyleResolver.cpp (229447 => 229448)


--- trunk/Source/WebCore/css/StyleResolver.cpp	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/css/StyleResolver.cpp	2018-03-09 04:55:22 UTC (rev 229448)
@@ -1822,7 +1822,7 @@
     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?
@@ -1829,7 +1829,7 @@
         m_state.style()->setHasExplicitlyInheritedProperties();
         return m_state.style()->color();
     default:
-        return StyleColor::colorFromKeyword(identifier);
+        return StyleColor::colorFromKeyword(identifier, document().useSystemAppearance());
     }
 }
 

Modified: trunk/Source/WebCore/css/parser/CSSParser.cpp (229447 => 229448)


--- trunk/Source/WebCore/css/parser/CSSParser.cpp	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/css/parser/CSSParser.cpp	2018-03-09 04:55:22 UTC (rev 229448)
@@ -176,13 +176,14 @@
     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)

Modified: trunk/Source/WebCore/css/parser/CSSParser.h (229447 => 229448)


--- trunk/Source/WebCore/css/parser/CSSParser.h	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/css/parser/CSSParser.h	2018-03-09 04:55:22 UTC (rev 229448)
@@ -78,7 +78,7 @@
     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);

Modified: trunk/Source/WebCore/css/parser/CSSParserMode.h (229447 => 229448)


--- trunk/Source/WebCore/css/parser/CSSParserMode.h	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/css/parser/CSSParserMode.h	2018-03-09 04:55:22 UTC (rev 229448)
@@ -111,6 +111,8 @@
     
     // This is only needed to support getMatchedCSSRules.
     bool hasDocumentSecurityOrigin { false };
+    
+    bool useSystemAppearance { false };
 
     URL completeURL(const String& url) const
     {

Modified: trunk/Source/WebCore/dom/Document.cpp (229447 => 229448)


--- trunk/Source/WebCore/dom/Document.cpp	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/dom/Document.cpp	2018-03-09 04:55:22 UTC (rev 229448)
@@ -7028,6 +7028,15 @@
         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())

Modified: trunk/Source/WebCore/dom/Document.h (229447 => 229448)


--- trunk/Source/WebCore/dom/Document.h	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/dom/Document.h	2018-03-09 04:55:22 UTC (rev 229448)
@@ -544,6 +544,8 @@
     Settings& mutableSettings() { return m_settings.get(); }
 
     float deviceScaleFactor() const;
+        
+    bool useSystemAppearance() const;
 
     WEBCORE_EXPORT Ref<Range> createRange();
 

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (229447 => 229448)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2018-03-09 04:55:22 UTC (rev 229448)
@@ -84,7 +84,7 @@
     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

Modified: trunk/Source/WebCore/html/canvas/CanvasStyle.cpp (229447 => 229448)


--- trunk/Source/WebCore/html/canvas/CanvasStyle.cpp	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/html/canvas/CanvasStyle.cpp	2018-03-09 04:55:22 UTC (rev 229448)
@@ -53,7 +53,7 @@
     Color color = CSSParser::parseColor(colorString);
     if (color.isValid())
         return color;
-    return CSSParser::parseSystemColor(colorString);
+    return CSSParser::parseSystemColor(colorString, std::nullopt);
 }
 
 Color currentColor(HTMLCanvasElement* canvas)

Modified: trunk/Source/WebCore/page/Page.h (229447 => 229448)


--- trunk/Source/WebCore/page/Page.h	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/page/Page.h	2018-03-09 04:55:22 UTC (rev 229448)
@@ -324,6 +324,9 @@
     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 @@
 #if PLATFORM(IOS)
     bool m_enclosedInScrollableAncestorView { false };
 #endif
+    
+    bool m_useSystemAppearance { false };
 
 #if ENABLE(TEXT_AUTOSIZING)
     float m_textAutosizingWidth { 0 };

Modified: trunk/Source/WebCore/platform/Theme.cpp (229447 => 229448)


--- trunk/Source/WebCore/platform/Theme.cpp	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/platform/Theme.cpp	2018-03-09 04:55:22 UTC (rev 229448)
@@ -57,7 +57,7 @@
     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)
 {
 }
 

Modified: trunk/Source/WebCore/platform/Theme.h (229447 => 229448)


--- trunk/Source/WebCore/platform/Theme.h	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/platform/Theme.h	2018-03-09 04:55:22 UTC (rev 229448)
@@ -67,7 +67,7 @@
     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.

Modified: trunk/Source/WebCore/platform/mac/LocalDefaultSystemAppearance.h (229447 => 229448)


--- trunk/Source/WebCore/platform/mac/LocalDefaultSystemAppearance.h	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/platform/mac/LocalDefaultSystemAppearance.h	2018-03-09 04:55:22 UTC (rev 229448)
@@ -30,7 +30,7 @@
 
 #if USE(APPKIT)
 
-OBJC_CLASS NSAppearence;
+OBJC_CLASS NSAppearance;
 
 namespace WebCore {
     
@@ -39,7 +39,7 @@
 class LocalDefaultSystemAppearance {
     WTF_MAKE_NONCOPYABLE(LocalDefaultSystemAppearance);
 public:
-    LocalDefaultSystemAppearance();
+    LocalDefaultSystemAppearance(bool useSystemAppearance);
     ~LocalDefaultSystemAppearance();
 private:
     RetainPtr<NSAppearance> m_savedSystemAppearance;

Modified: trunk/Source/WebCore/platform/mac/LocalDefaultSystemAppearance.mm (229447 => 229448)


--- trunk/Source/WebCore/platform/mac/LocalDefaultSystemAppearance.mm	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/platform/mac/LocalDefaultSystemAppearance.mm	2018-03-09 04:55:22 UTC (rev 229448)
@@ -31,17 +31,19 @@
 
 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()];
 }
     
 }

Modified: trunk/Source/WebCore/platform/mac/ThemeMac.h (229447 => 229448)


--- trunk/Source/WebCore/platform/mac/ThemeMac.h	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/platform/mac/ThemeMac.h	2018-03-09 04:55:22 UTC (rev 229448)
@@ -33,9 +33,9 @@
 
 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 @@
 
     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;

Modified: trunk/Source/WebCore/platform/mac/ThemeMac.mm (229447 => 229448)


--- trunk/Source/WebCore/platform/mac/ThemeMac.mm	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/platform/mac/ThemeMac.mm	2018-03-09 04:55:22 UTC (rev 229448)
@@ -68,12 +68,12 @@
 
 @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 @@
     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 @@
         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 @@
 
         [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 @@
     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 @@
     
     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 @@
 
 // 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 @@
     }
 
     // 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 @@
     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 @@
     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);

Modified: trunk/Source/WebCore/platform/wpe/ThemeWPE.cpp (229447 => 229448)


--- trunk/Source/WebCore/platform/wpe/ThemeWPE.cpp	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/platform/wpe/ThemeWPE.cpp	2018-03-09 04:55:22 UTC (rev 229448)
@@ -57,7 +57,7 @@
     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:

Modified: trunk/Source/WebCore/platform/wpe/ThemeWPE.h (229447 => 229448)


--- trunk/Source/WebCore/platform/wpe/ThemeWPE.h	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/platform/wpe/ThemeWPE.h	2018-03-09 04:55:22 UTC (rev 229448)
@@ -33,7 +33,7 @@
 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);

Modified: trunk/Source/WebCore/rendering/RenderListBox.cpp (229447 => 229448)


--- trunk/Source/WebCore/rendering/RenderListBox.cpp	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/rendering/RenderListBox.cpp	2018-03-09 04:55:22 UTC (rev 229448)
@@ -460,7 +460,7 @@
         if (frame().selection().isFocusedAndActive() && document().focusedElement() == &selectElement())
             backColor = theme().activeListBoxSelectionBackgroundColor();
         else
-            backColor = theme().inactiveListBoxSelectionBackgroundColor();
+            backColor = theme().inactiveListBoxSelectionBackgroundColor(document().useSystemAppearance());
     } else
         backColor = itemStyle.visitedDependentColor(CSSPropertyBackgroundColor);
 

Modified: trunk/Source/WebCore/rendering/RenderTheme.cpp (229447 => 229448)


--- trunk/Source/WebCore/rendering/RenderTheme.cpp	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/rendering/RenderTheme.cpp	2018-03-09 04:55:22 UTC (rev 229448)
@@ -290,10 +290,10 @@
     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 @@
     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 @@
     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 @@
     return platformActiveSelectionForegroundColor();
 }
 
-Color RenderTheme::platformInactiveListBoxSelectionBackgroundColor() const
+Color RenderTheme::platformInactiveListBoxSelectionBackgroundColor(bool) const
 {
     return platformInactiveSelectionBackgroundColor();
 }
@@ -1208,8 +1208,10 @@
     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 @@
     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

Modified: trunk/Source/WebCore/rendering/RenderTheme.h (229447 => 229448)


--- trunk/Source/WebCore/rendering/RenderTheme.h	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/rendering/RenderTheme.h	2018-03-09 04:55:22 UTC (rev 229448)
@@ -140,7 +140,7 @@
     // 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 @@
 
     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 @@
 
     // 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 @@
     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;
 

Modified: trunk/Source/WebCore/rendering/RenderThemeGtk.cpp (229447 => 229448)


--- trunk/Source/WebCore/rendering/RenderThemeGtk.cpp	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/rendering/RenderThemeGtk.cpp	2018-03-09 04:55:22 UTC (rev 229448)
@@ -1741,7 +1741,7 @@
     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 @@
     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 @@
     case CSSValueCaptiontext:
         return styleColor(Entry, GTK_STATE_FLAG_ACTIVE, StyleColorForeground);
     default:
-        return RenderTheme::systemColor(cssValueId);
+        return RenderTheme::systemColor(cssValueId, false);
     }
 }
 

Modified: trunk/Source/WebCore/rendering/RenderThemeGtk.h (229447 => 229448)


--- trunk/Source/WebCore/rendering/RenderThemeGtk.h	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/rendering/RenderThemeGtk.h	2018-03-09 04:55:22 UTC (rev 229448)
@@ -78,7 +78,7 @@
     // 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 @@
     void platformColorsDidChange() override;
 
     // System colors.
-    Color systemColor(CSSValueID) const override;
+    Color systemColor(CSSValueID, bool) const override;
 
     bool popsMenuBySpaceOrReturn() const override { return true; }
 

Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.h (229447 => 229448)


--- trunk/Source/WebCore/rendering/RenderThemeIOS.h	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.h	2018-03-09 04:55:22 UTC (rev 229448)
@@ -135,7 +135,7 @@
     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;

Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (229447 => 229448)


--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2018-03-09 04:55:22 UTC (rev 229448)
@@ -1397,7 +1397,7 @@
 
 #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 @@
     }
 
     if (!color.isValid())
-        color = RenderTheme::systemColor(cssValueID);
+        color = RenderTheme::systemColor(cssValueID, false);
 
     addResult.iterator->value = color;
 

Modified: trunk/Source/WebCore/rendering/RenderThemeMac.h (229447 => 229448)


--- trunk/Source/WebCore/rendering/RenderThemeMac.h	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.h	2018-03-09 04:55:22 UTC (rev 229448)
@@ -57,9 +57,9 @@
     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:
     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;
 

Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (229447 => 229448)


--- trunk/Source/WebCore/rendering/RenderThemeMac.mm	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm	2018-03-09 04:55:22 UTC (rev 229448)
@@ -202,7 +202,7 @@
 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 @@
     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 @@
     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 @@
             // 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 @@
     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 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;

Modified: trunk/Source/WebCore/rendering/RenderThemeWin.cpp (229447 => 229448)


--- trunk/Source/WebCore/rendering/RenderThemeWin.cpp	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/rendering/RenderThemeWin.cpp	2018-03-09 04:55:22 UTC (rev 229448)
@@ -1012,11 +1012,11 @@
     }
 }
 
-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));

Modified: trunk/Source/WebCore/rendering/RenderThemeWin.h (229447 => 229448)


--- trunk/Source/WebCore/rendering/RenderThemeWin.h	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/rendering/RenderThemeWin.h	2018-03-09 04:55:22 UTC (rev 229448)
@@ -59,7 +59,7 @@
     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); }

Modified: trunk/Source/WebCore/rendering/TextPaintStyle.cpp (229447 => 229448)


--- trunk/Source/WebCore/rendering/TextPaintStyle.cpp	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebCore/rendering/TextPaintStyle.cpp	2018-03-09 04:55:22 UTC (rev 229448)
@@ -98,7 +98,7 @@
     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;
         }
     }

Modified: trunk/Source/WebKit/ChangeLog (229447 => 229448)


--- trunk/Source/WebKit/ChangeLog	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebKit/ChangeLog	2018-03-09 04:55:22 UTC (rev 229448)
@@ -1,3 +1,31 @@
+2018-03-08  Megan Gardner  <megan_gard...@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  <mcatanz...@igalia.com>
 
         Unreviewed, speculative attempt to fix CMake build after r229426

Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp (229447 => 229448)


--- trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp	2018-03-09 04:55:22 UTC (rev 229448)
@@ -81,6 +81,7 @@
 #endif
 #if PLATFORM(MAC)
     encoder << colorSpace;
+    encoder << useSystemAppearance;
 #endif
 #if PLATFORM(IOS)
     encoder << screenSize;
@@ -232,6 +233,8 @@
 #if PLATFORM(MAC)
     if (!decoder.decode(parameters.colorSpace))
         return std::nullopt;
+    if (!decoder.decode(parameters.useSystemAppearance))
+        return std::nullopt;
 #endif
 
 #if PLATFORM(IOS)

Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.h (229447 => 229448)


--- trunk/Source/WebKit/Shared/WebPageCreationParameters.h	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.h	2018-03-09 04:55:22 UTC (rev 229448)
@@ -138,6 +138,7 @@
 
 #if PLATFORM(MAC)
     ColorSpaceData colorSpace;
+    bool useSystemAppearance;
 #endif
 #if PLATFORM(IOS)
     WebCore::FloatSize screenSize;

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (229447 => 229448)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2018-03-09 04:55:22 UTC (rev 229448)
@@ -6139,6 +6139,16 @@
     return _page->editorState().postLayoutData().selectionClipRect;
 }
 
+- (BOOL)_useSystemAppearance
+{
+    return _page->useSystemAppearance();
+}
+
+- (void)_setUseSystemAppearance:(BOOL)useSystemAppearance
+{
+    _page->setUseSystemAppearance(useSystemAppearance);
+}
+
 - (void)_setHeaderBannerHeight:(int)height
 {
     _page->setHeaderBannerHeightForTesting(height);

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h (229447 => 229448)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h	2018-03-09 04:55:22 UTC (rev 229448)
@@ -439,6 +439,7 @@
 @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));

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (229447 => 229448)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-03-09 04:55:22 UTC (rev 229448)
@@ -5854,6 +5854,7 @@
 #endif
 #if PLATFORM(MAC)
     parameters.colorSpace = m_pageClient.colorSpace();
+    parameters.useSystemAppearance = m_useSystemAppearance;
 #endif
 #if PLATFORM(IOS)
     parameters.screenSize = screenSize();
@@ -6951,6 +6952,18 @@
 {
     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)
 {

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (229447 => 229448)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2018-03-09 04:55:22 UTC (rev 229448)
@@ -801,6 +801,11 @@
     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 @@
     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;

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (229447 => 229448)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2018-03-09 04:55:22 UTC (rev 229448)
@@ -4119,6 +4119,10 @@
     return pluginView->pdfDocumentForPrinting();
 }
 
+void WebPage::setUseSystemAppearance(bool useSystemAppearance)
+{
+    corePage()->setUseSystemAppearance(useSystemAppearance);
+}
 #endif
 
 void WebPage::beginPrinting(uint64_t frameID, const PrintInfo& printInfo)

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (229447 => 229448)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2018-03-09 04:55:22 UTC (rev 229448)
@@ -488,6 +488,8 @@
 #if PLATFORM(MAC)
     void setTopOverhangImage(WebImage*);
     void setBottomOverhangImage(WebImage*);
+    
+    void setUseSystemAppearance(bool);
 #endif
 
     bool windowIsFocused() const;

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (229447 => 229448)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2018-03-09 04:55:22 UTC (rev 229448)
@@ -442,6 +442,8 @@
 
     HandleAcceptedCandidate(struct WebCore::TextCheckingResult acceptedCandidate)
 
+    SetUseSystemAppearance(bool useSystemAppearance);
+
     SetHeaderBannerHeightForTesting(int height);
     SetFooterBannerHeightForTesting(int height);
 #endif

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (229447 => 229448)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2018-03-09 04:55:22 UTC (rev 229448)
@@ -1,3 +1,18 @@
+2018-03-08  Megan Gardner  <megan_gard...@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  <you...@apple.com>
 
         libwebrtc update broke internal builds

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebView.mm (229447 => 229448)


--- trunk/Source/WebKitLegacy/mac/WebView/WebView.mm	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebView.mm	2018-03-09 04:55:22 UTC (rev 229448)
@@ -5190,6 +5190,19 @@
     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)

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebViewPrivate.h (229447 => 229448)


--- trunk/Source/WebKitLegacy/mac/WebView/WebViewPrivate.h	2018-03-09 02:16:27 UTC (rev 229447)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebViewPrivate.h	2018-03-09 04:55:22 UTC (rev 229448)
@@ -927,6 +927,8 @@
 
 @property (nonatomic, assign, setter=_setUnobscuredSafeAreaInsets:) WebEdgeInsets _unobscuredSafeAreaInsets;
 
+@property (nonatomic, assign, setter=_setUseSystemAppearance:) BOOL _useSystemAppearance;
+
 @end
 
 #if !TARGET_OS_IPHONE
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to