From 594f23fa1eb22504a70cac4a7a514cdca509fa4c Mon Sep 17 00:00:00 2001 From: Dylan Smith Date: Fri, 18 May 2012 00:30:03 -0400 Subject: [PATCH] richedit: Invalidate a range of paragraphs without marking them. (cherry picked from commit 10d800b6b805af0636a8aa9c95512fde3093cf33) --- dlls/riched20/editor.h | 5 ++--- dlls/riched20/editstr.h | 1 - dlls/riched20/paint.c | 17 +++++++---------- dlls/riched20/para.c | 9 --------- dlls/riched20/table.c | 14 ++++++++++++++ dlls/riched20/wrap.c | 38 +++++++++++++++----------------------- 6 files changed, 38 insertions(+), 46 deletions(-) diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h index 82d86a2efd0..b9c055fadcc 100644 --- a/dlls/riched20/editor.h +++ b/dlls/riched20/editor.h @@ -187,7 +187,7 @@ void ME_DestroyContext(ME_Context *c) DECLSPEC_HIDDEN; /* wrap.c */ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor) DECLSPEC_HIDDEN; -void ME_InvalidateMarkedParagraphs(ME_TextEditor *editor, ME_DisplayItem *start_para, ME_DisplayItem *end_para) DECLSPEC_HIDDEN; +void ME_InvalidateParagraphRange(ME_TextEditor *editor, ME_DisplayItem *start_para, ME_DisplayItem *last_para) DECLSPEC_HIDDEN; void ME_SendRequestResize(ME_TextEditor *editor, BOOL force) DECLSPEC_HIDDEN; /* para.c */ @@ -201,8 +201,6 @@ void ME_DumpParaStyle(ME_Paragraph *s) DECLSPEC_HIDDEN; void ME_DumpParaStyleToBuf(const PARAFORMAT2 *pFmt, char buf[2048]) DECLSPEC_HIDDEN; BOOL ME_SetSelectionParaFormat(ME_TextEditor *editor, const PARAFORMAT2 *pFmt) DECLSPEC_HIDDEN; void ME_GetSelectionParaFormat(ME_TextEditor *editor, PARAFORMAT2 *pFmt) DECLSPEC_HIDDEN; -/* marks from first up to (but not including) last */ -void ME_MarkForPainting(ME_TextEditor *editor, ME_DisplayItem *first, const ME_DisplayItem *last) DECLSPEC_HIDDEN; void ME_MarkAllForWrapping(ME_TextEditor *editor) DECLSPEC_HIDDEN; void ME_SetDefaultParaFormat(PARAFORMAT2 *pFmt) DECLSPEC_HIDDEN; @@ -261,6 +259,7 @@ ME_DisplayItem *ME_InsertTableCellFromCursor(ME_TextEditor *editor) DECLSPEC_HID ME_DisplayItem *ME_InsertTableRowEndFromCursor(ME_TextEditor *editor) DECLSPEC_HIDDEN; ME_DisplayItem *ME_GetTableRowEnd(ME_DisplayItem *para) DECLSPEC_HIDDEN; ME_DisplayItem *ME_GetTableRowStart(ME_DisplayItem *para) DECLSPEC_HIDDEN; +ME_DisplayItem *ME_GetOuterParagraph(ME_DisplayItem *para) DECLSPEC_HIDDEN; void ME_CheckTablesForCorruption(ME_TextEditor *editor) DECLSPEC_HIDDEN; void ME_ProtectPartialTableDeletion(ME_TextEditor *editor, ME_Cursor *c, int *nChars) DECLSPEC_HIDDEN; ME_DisplayItem* ME_AppendTableRow(ME_TextEditor *editor, ME_DisplayItem *table_row) DECLSPEC_HIDDEN; diff --git a/dlls/riched20/editstr.h b/dlls/riched20/editstr.h index b782ed3e554..8f136cb0fa2 100644 --- a/dlls/riched20/editstr.h +++ b/dlls/riched20/editstr.h @@ -138,7 +138,6 @@ typedef enum { /* this paragraph was already wrapped and hasn't changed, every change resets that flag */ #define MEPF_REWRAP 0x01 -#define MEPF_REPAINT 0x02 /* v4.1 */ #define MEPF_CELL 0x04 /* The paragraph is nested in a cell */ #define MEPF_ROWSTART 0x08 /* Hidden empty paragraph at the start of the row */ diff --git a/dlls/riched20/paint.c b/dlls/riched20/paint.c index 92c34c63afc..0ae33336002 100644 --- a/dlls/riched20/paint.c +++ b/dlls/riched20/paint.c @@ -1274,32 +1274,29 @@ ME_InvalidateSelection(ME_TextEditor *editor) * they can point past the end of the document */ if (editor->nLastSelStart > len || editor->nLastSelEnd > len) { repaint_start = ME_FindItemFwd(editor->pBuffer->pFirst, diParagraph); - repaint_end = editor->pBuffer->pLast; - ME_MarkForPainting(editor, repaint_start, repaint_end); + repaint_end = editor->pBuffer->pLast->member.para.prev_para; } else { /* if the start part of selection is being expanded or contracted... */ if (nStart < editor->nLastSelStart) { repaint_start = sel_start; - repaint_end = editor->pLastSelStartPara->member.para.next_para; + repaint_end = editor->pLastSelStartPara; } else if (nStart > editor->nLastSelStart) { repaint_start = editor->pLastSelStartPara; - repaint_end = sel_start->member.para.next_para; + repaint_end = sel_start; } - ME_MarkForPainting(editor, repaint_start, repaint_end); /* if the end part of selection is being contracted or expanded... */ if (nEnd < editor->nLastSelEnd) { if (!repaint_start) repaint_start = sel_end; - repaint_end = editor->pLastSelEndPara->member.para.next_para; - ME_MarkForPainting(editor, sel_end, repaint_end); + repaint_end = editor->pLastSelEndPara; } else if (nEnd > editor->nLastSelEnd) { if (!repaint_start) repaint_start = editor->pLastSelEndPara; - repaint_end = sel_end->member.para.next_para; - ME_MarkForPainting(editor, editor->pLastSelEndPara, repaint_end); + repaint_end = sel_end; } } - ME_InvalidateMarkedParagraphs(editor, repaint_start, repaint_end); + if (repaint_start) + ME_InvalidateParagraphRange(editor, repaint_start, repaint_end); /* remember the last invalidated position */ ME_GetSelectionOfs(editor, &editor->nLastSelStart, &editor->nLastSelEnd); ME_GetSelectionParas(editor, &editor->pLastSelStartPara, &editor->pLastSelEndPara); diff --git a/dlls/riched20/para.c b/dlls/riched20/para.c index efd3d042e7d..ffa816de543 100644 --- a/dlls/riched20/para.c +++ b/dlls/riched20/para.c @@ -94,15 +94,6 @@ void ME_MarkAllForWrapping(ME_TextEditor *editor) ME_MarkForWrapping(editor, editor->pBuffer->pFirst->member.para.next_para, editor->pBuffer->pLast); } -void ME_MarkForPainting(ME_TextEditor *editor, ME_DisplayItem *first, const ME_DisplayItem *last) -{ - while(first != last && first) - { - first->member.para.nFlags |= MEPF_REPAINT; - first = first->member.para.next_para; - } -} - static void ME_UpdateTableFlags(ME_DisplayItem *para) { para->member.para.pFmt->dwMask |= PFM_TABLE|PFM_TABLEROWDELIMITER; diff --git a/dlls/riched20/table.c b/dlls/riched20/table.c index 053bedf553a..1182550679f 100644 --- a/dlls/riched20/table.c +++ b/dlls/riched20/table.c @@ -172,6 +172,20 @@ ME_DisplayItem* ME_GetTableRowStart(ME_DisplayItem *para) return para; } +ME_DisplayItem* ME_GetOuterParagraph(ME_DisplayItem *para) +{ + if (para->member.para.nFlags & MEPF_ROWEND) + para = para->member.para.prev_para; + while (para->member.para.pCell) + { + para = ME_GetTableRowStart(para); + if (!para->member.para.pCell) + break; + para = ME_FindItemBack(para->member.para.pCell, diParagraph); + } + return para; +} + /* Make a bunch of assertions to make sure tables haven't been corrupted. * * These invariants may not hold true in the middle of streaming in rich text diff --git a/dlls/riched20/wrap.c b/dlls/riched20/wrap.c index ceb87ad22c3..8ac14f93536 100644 --- a/dlls/riched20/wrap.c +++ b/dlls/riched20/wrap.c @@ -589,8 +589,7 @@ static void ME_MarkRepaintEnd(ME_DisplayItem *para, { if (!*repaint_start) *repaint_start = para; - *repaint_end = para->member.para.next_para; - para->member.para.nFlags |= MEPF_REPAINT; + *repaint_end = para; } BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor) @@ -738,42 +737,35 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor) ME_DestroyContext(&c); if (repaint_start || editor->nTotalLength < editor->nLastTotalLength) - { - if (!repaint_start) repaint_start = editor->pBuffer->pFirst; - ME_InvalidateMarkedParagraphs(editor, repaint_start, repaint_end); - } + ME_InvalidateParagraphRange(editor, repaint_start, repaint_end); return !!repaint_start; } -void ME_InvalidateMarkedParagraphs(ME_TextEditor *editor, - ME_DisplayItem *start_para, - ME_DisplayItem *end_para) +void ME_InvalidateParagraphRange(ME_TextEditor *editor, + ME_DisplayItem *start_para, + ME_DisplayItem *last_para) { ME_Context c; RECT rc; int ofs; - ME_DisplayItem *item; ME_InitContext(&c, editor, ITextHost_TxGetDC(editor->texthost)); rc = c.rcView; ofs = editor->vert_si.nPos; - item = start_para; - while(item && item != end_para) { - if (item->member.para.nFlags & MEPF_REPAINT) { - rc.top = c.rcView.top + item->member.para.pt.y - ofs; - rc.bottom = max(rc.top + item->member.para.nHeight, c.rcView.bottom); - ITextHost_TxInvalidateRect(editor->texthost, &rc, TRUE); - item->member.para.nFlags &= ~MEPF_REPAINT; - } - item = item->member.para.next_para; + if (start_para) { + start_para = ME_GetOuterParagraph(start_para); + last_para = ME_GetOuterParagraph(last_para); + rc.top = c.rcView.top + start_para->member.para.pt.y - ofs; + } else { + rc.top = c.rcView.top + editor->nTotalLength - ofs; } if (editor->nTotalLength < editor->nLastTotalLength) - { - rc.top = c.rcView.top + editor->nTotalLength - ofs; rc.bottom = c.rcView.top + editor->nLastTotalLength - ofs; - ITextHost_TxInvalidateRect(editor->texthost, &rc, TRUE); - } + else + rc.bottom = c.rcView.top + last_para->member.para.pt.y + last_para->member.para.nHeight - ofs; + ITextHost_TxInvalidateRect(editor->texthost, &rc, TRUE); + ME_DestroyContext(&c); } -- 2.11.4.GIT