Title: [229692] trunk/Tools
Revision
229692
Author
[email protected]
Date
2018-03-16 21:34:02 -0700 (Fri, 16 Mar 2018)

Log Message

[LayoutReloaded] Move move functions to the base class from BlockFormattingContext
https://bugs.webkit.org/show_bug.cgi?id=183719

Reviewed by Antti Koivisto.

* LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js:
(BlockFormattingContext):
(BlockFormattingContext.prototype.layout):
(BlockFormattingContext.prototype._shrinkToFitWidth):
(BlockFormattingContext.prototype._toAbsolutePosition): Deleted.
(BlockFormattingContext.prototype._needsLayout): Deleted.
(BlockFormattingContext.prototype._addToLayoutQueue): Deleted.
(BlockFormattingContext.prototype._nextInLayoutQueue): Deleted.
(BlockFormattingContext.prototype._removeFromLayoutQueue): Deleted.
(BlockFormattingContext.prototype._createDisplayBox): Deleted.
(BlockFormattingContext.prototype._toDisplayBox): Deleted.
(BlockFormattingContext.prototype._toLayoutBox): Deleted.
* LayoutReloaded/FormattingContext/FormattingContext.js:
(FormattingContext):
(FormattingContext.prototype._toAbsolutePosition):
(FormattingContext.prototype._descendantNeedsLayout):
(FormattingContext.prototype._addToLayoutQueue):
(FormattingContext.prototype._nextInLayoutQueue):
(FormattingContext.prototype._removeFromLayoutQueue):
(FormattingContext.prototype._createDisplayBox):
(FormattingContext.prototype._toDisplayBox):
(FormattingContext.prototype._toLayoutBox):
* LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js:
(InlineFormattingContext.prototype.layout):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (229691 => 229692)


--- trunk/Tools/ChangeLog	2018-03-17 02:43:24 UTC (rev 229691)
+++ trunk/Tools/ChangeLog	2018-03-17 04:34:02 UTC (rev 229692)
@@ -1,3 +1,35 @@
+2018-03-16  Zalan Bujtas  <[email protected]>
+
+        [LayoutReloaded] Move move functions to the base class from BlockFormattingContext
+        https://bugs.webkit.org/show_bug.cgi?id=183719
+
+        Reviewed by Antti Koivisto.
+
+        * LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js:
+        (BlockFormattingContext):
+        (BlockFormattingContext.prototype.layout):
+        (BlockFormattingContext.prototype._shrinkToFitWidth):
+        (BlockFormattingContext.prototype._toAbsolutePosition): Deleted.
+        (BlockFormattingContext.prototype._needsLayout): Deleted.
+        (BlockFormattingContext.prototype._addToLayoutQueue): Deleted.
+        (BlockFormattingContext.prototype._nextInLayoutQueue): Deleted.
+        (BlockFormattingContext.prototype._removeFromLayoutQueue): Deleted.
+        (BlockFormattingContext.prototype._createDisplayBox): Deleted.
+        (BlockFormattingContext.prototype._toDisplayBox): Deleted.
+        (BlockFormattingContext.prototype._toLayoutBox): Deleted.
+        * LayoutReloaded/FormattingContext/FormattingContext.js:
+        (FormattingContext):
+        (FormattingContext.prototype._toAbsolutePosition):
+        (FormattingContext.prototype._descendantNeedsLayout):
+        (FormattingContext.prototype._addToLayoutQueue):
+        (FormattingContext.prototype._nextInLayoutQueue):
+        (FormattingContext.prototype._removeFromLayoutQueue):
+        (FormattingContext.prototype._createDisplayBox):
+        (FormattingContext.prototype._toDisplayBox):
+        (FormattingContext.prototype._toLayoutBox):
+        * LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js:
+        (InlineFormattingContext.prototype.layout):
+
 2018-03-16  Chris Dumez  <[email protected]>
 
         WebKit.WebsitePoliciesAutoplayQuirks API test times out with async policy delegates

Modified: trunk/Tools/LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js (229691 => 229692)


--- trunk/Tools/LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js	2018-03-17 02:43:24 UTC (rev 229691)
+++ trunk/Tools/LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js	2018-03-17 04:34:02 UTC (rev 229692)
@@ -27,9 +27,6 @@
         super(root);
         // New block formatting context always establishes a new floating context.
         this.m_floatingContext = new FloatingContext(this);
