AX: soft link libAccessibility.dylb
authorn_wang@apple.com <n_wang@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Apr 2018 21:27:01 +0000 (21:27 +0000)
committern_wang@apple.com <n_wang@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Apr 2018 21:27:01 +0000 (21:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=184919

Reviewed by Chris Fleizach.

Source/WebKit:

Make sure we soft link the library so that it won't crash
if it's missing in the system.

* Configurations/WebKit.xcconfig:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _initializeWithConfiguration:]):
(-[WKWebView _updateAccessibilityEventsEnabled]):

Source/WTF:

* wtf/cocoa/SoftLinking.h:

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

Source/WTF/ChangeLog
Source/WTF/wtf/cocoa/SoftLinking.h
Source/WebKit/ChangeLog
Source/WebKit/Configurations/WebKit.xcconfig
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm

index 4720655..7bbdb51 100644 (file)
@@ -1,3 +1,12 @@
+2018-04-24  Nan Wang  <n_wang@apple.com>
+
+        AX: soft link libAccessibility.dylb
+        https://bugs.webkit.org/show_bug.cgi?id=184919
+
+        Reviewed by Chris Fleizach.
+
+        * wtf/cocoa/SoftLinking.h:
+
 2018-04-23  Zalan Bujtas  <zalan@apple.com>
 
         [LayoutFormattingContext] Initial commit.
index f228576..66452b3 100644 (file)
         return dylib; \
     }
 
+#define SOFT_LINK_LIBRARY_OPTIONAL(lib) \
+    static void* lib##Library() \
+    { \
+        static void* dylib = dlopen("/usr/lib/" #lib ".dylib", RTLD_NOW); \
+        return dylib; \
+    }
+
 #define SOFT_LINK_FRAMEWORK(framework) \
     static void* framework##Library() \
     { \
index e45591e..0d092c7 100644 (file)
@@ -1,3 +1,18 @@
+2018-04-24  Nan Wang  <n_wang@apple.com>
+
+        AX: soft link libAccessibility.dylb
+        https://bugs.webkit.org/show_bug.cgi?id=184919
+
+        Reviewed by Chris Fleizach.
+
+        Make sure we soft link the library so that it won't crash
+        if it's missing in the system.
+
+        * Configurations/WebKit.xcconfig:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _initializeWithConfiguration:]):
+        (-[WKWebView _updateAccessibilityEventsEnabled]):
+
 2018-04-24  John Wilander  <wilander@apple.com>
 
         From-Origin: Support for 'same' and 'same-site' response header, nested frame origin check
index 045889c..0cbfbab 100644 (file)
@@ -39,14 +39,6 @@ DYLIB_INSTALL_NAME_BASE_YES = $(DYLIB_INSTALL_NAME_BASE);
 
 LIBRARY_SEARCH_PATHS = $(inherited) "$(LIBWEBRTC_LIBRARY_DIR)";
 
-WK_ACCESSIBILITY_LDFLAGS = $(WK_ACCESSIBILITY_LDFLAGS_$(WK_PLATFORM_NAME));
-WK_ACCESSIBILITY_LDFLAGS_iphoneos = -lAccessibility;
-WK_ACCESSIBILITY_LDFLAGS_iphonesimulator = $(WK_ACCESSIBILITY_LDFLAGS_iphoneos);
-WK_ACCESSIBILITY_LDFLAGS_watchos = $(WK_ACCESSIBILITY_LDFLAGS_iphoneos);
-WK_ACCESSIBILITY_LDFLAGS_appletvos = $(WK_ACCESSIBILITY_LDFLAGS_iphoneos);
-WK_ACCESSIBILITY_LDFLAGS_macosx = $(WK_ACCESSIBILITY_LDFLAGS$(WK_MACOS_1014));
-WK_ACCESSIBILITY_LDFLAGS_MACOS_SINCE_1014 = -lAccessibility;
-
 WK_APPKIT_LDFLAGS = $(WK_APPKIT_LDFLAGS_$(WK_PLATFORM_NAME));
 WK_APPKIT_LDFLAGS_macosx = -framework AppKit;
 
@@ -112,7 +104,7 @@ WK_SAFE_BROWSING_LDFLAGS_MACOS_SINCE_1013 = -weak_framework SafariSafeBrowsing;
 WK_UIKIT_LDFLAGS = $(WK_UIKIT_LDFLAGS_$(WK_COCOA_TOUCH));
 WK_UIKIT_LDFLAGS_cocoatouch = -framework UIKit;
 
