Module: wine
Branch: master
Commit: 5c91d5356ec2f1e3f87ba4d3665c8230dd8ee25c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=5c91d5356ec2f1e3f87ba4d36…
Author: Dylan Smith <dylan.ah.smith(a)gmail.com>
Date: Fri Feb 6 01:10:06 2009 -0500
richedit: Avoided searching for adjacent paragraphs through runs.
When finding an adjacent paragraph, the next_para and prev_para pointers
should be used because they are direct pointers, a constant time
operation. Instead I found some places in the code that searched through
the general linked list to get to an adjacent paragraph, which is a linear
time operation, depending on the number of rows and runs in between
paragraphs.
---
dlls/riched20/paint.c | 18 ++++++++----------
dlls/riched20/para.c | 21 +++++++++++----------
dlls/riched20/row.c | 22 ++++++++++++----------
3 files changed, 31 insertions(+), 30 deletions(-)
diff --git a/dlls/riched20/paint.c b/dlls/riched20/paint.c
index 03ece7b..28813d4 100644
--- a/dlls/riched20/paint.c
+++ b/dlls/riched20/paint.c
@@ -1267,26 +1267,24 @@ ME_InvalidateSelection(ME_TextEditor *editor)
assert(para1->type == diParagraph);
assert(para2->type == diParagraph);
/* last selection markers aren't always updated, which means
- they can point past the end of the document */
+ * they can point past the end of the document */
if (editor->nLastSelStart > len || editor->nLastSelEnd > len) {
ME_MarkForPainting(editor,
ME_FindItemFwd(editor->pBuffer->pFirst, diParagraph),
- ME_FindItemFwd(editor->pBuffer->pFirst, diTextEnd));
+ editor->pBuffer->pLast);
} else {
/* if the start part of selection is being expanded or contracted... */
if (nStart < editor->nLastSelStart) {
- ME_MarkForPainting(editor, para1, ME_FindItemFwd(editor->pLastSelStartPara, diParagraphOrEnd));
- } else
- if (nStart > editor->nLastSelStart) {
- ME_MarkForPainting(editor, editor->pLastSelStartPara, ME_FindItemFwd(para1, diParagraphOrEnd));
+ ME_MarkForPainting(editor, para1, editor->pLastSelStartPara->member.para.next_para);
+ } else if (nStart > editor->nLastSelStart) {
+ ME_MarkForPainting(editor, editor->pLastSelStartPara, para1->member.para.next_para);
}
/* if the end part of selection is being contracted or expanded... */
if (nEnd < editor->nLastSelEnd) {
- ME_MarkForPainting(editor, para2, ME_FindItemFwd(editor->pLastSelEndPara, diParagraphOrEnd));
- } else
- if (nEnd > editor->nLastSelEnd) {
- ME_MarkForPainting(editor, editor->pLastSelEndPara, ME_FindItemFwd(para2, diParagraphOrEnd));
+ ME_MarkForPainting(editor, para2, editor->pLastSelEndPara->member.para.next_para);
+ } else if (nEnd > editor->nLastSelEnd) {
+ ME_MarkForPainting(editor, editor->pLastSelEndPara, para2->member.para.next_para);
}
}
diff --git a/dlls/riched20/para.c b/dlls/riched20/para.c
index a4a9adb..0836390 100644
--- a/dlls/riched20/para.c
+++ b/dlls/riched20/para.c
@@ -515,9 +515,12 @@ void
ME_GetSelectionParas(ME_TextEditor *editor, ME_DisplayItem **para, ME_DisplayItem **para_end)
{
ME_Cursor *pEndCursor = &editor->pCursors[1];
-
+
*para = ME_GetParagraph(editor->pCursors[0].pRun);
*para_end = ME_GetParagraph(editor->pCursors[1].pRun);
+ if (*para == *para_end)
+ return;
+
if ((*para_end)->member.para.nCharOfs < (*para)->member.para.nCharOfs) {
ME_DisplayItem *tmp = *para;
@@ -525,22 +528,20 @@ ME_GetSelectionParas(ME_TextEditor *editor, ME_DisplayItem **para, ME_DisplayIte
*para_end = tmp;
pEndCursor = &editor->pCursors[0];
}
-
- /* selection consists of chars from nFrom up to nTo-1 */
- if ((*para_end)->member.para.nCharOfs > (*para)->member.para.nCharOfs) {
- if (!pEndCursor->nOffset) {
- *para_end = ME_GetParagraph(ME_FindItemBack(pEndCursor->pRun, diRun));
- }
- }
+
+ /* The paragraph at the end of a non-empty selection isn't included
+ * if the selection ends at the start of the paragraph. */
+ if (!pEndCursor->pRun->member.run.nCharOfs && !pEndCursor->nOffset)
+ *para_end = (*para_end)->member.para.prev_para;
}
BOOL ME_SetSelectionParaFormat(ME_TextEditor *editor, const PARAFORMAT2 *pFmt)
{
ME_DisplayItem *para, *para_end;
-
+
ME_GetSelectionParas(editor, ¶, ¶_end);
-
+
do {
ME_SetParaFormat(editor, para, pFmt);
if (para == para_end)
diff --git a/dlls/riched20/row.c b/dlls/riched20/row.c
index 3abff5f..d3ef3de 100644
--- a/dlls/riched20/row.c
+++ b/dlls/riched20/row.c
@@ -89,14 +89,15 @@ ME_FindRowWithNumber(ME_TextEditor *editor, int nRow)
{
ME_DisplayItem *item = ME_FindItemFwd(editor->pBuffer->pFirst, diParagraph);
int nCount = 0;
-
- while (item && nCount + item->member.para.nRows <= nRow)
+
+ while (item->type == diParagraph &&
+ nCount + item->member.para.nRows <= nRow)
{
nCount += item->member.para.nRows;
- item = ME_FindItemFwd(item, diParagraph);
+ item = item->member.para.next_para;
}
- if (!item)
- return item;
+ if (item->type != diParagraph)
+ return NULL;
for (item = ME_FindItemFwd(item, diStartRow); item && nCount < nRow; nCount++)
item = ME_FindItemFwd(item, diStartRow);
return item;
@@ -106,18 +107,19 @@ ME_FindRowWithNumber(ME_TextEditor *editor, int nRow)
int
ME_RowNumberFromCharOfs(ME_TextEditor *editor, int nOfs)
{
- ME_DisplayItem *item = editor->pBuffer->pFirst->next;
+ ME_DisplayItem *item = ME_FindItemFwd(editor->pBuffer->pFirst, diParagraph);
int nRow = 0;
- while (item && item->member.para.next_para->member.para.nCharOfs <= nOfs)
+ while (item->type == diParagraph &&
+ item->member.para.next_para->member.para.nCharOfs <= nOfs)
{
nRow += item->member.para.nRows;
- item = ME_FindItemFwd(item, diParagraph);
+ item = item->member.para.next_para;
}
- if (item)
+ if (item->type == diParagraph)
{
ME_DisplayItem *next_para = item->member.para.next_para;
-
+
nOfs -= item->member.para.nCharOfs;
item = ME_FindItemFwd(item, diRun);
while ((item = ME_FindItemFwd(item, diStartRowOrParagraph)) != NULL)
Module: wine
Branch: master
Commit: 5a84e193c2558a9ac6ab1a24d984f6da275b4e6f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=5a84e193c2558a9ac6ab1a24d…
Author: Dylan Smith <dylan.ah.smith(a)gmail.com>
Date: Fri Feb 6 01:10:00 2009 -0500
richedit: Removed incorrect FIXME comment.
The fixme comment is suggesting wrapping a paragraph within a function
that is for moving the selection cursor up or down a line when the up
or down keys are pressed. The contents fo paragraph aren't being
changed, so there is no need to wrap the paragraph.
---
dlls/riched20/caret.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c
index 0e42f10..46e16d4 100644
--- a/dlls/riched20/caret.c
+++ b/dlls/riched20/caret.c
@@ -1266,8 +1266,6 @@ ME_MoveCursorLines(ME_TextEditor *editor, ME_Cursor *pCursor, int nRelOfs)
pItem = ME_FindItemFwd(pRun, diStartRow);
if (!pItem)
return; /* row not found - ignore */
- /* FIXME If diParagraph is before diStartRow, wrap the next paragraph?
- */
pNewPara = ME_GetParagraph(pItem);
if (pOldPara->member.para.nFlags & MEPF_ROWSTART ||
(pOldPara->member.para.pCell &&
Module: wine
Branch: master
Commit: 12ca50db7a8f60b980cef50d7addaeae010f79c4
URL: http://source.winehq.org/git/wine.git/?a=commit;h=12ca50db7a8f60b980cef50d7…
Author: Dylan Smith <dylan.ah.smith(a)gmail.com>
Date: Fri Feb 6 01:09:47 2009 -0500
richedit: Get the paragraph with ME_RunOfsFromCharOfs.
The ME_RunOfsFromCharOfs function finds the paragraph before finding the
run and offset within the run, so the function may as well be able to
return this paragraph to the caller. Many callers to the function
instead find the paragraph from the run, which ends up unnecessarily
traversing a linked list of runs within the paragraph.
---
dlls/riched20/editor.c | 55 +++++++++--------------------------------------
dlls/riched20/editor.h | 4 +-
dlls/riched20/run.c | 28 +++++++++++++-----------
dlls/riched20/writer.c | 14 +++++-------
4 files changed, 34 insertions(+), 67 deletions(-)
Diff: http://source.winehq.org/git/wine.git/?a=commitdiff;h=12ca50db7a8f60b980cef…
Module: wine
Branch: master
Commit: a5bfa1a2abfa20f85df0396b74822106a6795c89
URL: http://source.winehq.org/git/wine.git/?a=commit;h=a5bfa1a2abfa20f85df0396b7…
Author: Dylan Smith <dylan.ah.smith(a)gmail.com>
Date: Fri Feb 6 01:09:43 2009 -0500
richedit: Properly destroy context in two places.
Whenever ME_InitContext is called, ME_DestroyContext should be used to
clean it up. This way the context can be extended easily by modifying
those two functions. Instead, these two places of code just released
the DC, without using ME_DestroyContext, so the created brush for the
margin was not deleted.
---
dlls/riched20/run.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/riched20/run.c b/dlls/riched20/run.c
index 1f8cc18..741a469 100644
--- a/dlls/riched20/run.c
+++ b/dlls/riched20/run.c
@@ -600,7 +600,7 @@ int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset)
{
if (nOffset)
ME_GetOLEObjectSize(&c, pRun, &size);
- ITextHost_TxReleaseDC(editor->texthost, c.hDC);
+ ME_DestroyContext(&c);
return nOffset != 0;
} else if (pRun->nFlags & MERF_ENDPARA) {
nOffset = 0;
@@ -612,7 +612,7 @@ int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset)
strRunText = pRun->strText;
ME_GetTextExtent(&c, strRunText->szData, nOffset, pRun->style, &size);
- ITextHost_TxReleaseDC(editor->texthost, c.hDC);
+ ME_DestroyContext(&c);
if (editor->cPasswordMask)
ME_DestroyString(strRunText);
return size.cx;
Module: wine
Branch: master
Commit: ea9e062b6c460b17ddc3b820dee80960b74b9369
URL: http://source.winehq.org/git/wine.git/?a=commit;h=ea9e062b6c460b17ddc3b820d…
Author: Dylan Smith <dylan.ah.smith(a)gmail.com>
Date: Fri Feb 6 01:09:36 2009 -0500
richedit: Removed unnecessary calls to ME_WrapMarkedParagraphs.
These calls to ME_WrapMarkedParagraphs never do anything, and don't make
sense to be called in these places. These places are for ME_MoveCaret,
and ME_ArrowHome, which both don't involve any text being modified, and
all (direct and indirect) calls to these functions are done after the
text has already been wrapped.
---
dlls/riched20/caret.c | 3 ---
dlls/riched20/paint.c | 2 +-
2 files changed, 1 insertions(+), 4 deletions(-)
diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c
index 7bdd0a7..e901095 100644
--- a/dlls/riched20/caret.c
+++ b/dlls/riched20/caret.c
@@ -237,8 +237,6 @@ ME_MoveCaret(ME_TextEditor *editor)
{
int x, y, height;
- if (ME_WrapMarkedParagraphs(editor))
- ME_UpdateScrollBar(editor);
ME_GetCursorCoordinates(editor, &editor->pCursors[0], &x, &y, &height);
if(editor->bHaveFocus && !ME_IsSelection(editor))
{
@@ -1420,7 +1418,6 @@ static void ME_ArrowPageDown(ME_TextEditor *editor, ME_Cursor *pCursor)
static void ME_ArrowHome(ME_TextEditor *editor, ME_Cursor *pCursor)
{
ME_DisplayItem *pRow = ME_FindItemBack(pCursor->pRun, diStartRow);
- ME_WrapMarkedParagraphs(editor);
if (pRow) {
ME_DisplayItem *pRun;
if (editor->bCaretAtEnd && !pCursor->nOffset) {
diff --git a/dlls/riched20/paint.c b/dlls/riched20/paint.c
index 30548fe..03ece7b 100644
--- a/dlls/riched20/paint.c
+++ b/dlls/riched20/paint.c
@@ -44,7 +44,7 @@ void ME_PaintContent(ME_TextEditor *editor, HDC hDC, BOOL bOnlyNew, const RECT *
editor->nSequence++;
ME_InitContext(&c, editor, hDC);
SetBkMode(hDC, TRANSPARENT);
- ME_MoveCaret(editor); /* Calls ME_WrapMarkedParagraphs */
+ ME_MoveCaret(editor);
item = editor->pBuffer->pFirst->next;
/* This context point is an offset for the paragraph positions stored
* during wrapping. It shouldn't be modified during painting. */