Commit d306b6b5 authored by Dylan Smith's avatar Dylan Smith Committed by Alexandre Julliard

richedit: Removed some conditions that are always taken.

ME_GetCursorCoordinates had two conditions that were always taken. The first condition was if(pCursor->pRun->type == diRun) was following an assertion making the exact same check. The next one, if(row), should always be taken, otherwise the richedit controls are in a corrupt state, therefore an assertion is more appropriate.
parent 4b7e8f18
...@@ -168,37 +168,30 @@ void ...@@ -168,37 +168,30 @@ void
ME_GetCursorCoordinates(ME_TextEditor *editor, ME_Cursor *pCursor, ME_GetCursorCoordinates(ME_TextEditor *editor, ME_Cursor *pCursor,
int *x, int *y, int *height) int *x, int *y, int *height)
{ {
ME_DisplayItem *pCursorRun = pCursor->pRun; ME_DisplayItem *row;
ME_DisplayItem *pSizeRun = pCursor->pRun; ME_DisplayItem *run = pCursor->pRun;
ME_DisplayItem *para = ME_GetParagraph(run);
ME_DisplayItem *pSizeRun = run;
ME_Context c;
SIZE sz = {0, 0};
assert(height && x && y); assert(height && x && y);
assert(!(ME_GetParagraph(pCursorRun)->member.para.nFlags & MEPF_REWRAP)); assert(~para->member.para.nFlags & MEPF_REWRAP);
assert(pCursor->pRun); assert(run && run->type == diRun);
assert(pCursor->pRun->type == diRun); assert(para && para->type == diParagraph);
if (pCursorRun->type == diRun) {
ME_DisplayItem *row = ME_FindItemBack(pCursorRun, diStartRowOrParagraph);
if (row) { row = ME_FindItemBack(run, diStartRowOrParagraph);
HDC hDC = ITextHost_TxGetDC(editor->texthost); assert(row && row->type == diStartRow);
ME_Context c;
ME_DisplayItem *run = pCursorRun;
ME_DisplayItem *para = NULL;
SIZE sz = {0, 0};
ME_InitContext(&c, editor, hDC); ME_InitContext(&c, editor, ITextHost_TxGetDC(editor->texthost));
if (!pCursor->nOffset) if (!pCursor->nOffset)
{ {
ME_DisplayItem *prev = ME_FindItemBack(pCursorRun, diRunOrParagraph); ME_DisplayItem *prev = ME_FindItemBack(run, diRunOrParagraph);
assert(prev); assert(prev);
if (prev->type == diRun) if (prev->type == diRun)
pSizeRun = prev; pSizeRun = prev;
} }
assert(row->type == diStartRow); /* paragraph -> run without start row ?*/
para = ME_FindItemBack(row, diParagraph);
assert(para);
assert(para->type == diParagraph);
if (editor->bCaretAtEnd && !pCursor->nOffset && if (editor->bCaretAtEnd && !pCursor->nOffset &&
run == ME_FindItemFwd(row, diRun)) run == ME_FindItemFwd(row, diRun))
{ {
...@@ -216,21 +209,17 @@ ME_GetCursorCoordinates(ME_TextEditor *editor, ME_Cursor *pCursor, ...@@ -216,21 +209,17 @@ ME_GetCursorCoordinates(ME_TextEditor *editor, ME_Cursor *pCursor,
} }
} }
if (pCursor->nOffset) { if (pCursor->nOffset) {
sz = ME_GetRunSize(&c, &para->member.para, &run->member.run, pCursor->nOffset, sz = ME_GetRunSize(&c, &para->member.para, &run->member.run,
row->member.row.nLMargin); pCursor->nOffset, row->member.row.nLMargin);
} }
*height = pSizeRun->member.run.nAscent + pSizeRun->member.run.nDescent; *height = pSizeRun->member.run.nAscent + pSizeRun->member.run.nDescent;
*x = c.rcView.left + run->member.run.pt.x + sz.cx - editor->horz_si.nPos; *x = c.rcView.left + run->member.run.pt.x + sz.cx - editor->horz_si.nPos;
*y = c.rcView.top + para->member.para.pt.y + row->member.row.nBaseline *y = c.rcView.top + para->member.para.pt.y + row->member.row.nBaseline
+ run->member.run.pt.y - pSizeRun->member.run.nAscent - editor->vert_si.nPos; + run->member.run.pt.y - pSizeRun->member.run.nAscent
- editor->vert_si.nPos;
ME_DestroyContext(&c); ME_DestroyContext(&c);
return; return;
}
}
*height = 10; /* FIXME use global font */
*x = 0;
*y = 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment