[ilovegom commit] r76 - in trunk/gom: . idl include include/xpgom src/xpgom

0 views
Skip to first unread message

codesite...@google.com

unread,
Aug 17, 2008, 1:51:42 AM8/17/08
to gom-c...@googlegroups.com
Author: ja...@87k.net
Date: Sat Aug 16 22:50:31 2008
New Revision: 76

Added:
trunk/gom/idl/xgIWindow.idl
trunk/gom/include/nsIScriptGlobalObject.h
trunk/gom/include/xpgom/xgWindow.hh
trunk/gom/src/xpgom/xgNavigator.js.in
trunk/gom/src/xpgom/xgParser.js
trunk/gom/src/xpgom/xgWindow.cc
Removed:
trunk/gom/include/xpgom/xgGomContext.hh
trunk/gom/src/xpgom/xgGomContext.cc
trunk/gom/src/xpgom/xgGomParser.js
Modified:
trunk/gom/ChangeLog
trunk/gom/configure.ac
trunk/gom/idl/Makefile.inc
trunk/gom/idl/xgIParser.idl
trunk/gom/src/xpgom/ (props changed)
trunk/gom/src/xpgom/Makefile.inc
trunk/gom/src/xpgom/xgGomModule.cc
trunk/gom/src/xpgom/xgGtkElement.cc
trunk/gom/src/xpgom/xpgom.js

Log:
2008-08-16 jacob berkman <ja...@ilovegom.org>

* src/xpgom/xgGomModule.cc: update for xgWindow

* src/xpgom/xgNavigator.js.in: an implementation of
nsIDOMNavigator

* src/xpgom/xgParser.js: rename xgGomParser.js

* src/xpgom/xpgom.js: use a window object instead of the
defunct context

* src/xpgom/xgWindow.cc: an xpcom-based window object

Modified: trunk/gom/ChangeLog
==============================================================================
--- trunk/gom/ChangeLog (original)
+++ trunk/gom/ChangeLog Sat Aug 16 22:50:31 2008
@@ -1,5 +1,17 @@
2008-08-16 jacob berkman <ja...@ilovegom.org>

+ * src/xpgom/xgGomModule.cc: update for xgWindow
+
+ * src/xpgom/xgNavigator.js.in: an implementation of
+ nsIDOMNavigator
+
+ * src/xpgom/xgParser.js: rename xgGomParser.js
+
+ * src/xpgom/xpgom.js: use a window object instead of the
+ defunct context
+
+ * src/xpgom/xgWindow.cc: an xpcom-based window object
+
* src/xpgom/xgGomModule.cc (nsGomModuleConstructor):
initialize the gtk widget types here for now, instead of using
the defunct libgom

Modified: trunk/gom/configure.ac
==============================================================================
--- trunk/gom/configure.ac (original)
+++ trunk/gom/configure.ac Sat Aug 16 22:50:31 2008
@@ -24,7 +24,7 @@
GTK_REQVER="2.6.0"
CURL_REQVER="0"

-GOM_MODULES="gtk+-2.0 >= $GTK_REQVER gthread-2.0 gio-2.0"
+GOM_MODULES="gtk+-2.0 >= $GTK_REQVER gthread-2.0"
PKG_CHECK_MODULES(GOM, [$GOM_MODULES])
AC_SUBST(GOM_CFLAGS)
AC_SUBST(GOM_LIBS)
@@ -60,7 +60,6 @@
#