-FRAMEWORK_AND_LIBRARY_LDFLAGS = -lobjc -framework CFNetwork -framework CoreAudio -framework CoreFoundation -framework CoreGraphics -framework CoreText -framework Foundation -framework ImageIO -framework IOKit -framework WebKitLegacy $(WK_ACCESSIBILITY_LDFLAGS) $(WK_APPKIT_LDFLAGS) $(WK_ASSERTION_SERVICES_LDFLAGS) $(WK_CARBON_LDFLAGS) $(WK_CORE_PDF_LDFLAGS) $(WK_CORE_PREDICTION_LDFLAGS) $(WK_CORE_SERVICES_LDFLAGS) $(WK_GRAPHICS_SERVICES_LDFLAGS) $(WK_IOSURFACE_LDFLAGS) $(WK_LIBWEBRTC_LDFLAGS) $(WK_MOBILE_CORE_SERVICES_LDFLAGS) $(WK_MOBILE_GESTALT_LDFLAGS) $(WK_OPENGL_LDFLAGS) $(WK_PDFKIT_LDFLAGS) $(WK_SAFE_BROWSING_LDFLAGS) $(WK_UIKIT_LDFLAGS);
+FRAMEWORK_AND_LIBRARY_LDFLAGS = -lobjc -framework CFNetwork -framework CoreAudio -framework CoreFoundation -framework CoreGraphics -framework CoreText -framework Foundation -framework ImageIO -framework IOKit -framework WebKitLegacy $(WK_APPKIT_LDFLAGS) $(WK_ASSERTION_SERVICES_LDFLAGS) $(WK_CARBON_LDFLAGS) $(WK_CORE_PDF_LDFLAGS) $(WK_CORE_PREDICTION_LDFLAGS) $(WK_CORE_SERVICES_LDFLAGS) $(WK_GRAPHICS_SERVICES_LDFLAGS) $(WK_IOSURFACE_LDFLAGS) $(WK_LIBWEBRTC_LDFLAGS) $(WK_MOBILE_CORE_SERVICES_LDFLAGS) $(WK_MOBILE_GESTALT_LDFLAGS) $(WK_OPENGL_LDFLAGS) $(WK_PDFKIT_LDFLAGS) $(WK_SAFE_BROWSING_LDFLAGS) $(WK_UIKIT_LDFLAGS);
 
 // Prevent C++ standard library operator new, delete and their related exception types from being exported as weak symbols.
 UNEXPORTED_SYMBOL_LDFLAGS = -Wl,-unexported_symbol -Wl,__ZTISt9bad_alloc -Wl,-unexported_symbol -Wl,__ZTISt9exception -Wl,-unexported_symbol -Wl,__ZTSSt9bad_alloc -Wl,-unexported_symbol -Wl,__ZTSSt9exception -Wl,-unexported_symbol -Wl,__ZdlPvS_ -Wl,-unexported_symbol -Wl,__ZnwmPv -Wl,-unexported_symbol -Wl,__Znwm -Wl,-unexported_symbol, -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEC2EOS4_ -Wl,-unexported_symbol, -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEC1EOS4_ -Wl,-unexported_symbol, -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEaSEDn -Wl,-unexported_symbol, -Wl,__ZNKSt3__18functionIFvN7WebCore12PolicyActionEEEclES2_ -Wl,-unexported_symbol, -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEE4swapERS4_ -Wl,-unexported_symbol, -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEC1ERKS4_ -Wl,-unexported_symbol, -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEC2ERKS4_ -Wl,-unexported_symbol, -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEED1Ev -Wl,-unexported_symbol, -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEED2Ev -Wl,-unexported_symbol, -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEaSERKS4_ -Wl,-unexported_symbol, -Wl,__ZTVNSt3__117bad_function_callE;
index de12e5a..c51d9da 100644 (file)
@@ -207,14 +207,10 @@ static const uint32_t firstSDKVersionWithLinkPreviewEnabledByDefault = 0xA0000;
 #endif // PLATFORM(MAC)
 
 #if ENABLE(ACCESSIBILITY_EVENTS)
-#if __has_include(<AccessibilitySupport.h>)
-#include <AccessibilitySupport.h>
-#else
-extern "C" {
-CFStringRef kAXSWebAccessibilityEventsEnabledNotification;
-Boolean _AXSWebAccessibilityEventsEnabled();
-}
-#endif
+#include <wtf/SoftLinking.h>
+SOFT_LINK_LIBRARY_OPTIONAL(libAccessibility)
+SOFT_LINK_MAY_FAIL(libAccessibility, _AXSWebAccessibilityEventsEnabled, Boolean, (), ())
+SOFT_LINK_CONSTANT_MAY_FAIL(libAccessibility, kAXSWebAccessibilityEventsEnabledNotification, CFStringRef)
 #endif
 
 static HashMap<WebKit::WebPageProxy*, WKWebView *>& pageToViewMap()
@@ -700,7 +696,8 @@ static void validate(WKWebViewConfiguration *configuration)
 #endif
 
 #if ENABLE(ACCESSIBILITY_EVENTS)
-    CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), (__bridge const void *)(self), accessibilityEventsEnabledChangedCallback, kAXSWebAccessibilityEventsEnabledNotification, 0, CFNotificationSuspensionBehaviorDeliverImmediately);
+    if (canLoadkAXSWebAccessibilityEventsEnabledNotification())
+        CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), (__bridge const void *)(self), accessibilityEventsEnabledChangedCallback, getkAXSWebAccessibilityEventsEnabledNotification(), 0, CFNotificationSuspensionBehaviorDeliverImmediately);
     [self _updateAccessibilityEventsEnabled];
 #endif
 
@@ -3073,6 +3070,8 @@ static void accessibilityEventsEnabledChangedCallback(CFNotificationCenterRef, v
 
 - (void)_updateAccessibilityEventsEnabled
 {
+    if (!canLoad_AXSWebAccessibilityEventsEnabled())
+        return;
     _page->updateAccessibilityEventsEnabled(_AXSWebAccessibilityEventsEnabled());
 }
 #endif