aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2006-02-03 06:25:18 +0800
committerChristian Persch <chpe@src.gnome.org>2006-02-03 06:25:18 +0800
commitb5d229937e31e9cec6cf599ae816e22888237aa0 (patch)
tree9b62c3b002838151fb7383f874cc29502a447eac
parentfd6923b630ae9629a99fa527baabb47d4454913a (diff)
downloadgsoc2013-epiphany-b5d229937e31e9cec6cf599ae816e22888237aa0.tar
gsoc2013-epiphany-b5d229937e31e9cec6cf599ae816e22888237aa0.tar.gz
gsoc2013-epiphany-b5d229937e31e9cec6cf599ae816e22888237aa0.tar.bz2
gsoc2013-epiphany-b5d229937e31e9cec6cf599ae816e22888237aa0.tar.lz
gsoc2013-epiphany-b5d229937e31e9cec6cf599ae816e22888237aa0.tar.xz
gsoc2013-epiphany-b5d229937e31e9cec6cf599ae816e22888237aa0.tar.zst
gsoc2013-epiphany-b5d229937e31e9cec6cf599ae816e22888237aa0.zip
Helper class that pushes a null JS context on the stack, and pops it in
2006-02-02 Christian Persch <chpe@cvs.gnome.org> * embed/mozilla/Makefile.am: * embed/mozilla/AutoJSContextStack.cpp: * embed/mozilla/AutoJSContextStack.h: Helper class that pushes a null JS context on the stack, and pops it in the destructor. * embed/mozilla/ContentHandler.cpp: * embed/mozilla/EphyPromptService.cpp: * embed/mozilla/FilePicker.cpp: * embed/mozilla/GtkNSSClientAuthDialogs.cpp: * embed/mozilla/GtkNSSDialogs.cpp: * embed/mozilla/GtkNSSKeyPairDialogs.cpp: * embed/mozilla/GtkNSSSecurityWarningDialogs.cpp: * embed/mozilla/PrintingPromptService.cpp: Push a null JS context on the stack when we run a recursive mainloop. Fixes the epiphany equivalend of camino bug https://bugzilla.mozilla.org/show_bug.cgi?id=179307.
-rw-r--r--ChangeLog28
-rw-r--r--embed/mozilla/AutoJSContextStack.cpp48
-rw-r--r--embed/mozilla/AutoJSContextStack.h41
-rw-r--r--embed/mozilla/ContentHandler.cpp6
-rw-r--r--embed/mozilla/EphyPromptService.cpp6
-rw-r--r--embed/mozilla/FilePicker.cpp6
-rw-r--r--embed/mozilla/GtkNSSClientAuthDialogs.cpp6
-rw-r--r--embed/mozilla/GtkNSSDialogs.cpp27
-rw-r--r--embed/mozilla/GtkNSSKeyPairDialogs.cpp5
-rw-r--r--embed/mozilla/GtkNSSSecurityWarningDialogs.cpp7
-rw-r--r--embed/mozilla/Makefile.am2
-rw-r--r--embed/mozilla/PrintingPromptService.cpp18
12 files changed, 195 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 51b563084..0e981a294 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,33 @@
2006-02-02 Christian Persch <chpe@cvs.gnome.org>
+ * embed/mozilla/Makefile.am:
+ * embed/mozilla/AutoJSContextStack.cpp:
+ * embed/mozilla/AutoJSContextStack.h:
+
+ Helper class that pushes a null JS context on the stack,
+ and pops it in the destructor.
+
+ * embed/mozilla/ContentHandler.cpp:
+ * embed/mozilla/EphyPromptService.cpp:
+ * embed/mozilla/FilePicker.cpp:
+ * embed/mozilla/GtkNSSClientAuthDialogs.cpp:
+ * embed/mozilla/GtkNSSDialogs.cpp:
+ * embed/mozilla/GtkNSSKeyPairDialogs.cpp:
+ * embed/mozilla/GtkNSSSecurityWarningDialogs.cpp:
+ * embed/mozilla/PrintingPromptService.cpp:
+
+ Push a null JS context on the stack when we run a recursive
+ mainloop. Fixes the epiphany equivalend of camino bug
+ https://bugzilla.mozilla.org/show_bug.cgi?id=179307.
+
+2006-02-02 Christian Persch <chpe@cvs.gnome.org>
+
+ * m4/gecko.m4:
+
+ Add GECKO_XPIDL to check for xpidl compiler and include directory.
+
+2006-02-02 Christian Persch <chpe@cvs.gnome.org>
+
* m4/gecko.m4:
Add GECKO_CHECK_HEADERS, wrapping AC_CHECK_HEADERS.
diff --git a/embed/mozilla/AutoJSContextStack.cpp b/embed/mozilla/AutoJSContextStack.cpp
new file mode 100644
index 000000000..77bbb81eb
--- /dev/null
+++ b/embed/mozilla/AutoJSContextStack.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2006 Christian Persch
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#include "mozilla-config.h"
+#include "config.h"
+
+#include "AutoJSContextStack.h"
+
+#include <nsIServiceManager.h>
+#include <nsIServiceManagerUtils.h>
+
+AutoJSContextStack::~AutoJSContextStack()
+{
+ if (mStack)
+ {
+ JSContext* cx;
+ mStack->Pop (&cx);
+
+ NS_ASSERTION(cx == nsnull, "We pushed a null context but popped a non-null context!?");
+ }
+}
+
+nsresult
+AutoJSContextStack::Init()
+{
+ nsresult rv;
+ mStack = do_GetService ("@mozilla.org/js/xpc/ContextStack;1", &rv);
+ if (NS_FAILED (rv)) return rv;
+
+ return mStack->Push (nsnull);
+}
diff --git a/embed/mozilla/AutoJSContextStack.h b/embed/mozilla/AutoJSContextStack.h
new file mode 100644
index 000000000..5f4069293
--- /dev/null
+++ b/embed/mozilla/AutoJSContextStack.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2006 Christian Persch
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#ifndef AUTO_JSCONTEXTSTACK_H
+#define AUTO_JSCONTEXTSTACK_H
+
+struct JSContext;
+
+#include <nsCOMPtr.h>
+#include <nsIJSContextStack.h>
+
+class AutoJSContextStack
+{
+ public:
+ AutoJSContextStack () { }
+ ~AutoJSContextStack ();
+
+ nsresult Init ();
+
+ private:
+ nsCOMPtr<nsIJSContextStack> mStack;
+};
+
+#endif
diff --git a/embed/mozilla/ContentHandler.cpp b/embed/mozilla/ContentHandler.cpp
index e7d7ca885..6c3acd696 100644
--- a/embed/mozilla/ContentHandler.cpp
+++ b/embed/mozilla/ContentHandler.cpp
@@ -26,6 +26,7 @@
#include "config.h"
#include "ContentHandler.h"
+#include "AutoJSContextStack.h"
#include <gtk/gtkdialog.h>
#include <gtk/gtkmessagedialog.h>
@@ -166,6 +167,11 @@ NS_IMETHODIMP GContentHandler::PromptForSaveToFile(
return BuildDownloadPath (defaultFile.get(), _retval);
}
+ nsresult rv;
+ AutoJSContextStack stack;
+ rv = stack.Init ();
+ if (NS_FAILED (rv)) return rv;
+
nsCOMPtr<nsIDOMWindow> parentDOMWindow = do_GetInterface (aWindowContext);
GtkWidget *parentWindow = GTK_WIDGET (EphyUtils::FindGtkParent (parentDOMWindow));
diff --git a/embed/mozilla/EphyPromptService.cpp b/embed/mozilla/EphyPromptService.cpp
index 6b6abf382..1d251d051 100644
--- a/embed/mozilla/EphyPromptService.cpp
+++ b/embed/mozilla/EphyPromptService.cpp
@@ -22,6 +22,7 @@
#include "config.h"
#include "EphyPromptService.h"
+#include "AutoJSContextStack.h"
#include <nsCOMPtr.h>
#include <nsIDOMWindow.h>
@@ -483,6 +484,11 @@ Prompter::Run (PRBool *aSuccess)
}
#endif
+ nsresult rv;
+ AutoJSContextStack stack;
+ rv = stack.Init ();
+ if (NS_FAILED (rv)) return rv;
+
if (mDelay)
{
guint timeout = g_timeout_add (TIMEOUT,
diff --git a/embed/mozilla/FilePicker.cpp b/embed/mozilla/FilePicker.cpp
index 9159e72ac..43b6b3688 100644
--- a/embed/mozilla/FilePicker.cpp
+++ b/embed/mozilla/FilePicker.cpp
@@ -25,6 +25,7 @@
#include "FilePicker.h"
#include "EphyUtils.h"
+#include "AutoJSContextStack.h"
#include <nsCOMPtr.h>
#undef MOZILLA_INTERNAL_API
@@ -430,6 +431,11 @@ NS_IMETHODIMP GFilePicker::GetFiles(nsISimpleEnumerator * *aFiles)
/* short show (); */
NS_IMETHODIMP GFilePicker::Show(PRInt16 *_retval)
{
+ nsresult rv;
+ AutoJSContextStack stack;
+ rv = stack.Init ();
+ if (NS_FAILED (rv)) return rv;
+
LOG ("GFilePicker::Show");
gtk_window_set_modal (GTK_WINDOW (mDialog), TRUE);
diff --git a/embed/mozilla/GtkNSSClientAuthDialogs.cpp b/embed/mozilla/GtkNSSClientAuthDialogs.cpp
index ae88a6b25..b5169823b 100644
--- a/embed/mozilla/GtkNSSClientAuthDialogs.cpp
+++ b/embed/mozilla/GtkNSSClientAuthDialogs.cpp
@@ -25,6 +25,7 @@
#include "config.h"
#include "EphyUtils.h"
+#include "AutoJSContextStack.h"
#include <nsIDOMWindow.h>
#include <nsIServiceManager.h>
@@ -145,6 +146,11 @@ GtkNSSClientAuthDialogs::ChooseCertificate (nsIInterfaceRequestor *ctx,
char *msg, *markup_text;
PRUint32 i;
+ nsresult rv;
+ AutoJSContextStack stack;
+ rv = stack.Init ();
+ if (NS_FAILED (rv)) return rv;
+
nsCOMPtr<nsIDOMWindow> parent = do_GetInterface (ctx);
GtkWindow *gparent = GTK_WINDOW (EphyUtils::FindGtkParent (parent));
diff --git a/embed/mozilla/GtkNSSDialogs.cpp b/embed/mozilla/GtkNSSDialogs.cpp
index a9c4f4c25..b9dfca829 100644
--- a/embed/mozilla/GtkNSSDialogs.cpp
+++ b/embed/mozilla/GtkNSSDialogs.cpp
@@ -31,6 +31,7 @@
#include "config.h"
#include "EphyUtils.h"
+#include "AutoJSContextStack.h"
#include <nsCOMPtr.h>
#include <nsMemory.h>
@@ -207,6 +208,11 @@ display_cert_warning_box (nsIInterfaceRequestor *ctx,
GtkWidget *dialog, *label, *checkbox, *vbox, *button;
int res;
+ nsresult rv;
+ AutoJSContextStack stack;
+ rv = stack.Init ();
+ if (NS_FAILED (rv)) return rv;
+
/* NOTE: Due to a mozilla bug [https://bugzilla.mozilla.org/show_bug.cgi?id=306288],
* we will always end up without a parent!
*/
@@ -539,6 +545,11 @@ GtkNSSDialogs::ConfirmDownloadCACert(nsIInterfaceRequestor *ctx,
GtkWidget *dialog, *label;
char *msg, *primary;
+ nsresult rv;
+ AutoJSContextStack stack;
+ rv = stack.Init ();
+ if (NS_FAILED (rv)) return rv;
+
nsCOMPtr<nsIDOMWindow> parent = do_GetInterface (ctx);
GtkWindow *gparent = GTK_WINDOW (EphyUtils::FindGtkParent (parent));
@@ -751,6 +762,11 @@ GtkNSSDialogs::SetPKCS12FilePassword(nsIInterfaceRequestor *ctx,
GtkWidget *progress;
char *msg;
+ nsresult rv;
+ AutoJSContextStack stack;
+ rv = stack.Init ();
+ if (NS_FAILED (rv)) return rv;
+
nsCOMPtr<nsIDOMWindow> parent = do_GetInterface (ctx);
GtkWindow *gparent = GTK_WINDOW (EphyUtils::FindGtkParent (parent));
@@ -869,6 +885,11 @@ GtkNSSDialogs::GetPKCS12FilePassword(nsIInterfaceRequestor *ctx,
GtkWidget *dialog, *hbox, *label, *entry, *vbox;
char *msg;
+ nsresult rv;
+ AutoJSContextStack stack;
+ rv = stack.Init ();
+ if (NS_FAILED (rv)) return rv;
+
nsCOMPtr<nsIDOMWindow> parent = do_GetInterface (ctx);
GtkWindow *gparent = GTK_WINDOW (EphyUtils::FindGtkParent (parent));
@@ -1313,11 +1334,15 @@ GtkNSSDialogs::ViewCert(nsIInterfaceRequestor *ctx,
GtkWidget *dialog, *widget;
GladeXML *gxml;
nsEmbedString value;
- nsresult rv;
PRUint32 verifystate, count;
PRUnichar ** usage;
GtkSizeGroup * sizegroup;
+ nsresult rv;
+ AutoJSContextStack stack;
+ rv = stack.Init ();
+ if (NS_FAILED (rv)) return rv;
+
gxml = glade_xml_new (ephy_file ("certificate-dialogs.glade"),
"viewcert_dialog", NULL);
g_return_val_if_fail (gxml != NULL, NS_ERROR_FAILURE);
diff --git a/embed/mozilla/GtkNSSKeyPairDialogs.cpp b/embed/mozilla/GtkNSSKeyPairDialogs.cpp
index 5931a4e22..cd8315604 100644
--- a/embed/mozilla/GtkNSSKeyPairDialogs.cpp
+++ b/embed/mozilla/GtkNSSKeyPairDialogs.cpp
@@ -40,6 +40,7 @@
#include "config.h"
#include "EphyUtils.h"
+#include "AutoJSContextStack.h"
#include <nsIServiceManager.h>
#include <nsIInterfaceRequestor.h>
@@ -197,6 +198,10 @@ GtkNSSKeyPairDialogs::DisplayGeneratingKeypairInfo (nsIInterfaceRequestor *ctx,
GtkWidget *dialog, *progress, *label, *vbox;
gint timeout_id;
+ nsresult rv;
+ AutoJSContextStack stack;
+ rv = stack.Init ();
+ if (NS_FAILED (rv)) return rv;
nsCOMPtr<nsIDOMWindow> parent = do_GetInterface (ctx);
GtkWindow *gparent = GTK_WINDOW (EphyUtils::FindGtkParent (parent));
diff --git a/embed/mozilla/GtkNSSSecurityWarningDialogs.cpp b/embed/mozilla/GtkNSSSecurityWarningDialogs.cpp
index 5bdc894d3..fe87b192f 100644
--- a/embed/mozilla/GtkNSSSecurityWarningDialogs.cpp
+++ b/embed/mozilla/GtkNSSSecurityWarningDialogs.cpp
@@ -47,6 +47,7 @@
#include "GtkNSSSecurityWarningDialogs.h"
#include "EphyUtils.h"
+#include "AutoJSContextStack.h"
#include <nsCOMPtr.h>
#include <nsIPrefBranch.h>
@@ -225,7 +226,11 @@ GtkNSSSecurityWarningDialogs::DoDialog (nsIInterfaceRequestor *aContext,
*_retval = PR_TRUE;
return;
}
-
+
+ AutoJSContextStack stack;
+ rv = stack.Init ();
+ if (NS_FAILED (rv));
+
/* Didn't you know it, mozilla SUCKS!
* the "aContext" interface requestor is made from a nsIDOMWindow,
* but can only give out a nsIPrompt, from where there's no way to get
diff --git a/embed/mozilla/Makefile.am b/embed/mozilla/Makefile.am
index f5504128b..e8c747e8f 100644
--- a/embed/mozilla/Makefile.am
+++ b/embed/mozilla/Makefile.am
@@ -1,6 +1,8 @@
noinst_LTLIBRARIES = libephymozillaembed.la
libephymozillaembed_la_SOURCES = \
+ AutoJSContextStack.cpp \
+ AutoJSContextStack.h \
ContentHandler.cpp \
ContentHandler.h \
EphyAboutModule.cpp \
diff --git a/embed/mozilla/PrintingPromptService.cpp b/embed/mozilla/PrintingPromptService.cpp
index 2770f0d30..218c63b81 100644
--- a/embed/mozilla/PrintingPromptService.cpp
+++ b/embed/mozilla/PrintingPromptService.cpp
@@ -24,6 +24,10 @@
#include "config.h"
+#include "PrintingPromptService.h"
+#include "EphyUtils.h"
+#include "AutoJSContextStack.h"
+
#include <gtk/gtkdialog.h>
#include <libgnomeprintui/gnome-print-dialog.h>
@@ -31,8 +35,6 @@
#include "print-dialog.h"
#include "ephy-embed.h"
#include "ephy-command-manager.h"
-#include "EphyUtils.h"
-#include "PrintingPromptService.h"
#include "eel-gconf-extensions.h"
#include "ephy-prefs.h"
#include "ephy-debug.h"
@@ -72,6 +74,11 @@ NS_IMETHODIMP GPrintingPromptService::ShowPrintDialog(nsIDOMWindow *parent, nsIW
return NS_ERROR_ABORT;
}
+ nsresult rv;
+ AutoJSContextStack stack;
+ rv = stack.Init ();
+ if (NS_FAILED (rv)) return rv;
+
EphyEmbed *embed = EPHY_EMBED (EphyUtils::FindEmbed (parent));
NS_ENSURE_TRUE (embed, NS_ERROR_FAILURE);
@@ -136,7 +143,8 @@ NS_IMETHODIMP GPrintingPromptService::ShowProgress(nsIDOMWindow *parent, nsIWebB
}
/* void showPageSetup (in nsIDOMWindow parent, in nsIPrintSettings printSettings, in nsIObserver printObserver); */
-NS_IMETHODIMP GPrintingPromptService::ShowPageSetup(nsIDOMWindow *parent, nsIPrintSettings *printSettings,
+NS_IMETHODIMP GPrintingPromptService::ShowPageSetup(nsIDOMWindow *parent,
+ nsIPrintSettings *printSettings,
nsIObserver *printObserver)
{
EphyDialog *dialog;
@@ -148,6 +156,10 @@ NS_IMETHODIMP GPrintingPromptService::ShowPageSetup(nsIDOMWindow *parent, nsIPri
return rv;
}
+ AutoJSContextStack stack;
+ rv = stack.Init ();
+ if (NS_FAILED (rv)) return rv;
+
dialog = ephy_print_setup_dialog_new ();
ephy_dialog_set_modal (dialog, TRUE);