Diff
Modified: branches/safari-601.1.46-branch/Source/WebKit2/ChangeLog (193918 => 193919)
--- branches/safari-601.1.46-branch/Source/WebKit2/ChangeLog 2015-12-10 19:18:54 UTC (rev 193918)
+++ branches/safari-601.1.46-branch/Source/WebKit2/ChangeLog 2015-12-10 19:18:58 UTC (rev 193919)
@@ -1,5 +1,46 @@
2015-12-10 Matthew Hanson <[email protected]>
+ Merge r193481. rdar://problem/23110745
+
+ 2015-12-04 Gavin Barraclough <[email protected]>
+
+ Background state not being tracked correctly for PDFs on iOS
+ https://bugs.webkit.org/show_bug.cgi?id=151886
+
+ Reviewed by Anders Carlson.
+
+ The problem here is that when viewing a PDF we don't have an ApplicationStateTracker.
+ (While we do have a content view - which normally holds the ApplicationStateTracker -
+ the content view is not in a window, and only has an ApplicationStateTracker while in a
+ window). For now, let's give the WKPDFView an ApplicationStateTracker of its very own.
+ In the future we may want to refactor ownership of the ApplicationStateTracker up to
+ the WKWebView.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _isBackground]):
+ - Added, checks background state of content/PDF view.
+ * UIProcess/API/Cocoa/WKWebViewInternal.h:
+ - expose _isBackground to PageClientImplIOS.
+ * UIProcess/ApplicationStateTracker.h:
+ (WebKit::ApplicationStateTracker::isInBackground):
+ * UIProcess/ApplicationStateTracker.mm:
+ (WebKit::isBackgroundState):
+ (WebKit::ApplicationStateTracker::ApplicationStateTracker):
+ - generalize WKContentView -> UIView, so this may now also be a WKPDFView.
+ * UIProcess/ios/PageClientImplIOS.mm:
+ (WebKit::PageClientImpl::isViewVisible):
+ - check background state via the WKWebView.
+ * UIProcess/ios/WKPDFView.h:
+ * UIProcess/ios/WKPDFView.mm:
+ (-[WKPDFView willMoveToWindow:]):
+ (-[WKPDFView didMoveToWindow]):
+ (-[WKPDFView isBackground]):
+ (-[WKPDFView _applicationDidEnterBackground]):
+ (-[WKPDFView _applicationWillEnterForeground]):
+ - added methods to initialize ApplicationStateTracker, access background state, & callbacks to the page proxy.
+
+2015-12-10 Matthew Hanson <[email protected]>
+
Merge r193382. rdar://problem/23814344
2015-12-03 Simon Fraser <[email protected]>
Modified: branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (193918 => 193919)
--- branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2015-12-10 19:18:54 UTC (rev 193918)
+++ branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2015-12-10 19:18:58 UTC (rev 193919)
@@ -699,6 +699,15 @@
#pragma mark iOS-specific methods
#if PLATFORM(IOS)
+
+- (BOOL)_isBackground
+{
+ if ([self _isDisplayingPDF])
+ return [(WKPDFView *)_customContentView isBackground];
+
+ return [_contentView isBackground];
+}
+
- (void)setFrame:(CGRect)frame
{
CGRect oldFrame = self.frame;
Modified: branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h (193918 => 193919)
--- branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h 2015-12-10 19:18:54 UTC (rev 193918)
+++ branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h 2015-12-10 19:18:58 UTC (rev 193919)
@@ -109,6 +109,7 @@
- (void)_navigationGestureDidBegin;
- (void)_navigationGestureDidEnd;
+@property (nonatomic, readonly) BOOL _isBackground;
@property (nonatomic, readonly) BOOL _allowsDoubleTapGestures;
@property (nonatomic, readonly) UIEdgeInsets _computedContentInset;
#else
Modified: branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ApplicationStateTracker.h (193918 => 193919)
--- branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ApplicationStateTracker.h 2015-12-10 19:18:54 UTC (rev 193918)
+++ branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ApplicationStateTracker.h 2015-12-10 19:18:58 UTC (rev 193919)
@@ -33,13 +33,13 @@
#import <wtf/WeakPtr.h>
OBJC_CLASS BKSApplicationStateMonitor;
-OBJC_CLASS WKContentView;
+OBJC_CLASS UIView;
namespace WebKit {
class ApplicationStateTracker {
public:
- ApplicationStateTracker(WKContentView *, SEL didEnterBackgroundSelector, SEL willEnterForegroundSelector);
+ ApplicationStateTracker(UIView *, SEL didEnterBackgroundSelector, SEL willEnterForegroundSelector);
~ApplicationStateTracker();
bool isInBackground() const { return m_isInBackground; }
@@ -48,7 +48,7 @@
void applicationDidEnterBackground();
void applicationWillEnterForeground();
- WeakObjCPtr<WKContentView> m_view;
+ WeakObjCPtr<UIView> m_view;
SEL m_didEnterBackgroundSelector;
SEL m_willEnterForegroundSelector;
Modified: branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ApplicationStateTracker.mm (193918 => 193919)
--- branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ApplicationStateTracker.mm 2015-12-10 19:18:54 UTC (rev 193918)
+++ branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ApplicationStateTracker.mm 2015-12-10 19:18:58 UTC (rev 193919)
@@ -31,7 +31,6 @@
#import "AssertionServicesSPI.h"
#import "SandboxUtilities.h"
#import "UIKitSPI.h"
-#import "WKContentView.h"
#import <WebCore/SecuritySPI.h>
#import <wtf/NeverDestroyed.h>
#import <wtf/ObjcRuntimeExtras.h>
@@ -74,7 +73,7 @@
}
}
-ApplicationStateTracker::ApplicationStateTracker(WKContentView *view, SEL didEnterBackgroundSelector, SEL willEnterForegroundSelector)
+ApplicationStateTracker::ApplicationStateTracker(UIView *view, SEL didEnterBackgroundSelector, SEL willEnterForegroundSelector)
: m_view(view)
, m_didEnterBackgroundSelector(didEnterBackgroundSelector)
, m_willEnterForegroundSelector(willEnterForegroundSelector)
Modified: branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm (193918 => 193919)
--- branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm 2015-12-10 19:18:54 UTC (rev 193918)
+++ branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm 2015-12-10 19:18:58 UTC (rev 193919)
@@ -182,7 +182,7 @@
bool PageClientImpl::isViewVisible()
{
- if (isViewInWindow() && !m_contentView.isBackground)
+ if (isViewInWindow() && !m_webView._isBackground)
return true;
if ([m_webView _isShowingVideoPictureInPicture])
Modified: branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/WKPDFView.h (193918 => 193919)
--- branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/WKPDFView.h 2015-12-10 19:18:54 UTC (rev 193918)
+++ branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/WKPDFView.h 2015-12-10 19:18:58 UTC (rev 193919)
@@ -34,6 +34,7 @@
@property (nonatomic, readonly) NSString *suggestedFilename;
@property (nonatomic, readonly) CGPDFDocumentRef pdfDocument;
+@property (nonatomic, readonly) BOOL isBackground;
@end
Modified: branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/WKPDFView.mm (193918 => 193919)
--- branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/WKPDFView.mm 2015-12-10 19:18:54 UTC (rev 193918)
+++ branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/WKPDFView.mm 2015-12-10 19:18:58 UTC (rev 193919)
@@ -30,6 +30,7 @@
#import "APIFindClient.h"
#import "APIUIClient.h"
+#import "ApplicationStateTracker.h"
#import "CorePDFSPI.h"
#import "SessionState.h"
#import "UIKitSPI.h"
@@ -45,6 +46,7 @@
#import <wtf/Vector.h>
using namespace WebCore;
+using namespace WebKit;
const CGFloat pdfPageMargin = 8;
const CGFloat pdfMinimumZoomScale = 1;
@@ -105,6 +107,8 @@
_WKFindOptions _nextCachedFindOptionsAffectingResults;
dispatch_queue_t _findQueue;
+
+ std::unique_ptr<ApplicationStateTracker> _applicationStateTracker;
}
- (instancetype)web_initWithFrame:(CGRect)frame webView:(WKWebView *)webView
@@ -834,6 +838,47 @@
return NO;
}
+- (void)willMoveToWindow:(UIWindow *)newWindow
+{
+ if (newWindow)
+ return;
+
+ ASSERT(self.window);
+ ASSERT(_applicationStateTracker);
+ _applicationStateTracker = nullptr;
+}
+
+- (void)didMoveToWindow
+{
+ if (!self.window)
+ return;
+
+ ASSERT(!_applicationStateTracker);
+ _applicationStateTracker = std::make_unique<ApplicationStateTracker>(self, @selector(_applicationDidEnterBackground), @selector(_applicationWillEnterForeground));
+}
+
+- (BOOL)isBackground
+{
+ if (!_applicationStateTracker)
+ return YES;
+
+ return _applicationStateTracker->isInBackground();
+}
+
+- (void)_applicationDidEnterBackground
+{
+ _webView->_page->applicationDidEnterBackground();
+ _webView->_page->viewStateDidChange(ViewState::AllFlags & ~ViewState::IsInWindow);
+}
+
+- (void)_applicationWillEnterForeground
+{
+ _webView->_page->applicationWillEnterForeground();
+ if (auto drawingArea = _webView->_page->drawingArea())
+ drawingArea->hideContentUntilAnyUpdate();
+ _webView->_page->viewStateDidChange(ViewState::AllFlags & ~ViewState::IsInWindow, true, WebPageProxy::ViewStateChangeDispatchMode::Immediate);
+}
+
@end
#endif /* PLATFORM(IOS) */