[LayoutReloaded] Remove border/padding/contentBox() functions from Layout.Box
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Mar 2018 02:30:51 +0000 (02:30 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Mar 2018 02:30:51 +0000 (02:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=183761

Reviewed by Antti Koivisto.

Display.Box has them.

* LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js:
(BlockFormattingContext.prototype._computeOutOfFlowWidth):
(BlockFormattingContext.prototype._computeOutOfFlowHeight):
(BlockFormattingContext.prototype._horizontalConstraint):
(BlockFormattingContext.prototype._contentHeight):
(BlockFormattingContext.prototype._adjustBottomWithFIXME):
(BlockFormattingContext.prototype._computeOutOfFlowPosition):
* LayoutReloaded/FormattingContext/FloatingContext.js:
(FloatingContext.prototype._availableSpace):
* LayoutReloaded/FormattingContext/FormattingContext.js:
(FormattingContext.prototype.absoluteBorderBox):
(FormattingContext.prototype.absolutePaddingBox):
(FormattingContext.prototype.absoluteContentBox):
* LayoutReloaded/LayoutTree/Box.js:
(Layout.Box.prototype.isDescendantOf):
(Layout.Box):
(Layout.Box.prototype.borderBox): Deleted.
(Layout.Box.prototype.paddingBox): Deleted.
(Layout.Box.prototype.contentBox): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229734 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/LayoutTree/Box.js

index 06cb7ed..3994658 100644 (file)
@@ -1,3 +1,32 @@
+2018-03-19  Zalan Bujtas  <zalan@apple.com>
+
+        [LayoutReloaded] Remove border/padding/contentBox() functions from Layout.Box
+        https://bugs.webkit.org/show_bug.cgi?id=183761
+
+        Reviewed by Antti Koivisto.
+
+        Display.Box has them.
+
+        * LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js:
+        (BlockFormattingContext.prototype._computeOutOfFlowWidth):
+        (BlockFormattingContext.prototype._computeOutOfFlowHeight):
+        (BlockFormattingContext.prototype._horizontalConstraint):
+        (BlockFormattingContext.prototype._contentHeight):
+        (BlockFormattingContext.prototype._adjustBottomWithFIXME):
+        (BlockFormattingContext.prototype._computeOutOfFlowPosition):
+        * LayoutReloaded/FormattingContext/FloatingContext.js:
+        (FloatingContext.prototype._availableSpace):
+        * LayoutReloaded/FormattingContext/FormattingContext.js:
+        (FormattingContext.prototype.absoluteBorderBox):
+        (FormattingContext.prototype.absolutePaddingBox):
+        (FormattingContext.prototype.absoluteContentBox):
+        * LayoutReloaded/LayoutTree/Box.js:
+        (Layout.Box.prototype.isDescendantOf):
+        (Layout.Box):
+        (Layout.Box.prototype.borderBox): Deleted.
+        (Layout.Box.prototype.paddingBox): Deleted.
+        (Layout.Box.prototype.contentBox): Deleted.
+
 2018-03-19  Jiewen Tan  <jiewen_tan@apple.com>
 
         Unreviewed, another quick fix for r229699
index 0bb1273..e917963 100644 (file)
@@ -171,7 +171,7 @@ class BlockFormattingContext extends FormattingContext {
         else if (Utils.isLeftAuto(layoutBox) && !Utils.isWidthAuto(layoutBox) && !Utils.isRightAuto(layoutBox))
             width = Utils.width(layoutBox); // 4
         else if (Utils.isWidthAuto(layoutBox) && !Utils.isLeftAuto(layoutBox) && !Utils.isRightAuto(layoutBox))
-            width = Math.max(0, layoutBox.containingBlock().contentBox().width() - Utils.right(layoutBox) - Utils.left(layoutBox)); // 5
+            width = Math.max(0, this.toDisplayBox(layoutBox.containingBlock()).contentBox().width() - Utils.right(layoutBox) - Utils.left(layoutBox)); // 5
         else if (Utils.isRightAuto(layoutBox) && !Utils.isLeftAuto(layoutBox) && !Utils.isWidthAuto(layoutBox))
             width = Utils.width(layoutBox); // 6
         else
@@ -219,7 +219,7 @@ class BlockFormattingContext extends FormattingContext {
         else if (Utils.isTopAuto((layoutBox)) && !Utils.isHeightAuto((layoutBox)) && !Utils.isBottomAuto((layoutBox)))
             height = Utils.height(layoutBox); // 6
         else if (Utils.isHeightAuto((layoutBox)) && !Utils.isTopAuto((layoutBox)) && !Utils.isBottomAuto((layoutBox)))
-            height = Math.max(0, layoutBox.containingBlock().contentBox().height() - Utils.bottom(layoutBox) - Utils.top(layoutBox)); // 7
+            height = Math.max(0, this.toDisplayBox(layoutBox.containingBlock()).contentBox().height() - Utils.bottom(layoutBox) - Utils.top(layoutBox)); // 7
         else if (Utils.isBottomAuto((layoutBox)) && !Utils.isTopAuto((layoutBox)) && !Utils.isHeightAuto((layoutBox)))
             height = Utils.height(layoutBox); // 8
         else
@@ -246,7 +246,7 @@ class BlockFormattingContext extends FormattingContext {
     }
 
     _horizontalConstraint(layoutBox) {
-        let horizontalConstraint = layoutBox.containingBlock().contentBox().width();
+        let horizontalConstraint = this.toDisplayBox(layoutBox.containingBlock()).contentBox().width();
         horizontalConstraint -= this.marginLeft(layoutBox) + this.marginRight(layoutBox);
         return horizontalConstraint;
     }
@@ -270,7 +270,7 @@ class BlockFormattingContext extends FormattingContext {
             let lastLine = lines[lines.length - 1];
             return lastLine.rect().bottom();
         }
-        let top = layoutBox.contentBox().top();
+        let top = this.toDisplayBox(layoutBox).contentBox().top();
         let bottom = this._adjustBottomWithFIXME(layoutBox);
         return bottom - top;
     }
@@ -281,7 +281,7 @@ class BlockFormattingContext extends FormattingContext {
         let lastInFlowDisplayBox = lastInFlowChild.displayBox();
         let bottom = lastInFlowDisplayBox.bottom() + this.marginBottom(lastInFlowChild);
         // FIXME: margin for body
-        if (lastInFlowChild.name() == "RenderBody" && Utils.isHeightAuto(lastInFlowChild) && !lastInFlowChild.contentBox().height())
+        if (lastInFlowChild.name() == "RenderBody" && Utils.isHeightAuto(lastInFlowChild) && !this.toDisplayBox(lastInFlowChild).contentBox().height())
             bottom -= this.marginBottom(lastInFlowChild);
         // FIXME: figure out why floatings part of the initial block formatting context get propagated to HTML
         if (layoutBox.node().tagName == "HTML") {
@@ -312,7 +312,7 @@ class BlockFormattingContext extends FormattingContext {
     _computeOutOfFlowPosition(layoutBox) {
         let displayBox = this.toDisplayBox(layoutBox);
         let top = Number.NaN;
-        let containerSize = layoutBox.containingBlock().contentBox().size();
+        let containerSize = this.toDisplayBox(layoutBox.containingBlock()).contentBox().size();
         // Top/bottom
         if (Utils.isTopAuto(layoutBox) && Utils.isBottomAuto(layoutBox)) {
             ASSERT(Utils.isStaticallyPositioned(layoutBox));
index b091397..ce88836 100644 (file)
@@ -132,13 +132,14 @@ class FloatingContext {
     }
 
     _availableSpace(containingBlock, floatingPair) {
+        let containingBlockContentBox = this._formattingContext().toDisplayBox(containingBlock);
         if (floatingPair.left && floatingPair.right)
             return this._formattingContext().absoluteMarginBox(floatingPair.right).left() - this._formattingContext().absoluteMarginBox(floatingPair.left).right();
         if (floatingPair.left)
-            return containingBlock.contentBox().width() - (this._formattingContext().absoluteMarginBox(floatingPair.left).right() - this._formattingContext().absoluteBorderBox(containingBlock).left());
+            return containingBlockContentBox.width() - (this._formattingContext().absoluteMarginBox(floatingPair.left).right() - this._formattingContext().absoluteBorderBox(containingBlock).left());
         if (floatingPair.right)
             return this._formattingContext().absoluteMarginBox(floatingPair.right).left();
-        return containingBlock.contentBox().width();
+        return containingBlockContentBox.width();
     }
 
     _findFloatingAtVerticalPosition(verticalPosition, floatingStack) {
index dd42cf7..a6a6468 100644 (file)
@@ -74,21 +74,21 @@ class FormattingContext {
     }
 
     absoluteBorderBox(layoutBox) {
-        let borderBox = layoutBox.borderBox();
+        let borderBox = this.toDisplayBox(layoutBox).borderBox();
         let absoluteRect = new LayoutRect(this._toRootAbsolutePosition(layoutBox), borderBox.size());
         absoluteRect.moveBy(borderBox.topLeft());
         return absoluteRect;
     }
 
     absolutePaddingBox(layoutBox) {
-        let paddingBox = layoutBox.paddingBox();
+        let paddingBox = this.toDisplayBox(layoutBox).paddingBox();
         let absoluteRect = new LayoutRect(this._toRootAbsolutePosition(layoutBox), paddingBox.size());
         absoluteRect.moveBy(paddingBox.topLeft());
         return absoluteRect;
     }
 
     absoluteContentBox(layoutBox) {
-        let contentBox = layoutBox.contentBox();
+        let contentBox = this.toDisplayBox(layoutBox).contentBox();
         let absoluteRect = new LayoutRect(this._toRootAbsolutePosition(layoutBox), contentBox.size());
         absoluteRect.moveBy(contentBox.topLeft());
         return absoluteRect;
index c22d56e..dcc5a43 100644 (file)
@@ -239,16 +239,4 @@ Layout.Box = class Box {
             ascendant = ascendant.parent();
         return !!ascendant;
     }
-
-    borderBox() {
-        return this.displayBox().borderBox();
-    }
-
-    paddingBox() {
-        return this.displayBox().paddingBox();
-    }
-
-    contentBox() {
-        return this.displayBox().contentBox();
-    }
 }