<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[211160] trunk/Source/WebKit2</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/211160">211160</a></dd>
<dt>Author</dt> <dd>aestes@apple.com</dd>
<dt>Date</dt> <dd>2017-01-25 12:48:41 -0800 (Wed, 25 Jan 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>[iOS] Move WKPDFView's password view to WKWebView
https://bugs.webkit.org/show_bug.cgi?id=167401

Reviewed by Tim Horton.

<a href="http://trac.webkit.org/projects/webkit/changeset/210943">r210943</a> moved the PDF password view into the new class WKPasswordView but left it as a
subview of the WKPDFView. To show the password view for Web content, my original plan was to
teach WKContentView to host its own password view, but this turned out not to work. Since
QuickLook needs to unlock a document before determining its preview's MIME type, we have to
ask for a password during provisional navigation, but if the still-committed document is a
PDF then the WKContentView will not be in the view hierarchy.

To ensure password view visibility, this patch moves the ownership of WKPasswordView to
WKWebView and creates an internal API for showing and hiding it. When
-_showPasswordViewWithDocumentName:passwordHandler: is called, WKWebView inserts a new
WKPasswordView as a subview of the scroll view and hides the current content view. The
password view is removed and the current content view is unhidden by -_hidePasswordView.

This also fixes a bug in WKPDFView where a PDF document is laid out incorrectly if the view
size changes while the password view is displayed.

* UIProcess/API/Cocoa/WKWebView.mm: Declared _passwordView.
(-[WKWebView _processDidExit]): Hid the password view.
(-[WKWebView _didCommitLayerTree:]): Ignored if not showing the standard content view.
(-[WKWebView _restorePageScrollPosition:scrollOrigin:previousObscuredInset:scale:]): Ditto.
(-[WKWebView _restorePageStateToUnobscuredCenter:scale:]): Ditto.
(-[WKWebView usesStandardContentView]): Changed to return false if _passwordView is non-nil.
(-[WKWebView _updateContentRectsWithState:]): Updated _passwordView's frame with the current
bounds size.
(-[WKWebView _showPasswordViewWithDocumentName:passwordHandler:]): Created a WKPasswordView,
called -showInScrollView:, and hid _currentContentView.
(-[WKWebView _hidePasswordView]): Removed _passwordView from its superview, set
_passwordView to nil, and unhid _currentContentView.
(-[WKWebView _passwordView]): Returned _passwordView.
(-[WKWebView _beginAnimatedResizeWithUpdates:]): Called -usesStandardContentView instead of
checking for a non-nil _customContentView when deciding whether to do a non-animated resize.
* UIProcess/API/Cocoa/WKWebViewInternal.h:
* UIProcess/ios/WKPDFView.mm: Removed _passwordView.
(-[WKPDFView web_setMinimumSize:]): Set m_minimumSize and updated the frame size even when a
password view is displayed.
(-[WKPDFView _computePageAndDocumentFrames]): Removed password view code.
(-[WKPDFView _showPasswordEntryField]): Ditto.
(-[WKPDFView _passwordViewFrame]): Deleted.
* UIProcess/ios/WKPasswordView.h:
* UIProcess/ios/WKPasswordView.mm:
(-[WKPasswordView initWithFrame:documentName:]): Stored a copy of documentName in
_documentName.
(-[WKPasswordView documentName]): Added. Returns _documentName.
(-[WKPasswordView showInScrollView:]): Renamed from displayInContentView:. Started saving
zoomScale and contentSize.
(-[WKPasswordView hide]): Started restoring zoomeScale and contentSize.
(-[WKPasswordView showPasswordFailureAlert]): Renamed from -displayPasswordFailureAlert.
(-[WKPasswordView displayInContentView:]): Renamed to -showInScrollView:
(-[WKPasswordView displayPasswordFailureAlert]): Renamed to -showPasswordFailureAlert.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewInternalh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKPDFViewmm">trunk/Source/WebKit2/UIProcess/ios/WKPDFView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKPasswordViewh">trunk/Source/WebKit2/UIProcess/ios/WKPasswordView.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKPasswordViewmm">trunk/Source/WebKit2/UIProcess/ios/WKPasswordView.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (211159 => 211160)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2017-01-25 20:42:10 UTC (rev 211159)
+++ trunk/Source/WebKit2/ChangeLog        2017-01-25 20:48:41 UTC (rev 211160)
</span><span class="lines">@@ -1,3 +1,60 @@
</span><ins>+2017-01-25  Andy Estes  &lt;aestes@apple.com&gt;
+
+        [iOS] Move WKPDFView's password view to WKWebView
+        https://bugs.webkit.org/show_bug.cgi?id=167401
+
+        Reviewed by Tim Horton.
+
+        r210943 moved the PDF password view into the new class WKPasswordView but left it as a
+        subview of the WKPDFView. To show the password view for Web content, my original plan was to
+        teach WKContentView to host its own password view, but this turned out not to work. Since
+        QuickLook needs to unlock a document before determining its preview's MIME type, we have to
+        ask for a password during provisional navigation, but if the still-committed document is a
+        PDF then the WKContentView will not be in the view hierarchy.
+
+        To ensure password view visibility, this patch moves the ownership of WKPasswordView to
+        WKWebView and creates an internal API for showing and hiding it. When
+        -_showPasswordViewWithDocumentName:passwordHandler: is called, WKWebView inserts a new
+        WKPasswordView as a subview of the scroll view and hides the current content view. The
+        password view is removed and the current content view is unhidden by -_hidePasswordView.
+
+        This also fixes a bug in WKPDFView where a PDF document is laid out incorrectly if the view
+        size changes while the password view is displayed.
+
+        * UIProcess/API/Cocoa/WKWebView.mm: Declared _passwordView.
+        (-[WKWebView _processDidExit]): Hid the password view.
+        (-[WKWebView _didCommitLayerTree:]): Ignored if not showing the standard content view.
+        (-[WKWebView _restorePageScrollPosition:scrollOrigin:previousObscuredInset:scale:]): Ditto.
+        (-[WKWebView _restorePageStateToUnobscuredCenter:scale:]): Ditto.
+        (-[WKWebView usesStandardContentView]): Changed to return false if _passwordView is non-nil.
+        (-[WKWebView _updateContentRectsWithState:]): Updated _passwordView's frame with the current
+        bounds size.
+        (-[WKWebView _showPasswordViewWithDocumentName:passwordHandler:]): Created a WKPasswordView,
+        called -showInScrollView:, and hid _currentContentView.
+        (-[WKWebView _hidePasswordView]): Removed _passwordView from its superview, set
+        _passwordView to nil, and unhid _currentContentView.
+        (-[WKWebView _passwordView]): Returned _passwordView.
+        (-[WKWebView _beginAnimatedResizeWithUpdates:]): Called -usesStandardContentView instead of
+        checking for a non-nil _customContentView when deciding whether to do a non-animated resize.
+        * UIProcess/API/Cocoa/WKWebViewInternal.h:
+        * UIProcess/ios/WKPDFView.mm: Removed _passwordView.
+        (-[WKPDFView web_setMinimumSize:]): Set m_minimumSize and updated the frame size even when a
+        password view is displayed.
+        (-[WKPDFView _computePageAndDocumentFrames]): Removed password view code.
+        (-[WKPDFView _showPasswordEntryField]): Ditto.
+        (-[WKPDFView _passwordViewFrame]): Deleted.
+        * UIProcess/ios/WKPasswordView.h:
+        * UIProcess/ios/WKPasswordView.mm:
+        (-[WKPasswordView initWithFrame:documentName:]): Stored a copy of documentName in
+        _documentName.
+        (-[WKPasswordView documentName]): Added. Returns _documentName.
+        (-[WKPasswordView showInScrollView:]): Renamed from displayInContentView:. Started saving
+        zoomScale and contentSize.
+        (-[WKPasswordView hide]): Started restoring zoomeScale and contentSize.
+        (-[WKPasswordView showPasswordFailureAlert]): Renamed from -displayPasswordFailureAlert.
+        (-[WKPasswordView displayInContentView:]): Renamed to -showInScrollView:
+        (-[WKPasswordView displayPasswordFailureAlert]): Renamed to -showPasswordFailureAlert.
+
</ins><span class="cx"> 2017-01-25  Wenson Hsieh  &lt;wenson_hsieh@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add support for named pasteboards, pasteboard strategies and platform pasteboards
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (211159 => 211160)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2017-01-25 20:42:10 UTC (rev 211159)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2017-01-25 20:48:41 UTC (rev 211160)
</span><span class="lines">@@ -57,6 +57,7 @@
</span><span class="cx"> #import &quot;WKNSURLExtras.h&quot;
</span><span class="cx"> #import &quot;WKNavigationDelegate.h&quot;
</span><span class="cx"> #import &quot;WKNavigationInternal.h&quot;
</span><ins>+#import &quot;WKPasswordView.h&quot;
</ins><span class="cx"> #import &quot;WKPreferencesInternal.h&quot;
</span><span class="cx"> #import &quot;WKProcessPoolInternal.h&quot;
</span><span class="cx"> #import &quot;WKSharedAPICast.h&quot;
</span><span class="lines">@@ -273,6 +274,8 @@
</span><span class="cx"> 
</span><span class="cx">     Vector&lt;std::function&lt;void ()&gt;&gt; _snapshotsDeferredDuringResize;
</span><span class="cx">     RetainPtr&lt;NSMutableArray&gt; _stableStatePresentationUpdateCallbacks;
</span><ins>+
+    RetainPtr&lt;WKPasswordView&gt; _passwordView;
</ins><span class="cx"> #endif
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx">     std::unique_ptr&lt;WebKit::WebViewImpl&gt; _impl;
</span><span class="lines">@@ -1192,6 +1195,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_processDidExit
</span><span class="cx"> {
</span><ins>+    [self _hidePasswordView];
</ins><span class="cx">     if (!_customContentView &amp;&amp; _dynamicViewportUpdateMode != DynamicViewportUpdateMode::NotResizing) {
</span><span class="cx">         NSUInteger indexOfResizeAnimationView = [[_scrollView subviews] indexOfObject:_resizeAnimationView.get()];
</span><span class="cx">         [_scrollView insertSubview:_contentView.get() atIndex:indexOfResizeAnimationView];
</span><span class="lines">@@ -1268,7 +1272,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_didCommitLayerTree:(const WebKit::RemoteLayerTreeTransaction&amp;)layerTreeTransaction
</span><span class="cx"> {
</span><del>-    if (_customContentView)
</del><ins>+    if (![self usesStandardContentView])
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     if (_dynamicViewportUpdateMode != DynamicViewportUpdateMode::NotResizing) {
</span><span class="lines">@@ -1406,7 +1410,7 @@
</span><span class="cx">     if (_dynamicViewportUpdateMode != DynamicViewportUpdateMode::NotResizing)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (_customContentView)
</del><ins>+    if (![self usesStandardContentView])
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     _needsToRestoreUnobscuredCenter = NO;
</span><span class="lines">@@ -1423,7 +1427,7 @@
</span><span class="cx">     if (_dynamicViewportUpdateMode != DynamicViewportUpdateMode::NotResizing)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (_customContentView)
</del><ins>+    if (![self usesStandardContentView])
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     _needsToRestoreScrollPosition = NO;
</span><span class="lines">@@ -1834,7 +1838,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (BOOL)usesStandardContentView
</span><span class="cx"> {
</span><del>-    return !_customContentView;
</del><ins>+    return !_customContentView &amp;&amp; !_passwordView;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (CGSize)scrollView:(UIScrollView*)scrollView contentSizeForZoomScale:(CGFloat)scale withProposedSize:(CGSize)proposedSize
</span><span class="lines">@@ -2111,6 +2115,7 @@
</span><span class="cx"> - (void)_updateContentRectsWithState:(BOOL)inStableState
</span><span class="cx"> {
</span><span class="cx">     if (![self usesStandardContentView]) {
</span><ins>+        [_passwordView setFrame:self.bounds];
</ins><span class="cx">         [_customContentView web_computedContentInsetDidChange];
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -2331,6 +2336,27 @@
</span><span class="cx">     _frozenUnobscuredContentRect = std::nullopt;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)_showPasswordViewWithDocumentName:(NSString *)documentName passwordHandler:(void (^)(NSString *))passwordHandler
+{
+    ASSERT(!_passwordView);
+    _passwordView = adoptNS([[WKPasswordView alloc] initWithFrame:self.bounds documentName:documentName]);
+    [_passwordView setUserDidEnterPassword:passwordHandler];
+    [_passwordView showInScrollView:_scrollView.get()];
+    self._currentContentView.hidden = YES;
+}
+
+- (void)_hidePasswordView
+{
+    self._currentContentView.hidden = NO;
+    [_passwordView removeFromSuperview];
+    _passwordView = nil;
+}
+
+- (WKPasswordView *)_passwordView
+{
+    return _passwordView.get();
+}
+
</ins><span class="cx"> #endif // PLATFORM(IOS)
</span><span class="cx"> 
</span><span class="cx"> #pragma mark OS X-specific methods
</span><span class="lines">@@ -4212,7 +4238,7 @@
</span><span class="cx">     CGRect oldBounds = self.bounds;
</span><span class="cx">     WebCore::FloatRect oldUnobscuredContentRect = _page-&gt;unobscuredContentRect();
</span><span class="cx"> 
</span><del>-    if (_customContentView || !_hasCommittedLoadForMainFrame || CGRectIsEmpty(oldBounds) || oldUnobscuredContentRect.isEmpty()) {
</del><ins>+    if (![self usesStandardContentView] || !_hasCommittedLoadForMainFrame || CGRectIsEmpty(oldBounds) || oldUnobscuredContentRect.isEmpty()) {
</ins><span class="cx">         updateBlock();
</span><span class="cx">         return;
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewInternalh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h (211159 => 211160)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h        2017-01-25 20:42:10 UTC (rev 211159)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h        2017-01-25 20:48:41 UTC (rev 211160)
</span><span class="lines">@@ -56,6 +56,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> @class WKWebViewContentProviderRegistry;
</span><ins>+@class WKPasswordView;
</ins><span class="cx"> @class _WKFrameHandle;
</span><span class="cx"> @protocol _WKWebViewPrintProvider;
</span><span class="cx"> 
</span><span class="lines">@@ -116,6 +117,11 @@
</span><span class="cx"> - (void)_navigationGestureDidEnd;
</span><span class="cx"> - (BOOL)_isNavigationSwipeGestureRecognizer:(UIGestureRecognizer *)recognizer;
</span><span class="cx"> 
</span><ins>+- (void)_showPasswordViewWithDocumentName:(NSString *)documentName passwordHandler:(void (^)(NSString *))passwordHandler;
+- (void)_hidePasswordView;
+
+@property (nonatomic, readonly) WKPasswordView *_passwordView;
+
</ins><span class="cx"> @property (nonatomic, readonly) BOOL _isBackground;
</span><span class="cx"> 
</span><span class="cx"> @property (nonatomic, readonly) WKWebViewContentProviderRegistry *_contentProviderRegistry;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKPDFViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKPDFView.mm (211159 => 211160)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKPDFView.mm        2017-01-25 20:42:10 UTC (rev 211159)
+++ trunk/Source/WebKit2/UIProcess/ios/WKPDFView.mm        2017-01-25 20:48:41 UTC (rev 211160)
</span><span class="lines">@@ -76,8 +76,6 @@
</span><span class="cx">     RetainPtr&lt;NSString&gt; _suggestedFilename;
</span><span class="cx">     RetainPtr&lt;WKPDFPageNumberIndicator&gt; _pageNumberIndicator;
</span><span class="cx"> 
</span><del>-    RetainPtr&lt;WKPasswordView&gt; _passwordView;
-
</del><span class="cx">     Vector&lt;PDFPageInfo&gt; _pages;
</span><span class="cx">     unsigned _centerPageNumber;
</span><span class="cx"> 
</span><span class="lines">@@ -205,13 +203,13 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)web_setMinimumSize:(CGSize)size
</span><span class="cx"> {
</span><del>-    if (_passwordView) {
-        [_passwordView setFrame:[self _passwordViewFrame]];
</del><ins>+    _minimumSize = size;
+
+    if (_webView._passwordView) {
+        self.frame = { self.frame.origin, size };
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    _minimumSize = size;
-
</del><span class="cx">     CGFloat oldDocumentLeftFraction = 0;
</span><span class="cx">     CGFloat oldDocumentTopFraction = 0;
</span><span class="cx">     CGSize contentSize = _scrollView.contentSize;
</span><span class="lines">@@ -361,9 +359,6 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_computePageAndDocumentFrames
</span><span class="cx"> {
</span><del>-    if (_passwordView)
-        return;
-
</del><span class="cx">     NSUInteger pageCount = [_pdfDocument numberOfPages];
</span><span class="cx">     [_pageNumberIndicator setPageCount:pageCount];
</span><span class="cx">     
</span><span class="lines">@@ -746,28 +741,17 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma mark Password protection UI
</span><span class="cx"> 
</span><del>-- (CGRect)_passwordViewFrame
-{
-    CGRect webViewBounds = _webView.bounds;
-    return CGRectMake(0, 0, webViewBounds.size.width, webViewBounds.size.height);
-}
-
</del><span class="cx"> - (void)_showPasswordEntryField
</span><span class="cx"> {
</span><del>-    _passwordView = adoptNS([[WKPasswordView alloc] initWithFrame:[self _passwordViewFrame] documentName:_suggestedFilename.get()]);
-
-    [_passwordView setUserDidEnterPassword:[retainedSelf = retainPtr(self)](NSString *password) {
</del><ins>+    [_webView _showPasswordViewWithDocumentName:_suggestedFilename.get() passwordHandler:[retainedSelf = retainPtr(self), webView = retainPtr(_webView)](NSString *password) {
</ins><span class="cx">         if (!CGPDFDocumentUnlockWithPassword(retainedSelf-&gt;_cgPDFDocument.get(), password.UTF8String)) {
</span><del>-            [retainedSelf-&gt;_passwordView displayPasswordFailureAlert];
</del><ins>+            [[webView _passwordView] showPasswordFailureAlert];
</ins><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        [retainedSelf-&gt;_passwordView hide];
-        retainedSelf-&gt;_passwordView = nil;
</del><ins>+        [webView _hidePasswordView];
</ins><span class="cx">         [retainedSelf _didLoadPDFDocument];
</span><span class="cx">     }];
</span><del>-
-    [_passwordView displayInContentView:self];
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)willMoveToWindow:(UIWindow *)newWindow
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKPasswordViewh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKPasswordView.h (211159 => 211160)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKPasswordView.h        2017-01-25 20:42:10 UTC (rev 211159)
+++ trunk/Source/WebKit2/UIProcess/ios/WKPasswordView.h        2017-01-25 20:48:41 UTC (rev 211160)
</span><span class="lines">@@ -30,10 +30,11 @@
</span><span class="cx"> @interface WKPasswordView : UIView
</span><span class="cx"> 
</span><span class="cx"> - (instancetype)initWithFrame:(CGRect)frame documentName:(NSString *)documentName;
</span><del>-- (void)displayInContentView:(UIView *)contentView;
</del><ins>+- (void)showInScrollView:(UIScrollView *)scrollView;
</ins><span class="cx"> - (void)hide;
</span><del>-- (void)displayPasswordFailureAlert;
</del><ins>+- (void)showPasswordFailureAlert;
</ins><span class="cx"> 
</span><ins>+@property (nonatomic, readonly) NSString *documentName;
</ins><span class="cx"> @property (nonatomic, copy) void (^userDidEnterPassword)(NSString *);
</span><span class="cx"> 
</span><span class="cx"> @end
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKPasswordViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKPasswordView.mm (211159 => 211160)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKPasswordView.mm        2017-01-25 20:42:10 UTC (rev 211159)
+++ trunk/Source/WebKit2/UIProcess/ios/WKPasswordView.mm        2017-01-25 20:48:41 UTC (rev 211160)
</span><span class="lines">@@ -41,10 +41,13 @@
</span><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> @implementation WKPasswordView {
</span><ins>+    RetainPtr&lt;NSString&gt; _documentName;
</ins><span class="cx">     RetainPtr&lt;UIScrollView&gt; _scrollView;
</span><span class="cx">     RetainPtr&lt;UIDocumentPasswordView&gt; _passwordView;
</span><span class="cx">     CGFloat _savedMinimumZoomScale;
</span><span class="cx">     CGFloat _savedMaximumZoomScale;
</span><ins>+    CGFloat _savedZoomScale;
+    CGSize _savedContentSize;
</ins><span class="cx">     RetainPtr&lt;UIColor&gt; _savedBackgroundColor;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -54,7 +57,8 @@
</span><span class="cx">     if (!self)
</span><span class="cx">         return nil;
</span><span class="cx"> 
</span><del>-    _passwordView = adoptNS([[UIDocumentPasswordView alloc] initWithDocumentName:documentName]);
</del><ins>+    _documentName = adoptNS([documentName copy]);
+    _passwordView = adoptNS([[UIDocumentPasswordView alloc] initWithDocumentName:_documentName.get()]);
</ins><span class="cx">     [_passwordView setFrame:self.bounds];
</span><span class="cx">     [_passwordView setPasswordDelegate:self];
</span><span class="cx">     [_passwordView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
</span><span class="lines">@@ -65,6 +69,11 @@
</span><span class="cx">     return self;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (NSString *)documentName
+{
+    return _documentName.get();
+}
+
</ins><span class="cx"> - (void)layoutSubviews
</span><span class="cx"> {
</span><span class="cx">     if (_scrollView)
</span><span class="lines">@@ -71,22 +80,23 @@
</span><span class="cx">         [_scrollView setContentSize:self.frame.size];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)displayInContentView:(UIView *)contentView
</del><ins>+- (void)showInScrollView:(UIScrollView *)scrollView
</ins><span class="cx"> {
</span><del>-    ASSERT([contentView isKindOfClass:[WKContentView class]] || [contentView conformsToProtocol:@protocol(WKWebViewContentProvider)]);
-    ASSERT([contentView.superview isKindOfClass:[UIScrollView class]]);
-    _scrollView = (UIScrollView *)contentView.superview;
</del><ins>+    _scrollView = scrollView;
</ins><span class="cx"> 
</span><span class="cx">     _savedMinimumZoomScale = [_scrollView minimumZoomScale];
</span><span class="cx">     _savedMaximumZoomScale = [_scrollView maximumZoomScale];
</span><ins>+    _savedZoomScale = [_scrollView zoomScale];
+    _savedContentSize = [_scrollView contentSize];
</ins><span class="cx">     _savedBackgroundColor = [_scrollView backgroundColor];
</span><span class="cx"> 
</span><span class="cx">     [_scrollView setMinimumZoomScale:1];
</span><span class="cx">     [_scrollView setMaximumZoomScale:1];
</span><ins>+    [_scrollView setZoomScale:1];
</ins><span class="cx">     [_scrollView setContentSize:self.frame.size];
</span><span class="cx">     [_scrollView setBackgroundColor:[UIColor groupTableViewBackgroundColor]];
</span><span class="cx"> 
</span><del>-    [contentView addSubview:self];
</del><ins>+    [scrollView addSubview:self];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)hide
</span><span class="lines">@@ -93,6 +103,8 @@
</span><span class="cx"> {
</span><span class="cx">     [_scrollView setMinimumZoomScale:_savedMinimumZoomScale];
</span><span class="cx">     [_scrollView setMaximumZoomScale:_savedMaximumZoomScale];
</span><ins>+    [_scrollView setZoomScale:_savedZoomScale];
+    [_scrollView setContentSize:_savedContentSize];
</ins><span class="cx">     [_scrollView setBackgroundColor:_savedBackgroundColor.get()];
</span><span class="cx"> 
</span><span class="cx">     _scrollView = nil;
</span><span class="lines">@@ -101,7 +113,7 @@
</span><span class="cx">     [self removeFromSuperview];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)displayPasswordFailureAlert
</del><ins>+- (void)showPasswordFailureAlert
</ins><span class="cx"> {
</span><span class="cx">     [[_passwordView passwordField] setText:@&quot;&quot;];
</span><span class="cx">     UIAlertController *alert = [UIAlertController alertControllerWithTitle:WEB_UI_STRING(&quot;The document could not be opened with that password.&quot;, &quot;document password failure alert message&quot;) message:@&quot;&quot; preferredStyle:UIAlertControllerStyleAlert];
</span></span></pre>
</div>
</div>

</body>
</html>