[LayoutReloaded] Introduce needsLayout to InlineFormattingContext
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Apr 2018 14:51:35 +0000 (14:51 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Apr 2018 14:51:35 +0000 (14:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=184538

Reviewed by Antti Koivisto.

* LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js:
(BlockFormattingContext.prototype._adjustBottomWithFIXME):
(BlockFormattingContext):
(BlockFormattingContext.prototype._firstInFlowChildWithNeedsLayout): Deleted.
(BlockFormattingContext.prototype._nextInFlowSiblingWithNeedsLayout): Deleted.
* LayoutReloaded/FormattingContext/FormattingContext.js:
(FormattingContext.prototype._firstInFlowChildWithNeedsLayout):
(FormattingContext.prototype._nextInFlowSiblingWithNeedsLayout):
(FormattingContext):
* LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js:
(InlineFormattingContext.prototype.layout):
(InlineFormattingContext.prototype._handleInlineContainer):
(InlineFormattingContext.prototype._handleInlineBlockContainer):
(InlineFormattingContext.prototype._handleInlineContent):
(InlineFormattingContext.prototype._clearAndMoveToNext):
(InlineFormattingContext):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230573 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js
Tools/LayoutReloaded/FormattingContext/FormattingContext.js
Tools/LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js

index 8aecaa98adf7723c0570da1bf3d66e25369d2531..be3071a182053fda1d16622c31fb0dc8082eea62 100644 (file)
@@ -1,3 +1,27 @@
+2018-04-12  Zalan Bujtas  <zalan@apple.com>
+
+        [LayoutReloaded] Introduce needsLayout to InlineFormattingContext
+        https://bugs.webkit.org/show_bug.cgi?id=184538
+
+        Reviewed by Antti Koivisto.
+
+        * LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js:
+        (BlockFormattingContext.prototype._adjustBottomWithFIXME):
+        (BlockFormattingContext):
+        (BlockFormattingContext.prototype._firstInFlowChildWithNeedsLayout): Deleted.
+        (BlockFormattingContext.prototype._nextInFlowSiblingWithNeedsLayout): Deleted.
+        * LayoutReloaded/FormattingContext/FormattingContext.js:
+        (FormattingContext.prototype._firstInFlowChildWithNeedsLayout):
+        (FormattingContext.prototype._nextInFlowSiblingWithNeedsLayout):
+        (FormattingContext):
+        * LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js:
+        (InlineFormattingContext.prototype.layout):
+        (InlineFormattingContext.prototype._handleInlineContainer):
+        (InlineFormattingContext.prototype._handleInlineBlockContainer):
+        (InlineFormattingContext.prototype._handleInlineContent):
+        (InlineFormattingContext.prototype._clearAndMoveToNext):
+        (InlineFormattingContext):
+
 2018-04-12  Xabier Rodriguez Calvar  <calvaris@igalia.com>
 
         [GStreamer] Speed up GStreamer dependency build by removing examples compilation
index 524c26497623f458f68a60845947f84a5cfb9aef..d12018ac2c6804c48832f014e8a051fb2af45a7e 100644 (file)
@@ -178,22 +178,4 @@ class BlockFormattingContext extends FormattingContext {
         }
         return bottom;
     }
-
-    _firstInFlowChildWithNeedsLayout(layoutBox) {
-        if (!layoutBox.isContainer())
-            return null;
-        for (let child = layoutBox.firstInFlowOrFloatChild(); child; child = child.nextInFlowOrFloatSibling()) {
-            if (this.formattingState().needsLayout(child))
-                return child;
-        }
-        return null;
-    }
-
-    _nextInFlowSiblingWithNeedsLayout(layoutBox) {
-        for (let sibling = layoutBox.nextInFlowOrFloatSibling(); sibling; sibling = sibling.nextInFlowOrFloatSibling()) {
-            if (this.formattingState().needsLayout(sibling))
-                return sibling;
-        }
-        return null;
-    }
 }
index e2c18d93a3313789d192193cfabdc14d93dd145b..ca1ce4b8082fd6a71a17215a7f8aa97d31412bd5 100644 (file)
@@ -332,4 +332,22 @@ class FormattingContext {
         }
         return outOfFlowBoxes;
     }
