Changeset 229739 in webkit
- Timestamp:
- Mar 19, 2018 10:02:41 PM (6 years ago)
- Location:
- trunk/Tools
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r229735 r229739 1 2018-03-19 Zalan Bujtas <zalan@apple.com> 2 3 [LayoutReloaded] Layout.Box should not create the formatting context. 4 https://bugs.webkit.org/show_bug.cgi?id=183766 5 6 Reviewed by Antti Koivisto. 7 8 Since the formattingContext's lifetime is tied to the layout, the LayoutContext 9 should construct it instead. 10 11 * LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js: 12 (BlockFormattingContext): 13 (BlockFormattingContext.prototype.layout): 14 (BlockFormattingContext.prototype._layoutOutOfFlowDescendants): 15 (BlockFormattingContext.prototype._contentHeight): 16 * LayoutReloaded/FormattingContext/FormattingContext.js: 17 (FormattingContext): 18 (FormattingContext.prototype.layoutContext): 19 (FormattingContext.prototype.toDisplayBox): 20 (FormattingContext.prototype._outOfFlowDescendants): 21 * LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js: 22 (InlineFormattingContext): 23 (InlineFormattingContext.prototype.layout): 24 * LayoutReloaded/Layout.js: 25 (layout): 26 * LayoutReloaded/LayoutContext.js: 27 (LayoutContext.prototype.layout): 28 (LayoutContext.prototype._createFormattingContext): 29 (LayoutContext): 30 (LayoutContext.prototype.layoutFormattingContext): Deleted. 31 * LayoutReloaded/LayoutTree/Box.js: 32 (Layout.Box): 33 (Layout.Box.prototype.establishedFormattingContext): Deleted. 34 * LayoutReloaded/misc/headers/Box.h: 35 1 36 2018-03-19 Chris Dumez <cdumez@apple.com> 2 37 -
trunk/Tools/LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js
r229734 r229739 24 24 */ 25 25 class BlockFormattingContext extends FormattingContext { 26 constructor(root ) {27 super(root );26 constructor(root, layoutContext) { 27 super(root, layoutContext); 28 28 // New block formatting context always establishes a new floating context. 29 29 this.m_floatingContext = new FloatingContext(this); 30 30 } 31 31 32 layout( layoutContext) {32 layout() { 33 33 // 9.4.1 Block formatting contexts 34 34 // In a block formatting context, boxes are laid out one after the other, vertically, beginning at the top of a containing block. … … 51 51 this._computeStaticPosition(layoutBox); 52 52 if (layoutBox.establishesFormattingContext()) { 53 layoutContext.layoutFormattingContext(layoutBox.establishedFormattingContext());53 this.layoutContext().layout(layoutBox); 54 54 break; 55 55 } … … 79 79 this._placeInFlowPositionedChildren(this.rootContainer()); 80 80 // And take care of out-of-flow boxes as the final step. 81 this._layoutOutOfFlowDescendants( layoutContext);81 this._layoutOutOfFlowDescendants(); 82 82 } 83 83 … … 135 135 } 136 136 137 _layoutOutOfFlowDescendants( layoutContext) {137 _layoutOutOfFlowDescendants() { 138 138 // This lays out all the out-of-flow boxes that belong to this formatting context even if 139 139 // the root container is not the containing block. … … 142 142 this._addToLayoutQueue(outOfFlowBox); 143 143 this.computeWidth(outOfFlowBox); 144 layoutContext.layoutFormattingContext(outOfFlowBox.establishedFormattingContext());144 this.layoutContext().layout(outOfFlowBox); 145 145 this.computeHeight(outOfFlowBox); 146 146 this._computeOutOfFlowPosition(outOfFlowBox); … … 264 264 return 0; 265 265 if (layoutBox.establishesInlineFormattingContext()) { 266 ASSERT(layoutBox.establishedFormattingContext());267 266 let lines = layoutBox.establishedFormattingContext().lines(); 268 267 if (!lines.length) -
trunk/Tools/LayoutReloaded/FormattingContext/FormattingContext.js
r229734 r229739 25 25 26 26 class FormattingContext { 27 constructor(rootContainer ) {27 constructor(rootContainer, layoutContext) { 28 28 this.m_rootContainer = rootContainer; 29 this.m_layoutContext = layoutContext; 29 30 this.m_floatingContext = null; 30 31 this.m_displayToLayout = new Map(); … … 35 36 rootContainer() { 36 37 return this.m_rootContainer; 38 } 39 40 layoutContext() { 41 return this.m_layoutContext; 37 42 } 38 43 … … 144 149 toDisplayBox(layoutBox) { 145 150 ASSERT(layoutBox); 146 ASSERT(this.m_layoutToDisplay.has(layoutBox) || layoutBox.establishedFormattingContext() == this); 147 if (layoutBox.establishedFormattingContext() == this) 148 return layoutBox.displayBox(); 149 return this.m_layoutToDisplay.get(layoutBox); 151 return layoutBox.displayBox(); 150 152 } 151 153 … … 183 185 outOfFlowBoxes.push(outOfFlowBox); 184 186 else if (containingBlock.isDescendantOf(this.rootContainer())) { 185 if (!containingBlock.establishe dFormattingContext() || !containingBlock.isPositioned())187 if (!containingBlock.establishesFormattingContext() || !containingBlock.isPositioned()) 186 188 outOfFlowBoxes.push(outOfFlowBox); 187 189 } -
trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js
r229692 r229739 25 25 26 26 class InlineFormattingContext extends FormattingContext { 27 constructor(root ) {28 super(root );27 constructor(root, layoutContext) { 28 super(root, layoutContext); 29 29 // If the block container box that initiates this inline formatting contex also establishes a block context, create a new float for us. 30 30 ASSERT(root.isBlockContainerBox()); … … 40 40 } 41 41 42 layout( layoutContext) {42 layout() { 43 43 // 9.4.2 Inline formatting contexts 44 44 // In an inline formatting context, boxes are laid out horizontally, one after the other, beginning at the top of a containing block. … … 53 53 let layoutBox = this._nextInLayoutQueue(); 54 54 if (layoutBox.establishesFormattingContext()) { 55 layoutContext.layoutFormattingContext(layoutBox.establishedFormattingContext());55 this.layoutContext().layout(layoutBox); 56 56 break; 57 57 } -
trunk/Tools/LayoutReloaded/Layout.js
r229702 r229739 32 32 33 33 let layoutContext = new LayoutContext(initialContainingBlock); 34 layoutContext.layout FormattingContext(initialContainingBlock.establishedFormattingContext());34 layoutContext.layout(initialContainingBlock); 35 35 return Utils.layoutTreeDump(initialContainingBlock); 36 36 } -
trunk/Tools/LayoutReloaded/LayoutContext.js
r229473 r229739 28 28 } 29 29 30 layoutFormattingContext(formattingContext) { 31 formattingContext.layout(this); 30 layout(formattingRoot) { 31 let formattingContext = this._createFormattingContext(formattingRoot); 32 formattingContext.layout(); 33 } 34 35 _createFormattingContext(formattingRoot) { 36 ASSERT(formattingRoot.establishesFormattingContext()); 37 if (formattingRoot.establishesBlockFormattingContext()) 38 return new BlockFormattingContext(formattingRoot, this); 39 if (formattingRoot.establishesInlineFormattingContext()) 40 return new InlineFormattingContext(formattingRoot, this); 41 ASSERT_NOT_REACHED(); 42 return null; 32 43 } 33 44 } -
trunk/Tools/LayoutReloaded/LayoutTree/Box.js
r229734 r229739 35 35 this.m_previousSibling = null; 36 36 this.m_isAnonymous = false; 37 this.m_establishedFormattingContext = null;38 37 this.m_displayBox = null; 39 38 } … … 147 146 return false; 148 147 return this.establishesBlockFormattingContext() || this.establishesInlineFormattingContext(); 149 }150 151 establishedFormattingContext() {152 if (this.establishesFormattingContext() && !this.m_establishedFormattingContext)153 this.m_establishedFormattingContext = this.establishesBlockFormattingContext() ? new BlockFormattingContext(this) : new InlineFormattingContext(this);154 return this.m_establishedFormattingContext;155 148 } 156 149 -
trunk/Tools/LayoutReloaded/misc/headers/Box.h
r229696 r229739 65 65 bool establishesBlockFormattingContext() const; 66 66 67 FormattingContext* establishedFormattingContext();68 69 67 bool isInFlow() const; 70 68 bool isPositioned() const; … … 92 90 bool m_isAnonymous { false }; 93 91 LayoutRect m_rect; 94 FormattingContext* m_establishedFormattingContext { nullptr };95 92 }; 96 93
Note: See TracChangeset
for help on using the changeset viewer.