When WKWebView prepares the session state blob, we should be able to filter it.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 9 Jul 2016 00:43:16 +0000 (00:43 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 9 Jul 2016 00:43:16 +0000 (00:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=159410

Add a SPI to WKWebView so that a client can decide how to filter backforward items
when WKWebView perparing session state.

Patch by Yongjun Zhang <yongjun_zhang@apple.com> on 2016-07-08
Reviewed by Brady Eidson.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _sessionStateWithFilter:]): When preparing session state, check each
backforward item against the filter block.
* UIProcess/API/Cocoa/WKWebViewPrivate.h: Add the SPI _sessionStateWithFilter:

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h

index 4ed4105..299a90e 100644 (file)
@@ -1,3 +1,19 @@
+2016-07-08  Yongjun Zhang  <yongjun_zhang@apple.com>
+
+        When WKWebView prepares the session state blob, we should be able to filter it.
+        https://bugs.webkit.org/show_bug.cgi?id=159410
+
+        Add a SPI to WKWebView so that a client can decide how to filter backforward items
+        when WKWebView perparing session state.
+
+        Reviewed by Brady Eidson.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _sessionStateWithFilter:]): When preparing session state, check each
+        backforward item against the filter block.
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h: Add the SPI _sessionStateWithFilter:
+
+
 2016-07-08  Tim Horton  <timothy_horton@apple.com>
 
         Mail messages don't start loading until scrolling completes
index 13796a6..32307c9 100644 (file)
@@ -3373,6 +3373,18 @@ static int32_t activeOrientation(WKWebView *webView)
     return adoptNS([[_WKSessionState alloc] _initWithSessionState:_page->sessionState()]).autorelease();
 }
 
+- (_WKSessionState *)_sessionStateWithFilter:(BOOL (^)(WKBackForwardListItem *item))filter
+{
+    WebKit::SessionState sessionState = _page->sessionState([filter](WebKit::WebBackForwardListItem& item) {
+        if (!filter)
+            return true;
+
+        return (bool)filter(wrapper(item));
+    });
+
+    return adoptNS([[_WKSessionState alloc] _initWithSessionState:sessionState]).autorelease();
+}
+
 - (void)_restoreFromSessionStateData:(NSData *)sessionStateData
 {
     // FIXME: This should not use the legacy session state decoder.
index 65120c5..18c303d 100644 (file)
@@ -100,6 +100,7 @@ typedef NS_ENUM(NSInteger, _WKImmediateActionType) {
 
 @property (nonatomic, readonly) _WKSessionState *_sessionState;
 - (WKNavigation *)_restoreSessionState:(_WKSessionState *)sessionState andNavigate:(BOOL)navigate;
+- (_WKSessionState *)_sessionStateWithFilter:(BOOL (^)(WKBackForwardListItem *item))filter;
 
 @property (nonatomic, setter=_setAllowsRemoteInspection:) BOOL _allowsRemoteInspection;
 @property (nonatomic, copy, setter=_setRemoteInspectionNameOverride:) NSString *_remoteInspectionNameOverride WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));