mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-25 03:49:42 +00:00
Fixed P0 Composer bug 312249 (backspacing when lines wrap) with help/review/approval by nisheeth. Also layout's part of fix to 310966 (changing doc colorsof current windows)
This commit is contained in:
parent
6f585babe9
commit
9076fefa9f
@ -795,6 +795,8 @@ LO_SetDocumentColor(MWContext *context, int type, LO_Color *color)
|
||||
LO_SetDocBgColor(context, color);
|
||||
break;
|
||||
case LO_COLOR_FG:
|
||||
/* Note: The color will be changed only if no one else
|
||||
has called this function before */
|
||||
lo_ChangeBodyTextFGColor(context, doc_state, color);
|
||||
break;
|
||||
case LO_COLOR_LINK:
|
||||
|
@ -903,6 +903,9 @@ extern Bool lo_ChangeText ( LO_TextBlock * block, char * text );
|
||||
extern void lo_FlushLineBuffer(MWContext *, lo_DocState *);
|
||||
extern void lo_FlushTextBlock ( MWContext *context, lo_DocState *state );
|
||||
extern void lo_ResetFontStack(MWContext *, lo_DocState *);
|
||||
/* This always sets the color. "state" will be obtained in function if NULL */
|
||||
extern void lo_SetBodyTextFGColor(MWContext *context, lo_DocState *state, LO_Color *color);
|
||||
/* This sets the color only the first time its called for one GetURL+layout cycle */
|
||||
extern void lo_ChangeBodyTextFGColor(MWContext *context, lo_DocState *state, LO_Color *color);
|
||||
extern void lo_PushFont(lo_DocState *, intn, LO_TextAttr *);
|
||||
extern LO_TextAttr *lo_PopFont(lo_DocState *, intn);
|
||||
|
@ -1229,12 +1229,26 @@ lo_BumpPosition(MWContext *context, lo_DocState *state, LO_Position* position, B
|
||||
PRIVATE
|
||||
Bool lo_ValidEditableElement(MWContext *context, LO_Element* eptr)
|
||||
{
|
||||
XP_Bool bEditable = FALSE;
|
||||
|
||||
if( eptr )
|
||||
return lo_EditableElement(eptr->type) &&
|
||||
{
|
||||
bEditable = lo_EditableElement(eptr->type) &&
|
||||
( (!EDT_IS_EDITOR(context) ) ||
|
||||
(eptr->lo_any.edit_element != 0 &&
|
||||
eptr->lo_any.edit_offset >= 0));
|
||||
return FALSE;
|
||||
/* cmanske. Not sure why these are created,
|
||||
but after backspacing from the beginning of line 2 of wrapped text,
|
||||
then type a space to cause wrapping again, a 0-len lo_text element
|
||||
is inserted. It stops caret navigation of left arrow from
|
||||
the 2nd line up to the end of the first.
|
||||
This fixes that, but now the caret moves 1 char too far into
|
||||
the 1st line (should be after the last visible char and before the space,
|
||||
but its before the last visible char. */
|
||||
if( bEditable && eptr->type == LO_TEXT && eptr->lo_text.text_len == 0 )
|
||||
bEditable = FALSE;
|
||||
}
|
||||
return bEditable;
|
||||
}
|
||||
|
||||
PRIVATE
|
||||
|
@ -3455,17 +3455,46 @@ lo_FlushTextBlock ( MWContext *context, lo_DocState *state )
|
||||
state->cur_text_block = NULL;
|
||||
}
|
||||
|
||||
/* Only the first call here actually changes the text color */
|
||||
void
|
||||
lo_ChangeBodyTextFGColor(MWContext *context, lo_DocState *state,
|
||||
LO_Color *color)
|
||||
lo_ChangeBodyTextFGColor(MWContext *context, lo_DocState *state, LO_Color *color)
|
||||
{
|
||||
if( (state->top_state->body_attr & BODY_ATTR_TEXT) != 0)
|
||||
return;
|
||||
|
||||
/* Set the flag so we don't change the color again
|
||||
unless we relayout from the URL again.
|
||||
*/
|
||||
state->top_state->body_attr |= BODY_ATTR_TEXT;
|
||||
|
||||
lo_SetBodyTextFGColor(context, state, color);
|
||||
}
|
||||
|
||||
|
||||
/* This REALLY sets the color. "state" may be NULL and it will be figured out */
|
||||
void
|
||||
lo_SetBodyTextFGColor(MWContext *context, lo_DocState *state, LO_Color *color)
|
||||
{
|
||||
int32 doc_id;
|
||||
lo_TopState *top_state;
|
||||
lo_FontStack *fptr;
|
||||
LO_TextAttr *attr;
|
||||
|
||||
if ((state->top_state->body_attr & BODY_ATTR_TEXT) != 0)
|
||||
return;
|
||||
|
||||
state->top_state->body_attr |= BODY_ATTR_TEXT;
|
||||
if( !context )
|
||||
return;
|
||||
|
||||
if( !state )
|
||||
{
|
||||
doc_id = XP_DOCID(context);
|
||||
top_state = lo_FetchTopState(doc_id);
|
||||
if (top_state != NULL && top_state->doc_state == NULL)
|
||||
return;
|
||||
|
||||
state = top_state->doc_state;
|
||||
|
||||
if (color == NULL)
|
||||
color = &lo_master_colors[LO_COLOR_FG];
|
||||
}
|
||||
|
||||
state->text_fg = *color;
|
||||
fptr = state->font_stack;
|
||||
@ -6430,7 +6459,16 @@ void lo_LayoutTextBlock ( MWContext * context, lo_DocState * state, Bool flushLa
|
||||
text_data->prev = NULL;
|
||||
|
||||
text_data->text = (PA_Block) text;
|
||||
text_data->text_len = lineLength;
|
||||
/* HACK: The editor needs spaces to be included in the length of the last text element on a line.
|
||||
If we do not do this, navigation between lines gets broken. So, for "1111 2222", if we break the
|
||||
line after the first number, the text element should contain "1111 " rather than "1111". The fix is
|
||||
to add 1 to the length of the text element once we have ensured that the extra character being added
|
||||
is a space and that this text element is going to be followed by a linebreak. */
|
||||
if (EDT_IS_EDITOR( context ) && !allTextFits && !justify && XP_IS_SPACE(((char *) text_data->text)[lineLength]))
|
||||
text_data->text_len = lineLength + 1;
|
||||
else
|
||||
text_data->text_len = lineLength;
|
||||
|
||||
|
||||
text_data->anchor_href = block->anchor_href;
|
||||
text_data->text_attr = block->text_attr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user