riched20: Simplify SplitByBacktracking().

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Huw Davies 2020-10-07 13:20:39 +01:00 committed by Alexandre Julliard
parent 5dc422d4e5
commit 14044d93fd
1 changed files with 13 additions and 18 deletions

View File

@ -498,7 +498,7 @@ static ME_DisplayItem *ME_MaximizeSplit(ME_WrapContext *wc, ME_DisplayItem *p, i
static ME_DisplayItem *ME_SplitByBacktracking(ME_WrapContext *wc, ME_DisplayItem *p, int loc) static ME_DisplayItem *ME_SplitByBacktracking(ME_WrapContext *wc, ME_DisplayItem *p, int loc)
{ {
ME_DisplayItem *piter = p, *pp; ME_DisplayItem *new_run;
int i, idesp, len; int i, idesp, len;
ME_Run *run = &p->member.run; ME_Run *run = &p->member.run;
@ -509,9 +509,8 @@ static ME_DisplayItem *ME_SplitByBacktracking(ME_WrapContext *wc, ME_DisplayItem
if (i) { if (i) {
/* don't split words */ /* don't split words */
i = reverse_find_whitespace( get_text( run, 0 ), i ); i = reverse_find_whitespace( get_text( run, 0 ), i );
pp = ME_MaximizeSplit(wc, p, i); new_run = ME_MaximizeSplit(wc, p, i);
if (pp) if (new_run) return new_run;
return pp;
} }
TRACE("Must backtrack to split at: %s\n", debugstr_run( &p->member.run )); TRACE("Must backtrack to split at: %s\n", debugstr_run( &p->member.run ));
if (wc->pLastSplittableRun) if (wc->pLastSplittableRun)
@ -528,20 +527,16 @@ static ME_DisplayItem *ME_SplitByBacktracking(ME_WrapContext *wc, ME_DisplayItem
ME_UpdateRunFlags(wc->context->editor, run); ME_UpdateRunFlags(wc->context->editor, run);
assert((wc->pLastSplittableRun->member.run.nFlags & MERF_SPLITTABLE)); assert((wc->pLastSplittableRun->member.run.nFlags & MERF_SPLITTABLE));
piter = wc->pLastSplittableRun; p = wc->pLastSplittableRun;
run = &piter->member.run; run = &p->member.run;
len = run->len; len = run->len;
/* don't split words */ /* don't split words */
i = reverse_find_whitespace( get_text( run, 0 ), len ); i = reverse_find_whitespace( get_text( run, 0 ), len );
if (i == len) if (i == len)
i = reverse_find_non_whitespace( get_text( run, 0 ), len ); i = reverse_find_non_whitespace( get_text( run, 0 ), len );
if (i) { new_run = split_run_extents(wc, p, i);
ME_DisplayItem *piter2 = split_run_extents(wc, piter, i); wc->pt = new_run->member.run.pt;
wc->pt = piter2->member.run.pt; return new_run;
return piter2;
}
/* splittable = must have whitespaces */
assert(0 == "Splittable, but no whitespaces");
} }
else else
{ {
@ -553,24 +548,24 @@ static ME_DisplayItem *ME_SplitByBacktracking(ME_WrapContext *wc, ME_DisplayItem
TRACE("Backtracking failed, trying desperate: %s\n", debugstr_run( &p->member.run )); TRACE("Backtracking failed, trying desperate: %s\n", debugstr_run( &p->member.run ));
/* OK, no better idea, so assume we MAY split words if we can split at all*/ /* OK, no better idea, so assume we MAY split words if we can split at all*/
if (idesp) if (idesp)
return split_run_extents(wc, piter, idesp); return split_run_extents(wc, p, idesp);
else else
if (wc->pRowStart && piter != wc->pRowStart) if (wc->pRowStart && p != wc->pRowStart)
{ {
/* don't need to break current run, because it's possible to split /* don't need to break current run, because it's possible to split
before this run */ before this run */
wc->bOverflown = TRUE; wc->bOverflown = TRUE;
return piter; return p;
} }
else else
{ {
/* split point inside first character - no choice but split after that char */ /* split point inside first character - no choice but split after that char */
if (len != 1) { if (len != 1) {
/* the run is more than 1 char, so we may split */ /* the run is more than 1 char, so we may split */
return split_run_extents(wc, piter, 1); return split_run_extents(wc, p, 1);
} }
/* the run is one char, can't split it */ /* the run is one char, can't split it */
return piter; return p;
} }
} }