[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
andersca at apple.com
andersca at apple.com
Wed Dec 22 11:39:11 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 36607b90bfe7bd7ff12ec20f23dc40af0471bc10
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Aug 2 21:32:11 2010 +0000
Add support for loading manual streams
https://bugs.webkit.org/show_bug.cgi?id=43380
Reviewed by Sam Weinig.
* WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
(WebKit::NetscapePlugin::NetscapePlugin):
Initialize m_loadManually to false.
(WebKit::NetscapePlugin::removePluginStream):
Special case the manual stream.
(WebKit::NetscapePlugin::initialize):
Don't request the stream if we're already loading.
(WebKit::NetscapePlugin::manualStreamDidReceiveResponse):
Create the manual stream and pass the response to it.
(WebKit::NetscapePlugin::manualStreamDidReceiveData):
Pass the data to the manual stream.
(WebKit::NetscapePlugin::manualStreamDidFinishLoading):
Call the manual stream.
(WebKit::NetscapePlugin::manualStreamDidFail):
Ditto.
* WebProcess/Plugins/Plugin.h:
Add pure virtual member functions for manual stream loading.
* WebProcess/Plugins/PluginView.cpp:
(WebKit::buildHTTPHeaders):
Put code in a function so both PluginView::Stream::didReceiveResponse and
manualLoadDidReceiveResponse can call it.
(WebKit::PluginView::Stream::didReceiveResponse):
Call buildHTTPHeaders.
(WebKit::PluginView::Stream::didFinishLoading):
Protect the plug-in when calling destroyStream.
(WebKit::PluginView::manualLoadDidReceiveResponse):
Call Plugin::manualStreamDidReceiveResponse.
(WebKit::PluginView::manualLoadDidReceiveData):
Call Plugin::manualStreamDidReceiveData.
(WebKit::PluginView::manualLoadDidFinishLoading):
Call Plugin::manualStreamDidFinishLoading.
(WebKit::PluginView::manualLoadDidFail):
Call Plugin::manualStreamDidFail.
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::WebFrameLoaderClient):
Initialize m_hasSentResponseToPluginView to false.
(WebKit::WebFrameLoaderClient::setMainDocumentError):
Call PluginView::manualLoadDidFail.
(WebKit::WebFrameLoaderClient::committedLoad):
Call PluginView::manualLoadDidReceiveResponse.
(WebKit::WebFrameLoaderClient::finishedLoading):
Call PluginView::manualLoadDidFinishLoading.
(WebKit::WebFrameLoaderClient::redirectDataToPlugin):
Keep track of the plug-in view.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64494 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index ef68846..5d93c9b 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,74 @@
+2010-08-02 Anders Carlsson <andersca at apple.com>
+
+ Reviewed by Sam Weinig.
+
+ Add support for loading manual streams
+ https://bugs.webkit.org/show_bug.cgi?id=43380
+
+ * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+ (WebKit::NetscapePlugin::NetscapePlugin):
+ Initialize m_loadManually to false.
+
+ (WebKit::NetscapePlugin::removePluginStream):
+ Special case the manual stream.
+
+ (WebKit::NetscapePlugin::initialize):
+ Don't request the stream if we're already loading.
+
+ (WebKit::NetscapePlugin::manualStreamDidReceiveResponse):
+ Create the manual stream and pass the response to it.
+
+ (WebKit::NetscapePlugin::manualStreamDidReceiveData):
+ Pass the data to the manual stream.
+
+ (WebKit::NetscapePlugin::manualStreamDidFinishLoading):
+ Call the manual stream.
+
+ (WebKit::NetscapePlugin::manualStreamDidFail):
+ Ditto.
+
+ * WebProcess/Plugins/Plugin.h:
+ Add pure virtual member functions for manual stream loading.
+
+ * WebProcess/Plugins/PluginView.cpp:
+ (WebKit::buildHTTPHeaders):
+ Put code in a function so both PluginView::Stream::didReceiveResponse and
+ manualLoadDidReceiveResponse can call it.
+
+ (WebKit::PluginView::Stream::didReceiveResponse):
+ Call buildHTTPHeaders.
+
+ (WebKit::PluginView::Stream::didFinishLoading):
+ Protect the plug-in when calling destroyStream.
+
+ (WebKit::PluginView::manualLoadDidReceiveResponse):
+ Call Plugin::manualStreamDidReceiveResponse.
+
+ (WebKit::PluginView::manualLoadDidReceiveData):
+ Call Plugin::manualStreamDidReceiveData.
+
+ (WebKit::PluginView::manualLoadDidFinishLoading):
+ Call Plugin::manualStreamDidFinishLoading.
+
+ (WebKit::PluginView::manualLoadDidFail):
+ Call Plugin::manualStreamDidFail.
+
+ * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+ (WebKit::WebFrameLoaderClient::WebFrameLoaderClient):
+ Initialize m_hasSentResponseToPluginView to false.
+
+ (WebKit::WebFrameLoaderClient::setMainDocumentError):
+ Call PluginView::manualLoadDidFail.
+
+ (WebKit::WebFrameLoaderClient::committedLoad):
+ Call PluginView::manualLoadDidReceiveResponse.
+
+ (WebKit::WebFrameLoaderClient::finishedLoading):
+ Call PluginView::manualLoadDidFinishLoading.
+
+ (WebKit::WebFrameLoaderClient::redirectDataToPlugin):
+ Keep track of the plug-in view.
+
2010-08-02 Brady Eidson <beidson at apple.com>
Reviewed by Anders Carlsson.
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
index eea5fc1..a525256 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
@@ -47,6 +47,7 @@ NetscapePlugin::NetscapePlugin(PassRefPtr<NetscapePluginModule> pluginModule)
, m_npWindow()
, m_isStarted(false)
, m_inNPPNew(false)
+ , m_loadManually(false)
#if PLATFORM(MAC)
, m_drawingModel(static_cast<NPDrawingModel>(-1))
, m_eventModel(static_cast<NPEventModel>(-1))
@@ -179,6 +180,11 @@ void NetscapePlugin::cancelStreamLoad(NetscapePluginStream* pluginStream)
void NetscapePlugin::removePluginStream(NetscapePluginStream* pluginStream)
{
+ if (pluginStream == m_manualStream) {
+ m_manualStream = 0;
+ return;
+ }
+
ASSERT(m_streams.get(pluginStream->streamID()) == pluginStream);
m_streams.remove(pluginStream->streamID());
}
@@ -292,6 +298,7 @@ bool NetscapePlugin::initialize(PluginController* pluginController, const Parame
uint16_t mode = parameters.loadManually ? NP_FULL : NP_EMBED;
+ m_loadManually = parameters.loadManually;
m_inNPPNew = true;
CString mimeTypeCString = parameters.mimeType.utf8();
@@ -331,7 +338,7 @@ bool NetscapePlugin::initialize(PluginController* pluginController, const Parame
}
// Load the src URL if needed.
- if (!parameters.url.isEmpty() && shouldLoadSrcURL())
+ if (!parameters.loadManually && !parameters.url.isEmpty() && shouldLoadSrcURL())
loadURL("GET", parameters.url.string(), String(), HTTPHeaderMap(), Vector<char>(), false, 0);
return true;
@@ -431,6 +438,40 @@ void NetscapePlugin::streamDidFail(uint64_t streamID, bool wasCancelled)
pluginStream->didFail(wasCancelled);
}
+void NetscapePlugin::manualStreamDidReceiveResponse(const KURL& responseURL, uint32_t streamLength, uint32_t lastModifiedTime,
+ const String& mimeType, const String& headers)
+{
+ ASSERT(m_loadManually);
+ ASSERT(!m_manualStream);
+
+ m_manualStream = NetscapePluginStream::create(this, 0, false, 0);
+ m_manualStream->didReceiveResponse(responseURL, streamLength, lastModifiedTime, mimeType, headers);
+}
+
+void NetscapePlugin::manualStreamDidReceiveData(const char* bytes, int length)
+{
+ ASSERT(m_loadManually);
+ ASSERT(m_manualStream);
+
+ m_manualStream->didReceiveData(bytes, length);
+}
+
+void NetscapePlugin::manualStreamDidFinishLoading()
+{
+ ASSERT(m_loadManually);
+ ASSERT(m_manualStream);
+
+ m_manualStream->didFinishLoading();
+}
+
+void NetscapePlugin::manualStreamDidFail(bool wasCancelled)
+{
+ ASSERT(m_loadManually);
+ ASSERT(m_manualStream);
+
+ m_manualStream->didFail(wasCancelled);
+}
+
bool NetscapePlugin::handleMouseEvent(const WebMouseEvent& mouseEvent)
{
return platformHandleMouseEvent(mouseEvent);
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
index 6516c0e..42269c8 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
@@ -114,6 +114,12 @@ private:
virtual void streamDidReceiveData(uint64_t streamID, const char* bytes, int length);
virtual void streamDidFinishLoading(uint64_t streamID);
virtual void streamDidFail(uint64_t streamID, bool wasCancelled);
+ virtual void manualStreamDidReceiveResponse(const WebCore::KURL& responseURL, uint32_t streamLength,
+ uint32_t lastModifiedTime, const WebCore::String& mimeType, const WebCore::String& headers);
+ virtual void manualStreamDidReceiveData(const char* bytes, int length);
+ virtual void manualStreamDidFinishLoading();
+ virtual void manualStreamDidFail(bool wasCancelled);
+
virtual bool handleMouseEvent(const WebMouseEvent&);
virtual bool handleWheelEvent(const WebWheelEvent&);
virtual bool handleMouseEnterEvent(const WebMouseEvent&);
@@ -143,6 +149,8 @@ private:
bool m_isStarted;
bool m_inNPPNew;
+ bool m_loadManually;
+ RefPtr<NetscapePluginStream> m_manualStream;
#if PLATFORM(MAC)
NPDrawingModel m_drawingModel;
diff --git a/WebKit2/WebProcess/Plugins/Plugin.h b/WebKit2/WebProcess/Plugins/Plugin.h
index 41c4c71..a353ff1 100644
--- a/WebKit2/WebProcess/Plugins/Plugin.h
+++ b/WebKit2/WebProcess/Plugins/Plugin.h
@@ -91,6 +91,19 @@ public:
// Tells the plug-in that a stream has failed to load, either because of network errors or because the load was cancelled.
virtual void streamDidFail(uint64_t streamID, bool wasCancelled) = 0;
+ // Tells the plug-in that the manual stream has received its HTTP response.
+ virtual void manualStreamDidReceiveResponse(const WebCore::KURL& responseURL, uint32_t streamLength,
+ uint32_t lastModifiedTime, const WebCore::String& mimeType, const WebCore::String& headers) = 0;
+
+ // Tells the plug-in that the manual stream did receive data.
+ virtual void manualStreamDidReceiveData(const char* bytes, int length) = 0;
+
+ // Tells the plug-in that a stream has finished loading.
+ virtual void manualStreamDidFinishLoading() = 0;
+
+ // Tells the plug-in that a stream has failed to load, either because of network errors or because the load was cancelled.
+ virtual void manualStreamDidFail(bool wasCancelled) = 0;
+
// Tells the plug-in to handle the passed in mouse event. The plug-in should return true if it processed the event.
virtual bool handleMouseEvent(const WebMouseEvent&) = 0;
diff --git a/WebKit2/WebProcess/Plugins/PluginView.cpp b/WebKit2/WebProcess/Plugins/PluginView.cpp
index e51e8be..1233492 100644
--- a/WebKit2/WebProcess/Plugins/PluginView.cpp
+++ b/WebKit2/WebProcess/Plugins/PluginView.cpp
@@ -140,6 +140,39 @@ void PluginView::Stream::cancel()
m_loader = 0;
}
+static String buildHTTPHeaders(const ResourceResponse& response, long long& expectedContentLength)
+{
+ if (!response.isHTTP())
+ return String();
+
+ Vector<UChar> stringBuilder;
+ String separator(": ");
+
+ String statusLine = String::format("HTTP %d ", response.httpStatusCode());
+ stringBuilder.append(statusLine.characters(), statusLine.length());
+ stringBuilder.append(response.httpStatusText().characters(), response.httpStatusText().length());
+ stringBuilder.append('\n');
+
+ HTTPHeaderMap::const_iterator end = response.httpHeaderFields().end();
+ for (HTTPHeaderMap::const_iterator it = response.httpHeaderFields().begin(); it != end; ++it) {
+ stringBuilder.append(it->first.characters(), it->first.length());
+ stringBuilder.append(separator.characters(), separator.length());
+ stringBuilder.append(it->second.characters(), it->second.length());
+ stringBuilder.append('\n');
+ }
+
+ String headers = String::adopt(stringBuilder);
+
+ // If the content is encoded (most likely compressed), then don't send its length to the plugin,
+ // which is only interested in the decoded length, not yet known at the moment.
+ // <rdar://problem/4470599> tracks a request for -[NSURLResponse expectedContentLength] to incorporate this logic.
+ String contentEncoding = response.httpHeaderField("Content-Encoding");
+ if (!contentEncoding.isNull() && contentEncoding != "identity")
+ expectedContentLength = -1;
+
+ return headers;
+}
+
void PluginView::Stream::didReceiveResponse(NetscapePlugInStreamLoader*, const ResourceResponse& response)
{
// Compute the stream related data from the resource response.
@@ -147,33 +180,7 @@ void PluginView::Stream::didReceiveResponse(NetscapePlugInStreamLoader*, const R
const String& mimeType = response.mimeType();
long long expectedContentLength = response.expectedContentLength();
- String headers;
- if (response.isHTTP()) {
- Vector<UChar> stringBuilder;
- String separator(": ");
-
- String statusLine = String::format("HTTP %d ", response.httpStatusCode());
- stringBuilder.append(statusLine.characters(), statusLine.length());
- stringBuilder.append(response.httpStatusText().characters(), response.httpStatusText().length());
- stringBuilder.append('\n');
-
- HTTPHeaderMap::const_iterator end = response.httpHeaderFields().end();
- for (HTTPHeaderMap::const_iterator it = response.httpHeaderFields().begin(); it != end; ++it) {
- stringBuilder.append(it->first.characters(), it->first.length());
- stringBuilder.append(separator.characters(), separator.length());
- stringBuilder.append(it->second.characters(), it->second.length());
- stringBuilder.append('\n');
- }
-
- headers = String::adopt(stringBuilder);
-
- // If the content is encoded (most likely compressed), then don't send its length to the plugin,
- // which is only interested in the decoded length, not yet known at the moment.
- // <rdar://problem/4470599> tracks a request for -[NSURLResponse expectedContentLength] to incorporate this logic.
- String contentEncoding = response.httpHeaderField("Content-Encoding");
- if (!contentEncoding.isNull() && contentEncoding != "identity")
- expectedContentLength = -1;
- }
+ String headers = buildHTTPHeaders(response, expectedContentLength);
uint32_t streamLength = 0;
if (expectedContentLength > 0)
@@ -203,9 +210,12 @@ void PluginView::Stream::didFail(NetscapePlugInStreamLoader*, const ResourceErro
void PluginView::Stream::didFinishLoading(NetscapePlugInStreamLoader*)
{
// Calling streamDidFinishLoading could cause us to be deleted, so we hold on to a reference here.
- RefPtr<Stream> protect(this);
+ RefPtr<Stream> protectStream(this);
+ // Protect the plug-in while we're calling into it.
+ NPRuntimeObjectMap::PluginProtector pluginProtector(&m_pluginView->m_npRuntimeObjectMap);
m_pluginView->m_plugin->streamDidFinishLoading(m_streamID);
+
m_pluginView->removeStream(this);
m_pluginView = 0;
}
@@ -253,6 +263,37 @@ Frame* PluginView::frame()
return m_pluginElement->document()->frame();
}
+void PluginView::manualLoadDidReceiveResponse(const ResourceResponse& response)
+{
+ // Compute the stream related data from the resource response.
+ const KURL& responseURL = response.url();
+ const String& mimeType = response.mimeType();
+ long long expectedContentLength = response.expectedContentLength();
+
+ String headers = buildHTTPHeaders(response, expectedContentLength);
+
+ uint32_t streamLength = 0;
+ if (expectedContentLength > 0)
+ streamLength = expectedContentLength;
+
+ m_plugin->manualStreamDidReceiveResponse(responseURL, streamLength, response.lastModifiedDate(), mimeType, headers);
+}
+
+void PluginView::manualLoadDidReceiveData(const char* bytes, int length)
+{
+ m_plugin->manualStreamDidReceiveData(bytes, length);
+}
+
+void PluginView::manualLoadDidFinishLoading()
+{
+ m_plugin->manualStreamDidFinishLoading();
+}
+
+void PluginView::manualLoadDidFail(const ResourceError& error)
+{
+ m_plugin->manualStreamDidFail(error.isCancellation());
+}
+
void PluginView::initializePlugin()
{
if (m_isInitialized)
diff --git a/WebKit2/WebProcess/Plugins/PluginView.h b/WebKit2/WebProcess/Plugins/PluginView.h
index c0e03f0..0676380 100644
--- a/WebKit2/WebProcess/Plugins/PluginView.h
+++ b/WebKit2/WebProcess/Plugins/PluginView.h
@@ -56,6 +56,11 @@ public:
bool isBeingDestroyed() const { return m_isBeingDestroyed; }
+ void manualLoadDidReceiveResponse(const WebCore::ResourceResponse&);
+ void manualLoadDidReceiveData(const char* bytes, int length);
+ void manualLoadDidFinishLoading();
+ void manualLoadDidFail(const WebCore::ResourceError&);
+
private:
PluginView(WebCore::HTMLPlugInElement*, PassRefPtr<Plugin>, const Plugin::Parameters& parameters);
virtual ~PluginView();
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp b/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
index 62b3078..79fb2e8 100644
--- a/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
+++ b/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
@@ -63,6 +63,16 @@ using namespace WebCore;
namespace WebKit {
+WebFrameLoaderClient::WebFrameLoaderClient(WebFrame* frame)
+ : m_frame(frame)
+ , m_hasSentResponseToPluginView(false)
+{
+}
+
+WebFrameLoaderClient::~WebFrameLoaderClient()
+{
+}
+
void WebFrameLoaderClient::frameLoaderDestroyed()
{
m_frame->invalidate();
@@ -451,9 +461,14 @@ void WebFrameLoaderClient::revertToProvisionalState(DocumentLoader*)
notImplemented();
}
-void WebFrameLoaderClient::setMainDocumentError(DocumentLoader*, const ResourceError&)
+void WebFrameLoaderClient::setMainDocumentError(DocumentLoader*, const ResourceError& error)
{
- notImplemented();
+ if (!m_pluginView)
+ return;
+
+ m_pluginView->manualLoadDidFail(error);
+ m_pluginView = 0;
+ m_hasSentResponseToPluginView = false;
}
void WebFrameLoaderClient::willChangeEstimatedProgress()
@@ -510,7 +525,23 @@ void WebFrameLoaderClient::committedLoad(DocumentLoader* loader, const char* dat
{
const String& textEncoding = loader->response().textEncodingName();
- receivedData(data, length, textEncoding);
+ if (!m_pluginView)
+ receivedData(data, length, textEncoding);
+
+ // Calling receivedData did not create the plug-in view.
+ if (!m_pluginView)
+ return;
+
+ if (!m_hasSentResponseToPluginView) {
+ m_pluginView->manualLoadDidReceiveResponse(m_frame->coreFrame()->loader()->documentLoader()->response());
+ // manualLoadDidReceiveResponse sets up a new stream to the plug-in. on a full-page plug-in, a failure in
+ // setting up this stream can cause the main document load to be cancelled, setting m_pluginView
+ // to null
+ if (!m_pluginView)
+ return;
+ m_hasSentResponseToPluginView = true;
+ }
+ m_pluginView->manualLoadDidReceiveData(data, length);
}
void WebFrameLoaderClient::receivedData(const char* data, int length, const String& textEncoding)
@@ -531,7 +562,14 @@ void WebFrameLoaderClient::receivedData(const char* data, int length, const Stri
void WebFrameLoaderClient::finishedLoading(DocumentLoader* loader)
{
- committedLoad(loader, 0, 0);
+ if (!m_pluginView) {
+ committedLoad(loader, 0, 0);
+ return;
+ }
+
+ m_pluginView->manualLoadDidFinishLoading();
+ m_pluginView = 0;
+ m_hasSentResponseToPluginView = false;
}
void WebFrameLoaderClient::updateGlobalHistory()
@@ -820,7 +858,10 @@ PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize&, HTMLPlugIn
void WebFrameLoaderClient::redirectDataToPlugin(Widget* pluginWidget)
{
- notImplemented();
+ ASSERT(!m_pluginView);
+ ASSERT(pluginWidget);
+
+ m_pluginView = static_cast<PluginView*>(pluginWidget);
}
PassRefPtr<Widget> WebFrameLoaderClient::createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues)
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h b/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h
index 6991f6c..58347a5 100644
--- a/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h
+++ b/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h
@@ -30,14 +30,13 @@
namespace WebKit {
+class PluginView;
class WebFrame;
-
+
class WebFrameLoaderClient : public WebCore::FrameLoaderClient {
public:
- WebFrameLoaderClient(WebFrame* frame)
- : m_frame(frame)
- {
- }
+ WebFrameLoaderClient(WebFrame*);
+ ~WebFrameLoaderClient();
WebFrame* webFrame() const { return m_frame; }
@@ -205,8 +204,11 @@ private:
virtual bool shouldUsePluginDocument(const WebCore::String& /*mimeType*/) const;
void receivedData(const char* data, int length, const WebCore::String& textEncoding);
-
+
WebFrame* m_frame;
+
+ RefPtr<PluginView> m_pluginView;
+ bool m_hasSentResponseToPluginView;
};
} // namespace WebKit
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list