Changeset 177219 in webkit


Ignore:
Timestamp:
Dec 12, 2014 3:49:51 AM (9 years ago)
Author:
Alan Bujtas
Message:

Simple line layout: Add 16bit support.
https://bugs.webkit.org/show_bug.cgi?id=139469

Reviewed by Antti Koivisto.

This patch adds the 16bit support to simple line layout.

Source/WebCore:

Test: fast/inline/simple-line-layout-16bit-content.html

  • rendering/SimpleLineLayout.cpp:

(WebCore::SimpleLineLayout::canUseFor):

  • rendering/SimpleLineLayoutFlowContents.cpp:

(WebCore::SimpleLineLayout::nextBreakablePosition):
(WebCore::SimpleLineLayout::FlowContents::findNextBreakablePosition):
(WebCore::SimpleLineLayout::findNextNonWhitespace):
(WebCore::SimpleLineLayout::FlowContents::findNextNonWhitespacePosition):
(WebCore::SimpleLineLayout::FlowContents::textWidth):
(WebCore::SimpleLineLayout::FlowContents::runWidth):

  • rendering/SimpleLineLayoutFlowContents.h:
  • rendering/SimpleLineLayoutResolver.cpp:

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

LayoutTests:

  • fast/inline/simple-line-layout-16bit-content-expected.html: Added.
  • fast/inline/simple-line-layout-16bit-content.html: Added.
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r177203 r177219  
     12014-12-12  Zalan Bujtas  <zalan@apple.com>
     2
     3        Simple line layout: Add 16bit support.
     4        https://bugs.webkit.org/show_bug.cgi?id=139469
     5
     6        Reviewed by Antti Koivisto.
     7
     8        This patch adds the 16bit support to simple line layout.
     9
     10        * fast/inline/simple-line-layout-16bit-content-expected.html: Added.
     11        * fast/inline/simple-line-layout-16bit-content.html: Added.
     12
    1132014-12-11  Michael Saboff  <msaboff@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r177216 r177219  
     12014-12-12  Zalan Bujtas  <zalan@apple.com>
     2
     3        Simple line layout: Add 16bit support.
     4        https://bugs.webkit.org/show_bug.cgi?id=139469
     5
     6        Reviewed by Antti Koivisto.
     7
     8        This patch adds the 16bit support to simple line layout.
     9
     10        Test: fast/inline/simple-line-layout-16bit-content.html
     11
     12        * rendering/SimpleLineLayout.cpp:
     13        (WebCore::SimpleLineLayout::canUseFor):
     14        * rendering/SimpleLineLayoutFlowContents.cpp:
     15        (WebCore::SimpleLineLayout::nextBreakablePosition):
     16        (WebCore::SimpleLineLayout::FlowContents::findNextBreakablePosition):
     17        (WebCore::SimpleLineLayout::findNextNonWhitespace):
     18        (WebCore::SimpleLineLayout::FlowContents::findNextNonWhitespacePosition):
     19        (WebCore::SimpleLineLayout::FlowContents::textWidth):
     20        (WebCore::SimpleLineLayout::FlowContents::runWidth):
     21        * rendering/SimpleLineLayoutFlowContents.h:
     22        * rendering/SimpleLineLayoutResolver.cpp:
     23        (WebCore::SimpleLineLayout::RunResolver::Run::text):
     24
    1252014-12-12  ChangSeok Oh  <changseok.oh@collabora.com>
    226
  • trunk/Source/WebCore/rendering/SimpleLineLayout.cpp

    r176534 r177219  
    9898    // The <blockflow><inline>#text</inline></blockflow> case is also popular and should be relatively easy to cover.
    9999    for (const auto& renderer : childrenOfType<RenderObject>(flow)) {
    100         if (!is<RenderText>(renderer) || !downcast<RenderText>(renderer).text()->is8Bit())
     100        if (!is<RenderText>(renderer))
    101101            return false;
    102102    }
  • trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContents.cpp

    r176528 r177219  
    6767}
    6868
     69template <typename CharacterType>
     70static unsigned nextBreakablePosition(LazyLineBreakIterator& lineBreakItearator, const FlowContents::Segment& segment, unsigned position)
     71{
     72    const auto* characters = segment.text.characters<CharacterType>();
     73    unsigned segmentLength = segment.end - segment.start;
     74    unsigned segmentPosition = position - segment.start;
     75    return nextBreakablePositionNonLoosely<CharacterType, NBSPBehavior::IgnoreNBSP>(lineBreakItearator, characters, segmentLength, segmentPosition);
     76}
     77
    6978unsigned FlowContents::findNextBreakablePosition(unsigned position) const
    7079{
     
    7887        }
    7988
    80         auto* characters = segment.text.characters8();
    81         unsigned segmentLength = segment.end - segment.start;
    82         unsigned segmentPosition = position - segment.start;
    83         unsigned breakable = nextBreakablePositionNonLoosely<LChar, NBSPBehavior::IgnoreNBSP>(m_lineBreakIterator, characters, segmentLength, segmentPosition);
     89        unsigned breakable = segment.text.is8Bit() ? nextBreakablePosition<LChar>(m_lineBreakIterator, segment, position) : nextBreakablePosition<UChar>(m_lineBreakIterator, segment, position);
    8490        position = segment.start + breakable;
    8591        if (position < segment.end)
     
    8995}
    9096
     97template <typename CharacterType>
    9198static bool findNextNonWhitespace(const FlowContents::Segment& segment, const FlowContents::Style& style, unsigned& position, unsigned& spaceCount)
    9299{
    93     const LChar* text = segment.text.characters8();
     100    const auto* text = segment.text.characters<CharacterType>();
    94101    for (; position < segment.end; ++position) {
    95102        auto character = text[position - segment.start];
     
    107114{
    108115    for (unsigned i = segmentIndexForPosition(position); i < m_segments.size(); ++i) {
    109         if (findNextNonWhitespace(m_segments[i], m_style, position, spaceCount))
     116        bool foundNonWhitespace = m_segments[i].text.is8Bit() ? findNextNonWhitespace<LChar>(m_segments[i], m_style, position, spaceCount) :
     117            findNextNonWhitespace<UChar>(m_segments[i], m_style, position, spaceCount);
     118        if (foundNonWhitespace)
    110119            break;
    111120    }
     
    115124float FlowContents::textWidth(unsigned from, unsigned to, float xPosition) const
    116125{
    117     auto& fromSegment = segmentForPosition(from);
     126    const auto& fromSegment = segmentForPosition(from);
    118127
    119128    if ((m_style.font.isFixedPitch() && fromSegment.end >= to) || (from == fromSegment.start && to == fromSegment.end))
    120129        return fromSegment.renderer.width(from - fromSegment.start, to - from, m_style.font, xPosition, nullptr, nullptr);
    121130
    122     auto* segment = &fromSegment;
     131    const auto* segment = &fromSegment;
    123132    float textWidth = 0;
    124133    unsigned fragmentEnd = 0;
    125134    while (true) {
    126135        fragmentEnd = std::min(to, segment->end);
    127         textWidth += runWidth(segment->text, from - segment->start, fragmentEnd - segment->start, xPosition + textWidth);
     136        textWidth += segment->text.is8Bit() ? runWidth<LChar>(segment->text, from - segment->start, fragmentEnd - segment->start, xPosition + textWidth) :
     137            runWidth<UChar>(segment->text, from - segment->start, fragmentEnd - segment->start, xPosition + textWidth);
    128138        if (fragmentEnd == to)
    129139            break;
     
    156166}
    157167
     168template <typename CharacterType>
    158169float FlowContents::runWidth(const String& text, unsigned from, unsigned to, float xPosition) const
    159170{
     
    162173    if (measureWithEndSpace)
    163174        ++to;
    164     TextRun run(text.characters8() + from, to - from);
     175    TextRun run(text.characters<CharacterType>() + from, to - from);
    165176    run.setXPos(xPosition);
    166177    run.setTabSize(!!m_style.tabWidth, m_style.tabWidth);
  • trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContents.h

    r176531 r177219  
    8181
    8282    UChar characterAt(unsigned position) const;
    83     float runWidth(const String&, unsigned from, unsigned to, float xPosition) const;
     83    template <typename CharacterType> float runWidth(const String&, unsigned from, unsigned to, float xPosition) const;
    8484
    8585    const Style m_style;
  • trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp

    r176510 r177219  
    7878    auto& run = m_iterator.simpleRun();
    7979    auto& segment = resolver.m_flowContents.segmentForPosition(run.start);
    80     ASSERT(segment.renderer.is8Bit());
    8180    // We currently split runs on segment boundaries (different RenderText).
    8281    ASSERT(run.end <= segment.end);
    83     return StringView(segment.renderer.characters8(), segment.renderer.textLength()).substring(run.start - segment.start, run.end - run.start);
     82    if (segment.renderer.is8Bit())
     83        return StringView(segment.renderer.characters8(), segment.renderer.textLength()).substring(run.start - segment.start, run.end - run.start);
     84    return StringView(segment.renderer.characters16(), segment.renderer.textLength()).substring(run.start - segment.start, run.end - run.start);
    8485}
    8586
Note: See TracChangeset for help on using the changeset viewer.