Skip to content

Commit

Permalink
Fix the HAVE(ACCESSIBILITY_ANIMATED_IMAGES) build for some SDK versions
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=246989

Reviewed by Tim Horton.

Use `SOFT_LINK_OPTIONAL` and `SOFT_LINK_CONSTANT`, respectively, to pull in the new SPI on versions
of the SDK where `HAVE(ACCESSIBILITY_ANIMATED_IMAGES)` is enabled, but these SPI don't yet exist.

* Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(SOFT_LINK_CONSTANT):
(WebKit::accessibilityPreferences):
(WebKit::WebProcessPool::registerNotificationObservers):

Canonical link: https://commits.webkit.org/255941@main
  • Loading branch information
whsieh committed Oct 25, 2022
1 parent 9b26f54 commit e573901
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm
Expand Up @@ -183,6 +183,12 @@ static bool canaryInBaseState()
SOFT_LINK(BackBoardServices, BKSDisplayBrightnessGetCurrent, float, (), ());
#endif

#if HAVE(ACCESSIBILITY_ANIMATED_IMAGES)
SOFT_LINK_LIBRARY_OPTIONAL(libAccessibility)
SOFT_LINK_OPTIONAL(libAccessibility, _AXSReduceMotionAutoplayAnimatedImagesEnabled, Boolean, (), ());
SOFT_LINK_CONSTANT(libAccessibility, kAXSReduceMotionAutoplayAnimatedImagesChangedNotification, CFStringRef)
#endif

#define WEBPROCESSPOOL_RELEASE_LOG(channel, fmt, ...) RELEASE_LOG(channel, "%p - WebProcessPool::" fmt, this, ##__VA_ARGS__)

@interface WKProcessPoolWeakObserver : NSObject {
Expand Down Expand Up @@ -262,7 +268,8 @@ static AccessibilityPreferences accessibilityPreferences()
#endif
preferences.enhanceTextLegibilityOverall = _AXSEnhanceTextLegibilityEnabled();
#if HAVE(ACCESSIBILITY_ANIMATED_IMAGES)
preferences.imageAnimationEnabled = _AXSReduceMotionAutoplayAnimatedImagesEnabled();
if (auto* functionPointer = _AXSReduceMotionAutoplayAnimatedImagesEnabledPtr())
preferences.imageAnimationEnabled = functionPointer();
#endif
return preferences;
}
Expand Down Expand Up @@ -822,7 +829,8 @@ static bool determineIfWeShouldCrashWhenCreatingWebProcess()
addCFNotificationObserver(accessibilityPreferencesChangedCallback, kAXSInvertColorsEnabledNotification);
#endif
#if HAVE(ACCESSIBILITY_ANIMATED_IMAGES)
addCFNotificationObserver(accessibilityPreferencesChangedCallback, kAXSReduceMotionAutoplayAnimatedImagesChangedNotification);
if (auto notificationName = getkAXSReduceMotionAutoplayAnimatedImagesChangedNotification())
addCFNotificationObserver(accessibilityPreferencesChangedCallback, notificationName);
#endif
#if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
addCFNotificationObserver(mediaAccessibilityPreferencesChangedCallback, kMAXCaptionAppearanceSettingsChangedNotification);
Expand Down

0 comments on commit e573901

Please sign in to comment.