зеркало из https://github.com/mozilla/pjs.git
265333 make gtkmozembed use nsIWebBrowserStream instead of implementing that
functionality itself r=marco sr=darin
This commit is contained in:
Родитель
f1c36d6e08
Коммит
c2da9eebf2
|
@ -39,6 +39,8 @@
|
|||
#include <nsIWebProgress.h>
|
||||
#include "nsIWidget.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIWebBrowserStream.h"
|
||||
|
||||
// for NS_APPSHELL_CID
|
||||
#include <nsWidgetsCID.h>
|
||||
|
@ -81,7 +83,6 @@
|
|||
#include "EmbedContentListener.h"
|
||||
#include "EmbedEventListener.h"
|
||||
#include "EmbedWindowCreator.h"
|
||||
#include "EmbedStream.h"
|
||||
#ifdef MOZ_WIDGET_GTK2
|
||||
#include "GtkPromptService.h"
|
||||
#else
|
||||
|
@ -149,7 +150,6 @@ EmbedPrivate::EmbedPrivate(void)
|
|||
mProgress = nsnull;
|
||||
mContentListener = nsnull;
|
||||
mEventListener = nsnull;
|
||||
mStream = nsnull;
|
||||
mChromeMask = nsIWebBrowserChrome::CHROME_ALL;
|
||||
mIsChrome = PR_FALSE;
|
||||
mChromeLoaded = PR_FALSE;
|
||||
|
@ -602,48 +602,47 @@ EmbedPrivate::SetDirectoryServiceProvider(nsIDirectoryServiceProvider * appFileL
|
|||
nsresult
|
||||
EmbedPrivate::OpenStream(const char *aBaseURI, const char *aContentType)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIWebBrowser> webBrowser;
|
||||
mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
|
||||
|
||||
if (!mStream) {
|
||||
mStream = new EmbedStream();
|
||||
mStreamGuard = do_QueryInterface(mStream);
|
||||
mStream->InitOwner(this);
|
||||
rv = mStream->Init();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
nsCOMPtr<nsIWebBrowserStream> wbStream = do_QueryInterface(webBrowser);
|
||||
if (!wbStream) return NS_ERROR_FAILURE;
|
||||
|
||||
rv = mStream->OpenStream(aBaseURI, aContentType);
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(uri), aBaseURI);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = wbStream->OpenStream(uri, nsDependentCString(aContentType));
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
EmbedPrivate::AppendToStream(const char *aData, PRInt32 aLen)
|
||||
EmbedPrivate::AppendToStream(const PRUint8 *aData, PRUint32 aLen)
|
||||
{
|
||||
if (!mStream)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Attach listeners to this document since in some cases we don't
|
||||
// get updates for content added this way.
|
||||
ContentStateChange();
|
||||
|
||||
return mStream->AppendToStream(aData, aLen);
|
||||
nsCOMPtr<nsIWebBrowser> webBrowser;
|
||||
mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
|
||||
|
||||
nsCOMPtr<nsIWebBrowserStream> wbStream = do_QueryInterface(webBrowser);
|
||||
if (!wbStream) return NS_ERROR_FAILURE;
|
||||
|
||||
return wbStream->AppendToStream(aData, aLen);
|
||||
}
|
||||
|
||||
nsresult
|
||||
EmbedPrivate::CloseStream(void)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIWebBrowser> webBrowser;
|
||||
mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
|
||||
|
||||
if (!mStream)
|
||||
return NS_ERROR_FAILURE;
|
||||
rv = mStream->CloseStream();
|
||||
nsCOMPtr<nsIWebBrowserStream> wbStream = do_QueryInterface(webBrowser);
|
||||
if (!wbStream) return NS_ERROR_FAILURE;
|
||||
|
||||
// release
|
||||
mStream = 0;
|
||||
mStreamGuard = 0;
|
||||
|
||||
return rv;
|
||||
return wbStream->CloseStream();
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
|
|
@ -60,7 +60,6 @@ class EmbedProgress;
|
|||
class EmbedWindow;
|
||||
class EmbedContentListener;
|
||||
class EmbedEventListener;
|
||||
class EmbedStream;
|
||||
|
||||
class nsPIDOMWindow;
|
||||
class nsIDirectoryServiceProvider;
|
||||
|
@ -96,7 +95,7 @@ class EmbedPrivate {
|
|||
static void SetDirectoryServiceProvider (nsIDirectoryServiceProvider * appFileLocProvider);
|
||||
|
||||
nsresult OpenStream (const char *aBaseURI, const char *aContentType);
|
||||
nsresult AppendToStream (const char *aData, PRInt32 aLen);
|
||||
nsresult AppendToStream (const PRUint8 *aData, PRUint32 aLen);
|
||||
nsresult CloseStream (void);
|
||||
|
||||
// This function will find the specific EmbedPrivate object for a
|
||||
|
@ -139,8 +138,6 @@ class EmbedPrivate {
|
|||
nsCOMPtr<nsISupports> mContentListenerGuard;
|
||||
EmbedEventListener *mEventListener;
|
||||
nsCOMPtr<nsISupports> mEventListenerGuard;
|
||||
EmbedStream *mStream;
|
||||
nsCOMPtr<nsISupports> mStreamGuard;
|
||||
|
||||
nsCOMPtr<nsIWebNavigation> mNavigation;
|
||||
nsCOMPtr<nsISHistory> mSessionHistory;
|
||||
|
|
|
@ -77,7 +77,7 @@ CPPSRCS = \
|
|||
EmbedContentListener.cpp \
|
||||
EmbedEventListener.cpp \
|
||||
EmbedWindowCreator.cpp \
|
||||
EmbedStream.cpp
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_ENABLE_GTK2
|
||||
CSRCS = \
|
||||
|
|
|
@ -987,7 +987,7 @@ gtk_moz_embed_render_data(GtkMozEmbed *embed, const char *data,
|
|||
embedPrivate = (EmbedPrivate *)embed->data;
|
||||
|
||||
embedPrivate->OpenStream(base_uri, mime_type);
|
||||
embedPrivate->AppendToStream(data, len);
|
||||
embedPrivate->AppendToStream((const PRUint8*)data, len);
|
||||
embedPrivate->CloseStream();
|
||||
}
|
||||
|
||||
|
@ -1016,7 +1016,7 @@ void gtk_moz_embed_append_data(GtkMozEmbed *embed, const char *data,
|
|||
g_return_if_fail (GTK_WIDGET_REALIZED(GTK_WIDGET(embed)));
|
||||
|
||||
embedPrivate = (EmbedPrivate *)embed->data;
|
||||
embedPrivate->AppendToStream(data, len);
|
||||
embedPrivate->AppendToStream((const PRUint8*)data, len);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -647,7 +647,7 @@ menu_stream_cb (GtkMenuItem *menuitem, TestGtkBrowser *browser)
|
|||
const char *data;
|
||||
const char *data2;
|
||||
data = "<html>Hi";
|
||||
data2 = " there</html>\n";
|
||||
data2 = " <a href='foo.html'>there</a></html>\n";
|
||||
g_print("stream_clicked_cb\n");
|
||||
gtk_moz_embed_open_stream(GTK_MOZ_EMBED(browser->mozEmbed),
|
||||
"file://", "text/html");
|
||||
|
|
Загрузка…
Ссылка в новой задаче