Changeset 176123 in webkit


Ignore:
Timestamp:
Nov 14, 2014 8:20:18 AM (9 years ago)
Author:
Alan Bujtas
Message:

Simple line layout: Move simple line layout RunResolver and LineResolver implementation to SimpleLineLayoutResolver.cpp
https://bugs.webkit.org/show_bug.cgi?id=138704

Reviewed by Antti Koivisto.

No change in functionality.

  • CMakeLists.txt:
  • WebCore.vcxproj/WebCore.vcxproj:
  • WebCore.vcxproj/WebCore.vcxproj.filters:
  • WebCore.xcodeproj/project.pbxproj:
  • rendering/SimpleLineLayoutResolver.cpp: Added.

(WebCore::SimpleLineLayout::RunResolver::Run::Run):
(WebCore::SimpleLineLayout::RunResolver::Run::rect):
(WebCore::SimpleLineLayout::RunResolver::Run::baseline):
(WebCore::SimpleLineLayout::RunResolver::Run::text):
(WebCore::SimpleLineLayout::RunResolver::Iterator::Iterator):
(WebCore::SimpleLineLayout::RunResolver::Iterator::advance):
(WebCore::SimpleLineLayout::RunResolver::Iterator::advanceLines):
(WebCore::SimpleLineLayout::RunResolver::RunResolver):
(WebCore::SimpleLineLayout::RunResolver::lineIndexForHeight):
(WebCore::SimpleLineLayout::RunResolver::rangeForRect):
(WebCore::SimpleLineLayout::LineResolver::Iterator::Iterator):
(WebCore::SimpleLineLayout::LineResolver::Iterator::operator*):
(WebCore::SimpleLineLayout::LineResolver::LineResolver):

  • rendering/SimpleLineLayoutResolver.h:

(WebCore::SimpleLineLayout::RunResolver::Run::Run): Deleted.
(WebCore::SimpleLineLayout::RunResolver::Run::rect): Deleted.
(WebCore::SimpleLineLayout::RunResolver::Run::baseline): Deleted.
(WebCore::SimpleLineLayout::RunResolver::Run::text): Deleted.
(WebCore::SimpleLineLayout::RunResolver::Iterator::Iterator): Deleted.
(WebCore::SimpleLineLayout::RunResolver::Iterator::advance): Deleted.
(WebCore::SimpleLineLayout::RunResolver::Iterator::advanceLines): Deleted.
(WebCore::SimpleLineLayout::RunResolver::RunResolver): Deleted.
(WebCore::SimpleLineLayout::RunResolver::lineIndexForHeight): Deleted.
(WebCore::SimpleLineLayout::RunResolver::rangeForRect): Deleted.
(WebCore::SimpleLineLayout::LineResolver::Iterator::Iterator): Deleted.
(WebCore::SimpleLineLayout::LineResolver::Iterator::operator*): Deleted.
(WebCore::SimpleLineLayout::LineResolver::LineResolver): Deleted.

