Move current_node and top_node to top_state, to protect them from tables.

Handle table and row and cell data.
(We do nested-table text now.)


git-svn-id: svn://10.0.0.236/trunk@8788 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
shaver%netscape.com
1998-08-29 02:52:27 +00:00
parent 8e2e51702b
commit 5f49f22fb7
5 changed files with 81 additions and 14 deletions

View File

@@ -4012,7 +4012,7 @@ static intn hooked_status = 0;
static PA_Tag *hooked_tag = NULL;
#ifdef DOM
static char *element_names[] = {
char *element_names[] = {
"NONE",
"TEXT",
"LINEFEED",
@@ -4057,6 +4057,11 @@ DumpNodeElements(DOM_Node *node)
fprintf(stderr, "%s %s elements:",
PA_TagString(ELEMENT_PRIV(node)->tagtype),
node->name ? node->name : "");
if (ELEMENT_PRIV(node)->tagtype == P_TABLE_ROW ||
ELEMENT_PRIV(node)->tagtype == P_TABLE_DATA) {
fprintf(stderr, " <NOT REALLY AN ELEMENT>\n");
return;
}
eptr = ELEMENT_PRIV(node)->ele_start;
if (!eptr) {
fprintf(stderr, " <none> (SHOULD REMOVE FROM TREE!)\n");

View File

@@ -658,8 +658,6 @@ typedef struct lo_DocState_struct {
#ifdef DOM
Bool in_span;
PA_Block current_span;
void /*DOM_Node*/ *top_node; /* top of the DOM_Node tree */
void /*DOM_Node*/ *current_node; /* active node (only during tree gen) */
#endif
} lo_DocState;
@@ -852,6 +850,10 @@ struct lo_TopState_struct {
#ifdef DEBUG_ScriptPlugin
char * mimetype;
#endif
#ifdef DOM
void /*DOM_Node*/ *top_node; /* top of the DOM_Node tree */
void /*DOM_Node*/ *current_node; /* active node (only during tree gen) */
#endif
};
/* Script type codes, stored in top_state->in_script. */
@@ -1158,6 +1160,9 @@ extern void lo_relayout_recycle(MWContext *context, lo_DocState *state,
LO_Element *elist);
extern LO_Element *lo_NewElement(MWContext *, lo_DocState *, intn,
ED_Element *, intn edit_offset);
#if DOM
extern void lo_SetNodeElement(lo_DocState *, LO_Element *);
#endif
extern void lo_AppendToLineList(MWContext *, lo_DocState *, LO_Element *,int32);
extern void lo_SetLineArrayEntry(lo_DocState *, LO_Element *, int32);
extern LO_Element *lo_FirstElementOfLine(MWContext *, lo_DocState *, int32);

View File

@@ -3628,6 +3628,14 @@ lo_BeginTableCellAttributes(MWContext *context,
return;
}
#if DOM
/*
* Unsafe cast, but code that operates on the Nodes will
* know that <TD> elements need special care.
*/
lo_SetNodeElement(state, (LO_Element *)table_cell);
#endif
if (state->is_a_subdoc != SUBDOC_NOT)
{
table_cell->in_nested_table = TRUE;
@@ -4340,6 +4348,15 @@ lo_BeginTableRowAttributes(MWContext *context,
{
return;
}
#if DOM
/*
* So this is a little unsafe, on the surface.
* The code that does the reordering of LO_Elements will have to
* think important, special-case thoughts about <TR> nodes,
* but that's OK.
*/
lo_SetNodeElement(state, (LO_Element *)table_row);
#endif
/* copied to lo_UpdateTableStateForBeginRow()
table_row->row_done = FALSE;
@@ -4657,6 +4674,10 @@ lo_BeginTableAttributes(MWContext *context,
table_ele->FE_Data = NULL;
table_ele->anchor_href = state->current_anchor;
#if DOM
lo_SetNodeElement(state, (LO_Element *)table_ele);
#endif
/*
* Default to the current alignment
*/

View File

@@ -5478,7 +5478,7 @@ void lo_AppendTextToBlock ( MWContext *context, lo_DocState *state, LO_TextBlock
block = lo_CurrentTextBlock ( context, state );
}
}
/* OPTIMIZATION: If the parser could tell us if we have a split
* buffer then we could intelligently set parseAllText here and
* not buffer words that we think may be split across a buffer but

View File

@@ -2561,6 +2561,51 @@ lo_CheckNameList(MWContext *context, lo_DocState *state, int32 min_id)
}
}
#if DOM
extern char *element_names[];
/* Wire the element to the DOM Node data for DOM-driven feedback. */
void
lo_SetNodeElement(lo_DocState *state, LO_Element *element)
{
LO_Element *eptr;
DOM_Node *node = CURRENT_NODE(state);
#ifdef DEBUG_shaver
fprintf(stderr, "lo_SetNodeElement: state %x: ", state);
if (!node)
fprintf(stderr, "NULL node\n");
else if (node->type == NODE_TYPE_DOCUMENT)
fprintf(stderr, "NODE_TYPE_DOCUMENT node\n");
#endif
if (node && node->type != NODE_TYPE_DOCUMENT) {
XP_ASSERT(!ELEMENT_PRIV(node)->ele_end);
eptr = ELEMENT_PRIV(node)->ele_start;
if (!eptr) {
/* this the first element for this node, so mark it */
ELEMENT_PRIV(node)->ele_start = element;
#ifdef DEBUG_shaver
fprintf(stderr, "giving node %s element %s\n",
ELEMENT_PRIV(node)->tagtype ?
PA_TagString(ELEMENT_PRIV(node)->tagtype) : "TEXT",
element->type > 0 &&
element->type <= 31 ? element_names[element->type]
: "UNKNOWN", state);
#endif
} else {
#ifdef DEBUG_shaver
fprintf(stderr, "node %s %s already has element %s\n",
ELEMENT_PRIV(node)->tagtype ?
PA_TagString(ELEMENT_PRIV(node)->tagtype) : "TEXT",
node->name ? node->name : "NULL",
element->type > 0 &&
element->type <= 31 ? element_names[element->type]
: "UNKNOWN");
#endif
}
}
}
#endif
void
lo_AppendToLineList(MWContext *context, lo_DocState *state,
@@ -2584,16 +2629,7 @@ lo_AppendToLineList(MWContext *context, lo_DocState *state,
state->current_span = NULL;
}
/* Wire the element to the DOM Node data for DOM-driven feedback. */
if (CURRENT_NODE(state) &&
CURRENT_NODE(state)->type != NODE_TYPE_DOCUMENT) {
XP_ASSERT(!ELEMENT_PRIV(CURRENT_NODE(state))->ele_end);
eptr = ELEMENT_PRIV(CURRENT_NODE(state))->ele_start;
if (!eptr)
/* this the first element for this node, so mark it */
ELEMENT_PRIV(CURRENT_NODE(state))->ele_start = element;
}
lo_SetNodeElement(state, element);
#endif
if (state->current_named_anchor != NULL) {