Skip to content
Permalink
Browse files
[LayoutReloaded] Remove left/right width/height setters from Layout.Box
https://bugs.webkit.org/show_bug.cgi?id=183731

Reviewed by Antti Koivisto.

...and use Display.Box instead.

* LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js:
(BlockFormattingContext.prototype._computeStaticPosition):
(BlockFormattingContext.prototype._computeOutOfFlowWidth):
(BlockFormattingContext.prototype._computeFloatingWidth):
(BlockFormattingContext.prototype._computeInFlowWidth):
(BlockFormattingContext.prototype._computeOutOfFlowHeight):
(BlockFormattingContext.prototype._computeFloatingHeight):
(BlockFormattingContext.prototype._computeInFlowHeight):
(BlockFormattingContext.prototype._computeInFlowPositionedPosition):
(BlockFormattingContext.prototype._computeOutOfFlowPosition):
* LayoutReloaded/FormattingContext/FloatingContext.js:
(FloatingContext.prototype.computePosition):
* LayoutReloaded/FormattingContext/FormattingContext.js:
(FormattingContext.prototype._toDisplayBox):
(FormattingContext.prototype._toLayoutBox):
* LayoutReloaded/Layout.js:
(layout):
* LayoutReloaded/LayoutTree/Box.js:
(Layout.Box.prototype.setTopLeft): Deleted.
(Layout.Box.prototype.setSize): Deleted.
(Layout.Box.prototype.setWidth): Deleted.
(Layout.Box.prototype.setHeight): Deleted.

Canonical link: https://commits.webkit.org/199369@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229702 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
alanbujtas committed Mar 19, 2018
1 parent cece1ed commit 9ee0465b1c556c86f46bc8a27333a5ca90a1aaf1
Showing 6 changed files with 54 additions and 36 deletions.
@@ -1,3 +1,35 @@
2018-03-18 Zalan Bujtas <zalan@apple.com>

[LayoutReloaded] Remove left/right width/height setters from Layout.Box
https://bugs.webkit.org/show_bug.cgi?id=183731

Reviewed by Antti Koivisto.

...and use Display.Box instead.

* LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js:
(BlockFormattingContext.prototype._computeStaticPosition):
(BlockFormattingContext.prototype._computeOutOfFlowWidth):
(BlockFormattingContext.prototype._computeFloatingWidth):
(BlockFormattingContext.prototype._computeInFlowWidth):
(BlockFormattingContext.prototype._computeOutOfFlowHeight):
(BlockFormattingContext.prototype._computeFloatingHeight):
(BlockFormattingContext.prototype._computeInFlowHeight):
(BlockFormattingContext.prototype._computeInFlowPositionedPosition):
(BlockFormattingContext.prototype._computeOutOfFlowPosition):
* LayoutReloaded/FormattingContext/FloatingContext.js:
(FloatingContext.prototype.computePosition):
* LayoutReloaded/FormattingContext/FormattingContext.js:
(FormattingContext.prototype._toDisplayBox):
(FormattingContext.prototype._toLayoutBox):
* LayoutReloaded/Layout.js:
(layout):
* LayoutReloaded/LayoutTree/Box.js:
(Layout.Box.prototype.setTopLeft): Deleted.
(Layout.Box.prototype.setSize): Deleted.
(Layout.Box.prototype.setWidth): Deleted.
(Layout.Box.prototype.setHeight): Deleted.

2018-03-18 Zalan Bujtas <zalan@apple.com>

[LayoutReloaded] Collect out-of-flow positioned boxes for a given formatting context.
@@ -115,7 +115,7 @@ class BlockFormattingContext extends FormattingContext {
let contentBottom = previousInFlowSibling ? previousInFlowSibling.bottomRight().top() + this.marginBottom(previousInFlowSibling) : parent.contentBox().top();
let position = new LayoutPoint(contentBottom, parent.contentBox().left());
position.moveBy(new LayoutSize(this.marginLeft(layoutBox), this.marginTop(layoutBox)));
layoutBox.setTopLeft(position);
this.toDisplayBox(layoutBox).setTopLeft(position);
}

