From 453cc779ce422f1fcfbe2cd1e21e8e2ebdf3f0c3 Mon Sep 17 00:00:00 2001 From: "shaver%netscape.com" Date: Fri, 9 Oct 1998 00:46:05 +0000 Subject: [PATCH] Use ACTIVE_NODE now rather than CURRENT_NODE, and include lm_dom.h everywhere to make that possible. Move LM_ReflectNode call to laytags.c back-end from layout.c front-end (thank you, Uncle Brendan). Correct FIND_LAST_ELEMENT to handle newly-ended doc_states. --- lib/layout/layblock.c | 7 ++++--- lib/layout/layform.c | 3 ++- lib/layout/layimage.c | 3 ++- lib/layout/layout.c | 7 +------ lib/layout/layout.h | 3 ++- lib/layout/laystyle.c | 3 ++- lib/layout/laytags.c | 31 +++++++++++++++++++++++++------ lib/layout/laytext.c | 2 +- lib/layout/layutil.c | 2 +- 9 files changed, 40 insertions(+), 21 deletions(-) diff --git a/lib/layout/layblock.c b/lib/layout/layblock.c index 7e9de4587566..40d38fc24f62 100644 --- a/lib/layout/layblock.c +++ b/lib/layout/layblock.c @@ -649,7 +649,7 @@ lo_BeginLayerTag(MWContext *context, lo_DocState *state, PA_Tag *tag) CL_Layer *parent_layer; #ifdef DOM DOM_AttributeEntry *entry; - DOM_Node *node = state->top_state->current_node; + DOM_Node *node = ACTIVE_NODE(state); DOM_StyleDatabase *db = state->top_state->style_db; JSContext *cx = context->mocha_context; #endif @@ -1046,8 +1046,9 @@ lo_SetStyleSheetLayerProperties(MWContext *context, lo_DocState *state, } else { if (!DOM_StyleGetProperty(cx, db, node, LAYER_SRC_STYLE, &entry)) return; - if (entry) - inflow = JS_TRUE; + if (!entry) + return; + inflow = JS_TRUE; } param = XP_NEW_ZAP(LO_BlockInitializeStruct); diff --git a/lib/layout/layform.c b/lib/layout/layform.c index 9e185ce23d78..f169965f25fa 100644 --- a/lib/layout/layform.c +++ b/lib/layout/layform.c @@ -55,6 +55,7 @@ #ifdef DOM #include "domstyle.h" +#include "lm_dom.h" #endif #ifndef XP_TRACE @@ -815,7 +816,7 @@ new_form_element(MWContext *context, lo_DocState *state, int32 type) DOM_AttributeEntry *entry; JSContext *cx = context->mocha_context; DOM_StyleDatabase *db = state->top_state->style_db; - DOM_Node *node = state->top_state->current_node; + DOM_Node *node = ACTIVE_NODE(state); if (node && (cx || db)) { /* diff --git a/lib/layout/layimage.c b/lib/layout/layimage.c index dcff2804bbf6..f9c8737c90af 100644 --- a/lib/layout/layimage.c +++ b/lib/layout/layimage.c @@ -34,6 +34,7 @@ #include "layers.h" #ifdef DOM #include "domstyle.h" +#include "lm_dom.h" #endif extern int MK_OUT_OF_MEMORY; @@ -1515,7 +1516,7 @@ lo_FormatImage(MWContext *context, lo_DocState *state, PA_Tag *tag) #ifdef DOM JSContext *cx = context->mocha_context; DOM_StyleDatabase *db = state->top_state->style_db; - DOM_Element *element = (DOM_Element *)state->top_state->current_node; + DOM_Element *element = (DOM_Element *)ACTIVE_NODE(state); DOM_AttributeEntry *entry; #endif diff --git a/lib/layout/layout.c b/lib/layout/layout.c index bb5bbf0e842d..490067e6653e 100644 --- a/lib/layout/layout.c +++ b/lib/layout/layout.c @@ -275,6 +275,7 @@ lo_NewTopState(MWContext *context, char *url) #ifdef DOM top_state->top_node = NULL; top_state->current_node = NULL; + top_state->active_node = NULL; top_state->style_db = NULL; #endif @@ -4161,12 +4162,6 @@ LO_ProcessTag(void *data_object, PA_Tag *tag, intn status) } context = doc_data->window_id; -#ifdef DOM - if (state && context) - last_node = LM_ReflectTagNode(tag, state, context); - else - last_node = NULL; -#endif /* * if we get called with abort/complete then ignore oom condition * and clean up diff --git a/lib/layout/layout.h b/lib/layout/layout.h index 65ee2e25d884..75dbf19de2c5 100644 --- a/lib/layout/layout.h +++ b/lib/layout/layout.h @@ -854,7 +854,8 @@ struct lo_TopState_struct { #endif #ifdef DOM struct DOM_Node *top_node; /* top of the DOM_Node tree */ - struct DOM_Node *current_node; /* active node (only during tree gen) */ + struct DOM_Node *current_node; /* node that's parent of next content */ + struct DOM_Node *active_node; /* node for which we're making elements */ struct DOM_StyleDatabase *style_db; #endif void* LAPIprobe; diff --git a/lib/layout/laystyle.c b/lib/layout/laystyle.c index e0da5dbe600c..37f569c1fae1 100644 --- a/lib/layout/laystyle.c +++ b/lib/layout/laystyle.c @@ -34,6 +34,7 @@ #include "intl_csi.h" #ifdef DOM #include "domstyle.h" +#include "lm_dom.h" #endif void @@ -306,7 +307,7 @@ LO_CheckForContentHiding(lo_DocState *state, MWContext *context) { JSContext *cx = context->mocha_context; DOM_StyleDatabase *db = state->top_state->style_db; - DOM_Node *node = state->top_state->current_node; + DOM_Node *node = ACTIVE_NODE(state); DOM_AttributeEntry *entry; if (!db || !cx || !node || diff --git a/lib/layout/laytags.c b/lib/layout/laytags.c index 536287ac10e6..cfe591a036c8 100644 --- a/lib/layout/laytags.c +++ b/lib/layout/laytags.c @@ -1503,7 +1503,7 @@ lo_process_anchor_tag(MWContext *context, lo_DocState *state, PA_Tag *tag) { lo_DocLists *doc_lists; #ifdef DOM - DOM_Node *node = state->top_state->current_node; + DOM_Node *node = ACTIVE_NODE(state); DOM_Element *element = (DOM_Element *)node; JSContext *cx = context->mocha_context; #else @@ -1514,6 +1514,9 @@ lo_process_anchor_tag(MWContext *context, lo_DocState *state, PA_Tag *tag) #ifdef DOM XP_ASSERT(node->type == NODE_TYPE_ELEMENT); +#ifdef DEBUG_shaver + PR_ASSERT(node->type == NODE_TYPE_ELEMENT); +#endif #endif /* * Opening a new anchor @@ -4146,7 +4149,7 @@ lo_SetStyleSheetProperties(MWContext *context, lo_DocState *state, PA_Tag *tag) { JSContext *cx = context->mocha_context; DOM_StyleDatabase *db = state->top_state->style_db; - DOM_Node *node = state->top_state->current_node; + DOM_Node *node = ACTIVE_NODE(state); if (!node) return; @@ -4525,12 +4528,16 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type)); LO_LockLayout(); +#ifdef DOM + LM_ReflectTagNode(tag, state, context); +#endif + if(!tag->is_end && lo_IsEmptyTag(tag->type)) { #ifdef DOM - lo_SetStyleSheetProperties(context, state, tag); + lo_SetStyleSheetProperties(context, state, tag); #else - lo_SetStyleSheetProperties(context, style_struct, tag); + lo_SetStyleSheetProperties(context, style_struct, tag); #endif } @@ -7644,13 +7651,19 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type)); /* find the last element on the line list and its node */ #define FIND_LAST_ELEMENT(eptr) \ eptr = state->line_list; \ + if (!eptr) \ + eptr = state->end_last_line; \ + /* if there are no elements in state, try the currently active one */ \ + if (!eptr) \ + eptr = state->top_state->doc_state->line_list; \ + if (!eptr) \ + eptr = state->top_state->doc_state->end_last_line; \ if (eptr) { \ while (eptr->lo_any.next != NULL) { \ eptr = eptr->lo_any.next; \ } \ - } else { \ - eptr = state->end_last_line; \ } + FIND_LAST_ELEMENT(eptr); if (!eptr) return; @@ -7673,6 +7686,12 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type)); /* if we popped stuff, resync the end pointer */ if (resyncElements) { FIND_LAST_ELEMENT(eptr); + if (!eptr) { +#ifdef DEBUG_shaver + fprintf(stderr, "can't find new eptr for resync!\n"); +#endif + return; + } XP_ASSERT(eptr->lo_any.node == node); } diff --git a/lib/layout/laytext.c b/lib/layout/laytext.c index 6b309577c825..2bf3d13f77f7 100644 --- a/lib/layout/laytext.c +++ b/lib/layout/laytext.c @@ -8553,7 +8553,7 @@ lo_FillInTextStyleInfo(lo_DocState *state, MWContext *context, JSContext *cx = context->mocha_context; DOM_StyleDatabase *db = state->top_state->style_db; DOM_AttributeEntry *entry; - DOM_Node *node = state->top_state->current_node; + DOM_Node *node = ACTIVE_NODE(state); LO_TextAttr text_attr, *newptr = NULL; JSBool copied = JS_FALSE; LO_Color col; diff --git a/lib/layout/layutil.c b/lib/layout/layutil.c index ca716550ac4a..caf50f6bab99 100644 --- a/lib/layout/layutil.c +++ b/lib/layout/layutil.c @@ -2608,7 +2608,7 @@ lo_SetNodeElement(lo_DocState *state, LO_Element *element) /* this the first element for this node, so mark it */ ELEMENT_PRIV(node)->ele_start = element; } -#ifdef DEBUG_shaver +#ifdef DEBUG_shaver_verbose if (element->lo_any.node) fprintf(stderr, "element %p (type %d) already has node %x\n", element, element->lo_any.type, element->lo_any.node);