Diff
Modified: branches/safari-601.1-branch/Source/WebKit2/ChangeLog (188094 => 188095)
--- branches/safari-601.1-branch/Source/WebKit2/ChangeLog 2015-08-06 23:48:16 UTC (rev 188094)
+++ branches/safari-601.1-branch/Source/WebKit2/ChangeLog 2015-08-06 23:48:19 UTC (rev 188095)
@@ -1,5 +1,54 @@
2015-08-06 Dana Burkart <dburk...@apple.com>
+ Merge r188011. rdar://problem/22055130
+
+ 2015-08-05 Tim Horton <timothy_hor...@apple.com>
+
+ PDFPlugins are clipped in link previews (and remain so when opened)
+ https://bugs.webkit.org/show_bug.cgi?id=147708
+ <rdar://problem/22055130>
+
+ Reviewed by Simon Fraser.
+
+ * UIProcess/API/mac/WKView.mm:
+ (-[WKView initWithFrame:processPool:configuration:webView:]):
+ (-[WKView _supportsArbitraryLayoutModes]):
+ (-[WKView _didCommitLoadForMainFrame]):
+ (-[WKView _setLayoutMode:]):
+ (-[WKView _setViewScale:]):
+ Avoid using any layout mode other than "ViewSize" for main frame PluginDocuments,
+ because they will often end up behaving incorrectly (especially with PDFPlugin,
+ which is even more special in that it takes over application of page scale).
+
+ Save any incoming changes to the viewScale and layoutMode, and re-apply
+ them once we load something in the main frame that is *not* a PluginDocument.
+
+ * UIProcess/API/mac/WKViewInternal.h:
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::scalePage):
+ Make sure to reset WebCore's page scale if the main frame contains a
+ PluginDocument that takes care of page scale itself.
+
+ (WebKit::WebPage::didCommitLoad):
+ Do the same thing as what we do in WKView _didCommitLoadForMainFrame,
+ but without the UI process round-trip, to avoid an ugly flash.
+
+ * UIProcess/WebFrameProxy.cpp:
+ (WebKit::WebFrameProxy::didCommitLoad):
+ * UIProcess/WebFrameProxy.h:
+ (WebKit::WebFrameProxy::containsPluginDocument):
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::didCommitLoadForFrame):
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebPageProxy.messages.in:
+ * UIProcess/mac/PageClientImpl.mm:
+ (WebKit::PageClientImpl::didCommitLoadForMainFrame):
+ * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+ (WebKit::WebFrameLoaderClient::dispatchDidCommitLoad):
+ Plumb and keep track of whether the main frame contains a PluginDocument or not.
+
+2015-08-06 Dana Burkart <dburk...@apple.com>
+
Merge r187962. rdar://problem/21827815
2015-08-05 Daniel Bates <daba...@apple.com>
Modified: branches/safari-601.1-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm (188094 => 188095)
--- branches/safari-601.1-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm 2015-08-06 23:48:16 UTC (rev 188094)
+++ branches/safari-601.1-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm 2015-08-06 23:48:19 UTC (rev 188095)
@@ -264,6 +264,8 @@
BOOL _allowsLinkPreview;
RetainPtr<WKViewLayoutStrategy> _layoutStrategy;
+ WKLayoutMode _lastRequestedLayoutMode;
+ float _lastRequestedViewScale;
CGSize _minimumViewSize;
RetainPtr<CALayer> _rootLayer;
@@ -3776,6 +3778,8 @@
_data->_clipsToVisibleRect = NO;
_data->_useContentPreparationRectForVisibleRect = NO;
_data->_windowOcclusionDetectionEnabled = YES;
+ _data->_lastRequestedLayoutMode = kWKLayoutModeViewSize;
+ _data->_lastRequestedViewScale = 1;
_data->_windowVisibilityObserver = adoptNS([[WKWindowVisibilityObserver alloc] initWithView:self]);
@@ -3894,6 +3898,41 @@
_data->_gestureController->didFirstVisuallyNonEmptyLayoutForMainFrame();
}
+- (BOOL)_supportsArbitraryLayoutModes
+{
+ WebPageProxy* page = _data->_page.get();
+ if (!page)
+ return YES;
+ WebFrameProxy* frame = page->mainFrame();
+ if (!frame)
+ return YES;
+
+ // If we have a plugin document in the main frame, avoid using custom WKLayoutModes
+ // and fall back to the defaults, because there's a good chance that it won't work (e.g. with PDFPlugin).
+ if (frame->containsPluginDocument())
+ return NO;
+
+ return YES;
+}
+
+- (void)_didCommitLoadForMainFrame
+{
+ if (![self _supportsArbitraryLayoutModes]) {
+ WKLayoutMode oldRequestedLayoutMode = _data->_lastRequestedLayoutMode;
+ float oldRequestedViewScale = _data->_lastRequestedViewScale;
+ [self _setViewScale:1];
+ [self _setLayoutMode:kWKLayoutModeViewSize];
+
+ // The 'last requested' parameters will have been overwritten by setting them above, but we don't
+ // want this to count as a request (only changes from the client count), so reset them.
+ _data->_lastRequestedLayoutMode = oldRequestedLayoutMode;
+ _data->_lastRequestedViewScale = oldRequestedViewScale;
+ } else if (_data->_lastRequestedLayoutMode != [_data->_layoutStrategy layoutMode]) {
+ [self _setViewScale:_data->_lastRequestedViewScale];
+ [self _setLayoutMode:_data->_lastRequestedLayoutMode];
+ }
+}
+
- (void)_didFinishLoadForMainFrame
{
if (_data->_gestureController)
@@ -4302,6 +4341,11 @@
- (void)_setLayoutMode:(WKLayoutMode)layoutMode
{
+ _data->_lastRequestedLayoutMode = layoutMode;
+
+ if (![self _supportsArbitraryLayoutModes] && layoutMode != kWKLayoutModeViewSize)
+ return;
+
if (layoutMode == [_data->_layoutStrategy layoutMode])
return;
@@ -4326,6 +4370,11 @@
- (void)_setViewScale:(CGFloat)viewScale
{
+ _data->_lastRequestedViewScale = viewScale;
+
+ if (![self _supportsArbitraryLayoutModes] && viewScale != 1)
+ return;
+
if (viewScale <= 0 || isnan(viewScale) || isinf(viewScale))
[NSException raise:NSInvalidArgumentException format:@"View scale should be a positive number"];
Modified: branches/safari-601.1-branch/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h (188094 => 188095)
--- branches/safari-601.1-branch/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h 2015-08-06 23:48:16 UTC (rev 188094)
+++ branches/safari-601.1-branch/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h 2015-08-06 23:48:19 UTC (rev 188095)
@@ -119,6 +119,7 @@
- (BOOL)_suppressVisibilityUpdates;
- (void)_didFirstVisuallyNonEmptyLayoutForMainFrame;
+- (void)_didCommitLoadForMainFrame;
- (void)_didFinishLoadForMainFrame;
- (void)_didFailLoadForMainFrame;
- (void)_didSameDocumentNavigationForMainFrame:(WebKit::SameDocumentNavigationType)type;
Modified: branches/safari-601.1-branch/Source/WebKit2/UIProcess/WebFrameProxy.cpp (188094 => 188095)
--- branches/safari-601.1-branch/Source/WebKit2/UIProcess/WebFrameProxy.cpp 2015-08-06 23:48:16 UTC (rev 188094)
+++ branches/safari-601.1-branch/Source/WebKit2/UIProcess/WebFrameProxy.cpp 2015-08-06 23:48:19 UTC (rev 188095)
@@ -144,7 +144,7 @@
m_frameLoadState.didFailProvisionalLoad();
}
-void WebFrameProxy::didCommitLoad(const String& contentType, WebCertificateInfo& certificateInfo)
+void WebFrameProxy::didCommitLoad(const String& contentType, WebCertificateInfo& certificateInfo, bool containsPluginDocument)
{
m_frameLoadState.didCommitLoad();
@@ -152,6 +152,7 @@
m_MIMEType = contentType;
m_isFrameSet = false;
m_certificateInfo = &certificateInfo;
+ m_containsPluginDocument = containsPluginDocument;
}
void WebFrameProxy::didFinishLoad()
Modified: branches/safari-601.1-branch/Source/WebKit2/UIProcess/WebFrameProxy.h (188094 => 188095)
--- branches/safari-601.1-branch/Source/WebKit2/UIProcess/WebFrameProxy.h 2015-08-06 23:48:16 UTC (rev 188094)
+++ branches/safari-601.1-branch/Source/WebKit2/UIProcess/WebFrameProxy.h 2015-08-06 23:48:19 UTC (rev 188095)
@@ -88,6 +88,7 @@
const String& unreachableURL() const { return m_frameLoadState.unreachableURL(); }
const String& mimeType() const { return m_MIMEType; }
+ bool containsPluginDocument() const { return m_containsPluginDocument; }
const String& title() const { return m_title; }
@@ -108,7 +109,7 @@
void didStartProvisionalLoad(const String& url);
void didReceiveServerRedirectForProvisionalLoad(const String& url);
void didFailProvisionalLoad();
- void didCommitLoad(const String& contentType, WebCertificateInfo&);
+ void didCommitLoad(const String& contentType, WebCertificateInfo&, bool containsPluginDocument);
void didFinishLoad();
void didFailLoad();
void didSameDocumentNavigation(const String&); // eg. anchor navigation, session state change.
@@ -134,6 +135,7 @@
String m_MIMEType;
String m_title;
bool m_isFrameSet;
+ bool m_containsPluginDocument { false };
RefPtr<WebCertificateInfo> m_certificateInfo;
RefPtr<WebFrameListenerProxy> m_activeListener;
uint64_t m_frameID;
Modified: branches/safari-601.1-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp (188094 => 188095)
--- branches/safari-601.1-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp 2015-08-06 23:48:16 UTC (rev 188094)
+++ branches/safari-601.1-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp 2015-08-06 23:48:19 UTC (rev 188095)
@@ -2973,7 +2973,7 @@
}
}
-void WebPageProxy::didCommitLoadForFrame(uint64_t frameID, uint64_t navigationID, const String& mimeType, bool frameHasCustomContentProvider, uint32_t opaqueFrameLoadType, const WebCore::CertificateInfo& certificateInfo, const UserData& userData)
+void WebPageProxy::didCommitLoadForFrame(uint64_t frameID, uint64_t navigationID, const String& mimeType, bool frameHasCustomContentProvider, uint32_t opaqueFrameLoadType, const WebCore::CertificateInfo& certificateInfo, bool containsPluginDocument, const UserData& userData)
{
PageClientProtector protector(m_pageClient);
@@ -3010,7 +3010,7 @@
clearLoadDependentCallbacks();
- frame->didCommitLoad(mimeType, webCertificateInfo);
+ frame->didCommitLoad(mimeType, webCertificateInfo, containsPluginDocument);
if (frame->isMainFrame()) {
m_mainFrameHasCustomContentProvider = frameHasCustomContentProvider;
Modified: branches/safari-601.1-branch/Source/WebKit2/UIProcess/WebPageProxy.h (188094 => 188095)
--- branches/safari-601.1-branch/Source/WebKit2/UIProcess/WebPageProxy.h 2015-08-06 23:48:16 UTC (rev 188094)
+++ branches/safari-601.1-branch/Source/WebKit2/UIProcess/WebPageProxy.h 2015-08-06 23:48:19 UTC (rev 188095)
@@ -1125,7 +1125,7 @@
void didReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, const String&, const UserData&);
void didChangeProvisionalURLForFrame(uint64_t frameID, uint64_t navigationID, const String& url);
void didFailProvisionalLoadForFrame(uint64_t frameID, const SecurityOriginData& frameSecurityOrigin, uint64_t navigationID, const String& provisionalURL, const WebCore::ResourceError&, const UserData&);
- void didCommitLoadForFrame(uint64_t frameID, uint64_t navigationID, const String& mimeType, bool frameHasCustomContentProvider, uint32_t frameLoadType, const WebCore::CertificateInfo&, const UserData&);
+ void didCommitLoadForFrame(uint64_t frameID, uint64_t navigationID, const String& mimeType, bool frameHasCustomContentProvider, uint32_t frameLoadType, const WebCore::CertificateInfo&, bool containsPluginDocument, const UserData&);
void didFinishDocumentLoadForFrame(uint64_t frameID, uint64_t navigationID, const UserData&);
void didFinishLoadForFrame(uint64_t frameID, uint64_t navigationID, const UserData&);
void didFailLoadForFrame(uint64_t frameID, uint64_t navigationID, const WebCore::ResourceError&, const UserData&);
Modified: branches/safari-601.1-branch/Source/WebKit2/UIProcess/WebPageProxy.messages.in (188094 => 188095)
--- branches/safari-601.1-branch/Source/WebKit2/UIProcess/WebPageProxy.messages.in 2015-08-06 23:48:16 UTC (rev 188094)
+++ branches/safari-601.1-branch/Source/WebKit2/UIProcess/WebPageProxy.messages.in 2015-08-06 23:48:19 UTC (rev 188095)
@@ -130,7 +130,7 @@
DidReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, String url, WebKit::UserData userData)
DidChangeProvisionalURLForFrame(uint64_t frameID, uint64_t navigationID, String url)
DidFailProvisionalLoadForFrame(uint64_t frameID, struct WebKit::SecurityOriginData frameSecurityOrigin, uint64_t navigationID, String provisionalURL, WebCore::ResourceError error, WebKit::UserData userData)
- DidCommitLoadForFrame(uint64_t frameID, uint64_t navigationID, String mimeType, bool hasCustomContentProvider, uint32_t loadType, WebCore::CertificateInfo certificateInfo, WebKit::UserData userData)
+ DidCommitLoadForFrame(uint64_t frameID, uint64_t navigationID, String mimeType, bool hasCustomContentProvider, uint32_t loadType, WebCore::CertificateInfo certificateInfo, bool containsPluginDocument, WebKit::UserData userData)
DidFailLoadForFrame(uint64_t frameID, uint64_t navigationID, WebCore::ResourceError error, WebKit::UserData userData)
DidFinishDocumentLoadForFrame(uint64_t frameID, uint64_t navigationID, WebKit::UserData userData)
DidFinishLoadForFrame(uint64_t frameID, uint64_t navigationID, WebKit::UserData userData)
Modified: branches/safari-601.1-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.mm (188094 => 188095)
--- branches/safari-601.1-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.mm 2015-08-06 23:48:16 UTC (rev 188094)
+++ branches/safari-601.1-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.mm 2015-08-06 23:48:19 UTC (rev 188095)
@@ -311,6 +311,7 @@
void PageClientImpl::didCommitLoadForMainFrame(const String& mimeType, bool useCustomContentProvider)
{
+ [m_wkView _didCommitLoadForMainFrame];
}
void PageClientImpl::didFinishLoadingDataForCustomContentProvider(const String& suggestedFilename, const IPC::DataReference& dataReference)
Modified: branches/safari-601.1-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (188094 => 188095)
--- branches/safari-601.1-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp 2015-08-06 23:48:16 UTC (rev 188094)
+++ branches/safari-601.1-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp 2015-08-06 23:48:19 UTC (rev 188095)
@@ -464,7 +464,7 @@
// Notify the UIProcess.
- webPage->send(Messages::WebPageProxy::DidCommitLoadForFrame(m_frame->frameID(), documentLoader.navigationID(), documentLoader.response().mimeType(), m_frameHasCustomContentProvider, static_cast<uint32_t>(m_frame->coreFrame()->loader().loadType()), documentLoader.response().certificateInfo(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
+ webPage->send(Messages::WebPageProxy::DidCommitLoadForFrame(m_frame->frameID(), documentLoader.navigationID(), documentLoader.response().mimeType(), m_frameHasCustomContentProvider, static_cast<uint32_t>(m_frame->coreFrame()->loader().loadType()), documentLoader.response().certificateInfo(), m_frame->coreFrame()->document()->isPluginDocument(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
webPage->didCommitLoad(m_frame);
}
Modified: branches/safari-601.1-branch/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (188094 => 188095)
--- branches/safari-601.1-branch/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2015-08-06 23:48:16 UTC (rev 188094)
+++ branches/safari-601.1-branch/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2015-08-06 23:48:19 UTC (rev 188095)
@@ -1405,6 +1405,14 @@
#endif
PluginView* pluginView = pluginViewForFrame(&m_page->mainFrame());
if (pluginView && pluginView->handlesPageScaleFactor()) {
+ // If the main-frame plugin wants to handle the page scale factor, make sure to reset WebCore's page scale.
+ // Otherwise, we can end up with an immutable but non-1 page scale applied by WebCore on top of whatever the plugin does.
+ if (m_page->pageScaleFactor() != 1) {
+ m_page->setPageScaleFactor(1, origin);
+ for (auto* pluginView : m_pluginViews)
+ pluginView->pageScaleFactorDidChange();
+ }
+
pluginView->setPageScaleFactor(totalScale, origin);
return;
}
@@ -4644,6 +4652,17 @@
if (frame->coreFrame()->loader().loadType() == FrameLoadType::Standard) {
Page* page = frame->coreFrame()->page();
+#if PLATFORM(MAC)
+ // As a very special case, we disable non-default layout modes in WKView for main-frame PluginDocuments.
+ // Ideally we would only worry about this in WKView or the WKViewLayoutStrategies, but if we allow
+ // a round-trip to the UI process, you'll see the wrong scale temporarily. So, we reset it here, and then
+ // again later from the UI process.
+ if (frame->coreFrame()->document()->isPluginDocument()) {
+ scaleView(1);
+ setUseFixedLayout(false);
+ }
+#endif
+
if (page && page->pageScaleFactor() != 1)
scalePage(1, IntPoint());
}