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:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229746
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2018-03-20 Zalan Bujtas <zalan@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 <zalan@apple.com>
[LayoutReloaded] Layout.Box should not create the formatting context.
* 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);
}
*/
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();
return this.m_rootContainer;
}
+ layoutState() {
+ return this.m_layoutState;
+ }
+
layoutContext() {
- return this.m_layoutContext;
+ return this.layoutState().layoutContext();
}
floatingContext() {
return this.m_floatingContext;
}
- layout(layoutContext) {
+ layout() {
+ ASSERT_NOT_REACHED();
}
computeWidth(layoutBox) {
*/
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())
--- /dev/null
+/*
+ * 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));
+ }
+}
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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));
+ }
+}
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;
}
location = "group:DisplayTree">
</FileRef>
<FileRef
- location = "group:test">
- </FileRef>
- <FileRef
- location = "group:misc">
+ location = "group:FormattingContext">
</FileRef>
<FileRef
- location = "group:FormattingContext">
+ location = "group:FormattingState">
</FileRef>
<FileRef
location = "group:LayoutTree">
<FileRef
location = "group:TreeBuilder.js">
</FileRef>
+ <FileRef
+ location = "group:test">
+ </FileRef>
+ <FileRef
+ location = "group:misc">
+ </FileRef>
</Workspace>
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");