Title: [229658] trunk/Tools
- Revision
- 229658
- Author
- [email protected]
- Date
- 2018-03-15 21:13:26 -0700 (Thu, 15 Mar 2018)
Log Message
[LayoutReloaded] Should never need to go beyond the root container when asking for the containing block.
https://bugs.webkit.org/show_bug.cgi?id=183691
Reviewed by Antti Koivisto.
While laying out the boxes in a block formatting context, if we happen to need
to get to the containing block of a box to compute geometry, it should always be a
descendant of the root container (or the root container itself).
Nothing outside of the formatting context should be able to impact the boxes inside.
* LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js:
(BlockFormattingContext.prototype._computeOutOfFlowPosition):
(BlockFormattingContext.prototype._toAbsolutePosition):
(BlockFormattingContext):
* LayoutReloaded/FormattingContext/BlockFormatting/BlockMarginCollapse.js:
(BlockMarginCollapse._isMarginTopCollapsedWithParent):
(BlockMarginCollapse._isMarginBottomCollapsedWithParent):
* LayoutReloaded/LayoutTree/Box.js:
(Layout.Box.prototype.isRootBox):
(Layout.Box.prototype.isRootElement): Deleted.
* LayoutReloaded/Utils.js:
(Utils.isDescendantOf):
(Utils.mapStaticToAbsolute): Deleted.
* LayoutReloaded/misc/headers/Box.h:
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (229657 => 229658)
--- trunk/Tools/ChangeLog 2018-03-16 02:57:42 UTC (rev 229657)
+++ trunk/Tools/ChangeLog 2018-03-16 04:13:26 UTC (rev 229658)
@@ -1,3 +1,30 @@
+2018-03-15 Zalan Bujtas <[email protected]>
+
+ [LayoutReloaded] Should never need to go beyond the root container when asking for the containing block.
+ https://bugs.webkit.org/show_bug.cgi?id=183691
+
+ Reviewed by Antti Koivisto.
+
+ While laying out the boxes in a block formatting context, if we happen to need
+ to get to the containing block of a box to compute geometry, it should always be a
+ descendant of the root container (or the root container itself).
+ Nothing outside of the formatting context should be able to impact the boxes inside.
+
+ * LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js:
+ (BlockFormattingContext.prototype._computeOutOfFlowPosition):
+ (BlockFormattingContext.prototype._toAbsolutePosition):
+ (BlockFormattingContext):
+ * LayoutReloaded/FormattingContext/BlockFormatting/BlockMarginCollapse.js:
+ (BlockMarginCollapse._isMarginTopCollapsedWithParent):
+ (BlockMarginCollapse._isMarginBottomCollapsedWithParent):
+ * LayoutReloaded/LayoutTree/Box.js:
+ (Layout.Box.prototype.isRootBox):
+ (Layout.Box.prototype.isRootElement): Deleted.
+ * LayoutReloaded/Utils.js:
+ (Utils.isDescendantOf):
+ (Utils.mapStaticToAbsolute): Deleted.
+ * LayoutReloaded/misc/headers/Box.h:
+
2018-03-15 Wenson Hsieh <[email protected]>
[iOS WK2] Hit-testing fails when specifying a large top content inset
Modified: trunk/Tools/LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js (229657 => 229658)
--- trunk/Tools/LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js 2018-03-16 02:57:42 UTC (rev 229657)
+++ trunk/Tools/LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js 2018-03-16 04:13:26 UTC (rev 229658)
@@ -294,7 +294,7 @@
let top = Number.NaN;
if (Utils.isTopAuto(layoutBox) && Utils.isBottomAuto(layoutBox)) {
// Convert static position to absolute.
- top = Utils.mapStaticToAbsolute(layoutBox).top();
+ top = this._toAbsolutePosition(layoutBox).top();
} else if (!Utils.isTopAuto(layoutBox))
top = Utils.top(layoutBox) + this.marginTop(layoutBox);
else if (!Utils.isBottomAuto(layoutBox))
@@ -305,7 +305,7 @@
let left = Number.NaN;
if (Utils.isLeftAuto(layoutBox) && Utils.isRightAuto(layoutBox)) {
// Convert static position to absolute.
- left = Utils.mapStaticToAbsolute(layoutBox).left();
+ left = this._toAbsolutePosition(layoutBox).left();
} else if (!Utils.isLeftAuto(layoutBox))
left = Utils.left(layoutBox) + this.marginLeft(layoutBox);
else if (!Utils.isRightAuto(layoutBox))
@@ -327,5 +327,18 @@
}
return width;
}
+
+ _toAbsolutePosition(layoutBox) {
+ // We should never need to go beyond the root container.
+ let containingBlock = layoutBox.containingBlock();
+ ASSERT(containingBlock == this.rootContainer() || Utils.isDescendantOf(containingBlock, this.rootContainer()));
+ let topLeft = layoutBox.rect().topLeft();
+ let ascendant = layoutBox.parent();
+ while (ascendant && ascendant != containingBlock) {
+ topLeft.moveBy(ascendant.rect().topLeft());
+ ascendant = ascendant.parent();
+ }
+ return new LayoutRect(topLeft, layoutBox.rect().size());
+ }
}
Modified: trunk/Tools/LayoutReloaded/FormattingContext/BlockFormatting/BlockMarginCollapse.js (229657 => 229658)
--- trunk/Tools/LayoutReloaded/FormattingContext/BlockFormatting/BlockMarginCollapse.js 2018-03-16 02:57:42 UTC (rev 229657)
+++ trunk/Tools/LayoutReloaded/FormattingContext/BlockFormatting/BlockMarginCollapse.js 2018-03-16 04:13:26 UTC (rev 229658)
@@ -94,7 +94,7 @@
if (parent.establishesBlockFormattingContext())
return false;
// Margins of the root element's box do not collapse.
- if (parent.isRootElement())
+ if (parent.isRootBox())
return false;
if (Utils.hasBorderTop(parent))
return false;
@@ -117,7 +117,7 @@
if (parent.establishesBlockFormattingContext())
return false;
// Margins of the root element's box do not collapse.
- if (parent.isRootElement())
+ if (parent.isRootBox())
return false;
if (Utils.hasBorderTop(parent))
return false;
Modified: trunk/Tools/LayoutReloaded/LayoutTree/Box.js (229657 => 229658)
--- trunk/Tools/LayoutReloaded/LayoutTree/Box.js 2018-03-16 02:57:42 UTC (rev 229657)
+++ trunk/Tools/LayoutReloaded/LayoutTree/Box.js 2018-03-16 04:13:26 UTC (rev 229658)
@@ -213,7 +213,7 @@
return this.isFloatingPositioned() || this.isOutOfFlowPositioned();
}
- isRootElement() {
+ isRootBox() {
// FIXME: This should just be a simple instanceof check, but we are in the mainframe while the test document is in an iframe
// Let's just return root for both the RenderView and the <html> element.
return !this.parent() || !this.parent().parent();
Modified: trunk/Tools/LayoutReloaded/Utils.js (229657 => 229658)
--- trunk/Tools/LayoutReloaded/Utils.js 2018-03-16 02:57:42 UTC (rev 229657)
+++ trunk/Tools/LayoutReloaded/Utils.js 2018-03-16 04:13:26 UTC (rev 229658)
@@ -486,8 +486,12 @@
return new LayoutRect(topLeft, box.rect().size());
}
- static mapStaticToAbsolute(box) {
- return Utils.mapToContainer(box, box.containingBlock());
+ static isDescendantOf(layoutBox, container) {
+ ASSERT(container);
+ let ascendant = layoutBox.parent();
+ while (ascendant && ascendant != container)
+ ascendant = ascendant.parent();
+ return !!ascendant;
}
static collectOutOfFlowDescendants(containtBlock) {
Modified: trunk/Tools/LayoutReloaded/misc/headers/Box.h (229657 => 229658)
--- trunk/Tools/LayoutReloaded/misc/headers/Box.h 2018-03-16 02:57:42 UTC (rev 229657)
+++ trunk/Tools/LayoutReloaded/misc/headers/Box.h 2018-03-16 04:13:26 UTC (rev 229658)
@@ -54,7 +54,7 @@
void setIsAnonymous(bool);
bool isAnonymous() const;
- virtual bool isRootElement() const;
+ bool isRootBox() const;
virtual bool isContainer() const;
bool isBlockLevelBox() const;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes