Changeset 238460 in webkit
- Timestamp:
- Nov 23, 2018, 9:05:43 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 11 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/inline/inline-content-with-image-simple-expected.txt (added)
-
LayoutTests/fast/inline/inline-content-with-image-simple.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/layout/Verification.cpp (modified) (4 diffs)
-
Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (modified) (5 diffs)
-
Source/WebCore/layout/inlineformatting/InlineFormattingContext.h (modified) (4 diffs)
-
Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp (modified) (1 diff)
-
Source/WebCore/layout/inlineformatting/InlineRun.h (modified) (1 diff)
-
Source/WebCore/layout/inlineformatting/Line.cpp (modified) (3 diffs)
-
Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/LayoutReloaded/misc/LFC-passing-tests.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r238457 r238460 1 2018-11-23 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][IFC] Add support for variable height runs. 4 https://bugs.webkit.org/show_bug.cgi?id=191925 5 6 Reviewed by Antti Koivisto. 7 8 * fast/inline/inline-content-with-image-simple-expected.txt: Added. 9 * fast/inline/inline-content-with-image-simple.html: Added. 10 1 11 2018-11-23 Javier Fernandez <jfernandez@igalia.com> 2 12 -
trunk/Source/WebCore/ChangeLog
r238459 r238460 1 2018-11-23 Zalan Butjas <zalan@apple.com> 2 3 [LFC][IFC] Add support for variable height runs. 4 https://bugs.webkit.org/show_bug.cgi?id=191925 5 6 Reviewed by Antti Koivisto. 7 8 https://www.w3.org/TR/CSS22/visudet.html#inline-box-height 9 10 10.8 Line height calculations: the 'line-height' and 'vertical-align' properties 11 12 The height of each inline-level box in the line box is calculated. For replaced elements, inline-block elements, 13 and inline-table elements, this is the height of their margin box; for inline boxes, this is their 'line-height'. 14 15 The line box height is the distance between the uppermost box top and the lowermost box bottom. 16 17 The minimum height consists of a minimum height above the baseline and a minimum depth below it, 18 exactly as if each line box starts with a zero-width inline box with the element's font and line height properties. 19 We call that imaginary box a "strut." (The name is inspired by TeX.). 20 21 Test: fast/inline/inline-content-with-image-simple.html 22 23 * layout/Verification.cpp: 24 (WebCore::Layout::checkForMatchingNonTextRuns): 25 (WebCore::Layout::checkForMatchingTextRuns): 26 (WebCore::Layout::outputMismatchingComplexLineInformationIfNeeded): 27 * layout/inlineformatting/InlineFormattingContext.cpp: 28 (WebCore::Layout::InlineFormattingContext::initializeNewLine const): 29 (WebCore::Layout::InlineFormattingContext::splitInlineRunIfNeeded const): 30 (WebCore::Layout::InlineFormattingContext::createFinalRuns const): 31 (WebCore::Layout::InlineFormattingContext::appendContentToLine const): 32 (WebCore::Layout::InlineFormattingContext::layoutInlineContent const): 33 * layout/inlineformatting/InlineFormattingContext.h: 34 (WebCore::Layout::InlineFormattingContext::Line::logicalHeight const): 35 * layout/inlineformatting/InlineFormattingContextGeometry.cpp: 36 (WebCore::Layout::InlineFormattingContext::Geometry::justifyRuns): 37 * layout/inlineformatting/InlineRun.h: 38 (WebCore::Layout::InlineRun::logicalWidth const): 39 (WebCore::Layout::InlineRun::logicalHeight const): 40 (WebCore::Layout::InlineRun::setLogicalWidth): 41 (WebCore::Layout::InlineRun::width const): Deleted. 42 (WebCore::Layout::InlineRun::height const): Deleted. 43 (WebCore::Layout::InlineRun::setWidth): Deleted. 44 * layout/inlineformatting/Line.cpp: 45 (WebCore::Layout::InlineFormattingContext::Line::init): 46 (WebCore::Layout::InlineFormattingContext::Line::appendContent): 47 (WebCore::Layout::InlineFormattingContext::Line::close): 48 * layout/layouttree/LayoutTreeBuilder.cpp: 49 (WebCore::Layout::outputInlineRuns): 50 1 51 2018-11-23 Antti Koivisto <antti@apple.com> 2 52 -
trunk/Source/WebCore/layout/Verification.cpp
r238431 r238460 88 88 static bool checkForMatchingNonTextRuns(const InlineRun& inlineRun, const WebCore::InlineBox& inlineBox) 89 89 { 90 return areEssentiallyEqual(inlineBox.logicalLeft(), inlineRun.logicalLeft()) && areEssentiallyEqual(inlineBox.logicalRight(), inlineRun.logicalRight()); 91 } 92 93 static bool checkForMatchingTextRuns(const InlineRun& inlineRun, float logicalLeft, float logicalRight, unsigned start, unsigned end) 94 { 95 return areEssentiallyEqual(logicalLeft, inlineRun.logicalLeft()) && areEssentiallyEqual(logicalRight, inlineRun.logicalRight()) && start == inlineRun.textContext()->start() && (end == (inlineRun.textContext()->start() + inlineRun.textContext()->length())); 90 return areEssentiallyEqual(inlineBox.logicalLeft(), inlineRun.logicalLeft()) 91 && areEssentiallyEqual(inlineBox.logicalRight(), inlineRun.logicalRight()) 92 && areEssentiallyEqual(inlineBox.logicalHeight(), inlineRun.logicalHeight()); 93 } 94 95 static bool checkForMatchingTextRuns(const InlineRun& inlineRun, float logicalLeft, float logicalRight, unsigned start, unsigned end, float logicalHeight) 96 { 97 return areEssentiallyEqual(logicalLeft, inlineRun.logicalLeft()) 98 && areEssentiallyEqual(logicalRight, inlineRun.logicalRight()) 99 && start == inlineRun.textContext()->start() 100 && (end == (inlineRun.textContext()->start() + inlineRun.textContext()->length())) 101 && areEssentiallyEqual(logicalHeight, inlineRun.logicalHeight()); 96 102 } 97 103 … … 160 166 if (inlineTextBox) { 161 167 auto xOffset = resolveForRelativePositionIfNeeded(*inlineTextBox); 162 matchingRuns = checkForMatchingTextRuns(inlineRun, inlineTextBox->logicalLeft() + xOffset, inlineTextBox->logicalRight() + xOffset, inlineTextBox->start(), inlineTextBox->end() + 1); 168 matchingRuns = checkForMatchingTextRuns(inlineRun, inlineTextBox->logicalLeft() + xOffset, 169 inlineTextBox->logicalRight() + xOffset, 170 inlineTextBox->start(), 171 inlineTextBox->end() + 1, 172 inlineTextBox->logicalHeight()); 163 173 164 174 // <span>foobar</span>foobar generates 2 inline text boxes while we only generate one inline run. … … 183 193 logicalRight = inlineTextBox->logicalRight() + xOffset; 184 194 end += (inlineTextBox->end() + 1); 185 if (checkForMatchingTextRuns(inlineRun, logicalLeft, logicalRight, start, end )) {195 if (checkForMatchingTextRuns(inlineRun, logicalLeft, logicalRight, start, end, inlineTextBox->logicalHeight())) { 186 196 matchingRuns = true; 187 197 inlineBoxIndex = index; … … 203 213 if (inlineTextBox) 204 214 stream << "(" << inlineTextBox->start() << ", " << inlineTextBox->end() + 1 << ")"; 205 stream << " (" << inlineBox->logicalLeft() << ", " << inlineBox->logicalRight() << ") ";215 stream << " (" << inlineBox->logicalLeft() << ", " << inlineBox->logicalRight() << ") (" << inlineBox->logicalWidth() << "x" << inlineBox->logicalHeight() << ")"; 206 216 207 217 stream << "inline run "; 208 218 if (inlineRun.textContext()) 209 219 stream << "(" << inlineRun.textContext()->start() << ", " << inlineRun.textContext()->start() + inlineRun.textContext()->length() << ") "; 210 stream << "(" << inlineRun.logicalLeft() << ", " << inlineRun.logicalRight() << ") ";220 stream << "(" << inlineRun.logicalLeft() << ", " << inlineRun.logicalRight() << ") (" << inlineRun.logicalWidth() << "x" << inlineRun.logicalHeight() << ")"; 211 221 stream.nextLine(); 212 222 mismatched = true; -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp
r238449 r238460 118 118 } 119 119 120 Display::Box::Rect logicalRect; 121 logicalRect.setTop(lineLogicalTop); 122 logicalRect.setLeft(lineLogicalLeft); 123 logicalRect.setWidth(availableWidth); 124 logicalRect.setHeight(formattingRoot.style().computedLineHeight()); 125 126 line.init(logicalRect); 120 line.init({ lineLogicalLeft, lineLogicalTop }, availableWidth, formattingRoot.style().computedLineHeight()); 127 121 } 128 122 … … 158 152 159 153 auto runWidth = Geometry::runWidth(inlineContent, *uncommitted->firstInlineItem, startPosition, uncommitted->length, contentStart); 160 auto run = InlineRun { { inlineRun.logicalTop(), contentStart, runWidth, inlineRun. height() }, *uncommitted->firstInlineItem };154 auto run = InlineRun { { inlineRun.logicalTop(), contentStart, runWidth, inlineRun.logicalHeight() }, *uncommitted->firstInlineItem }; 161 155 run.setTextContext({ startPosition, uncommitted->length }); 162 156 splitRuns.append(run); … … 236 230 237 231 InlineRun adjustedRun = inlineRun; 238 auto width = inlineRun. width() - inlineItem.nonBreakableStart() - inlineItem.nonBreakableEnd();232 auto width = inlineRun.logicalWidth() - inlineItem.nonBreakableStart() - inlineItem.nonBreakableEnd(); 239 233 adjustedRun.setLogicalLeft(inlineRun.logicalLeft() + inlineItem.nonBreakableStart()); 240 adjustedRun.set Width(width);234 adjustedRun.setLogicalWidth(width); 241 235 return adjustedRun; 242 236 }; … … 264 258 } 265 259 266 void InlineFormattingContext::appendContentToLine(Line& line, const Inline LineBreaker::Run& run) const260 void InlineFormattingContext::appendContentToLine(Line& line, const InlineRunProvider::Run& run, const LayoutSize& runSize) const 267 261 { 268 262 auto lastRunType = line.lastRunType(); 269 line.appendContent(run );263 line.appendContent(run, runSize); 270 264 271 265 if (root().style().textAlign() == TextAlignMode::Justify) 272 Geometry::computeExpansionOpportunities(line, run .content, lastRunType.value_or(InlineRunProvider::Run::Type::NonWhitespace));266 Geometry::computeExpansionOpportunities(line, run, lastRunType.value_or(InlineRunProvider::Run::Type::NonWhitespace)); 273 267 } 274 268 … … 319 313 } 320 314 321 if (generatesInlineRun) 322 appendContentToLine(line, *run); 315 if (generatesInlineRun) { 316 auto width = run->width; 317 auto height = run->content.isText() ? LayoutUnit(root().style().computedLineHeight()) : layoutState.displayBoxForLayoutBox(run->content.inlineItem().layoutBox()).height(); 318 appendContentToLine(line, run->content, { width, height }); 319 } 323 320 324 321 if (isLastRun) -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h
r238403 r238460 30 30 #include "DisplayBox.h" 31 31 #include "FormattingContext.h" 32 #include "InlineLineBreaker.h"33 32 #include "InlineRun.h" 34 33 #include <wtf/IsoMalloc.h> … … 52 51 class Line { 53 52 public: 54 void init(const Display::Box::Rect&);53 void init(const LayoutPoint& topLeft, LayoutUnit availableWidth, LayoutUnit minimalHeight); 55 54 void close(); 56 55 57 void appendContent(const Inline LineBreaker::Run&);56 void appendContent(const InlineRunProvider::Run&, const LayoutSize&); 58 57 59 58 void adjustLogicalLeft(LayoutUnit delta); … … 72 71 LayoutUnit logicalTop() const { return m_logicalRect.top(); } 73 72 LayoutUnit logicalBottom() const { return m_logicalRect.bottom(); } 73 LayoutUnit logicalHeight() const { return logicalBottom() - logicalTop(); } 74 74 75 75 private: … … 106 106 void initializeNewLine(Line&) const; 107 107 void closeLine(Line&, IsLastLine) const; 108 void appendContentToLine(Line&, const Inline LineBreaker::Run&) const;108 void appendContentToLine(Line&, const InlineRunProvider::Run&, const LayoutSize&) const; 109 109 void postProcessInlineRuns(Line&, IsLastLine) const; 110 110 void createFinalRuns(Line&) const; -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp
r238403 r238460 132 132 inlineRun.expansionOpportunity().expansion = expansionForRun; 133 133 inlineRun.setLogicalLeft(inlineRun.logicalLeft() + accumulatedExpansion); 134 inlineRun.set Width(inlineRun.width() + expansionForRun);134 inlineRun.setLogicalWidth(inlineRun.logicalWidth() + expansionForRun); 135 135 accumulatedExpansion += expansionForRun; 136 136 } -
trunk/Source/WebCore/layout/inlineformatting/InlineRun.h
r238225 r238460 42 42 LayoutUnit logicalBottom() const { return m_logicalRect.bottom(); } 43 43 44 LayoutUnit width() const { return m_logicalRect.width(); }45 LayoutUnit height() const { return m_logicalRect.height(); }44 LayoutUnit logicalWidth() const { return m_logicalRect.width(); } 45 LayoutUnit logicalHeight() const { return m_logicalRect.height(); } 46 46 bool overlapsMultipleInlineItems() const; 47 47 48 void set Width(LayoutUnit width) { m_logicalRect.setWidth(width); }48 void setLogicalWidth(LayoutUnit width) { m_logicalRect.setWidth(width); } 49 49 void setLogicalLeft(LayoutUnit logicalLeft) { m_logicalRect.setLeft(logicalLeft); } 50 50 void setLogicalRight(LayoutUnit logicalRight) { m_logicalRect.shiftRightTo(logicalRight); } -
trunk/Source/WebCore/layout/inlineformatting/Line.cpp
r238402 r238460 33 33 namespace Layout { 34 34 35 void InlineFormattingContext::Line::init(const Display::Box::Rect& logicalRect)35 void InlineFormattingContext::Line::init(const LayoutPoint& topLeft, LayoutUnit availableWidth, LayoutUnit minimalHeight) 36 36 { 37 m_logicalRect = logicalRect; 38 m_availableWidth = logicalRect.width(); 37 m_logicalRect.setTopLeft(topLeft); 38 m_logicalRect.setWidth(availableWidth); 39 m_logicalRect.setHeight(minimalHeight); 40 m_availableWidth = availableWidth; 39 41 40 42 m_inlineRuns.clear(); … … 77 79 } 78 80 79 void InlineFormattingContext::Line::appendContent(const Inline LineBreaker::Run& run)81 void InlineFormattingContext::Line::appendContent(const InlineRunProvider::Run& run, const LayoutSize& runSize) 80 82 { 81 83 ASSERT(!isClosed()); 82 84 83 auto& content = run.content;84 85 85 // Append this text run to the end of the last text run, if the last run is continuous. 86 86 std::optional<InlineRun::TextContext> textRun; 87 if ( content.isText()) {88 auto textContext = content.textContext();87 if (run.isText()) { 88 auto textContext = run.textContext(); 89 89 auto runLength = textContext->isCollapsed() ? 1 : textContext->length(); 90 90 textRun = InlineRun::TextContext { textContext->start(), runLength }; 91 91 } 92 92 93 auto requiresNewInlineRun = !hasContent() || ! content.isText() || !m_lastRunCanExpand;93 auto requiresNewInlineRun = !hasContent() || !run.isText() || !m_lastRunCanExpand; 94 94 if (requiresNewInlineRun) { 95 95 // FIXME: This needs proper baseline handling 96 auto inlineRun = InlineRun { { logicalTop(), contentLogicalRight(), run .width, logicalBottom() - logicalTop() }, content.inlineItem() };96 auto inlineRun = InlineRun { { logicalTop(), contentLogicalRight(), runSize.width(), runSize.height() }, run.inlineItem() }; 97 97 if (textRun) 98 98 inlineRun.setTextContext({ textRun->start(), textRun->length() }); 99 99 m_inlineRuns.append(inlineRun); 100 m_logicalRect.setHeight(std::max(runSize.height(), m_logicalRect.height())); 100 101 } else { 101 102 // Non-text runs always require new inline run. 102 103 ASSERT(textRun); 103 104 auto& inlineRun = m_inlineRuns.last(); 104 inlineRun.setWidth(inlineRun.width() + run.width); 105 ASSERT(runSize.height() == inlineRun.logicalHeight()); 106 inlineRun.setLogicalWidth(inlineRun.logicalWidth() + runSize.width()); 105 107 inlineRun.textContext()->setLength(inlineRun.textContext()->length() + textRun->length()); 106 108 } 107 109 108 m_availableWidth -= run .width;109 m_lastRunType = content.type();110 m_lastRunCanExpand = content.isText() && !content.textContext()->isCollapsed();110 m_availableWidth -= runSize.width(); 111 m_lastRunType = run.type(); 112 m_lastRunCanExpand = run.isText() && !run.textContext()->isCollapsed(); 111 113 m_trailingTrimmableContent = { }; 112 if (isTrimmableContent( content))113 m_trailingTrimmableContent = TrailingTrimmableContent { run .width, textRun->length() };114 if (isTrimmableContent(run)) 115 m_trailingTrimmableContent = TrailingTrimmableContent { runSize.width(), textRun->length() }; 114 116 } 115 117 … … 122 124 123 125 auto& lastInlineRun = m_inlineRuns.last(); 124 lastInlineRun.set Width(lastInlineRun.width() - m_trailingTrimmableContent->width);126 lastInlineRun.setLogicalWidth(lastInlineRun.logicalWidth() - m_trailingTrimmableContent->width); 125 127 lastInlineRun.textContext()->setLength(lastInlineRun.textContext()->length() - m_trailingTrimmableContent->length); 126 128 -
trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp
r238279 r238460 152 152 else 153 153 stream << "(x, x) "; 154 stream << "at [" << inlineRun.logicalLeft() << ", " << inlineRun.logicalTop() << "] size [" << inlineRun. width() << " " << inlineRun.height() << "]";154 stream << "at [" << inlineRun.logicalLeft() << ", " << inlineRun.logicalTop() << "] size [" << inlineRun.logicalWidth() << " " << inlineRun.logicalHeight() << "]"; 155 155 stream.nextLine(); 156 156 } -
trunk/Tools/ChangeLog
r238458 r238460 1 2018-11-23 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][IFC] Add support for variable height runs. 4 https://bugs.webkit.org/show_bug.cgi?id=191925 5 6 Reviewed by Antti Koivisto. 7 8 * LayoutReloaded/misc/LFC-passing-tests.txt: 9 1 10 2018-11-23 Alberto Garcia <berto@igalia.com> 2 11 -
trunk/Tools/LayoutReloaded/misc/LFC-passing-tests.txt
r238448 r238460 77 77 fast/inline/inline-content-with-margin-left-right.html 78 78 fast/inline/inline-content-and-nested-formatting-root-with-margin-left-right.html 79 fast/inline/inline-content-with-image-simple.html 79 80 fast/block/basic/height-percentage-simple.html 80 81 fast/block/basic/child-block-level-box-with-height-percent.html
Note:
See TracChangeset
for help on using the changeset viewer.