Changeset 176123 in webkit
- Timestamp:
- Nov 14, 2014 8:20:18 AM (9 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r175782 r176123 2352 2352 rendering/SimpleLineLayout.cpp 2353 2353 rendering/SimpleLineLayoutFunctions.cpp 2354 rendering/SimpleLineLayoutResolver.cpp 2354 2355 rendering/TextAutosizer.cpp 2355 2356 rendering/TextPaintStyle.cpp -
trunk/Source/WebCore/ChangeLog
r176122 r176123 1 2014-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 1 43 2014-11-14 Andrzej Badowski <a.badowski@samsung.com> 2 44 -
trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
r175782 r176123 11512 11512 <ClCompile Include="..\rendering\SimpleLineLayout.cpp" /> 11513 11513 <ClCompile Include="..\rendering\SimpleLineLayoutFunctions.cpp" /> 11514 <ClCompile Include="..\rendering\SimpleLineLayoutResolver.cpp" /> 11514 11515 <ClCompile Include="..\rendering\TextPaintStyle.cpp" /> 11515 11516 <ClCompile Include="..\rendering\line\LineBreaker.cpp" /> -
trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
r176112 r176123 6938 6938 <Filter>rendering</Filter> 6939 6939 </ClCompile> 6940 <ClCompile Include="..\rendering\SimpleLineLayoutResolver.cpp"> 6941 <Filter>rendering</Filter> 6942 </ClCompile> 6940 6943 <ClCompile Include="..\css\CSSGridTemplateAreasValue.cpp"> 6941 6944 <Filter>css</Filter> -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r176112 r176123 2059 2059 57CF497414EE36D700ECFF14 /* InsertionPoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57CF497214EE36D700ECFF14 /* InsertionPoint.cpp */; }; 2060 2060 57CF497514EE36D700ECFF14 /* InsertionPoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 57CF497314EE36D700ECFF14 /* InsertionPoint.h */; }; 2061 585D6DFC1A15355600FA4F12 /* SimpleLineLayoutResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 585D6DFB1A15355600FA4F12 /* SimpleLineLayoutResolver.cpp */; }; 2061 2062 589556ED18D4A44000764B03 /* BorderEdge.h in Headers */ = {isa = PBXBuildFile; fileRef = 589556EC18D4A44000764B03 /* BorderEdge.h */; }; 2062 2063 58AEE2F418D4BCCF0022E7FE /* BorderEdge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 58AEE2F318D4BCCF0022E7FE /* BorderEdge.cpp */; }; … … 9172 9173 57CF497214EE36D700ECFF14 /* InsertionPoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InsertionPoint.cpp; sourceTree = "<group>"; }; 9173 9174 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>"; }; 9174 9176 589556EC18D4A44000764B03 /* BorderEdge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BorderEdge.h; sourceTree = "<group>"; }; 9175 9177 58AEE2F318D4BCCF0022E7FE /* BorderEdge.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BorderEdge.cpp; sourceTree = "<group>"; }; … … 22482 22484 E4E9B11A18145692003ACCDF /* SimpleLineLayoutFunctions.cpp */, 22483 22485 E4E9B11C1814569C003ACCDF /* SimpleLineLayoutFunctions.h */, 22486 585D6DFB1A15355600FA4F12 /* SimpleLineLayoutResolver.cpp */, 22484 22487 E4E9B1181810916F003ACCDF /* SimpleLineLayoutResolver.h */, 22485 22488 A8CFF04C0A154F09000A4234 /* TableLayout.h */, … … 28414 28417 A86629D209DA2B48009633A5 /* JSMouseEvent.cpp in Sources */, 28415 28418 C6F420A216B7164E0052A9F2 /* JSMutationCallback.cpp in Sources */, 28419 585D6DFC1A15355600FA4F12 /* SimpleLineLayoutResolver.cpp in Sources */, 28416 28420 65DF31FB09D1CC60000BE325 /* JSMutationEvent.cpp in Sources */, 28417 28421 C6F0902C14327D4F00685849 /* JSMutationObserver.cpp in Sources */, -
trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h
r175565 r176123 148 148 LineResolver lineResolver(const RenderBlockFlow&, const Layout&); 149 149 150 inline RunResolver::Run::Run(const Iterator& iterator)151 : m_iterator(iterator)152 {153 }154 155 150 inline unsigned RunResolver::Run::start() const 156 151 { … … 163 158 } 164 159 165 inline LayoutRect RunResolver::Run::rect() const166 {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() const177 {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() const186 {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 192 160 inline unsigned RunResolver::Run::lineIndex() const 193 161 { 194 162 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 {202 163 } 203 164 … … 223 184 } 224 185 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 248 186 inline const SimpleLineLayout::Run& RunResolver::Iterator::simpleRun() const 249 187 { … … 251 189 } 252 190 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 264 191 inline RunResolver::Iterator RunResolver::begin() const 265 192 { … … 270 197 { 271 198 return Iterator(*this, m_layout.runCount(), m_layout.lineCount()); 272 }273 274 inline unsigned RunResolver::lineIndexForHeight(LayoutUnit height, IndexType type) const275 {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 else282 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) const288 {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 {307 199 } 308 200 … … 323 215 } 324 216 325 inline const LayoutRect LineResolver::Iterator::operator*() const326 {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 341 217 inline LineResolver::Iterator LineResolver::begin() const 342 218 {
Note: See TracChangeset
for help on using the changeset viewer.