Title: [230038] trunk/Tools
- Revision
- 230038
- Author
- [email protected]
- Date
- 2018-03-28 11:40:00 -0700 (Wed, 28 Mar 2018)
Log Message
[LayoutReloaded] InlineFormattingContext::_handleText should support runs on multiple lines
https://bugs.webkit.org/show_bug.cgi?id=184101
Reviewed by Antti Koivisto.
* LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js:
(InlineFormattingContext):
(InlineFormattingContext.prototype.layout):
(InlineFormattingContext.prototype._handleText):
(InlineFormattingContext.prototype._createNewLine):
* LayoutReloaded/test/index.html:
* LayoutReloaded/test/simple-multiline-text.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/Tools/ChangeLog (230037 => 230038)
--- trunk/Tools/ChangeLog 2018-03-28 18:30:15 UTC (rev 230037)
+++ trunk/Tools/ChangeLog 2018-03-28 18:40:00 UTC (rev 230038)
@@ -1,5 +1,20 @@
2018-03-28 Zalan Bujtas <[email protected]>
+ [LayoutReloaded] InlineFormattingContext::_handleText should support runs on multiple lines
+ https://bugs.webkit.org/show_bug.cgi?id=184101
+
+ Reviewed by Antti Koivisto.
+
+ * LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js:
+ (InlineFormattingContext):
+ (InlineFormattingContext.prototype.layout):
+ (InlineFormattingContext.prototype._handleText):
+ (InlineFormattingContext.prototype._createNewLine):
+ * LayoutReloaded/test/index.html:
+ * LayoutReloaded/test/simple-multiline-text.html: Added.
+
+2018-03-28 Zalan Bujtas <[email protected]>
+
[LayoutReloaded] Add InlineTextBreaker::skipLeadingWhitespaceIfNeeded
https://bugs.webkit.org/show_bug.cgi?id=184099
Modified: trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js (230037 => 230038)
--- trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js 2018-03-28 18:30:15 UTC (rev 230037)
+++ trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js 2018-03-28 18:40:00 UTC (rev 230038)
@@ -30,7 +30,6 @@
ASSERT(this.formattingRoot().isBlockContainerBox());
if (this.formattingRoot().establishesBlockFormattingContext())
this.m_floatingContext = new FloatingContext(this);
- this.m_line = this._createNewLine();
}
layout() {
@@ -40,6 +39,7 @@
return;
// This is a post-order tree traversal layout.
// The root container layout is done in the formatting context it lives in, not that one it creates, so let's start with the first child.
+ this.m_line = this._createNewLine();
this._addToLayoutQueue(this.formattingRoot().firstChild());
while (this._descendantNeedsLayout()) {
// Travers down on the descendants until we find a leaf node.
@@ -77,13 +77,13 @@
// FIXME: This is a extremely simple line breaking algorithm.
let currentPosition = 0;
let text = inlineBox.text().content();
- while (currentPosition < text.length - 1) {
+ while (text.length) {
let textRuns = Utils.textRunsForLine(text, this._line().availableWidth(), this.formattingRoot());
- for (let run of textRuns) {
+ if (!textRuns.length)
+ break;
+ for (let run of textRuns)
this._line().addTextLineBox(run.startPosition, run.endPosition, new LayoutSize(run.width, Utils.textHeight(inlineBox)));
- currentPosition = run.endPosition;
- }
- text = text.slice(currentPosition, text.length - 1);
+ text = text.slice(textRuns[textRuns.length - 1].endPosition, text.length);
this._commitLine();
}
}
@@ -102,7 +102,11 @@
_createNewLine() {
// TODO: Floats need to be taken into account.
let contentBoxRect = this.displayBox(this.formattingRoot()).contentBox();
- return new Line(contentBoxRect.topLeft(), Utils.computedLineHeight(this.formattingRoot().node()), contentBoxRect.width());
+ let topLeft = contentBoxRect.topLeft();
+ let lines = this.formattingState().lines();
+ if (lines.length)
+ topLeft.setTop(lines[lines.length - 1].rect().bottom());
+ return new Line(topLeft, Utils.computedLineHeight(this.formattingRoot().node()), contentBoxRect.width());
}
}
Modified: trunk/Tools/LayoutReloaded/test/index.html (230037 => 230038)
--- trunk/Tools/LayoutReloaded/test/index.html 2018-03-28 18:30:15 UTC (rev 230037)
+++ trunk/Tools/LayoutReloaded/test/index.html 2018-03-28 18:40:00 UTC (rev 230038)
@@ -62,7 +62,8 @@
"almost-intruding-left-float-simple.html",
"negative-margin-simple.html",
"intruding-left-float-simple.html",
- "simple-inline-text.html"
+ "simple-inline-text.html",
+ "simple-multiline-text.html"
];
let debugThis = [];
Added: trunk/Tools/LayoutReloaded/test/simple-multiline-text.html (0 => 230038)
--- trunk/Tools/LayoutReloaded/test/simple-multiline-text.html (rev 0)
+++ trunk/Tools/LayoutReloaded/test/simple-multiline-text.html 2018-03-28 18:40:00 UTC (rev 230038)
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div style="width: 50px">foobar foobar foobar foobar</div>
+<div style="width: 60px">foobar foobar foobar foobar</div>
+<div style="width: 70px">foobar foobar foobar foobar</div>
+<div style="width: 80px">foobar foobar foobar foobar</div>
+<div style="width: 90px">foobar foobar foobar foobar</div>
+<div style="width: 100px">foobar foobar foobar foobar</div>
+<div style="width: 110px">foobar foobar foobar foobar</div>
+<div style="width: 120px">foobar foobar foobar foobar</div>
+<div style="width: 140px">foobar foobar foobar foobar</div>
+<div style="width: 180px">foobar foobar foobar foobar</div>
+</body>
+</html>
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes