1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

[ecmascript] Commented out clientHeight and similar properties

Code is not ready yet.
This commit is contained in:
Witold Filipczyk 2024-03-02 19:13:45 +01:00
parent 862dfcc672
commit f762775b9d
8 changed files with 100 additions and 37 deletions

View File

@ -274,7 +274,7 @@ get_format_screen_char(struct html_context *html_context,
&& html_context->options->underline_links) {
schar_cache.attr |= SCREEN_ATTR_UNDERLINE;
}
schar_cache.element_offset = (html_top->name && html_context->document && html_context->document->text.source) ? html_top->name - html_context->document->text.source : 0;
// schar_cache.element_offset = (html_top->name && html_context->document && html_context->document->text.source) ? html_top->name - html_context->document->text.source : 0;
return &schar_cache;
}

View File

@ -294,6 +294,7 @@ render_xhtml_document(struct cache_entry *cached, struct document *document, str
dump_xhtml(cached, document, 0);
}
#if 0
static void
walk_tree2(struct document *document, dom_node *node)
{
@ -385,7 +386,9 @@ next:
child = next_child;
}
}
#endif
#if 0
static void
walk_tree2_color(struct terminal *term, struct el_box *box, struct document *document, int vx, int vy, dom_node *node)
{
@ -457,6 +460,7 @@ walk_tree2_color(struct terminal *term, struct el_box *box, struct document *doc
child = next_child;
}
}
#endif
void
dump_xhtml(struct cache_entry *cached, struct document *document, int parse)
@ -541,6 +545,7 @@ dump_xhtml(struct cache_entry *cached, struct document *document, int parse)
}
}
#if 0
void
walk2(struct document *document)
{
@ -567,7 +572,9 @@ walk2(struct document *document)
walk_tree2(document, root);
dom_node_unref(root);
}
#endif
#if 0
static int prev_offset = 0;
static struct node_rect *prev_element = NULL;
@ -610,8 +617,10 @@ get_element_rect(struct document *document, int offset)
return n;
}
#endif
//static void dump_results(struct document *document);
#if 0
void
scan_document(struct document_view *doc_view)
{
@ -665,6 +674,7 @@ scan_document(struct document_view *doc_view)
walk2(doc_view->document);
// dump_results(doc_view->document);
}
#endif
#if 0
static void
@ -682,6 +692,7 @@ dump_results(struct document *document)
}
#endif
#if 0
void
try_to_color(struct terminal *term, struct el_box *box, struct document *document, int vx, int vy)
{
@ -708,3 +719,4 @@ try_to_color(struct terminal *term, struct el_box *box, struct document *documen
walk_tree2_color(term, box, document, vx, vy, root);
dom_node_unref(root);
}
#endif

View File

@ -18,10 +18,13 @@ struct node_rect {
void render_xhtml_document(struct cache_entry *cached, struct document *document, struct string *buffer);
void dump_xhtml(struct cache_entry *cached, struct document *document, int parse);
#if 0
void walk2(struct document *document);
void scan_document(struct document_view *doc_view);
void try_to_color(struct terminal *term, struct el_box *box, struct document *document, int vx, int vy);
struct node_rect *get_element_rect(struct document *document, int offset);
#endif
#ifdef __cplusplus
}

View File

@ -270,6 +270,7 @@ mjs_element_get_property_className(js_State *J)
}
}
#if 0
static void
mjs_element_get_property_clientHeight(js_State *J)
{
@ -328,7 +329,9 @@ mjs_element_get_property_clientHeight(js_State *J)
int dy = int_max(0, (rect->y1 + 1 - rect->y0) * ses->tab->term->cell_height);
js_pushnumber(J, dy);
}
#endif
#if 0
static void
mjs_element_get_property_clientLeft(js_State *J)
{
@ -337,7 +340,9 @@ mjs_element_get_property_clientLeft(js_State *J)
#endif
js_pushnumber(J, 0);
}
#endif
#if 0
static void
mjs_element_get_property_clientTop(js_State *J)
{
@ -346,7 +351,9 @@ mjs_element_get_property_clientTop(js_State *J)
#endif
js_pushnumber(J, 0);
}
#endif
#if 0
static void
mjs_element_get_property_clientWidth(js_State *J)
{
@ -406,6 +413,7 @@ mjs_element_get_property_clientWidth(js_State *J)
int dx = int_max(0, (rect->x1 + 1 - rect->x0) * ses->tab->term->cell_width);
js_pushnumber(J, dx);
}
#endif
static void
mjs_element_get_property_dir(js_State *J)
@ -781,6 +789,7 @@ mjs_element_get_property_nextSibling(js_State *J)
mjs_push_element(J, node);
}
#if 0
static void
mjs_element_get_property_offsetHeight(js_State *J)
{
@ -789,7 +798,9 @@ mjs_element_get_property_offsetHeight(js_State *J)
#endif
mjs_element_get_property_clientHeight(J);
}
#endif
#if 0
static void
mjs_element_get_property_offsetLeft(js_State *J)
{
@ -852,6 +863,7 @@ mjs_element_get_property_offsetLeft(js_State *J)
dom_node_unref(node);
js_pushnumber(J, dx);
}
#endif
static void
mjs_element_get_property_offsetParent(js_State *J)
@ -876,6 +888,7 @@ mjs_element_get_property_offsetParent(js_State *J)
mjs_push_element(J, node);
}
#if 0
static void
mjs_element_get_property_offsetTop(js_State *J)
{
@ -938,7 +951,9 @@ mjs_element_get_property_offsetTop(js_State *J)
dom_node_unref(node);
js_pushnumber(J, dy);
}
#endif
#if 0
static void
mjs_element_get_property_offsetWidth(js_State *J)
{
@ -947,6 +962,7 @@ mjs_element_get_property_offsetWidth(js_State *J)
#endif
mjs_element_get_property_clientWidth(J);
}
#endif
static void
mjs_element_get_property_ownerDocument(js_State *J)
@ -2985,10 +3001,10 @@ mjs_push_element(js_State *J, void *node)
addproperty(J, "childElementCount", mjs_element_get_property_childElementCount, NULL);
addproperty(J, "childNodes", mjs_element_get_property_childNodes, NULL);
addproperty(J, "className", mjs_element_get_property_className, mjs_element_set_property_className);
addproperty(J, "clientHeight", mjs_element_get_property_clientHeight, NULL);
addproperty(J, "clientLeft", mjs_element_get_property_clientLeft, NULL);
addproperty(J, "clientTop", mjs_element_get_property_clientTop, NULL);
addproperty(J, "clientWidth", mjs_element_get_property_clientWidth, NULL);
// addproperty(J, "clientHeight", mjs_element_get_property_clientHeight, NULL);
// addproperty(J, "clientLeft", mjs_element_get_property_clientLeft, NULL);
// addproperty(J, "clientTop", mjs_element_get_property_clientTop, NULL);
// addproperty(J, "clientWidth", mjs_element_get_property_clientWidth, NULL);
addproperty(J, "dir", mjs_element_get_property_dir, mjs_element_set_property_dir);
addproperty(J, "firstChild", mjs_element_get_property_firstChild, NULL);
addproperty(J, "firstElementChild", mjs_element_get_property_firstElementChild, NULL);
@ -3003,11 +3019,11 @@ mjs_push_element(js_State *J, void *node)
addproperty(J, "nodeName", mjs_element_get_property_nodeName, NULL);
addproperty(J, "nodeType", mjs_element_get_property_nodeType, NULL);
addproperty(J, "nodeValue", mjs_element_get_property_nodeValue, NULL);
addproperty(J, "offsetHeight", mjs_element_get_property_offsetHeight, NULL);
addproperty(J, "offsetLeft", mjs_element_get_property_offsetLeft, NULL);
// addproperty(J, "offsetHeight", mjs_element_get_property_offsetHeight, NULL);
// addproperty(J, "offsetLeft", mjs_element_get_property_offsetLeft, NULL);
addproperty(J, "offsetParent", mjs_element_get_property_offsetParent, NULL);
addproperty(J, "offsetTop", mjs_element_get_property_offsetTop, NULL);
addproperty(J, "offsetWidth", mjs_element_get_property_offsetWidth, NULL);
// addproperty(J, "offsetTop", mjs_element_get_property_offsetTop, NULL);
// addproperty(J, "offsetWidth", mjs_element_get_property_offsetWidth, NULL);
addproperty(J, "outerHTML", mjs_element_get_property_outerHtml, NULL);
addproperty(J, "ownerDocument", mjs_element_get_property_ownerDocument, NULL);
addproperty(J, "parentElement", mjs_element_get_property_parentElement, NULL);

