diff options
Diffstat (limited to 'embed/xulrunner/utils')
-rw-r--r-- | embed/xulrunner/utils/AutoJSContextStack.cpp | 48 | ||||
-rw-r--r-- | embed/xulrunner/utils/AutoJSContextStack.h | 41 | ||||
-rw-r--r-- | embed/xulrunner/utils/AutoWindowModalState.cpp | 43 | ||||
-rw-r--r-- | embed/xulrunner/utils/AutoWindowModalState.h | 38 | ||||
-rw-r--r-- | embed/xulrunner/utils/Makefile.am | 32 |
5 files changed, 202 insertions, 0 deletions
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 <xpcom-config.h> +#include "config.h" + +#include "AutoJSContextStack.h" + +#include <nsIServiceManager.h> +#include <nsServiceManagerUtils.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/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 <nsCOMPtr.h> +#include <nsIJSContextStack.h> + +class AutoJSContextStack +{ + public: + AutoJSContextStack () { } + ~AutoJSContextStack (); + + nsresult Init (); + + private: + nsCOMPtr<nsIJSContextStack> 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 <xpcom-config.h> +#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 <nsCOMPtr.h> +#include <nsPIDOMWindow.h> + +class AutoWindowModalState +{ + public: + AutoWindowModalState (nsIDOMWindow *); + ~AutoWindowModalState (); + + private: + + nsCOMPtr<nsPIDOMWindow> 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) |