⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 176531 in webkit


Ignore:
Timestamp:
Nov 24, 2014, 5:00:57 PM (12 years ago)
Author:
Alan Bujtas
Message:

Simple line layout: Rename TextFragment::mustBreak to TextFragment::isLineBreak
https://bugs.webkit.org/show_bug.cgi?id=139035

Reviewed by Antti Koivisto.

Move new line logic to FlowContents class.
This is in preparation to support <br>.

No change in functionality.

  • rendering/SimpleLineLayout.cpp:

(WebCore::SimpleLineLayout::TextFragment::TextFragment):
(WebCore::SimpleLineLayout::removeTrailingWhitespace):
(WebCore::SimpleLineLayout::nextFragment):
(WebCore::SimpleLineLayout::createLineRuns):

  • rendering/SimpleLineLayoutFlowContents.h:

(WebCore::SimpleLineLayout::FlowContents::isNewline):
(WebCore::SimpleLineLayout::FlowContents::isNewlineCharacter): Deleted.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r176529 r176531  
     12014-11-24  Zalan Bujtas  <zalan@apple.com>
     2
     3        Simple line layout: Rename TextFragment::mustBreak to TextFragment::isLineBreak
     4        https://bugs.webkit.org/show_bug.cgi?id=139035
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Move new line logic to FlowContents class.
     9        This is in preparation to support <br>.
     10
     11        No change in functionality.
     12
     13        * rendering/SimpleLineLayout.cpp:
     14        (WebCore::SimpleLineLayout::TextFragment::TextFragment):
     15        (WebCore::SimpleLineLayout::removeTrailingWhitespace):
     16        (WebCore::SimpleLineLayout::nextFragment):
     17        (WebCore::SimpleLineLayout::createLineRuns):
     18        * rendering/SimpleLineLayoutFlowContents.h:
     19        (WebCore::SimpleLineLayout::FlowContents::isNewline):
     20        (WebCore::SimpleLineLayout::FlowContents::isNewlineCharacter): Deleted.
     21
    1222014-11-24  Benjamin Poulain  <benjamin@webkit.org>
    223
  • trunk/Source/WebCore/rendering/SimpleLineLayout.cpp

    r176527 r176531  
    227227        , isWhitespaceOnly(false)
    228228        , isBreakable(false)
    229         , mustBreak(false)
     229        , isLineBreak(false)
    230230        , width(0)
    231231    {
     
    238238        , isWhitespaceOnly(isWhitespaceOnly)
    239239        , isBreakable(false)
    240         , mustBreak(false)
     240        , isLineBreak(false)
    241241        , width(textWidth)
    242242    {
     
    253253    bool isWhitespaceOnly : 1;
    254254    bool isBreakable;
    255     bool mustBreak;
     255    bool isLineBreak;
    256256    float width;
    257257};
     
    390390
    391391    // If we skipped any whitespace and now the line end is a "preserved" newline, skip the newline too as we are wrapping the line here already.
    392     if (lastPosition != lineState.position && style.preserveNewline && !flowContents.isEnd(lineState.position) && flowContents.isNewlineCharacter(lineState.position))
     392    if (lastPosition != lineState.position && style.preserveNewline && !flowContents.isEnd(lineState.position) && flowContents.isLineBreak(lineState.position))
    393393        ++lineState.position;
    394394}
     
    460460    const auto& style = flowContents.style();
    461461    TextFragment fragment;
    462     fragment.mustBreak = style.preserveNewline && flowContents.isNewlineCharacter(previousFragmentEnd);
     462    fragment.isLineBreak = flowContents.isLineBreak(previousFragmentEnd);
    463463    unsigned spaceCount = 0;
    464464    unsigned whitespaceEnd = previousFragmentEnd;
    465     if (!fragment.mustBreak)
     465    if (!fragment.isLineBreak)
    466466        whitespaceEnd = flowContents.findNextNonWhitespacePosition(previousFragmentEnd, spaceCount);
    467467    fragment.isWhitespaceOnly = previousFragmentEnd < whitespaceEnd;
     
    469469    if (fragment.isWhitespaceOnly)
    470470        fragment.end = whitespaceEnd;
    471     else if (fragment.mustBreak)
     471    else if (fragment.isLineBreak)
    472472        fragment.end = fragment.start + 1;
    473473    else
     
    482482    if (fragment.isCollapsedWhitespace)
    483483        fragment.width = style.spaceWidth;
    484     else if (fragment.mustBreak)
     484    else if (fragment.isLineBreak)
    485485        fragment.width = 0; // Newline character's width is 0.
    486486    else if (fragmentLength == spaceCount) // Space only.
     
    498498        // Find the next text fragment. Start from the end of the previous fragment -current line end.
    499499        TextFragment fragment = nextFragment(lineState.position, flowContents, lineState.width());
    500         if ((lineCanBeWrapped && !lineState.fits(fragment.width)) || fragment.mustBreak) {
     500        if ((lineCanBeWrapped && !lineState.fits(fragment.width)) || fragment.isLineBreak) {
    501501            // Overflow wrapping behaviour:
    502502            // 1. Newline character: wraps the line unless it's treated as whitespace.
     
    506506            // 5. Non-whitespace fragment when there's already another fragment on the line gets pushed to the next line.
    507507            bool isFirstFragment = !lineState.width();
    508             if (fragment.mustBreak) {
     508            if (fragment.isLineBreak) {
    509509                if (isFirstFragment)
    510510                    lineState.addUncommitted(fragment);
  • trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContents.h

    r176528 r176531  
    4646    float textWidth(unsigned from, unsigned to, float xPosition) const;
    4747
    48     bool isNewlineCharacter(unsigned position) const;
     48    bool isLineBreak(unsigned position) const;
    4949    bool isEnd(unsigned position) const;
    5050
     
    9696}
    9797
    98 inline bool FlowContents::isNewlineCharacter(unsigned position) const
     98inline bool FlowContents::isLineBreak(unsigned position) const
    9999{
    100     return characterAt(position) == '\n';
     100    return m_style.preserveNewline && characterAt(position) == '\n';
    101101}
    102102
Note: See TracChangeset for help on using the changeset viewer.