add elements for SUPER and SUB, so that we don't lose the basline adjustment on resize (bug 313426).
git-svn-id: svn://10.0.0.236/trunk@7886 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
e3c22b329f
commit
8cf64a1e7a
@ -111,20 +111,22 @@
|
||||
#define LO_SCRIPT 13
|
||||
#define LO_OBJECT 14
|
||||
#define LO_PARAGRAPH 15
|
||||
#define LO_CENTER 16
|
||||
#define LO_CENTER 16
|
||||
#define LO_MULTICOLUMN 17
|
||||
#define LO_FLOAT 18
|
||||
#define LO_FLOAT 18
|
||||
#define LO_TEXTBLOCK 19
|
||||
#define LO_LIST 20
|
||||
#define LO_LIST 20
|
||||
#define LO_DESCTITLE 21
|
||||
#define LO_DESCTEXT 22
|
||||
#define LO_DESCTEXT 22
|
||||
#define LO_BLOCKQUOTE 23
|
||||
#define LO_LAYER 24
|
||||
#define LO_HEADING 25
|
||||
#define LO_SPAN 26
|
||||
#define LO_DIV 27
|
||||
#define LO_LAYER 24
|
||||
#define LO_HEADING 25
|
||||
#define LO_SPAN 26
|
||||
#define LO_DIV 27
|
||||
#define LO_BUILTIN 28
|
||||
#define LO_SPACER 29
|
||||
#define LO_SPACER 29
|
||||
#define LO_SUPER 30
|
||||
#define LO_SUB 31
|
||||
|
||||
#define LO_FONT_NORMAL 0x0000
|
||||
#define LO_FONT_BOLD 0x0001
|
||||
@ -1127,6 +1129,20 @@ typedef struct LO_SpacerStruct_struct {
|
||||
PA_Tag *tag;
|
||||
} LO_SpacerStruct;
|
||||
|
||||
typedef struct LO_SuperStruct_struct {
|
||||
LO_Any lo_any;
|
||||
|
||||
int32 baseline_adj;
|
||||
Bool is_end;
|
||||
} LO_SuperStruct;
|
||||
|
||||
typedef struct LO_SubStruct_struct {
|
||||
LO_Any lo_any;
|
||||
|
||||
int32 baseline_adj;
|
||||
Bool is_end;
|
||||
} LO_SubStruct;
|
||||
|
||||
typedef struct LO_NoBreakStruct_struct {
|
||||
LO_Any lo_any;
|
||||
|
||||
@ -1247,13 +1263,15 @@ union LO_Element_struct {
|
||||
LO_ListStruct lo_list;
|
||||
LO_DescTitleStruct lo_desctitle;
|
||||
LO_DescTextStruct lo_desctext;
|
||||
LO_BlockQuoteStruct lo_blockquote;
|
||||
LO_LayerStruct lo_layer;
|
||||
LO_HeadingStruct lo_heading;
|
||||
LO_SpanStruct lo_span;
|
||||
LO_DivStruct lo_div;
|
||||
LO_SpacerStruct lo_spacer;
|
||||
LO_BuiltinStruct lo_builtin;
|
||||
LO_BlockQuoteStruct lo_blockquote;
|
||||
LO_LayerStruct lo_layer;
|
||||
LO_HeadingStruct lo_heading;
|
||||
LO_SpanStruct lo_span;
|
||||
LO_DivStruct lo_div;
|
||||
LO_SpacerStruct lo_spacer;
|
||||
LO_BuiltinStruct lo_builtin;
|
||||
LO_SuperStruct lo_super;
|
||||
LO_SubStruct lo_sub;
|
||||
};
|
||||
|
||||
struct LO_ObjectStruct_struct {
|
||||
|
||||
@ -825,6 +825,8 @@ lo_DisplayElement(MWContext *context, LO_Element *tptr,
|
||||
case LO_BLOCKQUOTE:
|
||||
case LO_HEADING:
|
||||
case LO_SPAN:
|
||||
case LO_SUB:
|
||||
case LO_SUPER:
|
||||
/* all non-display, doc-state mutating elements. */
|
||||
break;
|
||||
case LO_TEXTBLOCK:
|
||||
|
||||
@ -1651,7 +1651,7 @@ lo_VerifyList( MWContext *pContext, lo_TopState* top_state,
|
||||
/*
|
||||
* Does this element have a valid type?
|
||||
*/
|
||||
if ( eptr->lo_any.type < 0 || eptr->lo_any.type > LO_SPACER ) {
|
||||
if ( eptr->lo_any.type < 0 || eptr->lo_any.type > LO_SUB ) {
|
||||
XP_TRACE(("element %ld at address 0x%08x has an unknown type %d.",
|
||||
index, eptr, eptr->lo_any.type));
|
||||
result = FALSE;
|
||||
@ -1748,10 +1748,12 @@ lo_PrintLayoutElement(MWContext *pContext, lo_TopState* top_state,
|
||||
"LO_SPAN",
|
||||
"LO_DIV",
|
||||
"LO_BUILTIN",
|
||||
"LO_SPACER"
|
||||
"LO_SPACER",
|
||||
"LO_SUPER",
|
||||
"LO_SUB"
|
||||
};
|
||||
type = eptr->lo_any.type;
|
||||
if ( type < LO_UNKNOWN || type > LO_SPACER ) typeString = "Illegal type";
|
||||
if ( type < LO_UNKNOWN || type > LO_SUB ) typeString = "Illegal type";
|
||||
else typeString = kTypeStrings[type + 1];
|
||||
|
||||
XP_TRACE(("[%d] 0x%08x type %s(%d) ele_id %d",
|
||||
|
||||
@ -1269,6 +1269,12 @@ extern void lo_ReflectFormElement(MWContext *context,
|
||||
LO_FormElementStruct *form_element);
|
||||
|
||||
|
||||
extern void lo_ProcessSuperElement(MWContext *context,
|
||||
lo_DocState *state,
|
||||
LO_SuperStruct *super);
|
||||
extern void lo_ProcessSubElement(MWContext *context,
|
||||
lo_DocState *state,
|
||||
LO_SubStruct *sub);
|
||||
extern void lo_ProcessParagraphElement(MWContext *context, lo_DocState **state,
|
||||
LO_ParagraphStruct *paragraph,
|
||||
XP_Bool in_relayout);
|
||||
|
||||
@ -99,6 +99,8 @@ static LO_Element * lo_rl_FitHeading( lo_RelayoutState *relay_state, LO_Element
|
||||
static LO_Element * lo_rl_FitSpan( lo_RelayoutState *relay_state, LO_Element *lo_ele );
|
||||
static LO_Element * lo_rl_FitDiv( lo_RelayoutState *relay_state, LO_Element *lo_ele );
|
||||
static LO_Element * lo_rl_FitSpacer( lo_RelayoutState *relay_state, LO_Element *lo_ele );
|
||||
static LO_Element * lo_rl_FitSuper( lo_RelayoutState *relay_state, LO_Element *lo_ele );
|
||||
static LO_Element * lo_rl_FitSub( lo_RelayoutState *relay_state, LO_Element *lo_ele );
|
||||
|
||||
/* The table of fitting functions for each layout element type... */
|
||||
static lo_FitFunction lo_rl_FitFunctionTable[] = {
|
||||
@ -119,19 +121,21 @@ static lo_FitFunction lo_rl_FitFunctionTable[] = {
|
||||
lo_rl_FitObject, /* LO_OBJECT */
|
||||
lo_rl_FitParagraph, /* LO_PARAGRAPH */
|
||||
lo_rl_FitCenter, /* LO_CENTER */
|
||||
lo_rl_FitMulticolumn, /* LO_MULTICOLUMN */
|
||||
lo_rl_FitMulticolumn, /* LO_MULTICOLUMN */
|
||||
lo_rl_FitFloat, /* LO_FLOAT */
|
||||
lo_rl_FitTextBlock, /* LO_TEXTBLOCK */
|
||||
lo_rl_FitList, /* LO_LIST */
|
||||
lo_rl_FitDescTitle, /* LO_DESCTITLE */
|
||||
lo_rl_FitDescText, /* LO_DESCTEXT */
|
||||
lo_rl_FitBlockQuote, /* LO_BLOCKQUOTE */
|
||||
lo_rl_FitBlockQuote, /* LO_BLOCKQUOTE */
|
||||
lo_rl_FitLayer, /* LO_LAYER */
|
||||
lo_rl_FitHeading, /* LO_HEADING */
|
||||
lo_rl_FitSpan, /* LO_SPAN */
|
||||
lo_rl_FitDiv, /* LO_DIV */
|
||||
lo_rl_FitBuiltin, /* LO_BUILTIN */
|
||||
lo_rl_FitSpacer /* LO_SPACER */
|
||||
lo_rl_FitSpacer, /* LO_SPACER */
|
||||
lo_rl_FitSuper, /* LO_SUPER */
|
||||
lo_rl_FitSub /* LO_SUB */
|
||||
};
|
||||
|
||||
|
||||
@ -1574,6 +1578,44 @@ lo_rl_FitSpacer( lo_RelayoutState *relay_state, LO_Element *lo_ele )
|
||||
return next;
|
||||
}
|
||||
|
||||
static LO_Element * lo_rl_FitSuper( lo_RelayoutState *relay_state, LO_Element *lo_ele )
|
||||
{
|
||||
LO_Element *next = lo_tv_GetNextLayoutElement( relay_state->doc_state, lo_ele, TRUE);
|
||||
LO_SuperStruct *super = (LO_SuperStruct *) lo_ele;
|
||||
lo_DocState *state = relay_state->doc_state;
|
||||
MWContext *context = relay_state->context;
|
||||
|
||||
/* Put the LO_SUPER element back on the line list */
|
||||
super->lo_any.x = state->x;
|
||||
super->lo_any.y = state->y;
|
||||
super->lo_any.ele_id = state->top_state->element_id++;
|
||||
lo_AppendToLineList(context, state, lo_ele, 0);
|
||||
|
||||
/* Relayout the SUPER element */
|
||||
lo_ProcessSuperElement(context, state, super);
|
||||
|
||||
return next;
|
||||
}
|
||||
|
||||
static LO_Element * lo_rl_FitSub( lo_RelayoutState *relay_state, LO_Element *lo_ele )
|
||||
{
|
||||
LO_Element *next = lo_tv_GetNextLayoutElement( relay_state->doc_state, lo_ele, TRUE);
|
||||
LO_SubStruct *sub = (LO_SubStruct *) lo_ele;
|
||||
lo_DocState *state = relay_state->doc_state;
|
||||
MWContext *context = relay_state->context;
|
||||
|
||||
/* Put the LO_SUB element back on the line list */
|
||||
sub->lo_any.x = state->x;
|
||||
sub->lo_any.y = state->y;
|
||||
sub->lo_any.ele_id = state->top_state->element_id++;
|
||||
lo_AppendToLineList(context, state, lo_ele, 0);
|
||||
|
||||
/* Relayout the SUB element */
|
||||
lo_ProcessSubElement(context, state, sub);
|
||||
|
||||
return next;
|
||||
}
|
||||
|
||||
static LO_Element * lo_rl_FitSpan( lo_RelayoutState *relay_state, LO_Element *lo_ele )
|
||||
{
|
||||
#ifndef DOM
|
||||
|
||||
@ -438,6 +438,40 @@ lo_pop_paragraph_from_style_stack(lo_DocState **state,
|
||||
LO_PopStyleTagByIndex(context, state, P_PARAGRAPH, index);
|
||||
}
|
||||
|
||||
void
|
||||
lo_ProcessSuperElement(MWContext *context,
|
||||
lo_DocState *state,
|
||||
LO_SuperStruct *super)
|
||||
{
|
||||
if (super->is_end == FALSE)
|
||||
{
|
||||
state->baseline -=
|
||||
super->baseline_adj;
|
||||
}
|
||||
else
|
||||
{
|
||||
state->baseline +=
|
||||
super->baseline_adj;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
lo_ProcessSubElement(MWContext *context,
|
||||
lo_DocState *state,
|
||||
LO_SubStruct *sub)
|
||||
{
|
||||
if (sub->is_end == FALSE)
|
||||
{
|
||||
state->baseline +=
|
||||
sub->baseline_adj;
|
||||
}
|
||||
else
|
||||
{
|
||||
state->baseline -=
|
||||
sub->baseline_adj;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
lo_ProcessParagraphElement(MWContext *context,
|
||||
lo_DocState **state,
|
||||
@ -5119,20 +5153,32 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type));
|
||||
FE_GetTextInfo(context, &tmp_text, &text_info);
|
||||
PA_FREE(buff);
|
||||
|
||||
if (tag->is_end == FALSE)
|
||||
{
|
||||
state->baseline +=
|
||||
(text_info.ascent / 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
LO_TextAttr *attr;
|
||||
{
|
||||
LO_SubStruct *sub = (LO_SubStruct*)lo_NewElement(context, state, LO_SUB, NULL, 0);
|
||||
|
||||
XP_ASSERT(sub);
|
||||
if (!sub)
|
||||
{
|
||||
LO_UnlockLayout();
|
||||
return;
|
||||
}
|
||||
|
||||
state->baseline -=
|
||||
(text_info.ascent / 2);
|
||||
sub->lo_any.type = LO_SUB;
|
||||
sub->lo_any.ele_id = NEXT_ELEMENT;
|
||||
|
||||
sub->is_end = tag->is_end;
|
||||
sub->baseline_adj = text_info.ascent / 2;
|
||||
|
||||
lo_AppendToLineList(context, state, (LO_Element*)sub, 0);
|
||||
|
||||
lo_ProcessSubElement(context, state, sub);
|
||||
}
|
||||
|
||||
if (tag->is_end == TRUE)
|
||||
{
|
||||
LO_TextAttr *attr = lo_PopFont(state, tag->type);
|
||||
}
|
||||
|
||||
attr = lo_PopFont(state, tag->type);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@ -5189,20 +5235,30 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type));
|
||||
FE_GetTextInfo(context, &tmp_text, &text_info);
|
||||
PA_FREE(buff);
|
||||
|
||||
if (tag->is_end == FALSE)
|
||||
{
|
||||
state->baseline -=
|
||||
(text_info.ascent / 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
LO_TextAttr *attr;
|
||||
{
|
||||
LO_SuperStruct *super = (LO_SuperStruct*)lo_NewElement(context, state, LO_SUPER, NULL, 0);
|
||||
|
||||
XP_ASSERT(super);
|
||||
if (!super)
|
||||
{
|
||||
LO_UnlockLayout();
|
||||
return;
|
||||
}
|
||||
|
||||
state->baseline +=
|
||||
(text_info.ascent / 2);
|
||||
super->lo_any.type = LO_SUPER;
|
||||
super->lo_any.ele_id = NEXT_ELEMENT;
|
||||
super->is_end = tag->is_end;
|
||||
super->baseline_adj = text_info.ascent / 2;
|
||||
|
||||
attr = lo_PopFont(state, tag->type);
|
||||
}
|
||||
lo_AppendToLineList(context, state, (LO_Element*)super, 0);
|
||||
|
||||
lo_ProcessSuperElement(context, state, super);
|
||||
}
|
||||
|
||||
if (tag->is_end == TRUE)
|
||||
{
|
||||
LO_TextAttr *attr = lo_PopFont(state, tag->type);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@ -2052,6 +2052,12 @@ lo_NewElement(MWContext *context, lo_DocState *state, intn type,
|
||||
case LO_FLOAT:
|
||||
size = sizeof(LO_FloatStruct);
|
||||
break;
|
||||
case LO_SUPER:
|
||||
size = sizeof(LO_SuperStruct);
|
||||
break;
|
||||
case LO_SUB:
|
||||
size = sizeof(LO_SubStruct);
|
||||
break;
|
||||
default:
|
||||
size = sizeof(LO_Any);
|
||||
break;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user