https://bugs.webkit.org/show_bug.cgi?id=183734
Reviewed by Antti Koivisto.
...and use Display.Box instead.
* LayoutReloaded/DisplayTree/Box.js:
(Display.Box.prototype.bottomRight):
(Display.Box.prototype.size):
(Display.Box.prototype.height):
(Display.Box.prototype.width):
* LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js:
(BlockFormattingContext.prototype._computeStaticPosition):
(BlockFormattingContext.prototype._adjustBottomWithFIXME):
(BlockFormattingContext.prototype._computeInFlowPositionedPosition):
(BlockFormattingContext.prototype._computeOutOfFlowPosition):
* LayoutReloaded/FormattingContext/FloatingContext.js:
(FloatingContext.prototype._positionForClear):
(FloatingContext.prototype._computePositionToAvoidIntrudingFloats):
(FloatingContext.prototype._adjustedFloatingPosition):
* LayoutReloaded/FormattingContext/FormattingContext.js:
(FormattingContext.prototype.absoluteMarginBox):
(FormattingContext.prototype.absoluteBorderBox):
(FormattingContext.prototype.absolutePaddingBox):
(FormattingContext.prototype.absoluteContentBox):
(FormattingContext.prototype._toAbsolutePosition):
(FormattingContext.prototype._toRootAbsolutePosition):
* LayoutReloaded/LayoutTree/Box.js:
(Layout.Box.prototype.rect): Deleted.
(Layout.Box.prototype.topLeft): Deleted.
(Layout.Box.prototype.bottomRight): Deleted.
* LayoutReloaded/Utils.js:
(Utils._dumpBox):
(Utils.mapToContainer): Deleted.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229703
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2018-03-18 Zalan Bujtas <zalan@apple.com>
+
+ [LayoutReloaded] Remove left/right width/height getters from Layout.Box
+ https://bugs.webkit.org/show_bug.cgi?id=183734
+
+ Reviewed by Antti Koivisto.
+
+ ...and use Display.Box instead.
+
+ * LayoutReloaded/DisplayTree/Box.js:
+ (Display.Box.prototype.bottomRight):
+ (Display.Box.prototype.size):
+ (Display.Box.prototype.height):
+ (Display.Box.prototype.width):
+ * LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js:
+ (BlockFormattingContext.prototype._computeStaticPosition):
+ (BlockFormattingContext.prototype._adjustBottomWithFIXME):
+ (BlockFormattingContext.prototype._computeInFlowPositionedPosition):
+ (BlockFormattingContext.prototype._computeOutOfFlowPosition):
+ * LayoutReloaded/FormattingContext/FloatingContext.js:
+ (FloatingContext.prototype._positionForClear):
+ (FloatingContext.prototype._computePositionToAvoidIntrudingFloats):
+ (FloatingContext.prototype._adjustedFloatingPosition):
+ * LayoutReloaded/FormattingContext/FormattingContext.js:
+ (FormattingContext.prototype.absoluteMarginBox):
+ (FormattingContext.prototype.absoluteBorderBox):
+ (FormattingContext.prototype.absolutePaddingBox):
+ (FormattingContext.prototype.absoluteContentBox):
+ (FormattingContext.prototype._toAbsolutePosition):
+ (FormattingContext.prototype._toRootAbsolutePosition):
+ * LayoutReloaded/LayoutTree/Box.js:
+ (Layout.Box.prototype.rect): Deleted.
+ (Layout.Box.prototype.topLeft): Deleted.
+ (Layout.Box.prototype.bottomRight): Deleted.
+ * LayoutReloaded/Utils.js:
+ (Utils._dumpBox):
+ (Utils.mapToContainer): Deleted.
+
2018-03-18 Zalan Bujtas <zalan@apple.com>
[LayoutReloaded] Remove left/right width/height setters from Layout.Box
return this.rect().bottomRight();
}
+ size() {
+ return this.rect().size();
+ }
+
+ height() {
+ return this.rect().height();
+ }
+
+ width() {
+ return this.rect().width();
+ }
+
setTopLeft(topLeft) {
this.m_rect.setTopLeft(topLeft);
}
let parent = layoutBox.parent();
// Start from the top of the container's content box.
let previousInFlowSibling = layoutBox.previousInFlowSibling();
- let contentBottom = previousInFlowSibling ? previousInFlowSibling.bottomRight().top() + this.marginBottom(previousInFlowSibling) : parent.contentBox().top();
+ let contentBottom = parent.contentBox().top()
+ if (previousInFlowSibling)
+ contentBottom = this.toDisplayBox(previousInFlowSibling).bottomRight().top() + this.marginBottom(previousInFlowSibling);
let position = new LayoutPoint(contentBottom, parent.contentBox().left());
position.moveBy(new LayoutSize(this.marginLeft(layoutBox), this.marginTop(layoutBox)));
this.toDisplayBox(layoutBox).setTopLeft(position);
}
_adjustBottomWithFIXME(layoutBox) {
+ // FIXME: This function is a big FIXME.
let lastInFlowChild = layoutBox.lastInFlowChild();
- let bottom = lastInFlowChild.rect().bottom() + this.marginBottom(lastInFlowChild);
+ 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())
bottom -= this.marginBottom(lastInFlowChild);
_computeInFlowPositionedPosition(layoutBox) {
// Start with the original, static position.
- let relativePosition = layoutBox.topLeft();
+ let displayBox = this.toDisplayBox(layoutBox);
+ let relativePosition = displayBox.topLeft();
// Top/bottom
if (!Utils.isTopAuto(layoutBox))
relativePosition.shiftTop(Utils.top(layoutBox));
relativePosition.shiftLeft(Utils.left(layoutBox));
else if (!Utils.isRightAuto(layoutBox))
relativePosition.shiftLeft(-Utils.right(layoutBox));
- this.toDisplayBox(layoutBox).setTopLeft(relativePosition);
+ displayBox.setTopLeft(relativePosition);
}
_computeOutOfFlowPosition(layoutBox) {
+ let displayBox = this.toDisplayBox(layoutBox);
let containerSize = layoutBox.containingBlock().contentBox().size();
// Top/bottom
let top = Number.NaN;
} else if (!Utils.isTopAuto(layoutBox))
top = Utils.top(layoutBox) + this.marginTop(layoutBox);
else if (!Utils.isBottomAuto(layoutBox))
- top = containerSize.height() - Utils.bottom(layoutBox) - layoutBox.rect().height() - this.marginBottom(layoutBox);
+ top = containerSize.height() - Utils.bottom(layoutBox) - displayBox.height() - this.marginBottom(layoutBox);
else
ASSERT_NOT_REACHED();
// Left/right
} else if (!Utils.isLeftAuto(layoutBox))
left = Utils.left(layoutBox) + this.marginLeft(layoutBox);
else if (!Utils.isRightAuto(layoutBox))
- left = containerSize.width() - Utils.right(layoutBox) - layoutBox.rect().width() - this.marginRight(layoutBox);
+ left = containerSize.width() - Utils.right(layoutBox) - displayBox.width() - this.marginRight(layoutBox);
else
ASSERT_NOT_REACHED();
- this.toDisplayBox(layoutBox).setTopLeft(new LayoutPoint(top, left));
+ displayBox.setTopLeft(new LayoutPoint(top, left));
}
_shrinkToFitWidth(layoutBox) {
_positionForClear(layoutBox) {
ASSERT(Utils.hasClear(layoutBox));
+ let displayBox = this._formattingContext().toDisplayBox(layoutBox);
if (this._isEmpty())
- return layoutBox.topLeft();
+ return displayBox.topLeft();
let leftBottom = Number.NaN;
let rightBottom = Number.NaN;
rightBottom = this._bottom(this.m_rightFloatingBoxStack);
if (!Number.isNaN(leftBottom) && !Number.isNaN(rightBottom))
- return new LayoutPoint(Math.max(leftBottom, rightBottom), layoutBox.rect().left());
+ return new LayoutPoint(Math.max(leftBottom, rightBottom), displayBox.left());
if (!Number.isNaN(leftBottom))
- return new LayoutPoint(leftBottom, layoutBox.rect().left());
+ return new LayoutPoint(leftBottom, displayBox.left());
if (!Number.isNaN(rightBottom))
- return new LayoutPoint(rightBottom, layoutBox.rect().left());
- return layoutBox.topLeft();
+ return new LayoutPoint(rightBottom, displayBox.left());
+ return displayBox.topLeft();
}
_computePositionToAvoidIntrudingFloats(layoutBox) {
if (!layoutBox.establishesBlockFormattingContext() || this._isEmpty())
- return layoutBox.topLeft();
+ return this._formattingContext().toDisplayBox(layoutBox).topLeft();
// The border box of a table, a block-level replaced element, or an element in the normal flow that establishes
// a new block formatting context (such as an element with 'overflow' other than 'visible') must not overlap the
// margin box of any floats in the same block formatting context as the element itself.
if (Utils.isFloatingLeft(floatingBox) || !Utils.isFloatingPositioned(floatingBox))
return new LayoutPoint(verticalPosition, left);
- return new LayoutPoint(verticalPosition, right - floatingBox.rect().width());
+ return new LayoutPoint(verticalPosition, right - this._formattingContext().toDisplayBox(floatingBox).rect().width());
}
_bottom(floatingStack) {
}
absoluteMarginBox(layoutBox) {
- let absoluteContentBox = Utils.mapToContainer(layoutBox, this.rootContainer());
+ let absoluteContentBox = this._toRootAbsolutePosition(layoutBox);
absoluteContentBox.moveBy(new LayoutSize(-this.marginLeft(layoutBox), -this.marginTop(layoutBox)));
absoluteContentBox.growBy(new LayoutSize(this.marginLeft(layoutBox) + this.marginRight(layoutBox), this.marginTop(layoutBox) + this.marginBottom(layoutBox)));
return absoluteContentBox;
absoluteBorderBox(layoutBox) {
let borderBox = layoutBox.borderBox();
- let absoluteRect = new LayoutRect(Utils.mapToContainer(layoutBox, this.rootContainer()).topLeft(), borderBox.size());
+ let absoluteRect = new LayoutRect(this._toRootAbsolutePosition(layoutBox).topLeft(), borderBox.size());
absoluteRect.moveBy(borderBox.topLeft());
return absoluteRect;
}
absolutePaddingBox(layoutBox) {
let paddingBox = layoutBox.paddingBox();
- let absoluteRect = new LayoutRect(Utils.mapToContainer(layoutBox, this.rootContainer()).topLeft(), paddingBox.size());
+ let absoluteRect = new LayoutRect(this._toRootAbsolutePosition(layoutBox).topLeft(), paddingBox.size());
absoluteRect.moveBy(paddingBox.topLeft());
return absoluteRect;
}
absoluteContentBox(layoutBox) {
let contentBox = layoutBox.contentBox();
- let absoluteRect = new LayoutRect(Utils.mapToContainer(layoutBox, this.rootContainer()).topLeft(), contentBox.size());
+ let absoluteRect = new LayoutRect(this._toRootAbsolutePosition(layoutBox).topLeft(), contentBox.size());
absoluteRect.moveBy(contentBox.topLeft());
return absoluteRect;
}
// We should never need to go beyond the root container.
let containingBlock = layoutBox.containingBlock();
ASSERT(containingBlock == this.rootContainer() || containingBlock.isDescendantOf(this.rootContainer()));
- let topLeft = layoutBox.rect().topLeft();
+ let topLeft = this.toDisplayBox(layoutBox).topLeft();
let ascendant = layoutBox.parent();
while (ascendant && ascendant != containingBlock) {
- topLeft.moveBy(ascendant.rect().topLeft());
+ topLeft.moveBy(this.toDisplayBox(ascendant).topLeft());
ascendant = ascendant.parent();
}
- return new LayoutRect(topLeft, layoutBox.rect().size());
+ return new LayoutRect(topLeft, this.toDisplayBox(layoutBox).size());
}
+ _toRootAbsolutePosition(layoutBox) {
+ let displayBox = this.toDisplayBox(layoutBox);
+ let topLeft = displayBox.topLeft();
+ let ascendant = layoutBox.parent();
+ while (ascendant && ascendant != this.rootContainer()) {
+ topLeft.moveBy(this.toDisplayBox(ascendant).topLeft());
+ ascendant = ascendant.parent();
+ }
+ ASSERT(ascendant);
+ return new LayoutRect(topLeft, displayBox.size());
+ }
+
+
_descendantNeedsLayout() {
return this.m_layoutStack.length;
}
return this.m_displayBox;
}
- rect() {
- return this.displayBox().rect();
- }
-
- topLeft() {
- return this.rect().topLeft();
- }
-
- bottomRight() {
- return this.rect().bottomRight();
- }
-
isContainer() {
return false;
}
return window.getComputedStyle(node).float == "left";
}
- static mapToContainer(box, container) {
- let topLeft = box.rect().topLeft();
- let ascendant = box.parent();
- while (ascendant && ascendant != container) {
- topLeft.moveBy(ascendant.rect().topLeft());
- ascendant = ascendant.parent();
- }
- ASSERT(ascendant);
- return new LayoutRect(topLeft, box.rect().size());
- }
-
static nextBreakingOpportunity(textBox, currentPosition)
{
return window.nextBreakingOpportunity(textBox.content(), currentPosition);
}
if (box.isAnonymous())
return "";
- let boxRect = box.rect();
+ let displayBox = box.displayBox();
+ 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";
}