Changeset 229758 in webkit
- Timestamp:
- Mar 20, 2018, 9:14:28 AM (7 years ago)
- Location:
- trunk/Tools
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r229746 r229758 1 2018-03-20 Zalan Bujtas <zalan@apple.com> 2 3 [LayoutReloaded] Move Display.Box handling from FormattingContext to FormattingState 4 https://bugs.webkit.org/show_bug.cgi?id=183779 5 6 Reviewed by Antti Koivisto. 7 8 * LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js: 9 (BlockFormattingContext.prototype._computeStaticPosition): 10 (BlockFormattingContext.prototype._computeOutOfFlowWidth): 11 (BlockFormattingContext.prototype._computeFloatingWidth): 12 (BlockFormattingContext.prototype._computeInFlowWidth): 13 (BlockFormattingContext.prototype._computeOutOfFlowHeight): 14 (BlockFormattingContext.prototype._computeFloatingHeight): 15 (BlockFormattingContext.prototype._computeInFlowHeight): 16 (BlockFormattingContext.prototype._horizontalConstraint): 17 (BlockFormattingContext.prototype._contentHeight): 18 (BlockFormattingContext.prototype._adjustBottomWithFIXME): 19 (BlockFormattingContext.prototype._computeInFlowPositionedPosition): 20 (BlockFormattingContext.prototype._computeOutOfFlowPosition): 21 * LayoutReloaded/FormattingContext/FloatingContext.js: 22 (FloatingContext.prototype.computePosition): 23 (FloatingContext.prototype._positionForClear): 24 (FloatingContext.prototype._computePositionToAvoidIntrudingFloats): 25 (FloatingContext.prototype._availableSpace): 26 (FloatingContext.prototype._adjustedFloatingPosition): 27 * LayoutReloaded/FormattingContext/FormattingContext.js: 28 (FormattingContext): 29 (FormattingContext.prototype.absoluteMarginBox): 30 (FormattingContext.prototype.absoluteBorderBox): 31 (FormattingContext.prototype.absolutePaddingBox): 32 (FormattingContext.prototype.absoluteContentBox): 33 (FormattingContext.prototype._toAbsolutePosition): 34 (FormattingContext.prototype._toRootAbsolutePosition): 35 (FormattingContext.prototype._addToLayoutQueue): 36 (FormattingContext.prototype.displayBox): 37 (FormattingContext.prototype._createDisplayBox): Deleted. 38 (FormattingContext.prototype.toDisplayBox): Deleted. 39 (FormattingContext.prototype.toLayoutBox): Deleted. 40 * LayoutReloaded/FormattingState/FormattingState.js: 41 (FormattingState): 42 (FormattingState.prototype.createDisplayBox): 43 (FormattingState.prototype.displayBox): 44 1 45 2018-03-20 Zalan Bujtas <zalan@apple.com> 2 46 -
trunk/Tools/LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js
r229746 r229758 110 110 // The vertical distance between two sibling boxes is determined by the 'margin' properties. 111 111 // Vertical margins between adjacent block-level boxes in a block formatting context collapse. 112 let containingBlockContentBox = this. toDisplayBox(layoutBox.containingBlock()).contentBox();112 let containingBlockContentBox = this.displayBox(layoutBox.containingBlock()).contentBox(); 113 113 // Start from the top of the container's content box. 114 114 let previousInFlowSibling = layoutBox.previousInFlowSibling(); 115 115 let contentBottom = containingBlockContentBox.top() 116 116 if (previousInFlowSibling) 117 contentBottom = this. toDisplayBox(previousInFlowSibling).bottom() + this.marginBottom(previousInFlowSibling);117 contentBottom = this.displayBox(previousInFlowSibling).bottom() + this.marginBottom(previousInFlowSibling); 118 118 let position = new LayoutPoint(contentBottom, containingBlockContentBox.left()); 119 119 position.moveBy(new LayoutSize(this.marginLeft(layoutBox), this.marginTop(layoutBox))); 120 this. toDisplayBox(layoutBox).setTopLeft(position);120 this.displayBox(layoutBox).setTopLeft(position); 121 121 } 122 122 … … 172 172 width = Utils.width(layoutBox); // 4 173 173 else if (Utils.isWidthAuto(layoutBox) && !Utils.isLeftAuto(layoutBox) && !Utils.isRightAuto(layoutBox)) 174 width = Math.max(0, this. toDisplayBox(layoutBox.containingBlock()).contentBox().width() - Utils.right(layoutBox) - Utils.left(layoutBox)); // 5174 width = Math.max(0, this.displayBox(layoutBox.containingBlock()).contentBox().width() - Utils.right(layoutBox) - Utils.left(layoutBox)); // 5 175 175 else if (Utils.isRightAuto(layoutBox) && !Utils.isLeftAuto(layoutBox) && !Utils.isWidthAuto(layoutBox)) 176 176 width = Utils.width(layoutBox); // 6 … … 178 178 ASSERT_NOT_REACHED(); 179 179 width += Utils.computedHorizontalBorderAndPadding(layoutBox.node()); 180 this. toDisplayBox(layoutBox).setWidth(width);180 this.displayBox(layoutBox).setWidth(width); 181 181 } 182 182 183 183 _computeFloatingWidth(layoutBox) { 184 184 // FIXME: missing cases 185 this. toDisplayBox(layoutBox).setWidth(Utils.width(layoutBox) + Utils.computedHorizontalBorderAndPadding(layoutBox.node()));185 this.displayBox(layoutBox).setWidth(Utils.width(layoutBox) + Utils.computedHorizontalBorderAndPadding(layoutBox.node())); 186 186 } 187 187 188 188 _computeInFlowWidth(layoutBox) { 189 189 if (Utils.isWidthAuto(layoutBox)) 190 return this. toDisplayBox(layoutBox).setWidth(this._horizontalConstraint(layoutBox));191 return this. toDisplayBox(layoutBox).setWidth(Utils.width(layoutBox) + Utils.computedHorizontalBorderAndPadding(layoutBox.node()));190 return this.displayBox(layoutBox).setWidth(this._horizontalConstraint(layoutBox)); 191 return this.displayBox(layoutBox).setWidth(Utils.width(layoutBox) + Utils.computedHorizontalBorderAndPadding(layoutBox.node())); 192 192 } 193 193 … … 220 220 height = Utils.height(layoutBox); // 6 221 221 else if (Utils.isHeightAuto((layoutBox)) && !Utils.isTopAuto((layoutBox)) && !Utils.isBottomAuto((layoutBox))) 222 height = Math.max(0, this. toDisplayBox(layoutBox.containingBlock()).contentBox().height() - Utils.bottom(layoutBox) - Utils.top(layoutBox)); // 7222 height = Math.max(0, this.displayBox(layoutBox.containingBlock()).contentBox().height() - Utils.bottom(layoutBox) - Utils.top(layoutBox)); // 7 223 223 else if (Utils.isBottomAuto((layoutBox)) && !Utils.isTopAuto((layoutBox)) && !Utils.isHeightAuto((layoutBox))) 224 224 height = Utils.height(layoutBox); // 8 … … 226 226 ASSERT_NOT_REACHED(); 227 227 height += Utils.computedVerticalBorderAndPadding(layoutBox.node()); 228 this. toDisplayBox(layoutBox).setHeight(height);228 this.displayBox(layoutBox).setHeight(height); 229 229 } 230 230 231 231 _computeFloatingHeight(layoutBox) { 232 232 // FIXME: missing cases 233 this. toDisplayBox(layoutBox).setHeight(Utils.height(layoutBox) + Utils.computedVerticalBorderAndPadding(layoutBox.node()));233 this.displayBox(layoutBox).setHeight(Utils.height(layoutBox) + Utils.computedVerticalBorderAndPadding(layoutBox.node())); 234 234 } 235 235 … … 241 241 // The element's height is the distance from its top content edge to the first applicable of the following: 242 242 // 1. the bottom edge of the last line box, if the box establishes a inline formatting context with one or more lines 243 return this. toDisplayBox(layoutBox).setHeight(this._contentHeight(layoutBox) + Utils.computedVerticalBorderAndPadding(layoutBox.node()));244 } 245 return this. toDisplayBox(layoutBox).setHeight(Utils.height(layoutBox) + Utils.computedVerticalBorderAndPadding(layoutBox.node()));243 return this.displayBox(layoutBox).setHeight(this._contentHeight(layoutBox) + Utils.computedVerticalBorderAndPadding(layoutBox.node())); 244 } 245 return this.displayBox(layoutBox).setHeight(Utils.height(layoutBox) + Utils.computedVerticalBorderAndPadding(layoutBox.node())); 246 246 } 247 247 248 248 _horizontalConstraint(layoutBox) { 249 let horizontalConstraint = this. toDisplayBox(layoutBox.containingBlock()).contentBox().width();249 let horizontalConstraint = this.displayBox(layoutBox.containingBlock()).contentBox().width(); 250 250 horizontalConstraint -= this.marginLeft(layoutBox) + this.marginRight(layoutBox); 251 251 return horizontalConstraint; … … 270 270 return lastLine.rect().bottom(); 271 271 } 272 let top = this. toDisplayBox(layoutBox).contentBox().top();272 let top = this.displayBox(layoutBox).contentBox().top(); 273 273 let bottom = this._adjustBottomWithFIXME(layoutBox); 274 274 return bottom - top; … … 281 281 let bottom = lastInFlowDisplayBox.bottom() + this.marginBottom(lastInFlowChild); 282 282 // FIXME: margin for body 283 if (lastInFlowChild.name() == "RenderBody" && Utils.isHeightAuto(lastInFlowChild) && !this. toDisplayBox(lastInFlowChild).contentBox().height())283 if (lastInFlowChild.name() == "RenderBody" && Utils.isHeightAuto(lastInFlowChild) && !this.displayBox(lastInFlowChild).contentBox().height()) 284 284 bottom -= this.marginBottom(lastInFlowChild); 285 285 // FIXME: figure out why floatings part of the initial block formatting context get propagated to HTML … … 294 294 _computeInFlowPositionedPosition(layoutBox) { 295 295 // Start with the original, static position. 296 let displayBox = this. toDisplayBox(layoutBox);296 let displayBox = this.displayBox(layoutBox); 297 297 let relativePosition = displayBox.topLeft(); 298 298 // Top/bottom … … 310 310 311 311 _computeOutOfFlowPosition(layoutBox) { 312 let displayBox = this. toDisplayBox(layoutBox);312 let displayBox = this.displayBox(layoutBox); 313 313 let top = Number.NaN; 314 let containerSize = this. toDisplayBox(layoutBox.containingBlock()).contentBox().size();314 let containerSize = this.displayBox(layoutBox.containingBlock()).contentBox().size(); 315 315 // Top/bottom 316 316 if (Utils.isTopAuto(layoutBox) && Utils.isBottomAuto(layoutBox)) { -
trunk/Tools/LayoutReloaded/FormattingContext/FloatingContext.js
r229734 r229758 35 35 if (layoutBox.isOutOfFlowPositioned()) 36 36 return; 37 let displayBox = this._formattingContext(). toDisplayBox(layoutBox);37 let displayBox = this._formattingContext().displayBox(layoutBox); 38 38 if (layoutBox.isFloatingPositioned()) { 39 39 let position = this._positionForFloating(layoutBox); … … 75 75 _positionForClear(layoutBox) { 76 76 ASSERT(Utils.hasClear(layoutBox)); 77 let displayBox = this._formattingContext(). toDisplayBox(layoutBox);77 let displayBox = this._formattingContext().displayBox(layoutBox); 78 78 if (this._isEmpty()) 79 79 return displayBox.topLeft(); … … 97 97 _computePositionToAvoidIntrudingFloats(layoutBox) { 98 98 if (!layoutBox.establishesBlockFormattingContext() || this._isEmpty()) 99 return this._formattingContext(). toDisplayBox(layoutBox).topLeft();99 return this._formattingContext().displayBox(layoutBox).topLeft(); 100 100 // The border box of a table, a block-level replaced element, or an element in the normal flow that establishes 101 101 // a new block formatting context (such as an element with 'overflow' other than 'visible') must not overlap the … … 133 133 134 134 _availableSpace(containingBlock, floatingPair) { 135 let containingBlockContentBox = this._formattingContext(). toDisplayBox(containingBlock);135 let containingBlockContentBox = this._formattingContext().displayBox(containingBlock); 136 136 if (floatingPair.left && floatingPair.right) 137 137 return this._formattingContext().absoluteMarginBox(floatingPair.right).left() - this._formattingContext().absoluteMarginBox(floatingPair.left).right(); … … 183 183 if (Utils.isFloatingLeft(floatingBox) || !Utils.isFloatingPositioned(floatingBox)) 184 184 return new LayoutPoint(verticalPosition, left); 185 return new LayoutPoint(verticalPosition, right - this._formattingContext(). toDisplayBox(floatingBox).rect().width());185 return new LayoutPoint(verticalPosition, right - this._formattingContext().displayBox(floatingBox).rect().width()); 186 186 } 187 187 -
trunk/Tools/LayoutReloaded/FormattingContext/FormattingContext.js
r229746 r229758 29 29 this.m_layoutState = layoutState; 30 30 this.m_floatingContext = null; 31 this.m_displayToLayout = new Map();32 this.m_layoutToDisplay = new Map();33 31 this.m_layoutStack = new Array(); 34 32 } … … 77 75 78 76 absoluteMarginBox(layoutBox) { 79 let displayBox = this. toDisplayBox(layoutBox);77 let displayBox = this.displayBox(layoutBox); 80 78 let absoluteContentBox = new LayoutRect(this._toRootAbsolutePosition(layoutBox), displayBox.size()); 81 79 absoluteContentBox.moveBy(new LayoutSize(-this.marginLeft(layoutBox), -this.marginTop(layoutBox))); … … 85 83 86 84 absoluteBorderBox(layoutBox) { 87 let borderBox = this. toDisplayBox(layoutBox).borderBox();85 let borderBox = this.displayBox(layoutBox).borderBox(); 88 86 let absoluteRect = new LayoutRect(this._toRootAbsolutePosition(layoutBox), borderBox.size()); 89 87 absoluteRect.moveBy(borderBox.topLeft()); … … 92 90 93 91 absolutePaddingBox(layoutBox) { 94 let paddingBox = this. toDisplayBox(layoutBox).paddingBox();92 let paddingBox = this.displayBox(layoutBox).paddingBox(); 95 93 let absoluteRect = new LayoutRect(this._toRootAbsolutePosition(layoutBox), paddingBox.size()); 96 94 absoluteRect.moveBy(paddingBox.topLeft()); … … 99 97 100 98 absoluteContentBox(layoutBox) { 101 let contentBox = this. toDisplayBox(layoutBox).contentBox();99 let contentBox = this.displayBox(layoutBox).contentBox(); 102 100 let absoluteRect = new LayoutRect(this._toRootAbsolutePosition(layoutBox), contentBox.size()); 103 101 absoluteRect.moveBy(contentBox.topLeft()); … … 112 110 while (ascendant && ascendant != container) { 113 111 ASSERT(ascendant.isDescendantOf(this.rootContainer())); 114 absolutePosition.moveBy(this. toDisplayBox(ascendant).topLeft());112 absolutePosition.moveBy(this.displayBox(ascendant).topLeft()); 115 113 ascendant = ascendant.containingBlock(); 116 114 } … … 119 117 120 118 _toRootAbsolutePosition(layoutBox) { 121 return this._toAbsolutePosition(this. toDisplayBox(layoutBox).topLeft(), layoutBox, this.rootContainer());119 return this._toAbsolutePosition(this.displayBox(layoutBox).topLeft(), layoutBox, this.rootContainer()); 122 120 } 123 121 … … 128 126 _addToLayoutQueue(layoutBox) { 129 127 // Initialize the corresponding display box. 130 this. _createDisplayBox(layoutBox);128 this.layoutState().createDisplayBox(layoutBox); 131 129 this.m_layoutStack.push(layoutBox); 132 130 } … … 144 142 } 145 143 146 _createDisplayBox(layoutBox) { 147 let displayBox = new Display.Box(layoutBox.node()); 148 this.m_displayToLayout.set(displayBox, layoutBox); 149 this.m_layoutToDisplay.set(layoutBox, displayBox); 150 // This is temporary. 151 layoutBox.setDisplayBox(displayBox); 152 } 153 154 toDisplayBox(layoutBox) { 155 ASSERT(layoutBox); 156 return layoutBox.displayBox(); 157 } 158 159 toLayoutBox(displayBox) { 160 ASSERT(displayBox); 161 ASSERT(this.m_displayToLayout.has(displayBox)); 162 return this.m_displayToLayout.get(displayBox); 144 displayBox(layoutBox) { 145 return this.layoutState().displayBox(layoutBox); 163 146 } 164 147 -
trunk/Tools/LayoutReloaded/FormattingState/FormattingState.js
r229746 r229758 28 28 this.m_layoutContext = layoutContext; 29 29 this.m_formattingContext = null; 30 this.m_displayToLayout = new Map(); 30 31 } 31 32 … … 38 39 } 39 40 41 createDisplayBox(layoutBox) { 42 let displayBox = new Display.Box(layoutBox.node()); 43 this.m_displayToLayout.set(layoutBox, displayBox); 44 // This is temporary. 45 layoutBox.setDisplayBox(displayBox); 46 } 47 48 displayBox(layoutBox) { 49 ASSERT(layoutBox); 50 return layoutBox.displayBox(); 51 } 52 40 53 _setFormattingContext(formattingContext) { 41 54 this.m_formattingContext = formattingContext;
Note:
See TracChangeset
for help on using the changeset viewer.