Location:
trunk/Source/WebCore
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r175782 r176123  
    23522352    rendering/SimpleLineLayout.cpp
    23532353    rendering/SimpleLineLayoutFunctions.cpp
     2354    rendering/SimpleLineLayoutResolver.cpp
    23542355    rendering/TextAutosizer.cpp
    23552356    rendering/TextPaintStyle.cpp
  • trunk/Source/WebCore/ChangeLog

    r176122 r176123  
     12014-11-14  Zalan Bujtas  <zalan@apple.com>
     2
     3        Simple line layout: Move simple line layout RunResolver and LineResolver implementation to SimpleLineLayoutResolver.cpp
     4        https://bugs.webkit.org/show_bug.cgi?id=138704
     5
     6        Reviewed by Antti Koivisto.
     7
     8        No change in functionality.
     9
     10        * CMakeLists.txt:
     11        * WebCore.vcxproj/WebCore.vcxproj:
     12        * WebCore.vcxproj/WebCore.vcxproj.filters:
     13        * WebCore.xcodeproj/project.pbxproj:
     14        * rendering/SimpleLineLayoutResolver.cpp: Added.
     15        (WebCore::SimpleLineLayout::RunResolver::Run::Run):
     16        (WebCore::SimpleLineLayout::RunResolver::Run::rect):
     17        (WebCore::SimpleLineLayout::RunResolver::Run::baseline):
     18        (WebCore::SimpleLineLayout::RunResolver::Run::text):
     19        (WebCore::SimpleLineLayout::RunResolver::Iterator::Iterator):
     20        (WebCore::SimpleLineLayout::RunResolver::Iterator::advance):
     21        (WebCore::SimpleLineLayout::RunResolver::Iterator::advanceLines):
     22        (WebCore::SimpleLineLayout::RunResolver::RunResolver):
     23        (WebCore::SimpleLineLayout::RunResolver::lineIndexForHeight):
     24        (WebCore::SimpleLineLayout::RunResolver::rangeForRect):
     25        (WebCore::SimpleLineLayout::LineResolver::Iterator::Iterator):
     26        (WebCore::SimpleLineLayout::LineResolver::Iterator::operator*):
     27        (WebCore::SimpleLineLayout::LineResolver::LineResolver):
     28        * rendering/SimpleLineLayoutResolver.h:
     29        (WebCore::SimpleLineLayout::RunResolver::Run::Run): Deleted.
     30        (WebCore::SimpleLineLayout::RunResolver::Run::rect): Deleted.
     31        (WebCore::SimpleLineLayout::RunResolver::Run::baseline): Deleted.
     32        (WebCore::SimpleLineLayout::RunResolver::Run::text): Deleted.
     33        (WebCore::SimpleLineLayout::RunResolver::Iterator::Iterator): Deleted.
     34        (WebCore::SimpleLineLayout::RunResolver::Iterator::advance): Deleted.
     35        (WebCore::SimpleLineLayout::RunResolver::Iterator::advanceLines): Deleted.
     36        (WebCore::SimpleLineLayout::RunResolver::RunResolver): Deleted.
     37        (WebCore::SimpleLineLayout::RunResolver::lineIndexForHeight): Deleted.
     38        (WebCore::SimpleLineLayout::RunResolver::rangeForRect): Deleted.
     39        (WebCore::SimpleLineLayout::LineResolver::Iterator::Iterator): Deleted.
     40        (WebCore::SimpleLineLayout::LineResolver::Iterator::operator*): Deleted.
     41        (WebCore::SimpleLineLayout::LineResolver::LineResolver): Deleted.
     42
    1432014-11-14  Andrzej Badowski  <a.badowski@samsung.com>
    244
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj

    r175782 r176123  
    1151211512    <ClCompile Include="..\rendering\SimpleLineLayout.cpp" />
    1151311513    <ClCompile Include="..\rendering\SimpleLineLayoutFunctions.cpp" />
     11514    <ClCompile Include="..\rendering\SimpleLineLayoutResolver.cpp" />
    1151411515    <ClCompile Include="..\rendering\TextPaintStyle.cpp" />
    1151511516    <ClCompile Include="..\rendering\line\LineBreaker.cpp" />
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters

    r176112 r176123  
    69386938      <Filter>rendering</Filter>
    69396939    </ClCompile>
     6940    <ClCompile Include="..\rendering\SimpleLineLayoutResolver.cpp">
     6941      <Filter>rendering</Filter>
     6942    </ClCompile>
    69406943    <ClCompile Include="..\css\CSSGridTemplateAreasValue.cpp">
    69416944      <Filter>css</Filter>
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r176112 r176123  
    20592059                57CF497414EE36D700ECFF14 /* InsertionPoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57CF497214EE36D700ECFF14 /* InsertionPoint.cpp */; };
    20602060                57CF497514EE36D700ECFF14 /* InsertionPoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 57CF497314EE36D700ECFF14 /* InsertionPoint.h */; };
     2061                585D6DFC1A15355600FA4F12 /* SimpleLineLayoutResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 585D6DFB1A15355600FA4F12 /* SimpleLineLayoutResolver.cpp */; };
    20612062                589556ED18D4A44000764B03 /* BorderEdge.h in Headers */ = {isa = PBXBuildFile; fileRef = 589556EC18D4A44000764B03 /* BorderEdge.h */; };
    20622063                58AEE2F418D4BCCF0022E7FE /* BorderEdge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 58AEE2F318D4BCCF0022E7FE /* BorderEdge.cpp */; };
     
    91729173                57CF497214EE36D700ECFF14 /* InsertionPoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InsertionPoint.cpp; sourceTree = "<group>"; };
    91739174                57CF497314EE36D700ECFF14 /* InsertionPoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InsertionPoint.h; sourceTree = "<group>"; };
     9175                585D6DFB1A15355600FA4F12 /* SimpleLineLayoutResolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleLineLayoutResolver.cpp; sourceTree = "<group>"; };
    91749176                589556EC18D4A44000764B03 /* BorderEdge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BorderEdge.h; sourceTree = "<group>"; };
    91759177                58AEE2F318D4BCCF0022E7FE /* BorderEdge.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BorderEdge.cpp; sourceTree = "<group>"; };
     
    2248222484                                E4E9B11A18145692003ACCDF /* SimpleLineLayoutFunctions.cpp */,
    2248322485                                E4E9B11C1814569C003ACCDF /* SimpleLineLayoutFunctions.h */,
     22486                                585D6DFB1A15355600FA4F12 /* SimpleLineLayoutResolver.cpp */,
    2248422487                                E4E9B1181810916F003ACCDF /* SimpleLineLayoutResolver.h */,
    2248522488                                A8CFF04C0A154F09000A4234 /* TableLayout.h */,
     
    2841428417                                A86629D209DA2B48009633A5 /* JSMouseEvent.cpp in Sources */,
    2841528418                                C6F420A216B7164E0052A9F2 /* JSMutationCallback.cpp in Sources */,
     28419                                585D6DFC1A15355600FA4F12 /* SimpleLineLayoutResolver.cpp in Sources */,
    2841628420                                65DF31FB09D1CC60000BE325 /* JSMutationEvent.cpp in Sources */,
    2841728421                                C6F0902C14327D4F00685849 /* JSMutationObserver.cpp in Sources */,
  • trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h

    r175565 r176123  
    148148LineResolver lineResolver(const RenderBlockFlow&, const Layout&);
    149149
    150 inline RunResolver::Run::Run(const Iterator& iterator)
    151     : m_iterator(iterator)
    152 {
    153 }
    154 
    155150inline unsigned RunResolver::Run::start() const
    156151{
     
    163158}
    164159
    165 inline LayoutRect RunResolver::Run::rect() const
    166 {
    167     auto& resolver = m_iterator.resolver();
    168     auto& run = m_iterator.simpleRun();
    169 
    170     float baselinePosition = resolver.m_lineHeight * m_iterator.lineIndex() + resolver.m_baseline;
    171     LayoutPoint linePosition(LayoutUnit::fromFloatFloor(run.logicalLeft), roundToInt(baselinePosition - resolver.m_ascent + resolver.m_borderAndPaddingBefore));
    172     LayoutSize lineSize(LayoutUnit::fromFloatCeil(run.logicalRight) - LayoutUnit::fromFloatFloor(run.logicalLeft), resolver.m_ascent + resolver.m_descent);
    173     return LayoutRect(linePosition, lineSize);
    174 }
    175 
    176 inline FloatPoint RunResolver::Run::baseline() const
    177 {
    178     auto& resolver = m_iterator.resolver();
    179     auto& run = m_iterator.simpleRun();
    180 
    181     float baselinePosition = resolver.m_lineHeight * m_iterator.lineIndex() + resolver.m_baseline;
    182     return FloatPoint(run.logicalLeft, roundToInt(baselinePosition + resolver.m_borderAndPaddingBefore));
    183 }
    184 
    185 inline StringView RunResolver::Run::text() const
    186 {
    187     auto& resolver = m_iterator.resolver();
    188     auto& run = m_iterator.simpleRun();
    189     return StringView(resolver.m_string).substring(run.start, run.end - run.start);
    190 }
    191 
    192160inline unsigned RunResolver::Run::lineIndex() const
    193161{
    194162    return m_iterator.lineIndex();
    195 }
    196 
    197 inline RunResolver::Iterator::Iterator(const RunResolver& resolver, unsigned runIndex, unsigned lineIndex)
    198     : m_resolver(resolver)
    199     , m_runIndex(runIndex)
    200     , m_lineIndex(lineIndex)
    201 {
    202163}
    203164
     
    223184}
    224185
    225 inline RunResolver::Iterator& RunResolver::Iterator::advance()
    226 {
    227     if (simpleRun().isEndOfLine)
    228         ++m_lineIndex;
    229     ++m_runIndex;
    230     return *this;
    231 }
    232 
    233 inline RunResolver::Iterator& RunResolver::Iterator::advanceLines(unsigned lineCount)
    234 {
    235     unsigned runCount = m_resolver.m_layout.runCount();
    236     if (runCount == m_resolver.m_layout.lineCount()) {
    237         m_runIndex = std::min(runCount, m_runIndex + lineCount);
    238         m_lineIndex = m_runIndex;
    239         return *this;
    240     }
    241     unsigned target = m_lineIndex + lineCount;
    242     while (m_lineIndex < target && m_runIndex < runCount)
    243         advance();
    244 
    245     return *this;
    246 }
    247 
    248186inline const SimpleLineLayout::Run& RunResolver::Iterator::simpleRun() const
    249187{
     
    251189}
    252190
    253 inline RunResolver::RunResolver(const RenderBlockFlow& flow, const Layout& layout)
    254     : m_layout(layout)
    255     , m_string(downcast<RenderText>(*flow.firstChild()).text())
    256     , m_lineHeight(lineHeightFromFlow(flow))
    257     , m_baseline(baselineFromFlow(flow))
    258     , m_borderAndPaddingBefore(flow.borderAndPaddingBefore())
    259     , m_ascent(flow.style().font().fontMetrics().ascent())
    260     , m_descent(flow.style().font().fontMetrics().descent())
    261 {
    262 }
    263 
    264191inline RunResolver::Iterator RunResolver::begin() const
    265192{
     
    270197{
    271198    return Iterator(*this, m_layout.runCount(), m_layout.lineCount());
    272 }
    273 
    274 inline unsigned RunResolver::lineIndexForHeight(LayoutUnit height, IndexType type) const
    275 {
    276     ASSERT(m_lineHeight);
    277     float y = height - m_borderAndPaddingBefore;
    278     // Lines may overlap, adjust to get the first or last line at this height.
    279     if (type == IndexType::First)
    280         y += m_lineHeight - (m_baseline + m_descent);
    281     else
    282         y -= m_baseline - m_ascent;
    283     y = std::max<float>(y, 0);
    284     return std::min<unsigned>(y / m_lineHeight, m_layout.lineCount() - 1);
    285 }
    286 
    287 inline Range<RunResolver::Iterator> RunResolver::rangeForRect(const LayoutRect& rect) const
    288 {
    289     if (!m_lineHeight)
    290         return Range<Iterator>(begin(), end());
    291 
    292     unsigned firstLine = lineIndexForHeight(rect.y(), IndexType::First);
    293     unsigned lastLine = std::max(firstLine, lineIndexForHeight(rect.maxY(), IndexType::Last));
    294 
    295     auto rangeBegin = begin().advanceLines(firstLine);
    296     if (rangeBegin == end())
    297         return Range<Iterator>(end(), end());
    298     auto rangeEnd = rangeBegin;
    299     ASSERT(lastLine >= firstLine);
    300     rangeEnd.advanceLines(lastLine - firstLine + 1);
    301     return Range<Iterator>(rangeBegin, rangeEnd);
    302 }
    303 
    304 inline LineResolver::Iterator::Iterator(RunResolver::Iterator runIterator)
    305     : m_runIterator(runIterator)
    306 {
    307199}
    308200
     
    323215}
    324216
    325 inline const LayoutRect LineResolver::Iterator::operator*() const
    326 {
    327     unsigned currentLine = m_runIterator.lineIndex();
    328     auto it = m_runIterator;
    329     LayoutRect rect = (*it).rect();
    330     while (it.advance().lineIndex() == currentLine)
    331         rect.unite((*it).rect());
    332 
    333     return rect;
    334 }
    335 
    336 inline LineResolver::LineResolver(const RenderBlockFlow& flow, const Layout& layout)
    337     : m_runResolver(flow, layout)
    338 {
    339 }
    340 
    341217inline LineResolver::Iterator LineResolver::begin() const
    342218{
Note: See TracChangeset for help on using the changeset viewer.