Dylan Smith : richedit: Removed redundant editor height variables and calculations.

Alexandre Julliard julliard at winehq.org
Sat Dec 20 06:35:39 CST 2008


Module: wine
Branch: master
Commit: dc03b6b2f25cc4aa63ad2776943f55fd3f5aa656
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=dc03b6b2f25cc4aa63ad2776943f55fd3f5aa656

Author: Dylan Smith <dylan.ah.smith at gmail.com>
Date:   Fri Dec 19 08:15:04 2008 -0500

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 a9994bc..58301aa 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 0c8435b..cde05f9 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 521f646..0e12191 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 d989a2d..890c2bd 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;




More information about the wine-cvs mailing list