Changeset 159032 in webkit


Ignore:
Timestamp:
Nov 10, 2013 3:32:48 PM (10 years ago)
Author:
Antti Koivisto
Message:

Use start/end instead of textOffset/textLength for simple text runs
https://bugs.webkit.org/show_bug.cgi?id=124130

Reviewed by Oliver Hunt.

The code reads better this way.

  • rendering/SimpleLineLayout.cpp:

(WebCore::SimpleLineLayout::createTextRuns):

  • rendering/SimpleLineLayout.h:

(WebCore::SimpleLineLayout::Run::Run):

  • rendering/SimpleLineLayoutFunctions.h:

(WebCore::SimpleLineLayout::findTextCaretMinimumOffset):
(WebCore::SimpleLineLayout::findTextCaretMaximumOffset):
(WebCore::SimpleLineLayout::containsTextCaretOffset):
(WebCore::SimpleLineLayout::isTextRendered):

  • rendering/SimpleLineLayoutResolver.h:

(WebCore::SimpleLineLayout::RunResolver::Run::text):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r159030 r159032  
     12013-11-10  Antti Koivisto  <antti@apple.com>
     2
     3        Use start/end instead of textOffset/textLength for simple text runs
     4        https://bugs.webkit.org/show_bug.cgi?id=124130
     5
     6        Reviewed by Oliver Hunt.
     7       
     8        The code reads better this way.
     9
     10        * rendering/SimpleLineLayout.cpp:
     11        (WebCore::SimpleLineLayout::createTextRuns):
     12        * rendering/SimpleLineLayout.h:
     13        (WebCore::SimpleLineLayout::Run::Run):
     14        * rendering/SimpleLineLayoutFunctions.h:
     15        (WebCore::SimpleLineLayout::findTextCaretMinimumOffset):
     16        (WebCore::SimpleLineLayout::findTextCaretMaximumOffset):
     17        (WebCore::SimpleLineLayout::containsTextCaretOffset):
     18        (WebCore::SimpleLineLayout::isTextRendered):
     19        * rendering/SimpleLineLayoutResolver.h:
     20        (WebCore::SimpleLineLayout::RunResolver::Run::text):
     21
    1222013-11-10  Antti Koivisto  <antti@apple.com>
    223
  • trunk/Source/WebCore/rendering/SimpleLineLayout.cpp

    r159030 r159032  
    311311                    lineRuns.append(Run(lineEnd, lineRuns.last().right));
    312312                lineRuns.last().right = lineRuns.last().left;
    313                 lineRuns.last().textLength = 1;
     313                lineRuns.last().end = lineEnd + 1;
    314314                lineEnd = wordEnd;
    315315                break;
     
    344344                        if (whitespaceEnd < textLength && text[whitespaceEnd] == '\n')
    345345                            ++whitespaceEnd;
    346                         lineRuns.last().textLength = whitespaceEnd - lineRuns.last().textOffset;
     346                        lineRuns.last().end = whitespaceEnd;
    347347                        lineRuns.last().right = lineWidth.availableWidth();
    348348                        lineEnd = whitespaceEnd;
     
    356356                ASSERT(wordIsPrecededByWhitespace);
    357357                // Include space to the end of the previous run.
    358                 lineRuns.last().textLength++;
     358                lineRuns.last().end++;
    359359                lineRuns.last().right += spaceWidth;
    360360                // Start a new run on the same line.
     
    365365
    366366            lineRuns.last().right = lineWidth.committedWidth();
    367             lineRuns.last().textLength = wordEnd - lineRuns.last().textOffset;
     367            lineRuns.last().end = wordEnd;
    368368
    369369            lineEnd = wordEnd;
  • trunk/Source/WebCore/rendering/SimpleLineLayout.h

    r158268 r159032  
    4545struct Run {
    4646    Run() { }
    47     Run(unsigned textOffset, float left)
    48         : textOffset(textOffset)
    49         , textLength(0)
     47    Run(unsigned start, float left)
     48        : start(start)
     49        , end(start)
    5050        , isEndOfLine(false)
    5151        , left(left)
     
    5353    { }
    5454
    55     unsigned textOffset;
    56     unsigned textLength : 31;
     55    unsigned start;
     56    unsigned end : 31;
    5757    unsigned isEndOfLine : 1;
    5858    float left;
  • trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.h

    r158268 r159032  
    8585    if (!layout.runCount())
    8686        return 0;
    87     return layout.runAt(0).textOffset;
     87    return layout.runAt(0).start;
    8888}
    8989
     
    9393        return renderer.textLength();
    9494    auto& last = layout.runAt(layout.runCount() - 1);
    95     return last.textOffset + last.textLength;
     95    return last.end;
    9696}
    9797
     
    100100    for (unsigned i = 0; i < layout.runCount(); ++i) {
    101101        auto& run = layout.runAt(i);
    102         if (offset < run.textOffset)
     102        if (offset < run.start)
    103103            return false;
    104         if (offset <= run.textOffset + run.textLength)
     104        if (offset <= run.end)
    105105            return true;
    106106    }
     
    111111{
    112112    for (unsigned i = 0; i < layout.runCount(); ++i) {
    113         if (layout.runAt(i).textLength)
     113        auto& run = layout.runAt(i);
     114        if (run.end > run.start)
    114115            return true;
    115116    }
  • trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h

    r158268 r159032  
    149149    auto& resolver = m_iterator.resolver();
    150150    auto& run = m_iterator.simpleRun();
    151     return resolver.m_string.substringSharingImpl(run.textOffset, run.textLength);
     151    return resolver.m_string.substringSharingImpl(run.start, run.end - run.start);
    152152}
    153153
Note: See TracChangeset for help on using the changeset viewer.