Merge branch 'master' of git://git.netsurf-browser.org/netsurf into chris/palette-mapped-plotters
This commit is contained in:
commit
0210ef066b
|
@ -31,7 +31,7 @@ S_DESKTOP := cookies.c history_global_core.c hotlist.c knockout.c \
|
|||
|
||||
# Javascript sources
|
||||
ifeq ($(NETSURF_USE_JS),YES)
|
||||
S_JSAPI = window.c document.c navigator.c console.c
|
||||
S_JSAPI = window.c document.c navigator.c console.c element.c
|
||||
S_JAVASCRIPT += content.c jsapi.c $(addprefix jsapi/,$(S_JSAPI))
|
||||
else
|
||||
S_JAVASCRIPT += none.c
|
||||
|
|
1836
atari/settings.c
1836
atari/settings.c
File diff suppressed because it is too large
Load Diff
|
@ -788,8 +788,8 @@ content_find_rfc5988_link(hlcache_handle *h, lwc_string *rel)
|
|||
bool rel_match = false;
|
||||
|
||||
while (link != NULL) {
|
||||
lwc_string_caseless_isequal(link->rel, rel, &rel_match);
|
||||
if (rel_match) {
|
||||
if (lwc_string_caseless_isequal(link->rel, rel,
|
||||
&rel_match) == lwc_error_ok && rel_match) {
|
||||
break;
|
||||
}
|
||||
link = link->next;
|
||||
|
|
|
@ -291,9 +291,15 @@ struct fetch * fetch_start(nsurl *url, nsurl *referer,
|
|||
*/
|
||||
bool match1;
|
||||
bool match2;
|
||||
lwc_string_isequal(scheme, ref_scheme, &match);
|
||||
lwc_string_isequal(scheme, fetch_https_lwc, &match1);
|
||||
lwc_string_isequal(ref_scheme, fetch_http_lwc, &match2);
|
||||
if (lwc_string_isequal(scheme, ref_scheme, &match) != lwc_error_ok) {
|
||||
match = false;
|
||||
}
|
||||
if (lwc_string_isequal(scheme, fetch_https_lwc, &match1) != lwc_error_ok) {
|
||||
match1 = false;
|
||||
}
|
||||
if (lwc_string_isequal(ref_scheme, fetch_http_lwc, &match2) != lwc_error_ok) {
|
||||
match2= false;
|
||||
}
|
||||
if (match == true || (match1 == true && match2 == true))
|
||||
fetch->send_referer = true;
|
||||
}
|
||||
|
@ -306,8 +312,7 @@ struct fetch * fetch_start(nsurl *url, nsurl *referer,
|
|||
|
||||
/* Pick the scheme ops */
|
||||
while (fetcher) {
|
||||
lwc_string_isequal(fetcher->scheme_name, scheme, &match);
|
||||
if (match == true) {
|
||||
if ((lwc_string_isequal(fetcher->scheme_name, scheme, &match) == lwc_error_ok) && (match == true)) {
|
||||
fetch->ops = fetcher;
|
||||
break;
|
||||
}
|
||||
|
@ -542,9 +547,9 @@ bool fetch_can_fetch(const nsurl *url)
|
|||
lwc_string *scheme = nsurl_get_component(url, NSURL_SCHEME);
|
||||
|
||||
while (fetcher != NULL) {
|
||||
lwc_string_isequal(fetcher->scheme_name, scheme, &match);
|
||||
if (match == true)
|
||||
if (lwc_string_isequal(fetcher->scheme_name, scheme, &match) == lwc_error_ok && match == true) {
|
||||
break;
|
||||
}
|
||||
|
||||
fetcher = fetcher->next_fetcher;
|
||||
}
|
||||
|
|
|
@ -801,8 +801,7 @@ css_error node_has_name(void *pw, void *node,
|
|||
nscss_select_ctx *ctx = pw;
|
||||
dom_node *n = node;
|
||||
|
||||
lwc_string_isequal(qname->name, ctx->universal, match);
|
||||
if (*match == false) {
|
||||
if (lwc_string_isequal(qname->name, ctx->universal, match) == lwc_error_ok && *match == false) {
|
||||
dom_string *name;
|
||||
dom_exception err;
|
||||
|
||||
|
@ -1058,8 +1057,9 @@ css_error node_has_attribute_includes(void *pw, void *node,
|
|||
const char *start;
|
||||
const char *end;
|
||||
|
||||
*match = false;
|
||||
|
||||
if (vlen == 0) {
|
||||
*match = false;
|
||||
return CSS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -1372,18 +1372,22 @@ nserror browser_window_callback(hlcache_handle *c,
|
|||
|
||||
if (lwc_intern_string("icon", SLEN("icon"),
|
||||
&icon_str) == lwc_error_ok) {
|
||||
lwc_string_caseless_isequal(
|
||||
if (lwc_string_caseless_isequal(
|
||||
event->data.rfc5988_link->rel,
|
||||
icon_str, &icon_match);
|
||||
icon_str, &icon_match) != lwc_error_ok) {
|
||||
icon_match = false;
|
||||
}
|
||||
lwc_string_unref(icon_str);
|
||||
}
|
||||
|
||||
if (lwc_intern_string("shortcut icon", SLEN("shortcut icon"),
|
||||
&shortcut_icon_str) == lwc_error_ok) {
|
||||
lwc_string_caseless_isequal(
|
||||
if (lwc_string_caseless_isequal(
|
||||
event->data.rfc5988_link->rel,
|
||||
shortcut_icon_str,
|
||||
&shortcut_icon_match);
|
||||
&shortcut_icon_match) != lwc_error_ok) {
|
||||
shortcut_icon_match = false;
|
||||
}
|
||||
lwc_string_unref(shortcut_icon_str);
|
||||
}
|
||||
|
||||
|
|
|
@ -218,8 +218,8 @@ fbtk_event(fbtk_widget_t *root, nsfb_event_t *event, int timeout)
|
|||
switch (event->type) {
|
||||
case NSFB_EVENT_KEY_DOWN:
|
||||
case NSFB_EVENT_KEY_UP:
|
||||
if ((event->value.controlcode >= NSFB_KEY_MOUSE_1) &&
|
||||
(event->value.controlcode <= NSFB_KEY_MOUSE_5)) {
|
||||
if ((event->value.keycode >= NSFB_KEY_MOUSE_1) &&
|
||||
(event->value.keycode <= NSFB_KEY_MOUSE_5)) {
|
||||
fbtk_click(root, event);
|
||||
} else {
|
||||
fbtk_input(root, event);
|
||||
|
|
|
@ -129,7 +129,12 @@ fb_redraw_text(fbtk_widget_t *widget, fbtk_callback_info *cbi )
|
|||
|
||||
if (widget->u.text.text != NULL) {
|
||||
int x = bbox.x0 + padding;
|
||||
int y = bbox.y0 + ((fh * 3) / 4) + padding;
|
||||
int y = bbox.y0 + ((fh * 3 + 2) / 4) + padding;
|
||||
|
||||
#ifdef FB_USE_FREETYPE
|
||||
/* Freetype renders text higher */
|
||||
y += 1;
|
||||
#endif
|
||||
|
||||
if (caret && widget->width - padding - padding < caret_x) {
|
||||
scroll = (widget->width - padding - padding) - caret_x;
|
||||
|
|
|
@ -396,7 +396,8 @@ FT_Glyph fb_getglyph(const plot_font_style_t *fstyle, uint32_t ucs4)
|
|||
|
||||
fb_face = (fb_faceid_t *)srec.face_id;
|
||||
|
||||
glyph_index = FTC_CMapCache_Lookup(ft_cmap_cache, srec.face_id, fb_face->cidx, ucs4);
|
||||
glyph_index = FTC_CMapCache_Lookup(ft_cmap_cache, srec.face_id,
|
||||
fb_face->cidx, ucs4);
|
||||
|
||||
error = FTC_ImageCache_LookupScaler(ft_image_cache,
|
||||
&srec,
|
||||
|
@ -406,6 +407,8 @@ FT_Glyph fb_getglyph(const plot_font_style_t *fstyle, uint32_t ucs4)
|
|||
glyph_index,
|
||||
&glyph,
|
||||
NULL);
|
||||
if (error != 0)
|
||||
return NULL;
|
||||
|
||||
return glyph;
|
||||
}
|
||||
|
|
14
image/jpeg.c
14
image/jpeg.c
|
@ -245,14 +245,16 @@ jpeg_cache_convert(struct content *c)
|
|||
rowstride = bitmap_get_rowstride(bitmap);
|
||||
do {
|
||||
JSAMPROW scanlines[1];
|
||||
#if RGB_RED != 0 || RGB_GREEN != 1 || RGB_BLUE != 2 || RGB_PIXELSIZE != 4
|
||||
int i;
|
||||
|
||||
scanlines[0] = (JSAMPROW) (pixels +
|
||||
rowstride * cinfo.output_scanline);
|
||||
jpeg_read_scanlines(&cinfo, scanlines, 1);
|
||||
|
||||
/* expand to RGBA */
|
||||
#if RGB_RED != 0 || RGB_GREEN != 1 || RGB_BLUE != 2 || RGB_PIXELSIZE != 4
|
||||
{
|
||||
/* Missmatch between configured libjpeg pixel format and
|
||||
* NetSurf pixel format. Convert to RGBA */
|
||||
int i;
|
||||
for (i = width - 1; 0 <= i; i--) {
|
||||
int r = scanlines[0][i * RGB_PIXELSIZE + RGB_RED];
|
||||
int g = scanlines[0][i * RGB_PIXELSIZE + RGB_GREEN];
|
||||
|
@ -262,11 +264,7 @@ jpeg_cache_convert(struct content *c)
|
|||
scanlines[0][i * 4 + 2] = b;
|
||||
scanlines[0][i * 4 + 3] = 0xff;
|
||||
}
|
||||
#else
|
||||
scanlines[0] = (JSAMPROW) (pixels +
|
||||
rowstride * cinfo.output_scanline);
|
||||
jpeg_read_scanlines(&cinfo, scanlines, 1);
|
||||
|
||||
}
|
||||
#endif
|
||||
} while (cinfo.output_scanline != cinfo.output_height);
|
||||
bitmap_modified(bitmap);
|
||||
|
|
|
@ -111,8 +111,11 @@ static const content_handler javascript_content_handler = {
|
|||
};
|
||||
|
||||
static const char *javascript_types[] = {
|
||||
"application/javascript",
|
||||
"text/javascript"
|
||||
"application/javascript", /* RFC 4329 */
|
||||
"application/ecmascript", /* RFC 4329 */
|
||||
"application/x-javascript", /* common usage */
|
||||
"text/javascript", /* common usage */
|
||||
"text/ecmascript", /* common usage */
|
||||
};
|
||||
|
||||
CONTENT_FACTORY_REGISTER_TYPES(javascript, javascript_types, javascript_content_handler);
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
#include "mozjs/jsapi.h"
|
||||
#endif
|
||||
|
||||
#include "render/html_internal.h"
|
||||
|
||||
#if JS_VERSION <= 180
|
||||
|
||||
#include <string.h>
|
||||
|
@ -152,7 +154,7 @@ JSObject *jsapi_new_window(JSContext *cx, JSObject *parent, void *win_priv);
|
|||
* @param doc_priv The private context to set on the object
|
||||
* @return new javascript object or NULL on error
|
||||
*/
|
||||
JSObject *jsapi_new_document(JSContext *cx, JSObject *parent, void *doc_priv);
|
||||
JSObject *jsapi_new_document(JSContext *cx, JSObject *parent, struct html_content *htmlc);
|
||||
|
||||
/** Create a new javascript console object
|
||||
*
|
||||
|
@ -170,4 +172,13 @@ JSObject *jsapi_new_console(JSContext *cx, JSObject *parent);
|
|||
*/
|
||||
JSObject *jsapi_new_navigator(JSContext *cx, JSObject *parent);
|
||||
|
||||
/** Create a new javascript element object
|
||||
*
|
||||
* @param cx The javascript context.
|
||||
* @param parent The parent object, usually a global window object
|
||||
* @param doc_priv The private context to set on the object
|
||||
* @return new javascript object or NULL on error
|
||||
*/
|
||||
JSObject *jsapi_new_element(JSContext *cx, JSObject *parent, struct html_content *htmlc, struct dom_element *domelement);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -16,10 +16,11 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "javascript/jsapi.h"
|
||||
|
||||
#include "utils/log.h"
|
||||
|
||||
#include "javascript/jsapi.h"
|
||||
|
||||
static JSBool JSAPI_NATIVE(debug, JSContext *cx, uintN argc, jsval *vp)
|
||||
{
|
||||
JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
|
|
|
@ -18,85 +18,63 @@
|
|||
|
||||
#include <dom/dom.h>
|
||||
|
||||
|
||||
#include "javascript/jsapi.h"
|
||||
#include "utils/config.h"
|
||||
#include "render/html_internal.h"
|
||||
#include "utils/log.h"
|
||||
|
||||
/* IDL from http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html
|
||||
#include "javascript/jsapi.h"
|
||||
|
||||
/* IDL http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-document
|
||||
|
||||
CAUTION - write, writeln are not part of the DOM they come from:
|
||||
http://www.w3.org/TR/html5/apis-in-html-documents.html#document.write
|
||||
|
||||
interface Document : Node {
|
||||
// Modified in DOM Level 3:
|
||||
readonly attribute DocumentType doctype;
|
||||
readonly attribute DOMImplementation implementation;
|
||||
readonly attribute Element documentElement;
|
||||
Element createElement(in DOMString tagName)
|
||||
raises(DOMException);
|
||||
DocumentFragment createDocumentFragment();
|
||||
Text createTextNode(in DOMString data);
|
||||
Comment createComment(in DOMString data);
|
||||
CDATASection createCDATASection(in DOMString data)
|
||||
raises(DOMException);
|
||||
ProcessingInstruction createProcessingInstruction(in DOMString target,
|
||||
in DOMString data)
|
||||
raises(DOMException);
|
||||
Attr createAttribute(in DOMString name)
|
||||
raises(DOMException);
|
||||
EntityReference createEntityReference(in DOMString name)
|
||||
raises(DOMException);
|
||||
NodeList getElementsByTagName(in DOMString tagname);
|
||||
// Introduced in DOM Level 2:
|
||||
Node importNode(in Node importedNode,
|
||||
in boolean deep)
|
||||
raises(DOMException);
|
||||
// Introduced in DOM Level 2:
|
||||
Element createElementNS(in DOMString namespaceURI,
|
||||
in DOMString qualifiedName)
|
||||
raises(DOMException);
|
||||
// Introduced in DOM Level 2:
|
||||
Attr createAttributeNS(in DOMString namespaceURI,
|
||||
in DOMString qualifiedName)
|
||||
raises(DOMException);
|
||||
// Introduced in DOM Level 2:
|
||||
NodeList getElementsByTagNameNS(in DOMString namespaceURI,
|
||||
in DOMString localName);
|
||||
// Introduced in DOM Level 2:
|
||||
Element getElementById(in DOMString elementId);
|
||||
// Introduced in DOM Level 3:
|
||||
readonly attribute DOMString inputEncoding;
|
||||
// Introduced in DOM Level 3:
|
||||
readonly attribute DOMString xmlEncoding;
|
||||
// Introduced in DOM Level 3:
|
||||
attribute boolean xmlStandalone;
|
||||
// raises(DOMException) on setting
|
||||
readonly attribute DOMString URL;
|
||||
readonly attribute DOMString documentURI;
|
||||
readonly attribute DOMString compatMode;
|
||||
readonly attribute DOMString characterSet;
|
||||
readonly attribute DOMString contentType;
|
||||
|
||||
// Introduced in DOM Level 3:
|
||||
attribute DOMString xmlVersion;
|
||||
// raises(DOMException) on setting
|
||||
readonly attribute DocumentType? doctype;
|
||||
readonly attribute Element? documentElement;
|
||||
HTMLCollection getElementsByTagName(DOMString localName);
|
||||
HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
|
||||
HTMLCollection getElementsByClassName(DOMString classNames);
|
||||
Element? getElementById(DOMString elementId);
|
||||
|
||||
// Introduced in DOM Level 3:
|
||||
attribute boolean strictErrorChecking;
|
||||
// Introduced in DOM Level 3:
|
||||
attribute DOMString documentURI;
|
||||
// Introduced in DOM Level 3:
|
||||
Node adoptNode(in Node source)
|
||||
raises(DOMException);
|
||||
// Introduced in DOM Level 3:
|
||||
readonly attribute DOMConfiguration domConfig;
|
||||
// Introduced in DOM Level 3:
|
||||
void normalizeDocument();
|
||||
// Introduced in DOM Level 3:
|
||||
Node renameNode(in Node n,
|
||||
in DOMString namespaceURI,
|
||||
in DOMString qualifiedName)
|
||||
raises(DOMException);
|
||||
Element createElement(DOMString localName);
|
||||
Element createElementNS(DOMString? namespace, DOMString qualifiedName);
|
||||
DocumentFragment createDocumentFragment();
|
||||
Text createTextNode(DOMString data);
|
||||
Comment createComment(DOMString data);
|
||||
ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data);
|
||||
|
||||
Node importNode(Node node, optional boolean deep = true);
|
||||
Node adoptNode(Node node);
|
||||
|
||||
Event createEvent(DOMString interface);
|
||||
|
||||
Range createRange();
|
||||
|
||||
// NodeFilter.SHOW_ALL = 0xFFFFFFFF
|
||||
NodeIterator createNodeIterator(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null);
|
||||
TreeWalker createTreeWalker(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null);
|
||||
|
||||
// NEW
|
||||
void prepend((Node or DOMString)... nodes);
|
||||
void append((Node or DOMString)... nodes);
|
||||
};
|
||||
|
||||
|
||||
*/
|
||||
|
||||
static void jsfinalize_document(JSContext *cx, JSObject *obj);
|
||||
|
||||
struct jsclass_document_priv {
|
||||
struct html_content *htmlc;
|
||||
dom_document *node;
|
||||
};
|
||||
|
||||
static JSClass jsclass_document =
|
||||
{
|
||||
|
@ -109,24 +87,29 @@ static JSClass jsclass_document =
|
|||
JS_EnumerateStub,
|
||||
JS_ResolveStub,
|
||||
JS_ConvertStub,
|
||||
JS_FinalizeStub,
|
||||
jsfinalize_document,
|
||||
JSCLASS_NO_OPTIONAL_MEMBERS
|
||||
};
|
||||
|
||||
#define JSCLASS_NAME document
|
||||
|
||||
#include "node.c"
|
||||
|
||||
static JSBool JSAPI_NATIVE(getElementById, JSContext *cx, uintN argc, jsval *vp)
|
||||
{
|
||||
JSString* u16_txt;
|
||||
char *txt;
|
||||
unsigned long txtlen;
|
||||
struct html_content *htmlc;
|
||||
dom_string *idstr;
|
||||
dom_element *idelement;
|
||||
struct jsclass_document_priv *document;
|
||||
|
||||
htmlc = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &jsclass_document, NULL);
|
||||
if (htmlc == NULL)
|
||||
document = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &jsclass_document, NULL);
|
||||
if (document == NULL) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (htmlc->document == NULL) {
|
||||
if (document->node == NULL) {
|
||||
/* no document available, this is obviously a problem
|
||||
* for finding elements
|
||||
*/
|
||||
|
@ -142,13 +125,9 @@ static JSBool JSAPI_NATIVE(getElementById, JSContext *cx, uintN argc, jsval *vp)
|
|||
|
||||
dom_string_create((unsigned char*)txt, txtlen, &idstr);
|
||||
|
||||
dom_document_get_element_by_id(htmlc->document, idstr, &idelement);
|
||||
dom_document_get_element_by_id(document->node, idstr, &idelement);
|
||||
|
||||
if (idelement==NULL) {
|
||||
JSAPI_SET_RVAL(cx, vp, JSVAL_NULL);
|
||||
} else {
|
||||
/* create element object and return it*/
|
||||
}
|
||||
JSAPI_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsapi_new_element(cx, JS_GetGlobalObject(cx), document->htmlc, idelement)));
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
@ -158,20 +137,23 @@ static JSBool JSAPI_NATIVE(write, JSContext *cx, uintN argc, jsval *vp)
|
|||
JSString* u16_txt;
|
||||
char *txt;
|
||||
unsigned long length;
|
||||
struct html_content *htmlc;
|
||||
struct jsclass_document_priv *document;
|
||||
|
||||
htmlc = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &jsclass_document, NULL);
|
||||
if (htmlc == NULL)
|
||||
document = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &jsclass_document, NULL);
|
||||
if (document == NULL) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (!JS_ConvertArguments(cx, argc, JSAPI_ARGV(cx, vp), "S", &u16_txt))
|
||||
if (!JS_ConvertArguments(cx, argc, JSAPI_ARGV(cx, vp), "S", &u16_txt)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
JSString_to_char(u16_txt, txt, length);
|
||||
|
||||
LOG(("content %p parser %p writing %s",htmlc, htmlc->parser, txt));
|
||||
if (htmlc->parser != NULL) {
|
||||
dom_hubbub_parser_insert_chunk(htmlc->parser, (uint8_t *)txt, length);
|
||||
LOG(("content %p parser %p writing %s",
|
||||
document->htmlc, document->htmlc->parser, txt));
|
||||
if (document->htmlc->parser != NULL) {
|
||||
dom_hubbub_parser_insert_chunk(document->htmlc->parser, (uint8_t *)txt, length);
|
||||
}
|
||||
JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
|
||||
|
@ -179,6 +161,7 @@ static JSBool JSAPI_NATIVE(write, JSContext *cx, uintN argc, jsval *vp)
|
|||
}
|
||||
|
||||
static JSFunctionSpec jsfunctions_document[] = {
|
||||
JSAPI_FS_NODE,
|
||||
JSAPI_FS(write, 1, 0),
|
||||
JSAPI_FS(getElementById, 1, 0),
|
||||
JSAPI_FS_END
|
||||
|
@ -186,11 +169,30 @@ static JSFunctionSpec jsfunctions_document[] = {
|
|||
|
||||
|
||||
|
||||
|
||||
JSObject *jsapi_new_document(JSContext *cx, JSObject *parent, void *doc_priv)
|
||||
static void jsfinalize_document(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
JSObject *doc;
|
||||
doc = JS_InitClass(cx,
|
||||
struct jsclass_document_priv *document;
|
||||
|
||||
document = JS_GetInstancePrivate(cx, obj, &jsclass_document, NULL);
|
||||
if (document != NULL) {
|
||||
free(document);
|
||||
}
|
||||
}
|
||||
|
||||
JSObject *jsapi_new_document(JSContext *cx, JSObject *parent, struct html_content *htmlc)
|
||||
{
|
||||
/* create document object and return it */
|
||||
JSObject *jsdocument;
|
||||
struct jsclass_document_priv *document;
|
||||
|
||||
document = malloc(sizeof(document));
|
||||
if (document == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
document->htmlc = htmlc;
|
||||
document->node = htmlc->document;
|
||||
|
||||
jsdocument = JS_InitClass(cx,
|
||||
parent,
|
||||
NULL,
|
||||
&jsclass_document,
|
||||
|
@ -200,16 +202,18 @@ JSObject *jsapi_new_document(JSContext *cx, JSObject *parent, void *doc_priv)
|
|||
jsfunctions_document,
|
||||
NULL,
|
||||
NULL);
|
||||
if (doc == NULL) {
|
||||
if (jsdocument == NULL) {
|
||||
free(document);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
LOG(("setting content to %p",doc_priv));
|
||||
LOG(("setting document private to %p", document));
|
||||
/* private pointer to browsing context */
|
||||
if (JS_SetPrivate(cx, doc, doc_priv) != JS_TRUE) {
|
||||
LOG(("failed to set content"));
|
||||
if (JS_SetPrivate(cx, jsdocument, document) != JS_TRUE) {
|
||||
LOG(("failed to set document private"));
|
||||
free(document);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return doc;
|
||||
return jsdocument;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
/*
|
||||
* Copyright 2012 Vincent Sanders <vince@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 <dom/dom.h>
|
||||
|
||||
|
||||
#include "javascript/jsapi.h"
|
||||
#include "utils/config.h"
|
||||
#include "render/html_internal.h"
|
||||
#include "utils/log.h"
|
||||
|
||||
/* IDL http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#exception-domexception
|
||||
exception DOMException {
|
||||
const unsigned short INDEX_SIZE_ERR = 1;
|
||||
const unsigned short DOMSTRING_SIZE_ERR = 2; // historical
|
||||
const unsigned short HIERARCHY_REQUEST_ERR = 3;
|
||||
const unsigned short WRONG_DOCUMENT_ERR = 4;
|
||||
const unsigned short INVALID_CHARACTER_ERR = 5;
|
||||
const unsigned short NO_DATA_ALLOWED_ERR = 6; // historical
|
||||
const unsigned short NO_MODIFICATION_ALLOWED_ERR = 7;
|
||||
const unsigned short NOT_FOUND_ERR = 8;
|
||||
const unsigned short NOT_SUPPORTED_ERR = 9;
|
||||
const unsigned short INUSE_ATTRIBUTE_ERR = 10; // historical
|
||||
const unsigned short INVALID_STATE_ERR = 11;
|
||||
const unsigned short SYNTAX_ERR = 12;
|
||||
const unsigned short INVALID_MODIFICATION_ERR = 13;
|
||||
const unsigned short NAMESPACE_ERR = 14;
|
||||
const unsigned short INVALID_ACCESS_ERR = 15;
|
||||
const unsigned short VALIDATION_ERR = 16; // historical
|
||||
const unsigned short TYPE_MISMATCH_ERR = 17;
|
||||
const unsigned short SECURITY_ERR = 18;
|
||||
const unsigned short NETWORK_ERR = 19;
|
||||
const unsigned short ABORT_ERR = 20;
|
||||
const unsigned short URL_MISMATCH_ERR = 21;
|
||||
const unsigned short QUOTA_EXCEEDED_ERR = 22;
|
||||
const unsigned short TIMEOUT_ERR = 23;
|
||||
const unsigned short INVALID_NODE_TYPE_ERR = 24;
|
||||
const unsigned short DATA_CLONE_ERR = 25;
|
||||
unsigned short code;
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
static JSClass jsclass_domexception =
|
||||
{
|
||||
"DOMException",
|
||||
JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
JS_StrictPropertyStub,
|
||||
JS_EnumerateStub,
|
||||
JS_ResolveStub,
|
||||
JS_ConvertStub,
|
||||
JS_FinalizeStub,
|
||||
JSCLASS_NO_OPTIONAL_MEMBERS
|
||||
};
|
||||
|
||||
|
||||
|
||||
JSObject *
|
||||
jsapi_new_domexception(JSContext *cx,
|
||||
JSObject *parent,
|
||||
int code)
|
||||
{
|
||||
/* create element object and return it*/
|
||||
JSObject *jsdomexception;
|
||||
|
||||
jssomexception = JS_InitClass(cx,
|
||||
parent,
|
||||
NULL,
|
||||
&jsclass_domexception,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
if (jsdomexecption == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
LOG(("setting element private to %d", code));
|
||||
/* private pointer to browsing context */
|
||||
if (JS_SetPrivate(cx, jsdomexception, code) != JS_TRUE) {
|
||||
LOG(("failed to set content"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return jsdomexception;
|
||||
}
|
|
@ -0,0 +1,157 @@
|
|||
/*
|
||||
* Copyright 2012 Vincent Sanders <vince@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 <dom/dom.h>
|
||||
|
||||
#include "utils/config.h"
|
||||
#include "utils/log.h"
|
||||
#include "render/html_internal.h"
|
||||
|
||||
#include "javascript/jsapi.h"
|
||||
|
||||
/* IDL http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-element
|
||||
|
||||
CAUTION - innerHTML etc. are not part of the DOM they come from:
|
||||
http://html5.org/specs/dom-parsing.html#extensions-to-the-element-interface
|
||||
|
||||
interface Element : Node {
|
||||
readonly attribute DOMString? namespaceURI;
|
||||
readonly attribute DOMString? prefix;
|
||||
readonly attribute DOMString localName;
|
||||
readonly attribute DOMString tagName;
|
||||
|
||||
attribute DOMString id;
|
||||
attribute DOMString className;
|
||||
readonly attribute DOMTokenList classList;
|
||||
|
||||
readonly attribute Attr[] attributes;
|
||||
DOMString? getAttribute(DOMString name);
|
||||
DOMString? getAttributeNS(DOMString? namespace, DOMString localName);
|
||||
void setAttribute(DOMString name, DOMString value);
|
||||
void setAttributeNS(DOMString? namespace, DOMString name, DOMString value);
|
||||
void removeAttribute(DOMString name);
|
||||
void removeAttributeNS(DOMString? namespace, DOMString localName);
|
||||
boolean hasAttribute(DOMString name);
|
||||
boolean hasAttributeNS(DOMString? namespace, DOMString localName);
|
||||
|
||||
HTMLCollection getElementsByTagName(DOMString localName);
|
||||
HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
|
||||
HTMLCollection getElementsByClassName(DOMString classNames);
|
||||
|
||||
readonly attribute HTMLCollection children;
|
||||
readonly attribute Element? firstElementChild;
|
||||
readonly attribute Element? lastElementChild;
|
||||
readonly attribute Element? previousElementSibling;
|
||||
readonly attribute Element? nextElementSibling;
|
||||
readonly attribute unsigned long childElementCount;
|
||||
|
||||
// NEW
|
||||
void prepend((Node or DOMString)... nodes);
|
||||
void append((Node or DOMString)... nodes);
|
||||
void before((Node or DOMString)... nodes);
|
||||
void after((Node or DOMString)... nodes);
|
||||
void replace((Node or DOMString)... nodes);
|
||||
void remove();
|
||||
};
|
||||
*/
|
||||
|
||||
static void jsfinalize_element(JSContext *cx, JSObject *obj);
|
||||
|
||||
struct jsclass_document_priv {
|
||||
struct html_content *htmlc;
|
||||
dom_element *node;
|
||||
};
|
||||
|
||||
static JSClass jsclass_element =
|
||||
{
|
||||
"Element",
|
||||
JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
JS_StrictPropertyStub,
|
||||
JS_EnumerateStub,
|
||||
JS_ResolveStub,
|
||||
JS_ConvertStub,
|
||||
jsfinalize_element,
|
||||
JSCLASS_NO_OPTIONAL_MEMBERS
|
||||
};
|
||||
|
||||
#define JSCLASS_NAME element
|
||||
|
||||
#include "node.c"
|
||||
|
||||
static void jsfinalize_element(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
struct jsclass_document_priv *element;
|
||||
element = JS_GetInstancePrivate(cx, obj, &jsclass_element, NULL);
|
||||
if (element != NULL) {
|
||||
free(element);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static JSFunctionSpec jsfunctions_element[] = {
|
||||
JSAPI_FS_NODE,
|
||||
JSAPI_FS_END
|
||||
};
|
||||
|
||||
|
||||
JSObject *
|
||||
jsapi_new_element(JSContext *cx,
|
||||
JSObject *parent,
|
||||
struct html_content *htmlc,
|
||||
dom_element *domelement)
|
||||
{
|
||||
/* create element object and return it */
|
||||
JSObject *jselement;
|
||||
struct jsclass_document_priv *element;
|
||||
|
||||
element = malloc(sizeof(element));
|
||||
if (element == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
element->htmlc = htmlc;
|
||||
element->node = domelement;
|
||||
|
||||
jselement = JS_InitClass(cx,
|
||||
parent,
|
||||
NULL,
|
||||
&jsclass_element,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
jsfunctions_element,
|
||||
NULL,
|
||||
NULL);
|
||||
if (jselement == NULL) {
|
||||
free(element);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
LOG(("setting private to %p", element));
|
||||
/* private pointer to browsing context */
|
||||
if (JS_SetPrivate(cx, jselement, element) != JS_TRUE) {
|
||||
LOG(("failed to set private"));
|
||||
free(element);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return jselement;
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* Copyright 2012 Vincent Sanders <vince@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/>.
|
||||
*/
|
||||
|
||||
|
||||
/* IDL http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#eventtarget
|
||||
|
||||
interface EventTarget {
|
||||
void addEventListener(DOMString type, EventListener? callback, optional boolean capture = false);
|
||||
void removeEventListener(DOMString type, EventListener? callback, optional boolean capture = false);
|
||||
boolean dispatchEvent(Event event);
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
#ifndef JSCLASS_NAME
|
||||
#error "The class name must be defined"
|
||||
#endif
|
||||
|
||||
#ifndef JSCLASS_TYPE
|
||||
#define CLASS jsclass
|
||||
#define PRIVATE priv
|
||||
#define EXPAND(a,b) PASTE(a,b)
|
||||
#define PASTE(x,y) x##_##y
|
||||
#define JSCLASS_OBJECT EXPAND(CLASS,JSCLASS_NAME)
|
||||
#define JSCLASS_TYPE EXPAND(JSCLASS_OBJECT,PRIVATE)
|
||||
#endif
|
||||
|
||||
static JSBool JSAPI_NATIVE(addEventListener, JSContext *cx, uintN argc, jsval *vp)
|
||||
{
|
||||
struct JSCLASS_TYPE *priv;
|
||||
|
||||
priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
|
||||
if (priv == NULL)
|
||||
return JS_FALSE;
|
||||
|
||||
|
||||
JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool JSAPI_NATIVE(removeEventListener, JSContext *cx, uintN argc, jsval *vp)
|
||||
{
|
||||
struct JSCLASS_TYPE *priv;
|
||||
|
||||
priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
|
||||
if (priv == NULL)
|
||||
return JS_FALSE;
|
||||
|
||||
|
||||
JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool JSAPI_NATIVE(dispatchEvent, JSContext *cx, uintN argc, jsval *vp)
|
||||
{
|
||||
struct JSCLASS_TYPE *priv;
|
||||
|
||||
priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
|
||||
if (priv == NULL)
|
||||
return JS_FALSE;
|
||||
|
||||
|
||||
JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
#define JSAPI_FS_EVENTTARGET \
|
||||
JSAPI_FS(addEventListener, 0, 0), \
|
||||
JSAPI_FS(removeEventListener, 0, 0), \
|
||||
JSAPI_FS(dispatchEvent, 0, 0)
|
|
@ -17,8 +17,7 @@
|
|||
*/
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "javascript/jsapi.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "desktop/netsurf.h"
|
||||
#include "desktop/options.h"
|
||||
|
@ -28,6 +27,8 @@
|
|||
#include "utils/log.h"
|
||||
#include "utils/utsname.h"
|
||||
|
||||
#include "javascript/jsapi.h"
|
||||
|
||||
/*
|
||||
* navigator properties for netsurf
|
||||
*
|
||||
|
|
|
@ -0,0 +1,288 @@
|
|||
/*
|
||||
* Copyright 2012 Vincent Sanders <vince@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/>.
|
||||
*/
|
||||
|
||||
|
||||
/* IDL http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-node
|
||||
interface Node : EventTarget {
|
||||
const unsigned short ELEMENT_NODE = 1;
|
||||
const unsigned short ATTRIBUTE_NODE = 2; // historical
|
||||
const unsigned short TEXT_NODE = 3;
|
||||
const unsigned short CDATA_SECTION_NODE = 4; // historical
|
||||
const unsigned short ENTITY_REFERENCE_NODE = 5; // historical
|
||||
const unsigned short ENTITY_NODE = 6; // historical
|
||||
const unsigned short PROCESSING_INSTRUCTION_NODE = 7;
|
||||
const unsigned short COMMENT_NODE = 8;
|
||||
const unsigned short DOCUMENT_NODE = 9;
|
||||
const unsigned short DOCUMENT_TYPE_NODE = 10;
|
||||
const unsigned short DOCUMENT_FRAGMENT_NODE = 11;
|
||||
const unsigned short NOTATION_NODE = 12; // historical
|
||||
readonly attribute unsigned short nodeType;
|
||||
readonly attribute DOMString nodeName;
|
||||
|
||||
readonly attribute DOMString? baseURI;
|
||||
|
||||
readonly attribute Document? ownerDocument;
|
||||
readonly attribute Node? parentNode;
|
||||
readonly attribute Element? parentElement;
|
||||
boolean hasChildNodes();
|
||||
readonly attribute NodeList childNodes;
|
||||
readonly attribute Node? firstChild;
|
||||
readonly attribute Node? lastChild;
|
||||
readonly attribute Node? previousSibling;
|
||||
readonly attribute Node? nextSibling;
|
||||
|
||||
const unsigned short DOCUMENT_POSITION_DISCONNECTED = 0x01;
|
||||
const unsigned short DOCUMENT_POSITION_PRECEDING = 0x02;
|
||||
const unsigned short DOCUMENT_POSITION_FOLLOWING = 0x04;
|
||||
const unsigned short DOCUMENT_POSITION_CONTAINS = 0x08;
|
||||
const unsigned short DOCUMENT_POSITION_CONTAINED_BY = 0x10;
|
||||
const unsigned short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20; // historical
|
||||
unsigned short compareDocumentPosition(Node other);
|
||||
boolean contains(Node? other);
|
||||
|
||||
attribute DOMString? nodeValue;
|
||||
attribute DOMString? textContent;
|
||||
Node insertBefore(Node node, Node? child);
|
||||
Node appendChild(Node node);
|
||||
Node replaceChild(Node node, Node child);
|
||||
Node removeChild(Node child);
|
||||
void normalize();
|
||||
|
||||
|
||||
Node cloneNode(optional boolean deep = true);
|
||||
boolean isEqualNode(Node? node);
|
||||
|
||||
DOMString lookupPrefix(DOMString? namespace);
|
||||
DOMString lookupNamespaceURI(DOMString? prefix);
|
||||
boolean isDefaultNamespace(DOMString? namespace);
|
||||
};
|
||||
*/
|
||||
|
||||
#include "eventtarget.c"
|
||||
|
||||
#ifndef JSCLASS_NAME
|
||||
#error "The class name must be defined"
|
||||
#endif
|
||||
|
||||
#ifndef JSCLASS_TYPE
|
||||
#define CLASS jsclass
|
||||
#define PRIVATE priv
|
||||
#define EXPAND(a,b) PASTE(a,b)
|
||||
#define PASTE(x,y) x##_##y
|
||||
#define JSCLASS_OBJECT EXPAND(CLASS,JSCLASS_NAME)
|
||||
#define JSCLASS_TYPE EXPAND(JSCLASS_OBJECT,PRIVATE)
|
||||
#endif
|
||||
|
||||
static JSBool JSAPI_NATIVE(hasChildNodes, JSContext *cx, uintN argc, jsval *vp)
|
||||
{
|
||||
struct JSCLASS_TYPE *priv;
|
||||
|
||||
priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
|
||||
if (priv == NULL)
|
||||
return JS_FALSE;
|
||||
|
||||
|
||||
JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool JSAPI_NATIVE(compareDocumentPosition, JSContext *cx, uintN argc, jsval *vp)
|
||||
{
|
||||
struct JSCLASS_TYPE *priv;
|
||||
|
||||
priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
|
||||
if (priv == NULL)
|
||||
return JS_FALSE;
|
||||
|
||||
|
||||
JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool JSAPI_NATIVE(contains, JSContext *cx, uintN argc, jsval *vp)
|
||||
{
|
||||
struct JSCLASS_TYPE *priv;
|
||||
|
||||
priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
|
||||
if (priv == NULL)
|
||||
return JS_FALSE;
|
||||
|
||||
|
||||
JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool JSAPI_NATIVE(insertBefore, JSContext *cx, uintN argc, jsval *vp)
|
||||
{
|
||||
struct JSCLASS_TYPE *priv;
|
||||
|
||||
priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
|
||||
if (priv == NULL)
|
||||
return JS_FALSE;
|
||||
|
||||
|
||||
JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool JSAPI_NATIVE(appendChild, JSContext *cx, uintN argc, jsval *vp)
|
||||
{
|
||||
struct JSCLASS_TYPE *priv;
|
||||
|
||||
priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
|
||||
if (priv == NULL)
|
||||
return JS_FALSE;
|
||||
|
||||
|
||||
JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool JSAPI_NATIVE(replaceChild, JSContext *cx, uintN argc, jsval *vp)
|
||||
{
|
||||
struct JSCLASS_TYPE *priv;
|
||||
|
||||
priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
|
||||
if (priv == NULL)
|
||||
return JS_FALSE;
|
||||
|
||||
|
||||
JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool JSAPI_NATIVE(removeChild, JSContext *cx, uintN argc, jsval *vp)
|
||||
{
|
||||
struct JSCLASS_TYPE *priv;
|
||||
|
||||
priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
|
||||
if (priv == NULL)
|
||||
return JS_FALSE;
|
||||
|
||||
|
||||
JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool JSAPI_NATIVE(normalize, JSContext *cx, uintN argc, jsval *vp)
|
||||
{
|
||||
struct JSCLASS_TYPE *priv;
|
||||
|
||||
priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
|
||||
if (priv == NULL)
|
||||
return JS_FALSE;
|
||||
|
||||
|
||||
JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool JSAPI_NATIVE(cloneNode, JSContext *cx, uintN argc, jsval *vp)
|
||||
{
|
||||
struct JSCLASS_TYPE *priv;
|
||||
|
||||
priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
|
||||
if (priv == NULL)
|
||||
return JS_FALSE;
|
||||
|
||||
|
||||
JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool JSAPI_NATIVE(isEqualNode, JSContext *cx, uintN argc, jsval *vp)
|
||||
{
|
||||
struct JSCLASS_TYPE *priv;
|
||||
|
||||
priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
|
||||
if (priv == NULL)
|
||||
return JS_FALSE;
|
||||
|
||||
|
||||
JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool JSAPI_NATIVE(lookupPrefix, JSContext *cx, uintN argc, jsval *vp)
|
||||
{
|
||||
struct JSCLASS_TYPE *priv;
|
||||
|
||||
priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
|
||||
if (priv == NULL)
|
||||
return JS_FALSE;
|
||||
|
||||
|
||||
JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool JSAPI_NATIVE(lookupNamespaceURI, JSContext *cx, uintN argc, jsval *vp)
|
||||
{
|
||||
struct JSCLASS_TYPE *priv;
|
||||
|
||||
priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
|
||||
if (priv == NULL)
|
||||
return JS_FALSE;
|
||||
|
||||
|
||||
JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool JSAPI_NATIVE(isDefaultNamespace, JSContext *cx, uintN argc, jsval *vp)
|
||||
{
|
||||
struct JSCLASS_TYPE *priv;
|
||||
|
||||
priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
|
||||
if (priv == NULL)
|
||||
return JS_FALSE;
|
||||
|
||||
|
||||
JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
#define JSAPI_FS_NODE \
|
||||
JSAPI_FS_EVENTTARGET, \
|
||||
JSAPI_FS(hasChildNodes, 0, 0), \
|
||||
JSAPI_FS(compareDocumentPosition, 0, 0), \
|
||||
JSAPI_FS(contains, 0, 0), \
|
||||
JSAPI_FS(insertBefore, 0, 0), \
|
||||
JSAPI_FS(appendChild, 0, 0), \
|
||||
JSAPI_FS(replaceChild, 0, 0), \
|
||||
JSAPI_FS(removeChild, 0, 0), \
|
||||
JSAPI_FS(normalize, 0, 0), \
|
||||
JSAPI_FS(cloneNode, 0, 0), \
|
||||
JSAPI_FS(isEqualNode, 0, 0), \
|
||||
JSAPI_FS(lookupPrefix, 0, 0), \
|
||||
JSAPI_FS(lookupNamespaceURI, 0, 0), \
|
||||
JSAPI_FS(isDefaultNamespace, 0, 0)
|
|
@ -16,11 +16,10 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "javascript/jsapi.h"
|
||||
|
||||
#include "content/content.h"
|
||||
#include "utils/log.h"
|
||||
|
||||
#include "javascript/jsapi.h"
|
||||
|
||||
/* IDL
|
||||
|
||||
[NamedPropertiesObject]
|
||||
|
|
|
@ -335,10 +335,10 @@ html_create_html_data(html_content *c, const http_parameter *params)
|
|||
c->parser = dom_hubbub_parser_create(c->encoding,
|
||||
true,
|
||||
nsoption_bool(enable_javascript),
|
||||
&c->document,
|
||||
NULL,
|
||||
html_process_script,
|
||||
c);
|
||||
c,
|
||||
&c->document);
|
||||
if ((c->parser == NULL) && (c->encoding != NULL)) {
|
||||
/* Ok, we don't support the declared encoding. Bailing out
|
||||
* isn't exactly user-friendly, so fall back to autodetect */
|
||||
|
@ -348,12 +348,10 @@ html_create_html_data(html_content *c, const http_parameter *params)
|
|||
c->parser = dom_hubbub_parser_create(c->encoding,
|
||||
true,
|
||||
nsoption_bool(enable_javascript),
|
||||
&c->document,
|
||||
NULL,
|
||||
html_process_script,
|
||||
c);
|
||||
|
||||
|
||||
c,
|
||||
&c->document);
|
||||
}
|
||||
|
||||
if (c->parser == NULL) {
|
||||
|
@ -451,10 +449,10 @@ html_process_encoding_change(struct content *c,
|
|||
html->parser = dom_hubbub_parser_create(html->encoding,
|
||||
true,
|
||||
nsoption_bool(enable_javascript),
|
||||
&html->document,
|
||||
NULL,
|
||||
html_process_script,
|
||||
html);
|
||||
html,
|
||||
&html->document);
|
||||
if (html->parser == NULL) {
|
||||
/* Ok, we don't support the declared encoding. Bailing out
|
||||
* isn't exactly user-friendly, so fall back to Windows-1252 */
|
||||
|
@ -471,11 +469,10 @@ html_process_encoding_change(struct content *c,
|
|||
html->parser = dom_hubbub_parser_create(html->encoding,
|
||||
true,
|
||||
nsoption_bool(enable_javascript),
|
||||
&html->document,
|
||||
|
||||
NULL,
|
||||
html_process_script,
|
||||
html);
|
||||
html,
|
||||
&html->document);
|
||||
|
||||
if (html->parser == NULL) {
|
||||
union content_msg_data msg_data;
|
||||
|
|
|
@ -468,9 +468,6 @@ struct form_control *html_forms_get_control_for_node(struct form *forms, dom_nod
|
|||
dom_exception err;
|
||||
dom_string *ds_name = NULL;
|
||||
|
||||
if (forms == NULL)
|
||||
return NULL;
|
||||
|
||||
/* Step one, see if we already have a control */
|
||||
for (f = forms; f != NULL; f = f->prev) {
|
||||
for (ctl = f->controls; ctl != NULL; ctl = ctl->next) {
|
||||
|
|
|
@ -227,11 +227,13 @@ enum url_sections {
|
|||
|
||||
#define nsurl__component_copy(c) (c == NULL) ? NULL : lwc_string_ref(c)
|
||||
|
||||
#define nsurl__component_compare(c1, c2, match) \
|
||||
if (c1 && c2) \
|
||||
lwc_string_isequal(c1, c2, match); \
|
||||
else if (c1 || c2) \
|
||||
*match = false;
|
||||
#define nsurl__component_compare(c1, c2, match) \
|
||||
if (c1 && c2 && lwc_error_ok == \
|
||||
lwc_string_isequal(c1, c2, match)) { \
|
||||
/* do nothing */ \
|
||||
} else if (c1 || c2) { \
|
||||
*match = false; \
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,9 +16,12 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "utils/config.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "utils/utils.h"
|
||||
#include "utils/messages.h"
|
||||
#include "desktop/netsurf.h"
|
||||
|
|
|
@ -20,6 +20,9 @@
|
|||
#include <inttypes.h>
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "utils/config.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "image/bitmap.h"
|
||||
|
|
|
@ -17,10 +17,13 @@
|
|||
*/
|
||||
|
||||
#include <limits.h>
|
||||
#include <windows.h>
|
||||
#include <shlobj.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "utils/config.h"
|
||||
|
||||
#include <shlobj.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include "content/fetch.h"
|
||||
#include "desktop/gui.h"
|
||||
#include "utils/schedule.h"
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "utils/config.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
|
||||
|
|
|
@ -17,7 +17,9 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
#include <stdbool.h>
|
||||
|
@ -25,6 +27,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
#include "utils/url.h"
|
||||
|
|
|
@ -21,7 +21,11 @@
|
|||
#include <inttypes.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "utils/config.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "css/css.h"
|
||||
#include "render/font.h"
|
||||
#include "desktop/options.h"
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "utils/config.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <commctrl.h>
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "utils/config.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <commctrl.h>
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
|
||||
#include <limits.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "utils/config.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "desktop/gui.h"
|
||||
|
|
|
@ -20,6 +20,9 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "utils/config.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "desktop/cookies.h"
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "utils/config.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "utils/log.h"
|
||||
|
@ -94,12 +97,13 @@ static bool line(int x0, int y0, int x1, int y1, const plot_style_t *style)
|
|||
DeleteObject(clipregion);
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
RECT r;
|
||||
r.left = x0;
|
||||
r.top = y0;
|
||||
r.right = x1;
|
||||
r.bottom = y1;
|
||||
|
||||
*/
|
||||
SelectClipRgn(plot_hdc, clipregion);
|
||||
|
||||
MoveToEx(plot_hdc, x0, y0, (LPPOINT) NULL);
|
||||
|
@ -276,15 +280,16 @@ static bool text(int x, int y, const char *text, size_t length,
|
|||
int wlen;
|
||||
SIZE s;
|
||||
LPWSTR wstring;
|
||||
RECT r;
|
||||
fontbak = (HFONT) SelectObject(plot_hdc, font);
|
||||
GetTextExtentPoint(plot_hdc, text, length, &s);
|
||||
|
||||
/*
|
||||
RECT r;
|
||||
r.left = x;
|
||||
r.top = y - (3 * s.cy) / 4;
|
||||
r.right = x + s.cx;
|
||||
r.bottom = y + s.cy / 4;
|
||||
|
||||
*/
|
||||
SelectClipRgn(plot_hdc, clipregion);
|
||||
|
||||
SetTextAlign(plot_hdc, TA_BASELINE | TA_LEFT);
|
||||
|
@ -354,12 +359,13 @@ static bool disc(int x, int y, int radius, const plot_style_t *style)
|
|||
DeleteObject(brush);
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
RECT r;
|
||||
r.left = x - radius;
|
||||
r.top = y - radius;
|
||||
r.right = x + radius;
|
||||
r.bottom = y + radius;
|
||||
|
||||
*/
|
||||
SelectClipRgn(plot_hdc, clipregion);
|
||||
|
||||
if (style->fill_type == PLOT_OP_TYPE_NONE)
|
||||
|
@ -408,7 +414,7 @@ static bool arc(int x, int y, int radius, int angle1, int angle2,
|
|||
DeleteObject(pen);
|
||||
return false;
|
||||
}
|
||||
RECT r;
|
||||
|
||||
int q1, q2;
|
||||
double a1=1.0, a2=1.0, b1=1.0, b2=1.0;
|
||||
q1 = (int) ((angle1 + 45) / 90) - 45;
|
||||
|
@ -462,11 +468,13 @@ static bool arc(int x, int y, int radius, int angle1, int angle2,
|
|||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
RECT r;
|
||||
r.left = x - radius;
|
||||
r.top = y - radius;
|
||||
r.right = x + radius;
|
||||
r.bottom = y + radius;
|
||||
|
||||
*/
|
||||
SelectClipRgn(plot_hdc, clipregion);
|
||||
|
||||
Arc(plot_hdc, x - radius, y - radius, x + radius, y + radius,
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "utils/config.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "utils/config.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "content/urldb.h"
|
||||
|
|
Loading…
Reference in New Issue