[LayoutReloaded] Remove left/right width/height setters from Layout.Box
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Mar 2018 01:28:58 +0000 (01:28 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Mar 2018 01:28:58 +0000 (01:28 +0000)
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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229702 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js
Tools/LayoutReloaded/FormattingContext/FloatingContext.js
Tools/LayoutReloaded/FormattingContext/FormattingContext.js
Tools/LayoutReloaded/Layout.js
Tools/LayoutReloaded/LayoutTree/Box.js

index 2f23ce2..a824701 100644 (file)
@@ -1,5 +1,37 @@
 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.
         https://bugs.webkit.org/show_bug.cgi?id=183730
 
index 69efb38..2c273db 100644 (file)
@@ -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) {
index e723cda..a62f628 100644 (file)
@@ -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() {
index 921d07a..7b1d522 100644 (file)
@@ -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() {
index 0bec697..64c37a8 100644 (file)
@@ -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());
index 54c5302..ffc8c26 100644 (file)
@@ -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;
     }