Changeset 158268 in webkit


Ignore:
Timestamp:
Oct 30, 2013 7:12:32 AM (10 years ago)
Author:
Antti Koivisto
Message:

Make SimpleLineLayout::Layout a class
https://bugs.webkit.org/show_bug.cgi?id=123508

Reviewed by Mario Sanchez Prada.

Improve encapsulation.

Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r158265 r158268  
     12013-10-30  Antti Koivisto  <antti@apple.com>
     2
     3        Make SimpleLineLayout::Layout a class
     4        https://bugs.webkit.org/show_bug.cgi?id=123508
     5
     6        Reviewed by Mario Sanchez Prada.
     7
     8        Improve encapsulation.
     9
    1102013-10-30  Antti Koivisto  <antti@apple.com>
    211
  • trunk/Source/WebCore/rendering/RenderBlockFlow.cpp

    r158163 r158268  
    31493149
    31503150    if (m_simpleLineLayout)
    3151         return m_simpleLineLayout->lineCount;
     3151        return m_simpleLineLayout->lineCount();
    31523152
    31533153    return lineBoxes().firstLineBox();
  • trunk/Source/WebCore/rendering/SimpleLineLayout.cpp

    r158225 r158268  
    335335
    336336Layout::Layout(const RunVector& runVector, unsigned lineCount)
    337     : runCount(runVector.size())
    338     , lineCount(lineCount)
    339 {
    340     memcpy(runs, runVector.data(), runCount * sizeof(Run));
    341 }
    342 
    343 }
    344 }
     337    : m_lineCount(lineCount)
     338    , m_runCount(runVector.size())
     339{
     340    memcpy(m_runs, runVector.data(), m_runCount * sizeof(Run));
     341}
     342
     343}
     344}
  • trunk/Source/WebCore/rendering/SimpleLineLayout.h

    r158265 r158268  
    6060};
    6161
    62 struct Layout {
     62class Layout {
    6363    WTF_MAKE_FAST_ALLOCATED;
    6464public:
     
    6666    static std::unique_ptr<Layout> create(const RunVector&, unsigned lineCount);
    6767
    68     unsigned runCount;
    69     unsigned lineCount;
    70     Run runs[0];
     68    unsigned lineCount() const { return m_lineCount; }
     69
     70    unsigned runCount() const { return m_runCount; }
     71    const Run& runAt(unsigned i) const { return m_runs[i]; }
    7172
    7273private:
    7374    Layout(const RunVector&, unsigned lineCount);
     75
     76    unsigned m_lineCount;
     77    unsigned m_runCount;
     78    Run m_runs[0];
    7479};
    7580
  • trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp

    r158214 r158268  
    7575        return false;
    7676
    77     if (!layout.runCount)
     77    if (!layout.runCount())
    7878        return false;
    7979
  • trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.h

    r158214 r158268  
    6666inline LayoutUnit computeFlowHeight(const RenderBlockFlow& flow, const Layout& layout)
    6767{
    68     return lineHeightFromFlow(flow) * layout.lineCount;
     68    return lineHeightFromFlow(flow) * layout.lineCount();
    6969}
    7070
    7171inline LayoutUnit computeFlowFirstLineBaseline(const RenderBlockFlow& flow, const Layout& layout)
    7272{
    73     ASSERT_UNUSED(layout, layout.runCount);
     73    ASSERT_UNUSED(layout, layout.runCount());
    7474    return flow.borderAndPaddingBefore() + baselineFromFlow(flow);
    7575}
     
    7777inline LayoutUnit computeFlowLastLineBaseline(const RenderBlockFlow& flow, const Layout& layout)
    7878{
    79     ASSERT(layout.runCount);
    80     return flow.borderAndPaddingBefore() + lineHeightFromFlow(flow) * (layout.runCount - 1) + baselineFromFlow(flow);
     79    ASSERT(layout.runCount());
     80    return flow.borderAndPaddingBefore() + lineHeightFromFlow(flow) * (layout.runCount() - 1) + baselineFromFlow(flow);
    8181}
    8282
    8383inline unsigned findTextCaretMinimumOffset(const RenderText&, const Layout& layout)
    8484{
    85     if (!layout.runCount)
     85    if (!layout.runCount())
    8686        return 0;
    87     return layout.runs[0].textOffset;
     87    return layout.runAt(0).textOffset;
    8888}
    8989
    9090inline unsigned findTextCaretMaximumOffset(const RenderText& renderer, const Layout& layout)
    9191{
    92     if (!layout.runCount)
     92    if (!layout.runCount())
    9393        return renderer.textLength();
    94     auto& last = layout.runs[layout.runCount - 1];
     94    auto& last = layout.runAt(layout.runCount() - 1);
    9595    return last.textOffset + last.textLength;
    9696}
     
    9898inline bool containsTextCaretOffset(const RenderText&, const Layout& layout, unsigned offset)
    9999{
    100     for (unsigned i = 0; i < layout.runCount; ++i) {
    101         auto& line = layout.runs[i];
    102         if (offset < line.textOffset)
     100    for (unsigned i = 0; i < layout.runCount(); ++i) {
     101        auto& run = layout.runAt(i);
     102        if (offset < run.textOffset)
    103103            return false;
    104         if (offset <= line.textOffset + line.textLength)
     104        if (offset <= run.textOffset + run.textLength)
    105105            return true;
    106106    }
     
    110110inline bool isTextRendered(const RenderText&, const Layout& layout)
    111111{
    112     for (unsigned i = 0; i < layout.runCount; ++i) {
    113         if (layout.runs[i].textLength)
     112    for (unsigned i = 0; i < layout.runCount(); ++i) {
     113        if (layout.runAt(i).textLength)
    114114            return true;
    115115    }
  • trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h

    r158225 r158268  
    190190inline const SimpleLineLayout::Run& RunResolver::Iterator::simpleRun() const
    191191{
    192     return m_resolver.m_layout.runs[m_runIndex];
     192    return m_resolver.m_layout.runAt(m_runIndex);
    193193}
    194194
     
    211211inline RunResolver::Iterator RunResolver::end() const
    212212{
    213     return Iterator(*this, m_layout.runCount);
     213    return Iterator(*this, m_layout.runCount());
    214214}
    215215
Note: See TracChangeset for help on using the changeset viewer.