Title: [230655] trunk/Tools
Revision
230655
Author
za...@apple.com
Date
2018-04-13 20:21:59 -0700 (Fri, 13 Apr 2018)

Log Message

[LayoutReloaded] Add simple implementation for FormattingState::markNeedsLayout()
https://bugs.webkit.org/show_bug.cgi?id=184621

Reviewed by Antti Koivisto.

This is just a simple, mark ancestors dirty implementation.

* LayoutReloaded/FormattingState/FormattingState.js:
(FormattingState.prototype.markNeedsLayout):
* LayoutReloaded/LayoutState.js:
(LayoutState.prototype.markNeedsLayout):
(LayoutState.prototype.setNeedsLayoutById): Deleted.
(LayoutState.prototype.setNeedsLayout): Deleted.
* LayoutReloaded/TreeBuilder.js:
(TreeBuilder.prototype._createAndAttachBox):
(TreeBuilder.prototype._findBox): Deleted.
* LayoutReloaded/Utils.js:
(Utils.layoutBoxById):
* LayoutReloaded/test/index.html:
* LayoutReloaded/test/simple-incremental-layout-with-static-content.html:

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (230654 => 230655)


--- trunk/Tools/ChangeLog	2018-04-14 03:14:45 UTC (rev 230654)
+++ trunk/Tools/ChangeLog	2018-04-14 03:21:59 UTC (rev 230655)
@@ -1,3 +1,26 @@
+2018-04-13  Zalan Bujtas  <za...@apple.com>
+
+        [LayoutReloaded] Add simple implementation for FormattingState::markNeedsLayout()
+        https://bugs.webkit.org/show_bug.cgi?id=184621
+
+        Reviewed by Antti Koivisto.
+
+        This is just a simple, mark ancestors dirty implementation.
+
+        * LayoutReloaded/FormattingState/FormattingState.js:
+        (FormattingState.prototype.markNeedsLayout):
+        * LayoutReloaded/LayoutState.js:
+        (LayoutState.prototype.markNeedsLayout):
+        (LayoutState.prototype.setNeedsLayoutById): Deleted.
+        (LayoutState.prototype.setNeedsLayout): Deleted.
+        * LayoutReloaded/TreeBuilder.js:
+        (TreeBuilder.prototype._createAndAttachBox):
+        (TreeBuilder.prototype._findBox): Deleted.
+        * LayoutReloaded/Utils.js:
+        (Utils.layoutBoxById):
+        * LayoutReloaded/test/index.html:
+        * LayoutReloaded/test/simple-incremental-layout-with-static-content.html:
+
 2018-04-13  Carlos Alberto Lopez Perez  <clo...@igalia.com>
 
         [WPE] [webkitpy] The driver requirements should be checked before starting the tests

Modified: trunk/Tools/LayoutReloaded/FormattingState/FormattingState.js (230654 => 230655)


--- trunk/Tools/LayoutReloaded/FormattingState/FormattingState.js	2018-04-14 03:14:45 UTC (rev 230654)
+++ trunk/Tools/LayoutReloaded/FormattingState/FormattingState.js	2018-04-14 03:21:59 UTC (rev 230655)
@@ -80,7 +80,19 @@
     }
 
     markNeedsLayout(layoutBox) {
+        // Never mark the formatting root dirty. It belongs to the parent formatting context (or none if ICB).
+        ASSERT(layoutBox != this.formattingRoot());
         this.m_needsLayoutBoxList.set(layoutBox);
+        // FIXME: Let's just mark all the ancestors dirty in this formatting scope.
+        let containingBlock = layoutBox.containingBlock();
+        if (!containingBlock || containingBlock == this.formattingRoot())
+            return;
+        if (!FormattingContext.isInFormattingContext(containingBlock, this.formattingRoot()))
+            return;
+        if (this.needsLayout(containingBlock))
+            return;
+
+        this.markNeedsLayout(containingBlock);
     }
 
     clearNeedsLayout(layoutBox) {

Modified: trunk/Tools/LayoutReloaded/LayoutState.js (230654 => 230655)


--- trunk/Tools/LayoutReloaded/LayoutState.js	2018-04-14 03:14:45 UTC (rev 230654)
+++ trunk/Tools/LayoutReloaded/LayoutState.js	2018-04-14 03:21:59 UTC (rev 230655)
@@ -61,16 +61,12 @@
         return null;
     }
 
