[LayoutReloaded] FloatingContext does not need a parent formatting context.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 1 Apr 2018 02:44:49 +0000 (02:44 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 1 Apr 2018 02:44:49 +0000 (02:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=184219

Reviewed by Antti Koivisto.

We don't need the formatting context in the FloatingContext now that margins are moved over to Display.Box.
This is in preparation for being able to create a FloatingContext for an inline formatting context,
when the inline context actually inherits the floating state from its formatting root.

* LayoutReloaded/FormattingContext/FloatingContext.js:
(FloatingContext):
(FloatingContext.prototype._availableSpace):
(FloatingContext.prototype._adjustedFloatingPosition):
(FloatingContext.prototype._addFloatingBox):
(FloatingContext.prototype._formattingContext): Deleted.
* LayoutReloaded/FormattingContext/FormattingContext.js:
(FormattingContext):

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

Tools/ChangeLog
Tools/LayoutReloaded/FormattingContext/FloatingContext.js
Tools/LayoutReloaded/FormattingContext/FormattingContext.js

index 826a4c5..4d1f2e1 100644 (file)
@@ -1,5 +1,25 @@
 2018-03-31  Zalan Bujtas  <zalan@apple.com>
 
+        [LayoutReloaded] FloatingContext does not need a parent formatting context.
+        https://bugs.webkit.org/show_bug.cgi?id=184219
+
+        Reviewed by Antti Koivisto.
+
+        We don't need the formatting context in the FloatingContext now that margins are moved over to Display.Box.
+        This is in preparation for being able to create a FloatingContext for an inline formatting context,
+        when the inline context actually inherits the floating state from its formatting root.
+
+        * LayoutReloaded/FormattingContext/FloatingContext.js:
+        (FloatingContext):
+        (FloatingContext.prototype._availableSpace):
+        (FloatingContext.prototype._adjustedFloatingPosition):
+        (FloatingContext.prototype._addFloatingBox):
+        (FloatingContext.prototype._formattingContext): Deleted.
+        * LayoutReloaded/FormattingContext/FormattingContext.js:
+        (FormattingContext):
+
+2018-03-31  Zalan Bujtas  <zalan@apple.com>
+
         [LayoutReloaded] Do not clone Display.Box for FloatingState stacks.
         https://bugs.webkit.org/show_bug.cgi?id=184218
 
index 4d58a2a..cfa97ee 100644 (file)
@@ -25,9 +25,8 @@
 
 // All geometry here is absolute to the formatting context's root.
 class FloatingContext {
-    constructor(floatingState, parentFormattingContext) {
+    constructor(floatingState) {
         this.m_floatingState = floatingState;
-        this.m_parentFormattingContext = parentFormattingContext;
     }
 
     computePosition(layoutBox) {
@@ -123,7 +122,7 @@ class FloatingContext {
     }
 
     _availableSpace(containingBlock, floatingPair) {
-        let containingBlockContentBox = this._formattingContext().displayBox(containingBlock);
+        let containingBlockContentBox = this._formattingState().displayBox(containingBlock);
         if (floatingPair.left && floatingPair.right)
             return floatingPair.right.left() - floatingPair.left.right();
         if (floatingPair.left) {
@@ -162,9 +161,10 @@ class FloatingContext {
                     right = floatingBoxLeft;
             }
         }
-        left += this._formattingContext().marginLeft(floatingBox);
-        right -= this._formattingContext().marginRight(floatingBox);
-        verticalPosition += this._formattingContext().marginTop(floatingBox);
+        let floatingDisplayBox = this._formattingState().displayBox(floatingBox);
+        left += floatingDisplayBox.marginLeft();
+        right -= floatingDisplayBox.marginRight();
+        verticalPosition += floatingDisplayBox.marginTop();
         // No convert them back relative to the floatingBox's containing block.
         let containingBlockLeft = this._mapBorderBoxToFormattingRoot(containingBlock).left();
         let containingBlockTop = this._mapBorderBoxToFormattingRoot(containingBlock).top();
@@ -174,7 +174,7 @@ class FloatingContext {
 
         if (Utils.isFloatingLeft(floatingBox) || !Utils.isFloatingPositioned(floatingBox))
             return new LayoutPoint(verticalPosition, left);
-        return new LayoutPoint(verticalPosition, right - this._formattingContext().displayBox(floatingBox).rect().width());
+        return new LayoutPoint(verticalPosition, right - floatingDisplayBox.rect().width());
     }
 
     _bottom(floatingStack) {
@@ -187,7 +187,7 @@ class FloatingContext {
     }
 
     _addFloatingBox(layoutBox) {
-        this._floatingState().addFloating(this._formattingContext().displayBox(layoutBox), Utils.isFloatingLeft(layoutBox));
+        this._floatingState().addFloating(this._formattingState().displayBox(layoutBox), Utils.isFloatingLeft(layoutBox));
     }
 
     _mapMarginBoxToFormattingRoot(layoutBox) {
@@ -216,10 +216,6 @@ class FloatingContext {
         return this.m_floatingState;
     }
 
-    _formattingContext() {
-        return this.m_parentFormattingContext;
-    }
-
     _formattingRoot() {
         return this._formattingState().formattingRoot();
     }
index f521f05..0ab8ad0 100644 (file)
@@ -26,7 +26,7 @@
 class FormattingContext {
     constructor(formattingState) {
         this.m_formattingState = formattingState;
-        this.m_floatingContext = new FloatingContext(formattingState.floatingState(), this);
+        this.m_floatingContext = new FloatingContext(formattingState.floatingState());
         this.m_layoutStack = new Array();
     }