Diff
Modified: trunk/Tools/ChangeLog (229738 => 229739)
--- trunk/Tools/ChangeLog 2018-03-20 03:26:15 UTC (rev 229738)
+++ trunk/Tools/ChangeLog 2018-03-20 05:02:41 UTC (rev 229739)
@@ -1,3 +1,38 @@
+2018-03-19 Zalan Bujtas <za...@apple.com>
+
+ [LayoutReloaded] Layout.Box should not create the formatting context.
+ https://bugs.webkit.org/show_bug.cgi?id=183766
+
+ Reviewed by Antti Koivisto.
+
+ Since the formattingContext's lifetime is tied to the layout, the LayoutContext
+ should construct it instead.
+
+ * LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js:
+ (BlockFormattingContext):
+ (BlockFormattingContext.prototype.layout):
+ (BlockFormattingContext.prototype._layoutOutOfFlowDescendants):
+ (BlockFormattingContext.prototype._contentHeight):
+ * LayoutReloaded/FormattingContext/FormattingContext.js:
+ (FormattingContext):
+ (FormattingContext.prototype.layoutContext):
+ (FormattingContext.prototype.toDisplayBox):
+ (FormattingContext.prototype._outOfFlowDescendants):
+ * LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js:
+ (InlineFormattingContext):
+ (InlineFormattingContext.prototype.layout):
+ * LayoutReloaded/Layout.js:
+ (layout):
+ * LayoutReloaded/LayoutContext.js:
+ (LayoutContext.prototype.layout):
+ (LayoutContext.prototype._createFormattingContext):
+ (LayoutContext):
+ (LayoutContext.prototype.layoutFormattingContext): Deleted.
+ * LayoutReloaded/LayoutTree/Box.js:
+ (Layout.Box):
+ (Layout.Box.prototype.establishedFormattingContext): Deleted.
+ * LayoutReloaded/misc/headers/Box.h:
+
2018-03-19 Chris Dumez <cdu...@apple.com>
Have one service worker process per security origin
Modified: trunk/Tools/LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js (229738 => 229739)
--- trunk/Tools/LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js 2018-03-20 03:26:15 UTC (rev 229738)
+++ trunk/Tools/LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js 2018-03-20 05:02:41 UTC (rev 229739)
@@ -23,13 +23,13 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
class BlockFormattingContext extends FormattingContext {
- constructor(root) {
- super(root);
+ constructor(root, layoutContext) {
+ super(root, layoutContext);
// New block formatting context always establishes a new floating context.
this.m_floatingContext = new FloatingContext(this);
}
- layout(layoutContext) {
+ layout() {
// 9.4.1 Block formatting contexts
// In a block formatting context, boxes are laid out one after the other, vertically, beginning at the top of a containing block.
// The vertical distance between two sibling boxes is determined by the 'margin' properties.
@@ -50,7 +50,7 @@
this.computeWidth(layoutBox);
this._computeStaticPosition(layoutBox);
if (layoutBox.establishesFormattingContext()) {
- layoutContext.layoutFormattingContext(layoutBox.establishedFormattingContext());
+ this.layoutContext().layout(layoutBox);
break;
}
if (!layoutBox.isContainer() || !layoutBox.hasInFlowOrFloatChild())
@@ -78,7 +78,7 @@
// Place the inflow positioned children.
this._placeInFlowPositionedChildren(this.rootContainer());
// And take care of out-of-flow boxes as the final step.
- this._layoutOutOfFlowDescendants(layoutContext);
+ this._layoutOutOfFlowDescendants();
}
computeWidth(layoutBox) {
@@ -134,7 +134,7 @@
}
}
- _layoutOutOfFlowDescendants(layoutContext) {
+ _layoutOutOfFlowDescendants() {
// This lays out all the out-of-flow boxes that belong to this formatting context even if
// the root container is not the containing block.
let outOfFlowDescendants = this._outOfFlowDescendants();
@@ -141,7 +141,7 @@
for (let outOfFlowBox of outOfFlowDescendants) {
this._addToLayoutQueue(outOfFlowBox);
this.computeWidth(outOfFlowBox);
- layoutContext.layoutFormattingContext(outOfFlowBox.establishedFormattingContext());
+ this.layoutContext().layout(outOfFlowBox);
this.computeHeight(outOfFlowBox);
this._computeOutOfFlowPosition(outOfFlowBox);
this._removeFromLayoutQueue(outOfFlowBox);
@@ -263,7 +263,6 @@
if (!layoutBox.isContainer() || !layoutBox.hasInFlowChild())
return 0;
if (layoutBox.establishesInlineFormattingContext()) {
- ASSERT(layoutBox.establishedFormattingContext());
let lines = layoutBox.establishedFormattingContext().lines();
if (!lines.length)
return 0;
Modified: trunk/Tools/LayoutReloaded/FormattingContext/FormattingContext.js (229738 => 229739)
--- trunk/Tools/LayoutReloaded/FormattingContext/FormattingContext.js 2018-03-20 03:26:15 UTC (rev 229738)
+++ trunk/Tools/LayoutReloaded/FormattingContext/FormattingContext.js 2018-03-20 05:02:41 UTC (rev 229739)
@@ -24,8 +24,9 @@
*/
class FormattingContext {
- constructor(rootContainer) {
+ constructor(rootContainer, layoutContext) {
this.m_rootContainer = rootContainer;
+ this.m_layoutContext = layoutContext;
this.m_floatingContext = null;
this.m_displayToLayout = new Map();
this.m_layoutToDisplay = new Map();
@@ -36,6 +37,10 @@
return this.m_rootContainer;
}
+ layoutContext() {
+ return this.m_layoutContext;
+ }
+
floatingContext() {
return this.m_floatingContext;
}
@@ -143,10 +148,7 @@
toDisplayBox(layoutBox) {
ASSERT(layoutBox);
- ASSERT(this.m_layoutToDisplay.has(layoutBox) || layoutBox.establishedFormattingContext() == this);
- if (layoutBox.establishedFormattingContext() == this)
- return layoutBox.displayBox();
- return this.m_layoutToDisplay.get(layoutBox);
+ return layoutBox.displayBox();
}
toLayoutBox(displayBox) {
@@ -182,7 +184,7 @@
if (containingBlock == this.rootContainer())
outOfFlowBoxes.push(outOfFlowBox);
else if (containingBlock.isDescendantOf(this.rootContainer())) {
- if (!containingBlock.establishedFormattingContext() || !containingBlock.isPositioned())
+ if (!containingBlock.establishesFormattingContext() || !containingBlock.isPositioned())
outOfFlowBoxes.push(outOfFlowBox);
}
}
Modified: trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js (229738 => 229739)
--- trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js 2018-03-20 03:26:15 UTC (rev 229738)
+++ trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js 2018-03-20 05:02:41 UTC (rev 229739)
@@ -24,8 +24,8 @@
*/
class InlineFormattingContext extends FormattingContext {
- constructor(root) {
- super(root);
+ constructor(root, layoutContext) {
+ super(root, layoutContext);
// If the block container box that initiates this inline formatting contex also establishes a block context, create a new float for us.
ASSERT(root.isBlockContainerBox());
if (root.establishesBlockFormattingContext())
@@ -39,7 +39,7 @@
return this.m_lines;
}
- layout(layoutContext) {
+ layout() {
// 9.4.2 Inline formatting contexts
// In an inline formatting context, boxes are laid out horizontally, one after the other, beginning at the top of a containing block.
if (!this.rootContainer().firstChild())
@@ -52,7 +52,7 @@
while (true) {
let layoutBox = this._nextInLayoutQueue();
if (layoutBox.establishesFormattingContext()) {
- layoutContext.layoutFormattingContext(layoutBox.establishedFormattingContext());
+ this.layoutContext().layout(layoutBox);
break;
}
if (!layoutBox.isContainer() || !layoutBox.hasChild())
Modified: trunk/Tools/LayoutReloaded/Layout.js (229738 => 229739)
--- trunk/Tools/LayoutReloaded/Layout.js 2018-03-20 03:26:15 UTC (rev 229738)
+++ trunk/Tools/LayoutReloaded/Layout.js 2018-03-20 05:02:41 UTC (rev 229739)
@@ -31,6 +31,6 @@
initialContainingBlock.setDisplayBox(displayBox);
let layoutContext = new LayoutContext(initialContainingBlock);
- layoutContext.layoutFormattingContext(initialContainingBlock.establishedFormattingContext());
+ layoutContext.layout(initialContainingBlock);
return Utils.layoutTreeDump(initialContainingBlock);
}
Modified: trunk/Tools/LayoutReloaded/LayoutContext.js (229738 => 229739)
--- trunk/Tools/LayoutReloaded/LayoutContext.js 2018-03-20 03:26:15 UTC (rev 229738)
+++ trunk/Tools/LayoutReloaded/LayoutContext.js 2018-03-20 05:02:41 UTC (rev 229739)
@@ -27,7 +27,18 @@
constructor() {
}
- layoutFormattingContext(formattingContext) {
- formattingContext.layout(this);
+ layout(formattingRoot) {
+ let formattingContext = this._createFormattingContext(formattingRoot);
+ formattingContext.layout();
}
+
+ _createFormattingContext(formattingRoot) {
+ ASSERT(formattingRoot.establishesFormattingContext());
+ if (formattingRoot.establishesBlockFormattingContext())
+ return new BlockFormattingContext(formattingRoot, this);
+ if (formattingRoot.establishesInlineFormattingContext())
+ return new InlineFormattingContext(formattingRoot, this);
+ ASSERT_NOT_REACHED();
+ return null;
+ }
}
Modified: trunk/Tools/LayoutReloaded/LayoutTree/Box.js (229738 => 229739)
--- trunk/Tools/LayoutReloaded/LayoutTree/Box.js 2018-03-20 03:26:15 UTC (rev 229738)
+++ trunk/Tools/LayoutReloaded/LayoutTree/Box.js 2018-03-20 05:02:41 UTC (rev 229739)
@@ -34,7 +34,6 @@
this.m_nextSibling = null;
this.m_previousSibling = null;
this.m_isAnonymous = false;
- this.m_establishedFormattingContext = null;
this.m_displayBox = null;
}
@@ -148,12 +147,6 @@
return this.establishesBlockFormattingContext() || this.establishesInlineFormattingContext();
}
- establishedFormattingContext() {
- if (this.establishesFormattingContext() && !this.m_establishedFormattingContext)
- this.m_establishedFormattingContext = this.establishesBlockFormattingContext() ? new BlockFormattingContext(this) : new InlineFormattingContext(this);
- return this.m_establishedFormattingContext;
- }
-
establishesBlockFormattingContext() {
// 9.4.1 Block formatting contexts
// Floats, absolutely positioned elements, block containers (such as inline-blocks, table-cells, and table-captions)
Modified: trunk/Tools/LayoutReloaded/misc/headers/Box.h (229738 => 229739)
--- trunk/Tools/LayoutReloaded/misc/headers/Box.h 2018-03-20 03:26:15 UTC (rev 229738)
+++ trunk/Tools/LayoutReloaded/misc/headers/Box.h 2018-03-20 05:02:41 UTC (rev 229739)
@@ -64,8 +64,6 @@
bool establishesFormattingContext() const;
bool establishesBlockFormattingContext() const;
- FormattingContext* establishedFormattingContext();
-
bool isInFlow() const;
bool isPositioned() const;
bool isRelativelyPositioned() const;
@@ -91,7 +89,6 @@
Box* m_previousSibling { nullptr };
bool m_isAnonymous { false };
LayoutRect m_rect;
- FormattingContext* m_establishedFormattingContext { nullptr };
};
}