Bug 140757

Summary: Simple line layout: Move leading whitespace handling from removeTrailingWhitespace() to initializeNewLine().
Product: WebKit Reporter: zalan <zalan>
Component: Layout and RenderingAssignee: zalan <zalan>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, esprehn+autocc, glenn, koivisto, kondapallykalyan, mmaxfield
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
WIP patch.
none
Patch
none
Patch
none
Patch none

Description zalan 2015-01-21 20:42:42 PST
This is in preparation to make FlowContents as iterator class.
Comment 1 zalan 2015-01-21 20:43:50 PST
Created attachment 245112 [details]
WIP patch.
Comment 2 zalan 2015-01-22 16:38:45 PST
Created attachment 245183 [details]
Patch
Comment 3 zalan 2015-01-22 20:03:25 PST
Created attachment 245198 [details]
Patch
Comment 4 Antti Koivisto 2015-01-22 20:08:01 PST
Comment on attachment 245198 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=245198&action=review

> Source/WebCore/rendering/SimpleLineLayout.cpp:334
> +    // Remove collapsed whitespace, or non-collapsed pre-wrap whitepsace, unless it's the only content on the line -so removing the whitesapce would produce an empty line.
> +    if (!(style.collapseWhitespace || (preWrap(style) && !lineState.hasWhitespaceOnly())))

This is bit difficult to read with all the !s. Maybe have a sensibly named boolean helper?

> Source/WebCore/rendering/SimpleLineLayout.cpp:385
> +    if (overflowedFragment.isEmpty()) {
>          unsigned spaceCount = 0;
> -        lineState.jumpTo(flowContents.style().collapseWhitespace ? flowContents.findNextNonWhitespacePosition(previousLine.position, spaceCount) : previousLine.position, 0);
> +        lineState.jumpTo(style.collapseWhitespace ? flowContents.findNextNonWhitespacePosition(linePositon, spaceCount) : linePositon, 0);
> +    } else if (lineState.fits(overflowedFragment.width))
> +        lineState.addUncommitted(overflowedFragment);
> +    else {
> +        // Start over with this fragment.
> +        lineState.jumpTo(overflowedFragment.start, 0);
>      }
>      return lineState;

This would read better with early returns. No need for else branches.
Comment 5 zalan 2015-01-22 20:31:00 PST
Created attachment 245200 [details]
Patch
Comment 6 WebKit Commit Bot 2015-01-22 22:26:25 PST
Comment on attachment 245200 [details]
Patch

Clearing flags on attachment: 245200

Committed r178983: <http://trac.webkit.org/changeset/178983>
Comment 7 WebKit Commit Bot 2015-01-22 22:26:29 PST
All reviewed patches have been landed.  Closing bug.