Changeset 230655 in webkit
- Timestamp:
- Apr 13, 2018 8:21:59 PM (6 years ago)
- Location:
- trunk/Tools
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r230653 r230655 1 2018-04-13 Zalan Bujtas <zalan@apple.com> 2 3 [LayoutReloaded] Add simple implementation for FormattingState::markNeedsLayout() 4 https://bugs.webkit.org/show_bug.cgi?id=184621 5 6 Reviewed by Antti Koivisto. 7 8 This is just a simple, mark ancestors dirty implementation. 9 10 * LayoutReloaded/FormattingState/FormattingState.js: 11 (FormattingState.prototype.markNeedsLayout): 12 * LayoutReloaded/LayoutState.js: 13 (LayoutState.prototype.markNeedsLayout): 14 (LayoutState.prototype.setNeedsLayoutById): Deleted. 15 (LayoutState.prototype.setNeedsLayout): Deleted. 16 * LayoutReloaded/TreeBuilder.js: 17 (TreeBuilder.prototype._createAndAttachBox): 18 (TreeBuilder.prototype._findBox): Deleted. 19 * LayoutReloaded/Utils.js: 20 (Utils.layoutBoxById): 21 * LayoutReloaded/test/index.html: 22 * LayoutReloaded/test/simple-incremental-layout-with-static-content.html: 23 1 24 2018-04-13 Carlos Alberto Lopez Perez <clopez@igalia.com> 2 25 -
trunk/Tools/LayoutReloaded/FormattingState/FormattingState.js
r230580 r230655 81 81 82 82 markNeedsLayout(layoutBox) { 83 // Never mark the formatting root dirty. It belongs to the parent formatting context (or none if ICB). 84 ASSERT(layoutBox != this.formattingRoot()); 83 85 this.m_needsLayoutBoxList.set(layoutBox); 86 // FIXME: Let's just mark all the ancestors dirty in this formatting scope. 87 let containingBlock = layoutBox.containingBlock(); 88 if (!containingBlock || containingBlock == this.formattingRoot()) 89 return; 90 if (!FormattingContext.isInFormattingContext(containingBlock, this.formattingRoot())) 91 return; 92 if (this.needsLayout(containingBlock)) 93 return; 94 95 this.markNeedsLayout(containingBlock); 84 96 } 85 97 -
trunk/Tools/LayoutReloaded/LayoutState.js
r230622 r230655 62 62 } 63 63 64 // This is for testing only. 65 setNeedsLayoutById(layoutBoxId) { 66 } 67 68 setNeedsLayout(layoutBox) { 64 markNeedsLayout(layoutBox) { 69 65 let formattingState = this.formattingStateForBox(layoutBox); 70 66 // Newly created formatting state will obviously mark all the boxes dirty. 71 67 if (!formattingState) 72 68 return; 73 formattingState. setNeedsLayout(layoutBox);69 formattingState.markNeedsLayout(layoutBox); 74 70 } 75 71 -
trunk/Tools/LayoutReloaded/TreeBuilder.js
r230466 r230655 65 65 box.setRendererName(name); 66 66 67 let parentBox = this._findBox(initialBlockContainer, parentId);67 let parentBox = Utils.layoutBoxById(parentId, initialBlockContainer); 68 68 // WebKit does not construct anonymous inline container for text if the text 69 69 // is a direct child of a block container. … … 91 91 } 92 92 93 _findBox(root, boxId) {94 if (root.id() == boxId)95 return root;96 // Super inefficient but this is all temporary anyway.97 for (let box = root.firstChild(); box; box = box.nextSibling()) {98 if (box.id() == boxId)99 return box;100 if (box.isContainer() && box.hasChild()) {101 let candidate = this._findBox(box, boxId);102 if (candidate)103 return candidate;104 }105 }106 }107 108 93 _findNode(node, boxId) { 109 94 // Super inefficient but this is all temporary anyway. -
trunk/Tools/LayoutReloaded/Utils.js
r230622 r230655 549 549 } 550 550 551 static layoutBoxById(layoutBoxId, box) { 552 if (box.id() == layoutBoxId) 553 return box; 554 if (!box.isContainer()) 555 return null; 556 // Super inefficient but this is all temporary anyway. 557 for (let child = box.firstChild(); child; child = child.nextSibling()) { 558 if (child.id() == layoutBoxId) 559 return child; 560 let foundIt = Utils.layoutBoxById(layoutBoxId, child); 561 if (foundIt) 562 return foundIt; 563 } 564 return null; 565 } 551 566 // "RenderView at (0,0) size 1317x366\n HTML RenderBlock at (0,0) size 1317x116\n BODY RenderBody at (8,8) size 1301x100\n DIV RenderBlock at (0,0) size 100x100\n"; 552 567 static layoutTreeDump(layoutState) { -
trunk/Tools/LayoutReloaded/test/index.html
r230622 r230655 122 122 let isRunningAsyncTest = false; 123 123 let tests; 124 let testsPassed = 0; 124 125 let currentTestIndex = 0; 125 126 let subTests = 0; 127 let subTestPassed = true; 126 128 let layoutState = null; 127 128 function collectRenderersWithNeedsLayout() {129 // TODO: implement it in WebKit.130 return null;131 }132 129 133 130 function runAndVerifyLayout(window) { … … 143 140 notifyDone() { 144 141 let testFrame = document.getElementById("testFrame"); 145 let passed = runAndVerifyLayout(testFrame.contentWindow);146 finishAndMoveToNextTest( passed);142 ASSERT(subTests); 143 finishAndMoveToNextTest(subTestPassed); 147 144 } 148 145 149 146 forceLayout() { 150 147 let testFrame = document.getElementById("testFrame"); 151 let needsLayoutRenderers = collectRenderersWithNeedsLayout(); //testFrame.contentWindow.collectRenderersWithNeedsLayout();148 let needsLayoutRenderers = testFrame.contentWindow.collectRenderersWithNeedsLayout(); 152 149 testFrame.contentWindow.document.body.offsetWidth; 153 150 if (layoutState) { 154 for (let rendererId of needsLayoutRenderers) 155 layoutState.setNeedsLayoutById(rendererId); 151 // Finding box by id won't work unless this is ICB's layout state. 152 ASSERT(!layoutState.rootContainer().parent()); 153 for (let rendererId of needsLayoutRenderers) { 154 let layoutBox = Utils.layoutBoxById(rendererId, layoutState.rootContainer()); 155 layoutState.markNeedsLayout(layoutBox); 156 } 156 157 } 157 158 let passed = runAndVerifyLayout(testFrame.contentWindow); 158 159 ++subTests; 159 if (!passed && failedTests.indexOf(currentTestIndex) == -1) 160 failedTests.push(currentTestIndex); 160 if (!passed) { 161 subTestPassed = false; 162 if (failedTests.indexOf(currentTestIndex) == -1) 163 failedTests.push(currentTestIndex); 164 } 161 165 printIntermediateResult(); 162 166 } … … 177 181 178 182 function printIntermediateResult() { 179 let resultContent = "Testing..." + currentTestIndex+ (subTests > 0 ? "(" + subTests + ")" : "") + " out of " + tests.length;180 resultContent += "<br><br>Passed: " + (currentTestIndex - failedTests.length)+ "<br>Failed: " + failedTests.length;183 let resultContent = "Testing..." + (currentTestIndex + 1) + (subTests > 0 ? "(" + subTests + ")" : "") + " out of " + tests.length; 184 resultContent += "<br><br>Passed: " + testsPassed + "<br>Failed: " + failedTests.length; 181 185 if (failedTests.length > 0) { 182 186 resultContent += "<br><br>Failed cases:" … … 195 199 subTests = 0; 196 200 isRunningAsyncTest = false; 197 if (!passed) 201 if (passed) 202 ++testsPassed; 203 else if (failedTests.indexOf(currentTestIndex) == -1) 198 204 failedTests.push(currentTestIndex); 199 205 setTimeout(function() { -
trunk/Tools/LayoutReloaded/test/simple-incremental-layout-with-static-content.html
r230622 r230655 2 2 <html> 3 3 <body> 4 <div style="width: 100px; height: 100px; border: 1px solid green"></div>4 <div id=foobar style="width: 100px; height: 100px;"></div> 5 5 <script> 6 let foobarWidth = 200; 6 7 testRunner.waitUntilDone(); 8 testRunner.forceLayout(); 9 7 10 setInterval(function() { 11 foobar.style.width = foobarWidth + "px"; 8 12 testRunner.forceLayout(); 13 foobarWidth += 50; 9 14 }, 10); 10 15 11 16 setTimeout(function() { 12 17 testRunner.notifyDone(); 13 }, 100);18 }, 500); 14 19 </script> 15 20 </body>
Note: See TracChangeset
for help on using the changeset viewer.