From 4fe73188e1d1acf72a346d939a86691c73bb6ebd Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Thu, 13 Sep 2007 13:09:13 +0000 Subject: Move AutoJSContextStack and AutoWindowModalState helpers to embed/xulrunner/utils instead of having two copies of it in src and embed. svn path=/trunk/; revision=7424 --- embed/xulrunner/embed/AutoJSContextStack.cpp | 47 ------------------------- embed/xulrunner/embed/AutoJSContextStack.h | 41 ---------------------- embed/xulrunner/embed/AutoWindowModalState.cpp | 43 ----------------------- embed/xulrunner/embed/AutoWindowModalState.h | 38 -------------------- embed/xulrunner/embed/Makefile.am | 5 +-- embed/xulrunner/src/AutoJSContextStack.cpp | 48 -------------------------- embed/xulrunner/src/AutoJSContextStack.h | 41 ---------------------- embed/xulrunner/src/AutoWindowModalState.cpp | 39 --------------------- embed/xulrunner/src/AutoWindowModalState.h | 38 -------------------- embed/xulrunner/src/Makefile.am | 5 +-- embed/xulrunner/utils/AutoJSContextStack.cpp | 48 ++++++++++++++++++++++++++ embed/xulrunner/utils/AutoJSContextStack.h | 41 ++++++++++++++++++++++ embed/xulrunner/utils/AutoWindowModalState.cpp | 43 +++++++++++++++++++++++ embed/xulrunner/utils/AutoWindowModalState.h | 38 ++++++++++++++++++++ embed/xulrunner/utils/Makefile.am | 32 +++++++++++++++++ 15 files changed, 204 insertions(+), 343 deletions(-) delete mode 100644 embed/xulrunner/embed/AutoJSContextStack.cpp delete mode 100644 embed/xulrunner/embed/AutoJSContextStack.h delete mode 100644 embed/xulrunner/embed/AutoWindowModalState.cpp delete mode 100644 embed/xulrunner/embed/AutoWindowModalState.h delete mode 100644 embed/xulrunner/src/AutoJSContextStack.cpp delete mode 100644 embed/xulrunner/src/AutoJSContextStack.h delete mode 100644 embed/xulrunner/src/AutoWindowModalState.cpp delete mode 100644 embed/xulrunner/src/AutoWindowModalState.h create mode 100644 embed/xulrunner/utils/AutoJSContextStack.cpp create mode 100644 embed/xulrunner/utils/AutoJSContextStack.h create mode 100644 embed/xulrunner/utils/AutoWindowModalState.cpp create mode 100644 embed/xulrunner/utils/AutoWindowModalState.h diff --git a/embed/xulrunner/embed/AutoJSContextStack.cpp b/embed/xulrunner/embed/AutoJSContextStack.cpp deleted file mode 100644 index 2dc435625..000000000 --- a/embed/xulrunner/embed/AutoJSContextStack.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright © 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 Lesser 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - */ - -#include -#include "config.h" - -#include - -#include "AutoJSContextStack.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/xulrunner/embed/AutoJSContextStack.h b/embed/xulrunner/embed/AutoJSContextStack.h deleted file mode 100644 index 0db423a64..000000000 --- a/embed/xulrunner/embed/AutoJSContextStack.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright © 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 Lesser 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - */ - -#ifndef AUTO_JSCONTEXTSTACK_H -#define AUTO_JSCONTEXTSTACK_H - -struct JSContext; - -#include -#include - -class AutoJSContextStack -{ - public: - AutoJSContextStack () { } - ~AutoJSContextStack (); - - nsresult Init (); - - private: - nsCOMPtr mStack; -}; - -#endif diff --git a/embed/xulrunner/embed/AutoWindowModalState.cpp b/embed/xulrunner/embed/AutoWindowModalState.cpp deleted file mode 100644 index 79fb2c15a..000000000 --- a/embed/xulrunner/embed/AutoWindowModalState.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright © 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 Lesser 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - */ - -#include -#include "config.h" - -#include "AutoWindowModalState.h" - -AutoWindowModalState::AutoWindowModalState (nsIDOMWindow *aWindow) -{ - if (aWindow) { - mWindow = do_QueryInterface (aWindow); - NS_ASSERTION (mWindow, "Should have a window here!"); - } - - if (mWindow) { - mWindow->EnterModalState (); - } -} - -AutoWindowModalState::~AutoWindowModalState() -{ - if (mWindow) { - mWindow->LeaveModalState (); - } -} diff --git a/embed/xulrunner/embed/AutoWindowModalState.h b/embed/xulrunner/embed/AutoWindowModalState.h deleted file mode 100644 index 557865799..000000000 --- a/embed/xulrunner/embed/AutoWindowModalState.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright © 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 Lesser 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - */ - -#ifndef AUTO_WINDOWMODALSTATE_H -#define AUTO_WINDOWMODALSTATE_H - -#include -#include - -class AutoWindowModalState -{ - public: - AutoWindowModalState (nsIDOMWindow *); - ~AutoWindowModalState (); - - private: - - nsCOMPtr mWindow; -}; - -#endif diff --git a/embed/xulrunner/embed/Makefile.am b/embed/xulrunner/embed/Makefile.am index 5158bd45a..2c8d7d4f3 100644 --- a/embed/xulrunner/embed/Makefile.am +++ b/embed/xulrunner/embed/Makefile.am @@ -1,10 +1,6 @@ noinst_LTLIBRARIES = libephyxulrunnerembed.la libephyxulrunnerembed_la_SOURCES = \ - AutoJSContextStack.cpp \ - AutoJSContextStack.h \ - AutoWindowModalState.cpp \ - AutoWindowModalState.h \ ContentHandler.cpp \ ContentHandler.h \ EphyAboutModule.cpp \ @@ -99,6 +95,7 @@ libephyxulrunnerembed_la_CPPFLAGS = \ -I$(top_srcdir)/embed \ -I$(top_srcdir) \ -I$(top_srcdir)/embed/xulrunner/src \ + -I$(top_srcdir)/embed/xulrunner/utils \ -I$(top_builddir)/embed/xulrunner/src \ -DSHARE_DIR=\"$(pkgdatadir)\" \ -DPLUGINDIR=\"$(libdir)/epiphany/$(EPIPHANY_MAJOR)/plugins\" \ diff --git a/embed/xulrunner/src/AutoJSContextStack.cpp b/embed/xulrunner/src/AutoJSContextStack.cpp deleted file mode 100644 index 9c918fc3b..000000000 --- a/embed/xulrunner/src/AutoJSContextStack.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright © 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 Lesser 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 -#include "config.h" - -#include "AutoJSContextStack.h" - -#include -#include - -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/xulrunner/src/AutoJSContextStack.h b/embed/xulrunner/src/AutoJSContextStack.h deleted file mode 100644 index 5294e7d4e..000000000 --- a/embed/xulrunner/src/AutoJSContextStack.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright © 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 Lesser 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 -#include - -class AutoJSContextStack -{ - public: - AutoJSContextStack () { } - ~AutoJSContextStack (); - - nsresult Init (); - - private: - nsCOMPtr mStack; -}; - -#endif diff --git a/embed/xulrunner/src/AutoWindowModalState.cpp b/embed/xulrunner/src/AutoWindowModalState.cpp deleted file mode 100644 index 5f38acec5..000000000 --- a/embed/xulrunner/src/AutoWindowModalState.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright © 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 Lesser 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 -#include "config.h" - -#include "AutoWindowModalState.h" - -AutoWindowModalState::AutoWindowModalState (nsIDOMWindow *aWindow) -{ - mWindow = do_QueryInterface (aWindow); - if (mWindow) { - mWindow->EnterModalState (); - } -} - -AutoWindowModalState::~AutoWindowModalState() -{ - if (mWindow) { - mWindow->LeaveModalState (); - } -} diff --git a/embed/xulrunner/src/AutoWindowModalState.h b/embed/xulrunner/src/AutoWindowModalState.h deleted file mode 100644 index bccefede2..000000000 --- a/embed/xulrunner/src/AutoWindowModalState.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright © 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 Lesser 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_WINDOWMODALSTATE_H -#define AUTO_WINDOWMODALSTATE_H - -#include -#include - -class AutoWindowModalState -{ - public: - AutoWindowModalState (nsIDOMWindow *); - ~AutoWindowModalState (); - - private: - - nsCOMPtr mWindow; -}; - -#endif diff --git a/embed/xulrunner/src/Makefile.am b/embed/xulrunner/src/Makefile.am index a0d82d551..4dd581aae 100644 --- a/embed/xulrunner/src/Makefile.am +++ b/embed/xulrunner/src/Makefile.am @@ -79,10 +79,6 @@ libgnomegeckoembed_la_SOURCES = \ gecko-init.h \ gecko-init-internal.h \ gecko-init-private.h \ - AutoJSContextStack.cpp \ - AutoJSContextStack.h \ - AutoWindowModalState.cpp \ - AutoWindowModalState.h \ EmbedContentListener.cpp \ EmbedContentListener.h \ EmbedEventListener.cpp \ @@ -104,6 +100,7 @@ libgnomegeckoembed_la_SOURCES = \ $(NULL) libgnomegeckoembed_la_CPPFLAGS = \ + -I$(top_srcdir)/embed/xulrunner/utils \ $(LIBXUL_CXXCPPFLAGS) \ $(LIBXUL_INCLUDES) \ $(AM_CPPFLAGS) diff --git a/embed/xulrunner/utils/AutoJSContextStack.cpp b/embed/xulrunner/utils/AutoJSContextStack.cpp new file mode 100644 index 000000000..9c918fc3b --- /dev/null +++ b/embed/xulrunner/utils/AutoJSContextStack.cpp @@ -0,0 +1,48 @@ +/* + * Copyright © 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 Lesser 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 +#include "config.h" + +#include "AutoJSContextStack.h" + +#include +#include + +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/xulrunner/utils/AutoJSContextStack.h b/embed/xulrunner/utils/AutoJSContextStack.h new file mode 100644 index 000000000..5294e7d4e --- /dev/null +++ b/embed/xulrunner/utils/AutoJSContextStack.h @@ -0,0 +1,41 @@ +/* + * Copyright © 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 Lesser 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 +#include + +class AutoJSContextStack +{ + public: + AutoJSContextStack () { } + ~AutoJSContextStack (); + + nsresult Init (); + + private: + nsCOMPtr mStack; +}; + +#endif diff --git a/embed/xulrunner/utils/AutoWindowModalState.cpp b/embed/xulrunner/utils/AutoWindowModalState.cpp new file mode 100644 index 000000000..79fb2c15a --- /dev/null +++ b/embed/xulrunner/utils/AutoWindowModalState.cpp @@ -0,0 +1,43 @@ +/* + * Copyright © 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 Lesser 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Id$ + */ + +#include +#include "config.h" + +#include "AutoWindowModalState.h" + +AutoWindowModalState::AutoWindowModalState (nsIDOMWindow *aWindow) +{ + if (aWindow) { + mWindow = do_QueryInterface (aWindow); + NS_ASSERTION (mWindow, "Should have a window here!"); + } + + if (mWindow) { + mWindow->EnterModalState (); + } +} + +AutoWindowModalState::~AutoWindowModalState() +{ + if (mWindow) { + mWindow->LeaveModalState (); + } +} diff --git a/embed/xulrunner/utils/AutoWindowModalState.h b/embed/xulrunner/utils/AutoWindowModalState.h new file mode 100644 index 000000000..557865799 --- /dev/null +++ b/embed/xulrunner/utils/AutoWindowModalState.h @@ -0,0 +1,38 @@ +/* + * Copyright © 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 Lesser 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Id$ + */ + +#ifndef AUTO_WINDOWMODALSTATE_H +#define AUTO_WINDOWMODALSTATE_H + +#include +#include + +class AutoWindowModalState +{ + public: + AutoWindowModalState (nsIDOMWindow *); + ~AutoWindowModalState (); + + private: + + nsCOMPtr mWindow; +}; + +#endif diff --git a/embed/xulrunner/utils/Makefile.am b/embed/xulrunner/utils/Makefile.am index e69de29bb..5d6fe699d 100644 --- a/embed/xulrunner/utils/Makefile.am +++ b/embed/xulrunner/utils/Makefile.am @@ -0,0 +1,32 @@ +NULL = + +noinst_LTLIBRARIES = libephyxulrunnerutils.la + +libephyxulrunnerutils_la_SOURCES = \ + AutoJSContextStack.cpp \ + AutoJSContextStack.h \ + AutoWindowModalState.cpp \ + AutoWindowModalState.h \ + $(NULL) + +libephyxulrunnerutils_la_CPPFLAGS = \ + $(LIBXUL_CXXCPPFLAGS) \ + $(LIBXUL_INCLUDES) \ + $(AM_CPPFLAGS) + +libephyxulrunnerutils_la_CXXFLAGS = \ + $(LIBXUL_CXXFLAGS) \ + $(GTK_CFLAGS) \ + $(AM_CXXFLAGS) + +libephyxulrunnerutils_la_LDFLAGS = \ + $(AM_LDFLAGS) + +libephyxulrunnerutils_la_LIBADD = \ + $(LIBXUL_LIBS) + +CLEANFILES = + $(NULL) + +EXTRA_DIST = \ + $(NULL) -- cgit