From dc03b6b2f25cc4aa63ad2776943f55fd3f5aa656 Mon Sep 17 00:00:00 2001 From: Dylan Smith Date: Fri, 19 Dec 2008 08:15:04 -0500 Subject: [PATCH] richedit: Removed redundant editor height variables and calculations. During wrapping there were three different heights that were being stored, with only one of them being done correctly. The other ones failed to incorporate the height of the paragraph or row, so ended up being incorrect. --- dlls/riched20/editor.c | 1 - dlls/riched20/editstr.h | 1 - dlls/riched20/paint.c | 4 ++-- dlls/riched20/wrap.c | 15 +-------------- 4 files changed, 3 insertions(+), 18 deletions(-) diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index a9994bc9820..58301aaeeb1 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -2605,7 +2605,6 @@ ME_TextEditor *ME_MakeEditor(HWND hWnd) { ed->pCursors[2] = ed->pCursors[0]; ed->pCursors[3] = ed->pCursors[1]; ed->nLastTotalLength = ed->nTotalLength = 0; - ed->nHeight = 0; ed->nUDArrowX = -1; ed->nSequence = 0; ed->rgbBackColor = -1; diff --git a/dlls/riched20/editstr.h b/dlls/riched20/editstr.h index 0c8435bdad4..cde05f933ee 100644 --- a/dlls/riched20/editstr.h +++ b/dlls/riched20/editstr.h @@ -333,7 +333,6 @@ typedef struct tagME_TextEditor int nCursors; SIZE sizeWindow; int nTotalLength, nLastTotalLength; - int nHeight; int nUDArrowX; int nSequence; COLORREF rgbBackColor; diff --git a/dlls/riched20/paint.c b/dlls/riched20/paint.c index 521f646402f..0e12191128e 100644 --- a/dlls/riched20/paint.c +++ b/dlls/riched20/paint.c @@ -1101,7 +1101,7 @@ void ME_Scroll(ME_TextEditor *editor, int value, int type) hWnd = editor->hWnd; winStyle = GetWindowLongW(hWnd, GWL_STYLE); bScrollBarIsVisible = (winStyle & WS_VSCROLL) != 0; - bScrollBarWillBeVisible = (editor->nHeight > editor->sizeWindow.cy) + bScrollBarWillBeVisible = (editor->nTotalLength > editor->sizeWindow.cy) || (winStyle & ES_DISABLENOSCROLL); if (bScrollBarIsVisible != bScrollBarWillBeVisible) { @@ -1127,7 +1127,7 @@ void ME_UpdateScrollBar(ME_TextEditor *editor) hWnd = editor->hWnd; si.cbSize = sizeof(si); bScrollBarWasVisible = ME_GetYScrollVisible(editor); - bScrollBarWillBeVisible = editor->nHeight > editor->sizeWindow.cy; + bScrollBarWillBeVisible = editor->nTotalLength > editor->sizeWindow.cy; si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS; if (GetWindowLongW(hWnd, GWL_STYLE) & ES_DISABLENOSCROLL) diff --git a/dlls/riched20/wrap.c b/dlls/riched20/wrap.c index d989a2da1cd..890c2bd8870 100644 --- a/dlls/riched20/wrap.c +++ b/dlls/riched20/wrap.c @@ -578,17 +578,14 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor) ME_Context c; BOOL bModified = FALSE; int yStart = -1; - int yLastPos = 0; ME_InitContext(&c, editor, GetDC(editor->hWnd)); c.pt.x = 0; - editor->nHeight = 0; item = editor->pBuffer->pFirst->next; while(item != editor->pBuffer->pLast) { BOOL bRedraw = FALSE; assert(item->type == diParagraph); - editor->nHeight = max(editor->nHeight, item->member.para.pt.y); if ((item->member.para.nFlags & MEPF_REWRAP) || (item->member.para.pt.y != c.pt.y)) bRedraw = TRUE; @@ -605,8 +602,6 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor) bModified = bModified | bRedraw; - yLastPos = max(yLastPos, c.pt.y); - if (item->member.para.nFlags & MEPF_ROWSTART) { ME_DisplayItem *cell = ME_FindItemFwd(item, diCell); @@ -718,18 +713,10 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor) editor->nTotalLength = c.pt.y; editor->pBuffer->pLast->member.para.pt.x = 0; - editor->pBuffer->pLast->member.para.pt.y = yLastPos; + editor->pBuffer->pLast->member.para.pt.y = c.pt.y; ME_DestroyContext(&c, editor->hWnd); - /* Each paragraph may contain multiple rows, which should be scrollable, even - if the containing paragraph has pt.y == 0 */ - item = editor->pBuffer->pFirst; - while ((item = ME_FindItemFwd(item, diStartRow)) != NULL) { - assert(item->type == diStartRow); - editor->nHeight = max(editor->nHeight, item->member.row.pt.y); - } - if (bModified || editor->nTotalLength < editor->nLastTotalLength) ME_InvalidateMarkedParagraphs(editor); return bModified; -- 2.11.4.GIT