Digital crown should scroll safe browsing warning on watchOS
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Feb 2019 18:24:42 +0000 (18:24 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Feb 2019 18:24:42 +0000 (18:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=194363
<rdar://problem/47348124>

Reviewed by Wenson Hsieh.

* UIProcess/Cocoa/WKSafeBrowsingWarning.h:
* UIProcess/Cocoa/WKSafeBrowsingWarning.mm:
(-[WKSafeBrowsingWarning initWithFrame:safeBrowsingWarning:completionHandler:]):
(-[WKSafeBrowsingWarning addContent]):

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/Cocoa/WKSafeBrowsingWarning.h
Source/WebKit/UIProcess/Cocoa/WKSafeBrowsingWarning.mm

index 4fd03fe..1ba08f0 100644 (file)
@@ -1,5 +1,18 @@
 2019-02-07  Alex Christensen  <achristensen@webkit.org>
 
+        Digital crown should scroll safe browsing warning on watchOS
+        https://bugs.webkit.org/show_bug.cgi?id=194363
+        <rdar://problem/47348124>
+
+        Reviewed by Wenson Hsieh.
+
+        * UIProcess/Cocoa/WKSafeBrowsingWarning.h:
+        * UIProcess/Cocoa/WKSafeBrowsingWarning.mm:
+        (-[WKSafeBrowsingWarning initWithFrame:safeBrowsingWarning:completionHandler:]):
+        (-[WKSafeBrowsingWarning addContent]):
+
+2019-02-07  Alex Christensen  <achristensen@webkit.org>
+
         Shrink and hyphenate safe browsing warning text on watchOS
         https://bugs.webkit.org/show_bug.cgi?id=194361
         <rdar://problem/47466549>
index 88a2be0..f6114a4 100644 (file)
@@ -57,6 +57,9 @@ using RectType = CGRect;
     RefPtr<const WebKit::SafeBrowsingWarning> _warning;
     WeakObjCPtr<WKSafeBrowsingTextView> _details;
     WeakObjCPtr<ViewType> _box;
+#if PLATFORM(WATCHOS)
+    WeakObjCPtr<UIResponder> _previousFirstResponder;
+#endif
 }
 
 - (instancetype)initWithFrame:(RectType)frame safeBrowsingWarning:(const WebKit::SafeBrowsingWarning&)warning completionHandler:(CompletionHandler<void(Variant<WebKit::ContinueUnsafeLoad, URL>&&)>&&)completionHandler;
index 0cfdc9a..9c10958 100644 (file)
 #import <wtf/BlockPtr.h>
 #import <wtf/Language.h>
 
+#if PLATFORM(WATCHOS)
+#import "UIKitSPI.h"
+#import <PepperUICore/UIScrollView+PUICAdditionsPrivate.h>
+#endif
+
 constexpr CGFloat exclamationPointSize = 30;
 constexpr CGFloat boxCornerRadius = 6;
 #if HAVE(SAFE_BROWSING)
@@ -274,12 +279,22 @@ static void setBackground(ViewType *view, ColorType *color)
         completionHandler(WebKit::ContinueUnsafeLoad::Yes);
         return nil;
     }
-    _completionHandler = WTFMove(completionHandler);
+    _completionHandler = [weakSelf = WeakObjCPtr<WKSafeBrowsingWarning>(self), completionHandler = WTFMove(completionHandler)] (Variant<WebKit::ContinueUnsafeLoad, URL>&& result) mutable {
+#if PLATFORM(WATCHOS)
+        if (auto strongSelf = weakSelf.get())
+            [strongSelf.get()->_previousFirstResponder becomeFirstResponder];
+#endif
+        completionHandler(WTFMove(result));
+    };
     _warning = makeRef(warning);
     setBackground(self, colorForItem(WarningItem::Background, self));
 #if PLATFORM(MAC)
     [self addContent];
 #endif
+
+#if PLATFORM(WATCHOS)
+    self.crownInputScrollDirection = PUICCrownInputScrollDirectionVertical;
+#endif
     return self;
 }
 
@@ -368,6 +383,11 @@ static void setBackground(ViewType *view, ColorType *color)
     [self updateContentSize];
 #endif
 #endif
+    
+#if PLATFORM(WATCHOS)
+    self->_previousFirstResponder = [self firstResponder];
+    [self becomeFirstResponder];
+#endif
 }
 
 - (void)showDetailsClicked