Add -apple-color-filter and system appearance toggles to MiniBrowser
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 30 Jun 2018 01:20:02 +0000 (01:20 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 30 Jun 2018 01:20:02 +0000 (01:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=187210

Reviewed by Simon Fraser.

* MiniBrowser/mac/AppDelegate.m:
(defaultConfiguration):
* MiniBrowser/mac/SettingsController.h:
* MiniBrowser/mac/SettingsController.m:
(-[SettingsController _populateMenu]):
(-[SettingsController validateMenuItem:]):
(-[SettingsController toggleAppleColorFilterEnabled:]):
(-[SettingsController appleColorFilterEnabled]):
(-[SettingsController toggleUseSystemAppearance:]):
(-[SettingsController useSystemAppearance]):
* MiniBrowser/mac/WK1BrowserWindowController.m:
(-[WK1BrowserWindowController didChangeSettings]):
* MiniBrowser/mac/WK2BrowserWindowController.m:
(-[WK2BrowserWindowController didChangeSettings]):

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

Tools/ChangeLog
Tools/MiniBrowser/mac/AppDelegate.m
Tools/MiniBrowser/mac/SettingsController.h
Tools/MiniBrowser/mac/SettingsController.m
Tools/MiniBrowser/mac/WK1BrowserWindowController.m
Tools/MiniBrowser/mac/WK2BrowserWindowController.m

index 390e65d..9a880b8 100644 (file)
@@ -1,3 +1,25 @@
+2018-06-29  Tim Horton  <timothy_horton@apple.com>
+
+        Add -apple-color-filter and system appearance toggles to MiniBrowser
+        https://bugs.webkit.org/show_bug.cgi?id=187210
+
+        Reviewed by Simon Fraser.
+
+        * MiniBrowser/mac/AppDelegate.m:
+        (defaultConfiguration):
+        * MiniBrowser/mac/SettingsController.h:
+        * MiniBrowser/mac/SettingsController.m:
+        (-[SettingsController _populateMenu]):
+        (-[SettingsController validateMenuItem:]):
+        (-[SettingsController toggleAppleColorFilterEnabled:]):
+        (-[SettingsController appleColorFilterEnabled]):
+        (-[SettingsController toggleUseSystemAppearance:]):
+        (-[SettingsController useSystemAppearance]):
+        * MiniBrowser/mac/WK1BrowserWindowController.m:
+        (-[WK1BrowserWindowController didChangeSettings]):
+        * MiniBrowser/mac/WK2BrowserWindowController.m:
+        (-[WK2BrowserWindowController didChangeSettings]):
+
 2018-06-29  Aditya Keerthi  <akeerthi@apple.com>
 
         [macOS] Do not crash if there is an attempt to copy a file URL to the clipboard
index 3a369a4..53f8f5e 100644 (file)
@@ -116,6 +116,7 @@ static WKWebViewConfiguration *defaultConfiguration()
 
     configuration.suppressesIncrementalRendering = [SettingsController shared].incrementalRenderingSuppressed;
     configuration.websiteDataStore._resourceLoadStatisticsEnabled = [SettingsController shared].resourceLoadStatisticsEnabled;
+    configuration._colorFilterEnabled = [SettingsController shared].appleColorFilterEnabled;
     return configuration;
 }
 
index 84db32c..4eb5062 100644 (file)
@@ -56,6 +56,8 @@
 @property (nonatomic, readonly) BOOL visualViewportEnabled;
 @property (nonatomic, readonly) BOOL largeImageAsyncDecodingEnabled;
 @property (nonatomic, readonly) BOOL animatedImageAsyncDecodingEnabled;
+@property (nonatomic, readonly) BOOL appleColorFilterEnabled;
+@property (nonatomic, readonly) BOOL useSystemAppearance;
 @property (nonatomic, readonly) BOOL loadsAllSiteIcons;
 @property (nonatomic, readonly) BOOL usesGameControllerFramework;
 @property (nonatomic, readonly) BOOL networkCacheSpeculativeRevalidationDisabled;
index 84f0190..e097eff 100644 (file)
@@ -64,6 +64,8 @@ static NSString * const EnableSubPixelCSSOMMetricsPreferenceKey = @"EnableSubPix
 static NSString * const VisualViewportEnabledPreferenceKey = @"VisualViewportEnabled";
 static NSString * const LargeImageAsyncDecodingEnabledPreferenceKey = @"LargeImageAsyncDecodingEnabled";
 static NSString * const AnimatedImageAsyncDecodingEnabledPreferenceKey = @"AnimatedImageAsyncDecodingEnabled";
+static NSString * const AppleColorFilterEnabledPreferenceKey = @"AppleColorFilterEnabled";
+static NSString * const UseSystemAppearancePreferenceKey = @"UseSystemAppearance";
 
 // This default name intentionally overlaps with the key that WebKit2 checks when creating a view.
 static NSString * const UseRemoteLayerTreeDrawingAreaPreferenceKey = @"WebKit2UseRemoteLayerTreeDrawingArea";
@@ -170,7 +172,8 @@ typedef NS_ENUM(NSInteger, DebugOverylayMenuItemTag) {
     [self _addItemWithTitle:@"Enable Resource Load Statistics" action:@selector(toggleResourceLoadStatisticsEnabled:) indented:NO];
     [self _addItemWithTitle:@"Enable Large Image Async Decoding" action:@selector(toggleLargeImageAsyncDecodingEnabled:) indented:NO];
     [self _addItemWithTitle:@"Enable Animated Image Async Decoding" action:@selector(toggleAnimatedImageAsyncDecodingEnabled:) indented:NO];
-
+    [self _addItemWithTitle:@"Enable -apple-color-filter" action:@selector(toggleAppleColorFilterEnabled:) indented:NO];
+    [self _addItemWithTitle:@"Use System Appearance" action:@selector(toggleUseSystemAppearance:) indented:NO];
     [self _addHeaderWithTitle:@"WebKit2-only Settings"];
 
     [self _addItemWithTitle:@"Reserve Space For Banners" action:@selector(toggleReserveSpaceForBanners:) indented:YES];
@@ -260,6 +263,10 @@ typedef NS_ENUM(NSInteger, DebugOverylayMenuItemTag) {
         [menuItem setState:[self largeImageAsyncDecodingEnabled] ? NSControlStateValueOn : NSControlStateValueOff];
     else if (action == @selector(toggleAnimatedImageAsyncDecodingEnabled:))
         [menuItem setState:[self animatedImageAsyncDecodingEnabled] ? NSControlStateValueOn : NSControlStateValueOff];
+    else if (action == @selector(toggleAppleColorFilterEnabled:))
+        [menuItem setState:[self appleColorFilterEnabled] ? NSControlStateValueOn : NSControlStateValueOff];
+    else if (action == @selector(toggleUseSystemAppearance:))
+        [menuItem setState:[self useSystemAppearance] ? NSControlStateValueOn : NSControlStateValueOff];
     else if (action == @selector(toggleVisualViewportEnabled:))
         [menuItem setState:[self visualViewportEnabled] ? NSControlStateValueOn : NSControlStateValueOff];
     else if (action == @selector(toggleReserveSpaceForBanners:))
@@ -568,6 +575,26 @@ typedef NS_ENUM(NSInteger, DebugOverylayMenuItemTag) {
     return [[NSUserDefaults standardUserDefaults] boolForKey:AnimatedImageAsyncDecodingEnabledPreferenceKey];
 }
 
+- (void)toggleAppleColorFilterEnabled:(id)sender
+{
+    [self _toggleBooleanDefault:AppleColorFilterEnabledPreferenceKey];
+}
+
+- (BOOL)appleColorFilterEnabled
+{
+    return [[NSUserDefaults standardUserDefaults] boolForKey:AppleColorFilterEnabledPreferenceKey];
+}
+
+- (void)toggleUseSystemAppearance:(id)sender
+{
+    [self _toggleBooleanDefault:UseSystemAppearancePreferenceKey];
+}
+
+- (BOOL)useSystemAppearance
+{
+    return [[NSUserDefaults standardUserDefaults] boolForKey:UseSystemAppearancePreferenceKey];
+}
+
 - (void)toggleEnableSubPixelCSSOMMetrics:(id)sender
 {
     [self _toggleBooleanDefault:EnableSubPixelCSSOMMetricsPreferenceKey];
index 19bd2ff..c2c3647 100644 (file)
@@ -311,6 +311,9 @@ static BOOL areEssentiallyEqual(double a, double b)
     [[WebPreferences standardPreferences] setVisualViewportEnabled:settings.visualViewportEnabled];
     [[WebPreferences standardPreferences] setLargeImageAsyncDecodingEnabled:settings.largeImageAsyncDecodingEnabled];
     [[WebPreferences standardPreferences] setAnimatedImageAsyncDecodingEnabled:settings.animatedImageAsyncDecodingEnabled];
+    [[WebPreferences standardPreferences] setColorFilterEnabled:settings.appleColorFilterEnabled];
+
+    _webView._useSystemAppearance = settings.useSystemAppearance;
 
     BOOL useTransparentWindows = settings.useTransparentWindows;
     if (useTransparentWindows != !self.window.isOpaque) {
index 3ead630..33fab1d 100644 (file)
@@ -396,6 +396,8 @@ static BOOL areEssentiallyEqual(double a, double b)
     SettingsController *settings = [SettingsController shared];
     WKPreferences *preferences = _webView.configuration.preferences;
 
+    _webView._useSystemAppearance = settings.useSystemAppearance;
+
     preferences._tiledScrollingIndicatorVisible = settings.tiledScrollingIndicatorVisible;
     preferences._compositingBordersVisible = settings.layerBordersVisible;
     preferences._compositingRepaintCountersVisible = settings.layerBordersVisible;