- Revision
- 230621
- Author
- [email protected]
- Date
- 2018-04-12 20:09:03 -0700 (Thu, 12 Apr 2018)
Log Message
[LayoutReloaded] Move root container ownership to layout state
https://bugs.webkit.org/show_bug.cgi?id=184575
Reviewed by Antti Koivisto.
Now the root container is on the associated layout state (ICB only at this point though).
* LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js:
(BlockFormattingContext.prototype.layout):
* LayoutReloaded/FormattingContext/FormattingContext.js:
(FormattingContext.prototype._layoutOutOfFlowDescendants):
* LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js:
(InlineFormattingContext.prototype._handleInlineBlockContainer):
(InlineFormattingContext.prototype._handleFloatingBox):
* LayoutReloaded/Layout.js:
(layout):
* LayoutReloaded/LayoutState.js:
(LayoutState):
(LayoutState.prototype.formattingContext):
(LayoutState.prototype.establishedFormattingState):
(LayoutState.prototype.formattingStateForBox):
(LayoutState.prototype.needsLayout):
(LayoutState.prototype.displayBox):
(LayoutState.prototype._formattingContext):
(LayoutState.prototype.layout): Deleted.
(LayoutState.prototype.formattingStates): Deleted.
(LayoutState.prototype.initialDisplayBox): Deleted.
* LayoutReloaded/Utils.js:
(Utils._dumpBox):
(Utils._findDisplayBox): Deleted.
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (230620 => 230621)
--- trunk/Tools/ChangeLog 2018-04-13 01:56:24 UTC (rev 230620)
+++ trunk/Tools/ChangeLog 2018-04-13 03:09:03 UTC (rev 230621)
@@ -1,3 +1,36 @@
+2018-04-12 Zalan Bujtas <[email protected]>
+
+ [LayoutReloaded] Move root container ownership to layout state
+ https://bugs.webkit.org/show_bug.cgi?id=184575
+
+ Reviewed by Antti Koivisto.
+
+ Now the root container is on the associated layout state (ICB only at this point though).
+
+ * LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js:
+ (BlockFormattingContext.prototype.layout):
+ * LayoutReloaded/FormattingContext/FormattingContext.js:
+ (FormattingContext.prototype._layoutOutOfFlowDescendants):
+ * LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js:
+ (InlineFormattingContext.prototype._handleInlineBlockContainer):
+ (InlineFormattingContext.prototype._handleFloatingBox):
+ * LayoutReloaded/Layout.js:
+ (layout):
+ * LayoutReloaded/LayoutState.js:
+ (LayoutState):
+ (LayoutState.prototype.formattingContext):
+ (LayoutState.prototype.establishedFormattingState):
+ (LayoutState.prototype.formattingStateForBox):
+ (LayoutState.prototype.needsLayout):
+ (LayoutState.prototype.displayBox):
+ (LayoutState.prototype._formattingContext):
+ (LayoutState.prototype.layout): Deleted.
+ (LayoutState.prototype.formattingStates): Deleted.
+ (LayoutState.prototype.initialDisplayBox): Deleted.
+ * LayoutReloaded/Utils.js:
+ (Utils._dumpBox):
+ (Utils._findDisplayBox): Deleted.
+
2018-04-12 Jonathan Bedard <[email protected]>
Fix --build-directory flag for run-webkit-tests
Modified: trunk/Tools/LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js (230620 => 230621)
--- trunk/Tools/LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js 2018-04-13 01:56:24 UTC (rev 230620)
+++ trunk/Tools/LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js 2018-04-13 03:09:03 UTC (rev 230621)
@@ -47,7 +47,7 @@
this.computeWidth(layoutBox);
this._computeStaticPosition(layoutBox);
if (layoutBox.establishesFormattingContext()) {
- this.layoutState().layout(layoutBox);
+ this.layoutState().formattingContext(layoutBox).layout();
break;
}
let childToLayout = this._firstInFlowChildWithNeedsLayout(layoutBox);
Modified: trunk/Tools/LayoutReloaded/FormattingContext/FormattingContext.js (230620 => 230621)
--- trunk/Tools/LayoutReloaded/FormattingContext/FormattingContext.js 2018-04-13 01:56:24 UTC (rev 230620)
+++ trunk/Tools/LayoutReloaded/FormattingContext/FormattingContext.js 2018-04-13 03:09:03 UTC (rev 230621)
@@ -173,7 +173,7 @@
for (let outOfFlowBox of outOfFlowDescendants) {
this._addToLayoutQueue(outOfFlowBox);
this._computeOutOfFlowWidth(outOfFlowBox);
- this.layoutState().layout(outOfFlowBox);
+ this.layoutState().formattingContext(outOfFlowBox).layout();
this._computeOutOfFlowHeight(outOfFlowBox);
this._computeOutOfFlowPosition(outOfFlowBox);
this._removeFromLayoutQueue(outOfFlowBox);
Modified: trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js (230620 => 230621)
--- trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js 2018-04-13 01:56:24 UTC (rev 230620)
+++ trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js 2018-04-13 03:09:03 UTC (rev 230621)
@@ -81,7 +81,7 @@
// TODO: auto width/height
this._adjustLineForInlineContainerStart(inlineBlockContainer);
displayBox.setWidth(Utils.width(inlineBlockContainer) + Utils.computedHorizontalBorderAndPadding(inlineBlockContainer.node()));
- this.layoutState().layout(inlineBlockContainer);
+ this.layoutState().formattingContext(inlineBlockContainer).layout();
displayBox.setHeight(Utils.height(inlineBlockContainer) + Utils.computedVerticalBorderAndPadding(inlineBlockContainer.node()));
this._adjustLineForInlineContainerEnd(inlineBlockContainer);
this._line().addInlineContainerBox(displayBox.size());
@@ -122,7 +122,7 @@
_handleFloatingBox(floatingBox) {
this._computeFloatingWidth(floatingBox);
- this.layoutState().layout(floatingBox);
+ this.layoutState().formattingContext(floatingBox).layout();
this._computeFloatingHeight(floatingBox);
let displayBox = this.displayBox(floatingBox);
// Position this float statically first, the floating context will figure it out the final position.
Modified: trunk/Tools/LayoutReloaded/Layout.js (230620 => 230621)
--- trunk/Tools/LayoutReloaded/Layout.js 2018-04-13 01:56:24 UTC (rev 230620)
+++ trunk/Tools/LayoutReloaded/Layout.js 2018-04-13 03:09:03 UTC (rev 230621)
@@ -28,7 +28,7 @@
let initialContainingBlock = treeBuilder.createTree(window.document, window.renderTreeStructure);
let displayBox = new Display.Box();
displayBox.setSize(viewportSize);
- let layoutState = new LayoutState(displayBox);
- layoutState.layout(initialContainingBlock);
+ let layoutState = new LayoutState(initialContainingBlock, displayBox);
+ layoutState.formattingContext(initialContainingBlock).layout();
return Utils.layoutTreeDump(initialContainingBlock, layoutState);
}
Modified: trunk/Tools/LayoutReloaded/LayoutState.js (230620 => 230621)
--- trunk/Tools/LayoutReloaded/LayoutState.js 2018-04-13 01:56:24 UTC (rev 230620)
+++ trunk/Tools/LayoutReloaded/LayoutState.js 2018-04-13 03:09:03 UTC (rev 230621)
@@ -24,37 +24,30 @@
*/
class LayoutState {
- constructor(initialDisplayBox) {
+ constructor(rootContainer, rootDisplayBox) {
+ ASSERT(rootContainer.establishesFormattingContext());
+ this.m_rootContainer = rootContainer;
+ this.m_rootDisplayBox = rootDisplayBox;
+
this.m_formattingStates = new Map();
- this.m_initialDisplayBox = initialDisplayBox;
}
- layout(formattingRoot) {
- let formattingState = this._createFormattingState(formattingRoot);
- this.m_formattingStates.set(formattingRoot, formattingState);
- this.formattingContext(formattingState).layout();
+ formattingContext(formattingRoot) {
+ return this._formattingContext(this.establishedFormattingState(formattingRoot));
}
- formattingContext(formattingState) {
- if (formattingState instanceof BlockFormattingState)
- return new BlockFormattingContext(formattingState);
- if (formattingState instanceof InlineFormattingState)
- return new InlineFormattingContext(formattingState);
- ASSERT_NOT_REACHED();
- return null;
- }
-
- formattingStates() {
- return this.m_formattingStates;
- }
-
establishedFormattingState(formattingRoot) {
ASSERT(formattingRoot.establishesFormattingContext());
- return this.m_formattingStates.get(formattingRoot);
+ let formattingState = this.m_formattingStates.get(formattingRoot);
+ if (formattingState)
+ return formattingState;
+ formattingState = this._createFormattingState(formattingRoot);
+ this.m_formattingStates.set(formattingRoot, formattingState);
+ return formattingState;
}
formattingStateForBox(layoutBox) {
- for (let formattingEntry of this.formattingStates()) {
+ for (let formattingEntry of this.m_formattingStates) {
let formattingRoot = formattingEntry[0];
let formattingState = formattingEntry[1];
if (FormattingContext.isInFormattingContext(layoutBox, formattingRoot))
@@ -73,7 +66,7 @@
}
needsLayout() {
- for (let formattingEntry of this.formattingStates()) {
+ for (let formattingEntry of this.m_formattingStates) {
let formattingState = formattingEntry[1];
if (formattingState.layoutNeeded())
return true;
@@ -82,21 +75,17 @@
}
displayBox(layoutBox) {
- for (let formattingEntry of this.formattingStates()) {
+ for (let formattingEntry of this.m_formattingStates) {
let formattingState = formattingEntry[1];
let displayBox = formattingState.displayBoxes().get(layoutBox);
if (displayBox)
return displayBox;
}
- // It must be the ICB.
- ASSERT(!layoutBox.parent());
- return this.initialDisplayBox();
+ // It must be the root container.
+ ASSERT(layoutBox == this.m_rootContainer);
+ return this.m_rootDisplayBox;
}
- initialDisplayBox() {
- return this.m_initialDisplayBox;
- }
-
_createFormattingState(formattingRoot) {
ASSERT(formattingRoot.establishesFormattingContext());
if (formattingRoot.establishesInlineFormattingContext())
@@ -107,4 +96,12 @@
return null;
}
+ _formattingContext(formattingState) {
+ if (formattingState instanceof BlockFormattingState)
+ return new BlockFormattingContext(formattingState);
+ if (formattingState instanceof InlineFormattingState)
+ return new InlineFormattingContext(formattingState);
+ ASSERT_NOT_REACHED();
+ return null;
+ }
}
Modified: trunk/Tools/LayoutReloaded/Utils.js (230620 => 230621)
--- trunk/Tools/LayoutReloaded/Utils.js 2018-04-13 01:56:24 UTC (rev 230620)
+++ trunk/Tools/LayoutReloaded/Utils.js 2018-04-13 03:09:03 UTC (rev 230621)
@@ -553,17 +553,6 @@
return this._dumpBox(layoutState, initialContainingBlock, 1) + this._dumpTree(layoutState, initialContainingBlock, 2);
}
- static _findDisplayBox(layoutState, box) {
- for (let formattingEntry of layoutState.formattingStates()) {
- let formattingState = formattingEntry[1];
- let displayBox = formattingState.displayBoxes().get(box);
- if (displayBox)
- return displayBox;
- }
- ASSERT(!box.parent());
- return layoutState.initialDisplayBox();
- }
-
static _dumpBox(layoutState, box, level) {
// Skip anonymous boxes for now -This is the case where WebKit does not generate an anon inline container for text content where the text is a direct child
// of a block container.
@@ -574,7 +563,7 @@
}
if (box.name() == "RenderInline") {
if (box.isInFlowPositioned()) {
- let displayBox = Utils._findDisplayBox(layoutState, box);
+ let displayBox = layoutState.displayBox(box);
let boxRect = displayBox.rect();
return indentation + box.node().tagName + " " + box.name() + " (" + Utils.precisionRoundWithDecimals(boxRect.left()) + ", " + Utils.precisionRoundWithDecimals(boxRect.top()) + ")\n";
}
@@ -582,7 +571,7 @@
}
if (box.isAnonymous())
return "";
- let displayBox = Utils._findDisplayBox(layoutState, box);
+ let displayBox = layoutState.displayBox(box);
let boxRect = displayBox.rect();
return indentation + (box.node().tagName ? (box.node().tagName + " ") : "") + box.name() + " at (" + boxRect.left() + "," + boxRect.top() + ") size " + boxRect.width() + "x" + boxRect.height() + "\n";
}