Diff
Modified: trunk/Tools/ChangeLog (230699 => 230700)
--- trunk/Tools/ChangeLog 2018-04-17 03:15:16 UTC (rev 230699)
+++ trunk/Tools/ChangeLog 2018-04-17 05:17:26 UTC (rev 230700)
@@ -1,5 +1,29 @@
2018-04-16 Zalan Bujtas <[email protected]>
+ [LayoutReloaded] Add support for replaced box.
+ https://bugs.webkit.org/show_bug.cgi?id=184680
+
+ Reviewed by Antti Koivisto.
+
+ Basic support for inline replaced.
+
+ * LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js:
+ (InlineFormattingContext.prototype._handleInlineBox):
+ (InlineFormattingContext.prototype._handleInlineBlock):
+ (InlineFormattingContext.prototype._handleReplaced):
+ * LayoutReloaded/FormattingContext/InlineFormatting/Line.js:
+ (Line.prototype.lastLineBox):
+ (Line.prototype.addInlineBox):
+ (Line.prototype.addInlineContainerBox): Deleted.
+ * LayoutReloaded/TreeBuilder.js:
+ (TreeBuilder.prototype._createAndAttachBox):
+ * LayoutReloaded/Utils.js:
+ (Utils._dumpBox):
+ * LayoutReloaded/test/index.html:
+ * LayoutReloaded/test/inline-simple-replaced.html: Added.
+
+2018-04-16 Zalan Bujtas <[email protected]>
+
[LayoutReloaded] Minor InlineFormattingContext::layout() cleanup.
https://bugs.webkit.org/show_bug.cgi?id=184679
Modified: trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js (230699 => 230700)
--- trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js 2018-04-17 03:15:16 UTC (rev 230699)
+++ trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js 2018-04-17 05:17:26 UTC (rev 230700)
@@ -104,6 +104,8 @@
_handleInlineBox(inlineBox) {
if (inlineBox.text())
return this._handleText(inlineBox);
+ else
+ return this._handleReplaced(inlineBox);
}
_handleInlineBlock(inlineBlockBox) {
@@ -110,13 +112,13 @@
ASSERT(inlineBlockBox.establishesFormattingContext());
let displayBox = this.displayBox(inlineBlockBox);
- // TODO: auto width/height
+ // TODO: auto width/height and check if content actually at all.
this._adjustLineForInlineContainerStart(inlineBlockBox);
displayBox.setWidth(Utils.width(inlineBlockBox) + Utils.computedHorizontalBorderAndPadding(inlineBlockBox.node()));
this.layoutState().formattingContext(inlineBlockBox).layout();
displayBox.setHeight(Utils.height(inlineBlockBox) + Utils.computedVerticalBorderAndPadding(inlineBlockBox.node()));
+ this._line().addInlineBox(displayBox.size());
this._adjustLineForInlineContainerEnd(inlineBlockBox);
- this._line().addInlineContainerBox(displayBox.size());
}
_handleText(inlineBox) {
@@ -156,6 +158,18 @@
this._line().moveContentHorizontally(floatWidth);
}
+ _handleReplaced(replacedBox) {
+ // TODO: intrinsic size and check if content actually at all.
+ let displayBox = this.displayBox(replacedBox);
+ this._adjustLineForInlineContainerStart(replacedBox);
+ displayBox.setWidth(Utils.width(replacedBox) + Utils.computedHorizontalBorderAndPadding(replacedBox.node()));
+
+ displayBox.setHeight(Utils.height(replacedBox) + Utils.computedVerticalBorderAndPadding(replacedBox.node()));
+ this._line().addInlineBox(displayBox.size());
+ displayBox.setTopLeft(this._line().lastLineBox().lineBoxRect.topLeft());
+ this._adjustLineForInlineContainerEnd(replacedBox);
+ }
+
_adjustLineForInlineContainerStart(inlineContainer) {
let offset = this.marginLeft(inlineContainer) + Utils.computedBorderAndPaddingLeft(inlineContainer.node());
this._line().adjustWithOffset(offset);
Modified: trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/Line.js (230699 => 230700)
--- trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/Line.js 2018-04-17 03:15:16 UTC (rev 230699)
+++ trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/Line.js 2018-04-17 05:17:26 UTC (rev 230700)
@@ -31,13 +31,13 @@
LayoutUnit availableWidth();
LayoutRect rect();
- lineBoxes();
+ Vector<InlineDisplayBox> lineBoxes();
- shrink(float width);
- adjustWithOffset(LayoutUnit offset);
- moveContentHorizontally(LayoutUnit offset);
- addInlineContainerBox(LayoutSize);
- addTextLineBox(unsigned startPosition, unsigned endPosition, LayoutSize size);
+ void shrink(float width);
+ void adjustWithOffset(LayoutUnit offset);
+ void moveContentHorizontally(LayoutUnit offset);
+ void addInlineContainerBox(LayoutSize);
+ void addTextLineBox(unsigned startPosition, unsigned endPosition, LayoutSize size);
};
*/
class Line {
@@ -63,6 +63,10 @@
return this.m_lineBoxes;
}
+ lastLineBox() {
+ return this.m_lineBoxes[this.m_lineBoxes.length - 1];
+ }
+
shrink(width) {
this.m_availableWidth -= width;
}
@@ -79,7 +83,7 @@
this.m_lineRect.moveHorizontally(offset);
}
- addInlineContainerBox(size) {
+ addInlineBox(size) {
let width = size.width();
ASSERT(width <= this.m_availableWidth);
this.shrink(width);
Modified: trunk/Tools/LayoutReloaded/TreeBuilder.js (230699 => 230700)
--- trunk/Tools/LayoutReloaded/TreeBuilder.js 2018-04-17 03:15:16 UTC (rev 230699)
+++ trunk/Tools/LayoutReloaded/TreeBuilder.js 2018-04-17 05:17:26 UTC (rev 230700)
@@ -54,11 +54,13 @@
let node = this._findNode(initialBlockContainer.node(), id, name);
if (name == "RenderBlock" || name == "RenderBody")
box = new Layout.BlockContainer(node, id);
- else if (name == "RenderInline") {
+ else if (name == "RenderInline")
box = new Layout.InlineContainer(node, id);
- } else if (name == "RenderText") {
+ else if (name == "RenderText")
text = new Text(node, id);
- } else
+ else if (name == "RenderImage")
+ box = new Layout.InlineBox(node, id);
+ else
box = new Layout.Box(node, id);
if (box)
Modified: trunk/Tools/LayoutReloaded/Utils.js (230699 => 230700)
--- trunk/Tools/LayoutReloaded/Utils.js 2018-04-17 03:15:16 UTC (rev 230699)
+++ trunk/Tools/LayoutReloaded/Utils.js 2018-04-17 05:17:26 UTC (rev 230700)
@@ -584,6 +584,11 @@
}
return indentation + box.node().tagName + " " + box.name() + "\n";
}
+ if (box.name() == "RenderImage") {
+ let boxRect = layoutState.displayBox(box).rect();
+ return indentation + box.node().tagName + " " + box.name() + " at (" + Utils.precisionRound(boxRect.left()) + "," + Utils.precisionRound(boxRect.top()) + ") size " + Utils.precisionRound(boxRect.width()) + "x" + Utils.precisionRound(boxRect.height()) + "\n";
+
+ }
if (box.isAnonymous())
return "";
let displayBox = layoutState.displayBox(box);
Modified: trunk/Tools/LayoutReloaded/test/index.html (230699 => 230700)
--- trunk/Tools/LayoutReloaded/test/index.html 2018-04-17 03:15:16 UTC (rev 230699)
+++ trunk/Tools/LayoutReloaded/test/index.html 2018-04-17 05:17:26 UTC (rev 230700)
@@ -82,7 +82,8 @@
"inline-with-padding-border-margin-offsets.html",
"inline-block-with-fixed-width-height.html",
"inline-with-relative-positioning.html",
- "inline-with-out-of-flow-descendant.html"
+ "inline-with-out-of-flow-descendant.html",
+ "inline-simple-replaced.html"
];
let debugThis = [];
Added: trunk/Tools/LayoutReloaded/test/inline-simple-replaced.html (0 => 230700)
--- trunk/Tools/LayoutReloaded/test/inline-simple-replaced.html (rev 0)
+++ trunk/Tools/LayoutReloaded/test/inline-simple-replaced.html 2018-04-17 05:17:26 UTC (rev 230700)
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div style="height: 200px;">foobar foobar<img style="vertical-align: top" src="" width=100px height=100px></div>
+</body>
+</html>