r13965 vince - /trunk/netsurf/javascript/nojs.c
by netsurf@semichrome.net
Author: vince
Date: Wed Jun 13 13:02:46 2012
New Revision: 13965
URL: http://source.netsurf-browser.org?rev=13965&view=rev
Log:
Fix stupid braino missing include for non js case
Modified:
trunk/netsurf/javascript/nojs.c
Modified: trunk/netsurf/javascript/nojs.c
URL: http://source.netsurf-browser.org/trunk/netsurf/javascript/nojs.c?rev=139...
==============================================================================
--- trunk/netsurf/javascript/nojs.c (original)
+++ trunk/netsurf/javascript/nojs.c Wed Jun 13 13:02:46 2012
@@ -19,6 +19,8 @@
/** \file
* Dummy implementation of javascript engine functions.
*/
+
+#include "content/content.h"
#include "javascript/js.h"
#include "utils/log.h"
@@ -45,7 +47,7 @@
return NULL;
}
-bool js_exec(jscontext *ctx, char *txt, int txtlen)
+bool js_exec(jscontext *ctx, const char *txt, int txtlen)
{
return true;
}
10 years, 7 months
r13964 vince - in /trunk/netsurf/javascript: global.c nojs.c
by netsurf@semichrome.net
Author: vince
Date: Wed Jun 13 12:57:16 2012
New Revision: 13964
URL: http://source.netsurf-browser.org?rev=13964&view=rev
Log:
fix include for non javascript builds
Modified:
trunk/netsurf/javascript/global.c
trunk/netsurf/javascript/nojs.c
Modified: trunk/netsurf/javascript/global.c
URL: http://source.netsurf-browser.org/trunk/netsurf/javascript/global.c?rev=1...
==============================================================================
--- trunk/netsurf/javascript/global.c (original)
+++ trunk/netsurf/javascript/global.c Wed Jun 13 12:57:16 2012
@@ -31,15 +31,14 @@
return JS_FALSE;
-#ifdef SPIDERMONKEY_400
+#if JS_VERSION <= 180
+ txt = JS_GetStringBytes(u16_txt);
+#else
unsigned int length;
length = JS_GetStringLength(u16_txt);
txt = alloca(sizeof(char)*(length+1));
JS_EncodeStringToBuffer(u16_txt, txt, length);
txt[length] = '\0';
-
-#else
- txt = JS_GetStringBytes(u16_txt);
#endif
warn_user(txt, NULL);
Modified: trunk/netsurf/javascript/nojs.c
URL: http://source.netsurf-browser.org/trunk/netsurf/javascript/nojs.c?rev=139...
==============================================================================
--- trunk/netsurf/javascript/nojs.c (original)
+++ trunk/netsurf/javascript/nojs.c Wed Jun 13 12:57:16 2012
@@ -20,7 +20,7 @@
* Dummy implementation of javascript engine functions.
*/
-#include "desktop/js.h"
+#include "javascript/js.h"
#include "utils/log.h"
void js_initialise(void)
10 years, 7 months
r13963 rjek - in /trunk/tools/buildsystem/makefiles: Makefile.open64 Makefile.tools
by netsurf@semichrome.net
Author: rjek
Date: Wed Jun 13 12:47:53 2012
New Revision: 13963
URL: http://source.netsurf-browser.org?rev=13963&view=rev
Log:
Add experimental support for building with Open64
Added:
trunk/tools/buildsystem/makefiles/Makefile.open64
- copied, changed from r13962, trunk/tools/buildsystem/makefiles/Makefile.gcc
Modified:
trunk/tools/buildsystem/makefiles/Makefile.tools
Copied: trunk/tools/buildsystem/makefiles/Makefile.open64 (from r13962, trunk/tools/buildsystem/makefiles/Makefile.gcc)
URL: http://source.netsurf-browser.org/trunk/tools/buildsystem/makefiles/Makef...
==============================================================================
--- trunk/tools/buildsystem/makefiles/Makefile.gcc (original)
+++ trunk/tools/buildsystem/makefiles/Makefile.open64 Wed Jun 13 12:47:53 2012
@@ -1,8 +1,8 @@
-# GCC specific toolchain setup
+# Open64 specific toolchain setup
# We assume that we're using a standard GCC/binutils environment
CCDEF := -D
-CCOPT := -O2
+CCOPT := -O3 -IPA
CCNOOPT := -O0
CCDBG := -g
CCINC := -I
@@ -11,7 +11,7 @@
CCSHR := -fPIC
CXXDEF := -D
-CXXOPT := -O2
+CXXOPT := -O3
CXXNOOPT := -O0
CXXDBG := -g
CXXINC := -I
@@ -20,7 +20,9 @@
LDDBG := -g
# Reevaluation is required here
-LDSHR = -shared -Wl,-soname,$(SONAME)
+LDSHR = -ipa -shared -Wl,-soname,$(SONAME)
+
+LDFLAGS := $(LDFLAGS) -ipa
ARFLG := cru
@@ -49,34 +51,6 @@
LDFLAGS := $(LDFLAGS) $(PROFLDFLAGS)
endif
-# RISC OS module extensions
-ifeq ($(COMPONENT_TYPE),riscos-module)
- ifneq ($(TARGET),riscos)
- $(error Attempting to build a RISC OS module for a non-RISC OS target)
- endif
-
- CFLAGS := $(CFLAGS) -mmodule
- CXXFLAGS := $(CXXFLAGS) -mmodule
- LDFLAGS := $(LDFLAGS) -mmodule
-endif
-
-###############################################################################
-# Mac OS X Universal Binaries
-###############################################################################
-
-ifeq ($(TARGET),Darwin)
- ifneq ($(UNIVERSAL),)
- UNIVERSAL_FLAGS := $(foreach arch,$(UNIVERSAL),-arch $(arch) )
- CC_CAN_BUILD_AND_DEP := no
- CC_CANNOT_DEP := yes
-
- CFLAGS := $(CFLAGS) $(UNIVERSAL_FLAGS)
- LDFLAGS := $(LDFLAGS) $(UNIVERSAL_FLAGS)
- CXXFLAGS := $(CXXFLAGS) $(UNIVERSAL_FLAGS)
- ARFLAGS := $(ARFLAGS) -s
- endif
-endif
-
###############################################################################
# Other settings
###############################################################################
Modified: trunk/tools/buildsystem/makefiles/Makefile.tools
URL: http://source.netsurf-browser.org/trunk/tools/buildsystem/makefiles/Makef...
==============================================================================
--- trunk/tools/buildsystem/makefiles/Makefile.tools (original)
+++ trunk/tools/buildsystem/makefiles/Makefile.tools Wed Jun 13 12:47:53 2012
@@ -405,6 +405,9 @@
# (ie, Debian, Apple, etc)
toolchain := clang
endif
+ ifeq ($(word 1,$(ccvsn)),Open64)
+ toolchain := open64
+ endif
endif
ifeq ($(toolchain),)
10 years, 7 months
r13962 vince - in /trunk/netsurf: ./ content/ desktop/ gtk/ javascript/ render/
by netsurf@semichrome.net
Author: vince
Date: Sun Jun 10 17:17:30 2012
New Revision: 13962
URL: http://source.netsurf-browser.org?rev=13962&view=rev
Log:
improve javascript support
Added:
trunk/netsurf/javascript/
trunk/netsurf/javascript/global.c
trunk/netsurf/javascript/global.h
trunk/netsurf/javascript/js.c
- copied, changed from r13958, trunk/netsurf/desktop/js.c
trunk/netsurf/javascript/js.h
- copied, changed from r13958, trunk/netsurf/desktop/js.h
trunk/netsurf/javascript/nojs.c
- copied, changed from r13958, trunk/netsurf/desktop/nojs.c
Removed:
trunk/netsurf/desktop/js.c
trunk/netsurf/desktop/js.h
trunk/netsurf/desktop/nojs.c
Modified:
trunk/netsurf/Makefile.sources
trunk/netsurf/content/content.h
trunk/netsurf/desktop/browser.c
trunk/netsurf/desktop/browser.h
trunk/netsurf/desktop/netsurf.c
trunk/netsurf/gtk/Makefile.target
trunk/netsurf/render/html.c
trunk/netsurf/render/html_internal.h
Modified: trunk/netsurf/Makefile.sources
URL: http://source.netsurf-browser.org/trunk/netsurf/Makefile.sources?rev=1396...
==============================================================================
--- trunk/netsurf/Makefile.sources (original)
+++ trunk/netsurf/Makefile.sources Sun Jun 10 17:17:30 2012
@@ -27,6 +27,13 @@
scrollbar.c sslcert.c textarea.c thumbnail.c tree.c \
tree_url_node.c version.c
+# Javascript sources
+ifeq ($(NETSURF_USE_JS),YES)
+S_JAVASCRIPT += js.c global.c
+else
+S_JAVASCRIPT += nojs.c
+endif
+
# S_COMMON are sources common to all builds
S_COMMON := $(addprefix content/,$(S_CONTENT)) \
$(addprefix content/fetchers/,$(S_FETCHERS)) \
@@ -34,7 +41,8 @@
$(addprefix render/,$(S_RENDER)) \
$(addprefix utils/,$(S_UTILS)) \
$(addprefix utils/http/,$(S_HTTP)) \
- $(addprefix desktop/,$(S_DESKTOP))
+ $(addprefix desktop/,$(S_DESKTOP)) \
+ $(addprefix javascript/,$(S_JAVASCRIPT))
# S_IMAGE are sources related to image management
S_IMAGE_YES := image.c image_cache.c
@@ -61,12 +69,6 @@
S_BROWSER := browser.c download.c frames.c history_core.c netsurf.c \
save_complete.c save_text.c selection.c textinput.c
-ifeq ($(NETSURF_USE_JS),YES)
-S_BROWSER += js.c
-else
-S_BROWSER += nojs.c
-endif
-
S_BROWSER := $(addprefix desktop/,$(S_BROWSER))
# The following files depend on the testament
Modified: trunk/netsurf/content/content.h
URL: http://source.netsurf-browser.org/trunk/netsurf/content/content.h?rev=139...
==============================================================================
--- trunk/netsurf/content/content.h (original)
+++ trunk/netsurf/content/content.h Sun Jun 10 17:17:30 2012
@@ -73,6 +73,7 @@
CONTENT_MSG_REFRESH, /**< wants refresh */
CONTENT_MSG_DOWNLOAD, /**< download, not for display */
CONTENT_MSG_LINK, /**< RFC5988 link */
+ CONTENT_MSG_GETCTX, /**< Javascript context */
} content_msg;
/** RFC5988 metadata link */
@@ -80,7 +81,7 @@
struct content_rfc5988_link *next; /**< next rfc5988_link in list */
lwc_string *rel; /**< the link relationship - must be present */
- nsurl *href; /* the link href - must be present */
+ nsurl *href; /**< the link href - must be present */
lwc_string *hreflang;
lwc_string *type;
lwc_string *media;
@@ -89,8 +90,9 @@
/** Extra data for some content_msg messages. */
union content_msg_data {
- const char *error; /**< Error message, for CONTENT_MSG_ERROR. */
- /** Area of content which needs redrawing, for CONTENT_MSG_REDRAW. */
+ /** CONTENT_MSG_ERROR - Error message */
+ const char *error;
+ /** CONTENT_MSG_REDRAW - Area of content which needs redrawing */
struct {
int x, y, width, height;
/** Redraw the area fully. If false, object must be set,
@@ -103,13 +105,16 @@
/** Dimensions to plot object with. */
int object_width, object_height;
} redraw;
- int delay; /**< Minimum delay, for CONTENT_MSG_REFRESH */
- /** Reformat should not cause a redraw, for CONTENT_MSG_REFORMAT */
+ /** CONTENT_MSG_REFRESH - Minimum delay */
+ int delay;
+ /** CONTENT_MSG_REFORMAT - Reformat should not cause a redraw */
bool background;
- /** Low-level cache handle, for CONTENT_MSG_DOWNLOAD */
+ /** CONTENT_MSG_DOWNLOAD - Low-level cache handle */
struct llcache_handle *download;
- /** rfc5988 link data CONTENT_MSG_RFC5988_LINK */
+ /** CONTENT_MSG_RFC5988_LINK - rfc5988 link data */
struct content_rfc5988_link *rfc5988_link;
+ /** CONTENT_MSG_GETCTX - Javascript context */
+ struct jscontext **jscontext;
};
/** parameters to content redraw */
Modified: trunk/netsurf/desktop/browser.c
URL: http://source.netsurf-browser.org/trunk/netsurf/desktop/browser.c?rev=139...
==============================================================================
--- trunk/netsurf/desktop/browser.c (original)
+++ trunk/netsurf/desktop/browser.c Sun Jun 10 17:17:30 2012
@@ -54,7 +54,8 @@
#include "desktop/selection.h"
#include "desktop/textinput.h"
#include "desktop/plotters.h"
-#include "desktop/js.h"
+
+#include "javascript/js.h"
#include "render/form.h"
#include "render/textplain.h"
@@ -963,9 +964,6 @@
browser_window_set_status(bw, messages_get("Loading"));
bw->history_add = add_to_history;
- /* fresh javascript compartment */
- bw->jsglobal = js_newcompartment(bw->jsctx);
-
/* Verifiable fetches may trigger a download */
if (verifiable)
fetch_flags |= HLCACHE_RETRIEVE_MAY_DOWNLOAD;
@@ -977,28 +975,34 @@
browser_window_callback, bw,
parent != NULL ? &child : NULL,
CONTENT_ANY, &c);
- if (error == NSERROR_NO_FETCH_HANDLER) {
+
+ switch (error) {
+ case NSERROR_NO_FETCH_HANDLER: /* no handler for this type */
gui_launch_url(nsurl_access(nsurl));
nsurl_unref(nsurl);
if (nsref != NULL)
nsurl_unref(nsref);
- return;
- } else if (error != NSERROR_OK) {
+ break;
+
+ case NSERROR_OK:
+ bw->loading_content = c;
+ browser_window_start_throbber(bw);
+ browser_window_refresh_url_bar(bw, nsurl, NULL);
+
+ nsurl_unref(nsurl);
+ if (nsref != NULL)
+ nsurl_unref(nsref);
+ break;
+
+ default: /* assume out of memory */
+ /* TODO: fix all fetcher errors being reported as OOM? */
nsurl_unref(nsurl);
if (nsref != NULL)
nsurl_unref(nsref);
browser_window_set_status(bw, messages_get("NoMemory"));
warn_user("NoMemory", 0);
- return;
- }
-
- bw->loading_content = c;
- browser_window_start_throbber(bw);
- browser_window_refresh_url_bar(bw, nsurl, NULL);
-
- nsurl_unref(nsurl);
- if (nsref != NULL)
- nsurl_unref(nsref);
+
+ }
}
@@ -1389,6 +1393,16 @@
event->data.rfc5988_link);
}
}
+ break;
+
+ case CONTENT_MSG_GETCTX:
+ /* only the content object created by the browser
+ * window requires a new global compartment object
+ */
+ if (js_newcompartment(bw->jsctx,
+ hlcache_handle_get_content(c)) != NULL) {
+ *(event->data.jscontext) = bw->jsctx;
+ }
break;
default:
Modified: trunk/netsurf/desktop/browser.h
URL: http://source.netsurf-browser.org/trunk/netsurf/desktop/browser.h?rev=139...
==============================================================================
--- trunk/netsurf/desktop/browser.h (original)
+++ trunk/netsurf/desktop/browser.h Sun Jun 10 17:17:30 2012
@@ -199,8 +199,6 @@
/** current javascript context */
struct jscontext *jsctx;
- /** current global javascript object */
- struct jsobject *jsglobal;
/** cache of the currently displayed status text. */
char *status_text; /**< Current status bar text. */
Removed: trunk/netsurf/desktop/js.c
URL: http://source.netsurf-browser.org/trunk/netsurf/desktop/js.c?rev=13961&vi...
==============================================================================
--- trunk/netsurf/desktop/js.c (original)
+++ trunk/netsurf/desktop/js.c (removed)
@@ -1,104 +1,0 @@
-#include "mozjs/jsapi.h"
-
-#include "desktop/js.h"
-#include "utils/log.h"
-
-static JSRuntime *rt; /* global runtime */
-
-void js_initialise(void)
-{
- /* Create a JS runtime. */
- rt = JS_NewRuntime(8L * 1024L * 1024L);
- LOG(("New runtime handle %p", rt));
-}
-
-void js_finalise(void)
-{
- if (rt != NULL) {
- LOG(("destroying runtime handle %p", rt));
- JS_DestroyRuntime(rt);
- }
- JS_ShutDown();
-}
-
-/* The error reporter callback. */
-static void js_reportError(JSContext *cx, const char *message, JSErrorReport *report)
-{
- LOG(("%s:%u:%s\n",
- report->filename ? report->filename : "<no filename>",
- (unsigned int) report->lineno,
- message));
-}
-
-jscontext *js_newcontext(void)
-{
- JSContext *cx;
-
- if (rt == NULL) {
- return NULL;
- }
-
- cx = JS_NewContext(rt, 8192);
- if (cx == NULL) {
- return NULL;
- }
- JS_SetOptions(cx, JSOPTION_VAROBJFIX | JSOPTION_JIT );
- JS_SetVersion(cx, JSVERSION_LATEST);
- JS_SetErrorReporter(cx, js_reportError);
-
- LOG(("New Context %p", cx));
-
- return (jscontext *)cx;
-}
-
-void js_destroycontext(jscontext *ctx)
-{
- JSContext *cx = (JSContext *)ctx;
- if (cx != NULL) {
- LOG(("Destroying Context %p", cx));
- JS_DestroyContext(cx);
- }
-}
-
-
-
-/* The class of the global object. */
-static JSClass global_class = {
- "global", JSCLASS_GLOBAL_FLAGS,
- JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
- JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
- JSCLASS_NO_OPTIONAL_MEMBERS
-};
-
-
-jsobject *js_newcompartment(jscontext *ctx)
-{
- JSContext *cx = (JSContext *)ctx;
- JSObject *global;
-
- if (cx == NULL) {
- return NULL;
- }
-#ifdef HAVE_JS_NEWCOMPARTMENTANDGLOBALOBJECT
- global = JS_NewCompartmentAndGlobalObject(cx, &global_class, NULL);
- if (global == NULL) {
- return NULL;
- }
-#else
- global = JS_NewObject(cx, &global_class, NULL, NULL);
- if (global == NULL) {
- return NULL;
- }
- JS_SetGlobalObject(cx, global);
-#endif
-
- /* Populate the global object with the standard globals,
- like Object and Array. */
- if (!JS_InitStandardClasses(cx, global)) {
- return NULL;
- }
-
- LOG(("Creating new global object %p", global));
-
- return (jsobject *)global;
-}
Removed: trunk/netsurf/desktop/js.h
URL: http://source.netsurf-browser.org/trunk/netsurf/desktop/js.h?rev=13961&vi...
==============================================================================
--- trunk/netsurf/desktop/js.h (original)
+++ trunk/netsurf/desktop/js.h (removed)
@@ -1,11 +1,0 @@
-
-typedef struct jscontext jscontext;
-typedef struct jsobject jsobject;
-
-void js_initialise(void);
-void js_finalise(void);
-
-jscontext *js_newcontext(void);
-void js_destroycontext(jscontext *ctx);
-
-jsobject *js_newcompartment(jscontext *ctx);
Modified: trunk/netsurf/desktop/netsurf.c
URL: http://source.netsurf-browser.org/trunk/netsurf/desktop/netsurf.c?rev=139...
==============================================================================
--- trunk/netsurf/desktop/netsurf.c (original)
+++ trunk/netsurf/desktop/netsurf.c Sun Jun 10 17:17:30 2012
@@ -42,7 +42,9 @@
#include "desktop/gui.h"
#include "desktop/options.h"
#include "desktop/searchweb.h"
-#include "desktop/js.h"
+
+#include "javascript/js.h"
+
#include "render/html.h"
#include "render/textplain.h"
#include "utils/log.h"
Removed: trunk/netsurf/desktop/nojs.c
URL: http://source.netsurf-browser.org/trunk/netsurf/desktop/nojs.c?rev=13961&...
==============================================================================
--- trunk/netsurf/desktop/nojs.c (original)
+++ trunk/netsurf/desktop/nojs.c (removed)
@@ -1,24 +1,0 @@
-#include "desktop/js.h"
-#include "utils/log.h"
-
-void js_initialise(void)
-{
-}
-
-void js_finalise(void)
-{
-}
-
-jscontext *js_newcontext(void)
-{
- return NULL;
-}
-
-void js_destroycontext(jscontext *ctx)
-{
-}
-
-jsobject *js_newcompartment(jscontext *ctx)
-{
- return NULL;
-}
Modified: trunk/netsurf/gtk/Makefile.target
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/Makefile.target?rev=1...
==============================================================================
--- trunk/netsurf/gtk/Makefile.target (original)
+++ trunk/netsurf/gtk/Makefile.target Sun Jun 10 17:17:30 2012
@@ -102,7 +102,7 @@
treeview.c scaffolding.c gdk.c completion.c login.c throbber.c \
selection.c history.c window.c filetype.c download.c menu.c \
print.c save.c search.c tabs.c theme.c toolbar.c \
- compat.c cookies.c hotlist.c system_colour.c \
+ compat.c cookies.c hotlist.c system_colour.c \
$(addprefix dialogs/,options.c about.c source.c)
S_GTK := $(addprefix gtk/,$(S_GTK)) $(addprefix utils/,container.c)
Added: trunk/netsurf/javascript/global.c
URL: http://source.netsurf-browser.org/trunk/netsurf/javascript/global.c?rev=1...
==============================================================================
--- trunk/netsurf/javascript/global.c (added)
+++ trunk/netsurf/javascript/global.c Sun Jun 10 17:17:30 2012
@@ -1,0 +1,61 @@
+/*
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf 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 General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "mozjs/jsapi.h"
+
+#include "content/content.h"
+#include "javascript/global.h"
+#include "utils/log.h"
+
+static JSBool jsalert(JSContext *cx, uintN argc, jsval *vp)
+{
+ JSString* u16_txt;
+ char *txt;
+
+ if (!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &u16_txt))
+ return JS_FALSE;
+
+
+#ifdef SPIDERMONKEY_400
+ unsigned int length;
+ length = JS_GetStringLength(u16_txt);
+ txt = alloca(sizeof(char)*(length+1));
+ JS_EncodeStringToBuffer(u16_txt, txt, length);
+ txt[length] = '\0';
+
+#else
+ txt = JS_GetStringBytes(u16_txt);
+#endif
+
+ warn_user(txt, NULL);
+
+ JS_SET_RVAL(cx, vp, JSVAL_VOID);
+
+ return JS_TRUE;
+}
+
+static JSFunctionSpec global_functions[] =
+{
+ JS_FN("alert", jsalert, 1, 0),
+ JS_FS_END
+};
+
+bool js_new_globalfunc(JSContext *cx, JSObject *global)
+{
+ return JS_DefineFunctions(cx, global, global_functions);
+}
Added: trunk/netsurf/javascript/global.h
URL: http://source.netsurf-browser.org/trunk/netsurf/javascript/global.h?rev=1...
==============================================================================
--- trunk/netsurf/javascript/global.h (added)
+++ trunk/netsurf/javascript/global.h Sun Jun 10 17:17:30 2012
@@ -1,0 +1,28 @@
+/*
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf 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 General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** \file
+ * spidermonkey engine global functions.
+ */
+
+#ifndef _NETSURF_JAVASCRIPT_GLOBAL_H_
+#define _NETSURF_JAVASCRIPT_GLOBAL_H_
+
+bool js_new_globalfunc(JSContext *cx, JSObject *global);
+
+#endif
Copied: trunk/netsurf/javascript/js.c (from r13958, trunk/netsurf/desktop/js.c)
URL: http://source.netsurf-browser.org/trunk/netsurf/javascript/js.c?p2=trunk/...
==============================================================================
--- trunk/netsurf/desktop/js.c (original)
+++ trunk/netsurf/javascript/js.c Sun Jun 10 17:17:30 2012
@@ -1,6 +1,27 @@
+/*
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf 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 General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#include "mozjs/jsapi.h"
-#include "desktop/js.h"
+#include "content/content.h"
+#include "javascript/global.h"
+#include "javascript/js.h"
+
#include "utils/log.h"
static JSRuntime *rt; /* global runtime */
@@ -71,7 +92,7 @@
};
-jsobject *js_newcompartment(jscontext *ctx)
+jsobject *js_newcompartment(jscontext *ctx, struct content* c)
{
JSContext *cx = (JSContext *)ctx;
JSObject *global;
@@ -79,7 +100,7 @@
if (cx == NULL) {
return NULL;
}
-#ifdef HAVE_JS_NEWCOMPARTMENTANDGLOBALOBJECT
+#ifdef SPIDERMONKEY_400
global = JS_NewCompartmentAndGlobalObject(cx, &global_class, NULL);
if (global == NULL) {
return NULL;
@@ -92,13 +113,45 @@
JS_SetGlobalObject(cx, global);
#endif
- /* Populate the global object with the standard globals,
- like Object and Array. */
+ JS_SetContextPrivate(cx, c); /* private pointer to content */
+
+ js_new_globalfunc(cx, global);
+
+ /* Populate the global object with the standard globals, like
+ Object and Array. */
if (!JS_InitStandardClasses(cx, global)) {
return NULL;
}
- LOG(("Creating new global object %p", global));
+ LOG(("Created new global object %p", global));
return (jsobject *)global;
}
+
+bool js_exec(jscontext *ctx, const char *txt, int txtlen)
+{
+ JSContext *cx = (JSContext *)ctx;
+
+ //LOG(("%p \"%s\"",cx ,txt));
+
+ if (ctx == NULL) {
+ return false;
+ }
+
+ if (txt == NULL) {
+ return false;
+ }
+
+ if (txtlen == 0) {
+ return false;
+ }
+
+ if (JS_EvaluateScript(cx,
+ JS_GetGlobalObject(cx),
+ txt, txtlen,
+ "<head>", 0, NULL) == JS_TRUE) {
+ return true;
+ }
+
+ return false;
+}
Copied: trunk/netsurf/javascript/js.h (from r13958, trunk/netsurf/desktop/js.h)
URL: http://source.netsurf-browser.org/trunk/netsurf/javascript/js.h?p2=trunk/...
==============================================================================
--- trunk/netsurf/desktop/js.h (original)
+++ trunk/netsurf/javascript/js.h Sun Jun 10 17:17:30 2012
@@ -1,3 +1,27 @@
+/*
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf 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 General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** \file
+ * Interface to javascript engine functions.
+ */
+
+#ifndef _NETSURF_JAVASCRIPT_JS_H_
+#define _NETSURF_JAVASCRIPT_JS_H_
typedef struct jscontext jscontext;
typedef struct jsobject jsobject;
@@ -8,4 +32,8 @@
jscontext *js_newcontext(void);
void js_destroycontext(jscontext *ctx);
-jsobject *js_newcompartment(jscontext *ctx);
+jsobject *js_newcompartment(jscontext *ctx, struct content* c);
+
+bool js_exec(jscontext *ctx, const char *txt, int txtlen);
+
+#endif /* _NETSURF_JAVASCRIPT_JS_H_ */
Copied: trunk/netsurf/javascript/nojs.c (from r13958, trunk/netsurf/desktop/nojs.c)
URL: http://source.netsurf-browser.org/trunk/netsurf/javascript/nojs.c?p2=trun...
==============================================================================
--- trunk/netsurf/desktop/nojs.c (original)
+++ trunk/netsurf/javascript/nojs.c Sun Jun 10 17:17:30 2012
@@ -1,3 +1,25 @@
+/*
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf 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 General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** \file
+ * Dummy implementation of javascript engine functions.
+ */
+
#include "desktop/js.h"
#include "utils/log.h"
@@ -18,7 +40,12 @@
{
}
-jsobject *js_newcompartment(jscontext *ctx)
+jsobject *js_newcompartment(jscontext *ctx, struct content* c)
{
return NULL;
}
+
+bool js_exec(jscontext *ctx, char *txt, int txtlen)
+{
+ return true;
+}
Modified: trunk/netsurf/render/html.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/html.c?rev=13962&r...
==============================================================================
--- trunk/netsurf/render/html.c (original)
+++ trunk/netsurf/render/html.c Sun Jun 10 17:17:30 2012
@@ -38,6 +38,7 @@
#include "desktop/options.h"
#include "desktop/selection.h"
#include "desktop/scrollbar.h"
+#include "javascript/js.h"
#include "image/bitmap.h"
#include "render/box.h"
#include "render/font.h"
@@ -104,6 +105,7 @@
static dom_string *html_dom_string_title;
static dom_string *html_dom_string_base;
static dom_string *html_dom_string_link;
+static dom_string *html_dom_string_script;
dom_string *html_dom_string_target;
static dom_string *html_dom_string__parent;
static dom_string *html_dom_string__self;
@@ -158,6 +160,7 @@
c->box = NULL;
c->font_func = &nsfont;
c->scrollbar = NULL;
+ c->jscontext = NULL;
if (lwc_intern_string("*", SLEN("*"), &c->universal) != lwc_error_ok) {
error = BINDING_NOMEM;
@@ -354,6 +357,40 @@
* it cannot be changed again. */
return html_process_data(c, source_data, source_size);
}
+}
+
+/** process script node */
+static bool html_process_script(html_content *c, dom_node *node)
+{
+ dom_exception exc; /* returned by libdom functions */
+ dom_string *script;
+
+ bool success;
+
+ /* ensure javascript context is available */
+ if (c->jscontext == NULL) {
+ union content_msg_data msg_data;
+
+ msg_data.jscontext = &c->jscontext;
+ content_broadcast(&c->base, CONTENT_MSG_GETCTX, msg_data);
+ LOG(("javascript context %p ", c->jscontext));
+ if (c->jscontext == NULL) {
+ return false;
+ }
+ }
+
+ exc = dom_node_get_text_content(node, &script);
+ if ((exc != DOM_NO_ERR) || (script == NULL)) {
+ return false;
+ }
+
+ js_exec(c->jscontext,
+ dom_string_data(script),
+ dom_string_byte_length(script)) ;
+
+ dom_string_unref(script);
+
+ return success;
}
/** process link node */
@@ -557,6 +594,9 @@
} else if (dom_string_caseless_isequal(node_name,
html_dom_string_link)) {
html_process_link(c, node);
+ } else if (dom_string_caseless_isequal(node_name,
+ html_dom_string_script)) {
+ html_process_script(c, node);
}
}
}
@@ -3037,6 +3077,7 @@
HTML_DOM_STRING_UNREF(sizes);
HTML_DOM_STRING_UNREF(title);
HTML_DOM_STRING_UNREF(base);
+ HTML_DOM_STRING_UNREF(script);
HTML_DOM_STRING_UNREF(link);
HTML_DOM_STRING_UNREF(target);
HTML_DOM_STRING_UNREF(_blank);
@@ -3165,6 +3206,7 @@
HTML_DOM_STRING_INTERN(title);
HTML_DOM_STRING_INTERN(base);
HTML_DOM_STRING_INTERN(link);
+ HTML_DOM_STRING_INTERN(script);
HTML_DOM_STRING_INTERN(target);
HTML_DOM_STRING_INTERN(_blank);
HTML_DOM_STRING_INTERN(_self);
Modified: trunk/netsurf/render/html_internal.h
URL: http://source.netsurf-browser.org/trunk/netsurf/render/html_internal.h?re...
==============================================================================
--- trunk/netsurf/render/html_internal.h (original)
+++ trunk/netsurf/render/html_internal.h Sun Jun 10 17:17:30 2012
@@ -104,6 +104,10 @@
/** Context for free text search, or NULL if none */
struct search_context *search;
+
+ /** javascript context */
+ struct jscontext *jscontext;
+
} html_content;
10 years, 7 months
r13960 vince - /trunk/netsurf/gtk/tabs.c
by netsurf@semichrome.net
Author: vince
Date: Sun Jun 10 09:53:25 2012
New Revision: 13960
URL: http://source.netsurf-browser.org?rev=13960&view=rev
Log:
remove supurflous variable
Modified:
trunk/netsurf/gtk/tabs.c
Modified: trunk/netsurf/gtk/tabs.c
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/tabs.c?rev=13960&r1=1...
==============================================================================
--- trunk/netsurf/gtk/tabs.c (original)
+++ trunk/netsurf/gtk/tabs.c Sun Jun 10 09:53:25 2012
@@ -214,13 +214,15 @@
GtkWidget *label;
GtkWidget *tab;
tab = nsgtk_window_get_tab(g);
- gboolean is_top_level = (tab != NULL);
-
- if (is_top_level) {
- label = g_object_get_data(G_OBJECT(tab), "label");
- gtk_label_set_text(GTK_LABEL(label), title);
- gtk_widget_set_tooltip_text(tab, title);
- }
+
+ if (tab == NULL) {
+ return;
+ }
+
+ label = g_object_get_data(G_OBJECT(tab), "label");
+ gtk_label_set_text(GTK_LABEL(label), title);
+ gtk_widget_set_tooltip_text(tab, title);
+
}
/* exported interface documented in gtk/tabs.h */
10 years, 7 months
r13959 vince - in /trunk/netsurf: Makefile gtk/res/blankpage
by netsurf@semichrome.net
Author: vince
Date: Sun Jun 10 09:51:40 2012
New Revision: 13959
URL: http://source.netsurf-browser.org?rev=13959&view=rev
Log:
remove junk blank page resource
Removed:
trunk/netsurf/gtk/res/blankpage
Modified:
trunk/netsurf/Makefile
Modified: trunk/netsurf/Makefile
URL: http://source.netsurf-browser.org/trunk/netsurf/Makefile?rev=13959&r1=139...
==============================================================================
--- trunk/netsurf/Makefile (original)
+++ trunk/netsurf/Makefile Sun Jun 10 09:51:40 2012
@@ -625,7 +625,6 @@
@cp nsgtk $(DESTDIR)$(NETSURF_GTK_BIN)netsurf
@cp -RL gtk/res/adblock.css $(DESTDIR)$(NETSURF_GTK_RESOURCES)
@cp -RL gtk/res/arrow_down_8x32.png $(DESTDIR)$(NETSURF_GTK_RESOURCES)
- @cp -RL gtk/res/blankpage $(DESTDIR)$(NETSURF_GTK_RESOURCES)
@cp -RL gtk/res/ca-bundle.txt $(DESTDIR)$(NETSURF_GTK_RESOURCES)
@cp -RL gtk/res/default.css $(DESTDIR)$(NETSURF_GTK_RESOURCES)
@cp -RL gtk/res/default.ico $(DESTDIR)$(NETSURF_GTK_RESOURCES)
Removed: trunk/netsurf/gtk/res/blankpage
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/res/blankpage?rev=139...
==============================================================================
--- trunk/netsurf/gtk/res/blankpage (original)
+++ trunk/netsurf/gtk/res/blankpage (removed)
@@ -1,32 +1,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
10 years, 7 months
r13958 mono - /trunk/netsurf/atari/ctxmenu.c
by netsurf@semichrome.net
Author: mono
Date: Mon Jun 4 16:53:06 2012
New Revision: 13958
URL: http://source.netsurf-browser.org?rev=13958&view=rev
Log:
Added "Save link as..." context menu item.
Modified:
trunk/netsurf/atari/ctxmenu.c
Modified: trunk/netsurf/atari/ctxmenu.c
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/ctxmenu.c?rev=13958...
==============================================================================
--- trunk/netsurf/atari/ctxmenu.c (original)
+++ trunk/netsurf/atari/ctxmenu.c Mon Jun 4 16:53:06 2012
@@ -140,7 +140,7 @@
{
#define POP_FIRST_ITEM POP_CTX_CUT_SEL
-#define POP_LAST_ITEM POP_CTX_VIEW_SOURCE
+#define POP_LAST_ITEM POP_CTX_SAVE_LINK_AS
OBJECT * pop;
int choice;
@@ -175,10 +175,10 @@
}
if( ctx->flags & CNT_HREF ){
- SET_BIT(pop[ POP_CTX_SAVE_AS ].ob_state, DISABLED, 0);
- SET_BIT(pop[ POP_CTX_COPY_LINK ].ob_state, DISABLED, 0);
- SET_BIT(pop[ POP_CTX_OPEN_NEW ].ob_state, DISABLED, 0);
- }
+ SET_BIT(pop[ POP_CTX_COPY_LINK ].ob_state, DISABLED, 0);
+ SET_BIT(pop[ POP_CTX_OPEN_NEW ].ob_state, DISABLED, 0);
+ SET_BIT(pop[ POP_CTX_SAVE_LINK_AS ].ob_state, DISABLED, 0);
+ }
if( ctx->flags & CNT_IMG ){
SET_BIT(pop[ POP_CTX_SAVE_AS ].ob_state, DISABLED, 0);
@@ -209,14 +209,26 @@
browser_window_key_press( gw->browser->bw, KEY_SELECT_ALL );
break;
- case POP_CTX_SAVE_AS:
- if( hlcache_handle_get_url(ctx->ccdata.object) != NULL ){
+ case POP_CTX_SAVE_AS:
+ if( ctx->ccdata.object != NULL ) {
+ if( hlcache_handle_get_url(ctx->ccdata.object) != NULL ) {
+ browser_window_download(
+ gw->browser->bw,
+ nsurl_access(hlcache_handle_get_url(ctx->ccdata.object)),
+ nsurl_access(hlcache_handle_get_url(gw->browser->bw->current_content))
+ );
+ }
+ }
+
+ case POP_CTX_SAVE_LINK_AS:
+ if( ctx->ccdata.link_url != NULL ) {
browser_window_download(
gw->browser->bw,
- nsurl_access(hlcache_handle_get_url(ctx->ccdata.object)),
+ nsurl_access(ctx->ccdata.link_url),
nsurl_access(hlcache_handle_get_url(gw->browser->bw->current_content))
- );
- }
+ );
+ }
+
break;
case POP_CTX_COPY_URL:
10 years, 8 months
r13957 mono - in /trunk/netsurf/atari/res: netsurf.rsc netsurf.rsh netsurf.rsm
by netsurf@semichrome.net
Author: mono
Date: Mon Jun 4 16:52:41 2012
New Revision: 13957
URL: http://source.netsurf-browser.org?rev=13957&view=rev
Log:
Added "Save link as..." context menu item.
Modified:
trunk/netsurf/atari/res/netsurf.rsc
trunk/netsurf/atari/res/netsurf.rsh
trunk/netsurf/atari/res/netsurf.rsm
Modified: trunk/netsurf/atari/res/netsurf.rsc
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/res/netsurf.rsc?rev...
==============================================================================
Binary files - no diff available.
Modified: trunk/netsurf/atari/res/netsurf.rsh
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/res/netsurf.rsh?rev...
==============================================================================
--- trunk/netsurf/atari/res/netsurf.rsh (original)
+++ trunk/netsurf/atari/res/netsurf.rsh Mon Jun 4 16:52:41 2012
@@ -124,6 +124,7 @@
#define POP_CTX_COPY_URL 8 /* TEXT in tree POP_CTX */
#define POP_CTX_SAVE_AS 9 /* TEXT in tree POP_CTX */
#define POP_CTX_VIEW_SOURCE 10 /* TEXT in tree POP_CTX */
+#define POP_CTX_SAVE_LINK_AS 11 /* TEXT in tree POP_CTX */
#define CHOICES 13 /* form/dial */
#define CHOICES_REG_BROWSER 1 /* BUTTON in tree CHOICES */
Modified: trunk/netsurf/atari/res/netsurf.rsm
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/res/netsurf.rsm?rev...
==============================================================================
--- trunk/netsurf/atari/res/netsurf.rsm (original)
+++ trunk/netsurf/atari/res/netsurf.rsm Mon Jun 4 16:52:41 2012
@@ -3,7 +3,7 @@
#N 99@32@AZAaza___ _@AZAaza090___ _@@_@
#FoC-Header@rsm2out@C-Header@rsh@@@[C-Header@0@
#R 0@0@1@1@1@1@
-#M 20010100@0@7728@599@
+#M 20010100@0@7728@600@
#T 0@1@MAINMENU@@62@@
#O 4@32@T_FILE@@
#O 5@32@T_EDIT@@
@@ -106,7 +106,7 @@
#O 8@21@LBL_SPEED@@
#O 9@26@CB_CLOSE_RDY@@
#T 11@2@ABOUT@@2@@
-#T 12@2@POP_CTX@@11@@
+#T 12@2@POP_CTX@@12@@
#O 1@21@CUT_SEL@@
#O 2@21@COPY_SEL@@
#O 3@21@PASTE_SEL@@
@@ -116,6 +116,7 @@
#O 8@21@COPY_URL@@
#O 9@21@SAVE_AS@@
#O 10@21@VIEW_SOURCE@@
+#O 11@21@SAVE_LINK_AS@@
#T 13@2@CHOICES@@103@@
#O 1@26@REG_BROWSER@@
#O 2@26@REG_RENDER@@
@@ -183,4 +184,4 @@
#O 101@26@CB_BG_IMAGES@@
#O 98@26@ABORT@@
#O 99@26@OK@@
-#c 24297@
+#c 27841@
10 years, 8 months
r13956 mono - /trunk/netsurf/atari/toolbar.c
by netsurf@semichrome.net
Author: mono
Date: Mon Jun 4 16:12:44 2012
New Revision: 13956
URL: http://source.netsurf-browser.org?rev=13956&view=rev
Log:
Fix redraw of embedded toolbar, by removing declaration of already declared local variable. Load toolbar resource trees at toolbar_init().
Modified:
trunk/netsurf/atari/toolbar.c
Modified: trunk/netsurf/atari/toolbar.c
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/toolbar.c?rev=13956...
==============================================================================
--- trunk/netsurf/atari/toolbar.c (original)
+++ trunk/netsurf/atari/toolbar.c Mon Jun 4 16:12:44 2012
@@ -172,6 +172,14 @@
throbber_image = load_icon( "toolbar/default/throbber.png",
toolbar_icon_callback, NULL );
+ } else {
+ RsrcGaddr( h_gem_rsrc, R_TREE, TOOLBAR, &toolbar_buttons );
+ toolbar_buttons->ob_x = 0;
+ toolbar_buttons->ob_y = 0;
+
+ RsrcGaddr( h_gem_rsrc, R_TREE, THROBBER , &throbber_form );
+ throbber_form->ob_x = 0;
+ throbber_form->ob_y = 0;
}
n = (sizeof( toolbar_styles ) / sizeof( struct s_toolbar_style ));
for( i=0; i<n; i++ ){
@@ -268,7 +276,7 @@
plot_clip( &icon_clip );
} else {
/* Place the CICON into workarea: */
- OBJECT * tree = &toolbar_buttons[bt->rsc_id];
+ tree = &toolbar_buttons[bt->rsc_id];
if( tree == NULL )
return;
tree->ob_x = work.g_x;
@@ -737,11 +745,7 @@
t->comp->rect.g_h = toolbar_styles[t->style].height;
t->comp->bounds.max_height = toolbar_styles[t->style].height;
mt_CompEvntDataAdd(&app, t->comp, WM_REDRAW, evnt_toolbar_redraw,
- NULL, EV_BOT);
-
- if( img_toolbar == false ){
- RsrcGaddr( h_gem_rsrc, R_TREE, TOOLBAR, &toolbar_buttons );
- }
+ gw, EV_BOT);
/* count buttons and add them as components: */
i = 0;
@@ -777,13 +781,8 @@
mt_CompEvntAttach( &app, t->url.comp, WM_XBUTTON, evnt_url_click );
mt_CompDataAttach( &app, t->url.comp, CDT_OWNER, gw );
mt_CompAttach( &app, t->comp, t->url.comp );
-
+
/* create the throbber widget: */
- if( throbber_form == NULL && img_toolbar == false ) {
- RsrcGaddr( h_gem_rsrc, R_TREE, THROBBER , &throbber_form );
- throbber_form->ob_x = 0;
- throbber_form->ob_y = 0;
- }
t->throbber.comp = (COMPONENT*)mt_CompCreate(&app, CLT_HORIZONTAL,
toolbar_styles[t->style].height, 0);
t->throbber.comp->rect.g_h = toolbar_styles[t->style].height;
10 years, 8 months