зеркало из https://github.com/mozilla/gecko-dev.git
remove stale DOM span/transclusion code
This commit is contained in:
Родитель
2b5dd1db41
Коммит
51896259f4
|
@ -48,7 +48,6 @@ CSRCS = bullet.c \
|
|||
layobj.c \
|
||||
layscrip.c \
|
||||
layspace.c \
|
||||
layspan.c \
|
||||
laystyle.c \
|
||||
laysub.c \
|
||||
ptinpoly.c \
|
||||
|
|
|
@ -52,7 +52,6 @@ CSRCS = bullet.c \
|
|||
layobj.c \
|
||||
layscrip.c \
|
||||
layspace.c \
|
||||
layspan.c \
|
||||
laystyle.c \
|
||||
laysub.c \
|
||||
ptinpoly.c \
|
||||
|
|
|
@ -491,14 +491,6 @@ lo_block_src_exit_fn(URL_Struct *url_struct, int status, MWContext *context)
|
|||
NET_FreeURLStruct(url_struct);
|
||||
}
|
||||
|
||||
#ifndef DOM
|
||||
static void
|
||||
lo_free_stream(MWContext *context, NET_StreamClass *stream)
|
||||
{
|
||||
XP_DELETE(stream);
|
||||
}
|
||||
#endif
|
||||
|
||||
int32
|
||||
lo_GetEnclosingLayerWidth(lo_DocState *state)
|
||||
{
|
||||
|
|
|
@ -418,83 +418,6 @@ LO_EnumerateNamedAnchors(MWContext *context, int32 layer_id)
|
|||
return count;
|
||||
}
|
||||
|
||||
#ifdef DOM
|
||||
void
|
||||
lo_ReflectSpan(MWContext *context, lo_DocState *doc_state, PA_Tag *tag,
|
||||
lo_NameList *name_rec, int32 layer_id)
|
||||
{
|
||||
lo_DocLists *doc_lists;
|
||||
|
||||
if (!doc_state->in_relayout) {
|
||||
doc_lists = lo_GetDocListsById(doc_state, layer_id);
|
||||
if (!doc_lists)
|
||||
return;
|
||||
name_rec->index = doc_lists->span_count++;
|
||||
|
||||
if(!PA_HasMocha(tag))
|
||||
return;
|
||||
|
||||
ET_ReflectObject(context, (void *) name_rec, tag,
|
||||
layer_id, name_rec->index, LM_SPANS);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
lo_NameList *
|
||||
LO_GetSpanByIndex(MWContext *context, int32 layer_id, uint index)
|
||||
{
|
||||
lo_TopState *top_state;
|
||||
lo_NameList *name_rec, *nptr;
|
||||
lo_DocLists *doc_lists;
|
||||
|
||||
top_state = lo_GetTopState(context);
|
||||
if (top_state == NULL)
|
||||
return NULL;
|
||||
|
||||
doc_lists = lo_GetDocListsById(top_state->doc_state, layer_id);
|
||||
if (!doc_lists)
|
||||
return NULL;
|
||||
|
||||
/* The list is not guaranteed to be in reverse-source order when nested
|
||||
tables are involved, so search for matching index instead. */
|
||||
name_rec = NULL;
|
||||
for (nptr = doc_lists->span_list; nptr != NULL; nptr = nptr->next) {
|
||||
if (nptr->index == index) {
|
||||
name_rec = nptr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return name_rec;
|
||||
}
|
||||
|
||||
uint
|
||||
LO_EnumerateSpans(MWContext *context, int32 layer_id)
|
||||
{
|
||||
lo_TopState *top_state;
|
||||
lo_NameList *name_rec;
|
||||
uint count;
|
||||
lo_DocLists *doc_lists;
|
||||
|
||||
top_state = lo_GetTopState(context);
|
||||
if (top_state == NULL)
|
||||
return 0;
|
||||
|
||||
doc_lists = lo_GetDocListsById(top_state->doc_state, layer_id);
|
||||
if (!doc_lists)
|
||||
return 0;
|
||||
|
||||
count = 0;
|
||||
for (name_rec = doc_lists->span_list; name_rec != NULL;
|
||||
name_rec = name_rec->next) {
|
||||
if (name_rec->mocha_object == NULL)
|
||||
LM_ReflectSpan(context, (void *) name_rec, NULL,
|
||||
layer_id, name_rec->index);
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
lo_ReflectLink(MWContext *context, lo_DocState *doc_state, PA_Tag *tag,
|
||||
LO_AnchorData *anchor_data, int32 layer_id, uint index)
|
||||
|
|
|
@ -823,11 +823,6 @@ lo_InitDocState(lo_DocState *state, MWContext *context,
|
|||
state->old_break_pos = -1;
|
||||
state->old_break_width = 0;
|
||||
|
||||
#ifdef DOM
|
||||
state->current_span = NULL;
|
||||
state->in_span = FALSE;
|
||||
#endif
|
||||
|
||||
state->current_named_anchor = NULL;
|
||||
state->current_anchor = NULL;
|
||||
|
||||
|
@ -1034,7 +1029,7 @@ lo_calc_push_right_for_justify(lo_DocState *state, int32 *remainder)
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef DOM
|
||||
#if 0
|
||||
PRIVATE void
|
||||
lo_add_to_y_for_all_elements_in_line(lo_DocState *state, int32 y_add)
|
||||
{
|
||||
|
|
|
@ -366,11 +366,6 @@ typedef struct lo_DocLists_struct {
|
|||
lo_NameList *name_list; /* list of positions of named anchors */
|
||||
uint32 anchor_count; /* Count of named anchors in this document */
|
||||
|
||||
#ifdef DOM
|
||||
lo_NameList *span_list; /* list of positions of named spans*/
|
||||
uint32 span_count; /* Count of named spans in this document */
|
||||
#endif
|
||||
|
||||
lo_FormData *form_list; /* list of forms in doc */
|
||||
intn current_form_num; /* The id of the next form to lay out */
|
||||
|
||||
|
@ -660,10 +655,6 @@ typedef struct lo_DocState_struct {
|
|||
Bool need_min_width;
|
||||
uint32 src_text_offset;
|
||||
|
||||
#ifdef DOM
|
||||
Bool in_span;
|
||||
PA_Block current_span;
|
||||
#endif
|
||||
} lo_DocState;
|
||||
|
||||
#ifdef TEST_16BIT
|
||||
|
@ -1240,7 +1231,6 @@ extern void lo_CleanFormElementData(LO_FormElementData *);
|
|||
extern Bool lo_SetNamedAnchor(lo_DocState *, PA_Block);
|
||||
|
||||
#ifdef DOM
|
||||
extern Bool lo_SetNamedSpan(lo_DocState *, PA_Block);
|
||||
extern void lo_SetColor( LO_Element *ele, LO_Color *color, lo_DocState *state,
|
||||
Bool background);
|
||||
#endif
|
||||
|
@ -1565,12 +1555,6 @@ extern void
|
|||
lo_ReflectNamedAnchor(MWContext *context, lo_DocState *state, PA_Tag *tag,
|
||||
lo_NameList *name_rec, int32 layer_id);
|
||||
|
||||
#ifdef DOM
|
||||
extern void
|
||||
lo_ReflectSpan(MWContext *context, lo_DocState *doc_state, PA_Tag *tag,
|
||||
lo_NameList *name_rec, int32 layer_id);
|
||||
#endif
|
||||
|
||||
extern void
|
||||
lo_ReflectLink(MWContext *context, lo_DocState *state, PA_Tag *tag,
|
||||
LO_AnchorData *anchor_data, int32 layer_id, uint index);
|
||||
|
@ -1686,14 +1670,6 @@ Bool
|
|||
lo_BindNamedAnchorToElement(lo_DocState *state, PA_Block name,
|
||||
LO_Element *element);
|
||||
|
||||
#ifdef DOM
|
||||
Bool
|
||||
lo_BindNamedSpanToElement(lo_DocState *state, PA_Block name,
|
||||
LO_Element *element);
|
||||
|
||||
LO_SpanStruct * lo_FindParentSpan( LO_Element *ele );
|
||||
#endif
|
||||
|
||||
/* Return the table element containing the given element (usually a LO_CELL type) */
|
||||
LO_TableStruct *lo_GetParentTable(MWContext *pContext, LO_Element *pElement);
|
||||
|
||||
|
|
|
@ -578,11 +578,6 @@ lo_rl_InitDocState( MWContext *context, lo_DocState *state, int32 width, int32 h
|
|||
state->old_break_pos = -1;
|
||||
state->old_break_width = 0;
|
||||
|
||||
#ifdef DOM
|
||||
state->current_span = NULL;
|
||||
state->in_span = FALSE;
|
||||
#endif
|
||||
|
||||
state->current_named_anchor = NULL;
|
||||
state->current_anchor = NULL;
|
||||
|
||||
|
@ -1711,28 +1706,8 @@ static LO_Element * lo_rl_FitSub( lo_RelayoutState *relay_state, LO_Element *lo_
|
|||
|
||||
static LO_Element * lo_rl_FitSpan( lo_RelayoutState *relay_state, LO_Element *lo_ele )
|
||||
{
|
||||
#ifndef DOM
|
||||
XP_ASSERT(0);
|
||||
return lo_tv_GetNextLayoutElement( relay_state->doc_state, lo_ele, TRUE);
|
||||
#else
|
||||
MWContext *context = relay_state->context;
|
||||
lo_DocState *state = relay_state->doc_state;
|
||||
LO_Element *next = lo_tv_GetNextLayoutElement( relay_state->doc_state, lo_ele, TRUE);
|
||||
|
||||
/* Skip the SPAN element */
|
||||
if (lo_ele->lo_span.is_end == FALSE)
|
||||
{
|
||||
lo_AppendToLineList(context, state, lo_ele, 0);
|
||||
state->in_span = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
state->in_span = FALSE;
|
||||
lo_AppendToLineList(context, state, lo_ele, 0);
|
||||
}
|
||||
|
||||
return next;
|
||||
#endif
|
||||
}
|
||||
|
||||
static LO_Element * lo_rl_FitDiv( lo_RelayoutState *relay_state, LO_Element *lo_ele )
|
||||
|
|
|
@ -1,414 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifdef DOM
|
||||
|
||||
#include "xp.h"
|
||||
#include "pa_parse.h"
|
||||
#include "layout.h"
|
||||
#include "laylayer.h"
|
||||
#include "laystyle.h"
|
||||
#include "libmocha.h"
|
||||
#include "stystruc.h"
|
||||
#include "stystack.h"
|
||||
#include "layers.h"
|
||||
|
||||
|
||||
/* Initial attempt at DOM by letting JS set style of SPAN contents */
|
||||
void lo_SetColor( LO_Element *ele, LO_Color *color, lo_DocState *state,
|
||||
Bool background);
|
||||
static void lo_SetFontFamily( MWContext *context, LO_Element *ele, char *family);
|
||||
static void lo_SetFontWeight( MWContext *context, LO_Element *ele, char *weight);
|
||||
static void lo_SetFontSlant( MWContext *context, LO_Element *ele, char *weight);
|
||||
static void lo_SetFontSize( MWContext *context, LO_Element *ele, int32 size);
|
||||
|
||||
/* Public functions */
|
||||
JSObject *
|
||||
LO_GetMochaObjectOfParentSpan( LO_Element *ele)
|
||||
{
|
||||
LO_SpanStruct *span;
|
||||
lo_NameList *name_rec;
|
||||
JSObject *obj = NULL;
|
||||
|
||||
if (LO_IsWithinSpan( ele ))
|
||||
{
|
||||
/* Go back in the layout element list until we find a SPAN element */
|
||||
span = lo_FindParentSpan(ele);
|
||||
if ( span != NULL )
|
||||
{
|
||||
name_rec = (lo_NameList *) span->name_rec;
|
||||
if (name_rec != NULL)
|
||||
obj = name_rec->mocha_object;
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
/* Set the color of all layout elements contained within the span */
|
||||
void LO_SetSpanColor(MWContext* context, void *span, LO_Color *color)
|
||||
{
|
||||
lo_NameList *name_rec = (lo_NameList *)span;
|
||||
LO_SpanStruct *parent_span = lo_FindParentSpan(name_rec->element);
|
||||
LO_Element *ele;
|
||||
|
||||
ele = parent_span->lo_any.next;
|
||||
while (ele != NULL && ele->lo_any.type != LO_SPAN)
|
||||
{
|
||||
#if 0
|
||||
lo_SetColor(ele, color, FALSE);
|
||||
#endif
|
||||
ele = ele->lo_any.next;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the background color of all layout elements contained within the span */
|
||||
void LO_SetSpanBackground(MWContext* context, void *span, LO_Color *color)
|
||||
{
|
||||
lo_NameList *name_rec = (lo_NameList *)span;
|
||||
LO_SpanStruct *parent_span = lo_FindParentSpan(name_rec->element);
|
||||
LO_Element *ele;
|
||||
|
||||
ele = parent_span->lo_any.next;
|
||||
while (ele != NULL && ele->lo_any.type != LO_SPAN)
|
||||
{
|
||||
#if 0
|
||||
lo_SetColor(ele, color, TRUE);
|
||||
#endif
|
||||
ele = ele->lo_any.next;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the font family (Arial, Helvetica, Times) of all the layout
|
||||
elements contained within the span */
|
||||
void
|
||||
LO_SetSpanFontFamily(MWContext* context, void *span, char *family)
|
||||
{
|
||||
lo_NameList *name_rec = (lo_NameList *)span;
|
||||
LO_SpanStruct *parent_span = lo_FindParentSpan(name_rec->element);
|
||||
LO_Element *ele;
|
||||
|
||||
ele = parent_span->lo_any.next;
|
||||
while (ele != NULL && ele->lo_any.type != LO_SPAN)
|
||||
{
|
||||
lo_SetFontFamily(context, ele, family);
|
||||
ele = ele->lo_any.next;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the font weight (medium, bold, heavy, etc.) of all the layout
|
||||
elements contained within the span */
|
||||
void
|
||||
LO_SetSpanFontWeight(MWContext* context, void *span, char *weight)
|
||||
{
|
||||
lo_NameList *name_rec = (lo_NameList *)span;
|
||||
LO_SpanStruct *parent_span = lo_FindParentSpan(name_rec->element);
|
||||
LO_Element *ele;
|
||||
|
||||
ele = parent_span->lo_any.next;
|
||||
while (ele != NULL && ele->lo_any.type != LO_SPAN)
|
||||
{
|
||||
lo_SetFontWeight(context, ele, weight);
|
||||
ele = ele->lo_any.next;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the font size (in points) of all the layout elements contained
|
||||
within the span */
|
||||
void
|
||||
LO_SetSpanFontSize(MWContext* context, void *span, int32 size)
|
||||
{
|
||||
lo_NameList *name_rec = (lo_NameList *)span;
|
||||
LO_SpanStruct *parent_span = lo_FindParentSpan(name_rec->element);
|
||||
LO_Element *ele;
|
||||
|
||||
ele = parent_span->lo_any.next;
|
||||
while (ele != NULL && ele->lo_any.type != LO_SPAN)
|
||||
{
|
||||
lo_SetFontSize(context, ele, size);
|
||||
ele = ele->lo_any.next;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the font slant (in points) of all the layout elements contained
|
||||
within the span */
|
||||
void
|
||||
LO_SetSpanFontSlant(MWContext* context, void *span, char *slant)
|
||||
{
|
||||
lo_NameList *name_rec = (lo_NameList *)span;
|
||||
LO_SpanStruct *parent_span = lo_FindParentSpan(name_rec->element);
|
||||
LO_Element *ele;
|
||||
|
||||
ele = parent_span->lo_any.next;
|
||||
while (ele != NULL && ele->lo_any.type != LO_SPAN)
|
||||
{
|
||||
lo_SetFontSlant(context, ele, slant);
|
||||
ele = ele->lo_any.next;
|
||||
}
|
||||
}
|
||||
|
||||
/* Functions internal to layout */
|
||||
LO_SpanStruct *
|
||||
lo_FindParentSpan( LO_Element *ele )
|
||||
{
|
||||
while (ele != NULL && ele->lo_any.type != LO_SPAN)
|
||||
ele = ele->lo_any.prev;
|
||||
|
||||
return (LO_SpanStruct *) ele;
|
||||
}
|
||||
|
||||
#define GET_UNSHARED_TEXT_ATTR(new, old) \
|
||||
PR_BEGIN_MACRO \
|
||||
if ((old)->refcnt != 1) { \
|
||||
(new) = lo_NewCopyTextAttr(state, (old)); \
|
||||
(old)->refcnt--; \
|
||||
} else { \
|
||||
(new) = (old); \
|
||||
} \
|
||||
PR_END_MACRO
|
||||
|
||||
void lo_SetColor( LO_Element *ele, LO_Color *color, lo_DocState *state,
|
||||
Bool background)
|
||||
{
|
||||
LO_TextAttr *new_attr;
|
||||
switch (ele->lo_any.type)
|
||||
{
|
||||
case LO_TEXTBLOCK:
|
||||
GET_UNSHARED_TEXT_ATTR(new_attr, ele->lo_textBlock.text_attr);
|
||||
ele->lo_textBlock.text_attr = new_attr;
|
||||
break;
|
||||
case LO_TEXT:
|
||||
GET_UNSHARED_TEXT_ATTR(new_attr, ele->lo_text.text_attr);
|
||||
ele->lo_text.text_attr = new_attr;
|
||||
break;
|
||||
case LO_BULLET:
|
||||
GET_UNSHARED_TEXT_ATTR(new_attr, ele->lo_bullet.text_attr);
|
||||
ele->lo_bullet.text_attr = new_attr;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
if (background)
|
||||
{
|
||||
new_attr->bg = *color;
|
||||
new_attr->no_background = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_attr->fg = *color;
|
||||
}
|
||||
}
|
||||
|
||||
/* Functions internal to this file */
|
||||
static void
|
||||
lo_SetFontFamily( MWContext *context,
|
||||
LO_Element *ele,
|
||||
char *new_face)
|
||||
{
|
||||
LO_TextAttr *text_attr;
|
||||
|
||||
/* if the point size is different, tell the FE to release it's data,
|
||||
set the point_size to the new value, and then have the FE
|
||||
recompute it's information. */
|
||||
switch (ele->lo_any.type)
|
||||
{
|
||||
case LO_TEXTBLOCK:
|
||||
text_attr = ele->lo_textBlock.text_attr;
|
||||
break;
|
||||
case LO_TEXT:
|
||||
text_attr = ele->lo_text.text_attr;
|
||||
break;
|
||||
case LO_BULLET:
|
||||
text_attr = ele->lo_bullet.text_attr;
|
||||
break;
|
||||
default:
|
||||
/* we don't mess with any other type of element */
|
||||
return;
|
||||
}
|
||||
|
||||
if (ele->lo_any.type == LO_TEXT)
|
||||
{
|
||||
LO_TextInfo text_info;
|
||||
LO_TextStruct tmp_text;
|
||||
memset (&tmp_text, 0, sizeof (tmp_text));
|
||||
|
||||
FE_ReleaseTextAttrFeData(context, text_attr);
|
||||
|
||||
/* XP_FREE(text_attr->font_face); */
|
||||
text_attr->font_face = strdup(new_face);
|
||||
|
||||
tmp_text = ele->lo_text;
|
||||
|
||||
FE_GetTextInfo(context, &tmp_text, &text_info);
|
||||
}
|
||||
else if (ele->lo_any.type == LO_TEXTBLOCK)
|
||||
{
|
||||
/* XP_FREE(text_attr->font_face); */
|
||||
text_attr->font_face = strdup(new_face);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
lo_SetFontWeight( MWContext *context,
|
||||
LO_Element *ele,
|
||||
char *weight)
|
||||
{
|
||||
LO_TextAttr *text_attr;
|
||||
int new_weight = atoi(weight);
|
||||
|
||||
/* if the point size is different, tell the FE to release it's data,
|
||||
set the point_size to the new value, and then have the FE
|
||||
recompute it's information. */
|
||||
switch (ele->lo_any.type)
|
||||
{
|
||||
case LO_TEXTBLOCK:
|
||||
text_attr = ele->lo_textBlock.text_attr;
|
||||
break;
|
||||
case LO_TEXT:
|
||||
text_attr = ele->lo_text.text_attr;
|
||||
break;
|
||||
case LO_BULLET:
|
||||
text_attr = ele->lo_bullet.text_attr;
|
||||
break;
|
||||
default:
|
||||
/* we don't mess with any other type of element */
|
||||
return;
|
||||
}
|
||||
|
||||
if (ele->lo_any.type == LO_TEXT)
|
||||
{
|
||||
LO_TextInfo text_info;
|
||||
LO_TextStruct tmp_text;
|
||||
memset (&tmp_text, 0, sizeof (tmp_text));
|
||||
|
||||
FE_ReleaseTextAttrFeData(context, text_attr);
|
||||
|
||||
text_attr->font_weight = new_weight;
|
||||
if(text_attr->font_weight > 900)
|
||||
text_attr->font_weight = 900;
|
||||
|
||||
tmp_text = ele->lo_text;
|
||||
|
||||
FE_GetTextInfo(context, &tmp_text, &text_info);
|
||||
}
|
||||
else if (ele->lo_any.type == LO_TEXTBLOCK)
|
||||
{
|
||||
text_attr->font_weight = new_weight;
|
||||
if (text_attr->font_weight > 900)
|
||||
text_attr->font_weight = 900;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
lo_SetFontSlant( MWContext *context,
|
||||
LO_Element *ele,
|
||||
char *slant)
|
||||
{
|
||||
LO_TextAttr *text_attr;
|
||||
int flag;
|
||||
|
||||
/* if the point size is different, tell the FE to release it's data,
|
||||
set the point_size to the new value, and then have the FE
|
||||
recompute it's information. */
|
||||
switch (ele->lo_any.type)
|
||||
{
|
||||
case LO_TEXTBLOCK:
|
||||
text_attr = ele->lo_textBlock.text_attr;
|
||||
break;
|
||||
case LO_TEXT:
|
||||
text_attr = ele->lo_text.text_attr;
|
||||
break;
|
||||
case LO_BULLET:
|
||||
text_attr = ele->lo_bullet.text_attr;
|
||||
break;
|
||||
default:
|
||||
/* we don't mess with any other type of element */
|
||||
return;
|
||||
}
|
||||
|
||||
if (!strcmp(slant, "italic"))
|
||||
flag = LO_FONT_ITALIC;
|
||||
else if (!strcmp(slant, "fixed"))
|
||||
flag = LO_FONT_FIXED;
|
||||
|
||||
if (ele->lo_any.type == LO_TEXTBLOCK
|
||||
&& !text_attr->fontmask & flag)
|
||||
{
|
||||
LO_TextInfo text_info;
|
||||
LO_TextStruct tmp_text;
|
||||
memset (&tmp_text, 0, sizeof (tmp_text));
|
||||
|
||||
FE_ReleaseTextAttrFeData(context, text_attr);
|
||||
|
||||
text_attr->fontmask |= flag;
|
||||
|
||||
tmp_text = ele->lo_text;
|
||||
|
||||
FE_GetTextInfo(context, &tmp_text, &text_info);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
lo_SetFontSize( MWContext *context,
|
||||
LO_Element *ele,
|
||||
int32 new_size)
|
||||
{
|
||||
LO_TextAttr *text_attr;
|
||||
|
||||
/* if the point size is different, tell the FE to release it's data,
|
||||
set the point_size to the new value, and then have the FE
|
||||
recompute it's information. */
|
||||
switch (ele->lo_any.type)
|
||||
{
|
||||
case LO_TEXTBLOCK:
|
||||
text_attr = ele->lo_textBlock.text_attr;
|
||||
break;
|
||||
case LO_TEXT:
|
||||
text_attr = ele->lo_text.text_attr;
|
||||
break;
|
||||
case LO_BULLET:
|
||||
text_attr = ele->lo_bullet.text_attr;
|
||||
break;
|
||||
default:
|
||||
/* we don't mess with any other type of element */
|
||||
return;
|
||||
}
|
||||
|
||||
if (ele->lo_any.type == LO_TEXT)
|
||||
{
|
||||
LO_TextInfo text_info;
|
||||
LO_TextStruct tmp_text;
|
||||
memset (&tmp_text, 0, sizeof (tmp_text));
|
||||
|
||||
FE_ReleaseTextAttrFeData(context, text_attr);
|
||||
|
||||
text_attr->point_size = new_size;
|
||||
|
||||
tmp_text = ele->lo_text;
|
||||
|
||||
FE_GetTextInfo(context, &tmp_text, &text_info);
|
||||
}
|
||||
else if (ele->lo_any.type == LO_TEXTBLOCK)
|
||||
{
|
||||
text_attr->point_size = new_size;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -767,11 +767,6 @@ lo_reuse_current_state(MWContext *context, lo_DocState *state,
|
|||
state->old_break_pos = -1;
|
||||
state->old_break_width = 0;
|
||||
|
||||
#ifdef DOM
|
||||
state->current_span = NULL;
|
||||
state->in_span = FALSE;
|
||||
#endif
|
||||
|
||||
state->current_named_anchor = NULL;
|
||||
state->current_anchor = NULL;
|
||||
|
||||
|
|
|
@ -1367,63 +1367,6 @@ lo_process_header_tag(MWContext *context, lo_DocState *state, PA_Tag *tag, int t
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
lo_process_span_tag(MWContext *context, lo_DocState *state, PA_Tag *tag)
|
||||
{
|
||||
LO_SpanStruct *span;
|
||||
PA_Block buff;
|
||||
lo_DocLists *doc_lists;
|
||||
|
||||
doc_lists = lo_GetCurrentDocLists(state);
|
||||
|
||||
span = (LO_SpanStruct*)lo_NewElement(context, state, LO_SPAN, NULL, 0);
|
||||
XP_ASSERT(span);
|
||||
if (!span) return;
|
||||
|
||||
span->lo_any.type = LO_SPAN;
|
||||
span->lo_any.ele_id = NEXT_ELEMENT;
|
||||
span->is_end = tag->is_end;
|
||||
|
||||
span->lo_any.x = state->x;
|
||||
span->lo_any.y = state->y;
|
||||
span->lo_any.x_offset = 0;
|
||||
span->lo_any.y_offset = 0;
|
||||
span->lo_any.width = 0;
|
||||
span->lo_any.height = 0;
|
||||
span->lo_any.line_height = 0;
|
||||
|
||||
#ifdef DOM
|
||||
span->name_rec = NULL;
|
||||
if (tag->is_end == FALSE)
|
||||
{
|
||||
/* get the span's ID. */
|
||||
buff = lo_FetchParamValue(context, tag, PARAM_ID);
|
||||
if (buff != NULL)
|
||||
{
|
||||
state->in_span = TRUE;
|
||||
state->current_span = buff;
|
||||
if (lo_SetNamedSpan(state, buff))
|
||||
{
|
||||
lo_BindNamedSpanToElement(state, buff, NULL);
|
||||
lo_ReflectSpan(context, state, tag,
|
||||
doc_lists->span_list,
|
||||
lo_CurrentLayerId(state));
|
||||
span->name_rec = doc_lists->span_list;
|
||||
}
|
||||
|
||||
PA_UNLOCK(buff);
|
||||
}
|
||||
lo_AppendToLineList(context, state, (LO_Element*)span, 0);
|
||||
state->in_span = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
state->in_span = FALSE;
|
||||
lo_AppendToLineList(context, state, (LO_Element*)span, 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
lo_process_div_tag(MWContext *context, lo_DocState *state, PA_Tag *tag)
|
||||
{
|
||||
|
@ -4397,12 +4340,6 @@ lo_IsEmptyTag(TagType type)
|
|||
|| type == P_EMBED
|
||||
|| type == P_KEYGEN
|
||||
|| type == P_JAVA_APPLET
|
||||
#ifndef DOM
|
||||
|| type == P_LIST_ITEM /* not really empty! */
|
||||
|| type == P_DESC_TITLE
|
||||
|| type == P_NSDT
|
||||
|| type == P_DESC_TEXT
|
||||
#endif
|
||||
|| type == P_BASEFONT
|
||||
|| type == P_AREA
|
||||
|| type == P_BASE)
|
||||
|
@ -7548,9 +7485,6 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type));
|
|||
*/
|
||||
case P_SPAN:
|
||||
{
|
||||
#ifdef DOM
|
||||
lo_process_span_tag(context, state, tag);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -5371,10 +5371,6 @@ static uint32 lo_FindLineBreak ( MWContext * context, lo_DocState * state, LO_T
|
|||
/* the parsers */
|
||||
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 );
|
||||
#ifndef DOM
|
||||
static void lo_ParseSinglePreformattedText ( 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);
|
||||
|
@ -8268,14 +8264,6 @@ lo_GetLineStart ( LO_TextBlock * block )
|
|||
return &block->text_buffer[ block->last_line_break ];
|
||||
}
|
||||
|
||||
#ifdef DOM
|
||||
static void
|
||||
lo_SkipCharacter ( LO_TextBlock * block )
|
||||
{
|
||||
++block->buffer_read_index;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
lo_SetLineBreak ( LO_TextBlock * block, Bool skipSpace )
|
||||
{
|
||||
|
@ -8724,6 +8712,47 @@ lo_FillInTextStyleInfo(lo_DocState *state, MWContext *context,
|
|||
return tptr;
|
||||
}
|
||||
|
||||
#define GET_UNSHARED_TEXT_ATTR(new, old) \
|
||||
PR_BEGIN_MACRO \
|
||||
if ((old)->refcnt != 1) { \
|
||||
(new) = lo_NewCopyTextAttr(state, (old)); \
|
||||
(old)->refcnt--; \
|
||||
} else { \
|
||||
(new) = (old); \
|
||||
} \
|
||||
PR_END_MACRO
|
||||
|
||||
void lo_SetColor( LO_Element *ele, LO_Color *color, lo_DocState *state,
|
||||
Bool background)
|
||||
{
|
||||
LO_TextAttr *new_attr;
|
||||
switch (ele->lo_any.type)
|
||||
{
|
||||
case LO_TEXTBLOCK:
|
||||
GET_UNSHARED_TEXT_ATTR(new_attr, ele->lo_textBlock.text_attr);
|
||||
ele->lo_textBlock.text_attr = new_attr;
|
||||
break;
|
||||
case LO_TEXT:
|
||||
GET_UNSHARED_TEXT_ATTR(new_attr, ele->lo_text.text_attr);
|
||||
ele->lo_text.text_attr = new_attr;
|
||||
break;
|
||||
case LO_BULLET:
|
||||
GET_UNSHARED_TEXT_ATTR(new_attr, ele->lo_bullet.text_attr);
|
||||
ele->lo_bullet.text_attr = new_attr;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
if (background)
|
||||
{
|
||||
new_attr->bg = *color;
|
||||
new_attr->no_background = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_attr->fg = *color;
|
||||
}
|
||||
}
|
||||
#endif /* DOM */
|
||||
|
||||
#ifdef TEST_16BIT
|
||||
|
|
|
@ -52,10 +52,6 @@
|
|||
#define FONT_FACE_INC 10
|
||||
#define FONT_FACE_MAX 1000
|
||||
|
||||
#ifdef DOM
|
||||
static void lo_SetInSpanAttribute( LO_Element *ele );
|
||||
#endif
|
||||
|
||||
void
|
||||
lo_GetElementBbox(LO_Element *element, XP_Rect *rect)
|
||||
{
|
||||
|
@ -1287,9 +1283,6 @@ lo_FetchTextAttr(lo_DocState *state, LO_TextAttr *old_attr)
|
|||
(attr_ptr->charset == old_attr->charset)&&
|
||||
(attr_ptr->point_size == old_attr->point_size)&&
|
||||
(attr_ptr->font_weight == old_attr->font_weight)
|
||||
#ifdef DOM
|
||||
&& (state->in_span == FALSE) /* Never reuse text attrs in SPANS */
|
||||
#endif
|
||||
)
|
||||
{
|
||||
attr_ptr->refcnt++;
|
||||
|
@ -2281,147 +2274,6 @@ lo_BindNamedAnchorToElement(lo_DocState *state, PA_Block name,
|
|||
}
|
||||
|
||||
|
||||
#ifdef DOM
|
||||
/* Add a named span to the global list of named spans. This does not
|
||||
associate the span with a layout element. lo_SetNamedSpan should be
|
||||
followed by a call to lo_BindNamedSpanToElement in order to associate
|
||||
the named span with a layout element. */
|
||||
Bool
|
||||
lo_SetNamedSpan(lo_DocState *state, PA_Block id)
|
||||
{
|
||||
lo_NameList *name_rec = NULL;
|
||||
lo_DocLists *doc_lists;
|
||||
|
||||
/*
|
||||
* No named spans are allowed within a
|
||||
* hacked scrolling content layout document.
|
||||
*/
|
||||
if (state->top_state->scrolling_doc != FALSE)
|
||||
{
|
||||
if (id != NULL)
|
||||
{
|
||||
PA_FREE(id);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
doc_lists = lo_GetCurrentDocLists(state);
|
||||
|
||||
if (state->in_relayout) {
|
||||
/* Look for the old lo_NameList. Its mocha_object is still valid. */
|
||||
lo_NameList *span_list = doc_lists->span_list;
|
||||
lo_NameList *prev;
|
||||
Bool no_match;
|
||||
char *s1, *s2;
|
||||
|
||||
XP_ASSERT(span_list); /* If in relayout, this cannot be empty. */
|
||||
|
||||
prev = span_list;
|
||||
name_rec = span_list;
|
||||
while (name_rec != NULL) {
|
||||
PA_LOCK(s1, char*, id);
|
||||
PA_LOCK(s2, char*, name_rec->name);
|
||||
no_match = XP_STRCMP(s1, s2);
|
||||
PA_UNLOCK(name_rec->name);
|
||||
PA_UNLOCK(id);
|
||||
if (!no_match) {
|
||||
if (name_rec == span_list)
|
||||
doc_lists->span_list = span_list->next;
|
||||
else
|
||||
prev->next = name_rec->next;
|
||||
PA_FREE(name_rec->name); /* No need for this, use new one. */
|
||||
break;
|
||||
}
|
||||
prev = name_rec;
|
||||
name_rec = name_rec->next;
|
||||
}
|
||||
}
|
||||
if (!name_rec || !state->in_relayout) {
|
||||
name_rec = XP_NEW(lo_NameList);
|
||||
if (name_rec == NULL)
|
||||
{
|
||||
state->top_state->out_of_memory = TRUE;
|
||||
PA_FREE(id);
|
||||
return FALSE;
|
||||
}
|
||||
name_rec->mocha_object = NULL;
|
||||
}
|
||||
name_rec->x = 0;
|
||||
name_rec->y = 0;
|
||||
name_rec->name = id;
|
||||
name_rec->element = NULL; /* Set by lo_BindNamedSpanToElement. */
|
||||
|
||||
name_rec->next = doc_lists->span_list;
|
||||
doc_lists->span_list = name_rec;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Associate a named span with a layout element. The named span should
|
||||
be the first one in the list of named spans.*/
|
||||
Bool
|
||||
lo_BindNamedSpanToElement(lo_DocState *state, PA_Block name,
|
||||
LO_Element *element)
|
||||
{
|
||||
Bool no_match;
|
||||
LO_Element *eptr;
|
||||
lo_NameList *name_rec;
|
||||
char *s1, *s2;
|
||||
lo_DocLists *doc_lists;
|
||||
|
||||
doc_lists = lo_GetCurrentDocLists(state);
|
||||
|
||||
if (element == NULL)
|
||||
{
|
||||
if (state->line_list == NULL)
|
||||
{
|
||||
eptr = state->end_last_line;
|
||||
}
|
||||
else
|
||||
{
|
||||
eptr = state->line_list;
|
||||
while (eptr->lo_any.next != NULL)
|
||||
{
|
||||
eptr = eptr->lo_any.next;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
eptr = element;
|
||||
}
|
||||
|
||||
/* Find the matching name_rec in the span_list */
|
||||
name_rec = doc_lists->span_list;
|
||||
PA_LOCK(s1, char*, name);
|
||||
while (name_rec != NULL)
|
||||
{
|
||||
PA_LOCK(s2, char*, name_rec->name);
|
||||
no_match = XP_STRCMP(s1, s2);
|
||||
PA_UNLOCK(name_rec->name);
|
||||
if (!no_match)
|
||||
break;
|
||||
name_rec = name_rec->next;
|
||||
}
|
||||
PA_UNLOCK(name);
|
||||
if (name_rec == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (eptr == NULL)
|
||||
{
|
||||
name_rec->x = 0;
|
||||
name_rec->y = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
name_rec->x = eptr->lo_any.x;
|
||||
name_rec->y = eptr->lo_any.y;
|
||||
}
|
||||
|
||||
name_rec->element = eptr;
|
||||
return TRUE;
|
||||
}
|
||||
#endif /* DOM */
|
||||
|
||||
void
|
||||
lo_AddNameList(lo_DocState *state, lo_DocState *old_state)
|
||||
{
|
||||
|
@ -2597,21 +2449,6 @@ lo_AppendToLineList(MWContext *context, lo_DocState *state,
|
|||
LO_Element *eptr;
|
||||
|
||||
#ifdef DOM
|
||||
if (state->in_span)
|
||||
{
|
||||
lo_SetInSpanAttribute( element );
|
||||
}
|
||||
|
||||
if (state->current_span != NULL)
|
||||
{
|
||||
if (!lo_BindNamedSpanToElement(state, state->current_span,
|
||||
element))
|
||||
{
|
||||
XP_ASSERT(FALSE);
|
||||
}
|
||||
state->current_span = NULL;
|
||||
}
|
||||
|
||||
lo_SetNodeElement(state, element);
|
||||
#endif
|
||||
|
||||
|
@ -3851,64 +3688,6 @@ LO_Element * lo_GetLastElementInList( LO_Element *eleList )
|
|||
|
||||
}
|
||||
|
||||
#ifdef DOM
|
||||
/* Checks the layout element to see if the element is enclosed within <SPAN> */
|
||||
Bool LO_IsWithinSpan( LO_Element *ele )
|
||||
{
|
||||
Bool isInSpan = FALSE;
|
||||
|
||||
if (ele)
|
||||
{
|
||||
switch (ele->type) {
|
||||
|
||||
case LO_TEXT:
|
||||
isInSpan = ele->lo_text.ele_attrmask & LO_ELE_IN_SPAN ? TRUE : FALSE;
|
||||
break;
|
||||
case LO_IMAGE:
|
||||
isInSpan = ele->lo_image.ele_attrmask & LO_ELE_IN_SPAN ? TRUE : FALSE;
|
||||
break;
|
||||
case LO_FORM_ELE:
|
||||
isInSpan = ele->lo_form.ele_attrmask & LO_ELE_IN_SPAN ? TRUE : FALSE;
|
||||
break;
|
||||
case LO_EMBED:
|
||||
isInSpan = ele->lo_embed.ele_attrmask & LO_ELE_IN_SPAN ? TRUE : FALSE;
|
||||
break;
|
||||
case LO_JAVA:
|
||||
isInSpan = ele->lo_java.ele_attrmask & LO_ELE_IN_SPAN ? TRUE : FALSE;
|
||||
break;
|
||||
case LO_BUILTIN:
|
||||
isInSpan = ele->lo_builtin.ele_attrmask & LO_ELE_IN_SPAN ? TRUE : FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return isInSpan;
|
||||
}
|
||||
|
||||
static void lo_SetInSpanAttribute( LO_Element *ele )
|
||||
{
|
||||
switch (ele->type) {
|
||||
|
||||
case LO_TEXT:
|
||||
ele->lo_text.ele_attrmask |= LO_ELE_IN_SPAN;
|
||||
break;
|
||||
case LO_IMAGE:
|
||||
ele->lo_image.ele_attrmask |= LO_ELE_IN_SPAN;
|
||||
break;
|
||||
case LO_FORM_ELE:
|
||||
ele->lo_form.ele_attrmask |= LO_ELE_IN_SPAN;
|
||||
break;
|
||||
case LO_EMBED:
|
||||
ele->lo_embed.ele_attrmask |= LO_ELE_IN_SPAN;
|
||||
break;
|
||||
#ifdef JAVA
|
||||
case LO_JAVA:
|
||||
ele->lo_java.ele_attrmask |= LO_ELE_IN_SPAN;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PROFILE
|
||||
#pragma profile off
|
||||
#endif
|
||||
|
|
|
@ -57,10 +57,8 @@ CSRCS = et_mocha.c \
|
|||
lm_nav.c \
|
||||
lm_plgin.c \
|
||||
lm_screen.c \
|
||||
lm_span.c \
|
||||
lm_supdt.c \
|
||||
lm_taint.c \
|
||||
lm_trans.c \
|
||||
lm_tree.c \
|
||||
lm_trggr.c \
|
||||
lm_url.c \
|
||||
|
|
|
@ -60,10 +60,8 @@ CSRCS = et_mocha.c \
|
|||
lm_nav.c \
|
||||
lm_plgin.c \
|
||||
lm_screen.c \
|
||||
lm_span.c \
|
||||
lm_supdt.c \
|
||||
lm_taint.c \
|
||||
lm_trans.c \
|
||||
lm_tree.c \
|
||||
lm_trggr.c \
|
||||
lm_url.c \
|
||||
|
|
|
@ -908,15 +908,6 @@ et_reflect_handler(Reflect_Event * e)
|
|||
case LM_LAYERS:
|
||||
LM_ReflectLayer(e->ce.context, e->index, e->layer_id, e->pa_tag);
|
||||
break;
|
||||
#ifdef DOM
|
||||
case LM_SPANS:
|
||||
LM_ReflectSpan(e->ce.context, e->lo_ele, e->pa_tag,
|
||||
e->layer_id, e->index);
|
||||
break;
|
||||
case LM_TRANSCLUSIONS:
|
||||
LM_ReflectTransclusion(e->ce.context, e->lo_ele, e->layer_id, e->index);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
XP_ASSERT(0);
|
||||
break;
|
||||
|
|
|
@ -3063,157 +3063,8 @@ ET_PostSignedAppletPrivileges
|
|||
et_PostEvent(&event->ce, FALSE);
|
||||
}
|
||||
|
||||
#ifdef DOM
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
typedef struct {
|
||||
ETEvent ce;
|
||||
lo_NameList *name_rec;
|
||||
ETSpanOp op;
|
||||
void *param_ptr;
|
||||
int32 param_val;
|
||||
} MozillaEvent_TweakSpan;
|
||||
|
||||
PR_STATIC_CALLBACK(int)
|
||||
et_HandleEvent_TweakSpan(MozillaEvent_TweakSpan* e)
|
||||
{
|
||||
Bool ret = TRUE;
|
||||
|
||||
/* check that the doc_id is valid */
|
||||
if(XP_DOCID(e->ce.context) != e->ce.doc_id)
|
||||
return FALSE;
|
||||
|
||||
switch(e->op) {
|
||||
case SP_SetColor:
|
||||
LO_SetSpanColor(e->ce.context, e->name_rec, (LO_Color*)e->param_ptr);
|
||||
/* This call to reflow is just a temp hack */
|
||||
LO_RelayoutFromElement(e->ce.context, e->name_rec->element);
|
||||
if (e->param_ptr)
|
||||
XP_FREE((void*)e->param_ptr);
|
||||
break;
|
||||
case SP_SetBackground:
|
||||
LO_SetSpanBackground(e->ce.context, e->name_rec, (LO_Color*)e->param_ptr);
|
||||
/* This call to reflow is just a temp hack */
|
||||
LO_RelayoutFromElement(e->ce.context, e->name_rec->element);
|
||||
if (e->param_ptr)
|
||||
XP_FREE((void*)e->param_ptr);
|
||||
break;
|
||||
case SP_SetFontFamily:
|
||||
LO_SetSpanFontFamily(e->ce.context, e->name_rec, (char*)e->param_ptr);
|
||||
LO_RelayoutFromElement(e->ce.context, e->name_rec->element);
|
||||
break;
|
||||
case SP_SetFontWeight:
|
||||
LO_SetSpanFontWeight(e->ce.context, e->name_rec, (char*)e->param_ptr);
|
||||
LO_RelayoutFromElement(e->ce.context, e->name_rec->element);
|
||||
break;
|
||||
case SP_SetFontSize:
|
||||
LO_SetSpanFontSize(e->ce.context, e->name_rec, e->param_val);
|
||||
LO_RelayoutFromElement(e->ce.context, e->name_rec->element);
|
||||
break;
|
||||
case SP_SetFontSlant:
|
||||
LO_SetSpanFontSlant(e->ce.context, e->name_rec, (char*)e->param_ptr);
|
||||
LO_RelayoutFromElement(e->ce.context, e->name_rec->element);
|
||||
break;
|
||||
default:
|
||||
XP_ASSERT(0);
|
||||
}
|
||||
|
||||
return (int)ret;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(void)
|
||||
et_DestroyEvent_TweakSpan(MozillaEvent_TweakSpan * event)
|
||||
{
|
||||
XP_FREE(event);
|
||||
}
|
||||
|
||||
/*
|
||||
* These need to be synchronous so that if we set this and then
|
||||
* immediately look at it we get the correct (new) value
|
||||
*/
|
||||
int
|
||||
ET_TweakSpan(MWContext * context, void *name_rec, void *param_ptr,
|
||||
int32 param_val, ETSpanOp op, int32 doc_id)
|
||||
{
|
||||
MozillaEvent_TweakSpan * event;
|
||||
event = PR_NEW(MozillaEvent_TweakSpan);
|
||||
if (event == NULL)
|
||||
return 0;
|
||||
|
||||
PR_InitEvent(&event->ce.event, context,
|
||||
(PRHandleEventProc)et_HandleEvent_TweakSpan,
|
||||
(PRDestroyEventProc)et_DestroyEvent_TweakSpan);
|
||||
event->ce.context = context;
|
||||
event->ce.doc_id = doc_id;
|
||||
event->op = op;
|
||||
event->name_rec = name_rec;
|
||||
event->param_ptr = param_ptr;
|
||||
event->param_val = param_val;
|
||||
|
||||
return (int)et_PostEvent(&event->ce, TRUE);
|
||||
}
|
||||
|
||||
/* Tweak XML Transclusion stuff starts here */
|
||||
typedef struct {
|
||||
ETEvent ce;
|
||||
ETTransclusionOp op;
|
||||
void *param_ptr;
|
||||
int32 param_val;
|
||||
void *xmlFile;
|
||||
} MozillaEvent_TweakTransclusion;
|
||||
|
||||
PR_STATIC_CALLBACK(int)
|
||||
et_HandleEvent_TweakTransclusion(MozillaEvent_TweakTransclusion* e)
|
||||
{
|
||||
Bool ret = TRUE;
|
||||
|
||||
/* check that the doc_id is valid */
|
||||
if(XP_DOCID(e->ce.context) != e->ce.doc_id)
|
||||
return FALSE;
|
||||
|
||||
switch(e->op) {
|
||||
case TR_SetHref:
|
||||
XMLSetTransclusionProperty(e->xmlFile, e->param_val, "href", e->param_ptr);
|
||||
if (e->param_ptr)
|
||||
XP_FREE((void*)e->param_ptr);
|
||||
break;
|
||||
default:
|
||||
XP_ASSERT(0);
|
||||
}
|
||||
|
||||
return (int)ret;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(void)
|
||||
et_DestroyEvent_TweakTransclusion(MozillaEvent_TweakTransclusion * event)
|
||||
{
|
||||
XP_FREE(event);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
ET_TweakTransclusion(MWContext * context, void *xmlFile, void *param_ptr,
|
||||
int32 param_val, ETTransclusionOp op, int32 doc_id)
|
||||
{
|
||||
MozillaEvent_TweakTransclusion * event;
|
||||
event = PR_NEW(MozillaEvent_TweakTransclusion);
|
||||
if (event == NULL)
|
||||
return 0;
|
||||
|
||||
PR_InitEvent(&event->ce.event, context,
|
||||
(PRHandleEventProc)et_HandleEvent_TweakTransclusion,
|
||||
(PRDestroyEventProc)et_DestroyEvent_TweakTransclusion);
|
||||
event->ce.context = context;
|
||||
event->ce.doc_id = doc_id;
|
||||
event->op = op;
|
||||
event->param_ptr = param_ptr;
|
||||
event->param_val = param_val;
|
||||
event->xmlFile = xmlFile;
|
||||
|
||||
return (int)et_PostEvent(&event->ce, FALSE);
|
||||
}
|
||||
|
||||
#if DOM
|
||||
/* Signal reflow from DOM alteration */
|
||||
typedef struct {
|
||||
ETEvent ce;
|
||||
|
|
|
@ -85,27 +85,25 @@ enum doc_slot {
|
|||
DOC_ANCHORS = -5,
|
||||
DOC_APPLETS = -6,
|
||||
DOC_EMBEDS = -7,
|
||||
DOC_SPANS = -8, /* Added for HTML SPAN DOM stuff */
|
||||
DOC_TRANSCLUSIONS = -9, /* Added for XML Transclusion DOM stuff */
|
||||
DOC_DOCELEMENT = -10, /* Added for W3C DOM stuff */
|
||||
DOC_TITLE = -11,
|
||||
DOC_URL = -12,
|
||||
DOC_REFERRER = -13,
|
||||
DOC_LAST_MODIFIED = -14,
|
||||
DOC_COOKIE = -15,
|
||||
DOC_DOMAIN = -16,
|
||||
DOC_DOCELEMENT = -8, /* Added for W3C DOM stuff */
|
||||
DOC_TITLE = -9,
|
||||
DOC_URL = -10,
|
||||
DOC_REFERRER = -11,
|
||||
DOC_LAST_MODIFIED = -12,
|
||||
DOC_COOKIE = -13,
|
||||
DOC_DOMAIN = -14,
|
||||
/* slots below this line are not secured */
|
||||
DOC_IMAGES = -17,
|
||||
DOC_LAYERS = -18,
|
||||
DOC_LOADED_DATE = -19,
|
||||
DOC_BG_COLOR = -20,
|
||||
DOC_FG_COLOR = -21,
|
||||
DOC_LINK_COLOR = -22,
|
||||
DOC_VLINK_COLOR = -23,
|
||||
DOC_ALINK_COLOR = -24,
|
||||
DOC_WIDTH = -25,
|
||||
DOC_HEIGHT = -26,
|
||||
DOC_BUILTINS = -27
|
||||
DOC_IMAGES = -15,
|
||||
DOC_LAYERS = -16,
|
||||
DOC_LOADED_DATE = -17,
|
||||
DOC_BG_COLOR = -18,
|
||||
DOC_FG_COLOR = -19,
|
||||
DOC_LINK_COLOR = -20,
|
||||
DOC_VLINK_COLOR = -21,
|
||||
DOC_ALINK_COLOR = -22,
|
||||
DOC_WIDTH = -23,
|
||||
DOC_HEIGHT = -24,
|
||||
DOC_BUILTINS = -25
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -123,8 +121,6 @@ static JSPropertySpec doc_props[] = {
|
|||
{lm_images_str, DOC_IMAGES, JSPROP_ENUMERATE|JSPROP_READONLY},
|
||||
{lm_layers_str, DOC_LAYERS, JSPROP_ENUMERATE|JSPROP_READONLY},
|
||||
#ifdef DOM
|
||||
{lm_spans_str, DOC_SPANS, JSPROP_ENUMERATE|JSPROP_READONLY},
|
||||
{lm_transclusions_str, DOC_TRANSCLUSIONS, JSPROP_ENUMERATE|JSPROP_READONLY},
|
||||
{"documentElement",DOC_DOCELEMENT, JSPROP_ENUMERATE|JSPROP_READONLY},
|
||||
#endif
|
||||
{"title", DOC_TITLE, JSPROP_ENUMERATE|JSPROP_READONLY},
|
||||
|
@ -305,35 +301,7 @@ doc_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
return JS_TRUE;
|
||||
|
||||
#ifdef DOM
|
||||
case DOC_SPANS:
|
||||
*vp = OBJECT_TO_JSVAL(lm_GetSpanArray(decoder, obj));
|
||||
active_layer_id = LM_GetActiveLayer(context);
|
||||
LM_SetActiveLayer(context, doc->layer_id);
|
||||
(void) LO_EnumerateSpans(context,doc->layer_id);
|
||||
LM_SetActiveLayer(context, active_layer_id);
|
||||
LO_UnlockLayout();
|
||||
return JS_TRUE;
|
||||
|
||||
case DOC_TRANSCLUSIONS:
|
||||
/* We are assuming that by the time any JS sees document.transclusions[]
|
||||
all the transclusions have been reflected into JS. So
|
||||
there is no need for the call to XMLEnumerateTransclusions that
|
||||
reflects all Transclusions into JS.
|
||||
*/
|
||||
*vp = OBJECT_TO_JSVAL(lm_GetTransclusionArray(decoder, obj));
|
||||
active_layer_id = LM_GetActiveLayer(context);
|
||||
LM_SetActiveLayer(context, doc->layer_id);
|
||||
/*
|
||||
(void) XMLEnumerateTransclusions(context,doc->layer_id);
|
||||
*/
|
||||
LM_SetActiveLayer(context, active_layer_id);
|
||||
LO_UnlockLayout();
|
||||
return JS_TRUE;
|
||||
|
||||
case DOC_DOCELEMENT:
|
||||
#ifdef DEBUG_shaver
|
||||
fprintf(stderr, "getting document.documentElement\n");
|
||||
#endif
|
||||
*vp = OBJECT_TO_JSVAL(lm_DOMGetDocumentElement(decoder, obj));
|
||||
LO_UnlockLayout();
|
||||
return JS_TRUE;
|
||||
|
@ -1700,12 +1668,7 @@ lm_DefineDocument(MochaDecoder *decoder, int32 layer_id)
|
|||
!JS_AddNamedRoot(cx, &doc->applets, lm_applets_str) ||
|
||||
!JS_AddNamedRoot(cx, &doc->embeds, lm_embeds_str) ||
|
||||
!JS_AddNamedRoot(cx, &doc->images, lm_images_str) ||
|
||||
!JS_AddNamedRoot(cx, &doc->layers, lm_layers_str)
|
||||
#ifdef DOM
|
||||
|| !JS_AddNamedRoot(cx, &doc->spans, lm_spans_str)
|
||||
|| !JS_AddNamedRoot(cx, &doc->transclusions, lm_transclusions_str)
|
||||
#endif
|
||||
) {
|
||||
!JS_AddNamedRoot(cx, &doc->layers, lm_layers_str)) {
|
||||
/* doc_finalize will clean up the rest. */
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1791,10 +1754,6 @@ lm_CleanUpDocumentRoots(MochaDecoder *decoder, JSObject *obj)
|
|||
doc->embeds = NULL;
|
||||
doc->images = NULL;
|
||||
doc->layers = NULL;
|
||||
#ifdef DOM
|
||||
doc->spans = NULL;
|
||||
doc->transclusions = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -102,10 +102,6 @@ char lm_applets_str[] = "applets";
|
|||
char lm_embeds_str[] = "embeds";
|
||||
char lm_images_str[] = "images";
|
||||
char lm_layers_str[] = "layers";
|
||||
#ifdef DOM
|
||||
char lm_spans_str[] = "spans";
|
||||
char lm_transclusions_str[] = "transclusions";
|
||||
#endif
|
||||
char lm_builtins_str[] = "trees";
|
||||
char lm_location_str[] = "location";
|
||||
char lm_navigator_str[] = "navigator";
|
||||
|
@ -1212,11 +1208,6 @@ LM_PutMochaDecoder(MochaDecoder *decoder)
|
|||
CLEAR(decoder->rect_prototype);
|
||||
CLEAR(decoder->url_prototype);
|
||||
|
||||
#ifdef DOM
|
||||
CLEAR(decoder->span_prototype);
|
||||
CLEAR(decoder->transclusion_prototype);
|
||||
#endif
|
||||
|
||||
/* Clear window sub-object refs. */
|
||||
if (decoder->document)
|
||||
lm_CleanUpDocumentRoots(decoder, decoder->document);
|
||||
|
|
|
@ -2383,14 +2383,6 @@ lm_InputEvent(MWContext *context, LO_Element *element, JSEvent *pEvent,
|
|||
case LO_TEXT:
|
||||
anchor = element->lo_text.text ? element->lo_text.anchor_href : 0;
|
||||
obj = anchor ? anchor->mocha_object : 0;
|
||||
#ifdef DOM
|
||||
/* If this layout element is within a span, set the mocha object to
|
||||
the containing SPAN's mocha object */
|
||||
if (LO_IsWithinSpan( element ))
|
||||
{
|
||||
obj = LO_GetMochaObjectOfParentSpan( element );
|
||||
}
|
||||
#endif
|
||||
if (!obj) {
|
||||
if (!LM_EventCaptureCheck(context, pEvent->type) || !anchor) {
|
||||
LO_UnlockLayout();
|
||||
|
|
|
@ -1,553 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/*
|
||||
* JS reflection of the named SPANS in the current document.
|
||||
*
|
||||
* Chris Toshok, 26-Feb-1998
|
||||
*/
|
||||
|
||||
#ifdef DOM
|
||||
|
||||
#include "lm.h"
|
||||
|
||||
#include "lo_ele.h"
|
||||
#include "prtypes.h"
|
||||
#include "pa_tags.h"
|
||||
#include "layout.h"
|
||||
|
||||
enum span_array_slot {
|
||||
SPAN_ARRAY_LENGTH = -1
|
||||
};
|
||||
|
||||
static JSPropertySpec span_array_props[] = {
|
||||
{ lm_length_str, SPAN_ARRAY_LENGTH,
|
||||
JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT},
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
extern JSClass lm_span_array_class;
|
||||
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
span_array_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
JSObjectArray *array;
|
||||
MochaDecoder *decoder;
|
||||
MWContext *context;
|
||||
jsint count, slot;
|
||||
lo_NameList *span;
|
||||
int32 active_layer_id;
|
||||
|
||||
/* XP_TRACE (("span_array_getProperty called\n")); */
|
||||
|
||||
if (!JSVAL_IS_INT(id))
|
||||
return JS_TRUE;
|
||||
|
||||
slot = JSVAL_TO_INT(id);
|
||||
|
||||
array = JS_GetInstancePrivate(cx, obj, &lm_span_array_class, NULL);
|
||||
if (!array)
|
||||
return JS_TRUE;
|
||||
decoder = array->decoder;
|
||||
context = decoder->window_context;
|
||||
if (!context)
|
||||
return JS_TRUE;
|
||||
|
||||
LO_LockLayout();
|
||||
switch (slot) {
|
||||
case SPAN_ARRAY_LENGTH:
|
||||
active_layer_id = LM_GetActiveLayer(context);
|
||||
LM_SetActiveLayer(context, array->layer_id);
|
||||
count = LO_EnumerateSpans(context, array->layer_id);
|
||||
LM_SetActiveLayer(context, active_layer_id);
|
||||
if (count > array->length)
|
||||
array->length = count;
|
||||
*vp = INT_TO_JSVAL(count);
|
||||
break;
|
||||
|
||||
default:
|
||||
if (slot < 0) {
|
||||
/* Don't mess with user-defined or method properties. */
|
||||
LO_UnlockLayout();
|
||||
return JS_TRUE;
|
||||
}
|
||||
if (slot >= array->length)
|
||||
array->length = slot + 1;
|
||||
span = LO_GetSpanByIndex(context, array->layer_id, (uint)slot);
|
||||
XP_TRACE (("span = %p\n", span));
|
||||
if (span) {
|
||||
*vp = OBJECT_TO_JSVAL(LM_ReflectSpan(context, span, NULL,
|
||||
array->layer_id, (uint)slot));
|
||||
}
|
||||
break;
|
||||
}
|
||||
LO_UnlockLayout();
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(void)
|
||||
span_array_finalize(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
JSObjectArray *array;
|
||||
|
||||
array = JS_GetPrivate(cx, obj);
|
||||
if (!array)
|
||||
return;
|
||||
DROP_BACK_COUNT(array->decoder);
|
||||
JS_free(cx, array);
|
||||
}
|
||||
|
||||
JSClass lm_span_array_class = {
|
||||
"SpanArray", JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub, JS_PropertyStub,
|
||||
span_array_getProperty, span_array_getProperty, JS_EnumerateStub,
|
||||
JS_ResolveStub, JS_ConvertStub, span_array_finalize
|
||||
};
|
||||
|
||||
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
SpanArray(JSContext *cx, JSObject *obj,
|
||||
uint argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSObject *
|
||||
reflect_span_array(MochaDecoder *decoder, JSClass *clasp,
|
||||
JSNative constructor, JSObject *document)
|
||||
{
|
||||
JSContext *cx;
|
||||
JSObject *obj, *prototype;
|
||||
JSObjectArray *array;
|
||||
JSDocument *doc;
|
||||
|
||||
cx = decoder->js_context;
|
||||
doc = JS_GetPrivate(cx, document);
|
||||
if (!doc)
|
||||
return NULL;
|
||||
|
||||
prototype = JS_InitClass(cx, decoder->window_object, NULL,
|
||||
clasp, constructor, 0,
|
||||
span_array_props, NULL, NULL, NULL);
|
||||
if (!prototype)
|
||||
return NULL;
|
||||
array = JS_malloc(cx, sizeof *array);
|
||||
if (!array)
|
||||
return NULL;
|
||||
XP_BZERO(array, sizeof *array);
|
||||
obj = JS_NewObject(cx, clasp, prototype, document);
|
||||
if (!obj || !JS_SetPrivate(cx, obj, array)) {
|
||||
JS_free(cx, array);
|
||||
return NULL;
|
||||
}
|
||||
array->decoder = HOLD_BACK_COUNT(decoder);
|
||||
array->layer_id = doc->layer_id;
|
||||
return obj;
|
||||
}
|
||||
|
||||
JSObject *
|
||||
lm_GetSpanArray(MochaDecoder *decoder, JSObject *document)
|
||||
{
|
||||
JSObject *obj;
|
||||
JSDocument *doc;
|
||||
|
||||
doc = JS_GetPrivate(decoder->js_context, document);
|
||||
if (!doc)
|
||||
return NULL;
|
||||
|
||||
obj = doc->spans;
|
||||
if (obj)
|
||||
return obj;
|
||||
obj = reflect_span_array(decoder, &lm_span_array_class, SpanArray,
|
||||
document);
|
||||
doc->spans = obj;
|
||||
return obj;
|
||||
}
|
||||
|
||||
JSBool PR_CALLBACK span_setProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
JSBool PR_CALLBACK span_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
void PR_CALLBACK span_Finalize(JSContext *cx, JSObject *obj);
|
||||
|
||||
enum {
|
||||
SPAN_NAME = -1,
|
||||
SPAN_FONTFAMILY = -2,
|
||||
SPAN_FONTWEIGHT = -3,
|
||||
SPAN_FONTSIZE = -4,
|
||||
SPAN_FONTSLANT = -5,
|
||||
SPAN_COLOR = -6,
|
||||
SPAN_BGCOLOR = -7
|
||||
};
|
||||
|
||||
static JSPropertySpec span_props[] =
|
||||
{
|
||||
{"name", SPAN_NAME, JSPROP_ENUMERATE | JSPROP_READONLY },
|
||||
{"fontFamily", SPAN_FONTFAMILY, JSPROP_ENUMERATE },
|
||||
{"fontWeight", SPAN_FONTWEIGHT, JSPROP_ENUMERATE },
|
||||
{"fontSize", SPAN_FONTSIZE, JSPROP_ENUMERATE },
|
||||
{"fontSlant", SPAN_FONTSLANT, JSPROP_ENUMERATE },
|
||||
{"color", SPAN_COLOR, JSPROP_ENUMERATE },
|
||||
{"bgcolor", SPAN_BGCOLOR, JSPROP_ENUMERATE },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
static JSClass lm_span_class =
|
||||
{
|
||||
"Span", JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub, JS_PropertyStub,
|
||||
span_getProperty, span_setProperty,
|
||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, span_Finalize
|
||||
};
|
||||
|
||||
/* Base span element type. */
|
||||
typedef struct JSSpan {
|
||||
MochaDecoder *decoder;
|
||||
int32 layer_id;
|
||||
uint index;
|
||||
JSString *text;
|
||||
JSString *name;
|
||||
} JSSpan;
|
||||
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
Span(JSContext *cx, JSObject *obj,
|
||||
uint argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSObject *
|
||||
LM_ReflectSpan(MWContext *context, lo_NameList *name_rec,
|
||||
PA_Tag * tag, int32 layer_id, uint index)
|
||||
{
|
||||
JSObject *obj, *array_obj, *document;
|
||||
MochaDecoder *decoder;
|
||||
JSContext *cx;
|
||||
JSObjectArray *array;
|
||||
JSSpan *named_span;
|
||||
lo_TopState *top_state;
|
||||
PRHashTable *map;
|
||||
JSString *str;
|
||||
|
||||
obj = name_rec->mocha_object;
|
||||
if (obj)
|
||||
return obj;
|
||||
|
||||
decoder = LM_GetMochaDecoder(context);
|
||||
if (!decoder)
|
||||
return NULL;
|
||||
cx = decoder->js_context;
|
||||
|
||||
top_state = lo_GetMochaTopState(context);
|
||||
if (top_state->resize_reload) {
|
||||
map = lm_GetIdToObjectMap(decoder);
|
||||
|
||||
if (map)
|
||||
obj = (JSObject *)PR_HashTableLookup(map,
|
||||
LM_GET_MAPPING_KEY(LM_SPANS,
|
||||
layer_id, index));
|
||||
if (obj) {
|
||||
name_rec->mocha_object = obj;
|
||||
LM_PutMochaDecoder(decoder);
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
/* Get the document object that will hold this span */
|
||||
document = lm_GetDocumentFromLayerId(decoder, layer_id);
|
||||
if (!document) {
|
||||
LM_PutMochaDecoder(decoder);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
array_obj = lm_GetSpanArray(decoder, document);
|
||||
if (!array_obj) {
|
||||
LM_PutMochaDecoder(decoder);
|
||||
return NULL;
|
||||
}
|
||||
array = JS_GetPrivate(cx, array_obj);
|
||||
if (!array) {
|
||||
LM_PutMochaDecoder(decoder);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
named_span = JS_malloc(cx, sizeof *named_span);
|
||||
if (!named_span) {
|
||||
LM_PutMochaDecoder(decoder);
|
||||
return NULL;
|
||||
}
|
||||
XP_BZERO(named_span, sizeof *named_span);
|
||||
|
||||
obj = JS_NewObject(cx, &lm_span_class, decoder->span_prototype,
|
||||
document);
|
||||
|
||||
if (!obj || !JS_SetPrivate(cx, obj, named_span)) {
|
||||
JS_free(cx, named_span);
|
||||
LM_PutMochaDecoder(decoder);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Put obj into the document.spans array. */
|
||||
JS_DefineProperty(cx, array_obj, (char *) name_rec->name,
|
||||
OBJECT_TO_JSVAL(obj), NULL, NULL,
|
||||
JSPROP_ENUMERATE|JSPROP_READONLY);
|
||||
JS_AliasElement(cx, array_obj, (char *) name_rec->name, index);
|
||||
|
||||
/* Put it in the index to object hash table */
|
||||
map = lm_GetIdToObjectMap(decoder);
|
||||
if (map) {
|
||||
PR_HashTableAdd(map,
|
||||
LM_GET_MAPPING_KEY(LM_SPANS, layer_id, index),
|
||||
obj);
|
||||
}
|
||||
if ((jsint) index >= array->length)
|
||||
array->length = index + 1;
|
||||
|
||||
named_span->decoder = HOLD_BACK_COUNT(decoder);
|
||||
named_span->layer_id = layer_id;
|
||||
named_span->index = index;
|
||||
if (name_rec->element && name_rec->element->type == LO_TEXT) {
|
||||
str = lm_LocalEncodingToStr(context,
|
||||
(char *) name_rec->element->lo_text.text);
|
||||
if (!str || !JS_LockGCThing(cx, str)) {
|
||||
LM_PutMochaDecoder(decoder);
|
||||
return NULL;
|
||||
}
|
||||
named_span->text = str;
|
||||
}
|
||||
str = JS_NewStringCopyZ(cx, (char *) name_rec->name);
|
||||
if (!str || !JS_LockGCThing(cx, str)) {
|
||||
LM_PutMochaDecoder(decoder);
|
||||
return NULL;
|
||||
}
|
||||
named_span->name = str;
|
||||
|
||||
name_rec->mocha_object = obj;
|
||||
|
||||
/* see if there are any attributes for event handlers */
|
||||
if(tag) {
|
||||
|
||||
PA_Block onclick, onmouseover, onmouseout, onmousedown, onmouseup, ondblclick, id;
|
||||
|
||||
/* don't hold the layout lock across compiles */
|
||||
LO_UnlockLayout();
|
||||
|
||||
onclick = lo_FetchParamValue(context, tag, PARAM_ONCLICK);
|
||||
onmouseover = lo_FetchParamValue(context, tag, PARAM_ONMOUSEOVER);
|
||||
onmouseout = lo_FetchParamValue(context, tag, PARAM_ONMOUSEOUT);
|
||||
onmousedown = lo_FetchParamValue(context, tag, PARAM_ONMOUSEDOWN);
|
||||
onmouseup = lo_FetchParamValue(context, tag, PARAM_ONMOUSEUP);
|
||||
ondblclick = lo_FetchParamValue(context, tag, PARAM_ONDBLCLICK);
|
||||
id = lo_FetchParamValue(context, tag, PARAM_ID);
|
||||
|
||||
if (onclick) {
|
||||
(void) lm_CompileEventHandler(decoder, id, tag->data,
|
||||
tag->newline_count, obj,
|
||||
PARAM_ONCLICK, onclick);
|
||||
PA_FREE(onclick);
|
||||
#if 0
|
||||
anchor_data->event_handler_present = TRUE;
|
||||
#endif
|
||||
}
|
||||
if (onmouseover) {
|
||||
(void) lm_CompileEventHandler(decoder, id, tag->data,
|
||||
tag->newline_count, obj,
|
||||
PARAM_ONMOUSEOVER, onmouseover);
|
||||
PA_FREE(onmouseover);
|
||||
#if 0
|
||||
anchor_data->event_handler_present = TRUE;
|
||||
#endif
|
||||
}
|
||||
if (onmouseout) {
|
||||
(void) lm_CompileEventHandler(decoder, id, tag->data,
|
||||
tag->newline_count, obj,
|
||||
PARAM_ONMOUSEOUT, onmouseout);
|
||||
PA_FREE(onmouseout);
|
||||
#if 0
|
||||
anchor_data->event_handler_present = TRUE;
|
||||
#endif
|
||||
}
|
||||
if (onmousedown) {
|
||||
(void) lm_CompileEventHandler(decoder, id, tag->data,
|
||||
tag->newline_count, obj,
|
||||
PARAM_ONMOUSEDOWN, onmousedown);
|
||||
PA_FREE(onmousedown);
|
||||
#if 0
|
||||
anchor_data->event_handler_present = TRUE;
|
||||
#endif
|
||||
}
|
||||
if (onmouseup) {
|
||||
(void) lm_CompileEventHandler(decoder, id, tag->data,
|
||||
tag->newline_count, obj,
|
||||
PARAM_ONMOUSEUP, onmouseup);
|
||||
PA_FREE(onmouseup);
|
||||
#if 0
|
||||
anchor_data->event_handler_present = TRUE;
|
||||
#endif
|
||||
}
|
||||
if (ondblclick) {
|
||||
(void) lm_CompileEventHandler(decoder, id, tag->data,
|
||||
tag->newline_count, obj,
|
||||
PARAM_ONDBLCLICK, ondblclick);
|
||||
PA_FREE(ondblclick);
|
||||
#if 0
|
||||
anchor_data->event_handler_present = TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (id)
|
||||
PA_FREE(id);
|
||||
LO_LockLayout();
|
||||
}
|
||||
|
||||
LM_PutMochaDecoder(decoder);
|
||||
return obj;
|
||||
}
|
||||
|
||||
JSBool PR_CALLBACK
|
||||
span_setProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
JSSpan *span;
|
||||
lo_NameList *name_rec;
|
||||
jsint slot;
|
||||
JSBool ok;
|
||||
LO_Color *rgb;
|
||||
char *font_family, *font_weight, *font_slant;
|
||||
int32 font_size;
|
||||
|
||||
if (!JSVAL_IS_INT(id)) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
slot = JSVAL_TO_INT(id);
|
||||
|
||||
span = JS_GetInstancePrivate(cx, obj, &lm_span_class, NULL);
|
||||
if (!span)
|
||||
{
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
LO_LockLayout();
|
||||
name_rec = LO_GetSpanByIndex(span->decoder->window_context,
|
||||
span->layer_id,
|
||||
span->index);
|
||||
if (!name_rec)
|
||||
{
|
||||
LO_UnlockLayout();
|
||||
return JS_TRUE; /* Try to handle this case gracefully. */
|
||||
}
|
||||
|
||||
ok = JS_TRUE;
|
||||
|
||||
switch (slot)
|
||||
{
|
||||
case SPAN_COLOR:
|
||||
LO_UnlockLayout();
|
||||
if (!lm_jsval_to_rgb(cx, vp, &rgb))
|
||||
return JS_FALSE;
|
||||
ET_TweakSpan(span->decoder->window_context, name_rec,
|
||||
rgb, 0, SP_SetColor, span->decoder->doc_id);
|
||||
break;
|
||||
case SPAN_BGCOLOR:
|
||||
LO_UnlockLayout();
|
||||
if (!lm_jsval_to_rgb(cx, vp, &rgb))
|
||||
return JS_FALSE;
|
||||
ET_TweakSpan(span->decoder->window_context, name_rec,
|
||||
rgb, 0, SP_SetBackground, span->decoder->doc_id);
|
||||
break;
|
||||
case SPAN_FONTFAMILY:
|
||||
LO_UnlockLayout();
|
||||
font_family = JS_GetStringBytes(JSVAL_TO_STRING(*vp));
|
||||
ET_TweakSpan(span->decoder->window_context, name_rec,
|
||||
font_family, 0, SP_SetFontFamily, span->decoder->doc_id);
|
||||
break;
|
||||
case SPAN_FONTWEIGHT:
|
||||
LO_UnlockLayout();
|
||||
font_weight = JS_GetStringBytes(JSVAL_TO_STRING(*vp));
|
||||
ET_TweakSpan(span->decoder->window_context, name_rec,
|
||||
font_weight, 0, SP_SetFontWeight, span->decoder->doc_id);
|
||||
break;
|
||||
case SPAN_FONTSIZE:
|
||||
LO_UnlockLayout();
|
||||
font_size = JSVAL_TO_INT(*vp);
|
||||
ET_TweakSpan(span->decoder->window_context, name_rec,
|
||||
NULL, font_size, SP_SetFontSize, span->decoder->doc_id);
|
||||
break;
|
||||
case SPAN_FONTSLANT:
|
||||
LO_UnlockLayout();
|
||||
font_slant = JS_GetStringBytes(JSVAL_TO_STRING(*vp));
|
||||
ET_TweakSpan(span->decoder->window_context, name_rec,
|
||||
font_slant, 0, SP_SetFontSlant, span->decoder->doc_id);
|
||||
break;
|
||||
default:
|
||||
ok = JS_FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
JSBool PR_CALLBACK
|
||||
span_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
XP_TRACE (("Span get property called...\n"));
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
void PR_CALLBACK
|
||||
span_Finalize(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
JSSpan *span;
|
||||
MochaDecoder *decoder;
|
||||
MWContext *context;
|
||||
lo_NameList *name_rec;
|
||||
|
||||
span = JS_GetPrivate(cx, obj);
|
||||
if (!span)
|
||||
return;
|
||||
decoder = span->decoder;
|
||||
context = decoder->window_context;
|
||||
if (context) {
|
||||
LO_LockLayout();
|
||||
name_rec = LO_GetSpanByIndex(context, span->layer_id,
|
||||
span->index);
|
||||
if (name_rec && name_rec->mocha_object == obj)
|
||||
name_rec->mocha_object = NULL;
|
||||
LO_UnlockLayout();
|
||||
}
|
||||
DROP_BACK_COUNT(decoder);
|
||||
JS_UnlockGCThing(cx, span->text);
|
||||
JS_UnlockGCThing(cx, span->name);
|
||||
JS_free(cx, span);
|
||||
}
|
||||
|
||||
JSBool
|
||||
lm_InitSpanClass(MochaDecoder *decoder)
|
||||
{
|
||||
JSContext *cx;
|
||||
JSObject *prototype;
|
||||
|
||||
cx = decoder->js_context;
|
||||
prototype = JS_InitClass(cx, decoder->window_object,
|
||||
decoder->event_receiver_prototype,
|
||||
&lm_span_class, Span, 0,
|
||||
span_props, NULL, NULL, NULL);
|
||||
if (!prototype)
|
||||
return JS_FALSE;
|
||||
decoder->span_prototype = prototype;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
#endif /* DOM */
|
|
@ -1,429 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/*
|
||||
* JS reflection of XML transclusions in the current document.
|
||||
*
|
||||
* Nisheeth Ranjan, 04-Apr-1998
|
||||
*/
|
||||
|
||||
#ifdef DOM
|
||||
|
||||
#include "lm.h"
|
||||
#include "lo_ele.h"
|
||||
#include "layout.h"
|
||||
#include "prtypes.h"
|
||||
|
||||
|
||||
enum transclusion_array_slot {
|
||||
TRANSCLUSION_ARRAY_LENGTH = -1
|
||||
};
|
||||
|
||||
static JSPropertySpec transclusion_array_props[] = {
|
||||
{ lm_length_str, TRANSCLUSION_ARRAY_LENGTH,
|
||||
JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT},
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
extern JSClass lm_transclusion_array_class;
|
||||
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
transclusion_array_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
JSObjectArray *array;
|
||||
void *xmlTrans;
|
||||
MochaDecoder *decoder;
|
||||
MWContext *context;
|
||||
jsint count, slot;
|
||||
int32 active_layer_id;
|
||||
|
||||
/* XP_TRACE (("span_array_getProperty called\n")); */
|
||||
|
||||
if (!JSVAL_IS_INT(id))
|
||||
return JS_TRUE;
|
||||
|
||||
slot = JSVAL_TO_INT(id);
|
||||
|
||||
array = JS_GetInstancePrivate(cx, obj, &lm_transclusion_array_class, NULL);
|
||||
if (!array)
|
||||
return JS_TRUE;
|
||||
decoder = array->decoder;
|
||||
context = decoder->window_context;
|
||||
if (!context)
|
||||
return JS_TRUE;
|
||||
|
||||
LO_LockLayout();
|
||||
switch (slot) {
|
||||
case TRANSCLUSION_ARRAY_LENGTH:
|
||||
active_layer_id = LM_GetActiveLayer(context);
|
||||
LM_SetActiveLayer(context, array->layer_id);
|
||||
count = XMLTransclusionCount(context);
|
||||
LM_SetActiveLayer(context, active_layer_id);
|
||||
if (count > array->length)
|
||||
array->length = count;
|
||||
*vp = INT_TO_JSVAL(count);
|
||||
break;
|
||||
|
||||
default:
|
||||
if (slot < 0) {
|
||||
/* Don't mess with user-defined or method properties. */
|
||||
LO_UnlockLayout();
|
||||
return JS_TRUE;
|
||||
}
|
||||
if (slot >= array->length)
|
||||
array->length = slot + 1;
|
||||
|
||||
xmlTrans = XMLGetTransclusionByIndex(context, (uint)slot);
|
||||
/* XP_TRACE (("span = %p\n", span)); */
|
||||
if (xmlTrans) {
|
||||
*vp = OBJECT_TO_JSVAL(LM_ReflectTransclusion(context, xmlTrans, array->layer_id, (uint)slot));
|
||||
}
|
||||
break;
|
||||
}
|
||||
LO_UnlockLayout();
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(void)
|
||||
transclusion_array_finalize(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
JSObjectArray *array;
|
||||
|
||||
array = JS_GetPrivate(cx, obj);
|
||||
if (!array)
|
||||
return;
|
||||
DROP_BACK_COUNT(array->decoder);
|
||||
JS_free(cx, array);
|
||||
}
|
||||
|
||||
JSClass lm_transclusion_array_class = {
|
||||
"TransclusionArray", JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub, JS_PropertyStub,
|
||||
transclusion_array_getProperty, transclusion_array_getProperty, JS_EnumerateStub,
|
||||
JS_ResolveStub, JS_ConvertStub, transclusion_array_finalize
|
||||
};
|
||||
|
||||
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
TransclusionArray(JSContext *cx, JSObject *obj,
|
||||
uint argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSObject *
|
||||
reflect_transclusion_array(MochaDecoder *decoder, JSClass *clasp,
|
||||
JSNative constructor, JSObject *document)
|
||||
{
|
||||
JSContext *cx;
|
||||
JSObject *obj, *prototype;
|
||||
JSObjectArray *array;
|
||||
JSDocument *doc;
|
||||
|
||||
cx = decoder->js_context;
|
||||
doc = JS_GetPrivate(cx, document);
|
||||
if (!doc)
|
||||
return NULL;
|
||||
|
||||
prototype = JS_InitClass(cx, decoder->window_object, NULL,
|
||||
clasp, constructor, 0,
|
||||
transclusion_array_props, NULL, NULL, NULL);
|
||||
if (!prototype)
|
||||
return NULL;
|
||||
array = JS_malloc(cx, sizeof *array);
|
||||
if (!array)
|
||||
return NULL;
|
||||
XP_BZERO(array, sizeof *array);
|
||||
obj = JS_NewObject(cx, clasp, prototype, document);
|
||||
if (!obj || !JS_SetPrivate(cx, obj, array)) {
|
||||
JS_free(cx, array);
|
||||
return NULL;
|
||||
}
|
||||
array->decoder = HOLD_BACK_COUNT(decoder);
|
||||
array->layer_id = doc->layer_id;
|
||||
return obj;
|
||||
}
|
||||
|
||||
JSObject *
|
||||
lm_GetTransclusionArray(MochaDecoder *decoder, JSObject *document)
|
||||
{
|
||||
JSObject *obj;
|
||||
JSDocument *doc;
|
||||
|
||||
doc = JS_GetPrivate(decoder->js_context, document);
|
||||
if (!doc)
|
||||
return NULL;
|
||||
|
||||
obj = doc->transclusions;
|
||||
if (obj)
|
||||
return obj;
|
||||
obj = reflect_transclusion_array(decoder, &lm_transclusion_array_class, TransclusionArray,
|
||||
document);
|
||||
doc->transclusions = obj;
|
||||
return obj;
|
||||
}
|
||||
|
||||
JSBool PR_CALLBACK transclusion_setProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
JSBool PR_CALLBACK transclusion_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
void PR_CALLBACK transclusion_Finalize(JSContext *cx, JSObject *obj);
|
||||
|
||||
enum {
|
||||
/* TRANS_NAME = -1, */
|
||||
TRANS_HREF = -1,
|
||||
TRANS_VISIBILITY = -2,
|
||||
TRANS_DATA = -3
|
||||
};
|
||||
|
||||
static JSPropertySpec transclusion_props[] =
|
||||
{
|
||||
/* {"name", TRANS_NAME, JSPROP_ENUMERATE | JSPROP_READONLY }, */
|
||||
{"href", TRANS_HREF, JSPROP_ENUMERATE },
|
||||
{"visibility", TRANS_VISIBILITY, JSPROP_ENUMERATE },
|
||||
{"data", TRANS_DATA, JSPROP_ENUMERATE },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
static JSClass lm_transclusion_class =
|
||||
{
|
||||
"Transclusion", JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub, JS_PropertyStub,
|
||||
transclusion_getProperty, transclusion_setProperty,
|
||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, transclusion_Finalize
|
||||
};
|
||||
|
||||
/* Base transclusion element type. */
|
||||
typedef struct JSTransclusion {
|
||||
MochaDecoder *decoder;
|
||||
int32 layer_id;
|
||||
uint index;
|
||||
/* JSString *name; */
|
||||
void *xmlFile;
|
||||
} JSTransclusion;
|
||||
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
Transclusion(JSContext *cx, JSObject *obj,
|
||||
uint argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
JSObject *
|
||||
LM_ReflectTransclusion(MWContext *context, lo_NameList *name_rec,
|
||||
PA_Tag * tag, int32 layer_id, uint index)
|
||||
*/
|
||||
JSObject *
|
||||
LM_ReflectTransclusion(MWContext *context, void *ele, int32 layer_id, uint index)
|
||||
{
|
||||
JSObject *obj, *array_obj, *document;
|
||||
MochaDecoder *decoder;
|
||||
JSContext *cx;
|
||||
JSObjectArray *array;
|
||||
JSTransclusion *trans;
|
||||
lo_TopState *top_state;
|
||||
PRHashTable *map;
|
||||
JSString *str;
|
||||
|
||||
|
||||
obj = XML_GetMochaObject(ele);
|
||||
if (obj)
|
||||
return obj;
|
||||
|
||||
decoder = LM_GetMochaDecoder(context);
|
||||
if (!decoder)
|
||||
return NULL;
|
||||
cx = decoder->js_context;
|
||||
|
||||
/* top_state = lo_GetMochaTopState(context);
|
||||
if (top_state->resize_reload) {
|
||||
map = lm_GetIdToObjectMap(decoder);
|
||||
|
||||
if (map)
|
||||
obj = (JSObject *)PR_HashTableLookup(map,
|
||||
LM_GET_MAPPING_KEY(LM_TRANSCLUSIONS,
|
||||
layer_id, index));
|
||||
if (obj) {
|
||||
XML_SetMochaObject(ele, obj);
|
||||
LM_PutMochaDecoder(decoder);
|
||||
return obj;
|
||||
}
|
||||
} */
|
||||
|
||||
/* Get the document object that will hold this transclusion */
|
||||
document = lm_GetDocumentFromLayerId(decoder, layer_id);
|
||||
if (!document) {
|
||||
LM_PutMochaDecoder(decoder);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
array_obj = lm_GetTransclusionArray(decoder, document);
|
||||
if (!array_obj) {
|
||||
LM_PutMochaDecoder(decoder);
|
||||
return NULL;
|
||||
}
|
||||
array = JS_GetPrivate(cx, array_obj);
|
||||
if (!array) {
|
||||
LM_PutMochaDecoder(decoder);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
trans = JS_malloc(cx, sizeof *trans);
|
||||
if (!trans) {
|
||||
LM_PutMochaDecoder(decoder);
|
||||
return NULL;
|
||||
}
|
||||
XP_BZERO(trans, sizeof *trans);
|
||||
|
||||
obj = JS_NewObject(cx, &lm_transclusion_class, decoder->transclusion_prototype,
|
||||
document);
|
||||
|
||||
if (!obj || !JS_SetPrivate(cx, obj, trans)) {
|
||||
JS_free(cx, trans);
|
||||
LM_PutMochaDecoder(decoder);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Put obj into the document.transclusions array. */
|
||||
/*
|
||||
JS_DefineProperty(cx, array_obj, (char *) name_rec->name,
|
||||
OBJECT_TO_JSVAL(obj), NULL, NULL,
|
||||
JSPROP_ENUMERATE|JSPROP_READONLY);
|
||||
JS_AliasElement(cx, array_obj, (char *) name_rec->name, index);
|
||||
*/
|
||||
|
||||
/* Put it in the index to object hash table */
|
||||
map = lm_GetIdToObjectMap(decoder);
|
||||
if (map) {
|
||||
PR_HashTableAdd(map,
|
||||
LM_GET_MAPPING_KEY(LM_TRANSCLUSIONS, layer_id, index),
|
||||
obj);
|
||||
}
|
||||
if ((jsint) index >= array->length)
|
||||
array->length = index + 1;
|
||||
|
||||
trans->decoder = HOLD_BACK_COUNT(decoder);
|
||||
trans->layer_id = layer_id;
|
||||
trans->index = index;
|
||||
trans->xmlFile = context->xmlfile;
|
||||
/*
|
||||
str = JS_NewStringCopyZ(cx, (char *) name_rec->name);
|
||||
if (!str || !JS_LockGCThing(cx, str)) {
|
||||
LM_PutMochaDecoder(decoder);
|
||||
return NULL;
|
||||
}
|
||||
trans->name = str;
|
||||
*/
|
||||
XML_SetMochaObject(ele, obj);
|
||||
|
||||
LM_PutMochaDecoder(decoder);
|
||||
return obj;
|
||||
}
|
||||
|
||||
JSBool PR_CALLBACK
|
||||
transclusion_setProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
JSTransclusion *trans;
|
||||
jsint slot;
|
||||
JSBool ok;
|
||||
char *url;
|
||||
|
||||
XP_ASSERT(JSVAL_IS_INT(id));
|
||||
slot = JSVAL_TO_INT(id);
|
||||
|
||||
trans = JS_GetInstancePrivate(cx, obj, &lm_transclusion_class, NULL);
|
||||
if (!trans)
|
||||
{
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
ok = JS_TRUE;
|
||||
|
||||
switch (slot)
|
||||
{
|
||||
case TRANS_HREF:
|
||||
url = JS_GetStringBytes(JSVAL_TO_STRING(*vp));
|
||||
ET_TweakTransclusion(trans->decoder->window_context, trans->xmlFile, url, trans->index, TR_SetHref, trans->decoder->doc_id);
|
||||
break;
|
||||
default:
|
||||
ok = JS_FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
JSBool PR_CALLBACK
|
||||
transclusion_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
XP_TRACE (("Transclusion get property called...\n"));
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
void PR_CALLBACK
|
||||
transclusion_Finalize(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
JSTransclusion *trans;
|
||||
MochaDecoder *decoder;
|
||||
MWContext *context;
|
||||
|
||||
trans = JS_GetPrivate(cx, obj);
|
||||
if (!trans)
|
||||
return;
|
||||
decoder = trans->decoder;
|
||||
context = decoder->window_context;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
if (context) {
|
||||
LO_LockLayout();
|
||||
name_rec = LO_GetSpanByIndex(context, span->layer_id,
|
||||
span->index);
|
||||
if (name_rec && name_rec->mocha_object == obj)
|
||||
name_rec->mocha_object = NULL;
|
||||
LO_UnlockLayout();
|
||||
}
|
||||
*/
|
||||
|
||||
XMLDeleteMochaObjectReference(trans->xmlFile, trans->index);
|
||||
|
||||
DROP_BACK_COUNT(decoder);
|
||||
/*
|
||||
JS_UnlockGCThing(cx, trans->text);
|
||||
JS_UnlockGCThing(cx, trans->name);
|
||||
*/
|
||||
JS_free(cx, trans);
|
||||
}
|
||||
|
||||
JSBool
|
||||
lm_InitTransclusionClass(MochaDecoder *decoder)
|
||||
{
|
||||
JSContext *cx;
|
||||
JSObject *prototype;
|
||||
|
||||
cx = decoder->js_context;
|
||||
prototype = JS_InitClass(cx, decoder->window_object,
|
||||
decoder->event_receiver_prototype,
|
||||
&lm_transclusion_class, Transclusion, 0,
|
||||
transclusion_props, NULL, NULL, NULL);
|
||||
if (!prototype)
|
||||
return JS_FALSE;
|
||||
decoder->transclusion_prototype = prototype;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
#endif /* DOM */
|
|
@ -3194,10 +3194,6 @@ lm_NewWindow(MWContext *context)
|
|||
HOLD(decoder->option_prototype);
|
||||
HOLD(decoder->rect_prototype);
|
||||
HOLD(decoder->url_prototype);
|
||||
#ifdef DOM
|
||||
HOLD(decoder->span_prototype);
|
||||
HOLD(decoder->transclusion_prototype);
|
||||
#endif
|
||||
|
||||
/* Drop window sub-object refs. */
|
||||
HOLD(decoder->document);
|
||||
|
@ -3256,11 +3252,6 @@ lm_DestroyWindow(MochaDecoder *decoder)
|
|||
DROP(decoder->option_prototype);
|
||||
DROP(decoder->rect_prototype);
|
||||
DROP(decoder->url_prototype);
|
||||
#ifdef DOM
|
||||
DROP(decoder->span_prototype);
|
||||
DROP(decoder->transclusion_prototype);
|
||||
#endif
|
||||
|
||||
|
||||
/* Drop window sub-object refs. */
|
||||
DROP(decoder->document);
|
||||
|
@ -3397,10 +3388,7 @@ lm_DefineWindowProps(JSContext *cx, MochaDecoder *decoder)
|
|||
lm_InitImageClass(decoder) &&
|
||||
lm_InitAnchorClass(decoder) &&
|
||||
#ifdef DOM
|
||||
/* the order of lm_DOMInit* is significant -- be careful */
|
||||
lm_DOMInit(decoder) &&
|
||||
lm_InitSpanClass(decoder) &&
|
||||
lm_InitTransclusionClass(decoder) &&
|
||||
#endif
|
||||
lm_InitBuiltinClass(decoder) &&
|
||||
lm_InitInputClasses(decoder) &&
|
||||
|
@ -3496,11 +3484,6 @@ lm_FreeWindowContent(MochaDecoder *decoder, JSBool fromDiscard)
|
|||
#endif
|
||||
CLEAR(decoder->pkcs11);
|
||||
|
||||
#ifdef DOM
|
||||
CLEAR(decoder->span_prototype);
|
||||
CLEAR(decoder->transclusion_prototype);
|
||||
#endif
|
||||
|
||||
/* Drop ad-hoc GC roots, but not opener -- it survives unloads. */
|
||||
CLEAR(decoder->event_receiver);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче