Changeset 230464 in webkit
- Timestamp:
- Apr 9, 2018 6:53:00 PM (6 years ago)
- Location:
- trunk/Tools
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r230462 r230464 1 2018-04-09 Zalan Bujtas <zalan@apple.com> 2 3 [LayoutReloaded] Add support for inline-block. 4 https://bugs.webkit.org/show_bug.cgi?id=184434 5 6 Reviewed by Antti Koivisto. 7 8 * LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js: 9 (InlineFormattingContext): 10 (InlineFormattingContext.prototype.layout): 11 (InlineFormattingContext.prototype._handleInlineContainer): 12 (InlineFormattingContext.prototype._handleInlineBlockContainer): 13 (InlineFormattingContext.prototype._handleInlineContent): 14 * LayoutReloaded/FormattingContext/InlineFormatting/Line.js: 15 (Line.prototype.addInlineContainerBox): 16 (Line.prototype.addTextLineBox): 17 (Line): 18 * LayoutReloaded/LayoutTree/Box.js: 19 (Layout.Box.prototype.isInlineBlockBox): 20 * LayoutReloaded/Utils.js: 21 (LayoutRect.prototype.growHorizontally): 22 (Utils.isBlockContainerElement): 23 (Utils.isInlineBlockElement): 24 (Utils._dumpLines.): 25 (Utils._dumpLines): 26 * LayoutReloaded/test/index.html: 27 * LayoutReloaded/test/inline-block-with-fixed-width-height.html: Added. 28 1 29 2018-04-09 Timothy Hatcher <timothy@apple.com> 2 30 -
trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js
r230386 r230464 28 28 super(inlineFormattingState); 29 29 ASSERT(this.formattingRoot().isBlockContainerBox()); 30 this.m_inlineContainerStack = new Array(); 30 31 } 31 32 … … 40 41 while (this._descendantNeedsLayout()) { 41 42 let layoutBox = this._nextInLayoutQueue(); 42 if (layoutBox.isInlineContainer()) { 43 if (inlineContainerStack.indexOf(layoutBox) == -1) { 44 inlineContainerStack.push(layoutBox); 45 this._adjustLineForInlineContainerStart(layoutBox); 46 if (layoutBox.establishesFormattingContext()) 47 this.layoutState().layout(layoutBox); 48 else 49 this._addToLayoutQueue(layoutBox.firstInFlowOrFloatChild()); 50 } else { 51 inlineContainerStack.pop(layoutBox); 52 this._adjustLineForInlineContainerEnd(layoutBox); 53 this._removeFromLayoutQueue(layoutBox); 54 this._addToLayoutQueue(layoutBox.nextInFlowOrFloatSibling()); 55 // Place the inflow positioned children. 56 this._placeInFlowPositionedChildren(this.formattingRoot()); 57 } 58 continue; 59 } 60 this._handleInlineContent(layoutBox); 61 this._removeFromLayoutQueue(layoutBox); 62 this._addToLayoutQueue(layoutBox.nextInFlowOrFloatSibling()); 43 if (layoutBox.isInlineContainer()) 44 this._handleInlineContainer(layoutBox); 45 else if (layoutBox.isInlineBlockBox()) 46 this._handleInlineBlockContainer(layoutBox); 47 else 48 this._handleInlineContent(layoutBox); 63 49 } 64 50 // Place the inflow positioned children. … … 67 53 this._placeOutOfFlowDescendants(this.formattingRoot()); 68 54 this._commitLine(); 55 ASSERT(!this.m_inlineContainerStack.length); 69 56 } 70 57 58 _handleInlineContainer(inlineContainer) { 59 ASSERT(!inlineContainer.establishesFormattingContext()); 60 let inlineContainerStart = this.m_inlineContainerStack.indexOf(inlineContainer) == -1; 61 if (inlineContainerStart) { 62 this.m_inlineContainerStack.push(inlineContainer); 63 this._adjustLineForInlineContainerStart(inlineContainer); 64 this._addToLayoutQueue(inlineContainer.firstInFlowOrFloatChild()); 65 // Keep the inline container in the layout stack so that we can finish it when all the descendants are all set. 66 return; 67 } 68 this.m_inlineContainerStack.pop(inlineContainer); 69 this._adjustLineForInlineContainerEnd(inlineContainer); 70 this._removeFromLayoutQueue(inlineContainer); 71 this._addToLayoutQueue(inlineContainer.nextInFlowOrFloatSibling()); 72 // Place the in- and out-of-flow positioned children. 73 this._placeInFlowPositionedChildren(inlineContainer); 74 this._placeOutOfFlowDescendants(inlineContainer); 75 } 76 77 78 _handleInlineBlockContainer(inlineBlockContainer) { 79 ASSERT(inlineBlockContainer.establishesFormattingContext()); 80 this._adjustLineForInlineContainerStart(inlineBlockContainer); 81 // TODO: auto width/height 82 let displayBox = this.displayBox(inlineBlockContainer); 83 displayBox.setWidth(Utils.width(inlineBlockContainer) + Utils.computedHorizontalBorderAndPadding(inlineBlockContainer.node())); 84 displayBox.setHeight(Utils.height(inlineBlockContainer) + Utils.computedVerticalBorderAndPadding(inlineBlockContainer.node())); 85 this.layoutState().layout(inlineBlockContainer); 86 this._line().addInlineContainerBox(displayBox.size()); 87 this._adjustLineForInlineContainerEnd(inlineBlockContainer); 88 this._removeFromLayoutQueue(inlineBlockContainer); 89 this._addToLayoutQueue(inlineBlockContainer.nextInFlowOrFloatSibling()); 90 } 91 71 92 _handleInlineContent(layoutBox) { 72 if (layoutBox.isInlineBox()) {93 if (layoutBox.isInlineBox()) 73 94 this._handleInlineBox(layoutBox); 74 return; 75 } 76 if (layoutBox.isFloatingPositioned()) { 95 else if (layoutBox.isFloatingPositioned()) 77 96 this._handleFloatingBox(layoutBox); 78 return; 79 } 80 ASSERT_NOT_REACHED(); 97 else 98 ASSERT_NOT_REACHED(); 99 this._removeFromLayoutQueue(layoutBox); 100 this._addToLayoutQueue(layoutBox.nextInFlowOrFloatSibling()); 81 101 } 82 102 -
trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/Line.js
r230386 r230464 63 63 } 64 64 65 addInlineContainerBox(size) { 66 let width = size.width(); 67 ASSERT(width <= this.m_availableWidth); 68 this.shrink(width); 69 let lineBoxRect = new LayoutRect(this.rect().topRight(), size); 70 this.m_lineBoxes.push({lineBoxRect}); 71 this.m_lineRect.growHorizontally(width); 72 } 73 65 74 addTextLineBox(startPosition, endPosition, size) { 66 ASSERT(size.width() <= this.m_availableWidth); 67 this.m_availableWidth -= size.width(); 75 let width = size.width(); 76 ASSERT(width <= this.m_availableWidth); 77 this.shrink(width); 68 78 // TODO: use the actual height instead of the line height. 69 let lineBoxRect = new LayoutRect(this.rect().topRight(), new LayoutSize( size.width(), this.rect().height()));79 let lineBoxRect = new LayoutRect(this.rect().topRight(), new LayoutSize(width, this.rect().height())); 70 80 this.m_lineBoxes.push({startPosition, endPosition, lineBoxRect}); 71 this.m_lineRect.grow By(new LayoutSize(size.width(), 0));81 this.m_lineRect.growHorizontally(width); 72 82 } 73 83 } -
trunk/Tools/LayoutReloaded/LayoutTree/Box.js
r230373 r230464 128 128 } 129 129 130 isInlineBlockBox() { 131 return Utils.isInlineBlockElement(this.node()); 132 } 133 130 134 isInlineLevelBox() { 131 135 return Utils.isInlineLevelElement(this.node()); -
trunk/Tools/LayoutReloaded/Utils.js
r230373 r230464 209 209 } 210 210 211 growHorizontally(distance) { 212 this.m_size.setWidth(this.m_size.width() + distance); 213 } 214 211 215 moveHorizontally(distance) { 212 216 this.m_topLeft.shiftLeft(distance); … … 424 428 425 429 static isBlockContainerElement(node) { 426 if ( node.nodeType != Node.ELEMENT_NODE)430 if (!node || node.nodeType != Node.ELEMENT_NODE) 427 431 return false; 428 432 let display = window.getComputedStyle(node).display; … … 438 442 let display = window.getComputedStyle(node).display; 439 443 return display == "table" || display == "inline-table"; 444 } 445 446 static isInlineBlockElement(node) { 447 if (!node || node.nodeType != Node.ELEMENT_NODE) 448 return false; 449 let display = window.getComputedStyle(node).display; 450 return display == "inline-block"; 440 451 } 441 452 … … 581 592 line.lineBoxes().forEach(function(lineBox) { 582 593 let indentation = " ".repeat(level + 1); 583 content += indentation + "InlineTextBox at (" + Utils.precisionRound(lineBox.lineBoxRect.left(), 2) + "," + Utils.precisionRound(lineBox.lineBoxRect.top(), 2) + ") size " + Utils.precisionRound(lineBox.lineBoxRect.width(), 2) + "x" + lineBox.lineBoxRect.height() + "\n"; 594 let inlineBoxName = lineBox.startPosition === undefined ? "InlineBox" : "InlineTextBox"; 595 content += indentation + inlineBoxName + " at (" + Utils.precisionRound(lineBox.lineBoxRect.left(), 2) + "," + Utils.precisionRound(lineBox.lineBoxRect.top(), 2) + ") size " + Utils.precisionRound(lineBox.lineBoxRect.width(), 2) + "x" + lineBox.lineBoxRect.height() + "\n"; 584 596 }); 585 597 }); -
trunk/Tools/LayoutReloaded/test/index.html
r230386 r230464 79 79 "inline-formatting-context-floats1.html", 80 80 "inline-formatting-context-floats2.html", 81 "inline-with-padding-border-margin-offsets.html" 81 "inline-with-padding-border-margin-offsets.html", 82 "inline-block-with-fixed-width-height.html" 82 83 ]; 83 84
Note: See TracChangeset
for help on using the changeset viewer.