Bug 140757 - Simple line layout: Move leading whitespace handling from removeTrailingWhitespace() to initializeNewLine().
Summary: Simple line layout: Move leading whitespace handling from removeTrailingWhite...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: zalan
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-21 20:42 PST by zalan
Modified: 2015-01-22 22:26 PST (History)
6 users (show)

See Also:


Attachments
WIP patch. (14.16 KB, patch)
2015-01-21 20:43 PST, zalan
no flags Details | Formatted Diff | Diff
Patch (7.55 KB, patch)
2015-01-22 16:38 PST, zalan
no flags Details | Formatted Diff | Diff
Patch (8.62 KB, patch)
2015-01-22 20:03 PST, zalan
no flags Details | Formatted Diff | Diff
Patch (8.75 KB, patch)
2015-01-22 20:31 PST, zalan
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.