Title: [166241] trunk
Revision
166241
Author
ander...@apple.com
Date
2014-03-25 12:17:54 -0700 (Tue, 25 Mar 2014)

Log Message

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.

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:]):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (166240 => 166241)


--- trunk/Source/WebKit2/ChangeLog	2014-03-25 18:00:30 UTC (rev 166240)
+++ trunk/Source/WebKit2/ChangeLog	2014-03-25 19:17:54 UTC (rev 166241)
@@ -1,3 +1,19 @@
+2014-03-25  Anders Carlsson  <ander...@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  <mrobin...@igalia.com>
 
         [GTK] Remove the autotools build

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.h (166240 => 166241)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.h	2014-03-25 18:00:30 UTC (rev 166240)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.h	2014-03-25 19:17:54 UTC (rev 166241)
@@ -89,8 +89,6 @@
  */
 - (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 @@
 @property (readonly) BOOL canGoBack;
 @property (readonly) BOOL canGoForward;
 
-- (void)goBack;
-- (void)goForward;
+- (WKNavigation *)goBack;
+- (WKNavigation *)goForward;
 
 @property (nonatomic) BOOL allowsBackForwardNavigationGestures;
 
@@ -133,4 +131,13 @@
 
 @end
 
+@interface WKWebView (WKIBActions) <NSUserInterfaceValidations>
+
+- (IBAction)goBack:(id)sender;
+- (IBAction)goForward:(id)sender;
+
+- (IBAction)stopLoading:(id)sender;
+
+@end
+
 #endif

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (166240 => 166241)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2014-03-25 18:00:30 UTC (rev 166240)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2014-03-25 19:17:54 UTC (rev 166241)
@@ -256,11 +256,6 @@
     return nil;
 }
 
-- (IBAction)stopLoading:(id)sender
-{
-    _page->stopLoading();
-}
-
 - (NSString *)title
 {
     return _page->pageLoadState().title();
@@ -298,16 +293,20 @@
     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 @@
 
 @end
 
+@implementation WKWebView (WKIBActions)
+
+- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item
+{
+    SEL 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

Modified: trunk/Tools/ChangeLog (166240 => 166241)


--- trunk/Tools/ChangeLog	2014-03-25 18:00:30 UTC (rev 166240)
+++ trunk/Tools/ChangeLog	2014-03-25 19:17:54 UTC (rev 166241)
@@ -1,3 +1,13 @@
+2014-03-25  Anders Carlsson  <ander...@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  <mrobin...@igalia.com>
 
         [GTK] Remove the autotools build

Modified: trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m (166240 => 166241)


--- trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m	2014-03-25 18:00:30 UTC (rev 166240)
+++ trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m	2014-03-25 19:17:54 UTC (rev 166241)
@@ -194,14 +194,11 @@
 
 - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item
 {
-    SEL action = "" action];
+    SEL action = ""
 
-    if (action == @selector(goBack:))
-        return _webView && [_webView canGoBack];
-    
-    if (action == @selector(goForward:))
-        return _webView && [_webView canGoForward];
-    
+    if (action == @selector(goBack:) || action == @selector(goForward:))
+        return [_webView validateUserInterfaceItem:item];
+
     return YES;
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to