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

Changeset 181682 in webkit


Ignore:
Timestamp:
Mar 17, 2015, 8:40:51 PM (11 years ago)
Author:
Alan Bujtas
Message:

Simple line layout: Change FlowContents::segmentForPosition() to segmentForRun().
https://bugs.webkit.org/show_bug.cgi?id=142785

Reviewed by Antti Koivisto.

This is in transition to support <br>. A particular position could point to multiple
segments when <br> is directly followed by text.

No change in functionality.

  • rendering/SimpleLineLayoutFlowContents.cpp:

(WebCore::SimpleLineLayout::FlowContents::segmentIndexForRunSlow):
(WebCore::SimpleLineLayout::FlowContents::segmentIndexForPositionSlow): Deleted.

  • rendering/SimpleLineLayoutFlowContents.h:

(WebCore::SimpleLineLayout::FlowContents::segmentForRun):
(WebCore::SimpleLineLayout::FlowContents::segmentIndexForPosition): Deleted.
(WebCore::SimpleLineLayout::FlowContents::segmentForPosition): Deleted.

  • rendering/SimpleLineLayoutResolver.cpp:

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

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r181671 r181682  
     12015-03-17  Zalan Bujtas  <zalan@apple.com>
     2
     3        Simple line layout: Change FlowContents::segmentForPosition() to segmentForRun().
     4        https://bugs.webkit.org/show_bug.cgi?id=142785
     5
     6        Reviewed by Antti Koivisto.
     7
     8        This is in transition to support <br>. A particular position could point to multiple
     9        segments when <br> is directly followed by text.
     10
     11        No change in functionality.
     12
     13        * rendering/SimpleLineLayoutFlowContents.cpp:
     14        (WebCore::SimpleLineLayout::FlowContents::segmentIndexForRunSlow):
     15        (WebCore::SimpleLineLayout::FlowContents::segmentIndexForPositionSlow): Deleted.
     16        * rendering/SimpleLineLayoutFlowContents.h:
     17        (WebCore::SimpleLineLayout::FlowContents::segmentForRun):
     18        (WebCore::SimpleLineLayout::FlowContents::segmentIndexForPosition): Deleted.
     19        (WebCore::SimpleLineLayout::FlowContents::segmentForPosition): Deleted.
     20        * rendering/SimpleLineLayoutResolver.cpp:
     21        (WebCore::SimpleLineLayout::RunResolver::Run::text):
     22
    1232015-03-17  Chris Dumez  <cdumez@apple.com>
    224
  • trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContents.cpp

    r181290 r181682  
    5252}
    5353
    54 unsigned FlowContents::segmentIndexForPositionSlow(unsigned position) const
     54unsigned FlowContents::segmentIndexForRunSlow(unsigned start, unsigned end) const
    5555{
    56     auto it = std::lower_bound(m_segments.begin(), m_segments.end(), position, [](const Segment& segment, unsigned position) {
    57         return segment.end <= position;
     56    auto it = std::lower_bound(m_segments.begin(), m_segments.end(), start, [](const Segment& segment, unsigned start) {
     57        return segment.end <= start;
    5858    });
    5959    ASSERT(it != m_segments.end());
     60    ASSERT_UNUSED(end, end <= it->end);
    6061    auto index = it - m_segments.begin();
    6162    m_lastSegmentIndex = index;
  • trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContents.h

    r181667 r181682  
    4444        const RenderObject& renderer;
    4545    };
    46     const Segment& segmentForPosition(unsigned) const;
     46    const Segment& segmentForRun(unsigned start, unsigned end) const;
    4747    const Segment& segmentForRenderer(const RenderObject&) const;
    4848
     
    7070    Iterator end() const { return Iterator(*this, m_segments.size()); }
    7171
    72     unsigned segmentIndexForPosition(unsigned position) const;
    73 
    7472private:
    75     unsigned segmentIndexForPositionSlow(unsigned position) const;
     73    unsigned segmentIndexForRunSlow(unsigned start, unsigned end) const;
    7674    const Vector<Segment, 8> m_segments;
    7775    mutable unsigned m_lastSegmentIndex;
     
    112110}
    113111
    114 inline unsigned FlowContents::segmentIndexForPosition(unsigned position) const
     112inline const FlowContents::Segment& FlowContents::segmentForRun(unsigned start, unsigned end) const
    115113{
     114    ASSERT(start < end);
    116115    auto& lastSegment = m_segments[m_lastSegmentIndex];
    117     if (lastSegment.start <= position && position < lastSegment.end)
    118         return m_lastSegmentIndex;
    119     return segmentIndexForPositionSlow(position);
    120 }
    121 
    122 inline const FlowContents::Segment& FlowContents::segmentForPosition(unsigned position) const
    123 {
    124     return m_segments[segmentIndexForPosition(position)];
     116    if (lastSegment.start <= start && end <= lastSegment.end)
     117        return m_segments[m_lastSegmentIndex];
     118    return m_segments[segmentIndexForRunSlow(start, end)];
    125119}
    126120
  • trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp

    r181290 r181682  
    7777    auto& resolver = m_iterator.resolver();
    7878    auto& run = m_iterator.simpleRun();
    79     auto& segment = resolver.m_flowContents.segmentForPosition(run.start);
     79    ASSERT(run.start < run.end);
     80    auto& segment = resolver.m_flowContents.segmentForRun(run.start, run.end);
    8081    // We currently split runs on segment boundaries (different RenderObject).
    8182    ASSERT(run.end <= segment.end);
Note: See TracChangeset for help on using the changeset viewer.