WKPreferences doesn’t expose editable link behavior
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Dec 2017 03:23:18 +0000 (03:23 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Dec 2017 03:23:18 +0000 (03:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=181111

Reviewed by Tim Horton.

* UIProcess/API/Cocoa/WKPreferences.mm:
(toAPI): Added. Converts WebCore::EditableLinkBehavior to _WKEditableLinkBehavior.
(toEditableLinkBehavior): Added. Converts the other way.
(-[WKPreferences _editableLinkBehavior]): Added this getter.
(-[WKPreferences _setEditableLinkBehavior:]): Ditto.
* UIProcess/API/Cocoa/WKPreferencesPrivate.h: Declared new property.

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm
Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h

index bebb9ea..317e4e7 100644 (file)
@@ -1,3 +1,17 @@
+2017-12-21  Dan Bernstein  <mitz@apple.com>
+
+        WKPreferences doesn’t expose editable link behavior
+        https://bugs.webkit.org/show_bug.cgi?id=181111
+
+        Reviewed by Tim Horton.
+
+        * UIProcess/API/Cocoa/WKPreferences.mm:
+        (toAPI): Added. Converts WebCore::EditableLinkBehavior to _WKEditableLinkBehavior.
+        (toEditableLinkBehavior): Added. Converts the other way.
+        (-[WKPreferences _editableLinkBehavior]): Added this getter.
+        (-[WKPreferences _setEditableLinkBehavior:]): Ditto.
+        * UIProcess/API/Cocoa/WKPreferencesPrivate.h: Declared new property.
+
 2017-12-21  Andy Estes  <aestes@apple.com>
 
         Address additional review feedback after r226182.
index f215ad6..186a171 100644 (file)
@@ -34,6 +34,7 @@
 #import "_WKExperimentalFeature.h"
 #import "_WKExperimentalFeatureInternal.h"
 #import <WebCore/SecurityOrigin.h>
+#import <WebCore/Settings.h>
 #import <wtf/RetainPtr.h>
 
 @implementation WKPreferences
@@ -677,6 +678,54 @@ static _WKStorageBlockingPolicy toAPI(WebCore::SecurityOrigin::StorageBlockingPo
     _preferences->setShouldAllowUserInstalledFonts(_shouldAllowUserInstalledFonts);
 }
 
+static _WKEditableLinkBehavior toAPI(WebCore::EditableLinkBehavior behavior)
+{
+    switch (behavior) {
+    case WebCore::EditableLinkDefaultBehavior:
+        return _WKEditableLinkBehaviorDefault;
+    case WebCore::EditableLinkAlwaysLive:
+        return _WKEditableLinkBehaviorAlwaysLive;
+    case WebCore::EditableLinkOnlyLiveWithShiftKey:
+        return _WKEditableLinkBehaviorOnlyLiveWithShiftKey;
+    case WebCore::EditableLinkLiveWhenNotFocused:
+        return _WKEditableLinkBehaviorLiveWhenNotFocused;
+    case WebCore::EditableLinkNeverLive:
+        return _WKEditableLinkBehaviorNeverLive;
+    }
+    
+    ASSERT_NOT_REACHED();
+    return _WKEditableLinkBehaviorNeverLive;
+}
+
+static WebCore::EditableLinkBehavior toEditableLinkBehavior(_WKEditableLinkBehavior wkBehavior)
+{
+    switch (wkBehavior) {
+    case _WKEditableLinkBehaviorDefault:
+        return WebCore::EditableLinkDefaultBehavior;
+    case _WKEditableLinkBehaviorAlwaysLive:
+        return WebCore::EditableLinkAlwaysLive;
+    case _WKEditableLinkBehaviorOnlyLiveWithShiftKey:
+        return WebCore::EditableLinkOnlyLiveWithShiftKey;
+    case _WKEditableLinkBehaviorLiveWhenNotFocused:
+        return WebCore::EditableLinkLiveWhenNotFocused;
+    case _WKEditableLinkBehaviorNeverLive:
+        return WebCore::EditableLinkNeverLive;
+    }
+    
+    ASSERT_NOT_REACHED();
+    return WebCore::EditableLinkNeverLive;
+}
+
+- (_WKEditableLinkBehavior)_editableLinkBehavior
+{
+    return toAPI(static_cast<WebCore::EditableLinkBehavior>(_preferences->editableLinkBehavior()));
+}
+
+- (void)_setEditableLinkBehavior:(_WKEditableLinkBehavior)editableLinkBehavior
+{
+    _preferences->setEditableLinkBehavior(toEditableLinkBehavior(editableLinkBehavior));
+}
+
 #if PLATFORM(MAC)
 - (void)_setJavaEnabledForLocalFiles:(BOOL)enabled
 {
index c3c0dba..1fe8ff3 100644 (file)
@@ -46,6 +46,14 @@ typedef NS_OPTIONS(NSUInteger, _WKJavaScriptRuntimeFlags) {
     _WKJavaScriptRuntimeFlagsAllEnabled = 0
 } WK_API_AVAILABLE(macosx(10.11), ios(9.0));
 
+typedef NS_ENUM(NSInteger, _WKEditableLinkBehavior) {
+    _WKEditableLinkBehaviorDefault,
+    _WKEditableLinkBehaviorAlwaysLive,
+    _WKEditableLinkBehaviorOnlyLiveWithShiftKey,
+    _WKEditableLinkBehaviorLiveWhenNotFocused,
+    _WKEditableLinkBehaviorNeverLive,
+} WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+
 @class _WKExperimentalFeature;
 
 @interface WKPreferences () <NSCopying>
@@ -118,6 +126,8 @@ typedef NS_OPTIONS(NSUInteger, _WKJavaScriptRuntimeFlags) {
 
 @property (nonatomic, setter=_setShouldAllowUserInstalledFonts:) BOOL _shouldAllowUserInstalledFonts WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 
+@property (nonatomic, setter=_setEditableLinkBehavior:) _WKEditableLinkBehavior _editableLinkBehavior WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+
 + (NSArray<_WKExperimentalFeature *> *)_experimentalFeatures WK_API_AVAILABLE(macosx(10.12), ios(10.0));
 - (BOOL)_isEnabledForFeature:(_WKExperimentalFeature *)feature WK_API_AVAILABLE(macosx(10.12), ios(10.0));
 - (void)_setEnabled:(BOOL)value forFeature:(_WKExperimentalFeature *)feature WK_API_AVAILABLE(macosx(10.12), ios(10.0));