Changeset 158214 in webkit
- Timestamp:
- Oct 29, 2013 1:25:44 PM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r158212 r158214 1 2013-10-29 Antti Koivisto <antti@apple.com> 2 3 Make SimpleLineLayout::Layout a variable size object 4 https://bugs.webkit.org/show_bug.cgi?id=123459 5 6 Reviewed by Andreas Kling. 7 8 Less memory, less indirection. 9 10 * rendering/SimpleLineLayout.cpp: 11 (WebCore::SimpleLineLayout::canUseFor): 12 (WebCore::SimpleLineLayout::create): 13 (WebCore::SimpleLineLayout::Layout::create): 14 (WebCore::SimpleLineLayout::Layout::Layout): 15 * rendering/SimpleLineLayout.h: 16 * rendering/SimpleLineLayoutFunctions.cpp: 17 (WebCore::SimpleLineLayout::hitTestFlow): 18 * rendering/SimpleLineLayoutFunctions.h: 19 (WebCore::SimpleLineLayout::computeFlowFirstLineBaseline): 20 (WebCore::SimpleLineLayout::computeFlowLastLineBaseline): 21 (WebCore::SimpleLineLayout::findTextCaretMinimumOffset): 22 (WebCore::SimpleLineLayout::findTextCaretMaximumOffset): 23 (WebCore::SimpleLineLayout::containsTextCaretOffset): 24 (WebCore::SimpleLineLayout::isTextRendered): 25 * rendering/SimpleLineLayoutResolver.h: 26 (WebCore::SimpleLineLayout::RunResolver::end): 27 1 28 2013-10-29 Andreas Kling <akling@apple.com> 2 29 -
trunk/Source/WebCore/rendering/SimpleLineLayout.cpp
r158196 r158214 237 237 std::unique_ptr<Layout> create(RenderBlockFlow& flow) 238 238 { 239 auto layout = std::make_unique<Layout>();240 241 239 RenderText& textRenderer = toRenderText(*flow.firstChild()); 242 240 ASSERT(!textRenderer.firstTextBox()); … … 250 248 LazyLineBreakIterator lineBreakIterator(textRenderer.text(), style.locale()); 251 249 int nextBreakable = -1; 250 251 Layout::RunVector runs; 252 unsigned lineCount = 0; 252 253 253 254 unsigned lineEndOffset = 0; … … 319 320 320 321 for (unsigned i = 0; i < lineRuns.size(); ++i) 321 layout->runs.append(lineRuns[i]);322 323 layout->runs.last().isEndOfLine = true;324 layout->lineCount++;322 runs.append(lineRuns[i]); 323 324 runs.last().isEndOfLine = true; 325 ++lineCount; 325 326 } 326 327 327 328 textRenderer.clearNeedsLayout(); 328 329 329 layout->runs.shrinkToFit(); 330 return layout; 331 } 332 333 } 334 } 330 return Layout::create(runs, lineCount); 331 } 332 333 std::unique_ptr<Layout> Layout::create(const RunVector& runVector, unsigned lineCount) 334 { 335 void* slot = WTF::fastMalloc(sizeof(Layout) + sizeof(Run) * runVector.size()); 336 return std::unique_ptr<Layout>(new (NotNull, slot) Layout(runVector, lineCount)); 337 } 338 339 Layout::Layout(const RunVector& runVector, unsigned lineCount) 340 : runCount(runVector.size()) 341 , lineCount(lineCount) 342 { 343 memcpy(runs, runVector.data(), runCount * sizeof(Run)); 344 } 345 346 } 347 } -
trunk/Source/WebCore/rendering/SimpleLineLayout.h
r158196 r158214 30 30 #include <wtf/text/WTFString.h> 31 31 32 #if COMPILER(MSVC) 33 #pragma warning(push) 34 #pragma warning(disable: 4200) // Disable "zero-sized array in struct/union" warning 35 #endif 36 32 37 namespace WebCore { 33 38 … … 55 60 56 61 struct Layout { 57 Layout() : lineCount(0) { } 62 typedef Vector<Run, 10> RunVector; 63 static std::unique_ptr<Layout> create(const RunVector&, unsigned lineCount); 58 64 65 unsigned runCount; 59 66 unsigned lineCount; 60 Vector<Run> runs; 67 Run runs[0]; 68 69 private: 70 Layout(const RunVector&, unsigned lineCount); 61 71 }; 62 72 … … 66 76 } 67 77 78 #if COMPILER(MSVC) 79 #pragma warning(pop) 68 80 #endif 81 82 #endif -
trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp
r158196 r158214 75 75 return false; 76 76 77 if ( layout.runs.isEmpty())77 if (!layout.runCount) 78 78 return false; 79 79 -
trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.h
r158107 r158214 71 71 inline LayoutUnit computeFlowFirstLineBaseline(const RenderBlockFlow& flow, const Layout& layout) 72 72 { 73 ASSERT_UNUSED(layout, !layout.runs.isEmpty());73 ASSERT_UNUSED(layout, layout.runCount); 74 74 return flow.borderAndPaddingBefore() + baselineFromFlow(flow); 75 75 } … … 77 77 inline LayoutUnit computeFlowLastLineBaseline(const RenderBlockFlow& flow, const Layout& layout) 78 78 { 79 ASSERT( !layout.runs.isEmpty());80 return flow.borderAndPaddingBefore() + lineHeightFromFlow(flow) * (layout.run s.size()- 1) + baselineFromFlow(flow);79 ASSERT(layout.runCount); 80 return flow.borderAndPaddingBefore() + lineHeightFromFlow(flow) * (layout.runCount - 1) + baselineFromFlow(flow); 81 81 } 82 82 83 83 inline unsigned findTextCaretMinimumOffset(const RenderText&, const Layout& layout) 84 84 { 85 if ( layout.runs.isEmpty())85 if (!layout.runCount) 86 86 return 0; 87 87 return layout.runs[0].textOffset; … … 90 90 inline unsigned findTextCaretMaximumOffset(const RenderText& renderer, const Layout& layout) 91 91 { 92 if ( layout.runs.isEmpty())92 if (!layout.runCount) 93 93 return renderer.textLength(); 94 auto& last = layout.runs[layout.run s.size()- 1];94 auto& last = layout.runs[layout.runCount - 1]; 95 95 return last.textOffset + last.textLength; 96 96 } … … 98 98 inline bool containsTextCaretOffset(const RenderText&, const Layout& layout, unsigned offset) 99 99 { 100 for (unsigned i = 0; i < layout.run s.size(); ++i) {100 for (unsigned i = 0; i < layout.runCount; ++i) { 101 101 auto& line = layout.runs[i]; 102 102 if (offset < line.textOffset) … … 110 110 inline bool isTextRendered(const RenderText&, const Layout& layout) 111 111 { 112 for (unsigned i = 0; i < layout.run s.size(); ++i) {112 for (unsigned i = 0; i < layout.runCount; ++i) { 113 113 if (layout.runs[i].textLength) 114 114 return true; -
trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h
r158196 r158214 211 211 inline RunResolver::Iterator RunResolver::end() const 212 212 { 213 return Iterator(*this, m_layout.run s.size());213 return Iterator(*this, m_layout.runCount); 214 214 } 215 215
Note: See TracChangeset
for help on using the changeset viewer.