- Revision
- 265996
- Author
- pvol...@apple.com
- Date
- 2020-08-20 19:31:40 -0700 (Thu, 20 Aug 2020)
Log Message
[macOS] Web pages are not responding correctly to changes in "Reduce motion" setting
https://bugs.webkit.org/show_bug.cgi?id=215664
Reviewed by Darin Adler.
Source/WebCore/PAL:
Declare "Reduce motion" preference key, as well as notification sent when the "Reduce motion" setting is changed.
* pal/spi/mac/HIServicesSPI.h:
Source/WebKit:
This happens because there is a race between the preference change and notification being received in the WebContent
process. This race is usually won by the notification, which then reads the wrong preference value when being handled.
This bug was introduced when access to the preference daemon was closed in the WebContent process, and preferences
were updated from the UI process. This patch addresses this issue by re-posting the notification when the preference
value is updated in the WebContent process.
API test: WebKit.AccessibilityReduceMotion
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::reduceMotionPreferenceKey):
(WebKit::dispatchSimulatedNotificationsForPreferenceChange):
Tools:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit/AccessibilityReduceMotion.mm: Added.
(TEST):
Modified Paths
Added Paths
Diff
Modified: trunk/Source/WebCore/PAL/ChangeLog (265995 => 265996)
--- trunk/Source/WebCore/PAL/ChangeLog 2020-08-21 02:10:23 UTC (rev 265995)
+++ trunk/Source/WebCore/PAL/ChangeLog 2020-08-21 02:31:40 UTC (rev 265996)
@@ -1,3 +1,14 @@
+2020-08-20 Per Arne Vollan <pvol...@apple.com>
+
+ [macOS] Web pages are not responding correctly to changes in "Reduce motion" setting
+ https://bugs.webkit.org/show_bug.cgi?id=215664
+
+ Reviewed by Darin Adler.
+
+ Declare "Reduce motion" preference key, as well as notification sent when the "Reduce motion" setting is changed.
+
+ * pal/spi/mac/HIServicesSPI.h:
+
2020-08-19 Aditya Keerthi <akeer...@apple.com>
[macOS] Move stepper painting code off of Carbon API
Modified: trunk/Source/WebCore/PAL/pal/spi/mac/HIServicesSPI.h (265995 => 265996)
--- trunk/Source/WebCore/PAL/pal/spi/mac/HIServicesSPI.h 2020-08-21 02:10:23 UTC (rev 265995)
+++ trunk/Source/WebCore/PAL/pal/spi/mac/HIServicesSPI.h 2020-08-21 02:31:40 UTC (rev 265996)
@@ -149,6 +149,9 @@
void _AXSetClientIdentificationOverride(AXClientType);
#endif // HAVE(AX_CLIENT_TYPE)
+extern CFStringRef kAXInterfaceReduceMotionKey;
+extern CFStringRef kAXInterfaceReduceMotionStatusDidChangeNotification;
+
WTF_EXTERN_C_END
#endif // USE(APPLE_INTERNAL_SDK)
Modified: trunk/Source/WebKit/ChangeLog (265995 => 265996)
--- trunk/Source/WebKit/ChangeLog 2020-08-21 02:10:23 UTC (rev 265995)
+++ trunk/Source/WebKit/ChangeLog 2020-08-21 02:31:40 UTC (rev 265996)
@@ -1,3 +1,22 @@
+2020-08-20 Per Arne Vollan <pvol...@apple.com>
+
+ [macOS] Web pages are not responding correctly to changes in "Reduce motion" setting
+ https://bugs.webkit.org/show_bug.cgi?id=215664
+
+ Reviewed by Darin Adler.
+
+ This happens because there is a race between the preference change and notification being received in the WebContent
+ process. This race is usually won by the notification, which then reads the wrong preference value when being handled.
+ This bug was introduced when access to the preference daemon was closed in the WebContent process, and preferences
+ were updated from the UI process. This patch addresses this issue by re-posting the notification when the preference
+ value is updated in the WebContent process.
+
+ API test: WebKit.AccessibilityReduceMotion
+
+ * WebProcess/cocoa/WebProcessCocoa.mm:
+ (WebKit::reduceMotionPreferenceKey):
+ (WebKit::dispatchSimulatedNotificationsForPreferenceChange):
+
2020-08-20 James Savage <james.sav...@apple.com>
Could not find module 'WebKit' for target 'armv7-apple-ios'
Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (265995 => 265996)
--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm 2020-08-21 02:10:23 UTC (rev 265995)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm 2020-08-21 02:31:40 UTC (rev 265996)
@@ -124,6 +124,7 @@
#import "WebSwitchingGPUClient.h"
#import <WebCore/GraphicsContextGLOpenGLManager.h>
#import <WebCore/ScrollbarThemeMac.h>
+#import <pal/spi/mac/HIServicesSPI.h>
#import <pal/spi/mac/NSScrollerImpSPI.h>
#endif
@@ -910,6 +911,12 @@
static NeverDestroyed<WTF::String> userHighlightColorPreferenceKey(MAKE_STATIC_STRING_IMPL("AppleHighlightColor"));
return userHighlightColorPreferenceKey;
}
+
+static const WTF::String& reduceMotionPreferenceKey()
+{
+ static NeverDestroyed<WTF::String> key(MAKE_STATIC_STRING_IMPL("reduceMotion"));
+ return key;
+}
#endif
static void dispatchSimulatedNotificationsForPreferenceChange(const String& key)
@@ -920,15 +927,17 @@
// of the system, we must re-post the notification in the Web Content process after updating the default.
if (key == userAccentColorPreferenceKey()) {
- NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
+ auto notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter postNotificationName:@"kCUINotificationAquaColorVariantChanged" object:nil];
[notificationCenter postNotificationName:@"NSSystemColorsWillChangeNotification" object:nil];
[notificationCenter postNotificationName:NSSystemColorsDidChangeNotification object:nil];
- }
- if (key == userHighlightColorPreferenceKey()) {
- NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
+ } else if (key == userHighlightColorPreferenceKey()) {
+ auto notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter postNotificationName:@"NSSystemColorsWillChangeNotification" object:nil];
[notificationCenter postNotificationName:NSSystemColorsDidChangeNotification object:nil];
+ } else if (key == reduceMotionPreferenceKey()) {
+ auto notificationCenter = CFNotificationCenterGetDistributedCenter();
+ CFNotificationCenterPostNotification(notificationCenter, kAXInterfaceReduceMotionStatusDidChangeNotification, nullptr, nullptr, true);
}
#endif
}
Modified: trunk/Tools/ChangeLog (265995 => 265996)
--- trunk/Tools/ChangeLog 2020-08-21 02:10:23 UTC (rev 265995)
+++ trunk/Tools/ChangeLog 2020-08-21 02:31:40 UTC (rev 265996)
@@ -1,3 +1,14 @@
+2020-08-20 Per Arne Vollan <pvol...@apple.com>
+
+ [macOS] Web pages are not responding correctly to changes in "Reduce motion" setting
+ https://bugs.webkit.org/show_bug.cgi?id=215664
+
+ Reviewed by Darin Adler.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKit/AccessibilityReduceMotion.mm: Added.
+ (TEST):
+
2020-08-20 Jonathan Bedard <jbed...@apple.com>
[webkitcorepy] Fix pip package
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (265995 => 265996)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2020-08-21 02:10:23 UTC (rev 265995)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2020-08-21 02:31:40 UTC (rev 265996)
@@ -933,6 +933,7 @@
C15CBB3023F1FF1A00300CC7 /* BacklightLevelNotification.mm in Sources */ = {isa = PBXBuildFile; fileRef = C15CBB2F23F1FF1A00300CC7 /* BacklightLevelNotification.mm */; };
C15CBB3F23FB177A00300CC7 /* PreferenceChanges.mm in Sources */ = {isa = PBXBuildFile; fileRef = C15CBB3E23FB177A00300CC7 /* PreferenceChanges.mm */; };
C1692DCA23D10DAE006E88F7 /* Battery.mm in Sources */ = {isa = PBXBuildFile; fileRef = C1692DC923D10DAE006E88F7 /* Battery.mm */; };
+ C1F4840724EDDB400053ECB8 /* AccessibilityReduceMotion.mm in Sources */ = {isa = PBXBuildFile; fileRef = C1F4840624EDDB400053ECB8 /* AccessibilityReduceMotion.mm */; };
C1F7B7392449083F00124557 /* AGXCompilerService.mm in Sources */ = {isa = PBXBuildFile; fileRef = C1F7B7382449083F00124557 /* AGXCompilerService.mm */; };
C1FF9EDB244644F000839AE4 /* WebFilter.mm in Sources */ = {isa = PBXBuildFile; fileRef = C1FF9EDA244644F000839AE4 /* WebFilter.mm */; };
C20F88A72295B96700D610FA /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C20F88A62295B96700D610FA /* CoreText.framework */; };
@@ -2607,6 +2608,7 @@
C15CBB3E23FB177A00300CC7 /* PreferenceChanges.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PreferenceChanges.mm; sourceTree = "<group>"; };
C1692DC923D10DAE006E88F7 /* Battery.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = Battery.mm; sourceTree = "<group>"; };
C1D8EE212028E8E3008EB141 /* WebProcessTerminate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessTerminate.mm; sourceTree = "<group>"; };
+ C1F4840624EDDB400053ECB8 /* AccessibilityReduceMotion.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AccessibilityReduceMotion.mm; sourceTree = "<group>"; };
C1F7B7382449083F00124557 /* AGXCompilerService.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AGXCompilerService.mm; sourceTree = "<group>"; };
C1FF9EDA244644F000839AE4 /* WebFilter.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebFilter.mm; sourceTree = "<group>"; };
C20F88A62295B96700D610FA /* CoreText.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreText.framework; path = System/Library/Frameworks/CoreText.framework; sourceTree = SDKROOT; };
@@ -3084,6 +3086,7 @@
0F139E741A423A4600F590F5 /* cocoa */ = {
isa = PBXGroup;
children = (
+ C1F4840624EDDB400053ECB8 /* AccessibilityReduceMotion.mm */,
E3F8AB91241AB9CE003E2A7E /* AccessibilityRemoteUIApp.mm */,
C1F7B7382449083F00124557 /* AGXCompilerService.mm */,
C15CBB2F23F1FF1A00300CC7 /* BacklightLevelNotification.mm */,
@@ -4865,9 +4868,9 @@
7C83DED21D0A590C00FEBCF3 /* HashMap.cpp in Sources */,
7C83DED41D0A590C00FEBCF3 /* HashSet.cpp in Sources */,
7C8BFF7123C0107A00C009B3 /* HexNumber.cpp in Sources */,
+ 33976D8324DC479B00812304 /* IndexSparseSet.cpp in Sources */,
7C83DEE01D0A590C00FEBCF3 /* IntegerToStringConversion.cpp in Sources */,
53FCDE6B229EFFB900598ECF /* IsoHeap.cpp in Sources */,
- 33976D8324DC479B00812304 /* IndexSparseSet.cpp in Sources */,
7CEB62AB223609DE0069CBB0 /* IteratorRange.cpp in Sources */,
7A0509411FB9F06400B33FB8 /* JSONValue.cpp in Sources */,
531C1D8E1DF8EF72006E979F /* LEBDecoder.cpp in Sources */,
@@ -4954,6 +4957,7 @@
57C6244E2346BCFA00383FE7 /* _WKWebAuthenticationPanel.mm in Sources */,
7CCE7EE41A411AE600447C4C /* AboutBlankLoad.cpp in Sources */,
7CCE7EB31A411A7E00447C4C /* AcceptsFirstMouse.mm in Sources */,
+ C1F4840724EDDB400053ECB8 /* AccessibilityReduceMotion.mm in Sources */,
E3F8AB92241AB9CE003E2A7E /* AccessibilityRemoteUIApp.mm in Sources */,
2E205BA41F527746005952DD /* AccessibilityTestsIOS.mm in Sources */,
9BD5111C1FE8E11600D2B630 /* AccessingPastedImage.mm in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit/AccessibilityReduceMotion.mm (0 => 265996)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit/AccessibilityReduceMotion.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit/AccessibilityReduceMotion.mm 2020-08-21 02:31:40 UTC (rev 265996)
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+#import "config.h"
+
+#if WK_HAVE_C_SPI
+
+#import "PlatformUtilities.h"
+#import "TestWKWebView.h"
+#import <WebKit/PreferenceObserver.h>
+#import <WebKit/WKProcessPoolPrivate.h>
+#import <WebKit/_WKProcessPoolConfiguration.h>
+
+#import <pal/spi/mac/HIServicesSPI.h>
+
+static bool reduceMotionNotificationReceived = false;
+static bool receivedPreferenceNotification = false;
+
+@interface WKPreferenceObserverForTesting : WKPreferenceObserver
+- (void)preferenceDidChange:(NSString *)domain key:(NSString *)key encodedValue:(NSString *)encodedValue;
+@end
+
+@implementation WKPreferenceObserverForTesting
+- (void)preferenceDidChange:(NSString *)domain key:(NSString *)key encodedValue:(NSString *)encodedValue
+{
+ receivedPreferenceNotification = true;
+ [super preferenceDidChange:domain key:key encodedValue:encodedValue];
+}
+@end
+
+TEST(WebKit, AccessibilityReduceMotion)
+{
+ RetainPtr<NSObject> accessibilityObserver = [[NSDistributedNotificationCenter defaultCenter] addObserverForName:(__bridge id)kAXInterfaceReduceMotionStatusDidChangeNotification object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification *note) {
+ reduceMotionNotificationReceived = true;
+ }];
+
+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ WKRetainPtr<WKContextRef> context = adoptWK(TestWebKitAPI::Util::createContextForInjectedBundleTest("InternalsInjectedBundleTest"));
+ configuration.get().processPool = (WKProcessPool *)context.get();
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get() addToWindow:YES]);
+
+ CFPreferencesSetAppValue(kAXInterfaceReduceMotionKey, kCFBooleanFalse, CFSTR("com.apple.universalaccess"));
+
+ auto observer = adoptNS([[WKPreferenceObserverForTesting alloc] init]);
+
+ [webView synchronouslyLoadTestPageNamed:@"simple"];
+
+ CFPreferencesSetAppValue(kAXInterfaceReduceMotionKey, kCFBooleanTrue, CFSTR("com.apple.universalaccess"));
+
+ TestWebKitAPI::Util::run(&receivedPreferenceNotification);
+
+ auto reduceMotion = [&] {
+ return [webView stringByEvaluatingJavaScript:@"window.internals.userPrefersReducedMotion()"].boolValue;
+ };
+
+ [webView synchronouslyLoadTestPageNamed:@"simple"];
+
+ TestWebKitAPI::Util::run(&reduceMotionNotificationReceived);
+
+ ASSERT_TRUE(reduceMotion());
+
+ CFPreferencesSetAppValue(kAXInterfaceReduceMotionKey, nullptr, CFSTR("com.apple.universalaccess"));
+
+ [[NSNotificationCenter defaultCenter] removeObserver:accessibilityObserver.get()];
+}
+
+#endif