View File

@ -329,6 +329,7 @@ js_element_get_property_className(JSContext *ctx, JSValueConst this_val)
RETURN_JS(r);
}
#if 0
static JSValue
js_element_get_property_clientHeight(JSContext *ctx, JSValueConst this_val)
{
@ -381,7 +382,9 @@ js_element_get_property_clientHeight(JSContext *ctx, JSValueConst this_val)
return JS_NewInt32(ctx, dy);
}
#endif
#if 0
static JSValue
js_element_get_property_clientLeft(JSContext *ctx, JSValueConst this_val)
{
@ -390,7 +393,9 @@ js_element_get_property_clientLeft(JSContext *ctx, JSValueConst this_val)
#endif
return JS_NewInt32(ctx, 0);
}
#endif
#if 0
static JSValue
js_element_get_property_clientTop(JSContext *ctx, JSValueConst this_val)
{
@ -399,7 +404,9 @@ js_element_get_property_clientTop(JSContext *ctx, JSValueConst this_val)
#endif
return JS_NewInt32(ctx, 0);
}
#endif
#if 0
static JSValue
js_element_get_property_clientWidth(JSContext *ctx, JSValueConst this_val)
{
@ -452,6 +459,7 @@ js_element_get_property_clientWidth(JSContext *ctx, JSValueConst this_val)
return JS_NewInt32(ctx, dx);
}
#endif
static JSValue
js_element_get_property_dir(JSContext *ctx, JSValueConst this_val)
@ -841,6 +849,7 @@ js_element_get_property_nextSibling(JSContext *ctx, JSValueConst this_val)
return getElement(ctx, node);
}
#if 0
static JSValue
js_element_get_property_offsetHeight(JSContext *ctx, JSValueConst this_val)
{
@ -849,8 +858,9 @@ js_element_get_property_offsetHeight(JSContext *ctx, JSValueConst this_val)
#endif
return js_element_get_property_clientHeight(ctx, this_val);
}
#endif
#if 0
static JSValue
js_element_get_property_offsetLeft(JSContext *ctx, JSValueConst this_val)
{
@ -905,6 +915,7 @@ js_element_get_property_offsetLeft(JSContext *ctx, JSValueConst this_val)
dom_node_unref(node);
return JS_NewInt32(ctx, dx);
}
#endif
static JSValue
js_element_get_property_offsetParent(JSContext *ctx, JSValueConst this_val)
@ -929,6 +940,7 @@ js_element_get_property_offsetParent(JSContext *ctx, JSValueConst this_val)
return getElement(ctx, node);
}
#if 0
static JSValue
js_element_get_property_offsetTop(JSContext *ctx, JSValueConst this_val)
{
@ -983,7 +995,9 @@ js_element_get_property_offsetTop(JSContext *ctx, JSValueConst this_val)
dom_node_unref(node);
return JS_NewInt32(ctx, dy);
}
#endif
#if 0
static JSValue
js_element_get_property_offsetWidth(JSContext *ctx, JSValueConst this_val)
{
@ -992,6 +1006,7 @@ js_element_get_property_offsetWidth(JSContext *ctx, JSValueConst this_val)
#endif
return js_element_get_property_clientWidth(ctx, this_val);
}
#endif
static JSValue
js_element_get_property_ownerDocument(JSContext *ctx, JSValueConst this_val)
@ -3096,10 +3111,10 @@ static const JSCFunctionListEntry js_element_proto_funcs[] = {
JS_CGETSET_DEF("childElementCount", js_element_get_property_childElementCount, NULL),
JS_CGETSET_DEF("childNodes", js_element_get_property_childNodes, NULL),
JS_CGETSET_DEF("className", js_element_get_property_className, js_element_set_property_className),
JS_CGETSET_DEF("clientHeight", js_element_get_property_clientHeight, NULL),
JS_CGETSET_DEF("clientLeft", js_element_get_property_clientLeft, NULL),
JS_CGETSET_DEF("clientTop", js_element_get_property_clientTop, NULL),
JS_CGETSET_DEF("clientWidth", js_element_get_property_clientWidth, NULL),
// JS_CGETSET_DEF("clientHeight", js_element_get_property_clientHeight, NULL),
// JS_CGETSET_DEF("clientLeft", js_element_get_property_clientLeft, NULL),
// JS_CGETSET_DEF("clientTop", js_element_get_property_clientTop, NULL),
// JS_CGETSET_DEF("clientWidth", js_element_get_property_clientWidth, NULL),
JS_CGETSET_DEF("dir", js_element_get_property_dir, js_element_set_property_dir),
JS_CGETSET_DEF("firstChild", js_element_get_property_firstChild, NULL),
JS_CGETSET_DEF("firstElementChild", js_element_get_property_firstElementChild, NULL),
@ -3114,11 +3129,11 @@ static const JSCFunctionListEntry js_element_proto_funcs[] = {
JS_CGETSET_DEF("nodeName", js_element_get_property_nodeName, NULL),
JS_CGETSET_DEF("nodeType", js_element_get_property_nodeType, NULL),
JS_CGETSET_DEF("nodeValue", js_element_get_property_nodeValue, NULL),
JS_CGETSET_DEF("offsetHeight", js_element_get_property_offsetHeight, NULL),
JS_CGETSET_DEF("offsetLeft", js_element_get_property_offsetLeft, NULL),
// JS_CGETSET_DEF("offsetHeight", js_element_get_property_offsetHeight, NULL),
// JS_CGETSET_DEF("offsetLeft", js_element_get_property_offsetLeft, NULL),
JS_CGETSET_DEF("offsetParent", js_element_get_property_offsetParent, NULL),
JS_CGETSET_DEF("offsetTop", js_element_get_property_offsetTop, NULL),
JS_CGETSET_DEF("offsetWidth", js_element_get_property_offsetWidth, NULL),
// JS_CGETSET_DEF("offsetTop", js_element_get_property_offsetTop, NULL),
// JS_CGETSET_DEF("offsetWidth", js_element_get_property_offsetWidth, NULL),
JS_CGETSET_DEF("outerHTML", js_element_get_property_outerHtml, NULL),
JS_CGETSET_DEF("ownerDocument", js_element_get_property_ownerDocument, NULL),
JS_CGETSET_DEF("parentElement", js_element_get_property_parentElement, NULL),

View File

@ -70,10 +70,10 @@ static bool element_get_property_childElementCount(JSContext *ctx, unsigned int
static bool element_get_property_childNodes(JSContext *ctx, unsigned int argc, JS::Value *vp);
static bool element_get_property_className(JSContext *ctx, unsigned int argc, JS::Value *vp);
static bool element_set_property_className(JSContext *ctx, unsigned int argc, JS::Value *vp);
static bool element_get_property_clientHeight(JSContext *ctx, unsigned int argc, JS::Value *vp);
static bool element_get_property_clientLeft(JSContext *ctx, unsigned int argc, JS::Value *vp);
static bool element_get_property_clientTop(JSContext *ctx, unsigned int argc, JS::Value *vp);
static bool element_get_property_clientWidth(JSContext *ctx, unsigned int argc, JS::Value *vp);
//static bool element_get_property_clientHeight(JSContext *ctx, unsigned int argc, JS::Value *vp);
//static bool element_get_property_clientLeft(JSContext *ctx, unsigned int argc, JS::Value *vp);
//static bool element_get_property_clientTop(JSContext *ctx, unsigned int argc, JS::Value *vp);
//static bool element_get_property_clientWidth(JSContext *ctx, unsigned int argc, JS::Value *vp);
static bool element_get_property_dir(JSContext *ctx, unsigned int argc, JS::Value *vp);
static bool element_set_property_dir(JSContext *ctx, unsigned int argc, JS::Value *vp);
static bool element_get_property_firstChild(JSContext *ctx, unsigned int argc, JS::Value *vp);
@ -92,11 +92,11 @@ static bool element_get_property_nextSibling(JSContext *ctx, unsigned int argc,
static bool element_get_property_nodeName(JSContext *ctx, unsigned int argc, JS::Value *vp);
static bool element_get_property_nodeType(JSContext *ctx, unsigned int argc, JS::Value *vp);
static bool element_get_property_nodeValue(JSContext *ctx, unsigned int argc, JS::Value *vp);
static bool element_get_property_offsetHeight(JSContext *ctx, unsigned int argc, JS::Value *vp);
static bool element_get_property_offsetLeft(JSContext *ctx, unsigned int argc, JS::Value *vp);
//static bool element_get_property_offsetHeight(JSContext *ctx, unsigned int argc, JS::Value *vp);
//static bool element_get_property_offsetLeft(JSContext *ctx, unsigned int argc, JS::Value *vp);
static bool element_get_property_offsetParent(JSContext *ctx, unsigned int argc, JS::Value *vp);
static bool element_get_property_offsetTop(JSContext *ctx, unsigned int argc, JS::Value *vp);
static bool element_get_property_offsetWidth(JSContext *ctx, unsigned int argc, JS::Value *vp);
//static bool element_get_property_offsetTop(JSContext *ctx, unsigned int argc, JS::Value *vp);
//static bool element_get_property_offsetWidth(JSContext *ctx, unsigned int argc, JS::Value *vp);
static bool element_get_property_outerHtml(JSContext *ctx, unsigned int argc, JS::Value *vp);
static bool element_set_property_outerHtml(JSContext *ctx, unsigned int argc, JS::Value *vp);
static bool element_get_property_ownerDocument(JSContext *ctx, unsigned int argc, JS::Value *vp);
@ -157,10 +157,10 @@ JSPropertySpec element_props[] = {
JS_PSG("childElementCount", element_get_property_childElementCount, JSPROP_ENUMERATE),
JS_PSG("childNodes", element_get_property_childNodes, JSPROP_ENUMERATE),
JS_PSGS("className", element_get_property_className, element_set_property_className, JSPROP_ENUMERATE),
JS_PSG("clientHeight", element_get_property_clientHeight, JSPROP_ENUMERATE),
JS_PSG("clientLeft", element_get_property_clientLeft, JSPROP_ENUMERATE),
JS_PSG("clientTop", element_get_property_clientTop, JSPROP_ENUMERATE),
JS_PSG("clientWidth", element_get_property_clientWidth, JSPROP_ENUMERATE),
// JS_PSG("clientHeight", element_get_property_clientHeight, JSPROP_ENUMERATE),
// JS_PSG("clientLeft", element_get_property_clientLeft, JSPROP_ENUMERATE),
// JS_PSG("clientTop", element_get_property_clientTop, JSPROP_ENUMERATE),
// JS_PSG("clientWidth", element_get_property_clientWidth, JSPROP_ENUMERATE),
JS_PSGS("dir", element_get_property_dir, element_set_property_dir, JSPROP_ENUMERATE),
JS_PSG("firstChild", element_get_property_firstChild, JSPROP_ENUMERATE),
JS_PSG("firstElementChild", element_get_property_firstElementChild, JSPROP_ENUMERATE),
@ -175,11 +175,11 @@ JSPropertySpec element_props[] = {
JS_PSG("nodeName", element_get_property_nodeName, JSPROP_ENUMERATE),
JS_PSG("nodeType", element_get_property_nodeType, JSPROP_ENUMERATE),
JS_PSG("nodeValue", element_get_property_nodeValue, JSPROP_ENUMERATE),
JS_PSG("offsetHeight", element_get_property_offsetHeight, JSPROP_ENUMERATE),
JS_PSG("offsetLeft", element_get_property_offsetLeft, JSPROP_ENUMERATE),
// JS_PSG("offsetHeight", element_get_property_offsetHeight, JSPROP_ENUMERATE),
// JS_PSG("offsetLeft", element_get_property_offsetLeft, JSPROP_ENUMERATE),
JS_PSG("offsetParent", element_get_property_offsetParent, JSPROP_ENUMERATE),
JS_PSG("offsetTop", element_get_property_offsetTop, JSPROP_ENUMERATE),
JS_PSG("offsetWidth", element_get_property_offsetWidth, JSPROP_ENUMERATE),
// JS_PSG("offsetTop", element_get_property_offsetTop, JSPROP_ENUMERATE),
// JS_PSG("offsetWidth", element_get_property_offsetWidth, JSPROP_ENUMERATE),
JS_PSGS("outerHTML", element_get_property_outerHtml, element_set_property_outerHtml, JSPROP_ENUMERATE),
JS_PSG("ownerDocument", element_get_property_ownerDocument, JSPROP_ENUMERATE),
JS_PSG("parentElement", element_get_property_parentElement, JSPROP_ENUMERATE),
@ -592,6 +592,7 @@ element_get_property_className(JSContext *ctx, unsigned int argc, JS::Value *vp)
return true;
}
#if 0 // it does not work yet
static bool
element_get_property_clientHeight(JSContext *ctx, unsigned int argc, JS::Value *vp)
{
@ -680,7 +681,9 @@ element_get_property_clientHeight(JSContext *ctx, unsigned int argc, JS::Value *
return true;
}
#endif
#if 0
static bool
element_get_property_clientLeft(JSContext *ctx, unsigned int argc, JS::Value *vp)
{
@ -692,7 +695,9 @@ element_get_property_clientLeft(JSContext *ctx, unsigned int argc, JS::Value *vp
return true;
}
#endif
#if 0
static bool
element_get_property_clientTop(JSContext *ctx, unsigned int argc, JS::Value *vp)
{
@ -704,7 +709,9 @@ element_get_property_clientTop(JSContext *ctx, unsigned int argc, JS::Value *vp)
return true;
}
#endif
#if 0
static bool
element_get_property_clientWidth(JSContext *ctx, unsigned int argc, JS::Value *vp)
{
@ -814,6 +821,7 @@ element_get_property_clientWidth(JSContext *ctx, unsigned int argc, JS::Value *v
return true;
}
#endif
static bool
element_get_property_dir(JSContext *ctx, unsigned int argc, JS::Value *vp)
@ -1616,6 +1624,7 @@ element_get_property_nextSibling(JSContext *ctx, unsigned int argc, JS::Value *v
return true;
}
#if 0
static bool
element_get_property_offsetHeight(JSContext *ctx, unsigned int argc, JS::Value *vp)
{
@ -1624,7 +1633,9 @@ element_get_property_offsetHeight(JSContext *ctx, unsigned int argc, JS::Value *
#endif
return element_get_property_clientHeight(ctx, argc, vp);
}
#endif
#if 0
static bool
element_get_property_offsetLeft(JSContext *ctx, unsigned int argc, JS::Value *vp)
{
@ -1718,6 +1729,7 @@ element_get_property_offsetLeft(JSContext *ctx, unsigned int argc, JS::Value *vp
return true;
}
#endif
static bool
element_get_property_offsetParent(JSContext *ctx, unsigned int argc, JS::Value *vp)
@ -1778,6 +1790,7 @@ element_get_property_offsetParent(JSContext *ctx, unsigned int argc, JS::Value *
return true;
}
#if 0
static bool
element_get_property_offsetTop(JSContext *ctx, unsigned int argc, JS::Value *vp)
{
@ -1871,7 +1884,9 @@ element_get_property_offsetTop(JSContext *ctx, unsigned int argc, JS::Value *vp)
return true;
}
#endif
#if 0
static bool
element_get_property_offsetWidth(JSContext *ctx, unsigned int argc, JS::Value *vp)
{
@ -1880,6 +1895,7 @@ element_get_property_offsetWidth(JSContext *ctx, unsigned int argc, JS::Value *v
#endif
return element_get_property_clientWidth(ctx, argc, vp);
}
#endif
static bool
element_get_property_ownerDocument(JSContext *ctx, unsigned int argc, JS::Value *vp)

View File

@ -64,8 +64,9 @@ struct screen_char {
unsigned char color[SCREEN_COLOR_SIZE];
unsigned int node_number;
} c;
#if 0
unsigned int element_offset;
#endif
};
/** @relates screen_char */

View File

@ -629,12 +629,12 @@ refresh_view(struct session *ses, struct document_view *doc_view, int frames)
if (ses->tab == get_current_tab(ses->tab->term)) {
if (doc_view->parent_doc_view) {
#ifdef CONFIG_LIBDOM
scan_document(doc_view->parent_doc_view);
//scan_document(doc_view->parent_doc_view);
#endif
draw_doc(ses, doc_view->parent_doc_view, 0);
} else {
#ifdef CONFIG_LIBDOM
scan_document(doc_view);
//scan_document(doc_view);
#endif
draw_doc(ses, doc_view, 1);
}