[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):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@229692 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Tools/LayoutReloaded/FormattingContext/FormattingContext.js b/Tools/LayoutReloaded/FormattingContext/FormattingContext.js
index 7a7cad8..e9251f6 100644
--- a/Tools/LayoutReloaded/FormattingContext/FormattingContext.js
+++ b/Tools/LayoutReloaded/FormattingContext/FormattingContext.js
@@ -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);
+    }
 }