more DOM style stuff, fix some warnings, conditionally prune looks-dead-to-me code, support font-weight:bold/normal

This commit is contained in:
shaver%netscape.com 1998-10-02 00:09:52 +00:00
Родитель 83d970858d
Коммит 1675302421
6 изменённых файлов: 132 добавлений и 24 удалений

Просмотреть файл

@ -29,6 +29,7 @@
#include "intl_csi.h" #include "intl_csi.h"
#ifdef DOM #ifdef DOM
#include "domstyle.h" #include "domstyle.h"
#include "lm_dom.h"
#endif #endif
/* This struct is used during the processing of a <LAYER> or <ILAYER> /* This struct is used during the processing of a <LAYER> or <ILAYER>
@ -479,11 +480,13 @@ lo_block_src_exit_fn(URL_Struct *url_struct, int status, MWContext *context)
NET_FreeURLStruct(url_struct); NET_FreeURLStruct(url_struct);
} }
#ifndef DOM
static void static void
lo_free_stream(MWContext *context, NET_StreamClass *stream) lo_free_stream(MWContext *context, NET_StreamClass *stream)
{ {
XP_DELETE(stream); XP_DELETE(stream);
} }
#endif
int32 int32
lo_GetEnclosingLayerWidth(lo_DocState *state) lo_GetEnclosingLayerWidth(lo_DocState *state)
@ -952,6 +955,62 @@ PositionParser(const char *position, uint32 *data, void *closure)
return JS_TRUE; return JS_TRUE;
} }
#define AXIS_NONE 0
#define AXIS_X 1
#define AXIS_Y 2
struct SSUnitContext {
MWContext *context;
uint32 enclosingVal;
uint8 units;
uint8 axisAdjust;
};
#define STYLE_UNITS_NONE 0
#define STYLE_UNITS_PERCENT 1
/* XXX finish */
JSBool
lo_ParseSSNum(const char *str, uint32 *num, uint8 *units)
{
*num = XP_ATOI(str);
if (strchr(str, '%'))
*units = STYLE_UNITS_PERCENT;
else
*units = STYLE_UNITS_NONE;
return JS_TRUE;
}
JSBool
lo_atoi(const char *str, uint32 *num, void *closure)
{
*num = XP_ATOI(str);
return JS_TRUE;
}
JSBool
lo_ParseSSNumToData(const char *str, uint32 *data, void *closure)
{
struct SSUnitContext *argp = closure;
uint32 num;
if (!lo_ParseSSNum(str, &num, &argp->units))
return JS_FALSE;
if (argp->units == STYLE_UNITS_PERCENT) {
num = argp->enclosingVal * num / 100;
}
if (argp->axisAdjust == AXIS_X)
num = FEUNITS_X(num, argp->context);
else if (argp->axisAdjust == AXIS_Y)
num = FEUNITS_Y(num, argp->context);
*data = num;
return JS_FALSE;
}
void void
lo_SetStyleSheetLayerProperties(MWContext *context, lo_DocState *state, lo_SetStyleSheetLayerProperties(MWContext *context, lo_DocState *state,
DOM_StyleDatabase *db, DOM_Node *node, DOM_StyleDatabase *db, DOM_Node *node,
@ -961,25 +1020,28 @@ lo_SetStyleSheetLayerProperties(MWContext *context, lo_DocState *state,
LO_BlockInitializeStruct *param; LO_BlockInitializeStruct *param;
DOM_AttributeEntry *entry; DOM_AttributeEntry *entry;
JSBool inflow; JSBool inflow;
struct SSUnitContext arg;
JSContext *cx = context->mocha_context;
#ifdef DEBUG_shaver #ifdef DEBUG_shaver
fprintf(stderr, "setting layer data on <%s>\n", PA_TagString(tag->type)); fprintf(stderr, "setting layer data on <%s>\n", PA_TagString(tag->type));
#endif #endif
return; arg.context = context;
#if 0
if (lo_IsEmptyTag(tag->type)) if (lo_IsEmptyTag(tag->type))
/* other code says we can't handle empty tags, so I bail...for now! */ /* other code says we can't handle empty tags, so I bail...for now! */
return; return;
if (!DOM_StyleGetProperty(cx, db, node, POSITION_STYLE, &entry)) if (!DOM_StyleGetProperty(cx, db, node, POSITION_STYLE, &entry))
return; return;
if (entry) { if (entry) {
if (!DOM_GetCleanAttributeData(cx, entry, PositionParser, if (!DOM_GetCleanAttributeData(cx, entry, PositionParser,
(uint32 *)&inflow, NULL)) (uint32 *)&inflow, NULL))
return; return;
} else { } else {
if (!DOM_StyleGetProperty(cx, db, node, LAYER_SRC, &entry)) if (!DOM_StyleGetProperty(cx, db, node, LAYER_SRC_STYLE, &entry))
return; return;
if (entry) if (entry)
inflow = JS_TRUE; inflow = JS_TRUE;
@ -989,6 +1051,10 @@ lo_SetStyleSheetLayerProperties(MWContext *context, lo_DocState *state,
if (!param) if (!param)
return; return;
#define CHECK_PERCENTAGE(entry, arg) \
if (arg.units == STYLE_UNITS_PERCENT) \
entry->dirty = JS_TRUE;
param->name = XP_STRDUP(node->name); param->name = XP_STRDUP(node->name);
if (node->type == NODE_TYPE_ELEMENT) if (node->type == NODE_TYPE_ELEMENT)
param->id = element->styleID ? XP_STRDUP(element->styleID) : NULL; param->id = element->styleID ? XP_STRDUP(element->styleID) : NULL;
@ -996,17 +1062,22 @@ lo_SetStyleSheetLayerProperties(MWContext *context, lo_DocState *state,
if (!DOM_StyleGetProperty(cx, db, node, LEFT_STYLE, &entry)) if (!DOM_StyleGetProperty(cx, db, node, LEFT_STYLE, &entry))
goto error; goto error;
if (entry) { if (entry) {
if (!DOM_GetCleanAttributeData(cx, entry, lo_SSNumToFEUnitsX, &param->left, arg.axisAdjust = AXIS_X;
(void *)context)) arg.enclosingVal = 0;
if (!DOM_GetCleanAttributeData(cx, entry, lo_ParseSSNumToData,
&param->left, (void *)&arg))
goto error; goto error;
CHECK_PERCENTAGE(entry, arg);
param->has_left = TRUE; param->has_left = TRUE;
} }
if (!DOM_StyleGetProperty(cx, db, node, TOP_STYLE, &entry)) if (!DOM_StyleGetProperty(cx, db, node, TOP_STYLE, &entry))
goto error; goto error;
if (entry) { if (entry) {
if (!DOM_GetCleanAttributeData(cx, entry, lo_SSNumToFEUnitsY, &param->top, arg.axisAdjust = AXIS_Y;
(void *)context)) arg.enclosingVal = 0;
if (!DOM_GetCleanAttributeData(cx, entry, lo_ParseSSNumToData, &param->top,
(void *)&arg))
goto error; goto error;
param->has_top = TRUE; param->has_top = TRUE;
} }
@ -1014,29 +1085,51 @@ lo_SetStyleSheetLayerProperties(MWContext *context, lo_DocState *state,
if (!DOM_StyleGetProperty(cx, db, node, HEIGHT_STYLE, &entry)) if (!DOM_StyleGetProperty(cx, db, node, HEIGHT_STYLE, &entry))
goto error; goto error;
if (entry) { if (entry) {
if (!DOM_GetCleanAttributeData(cx, entry, lo_SSNumToFEUnitsY, arg.axisAdjust = AXIS_Y;
&param->height, (void *)context)) arg.enclosingVal = lo_GetEnclosingLayerHeight(state);
if (!DOM_GetCleanAttributeData(cx, entry, lo_ParseSSNumToData,
&param->height, (void *)&arg))
goto error; goto error;
param->has_height = TRUE; param->has_height = TRUE;
} }
#if 0 /* waiting on DOM-savvy lo_ParseStyleCoords */
if (!DOM_StyleGetProperty(cx, db, node, CLIP_STYLE, &entry)) if (!DOM_StyleGetProperty(cx, db, node, CLIP_STYLE, &entry))
goto error; goto error;
if (entry) { if (entry) {
/* XXX GetCleanAttributeData */ /* XXX GetCleanAttributeData, with coord hash somewhere? */
param->clip = lo_ParseStyleCoords(context, state, entry->value); param->clip = lo_ParseStyleCoords(context, state, entry->value);
param->clip_expansion_policy = LO_AUTO_EXPAND_NONE; param->clip_expansion_policy = LO_AUTO_EXPAND_NONE;
} }
#endif
param->above = NULL; param->above = NULL;
param->below = NULL; param->below = NULL;
if (!DOM_StyleGetProperty(cx, db, node, ZINDEX_STYLE, &entry)) if (!DOM_StyleGetProperty(cx, db, node, ZINDEX_STYLE, &entry))
goto error; goto error;
if (entry) {
if (!DOM_GetCleanAttributeData(cx, entry, lo_atoi, &param->zindex, NULL))
goto error;
param->has_zindex = TRUE;
} else {
param->has_zindex = FALSE;
}
return; if (!DOM_StyleGetProperty(cx, db, node, VISIBILITY_STYLE, &entry))
error: goto error;
XP_FREE(param); if (entry)
#endif 0 param->visibility = XP_STRDUP(entry->value);
/* XXX handle src */
param->tag = NULL;
param->ss_tag = tag;
if (!LM_SetNodeFlags(node, STYLE_NODE_NEED_TO_POP_LAYER))
goto error;
if (lo_BeginLayer(context, state, param, inflow))
error:
lo_FreeBlockInitializeStruct(param);
} }
#else #else

Просмотреть файл

@ -1033,6 +1033,7 @@ lo_calc_push_right_for_justify(lo_DocState *state, int32 *remainder)
} }
} }
#ifndef DOM
PRIVATE void PRIVATE void
lo_add_to_y_for_all_elements_in_line(lo_DocState *state, int32 y_add) lo_add_to_y_for_all_elements_in_line(lo_DocState *state, int32 y_add)
{ {
@ -1054,6 +1055,7 @@ lo_add_to_y_for_all_elements_in_line(lo_DocState *state, int32 y_add)
tptr = tptr->lo_any.next; tptr = tptr->lo_any.next;
} }
} }
#endif
void void
lo_use_default_doc_background(MWContext *context, lo_DocState *state) lo_use_default_doc_background(MWContext *context, lo_DocState *state)
@ -4107,6 +4109,7 @@ char *element_names[] = {
"SUB" "SUB"
}; };
#ifdef DEBUG_shaver_verbose
static void static void
DumpNodeElements(DOM_Node *node) DumpNodeElements(DOM_Node *node)
{ {
@ -4138,6 +4141,7 @@ DumpNodeElements(DOM_Node *node)
#endif #endif
} }
#endif #endif
#endif
/************************************* /*************************************
* Function: LO_ProcessTag * Function: LO_ProcessTag

Просмотреть файл

@ -1224,6 +1224,8 @@ void lo_SetStyleSheetLayerProperties(MWContext *context, lo_DocState *state,
struct DOM_StyleDatabase *db, struct DOM_StyleDatabase *db,
struct DOM_Node *node, struct DOM_Node *node,
PA_Tag *tag); PA_Tag *tag);
struct DOM_StyleDatabase *
DOMMOZ_NewStyleDatabase(JSContext *context, lo_DocState *state);
#else #else
void lo_SetStyleSheetLayerProperties(MWContext *context, void lo_SetStyleSheetLayerProperties(MWContext *context,
lo_DocState *state, lo_DocState *state,

Просмотреть файл

@ -4147,12 +4147,15 @@ lo_SetStyleSheetProperties(MWContext *context, lo_DocState *state, PA_Tag *tag)
DOM_StyleDatabase *db = state->top_state->style_db; DOM_StyleDatabase *db = state->top_state->style_db;
DOM_Node *node = state->top_state->current_node; DOM_Node *node = state->top_state->current_node;
if (!node)
return;
if (!db) { if (!db) {
if (!cx) if (!cx)
return; return;
db = DOM_StyleDatabaseFromContext(cx); db = DOMMOZ_NewStyleDatabase(cx, state);
if (!db) if (!db)
return; return;
state->top_state->style_db = db;
} }
#ifdef DEBUG_shaver #ifdef DEBUG_shaver

Просмотреть файл

@ -3620,6 +3620,7 @@ lo_PushFont(lo_DocState *state, intn tag_type, LO_TextAttr *attr)
* *
* Returns: The LO_TextAttr structure of the font just passed. * Returns: The LO_TextAttr structure of the font just passed.
*************************************/ *************************************/
#ifndef DOM
PRIVATE PRIVATE
LO_TextAttr * LO_TextAttr *
lo_PopFontStack(lo_DocState *state, intn tag_type) lo_PopFontStack(lo_DocState *state, intn tag_type)
@ -3648,7 +3649,7 @@ XP_TRACE(("Warning: Font popped by different TAG than pushed it %d != %d\n", fp
return(attr); return(attr);
} }
#endif
LO_TextAttr * LO_TextAttr *
lo_PopFont(lo_DocState *state, intn tag_type) lo_PopFont(lo_DocState *state, intn tag_type)
@ -5366,9 +5367,11 @@ static uint32 lo_FindLineBreak ( MWContext * context, lo_DocState * state, LO_T
/* the parsers */ /* the parsers */
static void lo_ParseSingleText ( lo_DocState * state, LO_TextBlock * block, Bool parseAllText, char * text ); static void lo_ParseSingleText ( lo_DocState * state, LO_TextBlock * block, Bool parseAllText, char * text );
static void lo_ParseThaiText ( lo_DocState * state, LO_TextBlock * block, Bool parseAllText, char * text ); static void lo_ParseThaiText ( lo_DocState * state, LO_TextBlock * block, Bool parseAllText, char * text );
#ifndef DOM
static void lo_ParseSinglePreformattedText ( lo_DocState * state, LO_TextBlock * block, Bool parseAllText, char * text ); static void lo_ParseSinglePreformattedText ( lo_DocState * state, LO_TextBlock * block, Bool parseAllText, char * text );
static void lo_ParseDoubleText ( lo_DocState * state, LO_TextBlock * block, Bool parseAllText, char * text );
static void lo_ParseDoublePreformattedText ( lo_DocState * state, LO_TextBlock * block, Bool parseAllText, char * text ); static void lo_ParseDoublePreformattedText ( lo_DocState * state, LO_TextBlock * block, Bool parseAllText, char * text );
#endif
static void lo_ParseDoubleText ( lo_DocState * state, LO_TextBlock * block, Bool parseAllText, char * text );
extern int32 lo_correct_text_element_width(LO_TextInfo *text_info); extern int32 lo_correct_text_element_width(LO_TextInfo *text_info);
@ -8261,13 +8264,13 @@ lo_GetLineStart ( LO_TextBlock * block )
return &block->text_buffer[ block->last_line_break ]; return &block->text_buffer[ block->last_line_break ];
} }
#ifdef DOM
static void static void
lo_SkipCharacter ( LO_TextBlock * block ) lo_SkipCharacter ( LO_TextBlock * block )
{ {
++block->buffer_read_index; ++block->buffer_read_index;
} }
#endif
static void static void
lo_SetLineBreak ( LO_TextBlock * block, Bool skipSpace ) lo_SetLineBreak ( LO_TextBlock * block, Bool skipSpace )
@ -8505,6 +8508,10 @@ FontWeightToData(const char *str, uint32 *data, void *closure)
weight = FONT_WEIGHT_BOLDER; weight = FONT_WEIGHT_BOLDER;
} else if (!strcasecomp(str, "lighter")) { } else if (!strcasecomp(str, "lighter")) {
weight = FONT_WEIGHT_LIGHTER; weight = FONT_WEIGHT_LIGHTER;
} else if (!strcasecomp(str, "bold")) {
weight = 700;
} else if (!strcasecomp(str, "normal")) {
weight = 400;
} else { } else {
weight = XP_ATOI(str); weight = XP_ATOI(str);
weight -= weight % 100; weight -= weight % 100;

Просмотреть файл

@ -3432,8 +3432,8 @@ LO_CellStruct *lo_GetParentCell(MWContext * pContext, LO_Element *pElement)
} }
static lo_iColumnX = 0; static int lo_iColumnX = 0;
static lo_iRowY = 0; static int lo_iRowY = 0;
/* Find the first cell with with closest left border x-value <= than the given x /* Find the first cell with with closest left border x-value <= than the given x
* value or, if bGetColumn=FALSE, find the cell with closest top border * value or, if bGetColumn=FALSE, find the cell with closest top border
@ -3765,7 +3765,6 @@ XP_Bool LO_IsEmptyCell(LO_CellStruct *cell)
/* Unlikely, but if nothing inside cell, we're empty! */ /* Unlikely, but if nothing inside cell, we're empty! */
if(element) if(element)
{ {
LO_Element *pNext = element->lo_any.next;
while(element) while(element)
{ {
/* Any non-text element except linefeed is not "empty" /* Any non-text element except linefeed is not "empty"