<!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>[210943] trunk/Source</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/210943">210943</a></dd>
<dt>Author</dt> <dd>aestes@apple.com</dd>
<dt>Date</dt> <dd>2017-01-19 16:23:54 -0800 (Thu, 19 Jan 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>Source/WebCore:
[iOS] Move the PDF password view into its own class for reuse
https://bugs.webkit.org/show_bug.cgi?id=167192
Reviewed by Tim Horton.
* English.lproj/Localizable.strings: Updated the failure alert strings to not be specific to PDFs.
Source/WebKit2:
[iOS] Move the PDF password view into its own class for possible reuse
https://bugs.webkit.org/show_bug.cgi?id=167192
Reviewed by Tim Horton.
* UIProcess/ios/WKPDFView.h: Stopped conforming to UIDocumentPasswordViewDelegate.
* UIProcess/ios/WKPDFView.mm: Changed _passwordView to a WKPasswordView.
(-[WKPDFView _passwordViewFrame]): Returns the frame to set on _passwordView.
(-[WKPDFView _updatePasswordEntryField]): Removed.
(-[WKPDFView _showPasswordEntryField]): Created a WKPasswordView, set a lambda on its
userDidEnterPassword property to do the work previously done in -_tryToUnlockWithPassword:,
and showed the password view.
(-[WKPDFView _keyboardDidShow:]): Moved to WKPasswordView.
(-[WKPDFView _hidePasswordEntryField]): Deleted. The userDidEnterPassword lambda now calls
-[WKPasswordView hide] when the document is unlocked.
(-[WKPDFView userDidEnterPassword:forPasswordView:]): Moved to WKPasswordView.
(-[WKPDFView didBeginEditingPassword:inView:]): Ditto.
(-[WKPDFView didEndEditingPassword:inView:]): Ditto.
(-[WKPDFView _didFailToUnlock]): Ditto.
(-[WKPDFView _tryToUnlockWithPassword:]): Moved into _passwordView's userDidEnterPassword lambda.
* UIProcess/ios/WKPasswordView.h: Added.
* UIProcess/ios/WKPasswordView.mm: Added.
(-[WKPasswordView initWithFrame:documentName:]): Created a UIDocumentPasswordView with
documentName, set self as its passwordDelegate, and added it as a subview.
(-[WKPasswordView layoutSubviews]): Updated _scrollView's contentSize if we are displaying
the view.
(-[WKPasswordView displayInContentView:]): Saved the scroll view's previous minimum/maximum
zoom scale and color, set new values for minimum/maximum zoom scale and color, and added
self as a subview of contentView.
(-[WKPasswordView hide]): Restored the saved minimum/maximum zoom scale and color on the
scroll view and removed self from its superview.
(-[WKPasswordView displayPasswordFailureAlert]): Displayed the alert previously shown by
-[WKPDFView _didFailToUnlock].
(-[WKPasswordView _keyboardDidShow:]): Moved from WKPDFView.
(-[WKPasswordView userDidEnterPassword:forPasswordView:]): Retained self and called the
_userDidEnterPassword block with the password.
(-[WKPasswordView didBeginEditingPassword:inView:]): Moved from WKPDFView.
(-[WKPasswordView didEndEditingPassword:inView:]): Ditto.
* WebKit2.xcodeproj/project.pbxproj:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreEnglishlprojLocalizablestrings">trunk/Source/WebCore/English.lproj/Localizable.strings</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKPDFViewh">trunk/Source/WebKit2/UIProcess/ios/WKPDFView.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKPDFViewmm">trunk/Source/WebKit2/UIProcess/ios/WKPDFView.mm</a></li>
<li><a href="#trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj">trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<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="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (210942 => 210943)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-01-19 23:43:51 UTC (rev 210942)
+++ trunk/Source/WebCore/ChangeLog        2017-01-20 00:23:54 UTC (rev 210943)
</span><span class="lines">@@ -1,3 +1,12 @@
</span><ins>+2017-01-19 Andy Estes <aestes@apple.com>
+
+ [iOS] Move the PDF password view into its own class for reuse
+ https://bugs.webkit.org/show_bug.cgi?id=167192
+
+ Reviewed by Tim Horton.
+
+ * English.lproj/Localizable.strings: Updated the failure alert strings to not be specific to PDFs.
+
</ins><span class="cx"> 2017-01-19 Chris Dumez <cdumez@apple.com>
</span><span class="cx">
</span><span class="cx"> Make sure HTML validation bubble gets dismissed when its associated element's frame gets detached
</span></span></pre></div>
<a id="trunkSourceWebCoreEnglishlprojLocalizablestrings"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/English.lproj/Localizable.strings (210942 => 210943)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/English.lproj/Localizable.strings        2017-01-19 23:43:51 UTC (rev 210942)
+++ trunk/Source/WebCore/English.lproj/Localizable.strings        2017-01-20 00:23:54 UTC (rev 210943)
</span><span class="lines">@@ -403,8 +403,8 @@
</span><span class="cx"> /* Option in segmented control for inserting a numbered list in text editing */
</span><span class="cx"> "Numbered list" = "Numbered list";
</span><span class="cx">
</span><del>-/* OK button label in PDF password failure alert */
-"OK (PDF password failure alert)" = "OK";
</del><ins>+/* OK button label in document password failure alert */
+"OK (document password failure alert)" = "OK";
</ins><span class="cx">
</span><span class="cx"> /* Menu item label for the track that represents disabling closed captions */
</span><span class="cx"> "Off" = "Off";
</span><span class="lines">@@ -661,7 +661,7 @@
</span><span class="cx"> /* WebKitErrorGeolocationLocationUnknown description */
</span><span class="cx"> "The current location cannot be found." = "The current location cannot be found.";
</span><span class="cx">
</span><del>-/* PDF password failure alert message */
</del><ins>+/* document password failure alert message */
</ins><span class="cx"> "The document could not be opened with that password." = "The document could not be opened with that password.";
</span><span class="cx">
</span><span class="cx"> /* WebKitErrorCannotFindPlugin description */
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (210942 => 210943)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2017-01-19 23:43:51 UTC (rev 210942)
+++ trunk/Source/WebKit2/ChangeLog        2017-01-20 00:23:54 UTC (rev 210943)
</span><span class="lines">@@ -1,3 +1,45 @@
</span><ins>+2017-01-19 Andy Estes <aestes@apple.com>
+
+ [iOS] Move the PDF password view into its own class for possible reuse
+ https://bugs.webkit.org/show_bug.cgi?id=167192
+
+ Reviewed by Tim Horton.
+
+ * UIProcess/ios/WKPDFView.h: Stopped conforming to UIDocumentPasswordViewDelegate.
+ * UIProcess/ios/WKPDFView.mm: Changed _passwordView to a WKPasswordView.
+ (-[WKPDFView _passwordViewFrame]): Returns the frame to set on _passwordView.
+ (-[WKPDFView _updatePasswordEntryField]): Removed.
+ (-[WKPDFView _showPasswordEntryField]): Created a WKPasswordView, set a lambda on its
+ userDidEnterPassword property to do the work previously done in -_tryToUnlockWithPassword:,
+ and showed the password view.
+ (-[WKPDFView _keyboardDidShow:]): Moved to WKPasswordView.
+ (-[WKPDFView _hidePasswordEntryField]): Deleted. The userDidEnterPassword lambda now calls
+ -[WKPasswordView hide] when the document is unlocked.
+ (-[WKPDFView userDidEnterPassword:forPasswordView:]): Moved to WKPasswordView.
+ (-[WKPDFView didBeginEditingPassword:inView:]): Ditto.
+ (-[WKPDFView didEndEditingPassword:inView:]): Ditto.
+ (-[WKPDFView _didFailToUnlock]): Ditto.
+ (-[WKPDFView _tryToUnlockWithPassword:]): Moved into _passwordView's userDidEnterPassword lambda.
+ * UIProcess/ios/WKPasswordView.h: Added.
+ * UIProcess/ios/WKPasswordView.mm: Added.
+ (-[WKPasswordView initWithFrame:documentName:]): Created a UIDocumentPasswordView with
+ documentName, set self as its passwordDelegate, and added it as a subview.
+ (-[WKPasswordView layoutSubviews]): Updated _scrollView's contentSize if we are displaying
+ the view.
+ (-[WKPasswordView displayInContentView:]): Saved the scroll view's previous minimum/maximum
+ zoom scale and color, set new values for minimum/maximum zoom scale and color, and added
+ self as a subview of contentView.
+ (-[WKPasswordView hide]): Restored the saved minimum/maximum zoom scale and color on the
+ scroll view and removed self from its superview.
+ (-[WKPasswordView displayPasswordFailureAlert]): Displayed the alert previously shown by
+ -[WKPDFView _didFailToUnlock].
+ (-[WKPasswordView _keyboardDidShow:]): Moved from WKPDFView.
+ (-[WKPasswordView userDidEnterPassword:forPasswordView:]): Retained self and called the
+ _userDidEnterPassword block with the password.
+ (-[WKPasswordView didBeginEditingPassword:inView:]): Moved from WKPDFView.
+ (-[WKPasswordView didEndEditingPassword:inView:]): Ditto.
+ * WebKit2.xcodeproj/project.pbxproj:
+
</ins><span class="cx"> 2017-01-19 Chris Dumez <cdumez@apple.com>
</span><span class="cx">
</span><span class="cx"> Make sure HTML validation bubble gets dismissed when its associated element's frame gets detached
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKPDFViewh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKPDFView.h (210942 => 210943)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKPDFView.h        2017-01-19 23:43:51 UTC (rev 210942)
+++ trunk/Source/WebKit2/UIProcess/ios/WKPDFView.h        2017-01-20 00:23:54 UTC (rev 210943)
</span><span class="lines">@@ -26,11 +26,10 @@
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">
</span><span class="cx"> #import "CorePDFSPI.h"
</span><del>-#import "UIKitSPI.h"
</del><span class="cx"> #import "WKActionSheetAssistant.h"
</span><span class="cx"> #import "WKWebViewContentProvider.h"
</span><span class="cx">
</span><del>-@interface WKPDFView : UIView <WKWebViewContentProvider, UIPDFPageViewDelegate, UIPDFAnnotationControllerDelegate, WKActionSheetAssistantDelegate, UIDocumentPasswordViewDelegate>
</del><ins>+@interface WKPDFView : UIView <WKWebViewContentProvider, UIPDFPageViewDelegate, UIPDFAnnotationControllerDelegate, WKActionSheetAssistantDelegate>
</ins><span class="cx">
</span><span class="cx"> @property (nonatomic, readonly) NSString *suggestedFilename;
</span><span class="cx"> @property (nonatomic, readonly) CGPDFDocumentRef pdfDocument;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKPDFViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKPDFView.mm (210942 => 210943)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKPDFView.mm        2017-01-19 23:43:51 UTC (rev 210942)
+++ trunk/Source/WebKit2/UIProcess/ios/WKPDFView.mm        2017-01-20 00:23:54 UTC (rev 210943)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> #import "SessionState.h"
</span><span class="cx"> #import "UIKitSPI.h"
</span><span class="cx"> #import "WKPDFPageNumberIndicator.h"
</span><ins>+#import "WKPasswordView.h"
</ins><span class="cx"> #import "WKWebViewInternal.h"
</span><span class="cx"> #import "WeakObjCPtr.h"
</span><span class="cx"> #import "WebPageProxy.h"
</span><span class="lines">@@ -54,8 +55,6 @@
</span><span class="cx"> const CGFloat pdfMinimumZoomScale = 1;
</span><span class="cx"> const CGFloat pdfMaximumZoomScale = 5;
</span><span class="cx">
</span><del>-const CGFloat passwordEntryFieldPadding = 10;
-
</del><span class="cx"> const float overdrawHeightMultiplier = 1.5;
</span><span class="cx">
</span><span class="cx"> static const CGFloat smartMagnificationElementPadding = 0.05;
</span><span class="lines">@@ -77,7 +76,7 @@
</span><span class="cx"> RetainPtr<NSString> _suggestedFilename;
</span><span class="cx"> RetainPtr<WKPDFPageNumberIndicator> _pageNumberIndicator;
</span><span class="cx">
</span><del>- RetainPtr<UIDocumentPasswordView> _passwordView;
</del><ins>+ RetainPtr<WKPasswordView> _passwordView;
</ins><span class="cx">
</span><span class="cx"> Vector<PDFPageInfo> _pages;
</span><span class="cx"> unsigned _centerPageNumber;
</span><span class="lines">@@ -207,7 +206,7 @@
</span><span class="cx"> - (void)web_setMinimumSize:(CGSize)size
</span><span class="cx"> {
</span><span class="cx"> if (_passwordView) {
</span><del>- [self _updatePasswordEntryField];
</del><ins>+ [_passwordView setFrame:[self _passwordViewFrame]];
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -747,108 +746,30 @@
</span><span class="cx">
</span><span class="cx"> #pragma mark Password protection UI
</span><span class="cx">
</span><del>-- (void)_updatePasswordEntryField
</del><ins>+- (CGRect)_passwordViewFrame
</ins><span class="cx"> {
</span><del>- [_passwordView setFrame:CGRectMake(0, 0, _webView.bounds.size.width, _webView.bounds.size.height)];
- [_scrollView setContentSize:[_passwordView bounds].size];
</del><ins>+ CGRect webViewBounds = _webView.bounds;
+ return CGRectMake(0, 0, webViewBounds.size.width, webViewBounds.size.height);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-- (void)_keyboardDidShow:(NSNotification *)notification
-{
- UITextField *passwordField = [_passwordView passwordField];
- if (!passwordField.isEditing)
- return;
-
- CGRect keyboardRect = [UIPeripheralHost visiblePeripheralFrame];
- if (CGRectIsEmpty(keyboardRect))
- return;
-
- UIWindow *window = _scrollView.window;
- keyboardRect = [window convertRect:keyboardRect fromWindow:nil];
- keyboardRect = [_scrollView convertRect:keyboardRect fromView:window];
-
- CGRect passwordFieldFrame = [passwordField convertRect:passwordField.bounds toView:_scrollView];
-
- CGSize contentSize = [_passwordView bounds].size;
- contentSize.height += CGRectGetHeight(keyboardRect);
- [_scrollView setContentSize:contentSize];
-
- if (CGRectIntersectsRect(passwordFieldFrame, keyboardRect)) {
- CGFloat yDelta = CGRectGetMaxY(passwordFieldFrame) - CGRectGetMinY(keyboardRect);
-
- CGPoint contentOffset = _scrollView.contentOffset;
- contentOffset.y += yDelta + passwordEntryFieldPadding;
-
- [_scrollView setContentOffset:contentOffset animated:YES];
- }
-}
-
</del><span class="cx"> - (void)_showPasswordEntryField
</span><span class="cx"> {
</span><del>- [_scrollView setMinimumZoomScale:1];
- [_scrollView setMaximumZoomScale:1];
- [_scrollView setBackgroundColor:[UIColor groupTableViewBackgroundColor]];
</del><ins>+ _passwordView = adoptNS([[WKPasswordView alloc] initWithFrame:[self _passwordViewFrame] documentName:_suggestedFilename.get()]);
</ins><span class="cx">
</span><del>- _passwordView = adoptNS([[UIDocumentPasswordView alloc] initWithDocumentName:_suggestedFilename.get()]);
- [_passwordView setPasswordDelegate:self];
</del><ins>+ [_passwordView setUserDidEnterPassword:[retainedSelf = retainPtr(self)](NSString *password) {
+ if (!CGPDFDocumentUnlockWithPassword(retainedSelf->_cgPDFDocument.get(), password.UTF8String)) {
+ [retainedSelf->_passwordView displayPasswordFailureAlert];
+ return;
+ }
</ins><span class="cx">
</span><del>- [self _updatePasswordEntryField];
</del><ins>+ [retainedSelf->_passwordView hide];
+ retainedSelf->_passwordView = nil;
+ [retainedSelf _didLoadPDFDocument];
+ }];
</ins><span class="cx">
</span><del>- [self addSubview:_passwordView.get()];
</del><ins>+ [_passwordView displayInContentView:self];
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-- (void)_hidePasswordEntryField
-{
- [_passwordView removeFromSuperview];
- _passwordView = nil;
-
- [_scrollView setMinimumZoomScale:pdfMinimumZoomScale];
- [_scrollView setMaximumZoomScale:pdfMaximumZoomScale];
- [_scrollView setBackgroundColor:[UIColor grayColor]];
-}
-
-- (void)userDidEnterPassword:(NSString *)password forPasswordView:(UIDocumentPasswordView *)passwordView
-{
- [self _tryToUnlockWithPassword:password];
-}
-
-- (void)didBeginEditingPassword:(UITextField *)passwordField inView:(UIDocumentPasswordView *)passwordView
-{
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil];
-}
-
-- (void)didEndEditingPassword:(UITextField *)passwordField inView:(UIDocumentPasswordView *)passwordView
-{
- [_scrollView setContentSize:[_passwordView frame].size];
- [_scrollView setContentOffset:CGPointMake(-_scrollView.contentInset.left, -_scrollView.contentInset.top) animated:YES];
-
- [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardDidShowNotification object:nil];
-}
-
-- (void)_didFailToUnlock
-{
- [[_passwordView passwordField] setText:@""];
- UIAlertController* alert = [UIAlertController alertControllerWithTitle:WEB_UI_STRING("The document could not be opened with that password.", "PDF password failure alert message") message:@"" preferredStyle:UIAlertControllerStyleAlert];
-
- UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:WEB_UI_STRING_KEY("OK", "OK (PDF password failure alert)", "OK button label in PDF password failure alert") style:UIAlertActionStyleDefault handler:[](UIAlertAction *) { }];
-
- [alert addAction:defaultAction];
-
- [self.window.rootViewController presentViewController:alert animated:YES completion:nil];
-}
-
-- (BOOL)_tryToUnlockWithPassword:(NSString *)password
-{
- if (CGPDFDocumentUnlockWithPassword(_cgPDFDocument.get(), [password UTF8String])) {
- [self _hidePasswordEntryField];
- [self _didLoadPDFDocument];
- return YES;
- }
-
- [self _didFailToUnlock];
- return NO;
-}
-
</del><span class="cx"> - (void)willMoveToWindow:(UIWindow *)newWindow
</span><span class="cx"> {
</span><span class="cx"> if (newWindow)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKPasswordViewhfromrev210942trunkSourceWebKit2UIProcessiosWKPDFViewh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/UIProcess/ios/WKPasswordView.h (from rev 210942, trunk/Source/WebKit2/UIProcess/ios/WKPDFView.h) (0 => 210943)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKPasswordView.h         (rev 0)
+++ trunk/Source/WebKit2/UIProcess/ios/WKPasswordView.h        2017-01-20 00:23:54 UTC (rev 210943)
</span><span class="lines">@@ -0,0 +1,41 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if PLATFORM(IOS)
+
+#import <UIKit/UIKit.h>
+
+@interface WKPasswordView : UIView
+
+- (instancetype)initWithFrame:(CGRect)frame documentName:(NSString *)documentName;
+- (void)displayInContentView:(UIView *)contentView;
+- (void)hide;
+- (void)displayPasswordFailureAlert;
+
+@property (nonatomic, copy) void (^userDidEnterPassword)(NSString *);
+
+@end
+
+#endif // PLATFORM(IOS)
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKPasswordViewmm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/ios/WKPasswordView.mm (0 => 210943)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKPasswordView.mm         (rev 0)
+++ trunk/Source/WebKit2/UIProcess/ios/WKPasswordView.mm        2017-01-20 00:23:54 UTC (rev 210943)
</span><span class="lines">@@ -0,0 +1,172 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "WKPasswordView.h"
+
+#if PLATFORM(IOS)
+
+#import "UIKitSPI.h"
+#import "WKContentView.h"
+#import "WKWebViewContentProvider.h"
+#import <WebCore/LocalizedStrings.h>
+#import <wtf/RetainPtr.h>
+#import <wtf/text/WTFString.h>
+
+const CGFloat passwordEntryFieldPadding = 10;
+
+@interface WKPasswordView () <UIDocumentPasswordViewDelegate>
+@end
+
+@implementation WKPasswordView {
+ RetainPtr<UIScrollView> _scrollView;
+ RetainPtr<UIDocumentPasswordView> _passwordView;
+ CGFloat _savedMinimumZoomScale;
+ CGFloat _savedMaximumZoomScale;
+ RetainPtr<UIColor> _savedBackgroundColor;
+}
+
+- (instancetype)initWithFrame:(CGRect)frame documentName:(NSString *)documentName
+{
+ self = [super initWithFrame:frame];
+ if (!self)
+ return nil;
+
+ _passwordView = adoptNS([[UIDocumentPasswordView alloc] initWithDocumentName:documentName]);
+ [_passwordView setFrame:self.bounds];
+ [_passwordView setPasswordDelegate:self];
+ [_passwordView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
+
+ self.autoresizesSubviews = YES;
+ [self addSubview:_passwordView.get()];
+
+ return self;
+}
+
+- (void)layoutSubviews
+{
+ if (_scrollView)
+ [_scrollView setContentSize:self.frame.size];
+}
+
+- (void)displayInContentView:(UIView *)contentView
+{
+ ASSERT([contentView isKindOfClass:[WKContentView class]] || [contentView conformsToProtocol:@protocol(WKWebViewContentProvider)]);
+ ASSERT([contentView.superview isKindOfClass:[UIScrollView class]]);
+ _scrollView = (UIScrollView *)contentView.superview;
+
+ _savedMinimumZoomScale = [_scrollView minimumZoomScale];
+ _savedMaximumZoomScale = [_scrollView maximumZoomScale];
+ _savedBackgroundColor = [_scrollView backgroundColor];
+
+ [_scrollView setMinimumZoomScale:1];
+ [_scrollView setMaximumZoomScale:1];
+ [_scrollView setContentSize:self.frame.size];
+ [_scrollView setBackgroundColor:[UIColor groupTableViewBackgroundColor]];
+
+ [contentView addSubview:self];
+}
+
+- (void)hide
+{
+ [_scrollView setMinimumZoomScale:_savedMinimumZoomScale];
+ [_scrollView setMaximumZoomScale:_savedMaximumZoomScale];
+ [_scrollView setBackgroundColor:_savedBackgroundColor.get()];
+
+ _scrollView = nil;
+ _savedBackgroundColor = nil;
+
+ [self removeFromSuperview];
+}
+
+- (void)displayPasswordFailureAlert
+{
+ [[_passwordView passwordField] setText:@""];
+ UIAlertController *alert = [UIAlertController alertControllerWithTitle:WEB_UI_STRING("The document could not be opened with that password.", "document password failure alert message") message:@"" preferredStyle:UIAlertControllerStyleAlert];
+
+ UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:WEB_UI_STRING_KEY("OK", "OK (document password failure alert)", "OK button label in document password failure alert") style:UIAlertActionStyleDefault handler:[](UIAlertAction *) { }];
+
+ [alert addAction:defaultAction];
+
+ [self.window.rootViewController presentViewController:alert animated:YES completion:nil];
+}
+
+- (void)_keyboardDidShow:(NSNotification *)notification
+{
+ UITextField *passwordField = [_passwordView passwordField];
+ if (!passwordField.isEditing)
+ return;
+
+ CGRect keyboardRect = [UIPeripheralHost visiblePeripheralFrame];
+ if (CGRectIsEmpty(keyboardRect))
+ return;
+
+ UIWindow *window = [_scrollView window];
+ keyboardRect = [window convertRect:keyboardRect fromWindow:nil];
+ keyboardRect = [_scrollView convertRect:keyboardRect fromView:window];
+
+ CGRect passwordFieldFrame = [passwordField convertRect:passwordField.bounds toView:_scrollView.get()];
+
+ CGSize contentSize = [_passwordView bounds].size;
+ contentSize.height += CGRectGetHeight(keyboardRect);
+ [_scrollView setContentSize:contentSize];
+
+ if (CGRectIntersectsRect(passwordFieldFrame, keyboardRect)) {
+ CGFloat yDelta = CGRectGetMaxY(passwordFieldFrame) - CGRectGetMinY(keyboardRect);
+
+ CGPoint contentOffset = [_scrollView contentOffset];
+ contentOffset.y += yDelta + passwordEntryFieldPadding;
+
+ [_scrollView setContentOffset:contentOffset animated:YES];
+ }
+}
+
+#pragma mark UIDocumentPasswordViewDelegate
+
+- (void)userDidEnterPassword:(NSString *)password forPasswordView:(UIDocumentPasswordView *)passwordView
+{
+ auto protectedSelf = retainPtr(self);
+ if (_userDidEnterPassword)
+ _userDidEnterPassword(password);
+}
+
+- (void)didBeginEditingPassword:(UITextField *)passwordField inView:(UIDocumentPasswordView *)passwordView
+{
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil];
+}
+
+- (void)didEndEditingPassword:(UITextField *)passwordField inView:(UIDocumentPasswordView *)passwordView
+{
+ [_scrollView setContentSize:[_passwordView frame].size];
+
+ UIEdgeInsets contentInset = [_scrollView contentInset];
+ [_scrollView setContentOffset:CGPointMake(-contentInset.left, -contentInset.top) animated:YES];
+
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardDidShowNotification object:nil];
+}
+
+@end
+
+#endif // PLATFORM(IOS)
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (210942 => 210943)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2017-01-19 23:43:51 UTC (rev 210942)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2017-01-20 00:23:54 UTC (rev 210943)
</span><span class="lines">@@ -1343,6 +1343,8 @@
</span><span class="cx">                 A118A9EF1907AD6F00F7C92B /* QuickLookDocumentData.h in Headers */ = {isa = PBXBuildFile; fileRef = A118A9ED1907AD6F00F7C92B /* QuickLookDocumentData.h */; };
</span><span class="cx">                 A118A9F21908B8EA00F7C92B /* _WKNSFileManagerExtras.mm in Sources */ = {isa = PBXBuildFile; fileRef = A118A9F01908B8EA00F7C92B /* _WKNSFileManagerExtras.mm */; };
</span><span class="cx">                 A118A9F31908B8EA00F7C92B /* _WKNSFileManagerExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = A118A9F11908B8EA00F7C92B /* _WKNSFileManagerExtras.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                A15EEDE51E301CEE000069B0 /* WKPasswordView.mm in Sources */ = {isa = PBXBuildFile; fileRef = A15EEDE31E301CEE000069B0 /* WKPasswordView.mm */; };
+                A15EEDE61E301CEE000069B0 /* WKPasswordView.h in Headers */ = {isa = PBXBuildFile; fileRef = A15EEDE41E301CEE000069B0 /* WKPasswordView.h */; };
</ins><span class="cx">                 A182D5B41BE6BD250087A7CC /* AccessibilityIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = A182D5B21BE6BD250087A7CC /* AccessibilityIOS.mm */; };
</span><span class="cx">                 A182D5B51BE6BD250087A7CC /* AccessibilityIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = A182D5B31BE6BD250087A7CC /* AccessibilityIOS.h */; };
</span><span class="cx">                 A19DD3C01D07D16800AC823B /* _WKWebViewPrintFormatterInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = A19DD3BF1D07D16800AC823B /* _WKWebViewPrintFormatterInternal.h */; };
</span><span class="lines">@@ -3500,6 +3502,8 @@
</span><span class="cx">                 A118A9ED1907AD6F00F7C92B /* QuickLookDocumentData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = QuickLookDocumentData.h; path = ios/QuickLookDocumentData.h; sourceTree = "<group>"; };
</span><span class="cx">                 A118A9F01908B8EA00F7C92B /* _WKNSFileManagerExtras.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKNSFileManagerExtras.mm; sourceTree = "<group>"; };
</span><span class="cx">                 A118A9F11908B8EA00F7C92B /* _WKNSFileManagerExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKNSFileManagerExtras.h; sourceTree = "<group>"; };
</span><ins>+                A15EEDE31E301CEE000069B0 /* WKPasswordView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKPasswordView.mm; path = ios/WKPasswordView.mm; sourceTree = "<group>"; };
+                A15EEDE41E301CEE000069B0 /* WKPasswordView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKPasswordView.h; path = ios/WKPasswordView.h; sourceTree = "<group>"; };
</ins><span class="cx">                 A182D5B21BE6BD250087A7CC /* AccessibilityIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AccessibilityIOS.mm; sourceTree = "<group>"; };
</span><span class="cx">                 A182D5B31BE6BD250087A7CC /* AccessibilityIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityIOS.h; sourceTree = "<group>"; };
</span><span class="cx">                 A19DD3BF1D07D16800AC823B /* _WKWebViewPrintFormatterInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKWebViewPrintFormatterInternal.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -5161,6 +5165,8 @@
</span><span class="cx">                                 2D6AB540192B1C4A003A9FD1 /* WKPDFPageNumberIndicator.mm */,
</span><span class="cx">                                 2DA1E4FC18C02B6A00DBC929 /* WKPDFView.h */,
</span><span class="cx">                                 2DA1E4FD18C02B6A00DBC929 /* WKPDFView.mm */,
</span><ins>+                                A15EEDE41E301CEE000069B0 /* WKPasswordView.h */,
+                                A15EEDE31E301CEE000069B0 /* WKPasswordView.mm */,
</ins><span class="cx">                                 0FCB4E4418BBE044000FCFC9 /* WKScrollView.h */,
</span><span class="cx">                                 0FCB4E4518BBE044000FCFC9 /* WKScrollView.mm */,
</span><span class="cx">                                 26F10BE619187E2E001D0E68 /* WKSyntheticClickTapGestureRecognizer.h */,
</span><span class="lines">@@ -8038,6 +8044,7 @@
</span><span class="cx">                                 1AA3D75C1651B44F008713D0 /* RemoteLayerTreeHost.h in Headers */,
</span><span class="cx">                                 2DDE0AFA18298CC900F97EAA /* RemoteLayerTreePropertyApplier.h in Headers */,
</span><span class="cx">                                 0FF264A01A1FF9CC001FE759 /* RemoteLayerTreeScrollingPerformanceData.h in Headers */,
</span><ins>+                                A15EEDE61E301CEE000069B0 /* WKPasswordView.h in Headers */,
</ins><span class="cx">                                 1AF1AC6C1651759E00C17D7F /* RemoteLayerTreeTransaction.h in Headers */,
</span><span class="cx">                                 E1B78471163F24690007B692 /* RemoteNetworkingContext.h in Headers */,
</span><span class="cx">                                 1A5704FC1BE1751100874AF1 /* RemoteObjectInvocation.h in Headers */,
</span><span class="lines">@@ -9925,6 +9932,7 @@
</span><span class="cx">                                 C54256B618BEC18C00DE4179 /* WKFormInputControl.mm in Sources */,
</span><span class="cx">                                 C54256B918BEC18C00DE4179 /* WKFormPopover.mm in Sources */,
</span><span class="cx">                                 C57193BE18C14A44002D0F12 /* WKFormSelectControl.mm in Sources */,
</span><ins>+                                A15EEDE51E301CEE000069B0 /* WKPasswordView.mm in Sources */,
</ins><span class="cx">                                 C55CB5B818C2A5D600CA81E1 /* WKFormSelectPicker.mm in Sources */,
</span><span class="cx">                                 C55CB5B718C269CF00CA81E1 /* WKFormSelectPopover.mm in Sources */,
</span><span class="cx">                                 BCE469591214EDF4000B98EB /* WKFormSubmissionListener.cpp in Sources */,
</span></span></pre>
</div>
</div>
</body>
</html>