+
+    _firstInFlowChildWithNeedsLayout(layoutBox) {
+        if (!layoutBox.isContainer())
+            return null;
+        for (let child = layoutBox.firstInFlowOrFloatChild(); child; child = child.nextInFlowOrFloatSibling()) {
+            if (this.formattingState().needsLayout(child))
+                return child;
+        }
+        return null;
+    }
+
+    _nextInFlowSiblingWithNeedsLayout(layoutBox) {
+        for (let sibling = layoutBox.nextInFlowOrFloatSibling(); sibling; sibling = sibling.nextInFlowOrFloatSibling()) {
+            if (this.formattingState().needsLayout(sibling))
+                return sibling;
+        }
+        return null;
+    }
 }
index f7f0fc9e722db9c440ad3523d32d9ab29069149b..c2d85cb032bc153a8c5bec94fc60b305cbe2500a 100644 (file)
@@ -37,7 +37,7 @@ class InlineFormattingContext extends FormattingContext {
             return;
         this.m_line = this._createNewLine();
         let inlineContainerStack = new Array();
-        this._addToLayoutQueue(this.formattingRoot().firstInFlowOrFloatChild());
+        this._addToLayoutQueue(this._firstInFlowChildWithNeedsLayout(this.formattingRoot()));
         while (this._descendantNeedsLayout()) {
             let layoutBox = this._nextInLayoutQueue();
             if (layoutBox.isInlineContainer())
@@ -53,6 +53,7 @@ class InlineFormattingContext extends FormattingContext {
         this._layoutOutOfFlowDescendants(this.formattingRoot());
         this._commitLine();
         ASSERT(!this.m_inlineContainerStack.length);
+        ASSERT(!this.formattingState().layoutNeeded());
    }
 
     _handleInlineContainer(inlineContainer) {
@@ -61,14 +62,13 @@ class InlineFormattingContext extends FormattingContext {
         if (inlineContainerStart) {
             this.m_inlineContainerStack.push(inlineContainer);
             this._adjustLineForInlineContainerStart(inlineContainer);
-            this._addToLayoutQueue(inlineContainer.firstInFlowOrFloatChild());
+            this._addToLayoutQueue(this._firstInFlowChildWithNeedsLayout(inlineContainer));
             // Keep the inline container in the layout stack so that we can finish it when all the descendants are all set.
             return;
         }
         this.m_inlineContainerStack.pop(inlineContainer);
         this._adjustLineForInlineContainerEnd(inlineContainer);
-        this._removeFromLayoutQueue(inlineContainer);
-        this._addToLayoutQueue(inlineContainer.nextInFlowOrFloatSibling());
+        this._clearAndMoveToNext(inlineContainer);
         // Place inflow positioned children.
         this._placeInFlowPositionedChildren(inlineContainer);
     }
@@ -84,10 +84,8 @@ class InlineFormattingContext extends FormattingContext {
         this.layoutState().layout(inlineBlockContainer);
         displayBox.setHeight(Utils.height(inlineBlockContainer) + Utils.computedVerticalBorderAndPadding(inlineBlockContainer.node()));
         this._adjustLineForInlineContainerEnd(inlineBlockContainer);
-
         this._line().addInlineContainerBox(displayBox.size());
-        this._removeFromLayoutQueue(inlineBlockContainer);
-        this._addToLayoutQueue(inlineBlockContainer.nextInFlowOrFloatSibling());
+        this._clearAndMoveToNext(inlineBlockContainer);
     }
 
     _handleInlineContent(layoutBox) {
@@ -97,8 +95,7 @@ class InlineFormattingContext extends FormattingContext {
             this._handleFloatingBox(layoutBox);
         else
             ASSERT_NOT_REACHED();
-        this._removeFromLayoutQueue(layoutBox);
-        this._addToLayoutQueue(layoutBox.nextInFlowOrFloatSibling());
+        this._clearAndMoveToNext(layoutBox);
     }
 
     _handleInlineBox(inlineBox) {
@@ -212,5 +209,11 @@ class InlineFormattingContext extends FormattingContext {
             return root.contentBox().left();
         return horizontalPosition - rootLeft;
      }
+
+    _clearAndMoveToNext(layoutBox) {
+        this._removeFromLayoutQueue(layoutBox);
+        this.formattingState().clearNeedsLayout(layoutBox);
+        this._addToLayoutQueue(this._nextInFlowSiblingWithNeedsLayout(layoutBox));
+    }
 }