From 4c9bbea03508009017b44a5a6f4388f1a6130e44 Mon Sep 17 00:00:00 2001 From: "andersca@apple.com" Date: Mon, 16 Apr 2012 21:02:49 +0000 Subject: [PATCH] Nightly Back/Forward no longer calls plug-in's NPP_NewStream https://bugs.webkit.org/show_bug.cgi?id=83805 Reviewed by Simon Fraser. When a page with a full-frame plug-in is restored from the page cache, it needs to re-fetch the plug-in stream. Fix this by breaking the assumption that a plug-in will always get its data from WebCore if it's a full-frame plug-in; instead it only get its data from WebCore if it's a full-frame plug-in that's not being restored from the page cache. * WebProcess/Plugins/Netscape/NetscapePlugin.cpp: (WebKit::NetscapePlugin::NetscapePlugin): Rename m_loadManually to m_shouldUseManualLoader. (WebKit::NetscapePlugin::initialize): Get the mode from parameters.isFullFramePlugin instead. (WebKit::NetscapePlugin::manualStreamDidReceiveResponse): (WebKit::NetscapePlugin::manualStreamDidReceiveData): (WebKit::NetscapePlugin::manualStreamDidFinishLoading): (WebKit::NetscapePlugin::manualStreamDidFail): Rename m_loadManually to m_shouldUseManualLoader. * WebProcess/Plugins/Netscape/NetscapePlugin.h: Rename m_loadManually to m_shouldUseManualLoader. * WebProcess/Plugins/Plugin.cpp: (WebKit::Plugin::Parameters::encode): (WebKit::Plugin::Parameters::decode): * WebProcess/Plugins/Plugin.h: (Parameters): Add an extra isFullFramePlugin parameter, and rename loadManually to shouldUseManualLoader. * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: (WebKit::WebFrameLoaderClient::WebFrameLoaderClient): Initialize m_frameCameFromPageCache. (WebKit::WebFrameLoaderClient::transitionToCommittedFromCachedFrame): Set m_frameCameFromPageCache to true. (WebKit::WebFrameLoaderClient::transitionToCommittedForNewPage): Set m_frameCameFromPageCache to false. (WebKit::WebFrameLoaderClient::createPlugin): Initialize isFullFramePlugin and shouldUseManualLoader. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@114295 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebKit2/ChangeLog | 49 ++++++++++++++++++++++ .../WebProcess/Plugins/Netscape/NetscapePlugin.cpp | 16 +++---- .../WebProcess/Plugins/Netscape/NetscapePlugin.h | 2 +- .../WebProcess/Plugins/PDF/BuiltInPDFView.cpp | 2 +- Source/WebKit2/WebProcess/Plugins/Plugin.cpp | 7 +++- Source/WebKit2/WebProcess/Plugins/Plugin.h | 3 +- .../WebCoreSupport/WebFrameLoaderClient.cpp | 6 ++- .../WebCoreSupport/WebFrameLoaderClient.h | 1 + 8 files changed, 72 insertions(+), 14 deletions(-) diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog index 172ec9f..877c306 100644 --- a/Source/WebKit2/ChangeLog +++ b/Source/WebKit2/ChangeLog @@ -1,3 +1,52 @@ +2012-04-16 Anders Carlsson + + Nightly Back/Forward no longer calls plug-in's NPP_NewStream + https://bugs.webkit.org/show_bug.cgi?id=83805 + + + Reviewed by Simon Fraser. + + When a page with a full-frame plug-in is restored from the page cache, it needs to re-fetch the plug-in stream. + + Fix this by breaking the assumption that a plug-in will always get its data from WebCore if it's a full-frame plug-in; + instead it only get its data from WebCore if it's a full-frame plug-in that's not being restored from the page cache. + + * WebProcess/Plugins/Netscape/NetscapePlugin.cpp: + (WebKit::NetscapePlugin::NetscapePlugin): + Rename m_loadManually to m_shouldUseManualLoader. + + (WebKit::NetscapePlugin::initialize): + Get the mode from parameters.isFullFramePlugin instead. + + (WebKit::NetscapePlugin::manualStreamDidReceiveResponse): + (WebKit::NetscapePlugin::manualStreamDidReceiveData): + (WebKit::NetscapePlugin::manualStreamDidFinishLoading): + (WebKit::NetscapePlugin::manualStreamDidFail): + Rename m_loadManually to m_shouldUseManualLoader. + + * WebProcess/Plugins/Netscape/NetscapePlugin.h: + Rename m_loadManually to m_shouldUseManualLoader. + + * WebProcess/Plugins/Plugin.cpp: + (WebKit::Plugin::Parameters::encode): + (WebKit::Plugin::Parameters::decode): + * WebProcess/Plugins/Plugin.h: + (Parameters): + Add an extra isFullFramePlugin parameter, and rename loadManually to shouldUseManualLoader. + + * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: + (WebKit::WebFrameLoaderClient::WebFrameLoaderClient): + Initialize m_frameCameFromPageCache. + + (WebKit::WebFrameLoaderClient::transitionToCommittedFromCachedFrame): + Set m_frameCameFromPageCache to true. + + (WebKit::WebFrameLoaderClient::transitionToCommittedForNewPage): + Set m_frameCameFromPageCache to false. + + (WebKit::WebFrameLoaderClient::createPlugin): + Initialize isFullFramePlugin and shouldUseManualLoader. + 2012-04-16 Alexey Proskuryakov EndPrinting message should be sent synchronously when printing was initiated from DOM. diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp index e62d539..db6d8d8 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp @@ -68,7 +68,7 @@ NetscapePlugin::NetscapePlugin(PassRefPtr pluginModule) #endif , m_isTransparent(false) , m_inNPPNew(false) - , m_loadManually(false) + , m_shouldUseManualLoader(false) , m_nextTimerID(0) #if PLATFORM(MAC) , m_drawingModel(static_cast(-1)) @@ -543,9 +543,9 @@ bool NetscapePlugin::allowPopups() const bool NetscapePlugin::initialize(const Parameters& parameters) { - uint16_t mode = parameters.loadManually ? NP_FULL : NP_EMBED; + uint16_t mode = parameters.isFullFramePlugin ? NP_FULL : NP_EMBED; - m_loadManually = parameters.loadManually; + m_shouldUseManualLoader = parameters.shouldUseManualLoader; CString mimeTypeCString = parameters.mimeType.utf8(); @@ -611,7 +611,7 @@ bool NetscapePlugin::initialize(const Parameters& parameters) } // Load the src URL if needed. - if (!parameters.loadManually && !parameters.url.isEmpty() && shouldLoadSrcURL()) + if (!parameters.shouldUseManualLoader && !parameters.url.isEmpty() && shouldLoadSrcURL()) loadURL("GET", parameters.url.string(), String(), HTTPHeaderMap(), Vector(), false, 0); return true; @@ -787,7 +787,7 @@ void NetscapePlugin::manualStreamDidReceiveResponse(const KURL& responseURL, uin const String& mimeType, const String& headers, const String& /* suggestedFileName */) { ASSERT(m_isStarted); - ASSERT(m_loadManually); + ASSERT(m_shouldUseManualLoader); ASSERT(!m_manualStream); m_manualStream = NetscapePluginStream::create(this, 0, responseURL.string(), false, 0); @@ -797,7 +797,7 @@ void NetscapePlugin::manualStreamDidReceiveResponse(const KURL& responseURL, uin void NetscapePlugin::manualStreamDidReceiveData(const char* bytes, int length) { ASSERT(m_isStarted); - ASSERT(m_loadManually); + ASSERT(m_shouldUseManualLoader); ASSERT(m_manualStream); m_manualStream->didReceiveData(bytes, length); @@ -806,7 +806,7 @@ void NetscapePlugin::manualStreamDidReceiveData(const char* bytes, int length) void NetscapePlugin::manualStreamDidFinishLoading() { ASSERT(m_isStarted); - ASSERT(m_loadManually); + ASSERT(m_shouldUseManualLoader); ASSERT(m_manualStream); m_manualStream->didFinishLoading(); @@ -815,7 +815,7 @@ void NetscapePlugin::manualStreamDidFinishLoading() void NetscapePlugin::manualStreamDidFail(bool wasCancelled) { ASSERT(m_isStarted); - ASSERT(m_loadManually); + ASSERT(m_shouldUseManualLoader); if (!m_manualStream) return; diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h index d4ca901..569ffd7 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h @@ -263,7 +263,7 @@ private: bool m_isWindowed; bool m_isTransparent; bool m_inNPPNew; - bool m_loadManually; + bool m_shouldUseManualLoader; RefPtr m_manualStream; Vector m_popupEnabledStates; diff --git a/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.cpp b/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.cpp index 5794699..95026ee 100644 --- a/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.cpp +++ b/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.cpp @@ -331,7 +331,7 @@ bool BuiltInPDFView::initialize(const Parameters& parameters) { // Load the src URL if needed. m_sourceURL = parameters.url; - if (!parameters.loadManually && !parameters.url.isEmpty()) + if (!parameters.shouldUseManualLoader && !parameters.url.isEmpty()) controller()->loadURL(pdfDocumentRequestID, "GET", parameters.url.string(), String(), HTTPHeaderMap(), Vector(), false); return true; diff --git a/Source/WebKit2/WebProcess/Plugins/Plugin.cpp b/Source/WebKit2/WebProcess/Plugins/Plugin.cpp index 88e828d..bc884b9 100644 --- a/Source/WebKit2/WebProcess/Plugins/Plugin.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Plugin.cpp @@ -38,7 +38,8 @@ void Plugin::Parameters::encode(CoreIPC::ArgumentEncoder* encoder) const encoder->encode(names); encoder->encode(values); encoder->encode(mimeType); - encoder->encode(loadManually); + encoder->encode(isFullFramePlugin); + encoder->encode(shouldUseManualLoader); #if PLATFORM(MAC) encoder->encodeEnum(layerHostingMode); #endif @@ -58,7 +59,9 @@ bool Plugin::Parameters::decode(CoreIPC::ArgumentDecoder* decoder, Parameters& p return false; if (!decoder->decode(parameters.mimeType)) return false; - if (!decoder->decode(parameters.loadManually)) + if (!decoder->decode(parameters.isFullFramePlugin)) + return false; + if (!decoder->decode(parameters.shouldUseManualLoader)) return false; #if PLATFORM(MAC) if (!decoder->decodeEnum(parameters.layerHostingMode)) diff --git a/Source/WebKit2/WebProcess/Plugins/Plugin.h b/Source/WebKit2/WebProcess/Plugins/Plugin.h index 405258a..b16239b 100644 --- a/Source/WebKit2/WebProcess/Plugins/Plugin.h +++ b/Source/WebKit2/WebProcess/Plugins/Plugin.h @@ -68,7 +68,8 @@ public: Vector names; Vector values; String mimeType; - bool loadManually; + bool isFullFramePlugin; + bool shouldUseManualLoader; #if PLATFORM(MAC) LayerHostingMode layerHostingMode; #endif diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp index 9e7c6be..dc96163 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp @@ -78,6 +78,7 @@ WebFrameLoaderClient::WebFrameLoaderClient(WebFrame* frame) : m_frame(frame) , m_hasSentResponseToPluginView(false) , m_frameHasCustomRepresentation(false) + , m_frameCameFromPageCache(false) { } @@ -1165,6 +1166,7 @@ void WebFrameLoaderClient::transitionToCommittedFromCachedFrame(CachedFrame*) const ResourceResponse& response = m_frame->coreFrame()->loader()->documentLoader()->response(); m_frameHasCustomRepresentation = isMainFrame && WebProcess::shared().shouldUseCustomRepresentationForResponse(response); + m_frameCameFromPageCache = true; } void WebFrameLoaderClient::transitionToCommittedForNewPage() @@ -1177,6 +1179,7 @@ void WebFrameLoaderClient::transitionToCommittedForNewPage() const ResourceResponse& response = m_frame->coreFrame()->loader()->documentLoader()->response(); m_frameHasCustomRepresentation = isMainFrame && WebProcess::shared().shouldUseCustomRepresentationForResponse(response); + m_frameCameFromPageCache = false; m_frame->coreFrame()->createView(webPage->size(), backgroundColor, /* transparent */ false, IntSize(), shouldUseFixedLayout); m_frame->coreFrame()->view()->setTransparent(!webPage->drawsBackground()); @@ -1267,7 +1270,8 @@ PassRefPtr WebFrameLoaderClient::createPlugin(const IntSize&, HTMLPlugIn parameters.names = paramNames; parameters.values = paramValues; parameters.mimeType = mimeType; - parameters.loadManually = loadManually; + parameters.isFullFramePlugin = loadManually; + parameters.shouldUseManualLoader = parameters.isFullFramePlugin && !m_frameCameFromPageCache; #if PLATFORM(MAC) parameters.layerHostingMode = webPage->layerHostingMode(); #endif diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h index 3c7d5bf..b2e1f14 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h @@ -221,6 +221,7 @@ private: RefPtr m_pluginView; bool m_hasSentResponseToPluginView; bool m_frameHasCustomRepresentation; + bool m_frameCameFromPageCache; }; } // namespace WebKit -- 2.7.4