Title: [229336] trunk/Source/WebCore
Revision
229336
Author
megan_gard...@apple.com
Date
2018-03-06 12:20:29 -0800 (Tue, 06 Mar 2018)

Log Message

Ensure system appearance is default for web content
https://bugs.webkit.org/show_bug.cgi?id=183354
<rdar://problem/36975571>
<rdar://problem/38162381>

Make sure the the system appearance for web content is default, and
consolidate that code to a single class.

Reviewed by Tim Horton.

Not currently testable, will add tests in a future patch.

* WebCore.xcodeproj/project.pbxproj:
* platform/mac/LocalDefaultSystemAppearance.h: Added.
* platform/mac/LocalDefaultSystemAppearance.mm: Added.
(WebCore::LocalDefaultSystemAppearance::LocalDefaultSystemAppearance):
(WebCore::LocalDefaultSystemAppearance::~LocalDefaultSystemAppearance):
* platform/mac/ThemeMac.mm:
(-[WebCoreThemeView init]):
(WebCore::ThemeMac::drawCellOrFocusRingWithViewIntoContext):
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::systemColor const):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (229335 => 229336)


--- trunk/Source/WebCore/ChangeLog	2018-03-06 20:12:52 UTC (rev 229335)
+++ trunk/Source/WebCore/ChangeLog	2018-03-06 20:20:29 UTC (rev 229336)
@@ -1,3 +1,28 @@
+2018-03-06  Megan Gardner  <megan_gard...@apple.com>
+
+        Ensure system appearance is default for web content
+        https://bugs.webkit.org/show_bug.cgi?id=183354
+        <rdar://problem/36975571>
+        <rdar://problem/38162381>
+
+        Make sure the the system appearance for web content is default, and
+        consolidate that code to a single class.
+
+        Reviewed by Tim Horton.
+
+        Not currently testable, will add tests in a future patch.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/mac/LocalDefaultSystemAppearance.h: Added.
+        * platform/mac/LocalDefaultSystemAppearance.mm: Added.
+        (WebCore::LocalDefaultSystemAppearance::LocalDefaultSystemAppearance):
+        (WebCore::LocalDefaultSystemAppearance::~LocalDefaultSystemAppearance):
+        * platform/mac/ThemeMac.mm:
+        (-[WebCoreThemeView init]):
+        (WebCore::ThemeMac::drawCellOrFocusRingWithViewIntoContext):
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::systemColor const):
+
 2018-03-06  Antoine Quint  <grao...@apple.com>
 
         [Web Animations] Add a new runtime flag to control whether CSS Animations and CSS Transitions should run using the Web Animations timeline

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (229335 => 229336)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2018-03-06 20:12:52 UTC (rev 229335)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2018-03-06 20:20:29 UTC (rev 229336)
@@ -1172,6 +1172,8 @@
 		43EDD67F1B485DBF00640E75 /* CombinedFiltersAlphabet.h in Headers */ = {isa = PBXBuildFile; fileRef = 43EDD67D1B485DBF00640E75 /* CombinedFiltersAlphabet.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		4415292E0E1AE8A000C4A2D0 /* HTMLPlugInImageElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 4415292C0E1AE8A000C4A2D0 /* HTMLPlugInImageElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		443918001A91B2F8006E04F2 /* QuickLookSoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 443917FE1A91B2F8006E04F2 /* QuickLookSoftLink.h */; };
