Changeset 245962 in webkit
- Timestamp:
- May 31, 2019, 6:43:37 AM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
-
ChangeLog (modified) (1 diff)
-
layout/inlineformatting/InlineFormattingContext.h (modified) (3 diffs)
-
layout/inlineformatting/InlineFormattingContextLineLayout.cpp (modified) (5 diffs)
-
layout/inlineformatting/InlineLine.cpp (modified) (8 diffs)
-
layout/inlineformatting/InlineLine.h (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r245961 r245962 1 2019-05-31 Zalan Bujtas <zalan@apple.com> 2 3 [LFC[IFC] Do not reuse the same Line object. 4 https://bugs.webkit.org/show_bug.cgi?id=198366 5 <rdar://problem/51250279> 6 7 Reviewed by Antti Koivisto. 8 9 This is in preparation for constructing Line inside createInlineRunsForLine and return Line::Content. 10 11 * layout/inlineformatting/InlineFormattingContext.h: 12 * layout/inlineformatting/InlineFormattingContextLineLayout.cpp: 13 (WebCore::Layout::InlineFormattingContext::LineLayout::createLine const): 14 (WebCore::Layout::InlineFormattingContext::LineLayout::layout const): 15 (WebCore::Layout::InlineFormattingContext::LineLayout::processInlineRuns const): 16 (WebCore::Layout::InlineFormattingContext::LineLayout::initializeLine const): Deleted. 17 * layout/inlineformatting/InlineLine.cpp: 18 (WebCore::Layout::Line::Line): 19 (WebCore::Layout::m_lineLogicalWidth): 20 (WebCore::Layout::Line::close): 21 (WebCore::Layout::Line::moveLogicalLeft): 22 (WebCore::Layout::Line::appendNonBreakableSpace): 23 (WebCore::Layout::Line::appendTextContent): 24 (WebCore::Layout::Line::appendNonReplacedInlineBox): 25 (WebCore::Layout::Line::appendHardLineBreak): 26 (WebCore::Layout::Line::reset): Deleted. 27 * layout/inlineformatting/InlineLine.h: 28 (WebCore::Layout::Line::hasContent const): 29 1 30 2019-05-31 Zalan Bujtas <zalan@apple.com> 2 31 -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h
r245812 r245962 31 31 #include "FormattingContext.h" 32 32 #include "InlineFormattingState.h" 33 #include "InlineLine.h" 33 34 #include <wtf/IsoMalloc.h> 34 35 … … 38 39 class FloatingState; 39 40 class InlineContainer; 40 class Line;41 41 42 42 // This class implements the layout logic for inline formatting contexts. … … 59 59 private: 60 60 LayoutState& layoutState() const { return m_formattingContext.layoutState(); } 61 void initializeLine(Line&,LayoutUnit lineLogicalTop, LayoutUnit widthConstraint) const;61 std::unique_ptr<Line> createLine(LayoutUnit lineLogicalTop, LayoutUnit widthConstraint) const; 62 62 unsigned createInlineRunsForLine(Line&, unsigned firstInlineItemIndex) const; 63 void processInlineRuns( Line&) const;63 void processInlineRuns(const Line::Content&, LayoutUnit availableWidth) const; 64 64 void commitInlineItemToLine(Line&, const InlineItem&) const; 65 65 void handleFloat(Line&, const FloatingContext&, const InlineItem& floatBox) const; -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp
r245961 r245962 76 76 } 77 77 78 void InlineFormattingContext::LineLayout::initializeLine(Line& line,LayoutUnit lineLogicalTop, LayoutUnit availableWidth) const78 std::unique_ptr<Line> InlineFormattingContext::LineLayout::createLine(LayoutUnit lineLogicalTop, LayoutUnit availableWidth) const 79 79 { 80 80 auto& formattingRootDisplayBox = layoutState().displayBoxForLayoutBox(m_formattingRoot); … … 108 108 auto mimimumLineHeight = formattingRootStyle.computedLineHeight(); 109 109 auto baselineOffset = Line::halfLeadingMetrics(formattingRootStyle.fontMetrics(), mimimumLineHeight).height; 110 line.reset({ lineLogicalLeft, lineLogicalTop }, availableWidth, mimimumLineHeight, baselineOffset);110 return std::make_unique<Line>(layoutState(), LayoutPoint { lineLogicalLeft, lineLogicalTop }, availableWidth, mimimumLineHeight, baselineOffset); 111 111 } 112 112 … … 173 173 ASSERT(!m_formattingState.inlineItems().isEmpty()); 174 174 175 Line line(layoutState());176 initializeLine(line, layoutState().displayBoxForLayoutBox(m_formattingRoot).contentBoxTop(), widthConstraint);177 178 175 unsigned startInlineItemIndex = 0; 176 auto lineLogicalTop = layoutState().displayBoxForLayoutBox(m_formattingRoot).contentBoxTop(); 179 177 while (true) { 180 auto nextInlineItemIndex = createInlineRunsForLine(line, startInlineItemIndex); 181 processInlineRuns(line); 178 auto line = createLine(lineLogicalTop, widthConstraint); 179 auto nextInlineItemIndex = createInlineRunsForLine(*line, startInlineItemIndex); 180 auto lineContent = line->close(); 181 processInlineRuns(*lineContent, line->availableWidth()); 182 182 if (nextInlineItemIndex == m_formattingState.inlineItems().size()) 183 183 break; 184 184 startInlineItemIndex = nextInlineItemIndex; 185 initializeLine(line, line.logicalBottom(), widthConstraint);185 lineLogicalTop = lineContent->logicalBottom(); 186 186 } 187 187 } … … 215 215 } 216 216 217 void InlineFormattingContext::LineLayout::processInlineRuns(Line& line) const 218 { 219 auto& lineContent = line.close(); 217 void InlineFormattingContext::LineLayout::processInlineRuns(const Line::Content& lineContent, LayoutUnit availableWidth) const 218 { 220 219 if (lineContent.isEmpty()) { 221 220 // Spec tells us to create a zero height, empty line box. … … 315 314 m_formattingState.addLineBox({ lineBox }); 316 315 if (!lineContent.isVisuallyEmpty()) 317 alignRuns(m_formattingRoot.style().textAlign(), previousLineLastRunIndex.valueOr(-1) + 1, line.availableWidth());316 alignRuns(m_formattingRoot.style().textAlign(), previousLineLastRunIndex.valueOr(-1) + 1, availableWidth); 318 317 } 319 318 -
trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp
r245961 r245962 29 29 #if ENABLE(LAYOUT_FORMATTING_CONTEXT) 30 30 31 #include <wtf/IsoMallocInlines.h> 32 31 33 namespace WebCore { 32 34 namespace Layout { 35 36 WTF_MAKE_ISO_ALLOCATED_IMPL(Line); 33 37 34 38 bool Line::Content::isVisuallyEmpty() const … … 52 56 } 53 57 54 Line::Line(const LayoutState& layoutState )58 Line::Line(const LayoutState& layoutState, const LayoutPoint& topLeft, LayoutUnit availableWidth, LayoutUnit minimumHeight, LayoutUnit baselineOffset) 55 59 : m_layoutState(layoutState) 56 { 57 } 58 59 void Line::reset(const LayoutPoint& topLeft, LayoutUnit availableWidth, LayoutUnit minimumHeight, LayoutUnit baselineOffset) 60 { 61 m_logicalTopLeft = topLeft; 62 m_lineLogicalWidth = availableWidth; 63 m_logicalHeight = { baselineOffset, minimumHeight - baselineOffset }; 64 65 m_contentLogicalWidth = { }; 66 67 m_content = { }; 68 69 m_trimmableContent.clear(); 70 } 71 72 const Line::Content& Line::close() 60 , m_content(std::make_unique<Line::Content>()) 61 , m_logicalTopLeft(topLeft) 62 , m_logicalHeight({ baselineOffset, minimumHeight - baselineOffset }) 63 , m_lineLogicalWidth(availableWidth) 64 { 65 } 66 67 std::unique_ptr<Line::Content> Line::close() 73 68 { 74 69 removeTrailingTrimmableContent(); 75 70 // Convert inline run geometry from relative to the baseline to relative to logical top. 76 for (auto& run : m_content .runs()) {71 for (auto& run : m_content->runs()) { 77 72 auto adjustedLogicalTop = run->inlineRun.logicalTop() + m_logicalHeight.height + m_logicalTopLeft.y(); 78 73 run->inlineRun.setLogicalTop(adjustedLogicalTop); 79 74 } 80 m_content .setLogicalRect({ logicalTop(), logicalLeft(), contentLogicalWidth(), logicalHeight() });81 return m_content;75 m_content->setLogicalRect({ logicalTop(), logicalLeft(), contentLogicalWidth(), logicalHeight() }); 76 return WTFMove(m_content); 82 77 } 83 78 … … 101 96 m_logicalTopLeft.move(delta, 0); 102 97 m_lineLogicalWidth -= delta; 103 for (auto& run : m_content .runs())98 for (auto& run : m_content->runs()) 104 99 run->inlineRun.moveHorizontally(delta); 105 100 } … … 121 116 void Line::appendNonBreakableSpace(const InlineItem& inlineItem, const Display::Rect& logicalRect) 122 117 { 123 m_content .runs().append(std::make_unique<Content::Run>(Display::Run { logicalRect }, inlineItem, false, false));118 m_content->runs().append(std::make_unique<Content::Run>(Display::Run { logicalRect }, inlineItem, false, false)); 124 119 m_contentLogicalWidth += inlineItem.width(); 125 120 } … … 166 161 return false; 167 162 // Leading whitespace. 168 auto& runs = m_content .runs();163 auto& runs = m_content->runs(); 169 164 if (runs.isEmpty()) 170 165 return true; … … 192 187 m_trimmableContent.add(lineItem.get()); 193 188 194 m_content .runs().append(WTFMove(lineItem));189 m_content->runs().append(WTFMove(lineItem)); 195 190 m_contentLogicalWidth += isCompletelyCollapsed ? LayoutUnit() : runSize.width(); 196 191 } … … 220 215 auto logicalRect = Display::Rect { logicalTop, contentLogicalRight() + horizontalMargin.start, runSize.width(), runSize.height() }; 221 216 222 m_content .runs().append(std::make_unique<Content::Run>(Display::Run { logicalRect }, inlineItem, false, false));217 m_content->runs().append(std::make_unique<Content::Run>(Display::Run { logicalRect }, inlineItem, false, false)); 223 218 m_contentLogicalWidth += (runSize.width() + horizontalMargin.start + horizontalMargin.end); 224 219 m_trimmableContent.clear(); … … 235 230 auto ascent = inlineItem.layoutBox().style().fontMetrics().ascent(); 236 231 auto logicalRect = Display::Rect { -ascent, contentLogicalRight(), { }, logicalHeight() }; 237 m_content .runs().append(std::make_unique<Content::Run>(Display::Run { logicalRect }, inlineItem, false, false));232 m_content->runs().append(std::make_unique<Content::Run>(Display::Run { logicalRect }, inlineItem, false, false)); 238 233 } 239 234 -
trunk/Source/WebCore/layout/inlineformatting/InlineLine.h
r245961 r245962 30 30 #include "DisplayRun.h" 31 31 #include "InlineItem.h" 32 #include "InlineTextItem.h" 33 #include <wtf/IsoMalloc.h> 32 34 33 35 namespace WebCore { … … 35 37 36 38 class Line { 39 WTF_MAKE_ISO_ALLOCATED(Line); 37 40 public: 38 Line(const LayoutState&); 39 40 void reset(const LayoutPoint& topLeft, LayoutUnit availableWidth, LayoutUnit minimumLineHeight, LayoutUnit baselineOffset); 41 Line(const LayoutState&, const LayoutPoint& topLeft, LayoutUnit availableWidth, LayoutUnit minimumLineHeight, LayoutUnit baselineOffset); 41 42 42 43 class Content { … … 73 74 Runs m_runs; 74 75 }; 75 const Content&close();76 std::unique_ptr<Content> close(); 76 77 77 78 void appendTextContent(const InlineTextItem&, LayoutSize); … … 82 83 void appendHardLineBreak(const InlineItem&); 83 84 84 bool hasContent() const { return !m_content .isVisuallyEmpty(); }85 bool hasContent() const { return !m_content->isVisuallyEmpty(); } 85 86 86 87 LayoutUnit trailingTrimmableWidth() const; … … 113 114 114 115 const LayoutState& m_layoutState; 115 Contentm_content;116 std::unique_ptr<Content> m_content; 116 117 ListHashSet<Content::Run*> m_trimmableContent; 117 118
Note:
See TracChangeset
for help on using the changeset viewer.