Wire up Perignon stuff #if DOM.

Remove some unused variables.
This commit is contained in:
shaver%netscape.com 1998-09-28 23:39:17 +00:00
Родитель 157e4294d7
Коммит 29f18d8c5e
18 изменённых файлов: 863 добавлений и 87 удалений

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

@ -22,6 +22,11 @@ LIBRARY_NAME = lay
EXPORTS = laylayer.h layout.h lo_funcs.h
# XXX Perignon hack
ifdef DOM
EXPORTS += laystyle.h
endif
CSRCS = bullet.c \
clipline.c \
layarena.c \

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

@ -27,6 +27,9 @@
#include "libevent.h"
#include "layers.h"
#include "intl_csi.h"
#ifdef DOM
#include "domstyle.h"
#endif
/* This struct is used during the processing of a <LAYER> or <ILAYER>
* tag, but discarded after the tag is closed. It is used to store the
@ -641,7 +644,12 @@ lo_BeginLayerTag(MWContext *context, lo_DocState *state, PA_Tag *tag)
char *val;
lo_LayerDocState *layer_state;
CL_Layer *parent_layer;
#ifdef DOM
DOM_AttributeEntry *entry;
DOM_Node *node = state->top_state->current_node;
DOM_StyleDatabase *db = state->top_state->style_db;
JSContext *cx = context->mocha_context;
#endif
if (!context->compositor)
return;
@ -786,6 +794,17 @@ lo_BeginLayerTag(MWContext *context, lo_DocState *state, PA_Tag *tag)
/* Process background color (BGCOLOR) attribute, if present. */
param->bgcolor = (char*)PA_FetchParamValue(tag, PARAM_BGCOLOR, win_csid);
#ifdef DOM
/* if there was no bgcolor specified for the layer, find one in style */
if (!param->bgcolor) {
if (!DOM_StyleGetProperty(cx, db, node, BG_COLOR_STYLE, &entry))
/* what now? */
return NULL;
if (entry)
param->bgcolor = XP_STRDUP(entry->value);
}
#endif
/* Process backdrop (BACKGROUND) image attribute, if present. */
param->bgimage = lo_ParseBackgroundAttribute(context,
state,
@ -920,6 +939,20 @@ lo_ParseStyleCoords(MWContext *context,
return coords;
}
#ifdef DOM
void
lo_SetStyleSheetLayerProperties(MWContext *context, lo_DocState *state,
DOM_StyleDatabase *db, DOM_Node *node,
PA_Tag *tag)
{
LO_BlockInitializeStruct *param;
DOM_AttributeEntry *entry;
#ifdef DEBUG_shaver
fprintf(stderr, "setting layer data on <%s>\n", PA_TagString(tag->type));
#endif
}
#else
void
lo_SetStyleSheetLayerProperties(MWContext *context,
lo_DocState *state,
@ -1066,6 +1099,7 @@ lo_SetStyleSheetLayerProperties(MWContext *context,
if (lo_BeginLayer(context, state, param, is_inflow))
lo_FreeBlockInitializeStruct(param);
}
#endif /* DOM */
static void
lo_expand_parent_bbox(CL_Layer *layer); /* Forward declaration */

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

@ -45,7 +45,6 @@ lo_FormatBuiltin (MWContext *context, lo_DocState *state, PA_Tag *tag)
LO_BuiltinStruct *builtin;
PA_Block buff;
char *str;
uint32 src_len;
#ifdef DEBUG_SPENCE
printf ("lo_FormatBuiltin\n");
@ -105,9 +104,6 @@ lo_FormatBuiltinObject (MWContext *context, lo_DocState* state,
PA_Tag* tag , LO_BuiltinStruct *builtin, Bool streamStarted,
uint32 param_count, char **param_names, char **param_values)
{
uint32 count;
int32 typeIndex = -1;
int32 classidIndex = -1;
#ifdef DEBUG_SPENCE
printf ("lo_FormatBuiltinObject\n");
@ -538,6 +534,7 @@ lo_LayoutInflowBuiltin(MWContext *context,
PA_UNLOCK(buff);
tmp_text.text = buff;
tmp_text.text_len = 1;
/* TEXTATTR HERE */
tmp_text.text_attr =
state->font_stack->text_attr;
FE_GetTextInfo(context, &tmp_text, &text_info);

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

@ -701,6 +701,11 @@ lo_DisplayElement(MWContext *context, LO_Element *tptr,
if (bbox.right <= x )
return;
#ifdef DOM_notyet
if (LO_CheckForContentHiding(state, context))
return;
#endif
/* Temporarily translate to new coordinate system */
any->x += base_x;
any->y += base_y;

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

@ -213,8 +213,6 @@ lo_FormatEmbedObject(MWContext* context, lo_DocState* state,
uint32 param_count, char** param_names, char** param_values)
{
uint32 count;
int32 typeIndex = -1;
int32 classidIndex = -1;
LO_NVList_Init(&embed->attributes);
@ -1091,6 +1089,7 @@ lo_LayoutInflowEmbed(MWContext *context,
PA_UNLOCK(buff);
tmp_text.text = buff;
tmp_text.text_len = 1;
/* TEXTATTR HERE */
tmp_text.text_attr =
state->font_stack->text_attr;
FE_GetTextInfo(context, &tmp_text, &text_info);

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

@ -53,6 +53,10 @@
#include "receipt.h"
#endif
#ifdef DOM
#include "domstyle.h"
#endif
#ifndef XP_TRACE
# define XP_TRACE(X) fprintf X
#endif
@ -775,6 +779,10 @@ new_form_element(MWContext *context, lo_DocState *state, int32 type)
form_element->event_handler_present = FALSE;
#endif
/* TEXTATTR HERE */
#ifdef DOM
form_element->text_attr = lo_GetCurrentTextAttr(state, context);
#else
if (state->font_stack == NULL)
{
form_element->text_attr = NULL;
@ -782,6 +790,7 @@ new_form_element(MWContext *context, lo_DocState *state, int32 type)
else
{
form_element->text_attr = state->font_stack->text_attr;
#endif
/*
* Possibly inherit the background color attribute
* of a parent table cell.
@ -808,8 +817,44 @@ new_form_element(MWContext *context, lo_DocState *state, int32 type)
up_state->current_ele->lo_subdoc.backdrop.bg_color);
}
}
}
#ifdef DOM
{
LO_Color col;
DOM_AttributeEntry *entry;
JSContext *cx = context->mocha_context;
DOM_StyleDatabase *db = state->top_state->style_db;
DOM_Node *node = state->top_state->current_node;
if (node && (cx || db)) {
/*
* when we turn DOM on permanently, we can use it to find
* the parent cell with a bgcolor property, let style
* trump it in place and avoid the duplicate calls to
* lo_recolor_form_element_bg.
*/
if (!DOM_StyleGetProperty(cx, db, node, "bgcolor", &entry)) {
XP_FREE(form_element);
return NULL;
}
if (entry) {
if (!DOM_GetCleanEntryData(cx, entry, lo_ColorStringToData,
(uint32 *)&col, NULL)) {
XP_FREE(form_element);
return NULL;
}
lo_recolor_form_element_bg(state, form_element, &col);
}
}
}
#else
}
#endif
#ifdef XP_WIN
/* TEXTATTR HERE */
/*
* XXX DOM so, um, what does this mean when I get the text_attr from
* lo_GetCurrentTextAttr?
*/
attr_change = FALSE;
attr_change = FE_CheckFormTextAttributes(context,
form_element->text_attr, &tmp_attr, type);
@ -2309,7 +2354,11 @@ lo_BeginTextareaTag(MWContext *context, lo_DocState *state, PA_Tag *tag)
char *type_str;
#endif /*ENDER*/
#ifdef DOM
old_attr = lo_GetCurrentTextAttr(state, context);
#else
old_attr = state->font_stack->text_attr;
#endif
lo_CopyTextAttr(old_attr, &tmp_attr);
tmp_attr.fontmask |= LO_FONT_FIXED;
attr = lo_FetchTextAttr(state, &tmp_attr);
@ -2449,7 +2498,11 @@ lo_ProcessInputTag(MWContext *context, lo_DocState *state, PA_Tag *tag)
LO_TextAttr *old_attr;
LO_TextAttr *attr;
#ifdef DOM
old_attr = lo_GetCurrentTextAttr(state, context);
#else
old_attr = state->font_stack->text_attr;
#endif
lo_CopyTextAttr(old_attr, &tmp_attr);
tmp_attr.fontmask |= LO_FONT_FIXED;
attr = lo_FetchTextAttr(state, &tmp_attr);

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

@ -32,6 +32,9 @@
#include "prefapi.h"
#include "xlate.h"
#include "layers.h"
#ifdef DOM
#include "domstyle.h"
#endif
extern int MK_OUT_OF_MEMORY;
@ -327,7 +330,6 @@ lo_parse_style_RGB_functional_notation(char *rgb,
while(value && index < 3)
{
XP_Bool is_percentage = FALSE;
int scaled_value;
value = XP_StripLine(value);
@ -1396,7 +1398,7 @@ lo_PartialFormatImage(MWContext *context, lo_DocState *state, PA_Tag *tag)
tag->lo_data = NULL;
/*
* Assign it a properly sequencial element id.
* Assign it a properly sequential element id.
*/
image->ele_id = NEXT_ELEMENT;
@ -1421,6 +1423,9 @@ lo_PartialFormatImage(MWContext *context, lo_DocState *state, PA_Tag *tag)
}
#ifdef DOM
image->text_attr = lo_GetCurrentTextAttr(state, context);
#else
if (state->font_stack == NULL)
{
LO_TextAttr tmp_attr;
@ -1437,6 +1442,7 @@ lo_PartialFormatImage(MWContext *context, lo_DocState *state, PA_Tag *tag)
{
image->text_attr = state->font_stack->text_attr;
}
#endif
if ((image->text_attr != NULL)&&
(image->text_attr->attrmask & LO_ATTR_ANCHOR))
@ -1444,6 +1450,9 @@ lo_PartialFormatImage(MWContext *context, lo_DocState *state, PA_Tag *tag)
image->image_attr->attrmask |= LO_ATTR_ANCHOR;
}
#ifdef DOM
/* do we want a better way to do this USEMAP hackery? */
#endif
if (image->image_attr->usemap_name != NULL)
{
LO_TextAttr tmp_attr;
@ -1499,22 +1508,31 @@ lo_PartialFormatImage(MWContext *context, lo_DocState *state, PA_Tag *tag)
void
lo_FormatImage(MWContext *context, lo_DocState *state, PA_Tag *tag)
{
LO_ImageStruct *image;
LO_ImageStruct *image;
LO_TextAttr *tptr = NULL;
PA_Block buff;
char *str;
int32 val;
/* int32 doc_width; */
Bool is_a_form;
PA_Block buff;
char *str;
int32 val;
/* int32 doc_width; */
Bool is_a_form;
XP_ObserverList image_obs_list; /* List of observers for an image request. */
lo_DocLists *doc_lists;
int32 layer_id;
#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_AttributeEntry *entry;
#endif
doc_lists = lo_GetCurrentDocLists(state);
#ifdef DOM
tptr = lo_GetCurrentTextAttr(state, context);
#else
if (state->font_stack)
tptr = state->font_stack->text_attr;
#endif
/*
* Fill in the image structure with default data
*/
@ -1530,6 +1548,41 @@ lo_FormatImage(MWContext *context, lo_DocState *state, PA_Tag *tag)
*/
image->anchor_href = state->current_anchor;
#ifdef DOM
#ifdef DEBUG_shaver
fprintf(stderr, "----GETTING IMAGE DATA----\n");
#endif
if (!DOM_StyleGetProperty(cx, db, (DOM_Node *)element,
BORDERWIDTH_STYLE, &entry))
return;
if (entry) {
/* XXX handle borderTop/borderBottom/borderLeft/borderRight */
if (!DOM_GetCleanEntryData(cx, entry, lo_SSUnitsToData,
&image->border_width, context))
return;
} else {
XP_ASSERT(0 && "no style value for image " BORDERWIDTH_STYLE);
#ifdef DEBUG_shaver
fprintf(stderr, "no style value for IMG.border\n");
#endif
image->border_width = IMAGE_DEF_BORDER;
}
if (!DOM_StyleGetProperty(cx, db, (DOM_Node *)element,
PADDING_STYLE, &entry))
return;
if (entry) {
/* XXX handle paddingTop/paddingBottom/paddingLeft/paddingRight */
if (!DOM_GetCleanEntryData(cx, entry, lo_SSUnitsToData,
&image->border_vert_space, context))
return;
image->border_horiz_space = image->border_vert_space;
} else {
XP_ASSERT(0 && "no style value for image " PADDING_STYLE);
image->border_vert_space = IMAGE_DEF_VERTICAL_SPACE;
image->border_horiz_space = IMAGE_DEF_HORIZONTAL_SPACE;
}
#else
if (image->anchor_href != NULL)
{
image->border_width = IMAGE_DEF_ANCHOR_BORDER;
@ -1540,6 +1593,7 @@ lo_FormatImage(MWContext *context, lo_DocState *state, PA_Tag *tag)
}
image->border_vert_space = IMAGE_DEF_VERTICAL_SPACE;
image->border_horiz_space = IMAGE_DEF_HORIZONTAL_SPACE;
#endif
if ((image->text_attr != NULL)&&
(image->text_attr->attrmask & LO_ATTR_ANCHOR))
@ -1560,7 +1614,7 @@ lo_FormatImage(MWContext *context, lo_DocState *state, PA_Tag *tag)
{
LO_TextAttr tmp_attr;
image->image_attr->layer_id = lo_CurrentLayerId(state);
image->image_attr->layer_id = lo_CurrentLayerId(state);
image->image_attr->form_id = doc_lists->current_form_num;
image->image_attr->attrmask |= LO_ATTR_ISFORM;
image->border_width = IMAGE_DEF_ANCHOR_BORDER;
@ -2825,9 +2879,6 @@ static void
lo_internal_image(MWContext *context, LO_ImageStruct *lo_image, int icon_number,
int icon_width, int icon_height)
{
int bw = lo_image->border_width;
/* Don't draw icons for mocha images. */
if (lo_image->image_attr->attrmask & LO_ATTR_MOCHA_IMAGE)
return;
@ -3445,7 +3496,11 @@ void lo_LayoutInflowImage(MWContext *context, lo_DocState *state, LO_ImageStruct
tmp_text.text = buff;
tmp_text.text_len = 1;
tmp_text.text_attr =
state->font_stack->text_attr;
#ifdef DOM
lo_GetCurrentTextAttr(state, context);
#else
state->font_stack->text_attr;
#endif
FE_GetTextInfo(context, &tmp_text, &text_info);
PA_FREE(buff);

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

@ -867,7 +867,11 @@ lo_LayoutInflowJavaApp(MWContext *context,
tmp_text.text = buff;
tmp_text.text_len = 1;
tmp_text.text_attr =
state->font_stack->text_attr;
#ifdef DOM
lo_GetCurrentTextAttr(state, context);
#else
state->font_stack->text_attr;
#endif
FE_GetTextInfo(context, &tmp_text, &text_info);
PA_FREE(buff);

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

@ -272,6 +272,11 @@ lo_NewTopState(MWContext *context, char *url)
top_state->version = JSVERSION_UNKNOWN;
top_state->scriptData = NULL;
top_state->doc_state = NULL;
#ifdef DOM
top_state->top_node = NULL;
top_state->current_node = NULL;
top_state->style_db = NULL;
#endif
if (url == NULL)
{
@ -774,7 +779,11 @@ lo_InitDocState(lo_DocState *state, MWContext *context,
str[0] = ' ';
tmp_text.text = (PA_Block)str;
tmp_text.text_len = 1;
#ifdef DOM
tmp_text.text_attr = lo_GetCurrentTextAttr(state, context);
#else
tmp_text.text_attr = state->font_stack->text_attr;
#endif
FE_GetTextInfo(context, &tmp_text, &(state->text_info));
state->default_line_height = state->text_info.ascent +
@ -4919,7 +4928,7 @@ XP_TRACE(("Initializing new doc %d\n", doc_id));
XP_ASSERT(ELEMENT_PRIV(last_node)->ele_start);
#endif
ELEMENT_PRIV(last_node)->ele_end = eptr;
#ifdef DEBUG_shaver
#ifdef DEBUG_shaver_old
DumpNodeElements(last_node);
#endif
}

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

@ -34,6 +34,9 @@
#include "stystack.h"
#include "libmocha.h"
#ifdef DOM
#include "domstyle.h"
#endif
#define MEMORY_ARENAS 1
@ -855,6 +858,7 @@ struct lo_TopState_struct {
#ifdef DOM
void /*DOM_Node*/ *top_node; /* top of the DOM_Node tree */
void /*DOM_Node*/ *current_node; /* active node (only during tree gen) */
void /*DOM_StyleDatabase */ *style_db;
#endif
void* LAPIprobe;
};
@ -936,12 +940,55 @@ extern int32 lo_baseline_adjust(MWContext *context, lo_DocState *state, LO_Eleme
int32 old_baseline, int32 old_line_height);
extern void lo_UpdateElementPosition ( lo_DocState * state, LO_Element * element );
extern void lo_CopyTextAttr(LO_TextAttr *, LO_TextAttr *);
extern LO_TextAttr *lo_FetchTextAttr(lo_DocState *, LO_TextAttr *);
extern LO_TextAttr *lo_NewCopyTextAttr(lo_DocState *, LO_TextAttr *);
/*
* Get a TextAttr that matches the one passed in, by finding an existing one
* in the text_attr_hash collection or creating a new one.
*/
extern LO_TextAttr *
lo_FetchTextAttr(lo_DocState *, LO_TextAttr *);
/*
* Get a new (unshared) TextAttr that's a copy of the existing one.
*/
extern LO_TextAttr *
lo_NewCopyTextAttr(lo_DocState *, LO_TextAttr *);
#ifdef DOM
/*
* Get a TextAttr that has all the data from the font stack and Perignon.
*/
extern LO_TextAttr *
lo_GetCurrentTextAttr(lo_DocState *state, MWContext *context);
/*
* Return a TextAttr that has the Perignon data filled in. If isMutable
* is true, it will alter the TextAttr in place, and always return the
* same pointer. Otherwise, the return value may not be the same as
* the TextAttr passed in, since it will lo_FetchTextAttr the final TextAttr
* if mutated. (If it hasn't changed anything, it will return tptr, so that
* can be used to check.)
*/
extern LO_TextAttr *
lo_FillInTextStyleInfo(lo_DocState *state, MWContext *context,
LO_TextAttr *tptr, JSBool isMutable);
/* colour parsing function for use with DOM_GetCleanAttributeData */
extern JSBool
lo_ColorStringToData(const char *color, uint32 *data, void *closure);
extern JSBool
lo_SSUnitsToData(const char *units, uint32 *data, void *closure);
#endif /* DOM */
extern void lo_FindLineMargins(MWContext *, lo_DocState *, Bool updateFE);
extern void lo_AddMarginStack(lo_DocState *, int32, int32, int32, int32,
int32, int32, int32, intn);
extern LO_AnchorData *lo_NewAnchor(lo_DocState *, PA_Block, PA_Block);
/* should we underline anchors? */
extern Bool lo_underline_anchors(void);
extern void lo_DestroyAnchor(LO_AnchorData *anchor_data);
extern void lo_AddToUrlList(MWContext *, lo_DocState *, LO_AnchorData *);
extern void lo_AddEmbedData(MWContext *, void *, lo_FreeProc, int32);
@ -973,7 +1020,10 @@ lo_InitDocState(lo_DocState *state, MWContext *context,
extern lo_SavedFormListData *lo_NewDocumentFormListData(void);
extern Bool lo_StoreTopState(int32, lo_TopState *);
/* get the TopState for a given doc_id (MWContext.doc_id) */
extern lo_TopState *lo_FetchTopState(int32);
extern lo_DocState *lo_TopSubState(lo_TopState *);
extern lo_DocState *lo_CurrentSubState(lo_DocState *);
@ -1017,6 +1067,8 @@ extern char *lo_MemoryArenaAllocate(lo_TopState *, int32);
#endif /* MEMORY_ARENAS */
extern void lo_fillin_text_info(MWContext *context, lo_DocState *state);
/* are we allowed to use page-provided font faces? */
extern Bool lo_face_attribute(void);
extern char *lo_FetchFontFace(MWContext *, lo_DocState *, char *);
extern PA_Block lo_FetchParamValue(MWContext *, PA_Tag *, char *);
extern PA_Block lo_ValueToAlpha(int32, Bool, intn *);
@ -1177,10 +1229,16 @@ extern Bool lo_EvalTrueOrFalse(char *str, Bool default_val);
extern intn lo_EvalAlignParam(char *str, Bool *floating);
extern intn lo_EvalVAlignParam(char *str);
extern void lo_EvalStyleSheetAlignment(StyleStruct *, intn *, Bool *floating);
#ifdef DOM
void lo_SetStyleSheetLayerProperties(MWContext *context, lo_DocState *state,
DOM_StyleDatabase *db, DOM_Node *node,
PA_Tag *tag);
#else
void lo_SetStyleSheetLayerProperties(MWContext *context,
lo_DocState *state,
StyleStruct *style_struct,
PA_Tag *tag);
#endif
char * lo_ParseStyleSheetURL(char *url_string);
extern intn lo_EvalCellAlignParam(char *str);
extern intn lo_EvalDivisionAlignParam(char *str);

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

@ -688,7 +688,7 @@ static void lo_rl_FitLayoutElements( lo_RelayoutState *relay_state, LO_Element *
LO_Element *lo_ele = start_ele;
/* While not end of layout element list */
while ( lo_ele != NULL) {
while (lo_ele != NULL) {
lo_rl_PreLayoutElement ( relay_state->context, relay_state->doc_state, lo_ele );
if (relay_state->doc_state->top_state->out_of_memory)
{

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

@ -368,7 +368,11 @@ static void lo_LayoutBlockSpacer(MWContext *context, lo_DocState *state, LO_Spac
PA_UNLOCK(buff);
tmp_text.text = buff;
tmp_text.text_len = 1;
#ifdef DOM
tmp_text.text_attr = lo_GetCurrentTextAttr(state, context);
#else
tmp_text.text_attr = state->font_stack->text_attr;
#endif
FE_GetTextInfo(context, &tmp_text, &text_info);
PA_FREE(buff);
@ -653,7 +657,11 @@ lo_format_block_spacer(MWContext *context, lo_DocState *state, PA_Tag *tag, Bool
PA_UNLOCK(buff);
tmp_text.text = buff;
tmp_text.text_len = 1;
#ifdef DOM
tmp_text.text_attr = lo_GetCurrentTextAttr(state, context);
#else
tmp_text.text_attr = state->font_stack->text_attr;
#endif
FE_GetTextInfo(context, &tmp_text, &text_info);
PA_FREE(buff);

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

@ -32,6 +32,9 @@
#include "prefapi.h"
#include "css.h"
#include "intl_csi.h"
#ifdef DOM
#include "domstyle.h"
#endif
void
LO_SetStyleObjectRefs(MWContext *context, void *tags, void *classes, void *ids)
@ -76,8 +79,13 @@ lo_get_font_height(MWContext *context, lo_DocState *state)
int32 font_height = state->text_info.ascent +
state->text_info.descent;
if ((font_height <= 0)&&(state->font_stack != NULL)&&
(state->font_stack->text_attr != NULL))
if ((font_height <= 0)
#ifndef DOM
&&(state->font_stack != NULL)&&
(state->font_stack->text_attr != NULL)
#endif
)
{
lo_fillin_text_info(context, state);
@ -291,6 +299,37 @@ LO_AdjustSSUnits(SS_Number *number, char *style_type, MWContext *context, lo_Doc
return; /* conversion complete */
}
#ifdef DOM
XP_Bool
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_AttributeEntry *entry;
if (!db || !cx || !node ||
!DOM_StyleGetProperty(cx, db, node, DISPLAY_STYLE, &entry)) {
#ifdef DEBUG_shaver
fprintf(stderr, "not suppressing display\n");
#endif
return FALSE;
}
if (entry && !XP_STRCMP(entry->value, NONE_STYLE)) {
#ifdef DEBUG_shaver
fprintf(stderr, "suppressing display\n");
#endif
return TRUE;
}
#ifdef DEBUG_shaver
fprintf(stderr, "not suppressing display\n");
#endif
return FALSE;
}
#else
/* returns TRUE if the display: none property
* is set
*/
@ -322,6 +361,7 @@ LO_CheckForContentHiding(lo_DocState *state)
return hide_content;
}
#endif /* DOM */
#define SS_ENABLED_PREF "browser.enable_style_sheets"
Bool lo_style_sheets_enabled = TRUE;

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

@ -159,9 +159,13 @@ LO_PopAllTagsAbove(MWContext *context,
extern XP_Bool
LO_ImplicitPop(MWContext *context, lo_DocState **state, PA_Tag *tag);
#ifdef DOM
extern XP_Bool
LO_CheckForContentHiding(lo_DocState *state, MWContext *context);
#else
extern XP_Bool
LO_CheckForContentHiding(lo_DocState *state);
#endif
extern void
LO_AdjustSSUnits(SS_Number *number, char *style_type, MWContext *context, lo_DocState *state);

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

@ -145,7 +145,8 @@ void LO_SetTableCellAttributes(MWContext *context, void *cell_v,
const char *name, const char *value)
{
lo_TableCell *cell = (lo_TableCell *)cell_v;
LO_Element *start = cell->cell->cell_list, *end = cell->cell->cell_list_end;
LO_Element *start = cell->cell->cell_list;
/* LO_Element *end = cell->cell->cell_list_end; */
lo_DocState *state;
lo_TopState *top = lo_FetchTopState(context->doc_id);
if (!top)
@ -469,6 +470,9 @@ lo_BeginCaptionSubDoc(MWContext *context, lo_DocState *state,
subdoc->anchor_href = state->current_anchor;
#ifdef DOM
subdoc->text_attr = lo_GetCurrentTextAttr(state, context);
#else
if (state->font_stack == NULL)
{
subdoc->text_attr = NULL;
@ -477,6 +481,7 @@ lo_BeginCaptionSubDoc(MWContext *context, lo_DocState *state,
{
subdoc->text_attr = state->font_stack->text_attr;
}
#endif
subdoc->FE_Data = NULL;
subdoc->backdrop.bg_color = NULL;
@ -1039,6 +1044,9 @@ lo_BeginCellSubDoc(MWContext *context,
subdoc->anchor_href = state->current_anchor;
#ifdef DOM
subdoc->text_attr = lo_GetCurrentTextAttr(state, context);
#else
if (state->font_stack == NULL)
{
subdoc->text_attr = NULL;
@ -1047,6 +1055,7 @@ lo_BeginCellSubDoc(MWContext *context,
{
subdoc->text_attr = state->font_stack->text_attr;
}
#endif
subdoc->FE_Data = NULL;
@ -1613,7 +1622,11 @@ lo_BeginCellSubDoc(MWContext *context,
LO_TextAttr *attr;
LO_TextAttr tmp_attr;
#ifdef DOM
old_attr = lo_GetCurrentTextAttr(new_state, context);
#else
old_attr = new_state->font_stack->text_attr;
#endif
lo_CopyTextAttr(old_attr, &tmp_attr);
tmp_attr.fontmask |= LO_FONT_BOLD;
attr = lo_FetchTextAttr(new_state, &tmp_attr);
@ -2132,7 +2145,11 @@ lo_EndCellSubDoc(MWContext *context, lo_DocState *state, lo_DocState *old_state,
tmp_text.text = buff;
tmp_text.text_len = 1;
tmp_text.text_attr =
state->font_stack->text_attr;
#ifdef DOM
lo_GetCurrentTextAttr(state, context);
#else
state->font_stack->text_attr;
#endif
FE_GetTextInfo(context, &tmp_text, &text_info);
PA_FREE(buff);
@ -2939,7 +2956,11 @@ lo_RelayoutCaptionSubdoc(MWContext *context, lo_DocState *state, lo_TableCaption
LO_TextAttr *attr;
LO_TextAttr tmp_attr;
#ifdef DOM
old_attr = lo_GetCurrentTextAttr(new_state, context);
#else
old_attr = new_state->font_stack->text_attr;
#endif
lo_CopyTextAttr(old_attr, &tmp_attr);
tmp_attr.fontmask |= LO_FONT_BOLD;
attr = lo_FetchTextAttr(new_state, &tmp_attr);
@ -3362,7 +3383,11 @@ lo_RelayoutCell(MWContext *context, lo_DocState *state,
LO_TextAttr *attr;
LO_TextAttr tmp_attr;
#ifdef DOM
old_attr = lo_GetCurrentTextAttr(new_state, context);
#else
old_attr = new_state->font_stack->text_attr;
#endif
lo_CopyTextAttr(old_attr, &tmp_attr);
tmp_attr.fontmask |= LO_FONT_BOLD;
attr = lo_FetchTextAttr(new_state, &tmp_attr);

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

@ -36,6 +36,9 @@
/* style sheet tag stack and style struct */
#include "stystack.h"
#include "stystruc.h"
#ifdef DOM
#include "domstyle.h"
#endif
#include "pics.h"
#include "libmocha.h"
@ -88,7 +91,7 @@
#define HYPE_TAG_BECOMES "SRC=internal-gopher-sound BORDER=0>"
/* Added to encapsulate code that was previously in six different places in LO_LayoutTag()! */
static void lo_ProcessFontTag( lo_DocState *state, PA_Tag *tag, int32 fontSpecifier, int32 attrSpecifier );
static void lo_ProcessFontTag( lo_DocState *state, MWContext *context, PA_Tag *tag, int32 fontSpecifier, int32 attrSpecifier );
static void lo_AddParam(PA_Tag* tag, char* aName, char* aValue);
@ -1337,7 +1340,11 @@ lo_process_header_tag(MWContext *context, lo_DocState *state, PA_Tag *tag, int t
lo_SetLineBreakState ( context, state, FALSE, LO_LINEFEED_BREAK_HARD, 2, FALSE);
lo_OpenHeader(context, state, tag);
#ifdef DOM
old_attr = lo_GetCurrentTextAttr(state, context);
#else
old_attr = state->font_stack->text_attr;
#endif
lo_CopyTextAttr(old_attr, &tmp_attr);
tmp_attr.fontmask |= LO_FONT_BOLD;
tmp_attr.fontmask &= (~(LO_FONT_FIXED|LO_FONT_ITALIC));
@ -1452,7 +1459,6 @@ lo_underline_pref_callback(const char *pref_name, void *closure)
return PREF_NOERROR;
}
PRIVATE
Bool
lo_underline_anchors()
{
@ -1494,28 +1500,44 @@ lo_make_link_color_different_than_default(lo_DocState *state, LO_TextAttr *tmp_a
static void
lo_process_anchor_tag(MWContext *context, lo_DocState *state, PA_Tag *tag)
{
LO_TextAttr tmp_attr;
lo_DocLists *doc_lists;
#ifdef DOM
DOM_Node *node = state->top_state->current_node;
DOM_Element *element = (DOM_Element *)node;
JSContext *cx = context->mocha_context;
#else
LO_TextAttr tmp_attr;
#endif
doc_lists = lo_GetCurrentDocLists(state);
#ifdef DOM
XP_ASSERT(node->type == NODE_TYPE_ELEMENT);
#endif
/*
* Opening a new anchor
*/
if (tag->is_end == FALSE)
{
#ifndef DOM
LO_TextAttr *old_attr;
LO_TextAttr *attr;
#endif
char *url;
char *full_url;
PA_Block buff;
Bool is_new;
PA_Block anchor;
/*
* Get the NAME param for the name list
*/
#ifdef DOM
buff = (PA_Block) node->name;
#else
buff = lo_FetchParamValue(context, tag, PARAM_NAME);
#endif
if (buff != NULL)
{
char *name;
@ -1591,7 +1613,7 @@ lo_process_anchor_tag(MWContext *context, lo_DocState *state, PA_Tag *tag)
if (GH_CheckGlobalHistory(url) != -1)
{
is_new = FALSE;
is_new = FALSE;
}
}
else
@ -1602,6 +1624,14 @@ lo_process_anchor_tag(MWContext *context, lo_DocState *state, PA_Tag *tag)
state->top_state->out_of_memory = TRUE;
}
#ifdef DOM
/*
* A HREF is A:link if unvisited, A:visited otherwise.
*/
if (!DOM_SetElementPseudo(cx, element,
is_new ? "link" : "visited"))
return;
#endif
XP_FREE(url);
}
PA_UNLOCK(anchor);
@ -1652,6 +1682,7 @@ lo_process_anchor_tag(MWContext *context, lo_DocState *state, PA_Tag *tag)
else
{
state->top_state->out_of_memory = TRUE;
return;
}
}
@ -1703,12 +1734,19 @@ lo_process_anchor_tag(MWContext *context, lo_DocState *state, PA_Tag *tag)
doc_lists->url_list_len - 1);
}
/*
* With Perignon, none of this is necessary, because we put default
* rules in place for A:visited and A:link that set the colour
* correctly and install a border for images.
* A:visited IMG { borderColor:prefsColour, borderWidth:1, etc. }, etc.
*/
#ifndef DOM
/*
* Change the anchor attribute only for
* anchors with hrefs.
*/
if (state->current_anchor != NULL)
{
if (state->current_anchor != NULL) {
StyleStruct *style_struct = NULL;
char *property=NULL;
@ -1766,7 +1804,9 @@ lo_process_anchor_tag(MWContext *context, lo_DocState *state, PA_Tag *tag)
attr = lo_FetchTextAttr(state, &tmp_attr);
lo_PushFont(state, tag->type, attr);
}
#endif /* !DOM */
}
/*
* Closing an anchor. Anchors can't be nested, so close
* ALL anchors.
@ -2906,8 +2946,12 @@ lo_CalcCurrentLineHeight(MWContext *context, lo_DocState *state)
int32 new_height = state->text_info.ascent +
state->text_info.descent;
if ((new_height <= 0)&&(state->font_stack != NULL)&&
(state->font_stack->text_attr != NULL))
if ((new_height <= 0)
#ifndef DOM
&&(state->font_stack != NULL)&&
(state->font_stack->text_attr != NULL)
#endif
)
{
lo_fillin_text_info(context, state);
@ -3156,7 +3200,7 @@ lo_SetStyleSheetFontProperties(MWContext *context,
if(state->font_stack)
{
lo_CopyTextAttr(state->font_stack->text_attr, &tmp_attr);
lo_CopyTextAttr(state->font_stack->text_attr, &tmp_attr);
}
else
{
@ -3459,7 +3503,7 @@ lo_SetStyleSheetBoxProperties(MWContext *context,
if(!style_struct)
return;
/* if we get in here and the tag->type is UKNOWN then this must
/* if we get in here and the tag->type is UNKNOWN then this must
* be a dummy tag inserted for the sake of table relayout passes
* Mark it as such
*/
@ -3792,7 +3836,10 @@ lo_SetStyleSheetBoxProperties(MWContext *context,
{
/* begin a table */
lo_DocState *prev_state;
LO_TextAttr tmp_attr, *attr;
#ifndef DOM
LO_TextAttr tmp_attr;
#endif
LO_TextAttr *attr;
SS_Number *top_padding, *bottom_padding;
@ -3978,8 +4025,13 @@ lo_SetStyleSheetBoxProperties(MWContext *context,
* rules -- as far as I know we don't need to inherit any other props now
*/
#ifdef DOM
attr = lo_NewCopyTextAttr(state,
lo_GetCurrentTextAttr(prev_state, context));
#else
lo_CopyTextAttr(prev_state->font_stack->text_attr, &tmp_attr);
attr = lo_FetchTextAttr(state, &tmp_attr);
#endif
attr->no_background = TRUE; /* don't inherit text background colors */
/* don't use the tag type since the A tag is treated special
@ -4086,12 +4138,41 @@ lo_SetStyleSheetRandomProperties(MWContext *context,
}
}
#ifdef DOM
void
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;
if (!db) {
if (!cx)
return;
db = DOM_StyleDatabaseFromContext(cx);
if (!db)
return;
}
#ifdef DEBUG_shaver
fprintf(stderr, "setting style data for <%s>\n", PA_TagString(tag->type));
#endif
/* do box properties */
/* do layer properties (position:absolute, etc.) */
lo_SetStyleSheetLayerProperties(context, state, db, node, tag);
return;
}
#else
PRIVATE
void
lo_SetStyleSheetProperties(MWContext *context,
StyleStruct *style_struct,
PA_Tag *tag)
StyleStruct *style_struct,
PA_Tag *tag)
{
int32 doc_id;
lo_TopState *top_state;
@ -4130,7 +4211,11 @@ lo_SetStyleSheetProperties(MWContext *context,
* if set then we are ignoring tags and text for the duration
* of this tag span
*/
if(LO_CheckForContentHiding(state))
if(LO_CheckForContentHiding(state
#ifdef DOM
, context
#endif
))
{
state->hide_content = TRUE;
STYLESTRUCT_SetString(style_struct,
@ -4167,6 +4252,8 @@ lo_SetStyleSheetProperties(MWContext *context,
}
#endif
/* return TRUE if the tag type is an empty tag. (not a container tag)
*/
Bool
@ -4205,7 +4292,7 @@ lo_IsEmptyTag(TagType type)
}
static void lo_ProcessFontTag( lo_DocState *state, PA_Tag *tag, int32 fontSpecifier, int32 attrSpecifier )
static void lo_ProcessFontTag( lo_DocState *state, MWContext *context, PA_Tag *tag, int32 fontSpecifier, int32 attrSpecifier )
{
LO_TextAttr tmp_attr;
@ -4214,7 +4301,11 @@ static void lo_ProcessFontTag( lo_DocState *state, PA_Tag *tag, int32 fontSpecif
LO_TextAttr *old_attr;
LO_TextAttr *attr;
#ifdef DOM
old_attr = lo_GetCurrentTextAttr(state, context);
#else
old_attr = state->font_stack->text_attr;
#endif
lo_CopyTextAttr(old_attr, &tmp_attr);
tmp_attr.fontmask |= fontSpecifier;
tmp_attr.attrmask |= attrSpecifier;
@ -4363,7 +4454,11 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type));
if(!tag->is_end && lo_IsEmptyTag(tag->type))
{
lo_SetStyleSheetProperties(context, style_struct, tag);
#ifdef DOM
lo_SetStyleSheetProperties(context, state, tag);
#else
lo_SetStyleSheetProperties(context, style_struct, tag);
#endif
}
switch(tag->type)
@ -4399,7 +4494,7 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type));
case P_CODE:
case P_SAMPLE:
case P_KEYBOARD:
lo_ProcessFontTag( state, tag, LO_FONT_FIXED, 0);
lo_ProcessFontTag( state, context, tag, LO_FONT_FIXED, 0);
break;
#ifdef EDITOR
@ -4413,7 +4508,11 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type));
state->preformatted = PRE_TEXT_YES;
FE_BeginPreSection(context);
#ifdef DOM
old_attr = lo_GetCurrentTextAttr(state, context);
#else
old_attr = state->font_stack->text_attr;
#endif
lo_CopyTextAttr(old_attr, &tmp_attr);
tmp_attr.fontmask |= LO_FONT_FIXED;
if( tag->type == P_SCRIPT ){
@ -4450,7 +4549,7 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type));
*/
case P_BOLD:
case P_STRONG:
lo_ProcessFontTag( state, tag, LO_FONT_BOLD, 0);
lo_ProcessFontTag( state, context, tag, LO_FONT_BOLD, 0);
break;
/*
@ -4461,7 +4560,7 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type));
case P_EMPHASIZED:
case P_VARIABLE:
case P_CITATION:
lo_ProcessFontTag( state, tag, LO_FONT_ITALIC, 0);
lo_ProcessFontTag( state, context, tag, LO_FONT_ITALIC, 0);
break;
/*
@ -4869,7 +4968,11 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type));
LO_TextAttr *old_attr;
LO_TextAttr *attr;
#ifdef DOM
old_attr = lo_GetCurrentTextAttr(state, context);
#else
old_attr = state->font_stack->text_attr;
#endif
lo_CopyTextAttr(old_attr, &tmp_attr);
tmp_attr.attrmask |= LO_ATTR_BLINK;
attr = lo_FetchTextAttr(state, &tmp_attr);
@ -4891,33 +4994,34 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type));
*/
case P_STRIKEOUT:
case P_STRIKE:
lo_ProcessFontTag( state, tag, 0, LO_ATTR_STRIKEOUT);
lo_ProcessFontTag( state, context, tag, 0, LO_ATTR_STRIKEOUT);
break;
case P_SPELL:
lo_ProcessFontTag( state, tag, 0, LO_ATTR_SPELL);
lo_ProcessFontTag( state, context, tag, 0, LO_ATTR_SPELL);
break;
case P_INLINEINPUT:
lo_ProcessFontTag( state, tag, 0, LO_ATTR_INLINEINPUT);
lo_ProcessFontTag( state, context, tag, 0, LO_ATTR_INLINEINPUT);
break;
case P_INLINEINPUTTHICK:
lo_ProcessFontTag( state, tag, 0, LO_ATTR_INLINEINPUTTHICK);
lo_ProcessFontTag( state, context, tag, 0,
LO_ATTR_INLINEINPUTTHICK);
break;
case P_INLINEINPUTDOTTED:
lo_ProcessFontTag( state, tag, 0, LO_ATTR_INLINEINPUTDOTTED);
lo_ProcessFontTag( state, context, tag, 0, LO_ATTR_INLINEINPUTDOTTED);
break;
/*
* Another font attribute, another font on the font stack
*/
case P_UNDERLINE:
lo_ProcessFontTag( state, tag, 0, LO_ATTR_UNDERLINE);
lo_ProcessFontTag( state, context, tag, 0, LO_ATTR_UNDERLINE);
break;
/*
@ -5028,7 +5132,11 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type));
}
}
#ifdef DOM
old_attr = lo_GetCurrentTextAttr(state, context);
#else
old_attr = state->font_stack->text_attr;
#endif
lo_CopyTextAttr(old_attr, &tmp_attr);
/*
@ -5094,7 +5202,11 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type));
state->preformatted = PRE_TEXT_YES;
FE_BeginPreSection(context);
#ifdef DOM
old_attr = lo_GetCurrentTextAttr(state, context);
#else
old_attr = state->font_stack->text_attr;
#endif
lo_CopyTextAttr(old_attr, &tmp_attr);
tmp_attr.fontmask |= LO_FONT_FIXED;
tmp_attr.size = DEFAULT_BASE_FONT_SIZE - 1;
@ -5129,7 +5241,11 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type));
lo_SetSoftLineBreakState(context, state, FALSE, 1);
#ifdef DOM
old_attr = lo_GetCurrentTextAttr(state, context);
#else
old_attr = state->font_stack->text_attr;
#endif
lo_CopyTextAttr(old_attr, &tmp_attr);
tmp_attr.fontmask |= LO_FONT_ITALIC;
attr = lo_FetchTextAttr(state, &tmp_attr);
@ -5164,7 +5280,11 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type));
LO_TextAttr *attr;
intn new_size;
#ifdef DOM
old_attr = lo_GetCurrentTextAttr(state, context);
#else
old_attr = state->font_stack->text_attr;
#endif
lo_CopyTextAttr(old_attr, &tmp_attr);
new_size = LO_ChangeFontSize(tmp_attr.size,
"-1");
@ -5194,7 +5314,11 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type));
tmp_text.text = buff;
tmp_text.text_len = 1;
tmp_text.text_attr =
state->font_stack->text_attr;
#ifdef DOM
lo_GetCurrentTextAttr(state, context);
#else
state->font_stack->text_attr;
#endif
FE_GetTextInfo(context, &tmp_text, &text_info);
PA_FREE(buff);
@ -5221,7 +5345,7 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type));
if (tag->is_end == TRUE)
{
LO_TextAttr *attr = lo_PopFont(state, tag->type);
lo_PopFont(state, tag->type);
}
}
@ -5246,7 +5370,11 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type));
LO_TextAttr *attr;
intn new_size;
#ifdef DOM
old_attr = lo_GetCurrentTextAttr(state, context);
#else
old_attr = state->font_stack->text_attr;
#endif
lo_CopyTextAttr(old_attr, &tmp_attr);
new_size = LO_ChangeFontSize(tmp_attr.size,
"-1");
@ -5276,7 +5404,11 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type));
tmp_text.text = buff;
tmp_text.text_len = 1;
tmp_text.text_attr =
state->font_stack->text_attr;
#ifdef DOM
lo_GetCurrentTextAttr(state, context);
#else
state->font_stack->text_attr;
#endif
FE_GetTextInfo(context, &tmp_text, &text_info);
PA_FREE(buff);
@ -5302,7 +5434,7 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type));
if (tag->is_end == TRUE)
{
LO_TextAttr *attr = lo_PopFont(state, tag->type);
lo_PopFont(state, tag->type);
}
}
break;
@ -5484,7 +5616,11 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type));
}
}
#ifdef DOM
old_attr = lo_GetCurrentTextAttr(state, context);
#else
old_attr = state->font_stack->text_attr;
#endif
lo_CopyTextAttr(old_attr, &tmp_attr);
if (has_size != FALSE)
@ -5532,7 +5668,11 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type));
LO_TextAttr *attr;
intn new_size;
#ifdef DOM
old_attr = lo_GetCurrentTextAttr(state, context);
#else
old_attr = state->font_stack->text_attr;
#endif
lo_CopyTextAttr(old_attr, &tmp_attr);
new_size = LO_ChangeFontSize(tmp_attr.size, "+1");
tmp_attr.size = new_size;
@ -5558,7 +5698,11 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type));
LO_TextAttr *attr;
intn new_size;
#ifdef DOM
old_attr = lo_GetCurrentTextAttr(state, context);
#else
old_attr = state->font_stack->text_attr;
#endif
lo_CopyTextAttr(old_attr, &tmp_attr);
new_size = LO_ChangeFontSize(tmp_attr.size, "-1");
tmp_attr.size = new_size;
@ -5576,8 +5720,7 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type));
/*
* Change the absolute URL that describes where this
* docuemtn came from for all following
* relative URLs.
* document came from for all following relative URLs.
*/
case P_BASE:
{
@ -5722,7 +5865,7 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type));
/*
* Break the current line.
* Optionally break furthur down to get past floating
* Optionally break further down to get past floating
* elements in the margins.
*/
case P_LINEBREAK:
@ -6034,8 +6177,8 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type));
/*
* The hype tag is just for fun.
* It only effects the UNIX version
* which can affor to have a sound file
* It only affects the UNIX version
* which can afford to have a sound file
* compiled into the binary.
*/
case P_HYPE:
@ -6079,8 +6222,7 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type));
* of all allocated urls so we can free
* it later.
*/
lo_AddToUrlList(context, state,
hype_anchor);
lo_AddToUrlList(context, state, hype_anchor);
if (state->top_state->out_of_memory !=FALSE)
{
PA_FREE(abuff);
@ -7393,7 +7535,11 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type));
{
if(!lo_IsEmptyTag(tag->type))
{
#ifdef DOM
lo_SetStyleSheetProperties(context, state, tag);
#else
lo_SetStyleSheetProperties(context, style_struct, tag);
#endif
}
else
{

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

@ -26,6 +26,11 @@
#include "laystyle.h"
#include "laytrav.h"
#ifdef DOM
#include "domstyle.h"
#include "lm_dom.h"
#endif
/*
* Turn this define on to get the new multibyte parsing code
#define FAST_MULTI
@ -102,6 +107,7 @@ static void lo_SetupBreakState (LO_TextBlock * block );
Bool lo_GrowTextBlock (LO_TextBlock * block,
uint32 length );
typedef enum {
kSimpleSBTextParseAttribute = 0,
kMBTextParseAttribute,
@ -215,7 +221,12 @@ LO_TextBlock * lo_NewTextBlock ( MWContext * context,
if ( state->font_stack != NULL )
{
/* TEXTATTR HERE */
#ifdef DOM
block->text_attr = lo_GetCurrentTextAttr(state, context);
#else
block->text_attr = state->font_stack->text_attr;
#endif
}
if (state->breakable != FALSE)
@ -547,7 +558,12 @@ lo_fillin_text_info(MWContext *context, lo_DocState *state)
from the state */
if ( state->cur_text_block == NULL )
{
/* TEXTATTR HERE */
#ifdef DOM
tmp_text.text_attr = lo_GetCurrentTextAttr(state, context);
#else
tmp_text.text_attr = state->font_stack->text_attr;
#endif
}
else
{
@ -1022,13 +1038,18 @@ lo_InsertWordBreak(MWContext *context, lo_DocState *state)
text_ele->text_len = 0;
text_ele->anchor_href = state->current_anchor;
/* TEXTATTR HERE */
if (state->font_stack == NULL)
{
text_ele->text_attr = NULL;
}
else
{
text_ele->text_attr = state->font_stack->text_attr;
#ifdef DOM
text_ele->text_attr = lo_GetCurrentTextAttr(state, context);
#else
text_ele->text_attr = state->font_stack->text_attr;
#endif
}
text_ele->ele_attrmask = 0;
@ -3510,9 +3531,9 @@ lo_SetBodyTextFGColor(MWContext *context, lo_DocState *state, LO_Color *color)
LO_TextAttr tmp_attr;
if (fptr)
lo_CopyTextAttr(fptr->text_attr, &tmp_attr);
lo_CopyTextAttr(fptr->text_attr, &tmp_attr);
else
lo_SetDefaultFontAttr(state, &tmp_attr, context);
lo_SetDefaultFontAttr(state, &tmp_attr, context);
tmp_attr.fg.red = STATE_DEFAULT_FG_RED(state);
tmp_attr.fg.green = STATE_DEFAULT_FG_GREEN(state);
@ -3776,6 +3797,7 @@ lo_FormatBullet(MWContext *context, lo_DocState *state,
return;
}
/* TEXTATTR HERE */
tptr = bullet->text_attr;
memset (&tmp_text, 0, sizeof (tmp_text));
@ -3874,7 +3896,9 @@ lo_PlaceBullet(MWContext *context, lo_DocState *state)
{
LO_BulletStruct *bullet = NULL;
int32 line_height, baseline;
#ifndef DOM
LO_TextAttr tmp_attr;
#endif
LO_TextStruct tmp_text;
LO_TextInfo text_info;
LO_TextAttr *tptr;
@ -3926,6 +3950,10 @@ lo_PlaceBullet(MWContext *context, lo_DocState *state)
bullet->sel_start = -1;
bullet->sel_end = -1;
/* TEXTATTR HERE */
#ifdef DOM
tptr = lo_GetCurrentTextAttr(state, context);
#else
if(state->font_stack)
{
lo_CopyTextAttr(state->font_stack->text_attr, &tmp_attr);
@ -3935,6 +3963,7 @@ lo_PlaceBullet(MWContext *context, lo_DocState *state)
lo_SetDefaultFontAttr(state, &tmp_attr, context);
}
tptr = lo_FetchTextAttr(state, &tmp_attr);
#endif
memset (&tmp_text, 0, sizeof (tmp_text));
buff = PA_ALLOC(1);
@ -4132,7 +4161,12 @@ lo_PlaceBulletStr(MWContext *context, lo_DocState *state)
bullet_text->bullet_type = bullet_type;
bullet_text->text = buff;
bullet_text->text_len = len;
/* TEXTATTR HERE */
#ifdef DOM
bullet_text->text_attr = lo_GetCurrentTextAttr(state, context);
#else
bullet_text->text_attr = state->font_stack->text_attr;
#endif
FE_GetTextInfo(context, bullet_text, &text_info);
bullet_text->width = lo_correct_text_element_width(&text_info);
bullet_text->height = text_info.ascent + text_info.descent;
@ -4206,6 +4240,7 @@ lo_make_quote_text(MWContext *context, lo_DocState *state, int32 margin)
/*
* Fill in default fixed font information.
*/
/* TEXTATTR HERE -- why does this not use the font stack? */
lo_SetDefaultFontAttr(state, &tmp_attr, context);
tmp_attr.fontmask |= LO_FONT_FIXED;
quote_text->text_attr = lo_FetchTextAttr(state, &tmp_attr);
@ -4271,11 +4306,16 @@ lo_make_quote_bullet(MWContext *context, lo_DocState *state, int32 margin)
return(NULL);
}
/* TEXTATTR HERE -- why does this not use font/style info? */
lo_SetDefaultFontAttr(state, &tmp_attr, context);
tmp_attr.fg.red = 0;
tmp_attr.fg.green = 0;
tmp_attr.fg.blue = 255;
#ifdef DOM
tptr = lo_FillInTextStyleInfo(state, context, &tmp_attr, JS_TRUE);
#else
tptr = lo_FetchTextAttr(state, &tmp_attr);
#endif
memset (&tmp_text, 0, sizeof (tmp_text));
buff = PA_ALLOC(1);
@ -4431,8 +4471,12 @@ void lo_UpdateStateAfterLineBreak( MWContext *context,
{
state->line_height = state->text_info.ascent +
state->text_info.descent;
if ((state->line_height <= 0)&&(state->font_stack != NULL)&&
(state->font_stack->text_attr != NULL))
if ((state->line_height <= 0)
#ifndef DOM
&&(state->font_stack != NULL)&&
(state->font_stack->text_attr != NULL)
#endif
)
{
lo_fillin_text_info(context, state);
state->line_height = state->text_info.ascent +
@ -4585,8 +4629,12 @@ void lo_FillInLineFeed( MWContext *context,
{
linefeed->height = state->text_info.ascent +
state->text_info.descent;
if ((linefeed->height <= 0)&&(state->font_stack != NULL)&&
(state->font_stack->text_attr != NULL))
if ((linefeed->height <= 0)
#ifndef DOM
&&(state->font_stack != NULL)&&
(state->font_stack->text_attr != NULL)
#endif
)
{
lo_fillin_text_info(context, state);
linefeed->height = state->text_info.ascent +
@ -4606,6 +4654,9 @@ void lo_FillInLineFeed( MWContext *context,
linefeed->FE_Data = NULL;
linefeed->anchor_href = state->current_anchor;
#ifdef DOM
linefeed->text_attr = lo_GetCurrentTextAttr(state, context);
#else
if (state->font_stack == NULL)
{
LO_TextAttr tmp_attr;
@ -4620,8 +4671,10 @@ void lo_FillInLineFeed( MWContext *context,
}
else
{
/* TEXTATTR HERE */
linefeed->text_attr = state->font_stack->text_attr;
}
#endif
linefeed->baseline = state->baseline;
@ -5406,7 +5459,12 @@ lo_CurrentTextBlock ( MWContext * context, lo_DocState * state )
if ( state->font_stack != NULL )
{
textBlock->text_attr = state->font_stack->text_attr;
/* TEXTATTR HERE */
#ifdef DOM
textBlock->text_attr = lo_GetCurrentTextAttr(state, context);
#else
textBlock->text_attr = state->font_stack->text_attr;
#endif
}
if (state->breakable != FALSE)
@ -6139,7 +6197,6 @@ static void
lo_FlushText ( MWContext * context, lo_DocState * state )
{
LO_TextBlock * block;
Bool multiByte;
char * text_buf;
block = state->cur_text_block;
@ -8380,6 +8437,277 @@ lo_CopyTextToLineBuffer ( lo_DocState * state, uint8 * src, uint32 length )
PA_UNLOCK(state->line_buf);
}
#ifdef DOM
LO_TextAttr *
lo_GetCurrentTextAttr(lo_DocState *state, MWContext *context)
{
LO_TextAttr tmp_attr, *tptr, *styleptr;
JSBool isMutable;
if (!state->font_stack) {
/*
* XXX we should keep a text_attr with the default values around so that
* we can just bump the refcount instead of copying all that data and
* stuff.
*/
lo_SetDefaultFontAttr(state, &tmp_attr, context);
tptr = &tmp_attr;
isMutable = JS_TRUE;
} else {
/*
* we can just dup the pointer, because lo_FillInTextStyleInfo will
* copy-on-write for us.
*/
tptr = state->font_stack->text_attr;
tptr->refcnt++;
isMutable = JS_FALSE;
}
styleptr = lo_FillInTextStyleInfo(state, context, tptr, isMutable);
if (styleptr != tptr)
isMutable = JS_FALSE; /* already fetched, so no need to refetch */
tptr = styleptr;
if (isMutable)
/* we're working on the stack-allocated text_attr, so get a heap copy */
tptr = lo_FetchTextAttr(state, tptr);
return tptr;
}
JSBool
lo_ColorStringToData(const char *color, uint32 *data, void *closure)
{
LO_Color col;
if (!LO_ParseStyleSheetRGB((char *)color, &col.red, &col.green, &col.blue))
return JS_FALSE;
*data = *(uint32 *)&col;
return JS_TRUE;
}
#define FONT_WEIGHT_BOLDER 0x10000
#define FONT_WEIGHT_LIGHTER 0x20000
JSBool
lo_SSUnitsToData(const char *str, uint32 *data, void *closure)
{
/* XXX NYI */
*data = XP_ATOI(str);
return JS_TRUE;
}
static JSBool
FontWeightToData(const char *str, uint32 *data, void *closure)
{
uint32 weight;
/* XXX use proper CSS-value parsing stuff */
if (!strcasecomp(str, "bolder")) {
weight = FONT_WEIGHT_BOLDER;
} else if (!strcasecomp(str, "lighter")) {
weight = FONT_WEIGHT_LIGHTER;
} else {
weight = XP_ATOI(str);
weight -= weight % 100;
}
*data = weight;
return JS_TRUE;
}
#define SET_ATTR_BIT_IF(style, bit) \
if (!strcasecomp(decors, style)) \
attrs |= bit;
static JSBool
TextDecorationToData(const char *decors, uint32 *data, void *closure)
{
uint32 attrs = 0;
/* XXX handle multiple tokens */
SET_ATTR_BIT_IF(BLINK_STYLE, LO_ATTR_BLINK)
else
SET_ATTR_BIT_IF(STRIKEOUT_STYLE, LO_ATTR_STRIKEOUT)
else
SET_ATTR_BIT_IF(UNDERLINE_STYLE, LO_ATTR_UNDERLINE)
else
if (!strcasecomp(decors, "none"))
attrs = 0;
*data = attrs;
return JS_TRUE;
}
#undef SET_ATTR_BIT_IF
LO_TextAttr *
lo_FillInTextStyleInfo(lo_DocState *state, MWContext *context,
LO_TextAttr *tptr, JSBool isMutable)
{
JSContext *cx = context->mocha_context;
DOM_StyleDatabase *db = state->top_state->style_db;
DOM_AttributeEntry *entry;
DOM_Node *node = state->top_state->current_node;
LO_TextAttr text_attr, *newptr = NULL;
JSBool copied = JS_FALSE;
LO_Color col;
if (!cx || !db || !node)
return tptr;
if (node->type != NODE_TYPE_TEXT) {
if (node->type == NODE_TYPE_ELEMENT) {
DOM_HTMLElementPrivate *priv = node->data;
if (priv &&
(priv->tagtype == P_LIST_ITEM ||
priv->tagtype == P_IMAGE ||
priv->tagtype == P_HRULE /* layout NYI */)) {
#ifdef DEBUG_shaver
fprintf(stderr, "setting textattr on <%s>\n",
((DOM_Element *)node)->tagName);
#endif
} else {
#ifdef DEBUG_shaver
fprintf(stderr, "NOT setting textattr on <%s>\n",
((DOM_Element *)node)->tagName);
#endif
return tptr;
}
}
}
#define COW() \
if (!isMutable && !copied) { \
lo_CopyTextAttr(tptr, &text_attr); \
copied = JS_TRUE; \
}
if (!isMutable) {
XP_BZERO(&text_attr, sizeof(text_attr));
newptr = &text_attr;
} else {
newptr = tptr;
}
/* check "color" property */
if (!DOM_StyleGetProperty(cx, db, node, COLOR_STYLE, &entry))
/* XXX report error? return tptr unmodified? */
return NULL;
if (entry) {
if (!DOM_GetCleanEntryData(cx, entry, lo_ColorStringToData, (uint32*)&col,
NULL))
return NULL;
if (*(uint32 *)&col != *(uint32 *)&tptr->fg) {
COW();
newptr->fg = col;
}
}
/* check bgcolor property, including transparent */
if (!DOM_StyleGetProperty(cx, db, node, BG_COLOR_STYLE, &entry))
return NULL;
if (entry) {
COW();
if (!DOM_GetCleanEntryData(cx, entry, lo_ColorStringToData, (uint32*)&col,
NULL))
return NULL;
newptr->bg = col;
if (!strcasecomp(entry->value, "transparent"))
newptr->no_background = TRUE;
else
newptr->no_background = FALSE;
}
/* check font-face */
if (lo_face_attribute()) {
if (!DOM_StyleGetProperty(cx, db, node, FONTFACE_STYLE, &entry))
return NULL;
if (entry) {
COW();
/* XXXshaver use GetCleanEntryData when I figure out mem mgmt */
#if 0
if (newptr->font_face)
XP_FREE(newptr->font_face);
#endif
newptr->font_face = lo_FetchFontFace(context, state,
(char *)entry->value);
}
}
/* XXX font-size requires STYLESTRUCT_StringToSSNumber-alike */
/* check font-weight */
if (!DOM_StyleGetProperty(cx, db, node, FONTWEIGHT_STYLE, &entry))
return NULL;
if (entry) {
uint32 weight;
/*
* For "bolder" and "lighter", we need to keep them dirty because they're
* dependent on the enclosing state, so we have to recalculate each time.
* OPTIMIZATION: let FontWeightToData parse them and make the data be
* some magic value > 0xffff, to save the strcasecomps on each pass.
*/
if (!DOM_GetCleanEntryData(cx, entry, FontWeightToData, &weight, NULL))
return NULL;
if (weight) {
if (!newptr->font_weight) {
COW();
newptr->font_weight = 400;
}
if (weight == FONT_WEIGHT_BOLDER) {
weight = MAX(newptr->font_weight + 100, 100);
} else if (weight == FONT_WEIGHT_LIGHTER) {
weight = MIN(newptr->font_weight - 100, 900);
}
if (weight != (uint32)newptr->font_weight) {
COW();
newptr->font_weight = weight;
}
}
}
/* font-style */
if (!DOM_StyleGetProperty(cx, db, node, FONTSTYLE_STYLE, &entry))
return NULL;
if (entry) {
if (!strcasecomp(entry->value, NORMAL_STYLE)) {
/* { font-style:normal} */
if (newptr->fontmask & LO_FONT_ITALIC) {
COW();
newptr->fontmask &= ~LO_FONT_ITALIC;
}
} else if (!strcasecomp(entry->value, ITALIC_STYLE)) {
/* { font-style:italic} */
if (!(newptr->fontmask & LO_FONT_ITALIC)) {
COW();
newptr->fontmask |= LO_FONT_ITALIC;
}
}
/* XXX need LO_FONT_OBLIQUE */
}
/* text-decoration */
if (!DOM_StyleGetProperty(cx, db, node, TEXTDECORATION_STYLE, &entry))
return NULL;
if (entry) {
uint32 attrs;
#define ATTRMASK (LO_ATTR_BLINK | LO_ATTR_STRIKEOUT | LO_ATTR_UNDERLINE)
if (!DOM_GetCleanEntryData(cx, entry, TextDecorationToData, &attrs, NULL))
return NULL;
attrs = (tptr->attrmask & ~ATTRMASK) | (attrs & ATTRMASK);
if (attrs != tptr->attrmask) {
COW();
newptr->attrmask = attrs;
}
#undef ATTRMASK
}
#undef COW
if (!isMutable && copied)
return lo_FetchTextAttr(state, &text_attr);
return tptr;
}
#endif
#ifdef TEST_16BIT
#undef XP_WIN16
#endif /* TEST_16BIT */

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

@ -1260,9 +1260,6 @@ lo_NewCopyTextAttr(lo_DocState *state, LO_TextAttr *old_attr)
LO_TextAttr **text_attr_hash;
int32 hash_index;
#ifdef DEBUG_shaver
fprintf(stderr, "allocing new TextAttr\n");
#endif
hash_index = (old_attr->fontmask & old_attr->attrmask) % FONT_HASH_SIZE;
XP_LOCK_BLOCK(text_attr_hash, LO_TextAttr **,
@ -2604,14 +2601,23 @@ lo_SetNodeElement(lo_DocState *state, LO_Element *element)
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;
}
if (!node || node->type == NODE_TYPE_DOCUMENT)
return;
XP_ASSERT(!ELEMENT_PRIV(node)->ele_end);
#ifdef DEBUG_shaver
if (ELEMENT_PRIV(node)->ele_end) {
fprintf(stderr, "lo_SetNodeElement: node has end already!\n");
}
#endif
eptr = ELEMENT_PRIV(node)->ele_start;
if (!eptr) {
/* this the first element for this node, so mark it */
ELEMENT_PRIV(node)->ele_start = element;
}
#if 0 /* XXX waiting on proper LO_Elements for tables and cells and stuff */
if (!element->lo_any.node)
element->lo_any.node = node;
#endif
}
#endif