-    // This is for testing only.
-    setNeedsLayoutById(layoutBoxId) {
-    }
-
-    setNeedsLayout(layoutBox) {
+    markNeedsLayout(layoutBox) {
         let formattingState = this.formattingStateForBox(layoutBox);
         // Newly created formatting state will obviously mark all the boxes dirty.
         if (!formattingState)
             return;
-        formattingState.setNeedsLayout(layoutBox);
+        formattingState.markNeedsLayout(layoutBox);
     }
 
     needsLayout() {

Modified: trunk/Tools/LayoutReloaded/TreeBuilder.js (230654 => 230655)


--- trunk/Tools/LayoutReloaded/TreeBuilder.js	2018-04-14 03:14:45 UTC (rev 230654)
+++ trunk/Tools/LayoutReloaded/TreeBuilder.js	2018-04-14 03:21:59 UTC (rev 230655)
@@ -64,7 +64,7 @@
         if (box)
             box.setRendererName(name);
 
-        let parentBox = this._findBox(initialBlockContainer, parentId);
+        let parentBox = Utils.layoutBoxById(parentId, initialBlockContainer);
         // WebKit does not construct anonymous inline container for text if the text
         // is a direct child of a block container.
         if (text) {
@@ -90,21 +90,6 @@
         parent.setLastChild(child);
     }
 
-    _findBox(root, boxId) {
-        if (root.id() == boxId)
-            return root;
-        // Super inefficient but this is all temporary anyway.
-        for (let box = root.firstChild(); box; box = box.nextSibling()) {
-            if (box.id() == boxId)
-                return box;
-            if (box.isContainer() && box.hasChild()) {
-                let candidate = this._findBox(box, boxId);
-                if (candidate)
-                    return candidate;
-            }
-        }
-    }
-
     _findNode(node, boxId) {
         // Super inefficient but this is all temporary anyway.
         for (let currentNode = node.firstChild; currentNode; currentNode = currentNode.nextSibling) {

Modified: trunk/Tools/LayoutReloaded/Utils.js (230654 => 230655)


--- trunk/Tools/LayoutReloaded/Utils.js	2018-04-14 03:14:45 UTC (rev 230654)
+++ trunk/Tools/LayoutReloaded/Utils.js	2018-04-14 03:21:59 UTC (rev 230655)
@@ -548,6 +548,21 @@
         return textBox.text().node().textHeight();
     }
 
+    static layoutBoxById(layoutBoxId, box) {
+        if (box.id() == layoutBoxId)
+            return box;
+        if (!box.isContainer())
+            return null;
+        // Super inefficient but this is all temporary anyway.
+        for (let child = box.firstChild(); child; child = child.nextSibling()) {
+            if (child.id() == layoutBoxId)
+                return child;
+            let foundIt = Utils.layoutBoxById(layoutBoxId, child);
+            if (foundIt)
+                return foundIt;
+        }
+        return null;
+    }
     // "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";
     static layoutTreeDump(layoutState) {
         return this._dumpBox(layoutState, layoutState.rootContainer(), 1) + this._dumpTree(layoutState, layoutState.rootContainer(), 2);

Modified: trunk/Tools/LayoutReloaded/test/index.html (230654 => 230655)


--- trunk/Tools/LayoutReloaded/test/index.html	2018-04-14 03:14:45 UTC (rev 230654)
+++ trunk/Tools/LayoutReloaded/test/index.html	2018-04-14 03:21:59 UTC (rev 230655)
@@ -121,15 +121,12 @@
 
 let isRunningAsyncTest = false;
 let tests;
+let testsPassed = 0;
 let currentTestIndex = 0;
 let subTests = 0;
+let subTestPassed = true;
 let layoutState = null;
 
-function collectRenderersWithNeedsLayout() {
-    // TODO: implement it in WebKit.
-    return null;
-}
-
 function runAndVerifyLayout(window) {
     layoutState = runLayout(window, layoutState);
     return verifyLayout(window.simplifiedRenderTree);
@@ -142,22 +139,29 @@
 
     notifyDone() {
         let testFrame = document.getElementById("testFrame");
-        let passed = runAndVerifyLayout(testFrame.contentWindow);
-        finishAndMoveToNextTest(passed);
+        ASSERT(subTests);
+        finishAndMoveToNextTest(subTestPassed);
     }
 
     forceLayout() {
         let testFrame = document.getElementById("testFrame");
-        let needsLayoutRenderers = collectRenderersWithNeedsLayout(); //testFrame.contentWindow.collectRenderersWithNeedsLayout();
+        let needsLayoutRenderers = testFrame.contentWindow.collectRenderersWithNeedsLayout();
         testFrame.contentWindow.document.body.offsetWidth;
         if (layoutState) {
-            for (let rendererId of needsLayoutRenderers)
-                layoutState.setNeedsLayoutById(rendererId);
+            // Finding box by id won't work unless this is ICB's layout state.
+            ASSERT(!layoutState.rootContainer().parent());
+            for (let rendererId of needsLayoutRenderers) {
+                let layoutBox = Utils.layoutBoxById(rendererId, layoutState.rootContainer());
+                layoutState.markNeedsLayout(layoutBox);
+            }
         }
         let passed = runAndVerifyLayout(testFrame.contentWindow);
         ++subTests;
-        if (!passed && failedTests.indexOf(currentTestIndex) == -1)
-            failedTests.push(currentTestIndex);
+        if (!passed) {
+            subTestPassed = false;
+            if (failedTests.indexOf(currentTestIndex) == -1)
+                failedTests.push(currentTestIndex);
+        }
         printIntermediateResult();
     }
 
@@ -176,8 +180,8 @@
 }
 
 function printIntermediateResult() {
-    let resultContent = "Testing..." + currentTestIndex + (subTests > 0 ? "(" + subTests + ")" : "") + " out of " + tests.length;
-    resultContent += "<br><br>Passed: " + (currentTestIndex - failedTests.length) + "<br>Failed: " + failedTests.length;
+    let resultContent = "Testing..." + (currentTestIndex + 1) + (subTests > 0 ? "(" + subTests + ")" : "") + " out of " + tests.length;
+    resultContent += "<br><br>Passed: " + testsPassed + "<br>Failed: " + failedTests.length;
     if (failedTests.length > 0) {
         resultContent += "<br><br>Failed cases:"
         failedTests.forEach(function(item) {
@@ -194,7 +198,9 @@
     layoutState = null;
     subTests = 0;
     isRunningAsyncTest = false;
-    if (!passed)
+    if (passed)
+        ++testsPassed;
+    else if (failedTests.indexOf(currentTestIndex) == -1)
         failedTests.push(currentTestIndex);
     setTimeout(function() {
         if (currentTestIndex < tests.length - 1) {

Modified: trunk/Tools/LayoutReloaded/test/simple-incremental-layout-with-static-content.html (230654 => 230655)


--- trunk/Tools/LayoutReloaded/test/simple-incremental-layout-with-static-content.html	2018-04-14 03:14:45 UTC (rev 230654)
+++ trunk/Tools/LayoutReloaded/test/simple-incremental-layout-with-static-content.html	2018-04-14 03:21:59 UTC (rev 230655)
@@ -1,16 +1,21 @@
 <!DOCTYPE html>
 <html>
 <body>
-<div style="width: 100px; height: 100px; border: 1px solid green"></div>
+<div id=foobar style="width: 100px; height: 100px;"></div>
 <script>
+let foobarWidth = 200;
 testRunner.waitUntilDone();
+testRunner.forceLayout();
+
 setInterval(function() {
+    foobar.style.width = foobarWidth + "px";
     testRunner.forceLayout();
+    foobarWidth += 50;
 }, 10);
 
 setTimeout(function() {
     testRunner.notifyDone();
-}, 100);
+}, 500);
 </script>
 </body>
 </html>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to