Bug 146398

Summary: [WK2][iOS] Add WKWebView private API to save a back/forward snapshot
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: WebKit2Assignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: barraclough, commit-queue, mitz, thorton
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

Description Chris Dumez 2015-06-28 13:02:34 PDT
Add WKWebView private API to save a back/forward snapshot so that the client can make sure a back/forward snapshot is available even when swapping WKWebView upon navigation.
Comment 1 Chris Dumez 2015-06-28 13:02:47 PDT
rdar://problem/21584231
Comment 2 mitz 2015-06-28 13:08:08 PDT
Is this something the existing session state API can do?
Comment 3 Chris Dumez 2015-06-28 13:09:19 PDT
(In reply to comment #2)
> Is this something the existing session state API can do?

I will check. I was trying to match the way we currently do this on Mac:

in WKViewPrivate.h
- (void)saveBackForwardSnapshotForItem:(WKBackForwardListItemRef)item;
Comment 4 Chris Dumez 2015-06-28 13:22:44 PDT
(In reply to comment #2)
> Is this something the existing session state API can do?

Please see comment on radar.
Comment 5 Chris Dumez 2015-06-28 13:23:13 PDT
Created attachment 255729 [details]
Patch
Comment 6 mitz 2015-06-28 13:26:28 PDT
Comment on attachment 255729 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=255729&action=review

> Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h:212
> +- (void)_saveBackForwardSnapshotForItem:(WKBackForwardListItem *)item WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);

Can this be used on an item that isn’t the current item? What does it do in that case?
Comment 7 Chris Dumez 2015-06-28 13:30:44 PDT
Comment on attachment 255729 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=255729&action=review

>> Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h:212
>> +- (void)_saveBackForwardSnapshotForItem:(WKBackForwardListItem *)item WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
> 
> Can this be used on an item that isn’t the current item? What does it do in that case?

Yes, it can and it is the intended use. On Mac, we have both saveBackForwardSnapshotForItem(item) and saveBackForwardSnapshotForCurrentItem().

What it does in this case is take a snapshot of the current view and save it on the WKBackForwardListItem that is given. The WKBackForwardListItem being given in this case would be from another WKWebView.
Comment 8 WebKit Commit Bot 2015-06-29 12:09:15 PDT
Comment on attachment 255729 [details]
Patch

Clearing flags on attachment: 255729

Committed r186077: <http://trac.webkit.org/changeset/186077>
Comment 9 WebKit Commit Bot 2015-06-29 12:09:19 PDT
All reviewed patches have been landed.  Closing bug.