+		445775E520472F73008DCE5D /* LocalDefaultSystemAppearance.h in Headers */ = {isa = PBXBuildFile; fileRef = 445775E420472F73008DCE5D /* LocalDefaultSystemAppearance.h */; };
+		445775EA2047303C008DCE5D /* LocalDefaultSystemAppearance.mm in Sources */ = {isa = PBXBuildFile; fileRef = 445775E92047303B008DCE5D /* LocalDefaultSystemAppearance.mm */; };
 		447958041643B49A001E0A7F /* ParsedContentType.h in Headers */ = {isa = PBXBuildFile; fileRef = 447958031643B47B001E0A7F /* ParsedContentType.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		448A29BF0A46D9CB0030759F /* JSHTMLOptionsCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 448A29BD0A46D9CB0030759F /* JSHTMLOptionsCollection.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		448B1B7A0F3A2F9B0047A9E2 /* TextSizeAdjustment.h in Headers */ = {isa = PBXBuildFile; fileRef = 448B1B780F3A2F9B0047A9E2 /* TextSizeAdjustment.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -7375,6 +7377,8 @@
 		443917FE1A91B2F8006E04F2 /* QuickLookSoftLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QuickLookSoftLink.h; sourceTree = "<group>"; };
 		443F04260E75C8FB007E5407 /* NetworkStateNotifierIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetworkStateNotifierIOS.mm; sourceTree = "<group>"; };
 		444D4E210F708B2E003158E0 /* WebCoreURLResponseIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreURLResponseIOS.mm; sourceTree = "<group>"; };
+		445775E420472F73008DCE5D /* LocalDefaultSystemAppearance.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LocalDefaultSystemAppearance.h; sourceTree = "<group>"; };
+		445775E92047303B008DCE5D /* LocalDefaultSystemAppearance.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalDefaultSystemAppearance.mm; sourceTree = "<group>"; };
 		4476531A133170990006B789 /* SSLKeyGeneratorIOS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SSLKeyGeneratorIOS.cpp; sourceTree = "<group>"; };
 		447958021643B47B001E0A7F /* ParsedContentType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParsedContentType.cpp; sourceTree = "<group>"; };
 		447958031643B47B001E0A7F /* ParsedContentType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParsedContentType.h; sourceTree = "<group>"; };
@@ -18827,6 +18831,8 @@
 				F44A5F571FED3830007F5944 /* LegacyNSPasteboardTypes.h */,
 				06E81ED60AB5D5E900C87837 /* LocalCurrentGraphicsContext.h */,
 				06E81EEB0AB5DA9700C87837 /* LocalCurrentGraphicsContext.mm */,
+				445775E420472F73008DCE5D /* LocalDefaultSystemAppearance.h */,
+				445775E92047303B008DCE5D /* LocalDefaultSystemAppearance.mm */,
 				1402645D0AFDC19B005919E2 /* LoggingMac.mm */,
 				CD8ACA8C1D23971900ECC59E /* MediaRemoteSoftLink.cpp */,
 				CD8ACA8D1D23971900ECC59E /* MediaRemoteSoftLink.h */,
@@ -28887,6 +28893,7 @@
 				51E6821016387302003BBF3C /* LoaderStrategy.h in Headers */,
 				8A12E35D11FA33280025836A /* LoadTiming.h in Headers */,
 				06E81ED70AB5D5E900C87837 /* LocalCurrentGraphicsContext.h in Headers */,
+				445775E520472F73008DCE5D /* LocalDefaultSystemAppearance.h in Headers */,
 				F5973DE015CFB2030027F804 /* LocaleMac.h in Headers */,
 				7633A72613D8B33A008501B6 /* LocaleToScriptMapping.h in Headers */,
 				A516E8B7136E04DB0076C3C0 /* LocalizedDateCache.h in Headers */,
@@ -31052,6 +31059,7 @@
 				417612AF1E3A994000C3D81D /* LibWebRTCMediaEndpoint.cpp in Sources */,
 				417612B11E3A994000C3D81D /* LibWebRTCPeerConnectionBackend.cpp in Sources */,
 				9759E93E14EF1CF80026A2DD /* LoadableTextTrack.cpp in Sources */,
+				445775EA2047303C008DCE5D /* LocalDefaultSystemAppearance.mm in Sources */,
 				FABE72FE1059C21100D999DD /* MathMLNames.cpp in Sources */,
 				2D9BF7051DBFBB24007A7D99 /* MediaEncryptedEvent.cpp in Sources */,
 				2D9BF7471DBFDC49007A7D99 /* MediaKeyMessageEvent.cpp in Sources */,

Added: trunk/Source/WebCore/platform/mac/LocalDefaultSystemAppearance.h (0 => 229336)


--- trunk/Source/WebCore/platform/mac/LocalDefaultSystemAppearance.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/mac/LocalDefaultSystemAppearance.h	2018-03-06 20:20:29 UTC (rev 229336)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/Noncopyable.h>
+#include <wtf/RetainPtr.h>
+
+#if USE(APPKIT)
+
+OBJC_CLASS NSAppearence;
+
+namespace WebCore {
+    
+// This class automatically saves and restores the current NSAppearance for
+// functions which call out into AppKit and rely on the current NSAppearance being set
+class LocalDefaultSystemAppearance {
+    WTF_MAKE_NONCOPYABLE(LocalDefaultSystemAppearance);
+public:
+    LocalDefaultSystemAppearance();
+    ~LocalDefaultSystemAppearance();
+private:
+    RetainPtr<NSAppearance> m_savedSystemAppearance;
+};
+    
+}
+
+#endif // USE(APPKIT)
+

Added: trunk/Source/WebCore/platform/mac/LocalDefaultSystemAppearance.mm (0 => 229336)


--- trunk/Source/WebCore/platform/mac/LocalDefaultSystemAppearance.mm	                        (rev 0)
+++ trunk/Source/WebCore/platform/mac/LocalDefaultSystemAppearance.mm	2018-03-06 20:20:29 UTC (rev 229336)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "LocalDefaultSystemAppearance.h"
+
+#if USE(APPKIT)
+
+#include <AppKit/NSAppearance.h>
+
+namespace WebCore {
+    
+LocalDefaultSystemAppearance::LocalDefaultSystemAppearance()
+    : m_savedSystemAppearance()
+{
+    m_savedSystemAppearance = [NSAppearance currentAppearance];
+    NSAppearance *newAppearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua];
+    [NSAppearance setCurrentAppearance:newAppearance];
+}
+
+LocalDefaultSystemAppearance::~LocalDefaultSystemAppearance()
+{
+    [NSAppearance setCurrentAppearance:m_savedSystemAppearance.get()];
+}
+    
+}
+
+#endif // USE(APPKIT)

Modified: trunk/Source/WebCore/platform/mac/ThemeMac.mm (229335 => 229336)


--- trunk/Source/WebCore/platform/mac/ThemeMac.mm	2018-03-06 20:12:52 UTC (rev 229335)
+++ trunk/Source/WebCore/platform/mac/ThemeMac.mm	2018-03-06 20:20:29 UTC (rev 229336)
@@ -34,6 +34,7 @@
 #import "ImageBuffer.h"
 #import "LengthSize.h"
 #import "LocalCurrentGraphicsContext.h"
+#import "LocalDefaultSystemAppearance.h"
 #import "ScrollView.h"
 #import <Carbon/Carbon.h>
 #import <pal/spi/cocoa/NSButtonCellSPI.h>
@@ -67,6 +68,16 @@
 
 @implementation WebCoreThemeView
 
+- (instancetype)init
+{
+    if (!(self = [super init]))
+        return nil;
+    
+    WebCore::LocalDefaultSystemAppearance localAppearence;
+    [self setAppearance:[NSAppearance currentAppearance]];
+    return self;
+}
+
 - (NSWindow *)window
 {
     // Using defer:YES prevents us from wasting any window server resources for this window, since we're not actually
@@ -676,6 +687,7 @@
 bool ThemeMac::drawCellOrFocusRingWithViewIntoContext(NSCell *cell, GraphicsContext& context, const FloatRect& rect, NSView *view, bool drawButtonCell, bool drawFocusRing, bool useImageBuffer, float deviceScaleFactor)
 {
     ASSERT(drawButtonCell || drawFocusRing);
+    LocalDefaultSystemAppearance localAppearence;
     bool needsRepaint = false;
     if (useImageBuffer) {
         NSRect imageBufferDrawRect = NSRect(FloatRect(buttonFocusRectOutlineWidth, buttonFocusRectOutlineWidth, rect.width(), rect.height()));

Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (229335 => 229336)


--- trunk/Source/WebCore/rendering/RenderThemeMac.mm	2018-03-06 20:12:52 UTC (rev 229335)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm	2018-03-06 20:20:29 UTC (rev 229336)
@@ -45,6 +45,7 @@
 #import "Image.h"
 #import "ImageBuffer.h"
 #import "LocalCurrentGraphicsContext.h"
+#import "LocalDefaultSystemAppearance.h"
 #import "LocalizedStrings.h"
 #import "MediaControlElements.h"
 #import "Page.h"
@@ -494,6 +495,7 @@
 
 Color RenderThemeMac::systemColor(CSSValueID cssValueID) const
 {
+    LocalDefaultSystemAppearance localAppearence;
     return m_systemColorCache.ensure(cssValueID, [this, cssValueID] () -> Color {
         auto selectCocoaColor = [cssValueID] () -> SEL {
             switch (cssValueID) {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to