GLIB_PACKAGES="gobject-2.0 gmodule-no-export-2.0"
-
AM_PATH_GLIB_2_0(["$GLIB_REQVER"], :,
AC_MSG_ERROR([
*** GLIB ["$GLIB_REQVER"] or better is required. The latest version of
@@ -70,24 +69,19 @@
# Checks for header files.
CPPFLAGS_save=$CPPFLAGS

-js_cppflags="-I$xulrunnersdk/include/js -DXP_UNIX"
-CPPFLAGS="$CPPFLAGS_save $js_cppflags"
-AC_CHECK_HEADERS([jsapi.h],[],[
- AC_MSG_ERROR([$xulrunnersdk is missing Spidermonkey headers.])
-])
-GOM_CFLAGS="$GOM_CFLAGS $js_cppflags"
-
-xulrunner_cppflags="-I$xulrunnersdk/sdk/include
-I$xulrunnersdk/include/content -I$xulrunnersdk/include/xpcom
-DMOZILLA_STRICT_API"
-CPPFLAGS="$CPPFLAGS_save $xulrunner_cppflags"
+xulrunner_cppflags="-I$xulrunnersdk/sdk/include"
+for subdir in content dom js widget xpcom xpconnect ; do
+ xulrunner_cppflags="$xulrunner_cppflags
-I$xulrunnersdk/include/$subdir"
+done
+CPPFLAGS="$CPPFLAGS_save -include xpcom-config.h $xulrunner_cppflags"
CXXFLAGS="$CXXFLAGS -fshort-wchar"
AC_LANG_PUSH([C++])
-AC_CHECK_HEADERS([nsXPCOM.h nsIIOService.h nsIXTFElementFactory.h
nsIAtom.h],[],[
+AC_CHECK_HEADERS([nsXPCOM.h nsIIOService.h nsIXTFElementFactory.h
nsIAtom.h nsIDOMNavigator.h nsIXPConnect.h nsEvent.h],[],[
AC_MSG_ERROR([$xulrunnersdk is missing XPCOM headers.])
])
AC_LANG_POP([C++])
XPGOM_CFLAGS="$GOM_CFLAGS $xulrunner_cppflags"
-GOM_CFLAGS="$GOM_CFLAGS $xulrunner_cppflags -DXPCOMGLUE=1"
-
+
CPPFLAGS=$CPPFLAGS_save

# Checks for typedefs, structures, and compiler characteristics.
@@ -97,12 +91,6 @@

xulrunner_libs="-L$xulrunnersdk/sdk/lib"
LIBS="$LIBS_save $xulrunner_libs"
-AC_CHECK_LIB([mozjs],[JS_Init],[],[
- AC_MSG_ERROR([$xulrunner is missing Spidermonkey libraries.])
-])
-AC_CHECK_LIB([xpcomglue],[XPCOMGlueStartup],[],[
- AC_MSG_ERROR([$xulrunnersdk is missing XPCOM libraries.])
-])
case $host_os in
darwin*)
xplibpath="-Wl,-executable_path,$xulrunnersdk/bin"
@@ -114,8 +102,7 @@
AC_MSG_ERROR([I don't know how to link components on $host_os])
;;
esac
-XPGOM_LIBS="$GOM_LIBS $xulrunner_libs -L$xulrunnersdk/bin $xplibpath
-lxpcomglue_s -lmozjs -lxpcom -lnspr4"
-GOM_LIBS="$GOM_LIBS $xulrunner_libs -lxpcomglue -lmozjs"
+XPGOM_LIBS="$GOM_LIBS $xulrunner_libs -L$xulrunnersdk/bin $xplibpath
-lxpcomglue_s -lxpcom -lnspr4"

LIBS=$LIBS_save

@@ -127,5 +114,6 @@
AC_CONFIG_FILES([
gom-0.pc
Makefile
+src/xpgom/xgNavigator.js
])
AC_OUTPUT

Modified: trunk/gom/idl/Makefile.inc
==============================================================================
--- trunk/gom/idl/Makefile.inc (original)
+++ trunk/gom/idl/Makefile.inc Sat Aug 16 22:50:31 2008
@@ -1,3 +1,9 @@
# -*- Makefile -*-

dist_noinst_DATA += idl/xgPIWrapped.idl
+dist_noinst_DATA += idl/xgIParser.idl
+dist_noinst_DATA += idl/xgIWindow.idl
+
+noinst_DATA += idl/xgPIWrapped.xpt
+noinst_DATA += idl/xgIParser.xpt
+noinst_DATA += idl/xgIWindow.xpt

Modified: trunk/gom/idl/xgIParser.idl
==============================================================================
--- trunk/gom/idl/xgIParser.idl (original)
+++ trunk/gom/idl/xgIParser.idl Sat Aug 16 22:50:31 2008
@@ -1,15 +1,38 @@
+/*
+The MIT License
+
+Copyright (c) 2008 jacob berkman <ja...@ilovegom.org>
+
+Permission is hereby granted, free of charge, to any person obtaining a
copy
+of this software and associated documentation files (the "Software"), to
deal
+in the Software without restriction, including without limitation the
rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
#include "nsISupports.idl"

interface nsIDOMDocument;

[scriptable, uuid(194C04B0-62FD-4594-822D-1CDB3596BB7C)]
-interface xgIGomParserListener : nsISupports
+interface xgIParserListener : nsISupports
{
- void documentCreated (in nsIDOMDocument document);
+ void documentCreated (in nsIDOMDocument aDocument);
};

[scriptable, uuid(5B251DFE-C380-4298-B547-11A006AB4784)]
-interface xgIGomParser : nsISupports
+interface xgIParser : nsISupports
{
- nsIDOMDocument parseURI (in string uri, in xgIGomParserListener
listener);
+ nsIDOMDocument parseURI (in DOMString aUri, in xgIParserListener
aListener);
};

Added: trunk/gom/idl/xgIWindow.idl
==============================================================================
--- (empty file)
+++ trunk/gom/idl/xgIWindow.idl Sat Aug 16 22:50:31 2008
@@ -0,0 +1,64 @@
+/*
+The MIT License
+
+Copyright (c) 2008 jacob berkman <ja...@ilovegom.org>
+
+Permission is hereby granted, free of charge, to any person obtaining a
copy
+of this software and associated documentation files (the "Software"), to
deal
+in the Software without restriction, including without limitation the
rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+#include "nsISupports.idl"
+
+interface nsIDOMDocument;
+interface nsIDOMNavigator;
+interface nsIDOMLocation;
+
+[scriptable, uuid(3F6DF635-B4FB-4145-A43F-2110FDDE6BBF)]
+interface xgIWindow : nsISupports
+{
+ // cutom stuff
+ void run ();
+
+ // from nsIDOMWindowInternal.idl:
+ readonly attribute xgIWindow window;
+ readonly attribute nsIDOMDocument document;
+ readonly attribute nsIDOMNavigator navigator;
+ readonly attribute nsIDOMLocation location;
+
+ void alert (in DOMString text);
+ void close ();
+
+ // from nsIDOMJSWindow.idl:
+ void dump(in DOMString str);
+
+ /**
+ * These methods take typeless arguments and optional arguments, the
+ * first argument is either a function or a string, the second
+ * argument must be a number (ms) and the rest of the arguments (2
+ * ... n) are passed to the callback function
+ */
+ long setTimeout();
+ long setInterval();
+
+ /**
+ * These methods take one optional argument that's the timer ID to
+ * clear. Often in existing code these methods are passed undefined,
+ * which is a nop so we need to support that as well.
+ */
+ void clearTimeout();
+ void clearInterval();
+};
\ No newline at end of file

Added: trunk/gom/include/nsIScriptGlobalObject.h
==============================================================================
--- (empty file)
+++ trunk/gom/include/nsIScriptGlobalObject.h Sat Aug 16 22:50:31 2008
@@ -0,0 +1,194 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2
-*- */
+/* vim: set ts=2 sw=2 et tw=80: */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later
(the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable
instead
+ * of those above. If you wish to allow use of your version of this file
only
+ * under the terms of either the GPL or the LGPL, and not to allow others
to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the
notice
+ * and other provisions required by the GPL or the LGPL. If you do not
delete
+ * the provisions above, a recipient may use your version of this file
under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef nsIScriptGlobalObject_h__
+#define nsIScriptGlobalObject_h__
+
+#include "nsISupports.h"
+#include "nsEvent.h"
+#include "nsIProgrammingLanguage.h"
+
+class nsIScriptContext;
+class nsIDOMDocument;
+class nsIDOMEvent;
+class nsPresContext;
+class nsIScriptGlobalObjectOwner;
+class nsIArray;
+class nsScriptErrorEvent;
+class nsIScriptGlobalObject;
+enum nsEventStatus;
+struct JSObject; // until we finally remove GetGlobalJSObject...
+
+// Some helpers for working with integer "script type IDs", and
specifically
+// for working with arrays of such objects. For example, it is common for
+// implementations supporting multiple script languages to keep each
+// language's nsIScriptContext in an array indexed by the language ID.
+
+// Implementation note: We always ignore nsIProgrammingLanguage::UNKNOWN
and
+// nsIProgrammingLanguage::CPLUSPLUS - this gives javascript slot 0. An
+// attempted micro-optimization tried to avoid us going all the way to
+// nsIProgrammingLanguage::MAX; however:
+// * Someone is reportedly working on a PHP impl - that has value 9
+// * nsGenericElement therefore allows 4 bits for the value.
+// So there is no good reason for us to be more restrictive again...
+
+#define NS_STID_FIRST nsIProgrammingLanguage::JAVASCRIPT
+// like nsGenericElement, only 4 bits worth is valid...
+#define NS_STID_LAST (nsIProgrammingLanguage::MAX > 0x000FU ? \
+ 0x000FU : nsIProgrammingLanguage::MAX)
+
+// Use to declare the array size
+#define NS_STID_ARRAY_UBOUND (NS_STID_LAST-NS_STID_FIRST+1)
+
+// Is a language ID valid?
+#define NS_STID_VALID(langID) (langID >= NS_STID_FIRST && langID <=
NS_STID_LAST)
+
+// Return an index for a given ID.
+#define NS_STID_INDEX(langID) (langID-NS_STID_FIRST)
+
+// Create a 'for' loop iterating over all possible language IDs (*not*
indexes)
+#define NS_STID_FOR_ID(varName) \
+ for (varName=NS_STID_FIRST;varName<=NS_STID_LAST;varName++)
+
+// Create a 'for' loop iterating over all indexes (when you don't need to
know
+// what language it is)
+#define NS_STID_FOR_INDEX(varName) \
+ for (varName=0;varName<=NS_STID_INDEX(NS_STID_LAST);varName++)
+
+// A helper function for nsIScriptGlobalObject implementations to use
+// when handling a script error. Generally called by the global when a
context
+// notifies it of an error via nsIScriptGlobalObject::HandleScriptError.
+// Returns PR_TRUE if HandleDOMEvent was actually called, in which case
+// aStatus will be filled in with the status.
+PRBool
+NS_HandleScriptError(nsIScriptGlobalObject *aScriptGlobal,
+ nsScriptErrorEvent *aErrorEvent,
+ nsEventStatus *aStatus);
+
+
+#define NS_ISCRIPTGLOBALOBJECT_IID \
+{ /* {6afecd40-0b9a-4cfd-8c42-0f645cd91829} */ \
+ 0x6afecd40, 0x0b9a, 0x4cfd, \
+ { 0x8c, 0x42, 0x0f, 0x64, 0x5c, 0xd9, 0x18, 0x29 } }
+
+/**
++ * The global object which keeps a script context for each supported
script
++ * language. This often used to store per-window global state.
+ */
+
+class nsIScriptGlobalObject : public nsISupports
+{
+public:
+ NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISCRIPTGLOBALOBJECT_IID)
+
+ /**
+ * Ensure that the script global object is initialized for working with
the
+ * specified script language ID. This will set up the nsIScriptContext
+ * and 'script global' for that language, allowing these to be fetched
+ * and manipulated.
+ * @return NS_OK if successful; error conditions include that the
language
+ * has not been registered, as well as 'normal' errors, such as
+ * out-of-memory
+ */
+ virtual nsresult EnsureScriptEnvironment(PRUint32 aLangID) = 0;
+ /**
+ * Get a script context (WITHOUT added reference) for the specified
language.
+ */
+ virtual nsIScriptContext *GetScriptContext(PRUint32 lang) = 0;
+
+ /**
+ * Get the opaque "global" object for the specified lang.
+ */
+ virtual void *GetScriptGlobal(PRUint32 lang) = 0;
+
+ // Set/GetContext deprecated methods - use GetScriptContext/Global
+ virtual JSObject *GetGlobalJSObject() {
+ return (JSObject
*)GetScriptGlobal(nsIProgrammingLanguage::JAVASCRIPT);
+ }
+
+ virtual nsIScriptContext *GetContext() {
+ return GetScriptContext(nsIProgrammingLanguage::JAVASCRIPT);
+ }
+
+ /**
+ * Set a new language context for this global. The native global for the
+ * context is created by the context's GetNativeGlobal() method.
+ */
+
+ virtual nsresult SetScriptContext(PRUint32 lang, nsIScriptContext
*aContext) = 0;
+
+ /**
+ * Called when the global script for a language is finalized, typically
as
+ * part of its GC process. By the time this call is made, the
+ * nsIScriptContext for the language has probably already been removed.
+ * After this call, the passed object is dead - which should generally
be the
+ * same object the global is using for a global for that language.
+ */
+
+ virtual void OnFinalize(PRUint32 aLangID, void *aScriptGlobal) = 0;
+
+ /**
+ * Called to enable/disable scripts.
+ */
+ virtual void SetScriptsEnabled(PRBool aEnabled, PRBool aFireTimeouts) =
0;
+
+ /** Set a new arguments object for this window. This will be set on
+ * the window right away (if there's an existing document) and it
+ * will also be installed on the window when the next document is
+ * loaded. Each language impl is responsible for converting to
+ * an array of args as appropriate for that language.
+ */
+ virtual nsresult SetNewArguments(nsIArray *aArguments) = 0;
+
+ /** Handle a script error. Generally called by a script context.
+ */
+ virtual nsresult HandleScriptError(nsScriptErrorEvent *aErrorEvent,
+ nsEventStatus *aEventStatus)
+#if 0
+ {
+ return NS_HandleScriptError(this, aErrorEvent, aEventStatus);
+ }
+#else
+ = 0;
+#endif
+};
+
+NS_DEFINE_STATIC_IID_ACCESSOR(nsIScriptGlobalObject,
+ NS_ISCRIPTGLOBALOBJECT_IID)
+
+#endif

Added: trunk/gom/include/xpgom/xgWindow.hh
==============================================================================
--- (empty file)
+++ trunk/gom/include/xpgom/xgWindow.hh Sat Aug 16 22:50:31 2008
@@ -0,0 +1,78 @@
+/*
+The MIT License
+
+Copyright (c) 2008 jacob berkman <ja...@ilovegom.org>
+
+Permission is hereby granted, free of charge, to any person obtaining a
copy
+of this software and associated documentation files (the "Software"), to
deal
+in the Software without restriction, including without limitation the
rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+#ifndef XG_WINDOW_HH
+#define XG_WINDOW_HH
+
+#include <xgIWindow.hh>
+
+#include <nsIScriptGlobalObject.h>
+#include <nsCOMPtr.h>
+#include <jsapi.h>
+
+#define XG_WINDOW_CID_STR "86BACE85-5414-4A67-A5E2-825EAE4169CB"
+#define XG_WINDOW_CID \
+ { 0x86BACE85, 0x5414, 0x4A67, { 0xA5, 0xE2, 0x82, 0x5E, 0xAE, 0x41,
0x69, 0xCB } }
+#define XG_WINDOW_CONTRACTID "@ilovegom.org/window;1"
+
+class xgWindow : public nsIScriptGlobalObject,
+ public xgIWindow
+{
+public:
+ NS_DECL_ISUPPORTS
+ NS_DECL_XGIWINDOW
+
+ // nsIScriptGlobalObject
+ nsresult EnsureScriptEnvironment (PRUint32 aLangID);
+ nsIScriptContext *GetScriptContext (PRUint32 lang);
+ void *GetScriptGlobal (PRUint32 lang);
+ nsresult SetScriptContext (PRUint32 lang, nsIScriptContext *aContext);
+ void OnFinalize (PRUint32 aLangID, void *aScriptGlobal);
+ void SetScriptsEnabled (PRBool aEnabled, PRBool aFireTimeouts);
+ nsresult SetNewArguments(nsIArray *aArguments);
+ nsresult HandleScriptError(nsScriptErrorEvent *aErrorEvent,
+ nsEventStatus *aEventStatus);
+
+ xgWindow();
+ nsresult Init ();
+
+ // oh well
+ nsresult SetDocument (nsIDOMDocument *aDocument);
+
+private:
+ ~xgWindow();
+
+protected:
+
+ // xgIWindow
+ nsCOMPtr<nsIDOMDocument> mDocument;
+ nsCOMPtr<nsIDOMNavigator> mNavigator;
+ nsCOMPtr<nsIDOMLocation> mLocation;
+
+ // nsIScriptGlobalObject
+ nsCOMPtr<nsIScriptContext> mContext[NS_STID_ARRAY_UBOUND];
+ void *mGlobal[NS_STID_ARRAY_UBOUND];
+};
+
+
+#endif // XG_WINDOW_HH

Modified: trunk/gom/src/xpgom/Makefile.inc
==============================================================================
--- trunk/gom/src/xpgom/Makefile.inc (original)
+++ trunk/gom/src/xpgom/Makefile.inc Sat Aug 16 22:50:31 2008
@@ -13,18 +13,20 @@
#libxpgom_la_SOURCES += src/xpgom/xgDocument.cc
#libxpgom_la_SOURCES += src/xpgom/xgDOMImplementation.cc
#libxpgom_la_SOURCES += src/xpgom/xgElement.cc
-libxpgom_la_SOURCES += src/xpgom/xgGomContext.cc
libxpgom_la_SOURCES += src/xpgom/xgGomElementFactory.cc
libxpgom_la_SOURCES += src/xpgom/xgGtkElement.cc
libxpgom_la_SOURCES += src/xpgom/xgGtkElementFactory.cc
libxpgom_la_SOURCES += src/xpgom/xgGomModule.cc
#libxpgom_la_SOURCES += src/xpgom/xgNode.cc
+libxpgom_la_SOURCES += src/xpgom/xgWindow.cc
#libxpgom_la_SOURCES += src/xpgom/xgWrapped.cc

-#$(libxpgom_la_SOURCES): idl/xgPIWrapped.hh idl/xgIGomContext.hh
idl/xgIGomParser.hh
+$(libxpgom_la_SOURCES): idl/xgPIWrapped.hh idl/xgIWindow.hh
idl/xgIParser.hh

libxpgom_la_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include
-I$(top_builddir)/idl $(XPGOM_CFLAGS)
libxpgom_la_LIBDADD :=
libxpgom_la_LDFLAGS := -avoid-version -export-dynamic -no-undefined
$(XPGOM_LIBS)
+
+dist_noinst_DATA += src/xpgom/xgParser.js

# libxpgom_la_DEPENDENCIES := libgom.a

Modified: trunk/gom/src/xpgom/xgGomModule.cc
==============================================================================
--- trunk/gom/src/xpgom/xgGomModule.cc (original)
+++ trunk/gom/src/xpgom/xgGomModule.cc Sat Aug 16 22:50:31 2008
@@ -34,7 +34,7 @@
#include "xpgom/gomwrappedattr.hh"
#endif

-#include "xpgom/xgGomContext.hh"
+#include "xpgom/xgWindow.hh"
#include "xpgom/xgGomElementFactory.hh"
#include "xpgom/xgGtkElementFactory.hh"

@@ -51,10 +51,10 @@
NS_GENERIC_FACTORY_CONSTRUCTOR(xgGomElementFactory);
NS_GENERIC_FACTORY_CONSTRUCTOR(xgGtkElementFactory);
//NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(xgDOMImplementation, Init);
-NS_GENERIC_FACTORY_CONSTRUCTOR (xgGomContext);
+NS_GENERIC_FACTORY_CONSTRUCTOR_INIT (xgWindow, Init);

//NS_DECL_CLASSINFO(xgDOMImplementation)
-NS_DECL_CLASSINFO (xgGomContext)
+NS_DECL_CLASSINFO (xgWindow)

static const nsModuleComponentInfo components[] = {
{
@@ -68,13 +68,13 @@
xgGtkElementFactoryConstructor
},
{
- "Gom Application Context",
- XG_GOMCONTEXT_CID, XG_GOMCONTEXT_CONTRACTID,
- xgGomContextConstructor,
+ "Gom Global Window Object",
+ XG_WINDOW_CID, XG_WINDOW_CONTRACTID,
+ xgWindowConstructor,
NULL, NULL, NULL,
- NS_CI_INTERFACE_GETTER_NAME (xgGomContext),
+ NS_CI_INTERFACE_GETTER_NAME (xgWindow),
NULL,
- &NS_CLASSINFO_NAME (xgGomContext)
+ &NS_CLASSINFO_NAME (xgWindow)

#if 0
},

Modified: trunk/gom/src/xpgom/xgGtkElement.cc
==============================================================================
--- trunk/gom/src/xpgom/xgGtkElement.cc (original)
+++ trunk/gom/src/xpgom/xgGtkElement.cc Sat Aug 16 22:50:31 2008
@@ -25,8 +25,6 @@

#include "xpgom/xgGtkElement.hh"

-#include "xpgom/xgObjectUtils.hh"
-
#include <nsIAtom.h>
#include <nsIDOMNode.h>
#include <nsIDOMElement.h>

Added: trunk/gom/src/xpgom/xgNavigator.js.in
==============================================================================
--- (empty file)
+++ trunk/gom/src/xpgom/xgNavigator.js.in Sat Aug 16 22:50:31 2008
@@ -0,0 +1,99 @@
+/*
+The MIT License
+
+Copyright (c) 2008 jacob berkman <ja...@ilovegom.org>
+
+Permission is hereby granted, free of charge, to any person obtaining a
copy
+of this software and associated documentation files (the "Software"), to
deal
+in the Software without restriction, including without limitation the
rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+ */
+var xgNavigatorModule = { };
+function NSGetModule (aCompMgr, aFileSpec) { return xgNavigatorModule; }
+
+(function () {
+
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+
+const CLASS_ID = Components.ID('{A09E6353-FE78-4C69-AD70-0E5CC59345E3}');
+const CLASS_NAME = 'An Navigator object for Gom';
+const CONTRACT_ID = '@ilovegom.org/navigator;1';
+
+function xgNavigator() {
+ this.wrappedJSObject = this;
+};
+
+xgNavigator.prototype = {
+ // nsIDOMNavigator
+ appCodeName: 'Mozilla',
+ appName: 'Gom',
+ appVersion: '@VERSION@',
+ cookieEnabled: false,
+ language: 'en',
+ mimeTypes: null,
+ platform: '@host_os@',
+ userAgent: 'Mozilla/5.0 (compatible; Gom/@VERSION@; @host_os@)',
+
+ javaEnabled: function () { return false; },
+ taintEnabled: function () { return false; },
+
+ // nsISupports
+ QueryInterface: function (aIID) {
+ if (!aIID.equals(Ci.nsIDOMNavigator) &&
+ !aIID.equals(Ci.nsISupports))
+ throw Components.results.NS_ERROR_NO_INTERFACE;
+ return this;
+ }
+};
+
+var xgNavigatorFactory = {
+ createInstance: function (aOuter, aIID) {
+ if (aOuter != null) {
+ throw Components.results.NS_ERROR_NO_AGGREGATION;
+ }
+ return (new xgNavigator).QueryInterface (aIID);
+ }
+};
+
+xgNavigatorModule.registerSelf = function(aCompMgr, aFileSpec, aLocation,
aType)
+{
+ aCompMgr = aCompMgr.QueryInterface
(Components.interfaces.nsIComponentRegistrar);
+ aCompMgr.registerFactoryLocation (CLASS_ID, CLASS_NAME, CONTRACT_ID,
+ aFileSpec, aLocation, aType);
+};
+
+xgNavigatorModule.unregisterSelf = function (aCompMgr, aLocation, aType)
+{
+ aCompMgr = aCompMgr.QueryInterface
(Components.interfaces.nsIComponentRegistrar);
+ aCompMgr.unregisterFactoryLocation(CLASS_ID, aLocation);
+};
+
+xgNavigatorModule.getClassObject = function(aCompMgr, aCID, aIID)
+{
+ if (!aIID.equals(Ci.nsIFactory)) {
+ throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
+ }
+ if (aCID.equals(CLASS_ID)) {
+ return xgNavigatorFactory;
+ }
+
+ throw Components.results.NS_ERROR_NO_INTERFACE;
+};
+
+xgNavigatorModule.canUnload = function (aCompMgr) { return true; }
+
+})();

Added: trunk/gom/src/xpgom/xgParser.js
==============================================================================
--- (empty file)
+++ trunk/gom/src/xpgom/xgParser.js Sat Aug 16 22:50:31 2008
@@ -0,0 +1,148 @@
+/*
+The MIT License
+
+Copyright (c) 2008 jacob berkman <ja...@ilovegom.org>
+
+Permission is hereby granted, free of charge, to any person obtaining a
copy
+of this software and associated documentation files (the "Software"), to
deal
+in the Software without restriction, including without limitation the
rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+var xgParserModule = { };
+function NSGetModule (aCompMgr, aFileSpec) { return xgParserModule; }
+
+(function () {
+
+var Cc = Components.classes;
+var Ci = Components.interfaces;
+
+const CLASS_ID = Components.ID("{E643FF76-1F9C-452A-A0A6-421B1AA1AFE5}");
+const CLASS_NAME = "An XML Parser for Gom";
+const CONTRACT_ID = "@ilovegom.org/parser;1";
+
+function xgParser() {
+ this.wrappedJSObject = this;
+};
+
+function getDOMImplementation() {
+ // return
Cc['@ilovegom.org/dom-implementation;1'].createInstance(Ci.nsIDOMDOMImplementation);
+ var parser = Cc['@mozilla.org/xmlextras/domparser;1'].createInstance
(Ci.nsIDOMParser);
+ var document = parser.parseFromString('', "text/xml");
+ return document.implementation;
+};
+
+xgParser.prototype = {
+ // xgIGomParser
+ parseURI: function (uri, listener) {
+ var io = Cc['@mozilla.org/network/io-service;1'].getService
(Ci.nsIIOService);
+ var uri = io.newURI (uri, null, null);
+
+ var chan = io.newChannelFromURI (uri);
+ var stream = chan.open();
+
+ var reader = Cc['@mozilla.org/saxparser/xmlreader;1'].createInstance
(Ci.nsISAXXMLReader);
+ var document = null;
+ reader.contentHandler = {
+ elem: null,
+
+ // nsISAXContentHandler
+ startDocument: function () { },
+ endDocument: function () { },
+
+ startElement: function (nsUri, localName, qName, /*nsISAXAttributes*/
attributes) {
+ var elem;
+ if (document) {
+ elem = document.createElementNS (nsUri, qName);
+ } else {
+ document = getDOMImplementation ().createDocument (nsUri, qName,
null);
+ if (listener) {
+ listener.documentCreated (document);
+ }
+ elem = document.documentElement;
+ }
+ for(var i = 0; i < attributes.length; i++) {
+ elem.setAttribute (attributes.getLocalName (i),
+ attributes.getValue (i));
+ }
+ this.elem = this.elem ? this.elem.appendChild (elem) : elem;
+ },
+
+ endElement: function(uri, localName, qName) {
+ this.elem = this.elem.parentNode;
+ },
+
+ characters: function(value) { },
+ processingInstruction: function(target, data) { },
+ ignorableWhitespace: function(whitespace) { },
+ startPrefixMapping: function(prefix, uri) { },
+ endPrefixMapping: function(prefix) { },
+
+ // nsISupports
+ QueryInterface: function(iid) {
+ if(!iid.equals(Ci.nsISupports) &&
+ !iid.equals(Ci.nsISAXContentHandler))
+ throw Components.results.NS_ERROR_NO_INTERFACE;
+ return this;
+ }
+ };
+ reader.parseFromStream (stream, 'UTF-8', 'text/xml');
+ return document;
+ },
+ // nsISupports
+ QueryInterface: function (aIID) {
+ if (!aIID.equals(Ci.xgIParser) &&
+ !aIID.equals(Ci.nsISupports))
+ throw Components.results.NS_ERROR_NO_INTERFACE;
+ return this;
+ }
+};
+
+var xgParserFactory = {
+ createInstance: function (aOuter, aIID) {
+ if (aOuter != null) {
+ throw Components.results.NS_ERROR_NO_AGGREGATION;
+ }
+ return (new xgParser).QueryInterface (aIID);
+ }
+};
+
+xgParserModule.registerSelf = function(aCompMgr, aFileSpec, aLocation,
aType)
+{
+ aCompMgr = aCompMgr.QueryInterface
(Components.interfaces.nsIComponentRegistrar);
+ aCompMgr.registerFactoryLocation (CLASS_ID, CLASS_NAME, CONTRACT_ID,
+ aFileSpec, aLocation, aType);
+};
+
+xgParserModule.unregisterSelf = function (aCompMgr, aLocation, aType)
+{
+ aCompMgr = aCompMgr.QueryInterface
(Components.interfaces.nsIComponentRegistrar);
+ aCompMgr.unregisterFactoryLocation(CLASS_ID, aLocation);
+};
+
+xgParserModule.getClassObject = function(aCompMgr, aCID, aIID)
+{
+ if (!aIID.equals(Ci.nsIFactory)) {
+ throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
+ }
+ if (aCID.equals(CLASS_ID))
+ return xgParserFactory;
+
+ throw Components.results.NS_ERROR_NO_INTERFACE;
+};
+
+xgParserModule.canUnload = function(aCompMgr) { return true; }
+
+})();

