Title: [229746] trunk/Tools
Revision
229746
Author
za...@apple.com
Date
2018-03-20 08:12:33 -0700 (Tue, 20 Mar 2018)

Log Message

[LayoutReloaded] Introduce FormattingState (Block/Inline/etc)
https://bugs.webkit.org/show_bug.cgi?id=183777

Reviewed by Antti Koivisto.

This is in preparation for moving out states from the formatting contexts.

* LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js:
(BlockFormattingContext):
* LayoutReloaded/FormattingContext/FormattingContext.js:
(FormattingContext):
(FormattingContext.prototype.layoutState):
(FormattingContext.prototype.layoutContext):
(FormattingContext.prototype.layout):
* LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js:
(InlineFormattingContext):
* LayoutReloaded/FormattingState/BlockFormattingState.js: Copied from Tools/LayoutReloaded/LayoutContext.js.
(BlockFormattingState):
* LayoutReloaded/FormattingState/FormattingState.js: Copied from Tools/LayoutReloaded/LayoutContext.js.
(FormattingState):
(FormattingState.prototype.formattingContext):
(FormattingState.prototype.layoutContext):
(FormattingState.prototype._setFormattingContext):
* LayoutReloaded/FormattingState/InlineFormattingState.js: Copied from Tools/LayoutReloaded/LayoutContext.js.
(InlineFormattingState):
* LayoutReloaded/LayoutContext.js:
(LayoutContext):
(LayoutContext.prototype.layout):
(LayoutContext.prototype._createFormattingState):
(LayoutContext.prototype._createFormattingContext): Deleted.
* LayoutReloaded/LayoutReloaded.xcworkspace/contents.xcworkspacedata:
* LayoutReloaded/test/index.html:

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (229745 => 229746)


--- trunk/Tools/ChangeLog	2018-03-20 14:36:12 UTC (rev 229745)
+++ trunk/Tools/ChangeLog	2018-03-20 15:12:33 UTC (rev 229746)
@@ -1,3 +1,38 @@
+2018-03-20  Zalan Bujtas  <za...@apple.com>
+
+        [LayoutReloaded] Introduce FormattingState (Block/Inline/etc)
+        https://bugs.webkit.org/show_bug.cgi?id=183777
+
+        Reviewed by Antti Koivisto.
+
+        This is in preparation for moving out states from the formatting contexts.
+
+        * LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js:
+        (BlockFormattingContext):
+        * LayoutReloaded/FormattingContext/FormattingContext.js:
+        (FormattingContext):
+        (FormattingContext.prototype.layoutState):
+        (FormattingContext.prototype.layoutContext):
+        (FormattingContext.prototype.layout):
+        * LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js:
+        (InlineFormattingContext):
+        * LayoutReloaded/FormattingState/BlockFormattingState.js: Copied from Tools/LayoutReloaded/LayoutContext.js.
+        (BlockFormattingState):
+        * LayoutReloaded/FormattingState/FormattingState.js: Copied from Tools/LayoutReloaded/LayoutContext.js.
+        (FormattingState):
+        (FormattingState.prototype.formattingContext):
+        (FormattingState.prototype.layoutContext):
+        (FormattingState.prototype._setFormattingContext):
+        * LayoutReloaded/FormattingState/InlineFormattingState.js: Copied from Tools/LayoutReloaded/LayoutContext.js.
+        (InlineFormattingState):
+        * LayoutReloaded/LayoutContext.js:
+        (LayoutContext):
+        (LayoutContext.prototype.layout):
+        (LayoutContext.prototype._createFormattingState):
+        (LayoutContext.prototype._createFormattingContext): Deleted.
+        * LayoutReloaded/LayoutReloaded.xcworkspace/contents.xcworkspacedata:
+        * LayoutReloaded/test/index.html:
+
 2018-03-19  Zalan Bujtas  <za...@apple.com>
 
         [LayoutReloaded] Layout.Box should not create the formatting context.

Modified: trunk/Tools/LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js (229745 => 229746)


