Changeset 251857 in webkit
- Timestamp:
- Oct 31, 2019 10:37:56 AM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r251851 r251857 1 2019-10-31 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][IFC] Add expansion context to Line::Run 4 https://bugs.webkit.org/show_bug.cgi?id=203683 5 <rdar://problem/56785012> 6 7 Reviewed by Antti Koivisto. 8 9 This is in preparation for adding text-align: justify support. 10 The temporary Line::Run holds the number of expansion opportunities, while Display::Run holds both the expansion behavior and 11 the final expansion width. 12 The number of opportunities is used to compute the final expansion width for each run. 13 14 * layout/displaytree/DisplayPainter.cpp: 15 (WebCore::Display::paintInlineContent): 16 * layout/displaytree/DisplayRun.h: 17 (WebCore::Display::Run::TextContext::TextContext): 18 (WebCore::Display::Run::TextContext::setExpansion): 19 (WebCore::Display::Run::TextContext::expansion const): 20 (WebCore::Display::Run::TextContext::expansionBehavior const): Deleted. 21 * layout/inlineformatting/InlineLine.h: 22 (WebCore::Layout::Line::Run::hasExpansionOpportunity const): 23 (WebCore::Layout::Line::Run::expansionOpportunityCount const): 24 (WebCore::Layout::Line::Run::expansionBehavior const): 25 (WebCore::Layout::Line::Run::setHasExpansionOpportunity): 26 (WebCore::Layout::Line::Run::setComputedHorizontalExpansion): 27 1 28 2019-10-31 Zalan Bujtas <zalan@apple.com> 2 29 -
trunk/Source/WebCore/layout/displaytree/DisplayPainter.cpp
r251844 r251857 127 127 auto& lineBox = formattingState.lineBoxForRun(*run); 128 128 auto baselineOffset = rootAbsoluteDisplayBox.top() + lineBox.logicalTop() + lineBox.baselineOffset(); 129 context.drawText(style.fontCascade(), 130 TextRun { textContext->content(), logicalLeft, textContext->expansion().valueOr(0), textContext->expansionBehavior().valueOr(ForbidLeadingExpansion | ForbidTrailingExpansion)}, 131 { logicalLeft, baselineOffset }); 129 if (auto expansionContext = textContext->expansion()) 130 context.drawText(style.fontCascade(), TextRun { textContext->content(), logicalLeft, expansionContext->horiztontalExpansion, expansionContext->behavior }, { logicalLeft, baselineOffset }); 131 else 132 context.drawText(style.fontCascade(), TextRun { textContext->content(), logicalLeft }, { logicalLeft, baselineOffset }); 132 133 } else if (auto* cachedImage = run->image()) { 133 134 auto runAbsoluteRect = FloatRect { rootAbsoluteDisplayBox.left() + run->logicalLeft(), rootAbsoluteDisplayBox.top() + run->logicalTop(), run->logicalWidth(), run->logicalHeight() }; -
trunk/Source/WebCore/layout/displaytree/DisplayRun.h
r251844 r251857 44 44 WTF_MAKE_STRUCT_FAST_ALLOCATED; 45 45 public: 46 TextContext(unsigned position, unsigned length, String content, Optional<ExpansionBehavior> = { }, Optional<LayoutUnit> expansion = { }); 46 struct ExpansionContext; 47 TextContext(unsigned position, unsigned length, String content, Optional<ExpansionContext> = { }); 47 48 48 49 unsigned start() const { return m_start; } … … 51 52 String content() const { return m_content; } 52 53 53 Optional<ExpansionBehavior> expansionBehavior() const { return m_expansionBehavior; } 54 Optional<LayoutUnit> expansion() const { return m_expansion; } 54 struct ExpansionContext { 55 ExpansionBehavior behavior; 56 LayoutUnit horiztontalExpansion; 57 }; 58 void setExpansion(ExpansionContext expansionContext) { m_expansionContext = expansionContext; } 59 Optional<ExpansionContext> expansion() const { return m_expansionContext; } 55 60 56 61 void expand(const TextContext& other); … … 59 64 unsigned m_start { 0 }; 60 65 unsigned m_length { 0 }; 61 Optional<ExpansionBehavior> m_expansionBehavior; 62 Optional<LayoutUnit> m_expansion; 66 Optional<ExpansionContext> m_expansionContext; 63 67 // FIXME: This is temporary. We should have some mapping setup to identify associated text content instead. 64 68 String m_content; … … 111 115 } 112 116 113 inline Run::TextContext::TextContext(unsigned start, unsigned length, String content, Optional<Expansion Behavior> expansionBehavior, Optional<LayoutUnit> expansion)117 inline Run::TextContext::TextContext(unsigned start, unsigned length, String content, Optional<ExpansionContext> expansionContext) 114 118 : m_start(start) 115 119 , m_length(length) 116 , m_expansionBehavior(expansionBehavior) 117 , m_expansion(expansion) 120 , m_expansionContext(expansionContext) 118 121 , m_content(content) 119 122 { -
trunk/Source/WebCore/layout/inlineformatting/InlineLine.h
r251851 r251857 94 94 void setCollapsesToZeroAdvanceWidth(); 95 95 96 void setHasExpansionOpportunity(ExpansionBehavior); 97 bool hasExpansionOpportunity() const { return m_expansionOpportunityCount.hasValue(); } 98 Optional<ExpansionBehavior> expansionBehavior() const; 99 Optional<unsigned> expansionOpportunityCount() const { return m_expansionOpportunityCount; } 100 void setComputedHorizontalExpansion(LayoutUnit logicalExpansion); 101 96 102 bool isCollapsible() const { return m_isCollapsible; } 97 103 bool hasTrailingCollapsedContent() const { return m_hasTrailingCollapsedContent; } … … 106 112 bool m_collapsedToZeroAdvanceWidth { false }; 107 113 bool m_hasTrailingCollapsedContent { false }; 114 Optional<unsigned> m_expansionOpportunityCount; 108 115 }; 109 116 using RunList = Vector<std::unique_ptr<Run>>; … … 191 198 } 192 199 200 inline Optional<ExpansionBehavior> Line::Run::expansionBehavior() const 201 { 202 ASSERT(isText()); 203 if (auto expansionContext = m_displayRun.textContext()->expansion()) 204 return expansionContext->behavior; 205 return { }; 206 } 207 208 inline void Line::Run::setHasExpansionOpportunity(ExpansionBehavior expansionBehavior) 209 { 210 ASSERT(isText()); 211 ASSERT(!hasExpansionOpportunity()); 212 m_expansionOpportunityCount = 1; 213 m_displayRun.textContext()->setExpansion({ expansionBehavior, { } }); 214 } 215 216 inline void Line::Run::setComputedHorizontalExpansion(LayoutUnit logicalExpansion) 217 { 218 ASSERT(isText()); 219 ASSERT(hasExpansionOpportunity()); 220 ASSERT(m_displayRun.textContext()->expansion()); 221 m_displayRun.expandHorizontally(logicalExpansion); 222 m_displayRun.textContext()->setExpansion({ m_displayRun.textContext()->expansion()->behavior, logicalExpansion }); 223 } 224 193 225 } 194 226 }
Note: See TracChangeset
for help on using the changeset viewer.