Added: trunk/gom/src/xpgom/xgWindow.cc
==============================================================================
--- (empty file)
+++ trunk/gom/src/xpgom/xgWindow.cc Sat Aug 16 22:50:31 2008
@@ -0,0 +1,473 @@
+/*
+The MIT License
+
+Copyright (c) 2008 jacob berkman <ja...@ilovegom.org>
+
+Permission is hereby granted, free of charge, to any person obtaining a
copy
+of this software and associated documentation files (the "Software"), to
deal
+in the Software without restriction, including without limitation the
rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+#include "config.h"
+
+#include "xpgom/xgWindow.hh"
+#include "xgIParser.hh"
+
+#include <nsComponentManagerUtils.h>
+#include <nsDOMCID.h>
+#include <nsIClassInfoImpl.h>
+#include <nsIDOMDocument.h>
+#include <nsIDOMLocation.h>
+#include <nsIDOMNavigator.h>
+#include <nsIDOMScriptObjectFactory.h>
+#include <nsIScriptContext.h>
+#include <nsIScriptRuntime.h>
+#include <nsMemory.h>
+#include <nsServiceManagerUtils.h>
+#include <nsStringAPI.h>
+
+#include <glib/gmacros.h>
+#include <glib/gmessages.h>
+
+#include <gtk/gtkmain.h>
+
+#include "gommacros.h"
+
+static NS_DEFINE_CID (kDOMScriptObjectFactoryCID,
NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
+class xgLocation : public nsIDOMLocation
+{
+public:
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIDOMLOCATION
+
+ xgLocation (xgWindow *aWindow);
+
+private:
+ ~xgLocation();
+
+protected:
+ xgWindow *mWindow;
+};
+
+class xgWindowParserListener : public xgIParserListener
+{
+public:
+ NS_DECL_ISUPPORTS
+ NS_DECL_XGIPARSERLISTENER
+
+ xgWindowParserListener(xgWindow *aWindow);
+
+private:
+ ~xgWindowParserListener();
+
+protected:
+ xgWindow *mWindow;
+};
+
+xgWindow::xgWindow ()
+{
+ memset (mGlobal, 0, sizeof (mGlobal));
+}
+
+xgWindow::~xgWindow ()
+{
+ /* destructor code */
+}
+
+NS_IMPL_ISUPPORTS2_CI (xgWindow, xgIWindow, nsIScriptGlobalObject)
+
+nsresult
+xgWindow::Init ()
+{
+ nsresult rv;
+ mNavigator = do_CreateInstance ("@ilovegom.org/navigator;1", &rv);
+ NS_ENSURE_SUCCESS (rv, rv);
+
+ mLocation = new xgLocation (this);
+ NS_ENSURE_TRUE (mLocation, NS_ERROR_OUT_OF_MEMORY);
+ return NS_OK;
+}
+
+/* readonly attribute xgIWindow window; */
+NS_IMETHODIMP
+xgWindow::GetWindow (xgIWindow **aWindow)
+{
+ NS_ADDREF (*aWindow = this);
+ return NS_OK;
+}
+
+/* readonly attribute nsIDOMDocument document; */
+NS_IMETHODIMP
+xgWindow::GetDocument (nsIDOMDocument **aDocument)
+{
+ NS_IF_ADDREF (*aDocument = mDocument);
+ return NS_OK;
+}
+
+nsresult
+xgWindow::SetDocument (nsIDOMDocument *aDocument)
+{
+ NS_ENSURE_TRUE (aDocument, NS_ERROR_INVALID_ARG);
+
+ nsresult rv = Init ();
+ NS_ENSURE_SUCCESS (rv, rv);
+
+ mDocument = aDocument;
+
+ PRUint32 lang;
+ NS_STID_FOR_INDEX (lang) {
+ nsIScriptContext *cx = mContext[lang];
+ if (cx) {
+ cx->WillInitializeContext ();
+ cx->InitClasses (mGlobal[lang]);
+ cx->DidInitializeContext ();
+ cx->DidSetDocument (aDocument, mGlobal[lang]);
+ }
+ }
+
+ return NS_OK;
+}
+
+/* readonly attribute nsIDOMNavigator navigator; */
+NS_IMETHODIMP
+xgWindow::GetNavigator (nsIDOMNavigator **aNavigator)
+{
+ NS_IF_ADDREF (*aNavigator = mNavigator);
+ return NS_OK;
+}
+
+/* readonly attribute nsIDOMLocation location; */
+NS_IMETHODIMP
+xgWindow::GetLocation (nsIDOMLocation **aLocation)
+{
+ NS_IF_ADDREF (*aLocation = mLocation);
+ return NS_OK;
+}
+
+/* void alert (in DOMString text); */
+NS_IMETHODIMP
+xgWindow::Alert (const nsAString &text)
+{
+ XG_RETURN_NOT_IMPLEMENTED;
+}
+
+/* void run (); */
+NS_IMETHODIMP
+xgWindow::Run ()
+{
+ gtk_main ();
+ return NS_OK;
+}
+
+/* void close (); */
+NS_IMETHODIMP
+xgWindow::Close ()
+{
+ gtk_main_quit ();
+ return NS_OK;
+}
+
+/* void dump (in DOMString str); */
+NS_IMETHODIMP
+xgWindow::Dump (const nsAString &str)
+{
+ GOM_ASTRING_TO_GSTRING_RETURN (gstr, str, NS_ERROR_INVALID_ARG);
+ g_message ("JAVASCRIPT: %s\n", gstr);
+ return NS_OK;
+}
+
+/* long setTimeout (); */
+NS_IMETHODIMP
+xgWindow::SetTimeout (PRInt32 *_retval)
+{
+ XG_RETURN_NOT_IMPLEMENTED;
+}
+
+/* long setInterval (); */
+NS_IMETHODIMP
+xgWindow::SetInterval (PRInt32 *_retval)
+{
+ XG_RETURN_NOT_IMPLEMENTED;
+}
+
+/* void clearTimeout (); */
+NS_IMETHODIMP
+xgWindow::ClearTimeout ()
+{
+ XG_RETURN_NOT_IMPLEMENTED;
+}
+
+/* void clearInterval (); */
+NS_IMETHODIMP
+xgWindow::ClearInterval ()
+{
+ XG_RETURN_NOT_IMPLEMENTED;
+}
+
+nsresult
+xgWindow::EnsureScriptEnvironment (PRUint32 aLangID)
+{
+ NS_ENSURE_TRUE (NS_STID_VALID (aLangID), NS_ERROR_INVALID_ARG);
+
+ if (mGlobal[aLangID]) {
+ return NS_OK;
+ }
+
+ nsresult rv;
+ nsCOMPtr<nsIDOMScriptObjectFactory> sof (do_GetService
(kDOMScriptObjectFactoryCID, &rv));
+ NS_ENSURE_SUCCESS (rv, rv);
+
+ nsCOMPtr<nsIScriptRuntime> rt;
+ rv = sof->GetScriptRuntimeByID (aLangID, getter_AddRefs (rt));
+ NS_ENSURE_SUCCESS (rv, rv);
+
+ nsCOMPtr<nsIScriptContext> cx;
+ rv = rt->CreateContext (getter_AddRefs (cx));
+ NS_ENSURE_SUCCESS (rv, rv);
+
+ return SetScriptContext (aLangID, cx);
+}
+
+nsIScriptContext *
+xgWindow::GetScriptContext (PRUint32 lang)
+{
+ NS_ENSURE_TRUE (NS_STID_VALID (lang), NULL);
+ return mContext[NS_STID_INDEX (lang)];
+}
+
+void *
+xgWindow::GetScriptGlobal (PRUint32 lang)
+{
+ NS_ENSURE_TRUE (NS_STID_VALID (lang), NULL);
+ return mGlobal[NS_STID_INDEX (lang)];
+}
+
+nsresult
+xgWindow::SetScriptContext (PRUint32 lang, nsIScriptContext *aContext)
+{
+ NS_ENSURE_TRUE (NS_STID_VALID (lang), NULL);
+
+ mContext[NS_STID_INDEX (lang)] = aContext;
+ if (aContext) {
+ aContext->DidInitializeContext ();
+ }
+ mGlobal[NS_STID_INDEX (lang)] = aContext ? aContext->GetNativeGlobal
() : NULL;
+
+ return NS_OK;
+}
+
+void
+xgWindow::OnFinalize (PRUint32 aLangID, void *aScriptGlobal)
+{
+ if (!NS_STID_VALID (aLangID)) {
+ return;
+ }
+ mGlobal[NS_STID_INDEX (aLangID)] = NULL;
+}
+
+void
+xgWindow::SetScriptsEnabled (PRBool aEnabled, PRBool aFireTimeouts)
+{
+ GOM_NOT_IMPLEMENTED;
+}
+
+nsresult
+xgWindow::SetNewArguments (nsIArray *aArguments)
+{
+ XG_RETURN_NOT_IMPLEMENTED;
+}
+
+nsresult
+xgWindow::HandleScriptError (nsScriptErrorEvent *aErrorEvent,
+ nsEventStatus *aEventStatus)
+{
+ XG_RETURN_NOT_IMPLEMENTED;
+}
+
+
+/*
+ * nsILocation implementation
+ */
+
+xgLocation::xgLocation (xgWindow *aWindow)
+ : mWindow (aWindow)
+{
+}
+
+xgLocation::~xgLocation ()
+{
+ mWindow = NULL;
+}
+
+NS_IMPL_ISUPPORTS1 (xgLocation, nsIDOMLocation)
+
+/* attribute DOMString hash; */
+NS_IMETHODIMP
+xgLocation::GetHash (nsAString &aHash)
+{
+ XG_RETURN_NOT_IMPLEMENTED;
+}
+NS_IMETHODIMP
+xgLocation::SetHash (const nsAString &aHash)
+{
+ XG_RETURN_NOT_IMPLEMENTED;
+}
+
+/* attribute DOMString host; */
+NS_IMETHODIMP
+xgLocation::GetHost (nsAString &aHost)
+{
+ XG_RETURN_NOT_IMPLEMENTED;
+}
+NS_IMETHODIMP
+xgLocation::SetHost (const nsAString &aHost)
+{
+ XG_RETURN_NOT_IMPLEMENTED;
+}
+
+/* attribute DOMString hostname; */
+NS_IMETHODIMP
+xgLocation::GetHostname (nsAString &aHostname)
+{
+ XG_RETURN_NOT_IMPLEMENTED;
+}
+NS_IMETHODIMP
+xgLocation::SetHostname (const nsAString &aHostname)
+{
+ XG_RETURN_NOT_IMPLEMENTED;
+}
+
+/* attribute DOMString href; */
+NS_IMETHODIMP
+xgLocation::GetHref (nsAString &aHref)
+{
+ XG_RETURN_NOT_IMPLEMENTED;
+}
+NS_IMETHODIMP
+xgLocation::SetHref (const nsAString &aHref)
+{
+ XG_RETURN_NOT_IMPLEMENTED;
+}
+
+/* attribute DOMString pathname; */
+NS_IMETHODIMP
+xgLocation::GetPathname (nsAString &aPathname)
+{
+ XG_RETURN_NOT_IMPLEMENTED;
+}
+NS_IMETHODIMP
+xgLocation::SetPathname (const nsAString &aPathname)
+{
+ XG_RETURN_NOT_IMPLEMENTED;
+}
+
+/* attribute DOMString port; */
+NS_IMETHODIMP
+xgLocation::GetPort (nsAString &aPort)
+{
+ XG_RETURN_NOT_IMPLEMENTED;
+}
+NS_IMETHODIMP
+xgLocation::SetPort (const nsAString &aPort)
+{
+ XG_RETURN_NOT_IMPLEMENTED;
+}
+
+/* attribute DOMString protocol; */
+NS_IMETHODIMP
+xgLocation::GetProtocol (nsAString &aProtocol)
+{
+ XG_RETURN_NOT_IMPLEMENTED;
+}
+NS_IMETHODIMP
+xgLocation::SetProtocol (const nsAString &aProtocol)
+{
+ XG_RETURN_NOT_IMPLEMENTED;
+}
+
+/* attribute DOMString search; */
+NS_IMETHODIMP
+xgLocation::GetSearch (nsAString &aSearch)
+{
+ XG_RETURN_NOT_IMPLEMENTED;
+}
+NS_IMETHODIMP
+xgLocation::SetSearch (const nsAString &aSearch)
+{
+ XG_RETURN_NOT_IMPLEMENTED;
+}
+
+/* [noscript] void reload (in boolean forceget); */
+NS_IMETHODIMP
+xgLocation::Reload (PRBool forceget)
+{
+ XG_RETURN_NOT_IMPLEMENTED;
+}
+
+/* void replace (in DOMString url); */
+NS_IMETHODIMP
+xgLocation::Replace (const nsAString &url)
+{
+ XG_RETURN_NOT_IMPLEMENTED;
+}
+
+/* void assign (in DOMString url); */
+NS_IMETHODIMP
+xgLocation::Assign (const nsAString &url)
+{
+ nsCOMPtr<xgIParserListener> listener (new xgWindowParserListener
(mWindow));
+ NS_ENSURE_TRUE (listener, NS_ERROR_OUT_OF_MEMORY);
+
+ nsresult rv;
+ nsCOMPtr<xgIParser> parser (do_CreateInstance
("@ilovegom.org/parser;1", &rv));
+ NS_ENSURE_SUCCESS (rv, rv);
+
+ nsCOMPtr<nsIDOMDocument> doc;
+ return parser->ParseURI (url, listener, getter_AddRefs (doc));
+}
+
+/* DOMString toString (); */
+NS_IMETHODIMP
+xgLocation::ToString (nsAString &_retval)
+{
+ XG_RETURN_NOT_IMPLEMENTED;
+}
+
+/*
+ * an xgParserListener
+ */
+
+xgWindowParserListener::xgWindowParserListener(xgWindow *aWindow)
+ : mWindow (aWindow)
+{
+ NS_IF_ADDREF (mWindow);
+}
+
+xgWindowParserListener::~xgWindowParserListener()
+{
+ NS_IF_RELEASE (mWindow);
+}
+
+/* Implementation file */
+NS_IMPL_ISUPPORTS1(xgWindowParserListener, xgIParserListener)
+
+/* void documentCreated (in nsIDOMDocument document); */
+NS_IMETHODIMP
+xgWindowParserListener::DocumentCreated (nsIDOMDocument *aDocument)
+{
+ // friend access!
+ return mWindow->SetDocument (aDocument);
+}