-        this.m_displayToLayout = new Map();
-        this.m_layoutToDisplay = new Map();
-        this.m_layoutStack = new Array();
     }
 
     layout(layoutContext) {
@@ -46,7 +43,7 @@
         // 2. Compute static position and width as we travers down
         // 3. As we climb back on the tree, compute height and finialize position
         // (Any subtrees with new formatting contexts need to layout synchronously)
-        while (this._needsLayout()) {
+        while (this._descendantNeedsLayout()) {
             // Travers down on the descendants until we find a leaf node.
             while (true) {
                 let layoutBox = this._nextInLayoutQueue();
@@ -62,7 +59,7 @@
             }
 
             // Climb back on the ancestors and compute height/final position.
-            while (this._needsLayout()) {
+            while (this._descendantNeedsLayout()) {
                 // All inflow descendants (if there are any) are laid out by now. Let's compute the box's height.
                 let layoutBox = this._nextInLayoutQueue();
                 this.computeHeight(layoutBox);
@@ -331,59 +328,4 @@
         }
         return width;
     }
-
-    _toAbsolutePosition(layoutBox) {
-        // We should never need to go beyond the root container.
-        let containingBlock = layoutBox.containingBlock();
-        ASSERT(containingBlock == this.rootContainer() || Utils.isDescendantOf(containingBlock, this.rootContainer()));
-        let topLeft = layoutBox.rect().topLeft();
-        let ascendant = layoutBox.parent();
-        while (ascendant && ascendant != containingBlock) {
-            topLeft.moveBy(ascendant.rect().topLeft());
-            ascendant = ascendant.parent();
-        }
-        return new LayoutRect(topLeft, layoutBox.rect().size());
-    }
-
-    _needsLayout() {
-        return this.m_layoutStack.length;
-    }
-
-    _addToLayoutQueue(layoutBox) {
-        // Initialize the corresponding display box.
-        this._createDisplayBox(layoutBox);
-        this.m_layoutStack.push(layoutBox);
-    }
-
-    _nextInLayoutQueue() {
-        ASSERT(this.m_layoutStack.length);
-        return this.m_layoutStack[this.m_layoutStack.length - 1];
-    }
-
-    _removeFromLayoutQueue(layoutBox) {
-        // With the current layout logic, the layoutBox should be at the top (this.m_layoutStack.pop() should do).
-        ASSERT(this.m_layoutStack.length);
-        ASSERT(this.m_layoutStack[this.m_layoutStack.length - 1] == layoutBox);
-        this.m_layoutStack.splice(this.m_layoutStack.indexOf(layoutBox), 1);
-    }
-
-    _createDisplayBox(layoutBox) {
-        let displayBox = new Display.Box(layoutBox.node());
-        this.m_displayToLayout.set(displayBox, layoutBox);
-        this.m_layoutToDisplay.set(layoutBox, displayBox);
-        // This is temporary.
-        layoutBox.setDisplayBox(displayBox);
-    }
-
-    _toDisplayBox(layoutBox) {
-        ASSERT(layoutBox);
-        ASSERT(this.m_layoutToDisplay.has(layoutBox));
-        return this.m_layoutToDisplay.get(layout);
-    }
-
-    _toLayoutBox(displayBox) {
-        ASSERT(displayBox);
-        ASSERT(this.m_displayToLayout.has(displayBox));
-        return this.m_displayToLayout.get(layout);
-    }
 }

Modified: trunk/Tools/LayoutReloaded/FormattingContext/FormattingContext.js (229691 => 229692)


--- trunk/Tools/LayoutReloaded/FormattingContext/FormattingContext.js	2018-03-17 02:43:24 UTC (rev 229691)
+++ trunk/Tools/LayoutReloaded/FormattingContext/FormattingContext.js	2018-03-17 04:34:02 UTC (rev 229692)
@@ -27,6 +27,9 @@
     constructor(rootContainer) {
         this.m_rootContainer = rootContainer;
         this.m_floatingContext = null;
+        this.m_displayToLayout = new Map();
+        this.m_layoutToDisplay = new Map();
+        this.m_layoutStack = new Array();
     }
 
     rootContainer() {
@@ -89,4 +92,59 @@
         absoluteRect.moveBy(contentBox.topLeft());
         return absoluteRect;
     }
+
+    _toAbsolutePosition(layoutBox) {
+        // We should never need to go beyond the root container.
+        let containingBlock = layoutBox.containingBlock();
+        ASSERT(containingBlock == this.rootContainer() || Utils.isDescendantOf(containingBlock, this.rootContainer()));
+        let topLeft = layoutBox.rect().topLeft();
+        let ascendant = layoutBox.parent();
+        while (ascendant && ascendant != containingBlock) {
+            topLeft.moveBy(ascendant.rect().topLeft());
+            ascendant = ascendant.parent();
+        }
+        return new LayoutRect(topLeft, layoutBox.rect().size());
+    }
+
+    _descendantNeedsLayout() {
+        return this.m_layoutStack.length;
+    }
+
+    _addToLayoutQueue(layoutBox) {
+        // Initialize the corresponding display box.
+        this._createDisplayBox(layoutBox);
+        this.m_layoutStack.push(layoutBox);
+    }
+
+    _nextInLayoutQueue() {
+        ASSERT(this.m_layoutStack.length);
+        return this.m_layoutStack[this.m_layoutStack.length - 1];
+    }
+
+    _removeFromLayoutQueue(layoutBox) {
+        // With the current layout logic, the layoutBox should be at the top (this.m_layoutStack.pop() should do).
+        ASSERT(this.m_layoutStack.length);
+        ASSERT(this.m_layoutStack[this.m_layoutStack.length - 1] == layoutBox);
+        this.m_layoutStack.splice(this.m_layoutStack.indexOf(layoutBox), 1);
+    }
+
+    _createDisplayBox(layoutBox) {
+        let displayBox = new Display.Box(layoutBox.node());
+        this.m_displayToLayout.set(displayBox, layoutBox);
+        this.m_layoutToDisplay.set(layoutBox, displayBox);
+        // This is temporary.
+        layoutBox.setDisplayBox(displayBox);
+    }
+
+    _toDisplayBox(layoutBox) {
+        ASSERT(layoutBox);
+        ASSERT(this.m_layoutToDisplay.has(layoutBox));
+        return this.m_layoutToDisplay.get(layout);
+    }
+
+    _toLayoutBox(displayBox) {
+        ASSERT(displayBox);
+        ASSERT(this.m_displayToLayout.has(displayBox));
+        return this.m_displayToLayout.get(layout);
+    }
 }

Modified: trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js (229691 => 229692)


--- trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js	2018-03-17 02:43:24 UTC (rev 229691)
+++ trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js	2018-03-17 04:34:02 UTC (rev 229692)
@@ -45,13 +45,12 @@
         if (!this.rootContainer().firstChild())
             return;
         // This is a post-order tree traversal layout.
-        let layoutStack = new Array();
         // The root container layout is done in the formatting context it lives in, not that one it creates, so let's start with the first child.
-        layoutStack.push(this.rootContainer().firstChild());
+        this._addToLayoutQueue(this.rootContainer().firstChild());
         while (layoutStack.length) {
             // Travers down on the descendants until we find a leaf node.
             while (true) {
-                let layoutBox = layoutStack[layoutStack.length - 1];
+                let layoutBox = this._nextInLayoutQueue();
                 if (layoutBox.establishesFormattingContext()) {
                     layoutContext.layoutFormattingContext(layoutBox.establishedFormattingContext());
                     break;
@@ -58,13 +57,15 @@
                 }
                 if (!layoutBox.isContainer() || !layoutBox.hasChild())
                     break;
-                layoutStack.push(box.firstChild());
+                this._addToLayoutQueue(layoutBox.firstChild());
             }
             while (layoutStack.length) {
-                let layoutBox = layoutStack.pop();
+                let layoutBox = this._nextInLayoutQueue();
                 this._handleInlineBox(layoutBox);
+                // We are done with laying out this box.
+                this._removeFromLayoutQueue(layoutBox);
                 if (layoutBox.nextSibling()) {
-                    layoutStack.push(layoutBox.nextSibling());
+                    this._addToLayoutQueue(layoutBox.nextSibling());
                     break;
                 }
             }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to