Changeset 230469 in webkit
- Timestamp:
- Apr 9, 2018 10:06:37 PM (6 years ago)
- Location:
- trunk/Tools
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r230466 r230469 1 2018-04-09 Zalan Bujtas <zalan@apple.com> 2 3 [LayoutReloaded] Add support for relatively positioned containers in inline formatting context. 4 https://bugs.webkit.org/show_bug.cgi?id=184439 5 6 Reviewed by Antti Koivisto. 7 8 * LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js: 9 (BlockFormattingContext.prototype._placeInFlowPositionedChildren): Deleted. 10 (BlockFormattingContext.prototype._computeInFlowPositionedPosition): Deleted. 11 * LayoutReloaded/FormattingContext/FormattingContext.js: 12 (FormattingContext.prototype._computeInFlowPositionedPosition): 13 (FormattingContext.prototype._placeInFlowPositionedChildren): 14 * LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js: 15 (InlineFormattingContext.prototype._placeInFlowPositionedChildren): Deleted. 16 * LayoutReloaded/Utils.js: 17 (Utils._dumpBox): 18 (Utils._dumpLines.): 19 (Utils._dumpLines): 20 (Utils.precisionRoundWithDecimals): 21 (Utils.precisionRound): 22 (Utils): 23 * LayoutReloaded/test/index.html: 24 * LayoutReloaded/test/inline-with-relative-positioning.html: Added. 25 1 26 2018-04-09 Zalan Bujtas <zalan@apple.com> 2 27 -
trunk/Tools/LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js
r230243 r230469 117 117 position.moveBy(new LayoutSize(this.marginLeft(layoutBox), this.marginTop(layoutBox))); 118 118 this.displayBox(layoutBox).setTopLeft(position); 119 }120 121 _placeInFlowPositionedChildren(container) {122 if (!container.isContainer())123 return;124 // If this layoutBox also establishes a formatting context, then positioning already has happend at the formatting context.125 if (container.establishesFormattingContext() && container != this.formattingRoot())126 return;127 ASSERT(container.isContainer());128 for (let inFlowChild = container.firstInFlowChild(); inFlowChild; inFlowChild = inFlowChild.nextInFlowSibling()) {129 if (!inFlowChild.isInFlowPositioned())130 continue;131 this._computeInFlowPositionedPosition(inFlowChild);132 }133 119 } 134 120 … … 278 264 } 279 265 return bottom; 280 }281 282 _computeInFlowPositionedPosition(layoutBox) {283 // Start with the original, static position.284 let displayBox = this.displayBox(layoutBox);285 let relativePosition = displayBox.topLeft();286 // Top/bottom287 if (!Utils.isTopAuto(layoutBox))288 relativePosition.shiftTop(Utils.top(layoutBox));289 else if (!Utils.isBottomAuto(layoutBox))290 relativePosition.shiftTop(-Utils.bottom(layoutBox));291 // Left/right292 if (!Utils.isLeftAuto(layoutBox))293 relativePosition.shiftLeft(Utils.left(layoutBox));294 else if (!Utils.isRightAuto(layoutBox))295 relativePosition.shiftLeft(-Utils.right(layoutBox));296 displayBox.setTopLeft(relativePosition);297 266 } 298 267 -
trunk/Tools/LayoutReloaded/FormattingContext/FormattingContext.js
r230373 r230469 118 118 } 119 119 120 _computeInFlowPositionedPosition(layoutBox) { 121 // Start with the original, static position. 122 let displayBox = this.displayBox(layoutBox); 123 let relativePosition = displayBox.topLeft(); 124 // Top/bottom 125 if (!Utils.isTopAuto(layoutBox)) 126 relativePosition.shiftTop(Utils.top(layoutBox)); 127 else if (!Utils.isBottomAuto(layoutBox)) 128 relativePosition.shiftTop(-Utils.bottom(layoutBox)); 129 // Left/right 130 if (!Utils.isLeftAuto(layoutBox)) 131 relativePosition.shiftLeft(Utils.left(layoutBox)); 132 else if (!Utils.isRightAuto(layoutBox)) 133 relativePosition.shiftLeft(-Utils.right(layoutBox)); 134 displayBox.setTopLeft(relativePosition); 135 } 136 137 _placeInFlowPositionedChildren(container) { 138 if (!container.isContainer()) 139 return; 140 // If this layoutBox also establishes a formatting context, then positioning already has happend at the formatting context. 141 if (container.establishesFormattingContext() && container != this.formattingRoot()) 142 return; 143 ASSERT(container.isContainer()); 144 for (let inFlowChild = container.firstInFlowChild(); inFlowChild; inFlowChild = inFlowChild.nextInFlowSibling()) { 145 if (!inFlowChild.isInFlowPositioned()) 146 continue; 147 this._computeInFlowPositionedPosition(inFlowChild); 148 } 149 } 150 120 151 _outOfFlowDescendants() { 121 152 // FIXME: This is highly inefficient but will do for now. -
trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js
r230464 r230469 153 153 } 154 154 155 _placeInFlowPositionedChildren(container) {156 157 }158 159 155 _placeOutOfFlowDescendants(container) { 160 156 -
trunk/Tools/LayoutReloaded/Utils.js
r230464 r230469 572 572 return indentation + "#text RenderText\n"; 573 573 } 574 if (box.name() == "RenderInline") 574 if (box.name() == "RenderInline") { 575 if (box.isInFlowPositioned()) { 576 let displayBox = Utils._findDisplayBox(layoutState, box); 577 let boxRect = displayBox.rect(); 578 return indentation + box.node().tagName + " " + box.name() + " (" + Utils.precisionRoundWithDecimals(boxRect.left()) + ", " + Utils.precisionRoundWithDecimals(boxRect.top()) + ")\n"; 579 } 575 580 return indentation + box.node().tagName + " " + box.name() + "\n"; 581 } 576 582 if (box.isAnonymous()) 577 583 return ""; … … 589 595 lines.forEach(function(line) { 590 596 let lineRect = line.rect(); 591 content += indentation + "RootInlineBox at (" + lineRect.left() + "," + lineRect.top() + ") size " + Utils.precisionRound(lineRect.width() , 2) + "x" + lineRect.height() + "\n";597 content += indentation + "RootInlineBox at (" + lineRect.left() + "," + lineRect.top() + ") size " + Utils.precisionRound(lineRect.width()) + "x" + lineRect.height() + "\n"; 592 598 line.lineBoxes().forEach(function(lineBox) { 593 599 let indentation = " ".repeat(level + 1); 594 600 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";601 content += indentation + inlineBoxName + " at (" + Utils.precisionRound(lineBox.lineBoxRect.left()) + "," + Utils.precisionRound(lineBox.lineBoxRect.top()) + ") size " + Utils.precisionRound(lineBox.lineBoxRect.width()) + "x" + lineBox.lineBoxRect.height() + "\n"; 596 602 }); 597 603 }); … … 611 617 } 612 618 613 static precisionRound(number, precision) { 614 let factor = Math.pow(10, precision); 619 static precisionRoundWithDecimals(number) { 620 return number.toFixed(2); 621 } 622 623 static precisionRound(number) { 624 let factor = Math.pow(10, 2); 615 625 return Math.round(number * factor) / factor; 616 626 } -
trunk/Tools/LayoutReloaded/test/index.html
r230466 r230469 80 80 "inline-formatting-context-floats2.html", 81 81 "inline-with-padding-border-margin-offsets.html", 82 "inline-block-with-fixed-width-height.html" 82 "inline-block-with-fixed-width-height.html", 83 "inline-with-relative-positioning.html" 83 84 ]; 84 85
Note: See TracChangeset
for help on using the changeset viewer.