Modified: trunk/gom/src/xpgom/xpgom.js
==============================================================================
--- trunk/gom/src/xpgom/xpgom.js (original)
+++ trunk/gom/src/xpgom/xpgom.js Sat Aug 16 22:50:31 2008
@@ -1,3 +1,26 @@
+/*
+The MIT License
+
+Copyright (c) 2008 jacob berkman <ja...@ilovegom.org>
+
+Permission is hereby granted, free of charge, to any person obtaining a
copy
+of this software and associated documentation files (the "Software"), to
deal
+in the Software without restriction, including without limitation the
rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+ */
//(function (args) {
var args = arguments;
if (args.length == 0) {
@@ -5,15 +28,12 @@
quit (1);
}

-var Cc = Components.classes;
-var Ci = Components.interfaces;
-
-var gom = Cc['@ilovegom.org/context;1'].createInstance (Ci.xgIGomContext);
-gom.init (args[0]);
-
-var serializer =
Cc['@mozilla.org/xmlextras/xmlserializer;1'].createInstance(Ci.nsIDOMSerializer);
-print (serializer.serializeToString (gom.document));
+const Cc = Components.classes;
+const Ci = Components.interfaces;

+var gom = Cc['@ilovegom.org/window;1'].createInstance (Ci.xgIWindow);
+gom.dump ('userAgent: ' + gom.navigator.userAgent);
+gom.location.assign (args[0]);
gom.run ();

//})(arguments);

Reply all
Reply to author
Forward
0 new messages