Module: wine Branch: master Commit: 03036f42e1afa9c79246dcee6b9fe876286b1aa4 URL: https://gitlab.winehq.org/wine/wine/-/commit/03036f42e1afa9c79246dcee6b9fe87...
Author: Jinoh Kang jinoh.kang.kr@gmail.com Date: Thu Jul 13 20:47:52 2023 +0900
riched20: Factor out device context acquisition from ME_MakeFirstParagraph.
This lets ME_MakeEditor() reuse the device context throughout the editor initialization process.
---
dlls/riched20/editor.c | 6 +++++- dlls/riched20/editor.h | 2 +- dlls/riched20/para.c | 4 +--- 3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 201c4435453..d1819482b28 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -2931,6 +2931,7 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) int i; LONG selbarwidth; HRESULT hr; + HDC hdc;
ed->sizeWindow.cx = ed->sizeWindow.cy = 0; if (ITextHost_QueryInterface( texthost, &IID_ITextHost2, (void **)&ed->texthost ) == S_OK) @@ -2957,7 +2958,10 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) ed->nZoomNumerator = ed->nZoomDenominator = 0; ed->nAvailWidth = 0; /* wrap to client area */ list_init( &ed->style_list ); - ME_MakeFirstParagraph(ed); + + hdc = ITextHost_TxGetDC( ed->texthost ); + ME_MakeFirstParagraph( ed, hdc ); + ITextHost_TxReleaseDC( ed->texthost, hdc ); /* The four cursors are for: * 0 - The position where the caret is shown * 1 - The anchored end of the selection (for normal selection) diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h index da7d3bd35fd..1ad8f4adef4 100644 --- a/dlls/riched20/editor.h +++ b/dlls/riched20/editor.h @@ -209,7 +209,7 @@ void editor_get_selection_para_fmt( ME_TextEditor *editor, PARAFORMAT2 *fmt ); void editor_mark_rewrap_all( ME_TextEditor *editor ); void editor_set_default_para_fmt(ME_TextEditor *editor, PARAFORMAT2 *pFmt); BOOL editor_set_selection_para_fmt( ME_TextEditor *editor, const PARAFORMAT2 *fmt ); -void ME_MakeFirstParagraph(ME_TextEditor *editor); +void ME_MakeFirstParagraph(ME_TextEditor *editor, HDC hdc); void ME_DumpParaStyle(ME_Paragraph *s); void ME_DumpParaStyleToBuf(const PARAFORMAT2 *pFmt, char buf[2048]); int get_total_width(ME_TextEditor *editor); diff --git a/dlls/riched20/para.c b/dlls/riched20/para.c index 6085816f315..50a1073397a 100644 --- a/dlls/riched20/para.c +++ b/dlls/riched20/para.c @@ -148,7 +148,7 @@ ME_Row *para_end_row( ME_Paragraph *para ) return &item->member.row; }
-void ME_MakeFirstParagraph(ME_TextEditor *editor) +void ME_MakeFirstParagraph(ME_TextEditor *editor, HDC hdc) { ME_Context c; CHARFORMAT2W cf; @@ -160,7 +160,6 @@ void ME_MakeFirstParagraph(ME_TextEditor *editor) ME_Run *run; ME_Style *style; int eol_len; - HDC hdc = ITextHost_TxGetDC( editor->texthost );
ME_InitContext( &c, editor, hdc );
@@ -223,7 +222,6 @@ void ME_MakeFirstParagraph(ME_TextEditor *editor) para_mark_add( editor, para ); ME_DestroyContext(&c); wrap_marked_paras_dc( editor, hdc, FALSE ); - ITextHost_TxReleaseDC( editor->texthost, hdc ); }
static void para_mark_rewrap_paras( ME_TextEditor *editor, ME_Paragraph *first, const ME_Paragraph *end )