Huw Davies : riched20: Move run extent calculation to wrap.c.
Alexandre Julliard
julliard at winehq.org
Tue Feb 12 13:58:13 CST 2013
Module: wine
Branch: master
Commit: c07212b3d080cf7df18c5bdb4c0e61c37bac618d
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c07212b3d080cf7df18c5bdb4c0e61c37bac618d
Author: Huw Davies <huw at codeweavers.com>
Date: Tue Feb 12 15:48:14 2013 +0000
riched20: Move run extent calculation to wrap.c.
---
dlls/riched20/editor.h | 3 ++-
dlls/riched20/run.c | 26 ++------------------------
dlls/riched20/wrap.c | 29 +++++++++++++++++++++++------
3 files changed, 27 insertions(+), 31 deletions(-)
diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index 4401498..5383f82 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -147,7 +147,8 @@ int ME_CanJoinRuns(const ME_Run *run1, const ME_Run *run2) DECLSPEC_HIDDEN;
void ME_JoinRuns(ME_TextEditor *editor, ME_DisplayItem *p) DECLSPEC_HIDDEN;
ME_DisplayItem *ME_SplitRunSimple(ME_TextEditor *editor, ME_Cursor *cursor) DECLSPEC_HIDDEN;
void ME_UpdateRunFlags(ME_TextEditor *editor, ME_Run *run) DECLSPEC_HIDDEN;
-void ME_CalcRunExtent(ME_Context *c, const ME_Paragraph *para, int startx, ME_Run *run) DECLSPEC_HIDDEN;
+SIZE ME_GetRunSizeCommon(ME_Context *c, const ME_Paragraph *para, ME_Run *run, int nLen,
+ int startx, int *pAscent, int *pDescent) DECLSPEC_HIDDEN;
SIZE ME_GetRunSize(ME_Context *c, const ME_Paragraph *para, ME_Run *run, int nLen, int startx) DECLSPEC_HIDDEN;
void ME_CursorFromCharOfs(ME_TextEditor *editor, int nCharOfs, ME_Cursor *pCursor) DECLSPEC_HIDDEN;
void ME_RunOfsFromCharOfs(ME_TextEditor *editor, int nCharOfs, ME_DisplayItem **ppPara, ME_DisplayItem **ppRun, int *pOfs) DECLSPEC_HIDDEN;
diff --git a/dlls/riched20/run.c b/dlls/riched20/run.c
index 6f9d5b5..37445a1 100644
--- a/dlls/riched20/run.c
+++ b/dlls/riched20/run.c
@@ -530,8 +530,8 @@ int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset)
* Finds width, height, ascent and descent of a run, up to given character
* (nLen).
*/
-static SIZE ME_GetRunSizeCommon(ME_Context *c, const ME_Paragraph *para, ME_Run *run, int nLen,
- int startx, int *pAscent, int *pDescent)
+SIZE ME_GetRunSizeCommon(ME_Context *c, const ME_Paragraph *para, ME_Run *run, int nLen,
+ int startx, int *pAscent, int *pDescent)
{
SIZE size;
int nMaxLen = run->len;
@@ -615,28 +615,6 @@ SIZE ME_GetRunSize(ME_Context *c, const ME_Paragraph *para,
}
/******************************************************************************
- * ME_CalcRunExtent
- *
- * Updates the size of the run (fills width, ascent and descent). The height
- * is calculated based on whole row's ascent and descent anyway, so no need
- * to use it here.
- */
-void ME_CalcRunExtent(ME_Context *c, const ME_Paragraph *para, int startx, ME_Run *run)
-{
- if (run->nFlags & MERF_HIDDEN)
- run->nWidth = 0;
- else
- {
- int nEnd = run->len;
- SIZE size = ME_GetRunSizeCommon(c, para, run, nEnd, startx,
- &run->nAscent, &run->nDescent);
- run->nWidth = size.cx;
- if (!size.cx)
- WARN("size.cx == 0\n");
- }
-}
-
-/******************************************************************************
* ME_SetSelectionCharFormat
*
* Applies a style change, either to a current selection, or to insert cursor
diff --git a/dlls/riched20/wrap.c b/dlls/riched20/wrap.c
index 0531c97..aed04806 100644
--- a/dlls/riched20/wrap.c
+++ b/dlls/riched20/wrap.c
@@ -33,6 +33,23 @@ WINE_DEFAULT_DEBUG_CHANNEL(richedit);
*/
/******************************************************************************
+ * calc_run_extent
+ *
+ * Updates the size of the run (fills width, ascent and descent). The height
+ * is calculated based on whole row's ascent and descent anyway, so no need
+ * to use it here.
+ */
+static void calc_run_extent(ME_Context *c, const ME_Paragraph *para, int startx, ME_Run *run)
+{
+ if (run->nFlags & MERF_HIDDEN) run->nWidth = 0;
+ else
+ {
+ SIZE size = ME_GetRunSizeCommon( c, para, run, run->len, startx, &run->nAscent, &run->nDescent );
+ run->nWidth = size.cx;
+ }
+}
+
+/******************************************************************************
* split_run_extents
*
* Splits a run into two in a given place. It also updates the screen position
@@ -62,7 +79,7 @@ static ME_DisplayItem *split_run_extents(ME_WrapContext *wc, ME_DisplayItem *ite
run2 = &cursor.pRun->member.run;
- ME_CalcRunExtent(wc->context, para, wc->nRow ? wc->nLeftMargin : wc->nFirstMargin, run);
+ calc_run_extent(wc->context, para, wc->nRow ? wc->nLeftMargin : wc->nFirstMargin, run);
run2->pt.x = run->pt.x+run->nWidth;
run2->pt.y = run->pt.y;
@@ -296,8 +313,8 @@ static void ME_WrapSizeRun(ME_WrapContext *wc, ME_DisplayItem *p)
ME_UpdateRunFlags(wc->context->editor, &p->member.run);
- ME_CalcRunExtent(wc->context, &wc->pPara->member.para,
- wc->nRow ? wc->nLeftMargin : wc->nFirstMargin, &p->member.run);
+ calc_run_extent(wc->context, &wc->pPara->member.para,
+ wc->nRow ? wc->nLeftMargin : wc->nFirstMargin, &p->member.run);
}
@@ -488,9 +505,9 @@ static ME_DisplayItem *ME_WrapHandleRun(ME_WrapContext *wc, ME_DisplayItem *p)
if (black) {
wc->bOverflown = FALSE;
pp = split_run_extents(wc, p, black);
- ME_CalcRunExtent(wc->context, &wc->pPara->member.para,
- wc->nRow ? wc->nLeftMargin : wc->nFirstMargin,
- &pp->member.run);
+ calc_run_extent(wc->context, &wc->pPara->member.para,
+ wc->nRow ? wc->nLeftMargin : wc->nFirstMargin,
+ &pp->member.run);
ME_InsertRowStart(wc, pp);
return pp;
}
More information about the wine-cvs
mailing list