--- trunk/Tools/LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js	2018-03-20 14:36:12 UTC (rev 229745)
+++ trunk/Tools/LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js	2018-03-20 15:12:33 UTC (rev 229746)
@@ -23,8 +23,8 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 class BlockFormattingContext extends FormattingContext {
-    constructor(root, layoutContext) {
-        super(root, layoutContext);
+    constructor(root, layoutState) {
+        super(root, layoutState);
         // New block formatting context always establishes a new floating context.
         this.m_floatingContext = new FloatingContext(this);
     }

Modified: trunk/Tools/LayoutReloaded/FormattingContext/FormattingContext.js (229745 => 229746)


--- trunk/Tools/LayoutReloaded/FormattingContext/FormattingContext.js	2018-03-20 14:36:12 UTC (rev 229745)
+++ trunk/Tools/LayoutReloaded/FormattingContext/FormattingContext.js	2018-03-20 15:12:33 UTC (rev 229746)
@@ -24,9 +24,9 @@
  */
 
 class FormattingContext {
-    constructor(rootContainer, layoutContext) {
+    constructor(rootContainer, layoutState) {
         this.m_rootContainer = rootContainer;
-        this.m_layoutContext = layoutContext;
+        this.m_layoutState = layoutState;
         this.m_floatingContext = null;
         this.m_displayToLayout = new Map();
         this.m_layoutToDisplay = new Map();
@@ -37,8 +37,12 @@
         return this.m_rootContainer;
     }
 
+    layoutState() {
+        return this.m_layoutState;
+    }
+
     layoutContext() {
-        return this.m_layoutContext;
+        return this.layoutState().layoutContext();
     }
 
     floatingContext() {
@@ -45,7 +49,8 @@
         return this.m_floatingContext;
     }
 
-    layout(layoutContext) {
+    layout() {
+        ASSERT_NOT_REACHED();
     }
 
     computeWidth(layoutBox) {

Modified: trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js (229745 => 229746)


--- trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js	2018-03-20 14:36:12 UTC (rev 229745)
+++ trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js	2018-03-20 15:12:33 UTC (rev 229746)
@@ -24,8 +24,8 @@
  */
 
 class InlineFormattingContext extends FormattingContext {
-    constructor(root, layoutContext) {
-        super(root, layoutContext);
+    constructor(root, layoutState) {
+        super(root, layoutState);
         // If the block container box that initiates this inline formatting contex also establishes a block context, create a new float for us.
         ASSERT(root.isBlockContainerBox());
         if (root.establishesBlockFormattingContext())

Copied: trunk/Tools/LayoutReloaded/FormattingState/BlockFormattingState.js (from rev 229745, trunk/Tools/LayoutReloaded/LayoutContext.js) (0 => 229746)


--- trunk/Tools/LayoutReloaded/FormattingState/BlockFormattingState.js	                        (rev 0)
+++ trunk/Tools/LayoutReloaded/FormattingState/BlockFormattingState.js	2018-03-20 15:12:33 UTC (rev 229746)
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+class BlockFormattingState extends FormattingState {
+    constructor(formattingRoot, layoutContext) {
+        super(layoutContext);
+        this._setFormattingContext(new BlockFormattingContext(formattingRoot, this));
+    }
+}

Copied: trunk/Tools/LayoutReloaded/FormattingState/FormattingState.js (from rev 229745, trunk/Tools/LayoutReloaded/LayoutContext.js) (0 => 229746)


--- trunk/Tools/LayoutReloaded/FormattingState/FormattingState.js	                        (rev 0)
+++ trunk/Tools/LayoutReloaded/FormattingState/FormattingState.js	2018-03-20 15:12:33 UTC (rev 229746)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+class FormattingState {
+    constructor(layoutContext) {
+        this.m_layoutContext = layoutContext;
+        this.m_formattingContext = null;
+    }
+
+    formattingContext() {
+        return this.m_formattingContext;
+    }
+
+    layoutContext() {
+        return this.m_layoutContext;
+    }
+
+    _setFormattingContext(formattingContext) {
+        this.m_formattingContext = formattingContext;
+    }
+}

Copied: trunk/Tools/LayoutReloaded/FormattingState/InlineFormattingState.js (from rev 229745, trunk/Tools/LayoutReloaded/LayoutContext.js) (0 => 229746)


--- trunk/Tools/LayoutReloaded/FormattingState/InlineFormattingState.js	                        (rev 0)
+++ trunk/Tools/LayoutReloaded/FormattingState/InlineFormattingState.js	2018-03-20 15:12:33 UTC (rev 229746)
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+class InlineFormattingState extends FormattingState {
+    constructor(formattingRoot, layoutContext) {
+        super(layoutContext);
+        this._setFormattingContext(new InlineFormattingContext(formattingRoot, this));
+    }
+}

Modified: trunk/Tools/LayoutReloaded/LayoutContext.js (229745 => 229746)


--- trunk/Tools/LayoutReloaded/LayoutContext.js	2018-03-20 14:36:12 UTC (rev 229745)
+++ trunk/Tools/LayoutReloaded/LayoutContext.js	2018-03-20 15:12:33 UTC (rev 229746)
@@ -25,19 +25,21 @@
 
 class LayoutContext {
     constructor() {
+        this.m_layoutStates = new Map();
     }
 
     layout(formattingRoot) {
-        let formattingContext = this._createFormattingContext(formattingRoot);
-        formattingContext.layout();
+        let formattingState = this._createFormattingState(formattingRoot);
+        this.m_layoutStates.set(formattingRoot, formattingState);
+        formattingState.formattingContext().layout();
     }
 
-    _createFormattingContext(formattingRoot) {
+    _createFormattingState(formattingRoot) {
         ASSERT(formattingRoot.establishesFormattingContext());
         if (formattingRoot.establishesBlockFormattingContext())
-            return new BlockFormattingContext(formattingRoot, this);
+            return new BlockFormattingState(formattingRoot, this);
         if (formattingRoot.establishesInlineFormattingContext())
-            return new InlineFormattingContext(formattingRoot, this);
+            return new InlineFormattingState(formattingRoot, this);
         ASSERT_NOT_REACHED();
         return null;
     }

Modified: trunk/Tools/LayoutReloaded/LayoutReloaded.xcworkspace/contents.xcworkspacedata (229745 => 229746)


--- trunk/Tools/LayoutReloaded/LayoutReloaded.xcworkspace/contents.xcworkspacedata	2018-03-20 14:36:12 UTC (rev 229745)
+++ trunk/Tools/LayoutReloaded/LayoutReloaded.xcworkspace/contents.xcworkspacedata	2018-03-20 15:12:33 UTC (rev 229746)
@@ -5,15 +5,12 @@
       location = "group:DisplayTree">
    </FileRef>
    <FileRef
-      location = "group:test">
+      location = "group:FormattingContext">
    </FileRef>
    <FileRef
-      location = "group:misc">
+      location = "group:FormattingState">
    </FileRef>
    <FileRef
-      location = "group:FormattingContext">
-   </FileRef>
-   <FileRef
       location = "group:LayoutTree">
    </FileRef>
    <FileRef
@@ -31,4 +28,10 @@
    <FileRef
       location = "group:TreeBuilder.js">
    </FileRef>
+   <FileRef
+      location = "group:test">
+   </FileRef>
+   <FileRef
+      location = "group:misc">
+   </FileRef>
 </Workspace>

Modified: trunk/Tools/LayoutReloaded/test/index.html (229745 => 229746)


--- trunk/Tools/LayoutReloaded/test/index.html	2018-03-20 14:36:12 UTC (rev 229745)
+++ trunk/Tools/LayoutReloaded/test/index.html	2018-03-20 15:12:33 UTC (rev 229746)
@@ -85,6 +85,9 @@
 addJS("../LayoutTree/InlineBox.js");
 addJS("../LayoutTree/Text.js");
 addJS("../DisplayTree/Box.js");
+addJS("../FormattingState/FormattingState.js");
+addJS("../FormattingState/BlockFormattingState.js");
+addJS("../FormattingState/InlineFormattingState.js");
 addJS("../FormattingContext/FormattingContext.js");
 addJS("../FormattingContext/FloatingContext.js");
 addJS("../FormattingContext/BlockFormatting/BlockFormattingContext.js");
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to