Add goBack: and goForward: IBActions and move stopLoading: to a new WKIBActions categ...
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Mar 2014 19:17:54 +0000 (19:17 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Mar 2014 19:17:54 +0000 (19:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=130732

Reviewed by Tim Horton.

Source/WebKit2:

* UIProcess/API/Cocoa/WKWebView.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView goBack]):
(-[WKWebView goForward]):
(-[WKWebView validateUserInterfaceItem:]):
(-[WKWebView goBack:]):
(-[WKWebView goForward:]):
(-[WKWebView stopLoading:]):

Tools:

* MiniBrowser/mac/WK2BrowserWindowController.m:
(-[WK2BrowserWindowController validateUserInterfaceItem:]):

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.h
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Tools/ChangeLog
Tools/MiniBrowser/mac/WK2BrowserWindowController.m

index 40ebb2177e5209bb3567c32580958233d320068d..80c3ce460dffbde7e35c68b5950cd031b4c84019 100644 (file)
@@ -1,3 +1,19 @@
+2014-03-25  Anders Carlsson  <andersca@apple.com>
+
+        Add goBack: and goForward: IBActions and move stopLoading: to a new WKIBActions category on WKWebView
+        https://bugs.webkit.org/show_bug.cgi?id=130732
+
+        Reviewed by Tim Horton.
+
+        * UIProcess/API/Cocoa/WKWebView.h:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView goBack]):
+        (-[WKWebView goForward]):
+        (-[WKWebView validateUserInterfaceItem:]):
+        (-[WKWebView goBack:]):
+        (-[WKWebView goForward:]):
+        (-[WKWebView stopLoading:]):
+
 2014-03-25  Martin Robinson  <mrobinson@igalia.com>
 
         [GTK] Remove the autotools build
index c5a361f8bb389524c4f1ac979d8513f1b31095b2..68dc6af82f951260a51ab30842ad998b6b8b1b66 100644 (file)
@@ -89,8 +89,6 @@ WK_API_CLASS
  */
 - (WKNavigation *)goToBackForwardListItem:(WKBackForwardListItem *)item;
 
-- (IBAction)stopLoading:(id)sender;
-
 @property (nonatomic, readonly) NSString *title;
 
 /*! @abstract The active URL. @link WKWebView @/link is KVO-compliant for this property.
@@ -117,8 +115,8 @@ WK_API_CLASS
 @property (readonly) BOOL canGoBack;
 @property (readonly) BOOL canGoForward;
 
-- (void)goBack;
-- (void)goForward;
+- (WKNavigation *)goBack;
+- (WKNavigation *)goForward;
 
 @property (nonatomic) BOOL allowsBackForwardNavigationGestures;
 
@@ -133,4 +131,13 @@ WK_API_CLASS
 
 @end
 
+@interface WKWebView (WKIBActions) <NSUserInterfaceValidations>
+
+- (IBAction)goBack:(id)sender;
+- (IBAction)goForward:(id)sender;
+
+- (IBAction)stopLoading:(id)sender;
+
+@end
+
 #endif
index fe6f11a5e6039b66da792c84d0c4223e385fd557..28e898af3f2eff9b7dab7cde7a1a39ea84ea5f16 100644 (file)
     return nil;
 }
 
-- (IBAction)stopLoading:(id)sender
-{
-    _page->stopLoading();
-}
-
 - (NSString *)title
 {
     return _page->pageLoadState().title();
     return !!_page->backForwardList().forwardItem();
 }
 
-// FIXME: This should return a WKNavigation object.
-- (void)goBack
+- (WKNavigation *)goBack
 {
     _page->goBack();
+
+    // FIXME: Return a navigation object.
+    return nil;
 }
 
-// FIXME: This should return a WKNavigation object.
-- (void)goForward
+- (WKNavigation *)goForward
 {
     _page->goForward();
+
+    // FIXME: Return a navigation object.
+    return nil;
 }
 
 #pragma mark iOS-specific methods
@@ -1177,4 +1176,41 @@ static inline WebCore::LayoutMilestones layoutMilestones(_WKRenderingProgressEve
 
 @end
 
+@implementation WKWebView (WKIBActions)
+
+- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item
+{
+    SEL action = item.action;
+
+    if (action == @selector(goBack:))
+        return !!_page->backForwardList().backItem();
+
+    if (action == @selector(goForward:))
+        return !!_page->backForwardList().forwardItem();
+
+    if (action == @selector(stopLoading:)) {
+        // FIXME: Return no if we're stopped.
+        return YES;
+    }
+
+    return NO;
+}
+
+- (IBAction)goBack:(id)sender
+{
+    [self goBack];
+}
+
+- (IBAction)goForward:(id)sender
+{
+    [self goForward];
+}
+
+- (IBAction)stopLoading:(id)sender
+{
+    _page->stopLoading();
+}
+
+@end
+
 #endif // WK_API_ENABLED
index 49eff2753b2358d5c245ab9c23e6a6a7b61e3757..7d90265cf232b6c67cd3297591b09ba8de6fc6c3 100644 (file)
@@ -1,3 +1,13 @@
+2014-03-25  Anders Carlsson  <andersca@apple.com>
+
+        Add goBack: and goForward: IBActions and move stopLoading: to a new WKIBActions category on WKWebView
+        https://bugs.webkit.org/show_bug.cgi?id=130732
+
+        Reviewed by Tim Horton.
+
+        * MiniBrowser/mac/WK2BrowserWindowController.m:
+        (-[WK2BrowserWindowController validateUserInterfaceItem:]):
+
 2014-03-25  Martin Robinson  <mrobinson@igalia.com>
 
         [GTK] Remove the autotools build
index 3e8cbc3ee5de59541c9e378c9cdc3c657357ff44..3ce4716eb3bea4bcc83c2da43cdce85a89a939bb 100644 (file)
@@ -194,14 +194,11 @@ static NSString * const WebKit2UseRemoteLayerTreeDrawingAreaKey = @"WebKit2UseRe
 
 - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item
 {
-    SEL action = [item action];
+    SEL action = item.action;
+
+    if (action == @selector(goBack:) || action == @selector(goForward:))
+        return [_webView validateUserInterfaceItem:item];
 
-    if (action == @selector(goBack:))
-        return _webView && [_webView canGoBack];
-    
-    if (action == @selector(goForward:))
-        return _webView && [_webView canGoForward];
-    
     return YES;
 }