_placeInFlowPositionedChildren(container) {
@@ -176,18 +176,18 @@ class BlockFormattingContext extends FormattingContext {
else
ASSERT_NOT_REACHED();
width += Utils.computedHorizontalBorderAndPadding(layoutBox.node());
layoutBox.setWidth(width);
this.toDisplayBox(layoutBox).setWidth(width);
}

_computeFloatingWidth(layoutBox) {
// FIXME: missing cases
layoutBox.setWidth(Utils.width(layoutBox) + Utils.computedHorizontalBorderAndPadding(layoutBox.node()));
this.toDisplayBox(layoutBox).setWidth(Utils.width(layoutBox) + Utils.computedHorizontalBorderAndPadding(layoutBox.node()));
}

_computeInFlowWidth(layoutBox) {
if (Utils.isWidthAuto(layoutBox))
return layoutBox.setWidth(this._horizontalConstraint(layoutBox));
return layoutBox.setWidth(Utils.width(layoutBox) + Utils.computedHorizontalBorderAndPadding(layoutBox.node()));
return this.toDisplayBox(layoutBox).setWidth(this._horizontalConstraint(layoutBox));
return this.toDisplayBox(layoutBox).setWidth(Utils.width(layoutBox) + Utils.computedHorizontalBorderAndPadding(layoutBox.node()));
}

_computeOutOfFlowHeight(layoutBox) {
@@ -224,12 +224,12 @@ class BlockFormattingContext extends FormattingContext {
else
ASSERT_NOT_REACHED();
height += Utils.computedVerticalBorderAndPadding(layoutBox.node());
layoutBox.setHeight(height);
this.toDisplayBox(layoutBox).setHeight(height);
}

_computeFloatingHeight(layoutBox) {
// FIXME: missing cases
layoutBox.setHeight(Utils.height(layoutBox) + Utils.computedVerticalBorderAndPadding(layoutBox.node()));
this.toDisplayBox(layoutBox).setHeight(Utils.height(layoutBox) + Utils.computedVerticalBorderAndPadding(layoutBox.node()));
}

_computeInFlowHeight(layoutBox) {
@@ -239,9 +239,9 @@ class BlockFormattingContext extends FormattingContext {

// The element's height is the distance from its top content edge to the first applicable of the following:
// 1. the bottom edge of the last line box, if the box establishes a inline formatting context with one or more lines
return layoutBox.setHeight(this._contentHeight(layoutBox) + Utils.computedVerticalBorderAndPadding(layoutBox.node()));
return this.toDisplayBox(layoutBox).setHeight(this._contentHeight(layoutBox) + Utils.computedVerticalBorderAndPadding(layoutBox.node()));
}
return layoutBox.setHeight(Utils.height(layoutBox) + Utils.computedVerticalBorderAndPadding(layoutBox.node()));
return this.toDisplayBox(layoutBox).setHeight(Utils.height(layoutBox) + Utils.computedVerticalBorderAndPadding(layoutBox.node()));
}

_horizontalConstraint(layoutBox) {
@@ -302,7 +302,7 @@ class BlockFormattingContext extends FormattingContext {
relativePosition.shiftLeft(Utils.left(layoutBox));
else if (!Utils.isRightAuto(layoutBox))
relativePosition.shiftLeft(-Utils.right(layoutBox));
layoutBox.setTopLeft(relativePosition);
this.toDisplayBox(layoutBox).setTopLeft(relativePosition);
}

_computeOutOfFlowPosition(layoutBox) {
@@ -329,7 +329,7 @@ class BlockFormattingContext extends FormattingContext {
left = containerSize.width() - Utils.right(layoutBox) - layoutBox.rect().width() - this.marginRight(layoutBox);
else
ASSERT_NOT_REACHED();
layoutBox.setTopLeft(new LayoutPoint(top, left));
this.toDisplayBox(layoutBox).setTopLeft(new LayoutPoint(top, left));
}

_shrinkToFitWidth(layoutBox) {
@@ -34,15 +34,16 @@ class FloatingContext {
computePosition(layoutBox) {
if (layoutBox.isOutOfFlowPositioned())
return;
let displayBox = this._formattingContext().toDisplayBox(layoutBox);
if (layoutBox.isFloatingPositioned()) {
let position = this._positionForFloating(layoutBox);
this._addFloating(layoutBox);
return layoutBox.setTopLeft(position);
return displayBox.setTopLeft(position);
}
if (Utils.hasClear(layoutBox))
return layoutBox.setTopLeft(this._positionForClear(layoutBox));
return displayBox.setTopLeft(this._positionForClear(layoutBox));
// Intruding floats might force this box move.
return layoutBox.setTopLeft(this._computePositionToAvoidIntrudingFloats(layoutBox));
displayBox.setTopLeft(this._computePositionToAvoidIntrudingFloats(layoutBox));
}

bottom() {
@@ -136,16 +136,16 @@ class FormattingContext {
layoutBox.setDisplayBox(displayBox);
}

_toDisplayBox(layoutBox) {
toDisplayBox(layoutBox) {
ASSERT(layoutBox);
ASSERT(this.m_layoutToDisplay.has(layoutBox));
return this.m_layoutToDisplay.get(layout);
return this.m_layoutToDisplay.get(layoutBox);
}

_toLayoutBox(displayBox) {
toLayoutBox(displayBox) {
ASSERT(displayBox);
ASSERT(this.m_displayToLayout.has(displayBox));
return this.m_displayToLayout.get(layout);
return this.m_displayToLayout.get(displayBox);
}

_outOfFlowDescendants() {
@@ -26,8 +26,9 @@
function layout(window, viewportSize) {
let treeBuilder = new TreeBuilder();
let initialContainingBlock = treeBuilder.createTree(window.document, window.renderTreeStructure);
initialContainingBlock.setDisplayBox(new Display.Box());
initialContainingBlock.setSize(viewportSize);
let displayBox = new Display.Box();
displayBox.setSize(viewportSize);
initialContainingBlock.setDisplayBox(displayBox);

let layoutContext = new LayoutContext(initialContainingBlock);
layoutContext.layoutFormattingContext(initialContainingBlock.establishedFormattingContext());
@@ -130,22 +130,6 @@ Layout.Box = class Box {
return this.rect().bottomRight();
}

setTopLeft(topLeft) {
this.displayBox().setTopLeft(topLeft);
}

setSize(size) {
this.displayBox().setSize(size);
}

setWidth(width) {
this.displayBox().setWidth(width);
}

setHeight(height) {
this.displayBox().setHeight(height);
}

isContainer() {
return false;
}

0 comments on commit 9ee0465

Please sign in to comment.