haikuwebkit/Tools/LayoutReloaded/LayoutState.js

128 lines
4.7 KiB
JavaScript
Raw Permalink Normal View History

[LayoutReloaded] Initial commit -block formatting context. https://bugs.webkit.org/show_bug.cgi?id=183462 Reviewed by Antti Koivisto. See README.md * LayoutReloaded/BlockContainer.js: Added. (BlockContainer): (BlockContainer.prototype.establishesInlineFormattingContext): * LayoutReloaded/BlockFormattingContext.js: Added. (BlockFormattingContext): (BlockFormattingContext.prototype.layout): (BlockFormattingContext.prototype.computeWidth): (BlockFormattingContext.prototype.computeHeight): (BlockFormattingContext.prototype.marginTop): (BlockFormattingContext.prototype.marginBottom): (BlockFormattingContext.prototype._computeStaticPosition): (BlockFormattingContext.prototype._placeInFlowPositionedChildren): (BlockFormattingContext.prototype._placeOutOfFlowDescendants): (BlockFormattingContext.prototype._computeOutOfFlowWidth): (BlockFormattingContext.prototype._computeFloatingWidth): (BlockFormattingContext.prototype._computeInFlowWidth): (BlockFormattingContext.prototype._computeOutOfFlowHeight): (BlockFormattingContext.prototype._computeFloatingHeight): (BlockFormattingContext.prototype._computeInFlowHeight): (BlockFormattingContext.prototype._computeHorizontalConstraint): (BlockFormattingContext.prototype._computeContentHeight): (BlockFormattingContext.prototype._computeInFlowPositionedPosition): (BlockFormattingContext.prototype._computeOutOfFlowPosition): (BlockFormattingContext.prototype._shrinkToFitWidth): * LayoutReloaded/BlockMarginCollapse.js: Added. (BlockMarginCollapse.marginTop): (BlockMarginCollapse.marginBottom): (BlockMarginCollapse._isMarginTopCollapsedWithSibling): (BlockMarginCollapse._isMarginBottomCollapsedWithSibling): (BlockMarginCollapse._isMarginTopCollapsedWithParent): (BlockMarginCollapse._isMarginBottomCollapsedWithParent): (BlockMarginCollapse._nonCollapsedMarginTop): (BlockMarginCollapse._nonCollapsedMarginBottom): (BlockMarginCollapse._collapsedMarginTopFromFirstChild): (BlockMarginCollapse._collapsedMarginBottomFromLastChild): (BlockMarginCollapse._marginValue): (BlockMarginCollapse._hasAdjoiningMarginTopAndBottom): (BlockMarginCollapse): * LayoutReloaded/Box.js: Added. (Box): (Box.prototype.id): (Box.prototype.setRendererName): (Box.prototype.name): (Box.prototype.node): (Box.prototype.parent): (Box.prototype.nextSibling): (Box.prototype.nextInFlowSibling): (Box.prototype.previousSibling): (Box.prototype.previousInFlowSibling): (Box.prototype.setParent): (Box.prototype.setNextSibling): (Box.prototype.setPreviousSibling): (Box.prototype.rect): (Box.prototype.topLeft): (Box.prototype.bottomRight): (Box.prototype.setTopLeft): (Box.prototype.setSize): (Box.prototype.setWidth): (Box.prototype.setHeight): (Box.prototype.isContainer): (Box.prototype.isBlockLevelBox): (Box.prototype.isBlockContainerBox): (Box.prototype.isInlineLevelBox): (Box.prototype.setIsAnonymous): (Box.prototype.isAnonymous): (Box.prototype.establishesFormattingContext): (Box.prototype.establishedFormattingContext): (Box.prototype.establishesBlockFormattingContext): (Box.prototype.establishesInlineFormattingContext): (Box.prototype.isPositioned): (Box.prototype.isRelativePositioned): (Box.prototype.isAbsolutePositioned): (Box.prototype.isFixedPositioned): (Box.prototype.isInFlow): (Box.prototype.isOutOfFlowPositioned): (Box.prototype.isInFlowPositioned): (Box.prototype.isFloatingPositioned): (Box.prototype.isFloatingOrOutOfFlowPositioned): (Box.prototype.isRootElement): (Box.prototype.containingBlock): (Box.prototype.borderBox): (Box.prototype.paddingBox): (Box.prototype.contentBox): * LayoutReloaded/Container.js: Added. (Container): (Container.prototype.isContainer): (Container.prototype.setFirstChild): (Container.prototype.setLastChild): (Container.prototype.firstChild): (Container.prototype.firstInFlowChild): (Container.prototype.lastChild): (Container.prototype.lastInFlowChild): (Container.prototype.hasChild): (Container.prototype.hasInFlowChild): * LayoutReloaded/FloatingContext.js: Added. (FloatingContext): (FloatingContext.prototype.computePosition): (FloatingContext.prototype.bottom): (FloatingContext.prototype._positionForFloating): (FloatingContext.prototype._positionForClear): (FloatingContext.prototype._computePositionToAvoidIntrudingFloats): (FloatingContext.prototype._addFloating): (FloatingContext.prototype._findInnerMostLeftAndRight): (FloatingContext.prototype._moveToNextVerticalPosition): (FloatingContext.prototype._availableSpace): (FloatingContext.prototype._findFloatingAtVerticalPosition): (FloatingContext.prototype._isEmpty): (FloatingContext.prototype._adjustedFloatingPosition): (FloatingContext.prototype._bottom): (FloatingContext.prototype._formattingContext): * LayoutReloaded/FormattingContext.js: Added. (FormattingContext): (FormattingContext.prototype.rootContainer): (FormattingContext.prototype.floatingContext): (FormattingContext.prototype.layout): (FormattingContext.prototype.computeWidth): (FormattingContext.prototype.computeHeight): (FormattingContext.prototype.marginTop): (FormattingContext.prototype.marginLeft): (FormattingContext.prototype.marginBottom): (FormattingContext.prototype.marginRight): (FormattingContext.prototype.absoluteMarginBox): (FormattingContext.prototype.absoluteBorderBox): (FormattingContext.prototype.absolutePaddingBox): (FormattingContext.prototype.absoluteContentBox): * LayoutReloaded/InitialBlockContainer.js: Added. (InitialBlockContainer): (InitialBlockContainer.prototype.establishesBlockFormattingContext): (InitialBlockContainer.prototype.paddingBox): (InitialBlockContainer.prototype.contentBox): * LayoutReloaded/InlineBox.js: Added. (InlineBox): (InlineBox.prototype.setText): (InlineBox.prototype.text): * LayoutReloaded/InlineFormattingContext.js: Added. (InlineFormattingContext): (InlineFormattingContext.prototype.layout): (InlineFormattingContext.prototype._handleInlineBox): (InlineFormattingContext.prototype._handleText): * LayoutReloaded/Layout.js: Added. (layout): * LayoutReloaded/LayoutContext.js: Added. (LayoutContext): (LayoutContext.prototype.layoutFormattingContext): * LayoutReloaded/LayoutReloaded.xcworkspace/contents.xcworkspacedata: Added. * LayoutReloaded/LayoutReloaded.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: Added. * LayoutReloaded/README.md: Added. * LayoutReloaded/Text.js: Added. (Text): * LayoutReloaded/TreeBuilder.js: Added. (TreeBuilder.prototype.createTree): (TreeBuilder.prototype._createAndAttachBox): (TreeBuilder.prototype._appendChild): (TreeBuilder.prototype._findBox): (TreeBuilder.prototype._findNode): (TreeBuilder): * LayoutReloaded/Utils.js: Added. (LayoutPoint): (LayoutPoint.prototype.setLeft): (LayoutPoint.prototype.setTop): (LayoutPoint.prototype.left): (LayoutPoint.prototype.top): (LayoutPoint.prototype.shiftLeft): (LayoutPoint.prototype.shiftTop): (LayoutPoint.prototype.moveBy): (LayoutPoint.prototype.equal): (LayoutPoint.prototype.clone): (LayoutSize): (LayoutSize.prototype.setWidth): (LayoutSize.prototype.setHeight): (LayoutSize.prototype.width): (LayoutSize.prototype.height): (LayoutSize.prototype.growBy): (LayoutSize.prototype.shrinkBy): (LayoutSize.prototype.isEmpty): (LayoutSize.prototype.equal): (LayoutSize.prototype.clone): (LayoutRect): (LayoutRect.prototype.setTop): (LayoutRect.prototype.setLeft): (LayoutRect.prototype.setBottom): (LayoutRect.prototype.setRight): (LayoutRect.prototype.left): (LayoutRect.prototype.top): (LayoutRect.prototype.bottom): (LayoutRect.prototype.right): (LayoutRect.prototype.setTopLeft): (LayoutRect.prototype.topLeft): (LayoutRect.prototype.topRight): (LayoutRect.prototype.bottomRight): (LayoutRect.prototype.setWidth): (LayoutRect.prototype.setHeight): (LayoutRect.prototype.setSize): (LayoutRect.prototype.size): (LayoutRect.prototype.width): (LayoutRect.prototype.height): (LayoutRect.prototype.growBy): (LayoutRect.prototype.shrinkBy): (LayoutRect.prototype.moveBy): (LayoutRect.prototype.isEmpty): (LayoutRect.prototype.equal): (LayoutRect.prototype.intersects): (LayoutRect.prototype.contains): (LayoutRect.prototype.clone): (ASSERT_NOT_REACHED): (ASSERT): (Utils.computedValue): (Utils.propertyIsAuto): (Utils.isWidthAuto): (Utils.isHeightAuto): (Utils.isTopAuto): (Utils.isLeftAuto): (Utils.isBottomAuto): (Utils.isRightAuto): (Utils.width): (Utils.height): (Utils.top): (Utils.bottom): (Utils.left): (Utils.right): (Utils.hasBorderTop): (Utils.hasBorderBottom): (Utils.hasPaddingTop): (Utils.hasPaddingBottom): (Utils.computedMarginTop): (Utils.computedMarginLeft): (Utils.computedMarginBottom): (Utils.computedMarginRight): (Utils.computedBorderTopLeft): (Utils.computedBorderBottomRight): (Utils.computedPaddingTopLeft): (Utils.computedPaddingBottomRight): (Utils.computedBorderAndPaddingTop): (Utils.computedBorderAndPaddingLeft): (Utils.computedBorderAndPaddingBottom): (Utils.computedBorderAndPaddingRight): (Utils.computedHorizontalBorderAndPadding): (Utils.computedVerticalBorderAndPadding): (Utils.hasClear): (Utils.hasClearLeft): (Utils.hasClearRight): (Utils.hasClearBoth): (Utils.isBlockLevelElement): (Utils.isBlockContainerElement): (Utils.isInlineLevelElement): (Utils.isTableElement): (Utils.isRelativePositioned): (Utils.isAbsolutePositioned): (Utils.isFixedPositioned): (Utils.isOverflowVisible): (Utils.isFloatingPositioned): (Utils.isFloatingLeft): (Utils.mapToContainer): (Utils.mapStaticToAbsolute): (Utils.collectOutOfFlowDescendants): (Utils.nextBreakingOpportunity): (Utils.measureText): (Utils.layoutTreeDump): (Utils._dumpBox): (Utils._dumpTree): (Utils): * LayoutReloaded/misc/LayoutReloadedWebKit.patch: Added. * LayoutReloaded/misc/headers/BlockContainer.h: Added. * LayoutReloaded/misc/headers/BlockFormattingContext.h: Added. * LayoutReloaded/misc/headers/BlockMarginCollapse.h: Added. * LayoutReloaded/misc/headers/Box.h: Added. * LayoutReloaded/misc/headers/Container.h: Added. * LayoutReloaded/misc/headers/FloatingContext.h: Added. * LayoutReloaded/misc/headers/FormattingContext.h: Added. * LayoutReloaded/misc/headers/InitialBlockContainer.h: Added. * LayoutReloaded/misc/headers/InlineBox.h: Added. * LayoutReloaded/misc/headers/LayoutContext.h: Added. * LayoutReloaded/misc/headers/Text.h: Added. * LayoutReloaded/test/TestHarness.js: Added. (verifyLayoutTreeDump): (runLayout): * LayoutReloaded/test/absolute-auto-with-sibling-margin-bottom.html: Added. * LayoutReloaded/test/absolute-bottom.html: Added. * LayoutReloaded/test/absolute-height-stretch.html: Added. * LayoutReloaded/test/absolute-left-auto.html: Added. * LayoutReloaded/test/absolute-left-right-top-bottom-auto.html: Added. * LayoutReloaded/test/absolute-nested.html: Added. * LayoutReloaded/test/absolute-nested2.html: Added. * LayoutReloaded/test/absolute-simple.html: Added. * LayoutReloaded/test/absolute-width-shrink-to-fit.html: Added. * LayoutReloaded/test/absolute-width-stretch.html: Added. * LayoutReloaded/test/absolute-with-inline-preferred-width.html: Added. * LayoutReloaded/test/absolute-with-static-block-position-nested.html: Added. * LayoutReloaded/test/almost-intruding-left-float-simple.html: Added. * LayoutReloaded/test/border-simple.html: Added. * LayoutReloaded/test/fixed-nested.html: Added. * LayoutReloaded/test/float-left-when-container-has-padding-margin.html: Added. * LayoutReloaded/test/floating-box-clear-both-simple.html: Added. * LayoutReloaded/test/floating-box-clear-right-simple.html: Added. * LayoutReloaded/test/floating-box-left-and-right-multiple-with-top-offset.html: Added. * LayoutReloaded/test/floating-box-left-and-right-multiple.html: Added. * LayoutReloaded/test/floating-box-right-simple.html: Added. * LayoutReloaded/test/floating-box-with-clear-siblings.html: Added. * LayoutReloaded/test/floating-box-with-clear-simple.html: Added. * LayoutReloaded/test/floating-box-with-new-formatting-context.html: Added. * LayoutReloaded/test/floating-box-with-relative-positioned-sibling.html: Added. * LayoutReloaded/test/floating-left-right-simple.html: Added. * LayoutReloaded/test/floating-left-right-with-all-margins.html: Added. * LayoutReloaded/test/floating-lefts-and-rights-simple.html: Added. * LayoutReloaded/test/floating-multiple-lefts-in-body.html: Added. * LayoutReloaded/test/floating-multiple-lefts-multiple-lines.html: Added. * LayoutReloaded/test/floating-multiple-lefts.html: Added. * LayoutReloaded/test/floating-sizing.html: Added. * LayoutReloaded/test/floating-sizing2.html: Added. * LayoutReloaded/test/floating-sizing3.html: Added. * LayoutReloaded/test/floating-with-new-block-formatting-context.html: Added. * LayoutReloaded/test/index.html: Added. * LayoutReloaded/test/inline-content-simple.html: Added. * LayoutReloaded/test/intruding-left-float-simple.html: Added. * LayoutReloaded/test/margin-collapse-bottom-bottom.html: Added. * LayoutReloaded/test/margin-collapse-bottom-nested.html: Added. * LayoutReloaded/test/margin-collapse-first-last-are-floating.html: Added. * LayoutReloaded/test/margin-collapse-simple.html: Added. * LayoutReloaded/test/margin-collapse-top-nested.html: Added. * LayoutReloaded/test/margin-collapse-when-child-has-padding-border.html: Added. * LayoutReloaded/test/margin-collapse-with-block-formatting-context.html: Added. * LayoutReloaded/test/margin-collapse-with-block-formatting-context2.html: Added. * LayoutReloaded/test/margin-left-right-sizing-out-of-flow.html: Added. * LayoutReloaded/test/margin-left-right-sizing.html: Added. * LayoutReloaded/test/margin-propagation-simple-content-height.html: Added. * LayoutReloaded/test/margin-sibling-collapse-propagated.html: Added. * LayoutReloaded/test/margin-simple.html: Added. * LayoutReloaded/test/negative-margin-simple.html: Added. * LayoutReloaded/test/padding-nested.html: Added. * LayoutReloaded/test/padding-simple.html: Added. * LayoutReloaded/test/relative-auto-with-parent-offset.html: Added. * LayoutReloaded/test/relative-auto.html: Added. * LayoutReloaded/test/relative-bottom.html: Added. * LayoutReloaded/test/relative-right.html: Added. * LayoutReloaded/test/relative-siblings.html: Added. * LayoutReloaded/test/relative-simple.html: Added. Canonical link: https://commits.webkit.org/199175@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229473 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-03-09 19:10:37 +00:00
/*
* 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.
*/
[LayoutReloaded] Update class documentation https://bugs.webkit.org/show_bug.cgi?id=184625 Reviewed by Antti Koivisto. * LayoutReloaded/DisplayTree/Box.js: * LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js: * LayoutReloaded/FormattingContext/BlockFormatting/BlockMarginCollapse.js: * LayoutReloaded/FormattingContext/FloatingContext.js: * LayoutReloaded/FormattingContext/FormattingContext.js: * LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js: * LayoutReloaded/FormattingContext/InlineFormatting/Line.js: * LayoutReloaded/FormattingState/BlockFormattingState.js: * LayoutReloaded/FormattingState/FloatingState.js: * LayoutReloaded/FormattingState/FormattingState.js: * LayoutReloaded/FormattingState/InlineFormattingState.js: * LayoutReloaded/LayoutState.js: * LayoutReloaded/LayoutTree/BlockContainer.js: * LayoutReloaded/LayoutTree/Box.js: * LayoutReloaded/LayoutTree/Container.js: * LayoutReloaded/LayoutTree/InlineBox.js: * LayoutReloaded/LayoutTree/InlineContainer.js: * LayoutReloaded/LayoutTree/Text.js: * LayoutReloaded/misc/headers/BlockContainer.h: Removed. * LayoutReloaded/misc/headers/BlockFormattingContext.h: Removed. * LayoutReloaded/misc/headers/BlockMarginCollapse.h: Removed. * LayoutReloaded/misc/headers/Box.h: Removed. * LayoutReloaded/misc/headers/Container.h: Removed. * LayoutReloaded/misc/headers/FloatingContext.h: Removed. * LayoutReloaded/misc/headers/FormattingContext.h: Removed. * LayoutReloaded/misc/headers/InitialBlockContainer.h: Removed. * LayoutReloaded/misc/headers/InlineBox.h: Removed. * LayoutReloaded/misc/headers/LayoutContext.h: Removed. * LayoutReloaded/misc/headers/Line.h: Removed. * LayoutReloaded/misc/headers/Text.h: Removed. Canonical link: https://commits.webkit.org/200154@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230656 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-04-14 04:48:35 +00:00
/*
class LayoutState {
public:
Container& rootContainer();
FormattingContext& formattingContext(const Layout::Container& formattingRoot);
FormattingState& establishedFormattingState(const Layout::Container& formattingRoot);
FormattingState& formattingStateForBox(const Layout::Box&);
Display::Box* displayBox(const Layout::Box&);
void markNeedsLayout(const Layout::Box&);
bool needsLayout();
};
*/
[LayoutReloaded] Disconnect Display.Box from Layout.Box https://bugs.webkit.org/show_bug.cgi?id=183805 Reviewed by Antti Koivisto. Display.Box is only accessed through the FormattingState. * LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js: (BlockFormattingContext): (BlockFormattingContext.prototype.layout): (BlockFormattingContext.prototype._placeInFlowPositionedChildren): (BlockFormattingContext.prototype._layoutOutOfFlowDescendants): (BlockFormattingContext.prototype._adjustBottomWithFIXME): (BlockFormattingContext.prototype._computeOutOfFlowPosition): * LayoutReloaded/FormattingContext/FormattingContext.js: (FormattingContext): (FormattingContext.prototype.formattingRoot): (FormattingContext.prototype.formattingState): (FormattingContext.prototype.layoutState): (FormattingContext.prototype._toAbsolutePosition): (FormattingContext.prototype._toRootAbsolutePosition): (FormattingContext.prototype._addToLayoutQueue): (FormattingContext.prototype.displayBox): (FormattingContext.prototype._outOfFlowDescendants): (FormattingContext.prototype.rootContainer): Deleted. (FormattingContext.prototype.layoutContext): Deleted. * LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js: (InlineFormattingContext): (InlineFormattingContext.prototype.layout): (InlineFormattingContext.prototype._initializeLine): * LayoutReloaded/FormattingState/BlockFormattingState.js: (BlockFormattingState): * LayoutReloaded/FormattingState/FormattingState.js: (FormattingState): (FormattingState.prototype.formattingRoot): (FormattingState.prototype.layoutState): (FormattingState.prototype.createDisplayBox): (FormattingState.prototype.displayBoxMap): (FormattingState.prototype.displayBox): (FormattingState.prototype.layoutContext): Deleted. * LayoutReloaded/FormattingState/InlineFormattingState.js: (InlineFormattingState): * LayoutReloaded/Layout.js: (layout): * LayoutReloaded/LayoutReloaded.xcworkspace/contents.xcworkspacedata: * LayoutReloaded/LayoutState.js: Renamed from Tools/LayoutReloaded/LayoutContext.js. (LayoutState): (LayoutState.prototype.layout): (LayoutState.prototype._createFormattingState): (LayoutState.prototype.formattingStates): (LayoutState.prototype.initialDisplayBox): * LayoutReloaded/LayoutTree/Box.js: (Layout.Box.prototype.isOutOfFlowPositioned): (Layout.Box.prototype.containingBlock): (Layout.Box.prototype.setDisplayBox): Deleted. (Layout.Box.prototype.displayBox): Deleted. * LayoutReloaded/Utils.js: (Utils.layoutTreeDump): (Utils._findDisplayBox): (Utils._dumpBox): (Utils._dumpTree): * LayoutReloaded/misc/headers/BlockFormattingContext.h: * LayoutReloaded/misc/headers/FormattingContext.h: * LayoutReloaded/misc/headers/LayoutContext.h: * LayoutReloaded/test/index.html: Canonical link: https://commits.webkit.org/199430@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229786 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-03-21 04:42:32 +00:00
class LayoutState {
constructor(rootContainer, rootDisplayBox) {
ASSERT(rootContainer.establishesFormattingContext());
this.m_rootContainer = rootContainer;
this.m_rootDisplayBox = rootDisplayBox;
this.m_formattingStates = new Map();
}
formattingContext(formattingRoot) {
return this._formattingContext(this.establishedFormattingState(formattingRoot));
[LayoutReloaded] Disconnect Display.Box from Layout.Box https://bugs.webkit.org/show_bug.cgi?id=183805 Reviewed by Antti Koivisto. Display.Box is only accessed through the FormattingState. * LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js: (BlockFormattingContext): (BlockFormattingContext.prototype.layout): (BlockFormattingContext.prototype._placeInFlowPositionedChildren): (BlockFormattingContext.prototype._layoutOutOfFlowDescendants): (BlockFormattingContext.prototype._adjustBottomWithFIXME): (BlockFormattingContext.prototype._computeOutOfFlowPosition): * LayoutReloaded/FormattingContext/FormattingContext.js: (FormattingContext): (FormattingContext.prototype.formattingRoot): (FormattingContext.prototype.formattingState): (FormattingContext.prototype.layoutState): (FormattingContext.prototype._toAbsolutePosition): (FormattingContext.prototype._toRootAbsolutePosition): (FormattingContext.prototype._addToLayoutQueue): (FormattingContext.prototype.displayBox): (FormattingContext.prototype._outOfFlowDescendants): (FormattingContext.prototype.rootContainer): Deleted. (FormattingContext.prototype.layoutContext): Deleted. * LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js: (InlineFormattingContext): (InlineFormattingContext.prototype.layout): (InlineFormattingContext.prototype._initializeLine): * LayoutReloaded/FormattingState/BlockFormattingState.js: (BlockFormattingState): * LayoutReloaded/FormattingState/FormattingState.js: (FormattingState): (FormattingState.prototype.formattingRoot): (FormattingState.prototype.layoutState): (FormattingState.prototype.createDisplayBox): (FormattingState.prototype.displayBoxMap): (FormattingState.prototype.displayBox): (FormattingState.prototype.layoutContext): Deleted. * LayoutReloaded/FormattingState/InlineFormattingState.js: (InlineFormattingState): * LayoutReloaded/Layout.js: (layout): * LayoutReloaded/LayoutReloaded.xcworkspace/contents.xcworkspacedata: * LayoutReloaded/LayoutState.js: Renamed from Tools/LayoutReloaded/LayoutContext.js. (LayoutState): (LayoutState.prototype.layout): (LayoutState.prototype._createFormattingState): (LayoutState.prototype.formattingStates): (LayoutState.prototype.initialDisplayBox): * LayoutReloaded/LayoutTree/Box.js: (Layout.Box.prototype.isOutOfFlowPositioned): (Layout.Box.prototype.containingBlock): (Layout.Box.prototype.setDisplayBox): Deleted. (Layout.Box.prototype.displayBox): Deleted. * LayoutReloaded/Utils.js: (Utils.layoutTreeDump): (Utils._findDisplayBox): (Utils._dumpBox): (Utils._dumpTree): * LayoutReloaded/misc/headers/BlockFormattingContext.h: * LayoutReloaded/misc/headers/FormattingContext.h: * LayoutReloaded/misc/headers/LayoutContext.h: * LayoutReloaded/test/index.html: Canonical link: https://commits.webkit.org/199430@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229786 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-03-21 04:42:32 +00:00
}
rootContainer() {
return this.m_rootContainer;
}
establishedFormattingState(formattingRoot) {
ASSERT(formattingRoot.establishesFormattingContext());
let formattingState = this.m_formattingStates.get(formattingRoot);
if (formattingState)
return formattingState;
formattingState = this._createFormattingState(formattingRoot);
this.m_formattingStates.set(formattingRoot, formattingState);
return formattingState;
}
formattingStateForBox(layoutBox) {
for (let formattingEntry of this.m_formattingStates) {
let formattingRoot = formattingEntry[0];
let formattingState = formattingEntry[1];
if (FormattingContext.isInFormattingContext(layoutBox, formattingRoot))
return formattingState;
}
ASSERT_NOT_REACHED();
return null;
}
markNeedsLayout(layoutBox) {
let formattingState = this.formattingStateForBox(layoutBox);
// Newly created formatting state will obviously mark all the boxes dirty.
if (!formattingState)
return;
formattingState.markNeedsLayout(layoutBox);
}
needsLayout() {
for (let formattingEntry of this.m_formattingStates) {
let formattingState = formattingEntry[1];
if (formattingState.layoutNeeded())
return true;
}
return false;
}
displayBox(layoutBox) {
for (let formattingEntry of this.m_formattingStates) {
let formattingState = formattingEntry[1];
let displayBox = formattingState.displayBoxes().get(layoutBox);
if (displayBox)
return displayBox;
}
// It must be the root container.
ASSERT(layoutBox == this.m_rootContainer);
return this.m_rootDisplayBox;
[LayoutReloaded] Disconnect Display.Box from Layout.Box https://bugs.webkit.org/show_bug.cgi?id=183805 Reviewed by Antti Koivisto. Display.Box is only accessed through the FormattingState. * LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js: (BlockFormattingContext): (BlockFormattingContext.prototype.layout): (BlockFormattingContext.prototype._placeInFlowPositionedChildren): (BlockFormattingContext.prototype._layoutOutOfFlowDescendants): (BlockFormattingContext.prototype._adjustBottomWithFIXME): (BlockFormattingContext.prototype._computeOutOfFlowPosition): * LayoutReloaded/FormattingContext/FormattingContext.js: (FormattingContext): (FormattingContext.prototype.formattingRoot): (FormattingContext.prototype.formattingState): (FormattingContext.prototype.layoutState): (FormattingContext.prototype._toAbsolutePosition): (FormattingContext.prototype._toRootAbsolutePosition): (FormattingContext.prototype._addToLayoutQueue): (FormattingContext.prototype.displayBox): (FormattingContext.prototype._outOfFlowDescendants): (FormattingContext.prototype.rootContainer): Deleted. (FormattingContext.prototype.layoutContext): Deleted. * LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js: (InlineFormattingContext): (InlineFormattingContext.prototype.layout): (InlineFormattingContext.prototype._initializeLine): * LayoutReloaded/FormattingState/BlockFormattingState.js: (BlockFormattingState): * LayoutReloaded/FormattingState/FormattingState.js: (FormattingState): (FormattingState.prototype.formattingRoot): (FormattingState.prototype.layoutState): (FormattingState.prototype.createDisplayBox): (FormattingState.prototype.displayBoxMap): (FormattingState.prototype.displayBox): (FormattingState.prototype.layoutContext): Deleted. * LayoutReloaded/FormattingState/InlineFormattingState.js: (InlineFormattingState): * LayoutReloaded/Layout.js: (layout): * LayoutReloaded/LayoutReloaded.xcworkspace/contents.xcworkspacedata: * LayoutReloaded/LayoutState.js: Renamed from Tools/LayoutReloaded/LayoutContext.js. (LayoutState): (LayoutState.prototype.layout): (LayoutState.prototype._createFormattingState): (LayoutState.prototype.formattingStates): (LayoutState.prototype.initialDisplayBox): * LayoutReloaded/LayoutTree/Box.js: (Layout.Box.prototype.isOutOfFlowPositioned): (Layout.Box.prototype.containingBlock): (Layout.Box.prototype.setDisplayBox): Deleted. (Layout.Box.prototype.displayBox): Deleted. * LayoutReloaded/Utils.js: (Utils.layoutTreeDump): (Utils._findDisplayBox): (Utils._dumpBox): (Utils._dumpTree): * LayoutReloaded/misc/headers/BlockFormattingContext.h: * LayoutReloaded/misc/headers/FormattingContext.h: * LayoutReloaded/misc/headers/LayoutContext.h: * LayoutReloaded/test/index.html: Canonical link: https://commits.webkit.org/199430@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229786 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-03-21 04:42:32 +00:00
}
_createFormattingState(formattingRoot) {
ASSERT(formattingRoot.establishesFormattingContext());
if (formattingRoot.establishesInlineFormattingContext())
return new InlineFormattingState(formattingRoot, this);
if (formattingRoot.establishesBlockFormattingContext())
return new BlockFormattingState(formattingRoot, this);
ASSERT_NOT_REACHED();
return null;
}
_formattingContext(formattingState) {
if (formattingState instanceof BlockFormattingState)
return new BlockFormattingContext(formattingState);
if (formattingState instanceof InlineFormattingState)
return new InlineFormattingContext(formattingState);
ASSERT_NOT_REACHED();
return null;
}
[LayoutReloaded] Initial commit -block formatting context. https://bugs.webkit.org/show_bug.cgi?id=183462 Reviewed by Antti Koivisto. See README.md * LayoutReloaded/BlockContainer.js: Added. (BlockContainer): (BlockContainer.prototype.establishesInlineFormattingContext): * LayoutReloaded/BlockFormattingContext.js: Added. (BlockFormattingContext): (BlockFormattingContext.prototype.layout): (BlockFormattingContext.prototype.computeWidth): (BlockFormattingContext.prototype.computeHeight): (BlockFormattingContext.prototype.marginTop): (BlockFormattingContext.prototype.marginBottom): (BlockFormattingContext.prototype._computeStaticPosition): (BlockFormattingContext.prototype._placeInFlowPositionedChildren): (BlockFormattingContext.prototype._placeOutOfFlowDescendants): (BlockFormattingContext.prototype._computeOutOfFlowWidth): (BlockFormattingContext.prototype._computeFloatingWidth): (BlockFormattingContext.prototype._computeInFlowWidth): (BlockFormattingContext.prototype._computeOutOfFlowHeight): (BlockFormattingContext.prototype._computeFloatingHeight): (BlockFormattingContext.prototype._computeInFlowHeight): (BlockFormattingContext.prototype._computeHorizontalConstraint): (BlockFormattingContext.prototype._computeContentHeight): (BlockFormattingContext.prototype._computeInFlowPositionedPosition): (BlockFormattingContext.prototype._computeOutOfFlowPosition): (BlockFormattingContext.prototype._shrinkToFitWidth): * LayoutReloaded/BlockMarginCollapse.js: Added. (BlockMarginCollapse.marginTop): (BlockMarginCollapse.marginBottom): (BlockMarginCollapse._isMarginTopCollapsedWithSibling): (BlockMarginCollapse._isMarginBottomCollapsedWithSibling): (BlockMarginCollapse._isMarginTopCollapsedWithParent): (BlockMarginCollapse._isMarginBottomCollapsedWithParent): (BlockMarginCollapse._nonCollapsedMarginTop): (BlockMarginCollapse._nonCollapsedMarginBottom): (BlockMarginCollapse._collapsedMarginTopFromFirstChild): (BlockMarginCollapse._collapsedMarginBottomFromLastChild): (BlockMarginCollapse._marginValue): (BlockMarginCollapse._hasAdjoiningMarginTopAndBottom): (BlockMarginCollapse): * LayoutReloaded/Box.js: Added. (Box): (Box.prototype.id): (Box.prototype.setRendererName): (Box.prototype.name): (Box.prototype.node): (Box.prototype.parent): (Box.prototype.nextSibling): (Box.prototype.nextInFlowSibling): (Box.prototype.previousSibling): (Box.prototype.previousInFlowSibling): (Box.prototype.setParent): (Box.prototype.setNextSibling): (Box.prototype.setPreviousSibling): (Box.prototype.rect): (Box.prototype.topLeft): (Box.prototype.bottomRight): (Box.prototype.setTopLeft): (Box.prototype.setSize): (Box.prototype.setWidth): (Box.prototype.setHeight): (Box.prototype.isContainer): (Box.prototype.isBlockLevelBox): (Box.prototype.isBlockContainerBox): (Box.prototype.isInlineLevelBox): (Box.prototype.setIsAnonymous): (Box.prototype.isAnonymous): (Box.prototype.establishesFormattingContext): (Box.prototype.establishedFormattingContext): (Box.prototype.establishesBlockFormattingContext): (Box.prototype.establishesInlineFormattingContext): (Box.prototype.isPositioned): (Box.prototype.isRelativePositioned): (Box.prototype.isAbsolutePositioned): (Box.prototype.isFixedPositioned): (Box.prototype.isInFlow): (Box.prototype.isOutOfFlowPositioned): (Box.prototype.isInFlowPositioned): (Box.prototype.isFloatingPositioned): (Box.prototype.isFloatingOrOutOfFlowPositioned): (Box.prototype.isRootElement): (Box.prototype.containingBlock): (Box.prototype.borderBox): (Box.prototype.paddingBox): (Box.prototype.contentBox): * LayoutReloaded/Container.js: Added. (Container): (Container.prototype.isContainer): (Container.prototype.setFirstChild): (Container.prototype.setLastChild): (Container.prototype.firstChild): (Container.prototype.firstInFlowChild): (Container.prototype.lastChild): (Container.prototype.lastInFlowChild): (Container.prototype.hasChild): (Container.prototype.hasInFlowChild): * LayoutReloaded/FloatingContext.js: Added. (FloatingContext): (FloatingContext.prototype.computePosition): (FloatingContext.prototype.bottom): (FloatingContext.prototype._positionForFloating): (FloatingContext.prototype._positionForClear): (FloatingContext.prototype._computePositionToAvoidIntrudingFloats): (FloatingContext.prototype._addFloating): (FloatingContext.prototype._findInnerMostLeftAndRight): (FloatingContext.prototype._moveToNextVerticalPosition): (FloatingContext.prototype._availableSpace): (FloatingContext.prototype._findFloatingAtVerticalPosition): (FloatingContext.prototype._isEmpty): (FloatingContext.prototype._adjustedFloatingPosition): (FloatingContext.prototype._bottom): (FloatingContext.prototype._formattingContext): * LayoutReloaded/FormattingContext.js: Added. (FormattingContext): (FormattingContext.prototype.rootContainer): (FormattingContext.prototype.floatingContext): (FormattingContext.prototype.layout): (FormattingContext.prototype.computeWidth): (FormattingContext.prototype.computeHeight): (FormattingContext.prototype.marginTop): (FormattingContext.prototype.marginLeft): (FormattingContext.prototype.marginBottom): (FormattingContext.prototype.marginRight): (FormattingContext.prototype.absoluteMarginBox): (FormattingContext.prototype.absoluteBorderBox): (FormattingContext.prototype.absolutePaddingBox): (FormattingContext.prototype.absoluteContentBox): * LayoutReloaded/InitialBlockContainer.js: Added. (InitialBlockContainer): (InitialBlockContainer.prototype.establishesBlockFormattingContext): (InitialBlockContainer.prototype.paddingBox): (InitialBlockContainer.prototype.contentBox): * LayoutReloaded/InlineBox.js: Added. (InlineBox): (InlineBox.prototype.setText): (InlineBox.prototype.text): * LayoutReloaded/InlineFormattingContext.js: Added. (InlineFormattingContext): (InlineFormattingContext.prototype.layout): (InlineFormattingContext.prototype._handleInlineBox): (InlineFormattingContext.prototype._handleText): * LayoutReloaded/Layout.js: Added. (layout): * LayoutReloaded/LayoutContext.js: Added. (LayoutContext): (LayoutContext.prototype.layoutFormattingContext): * LayoutReloaded/LayoutReloaded.xcworkspace/contents.xcworkspacedata: Added. * LayoutReloaded/LayoutReloaded.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: Added. * LayoutReloaded/README.md: Added. * LayoutReloaded/Text.js: Added. (Text): * LayoutReloaded/TreeBuilder.js: Added. (TreeBuilder.prototype.createTree): (TreeBuilder.prototype._createAndAttachBox): (TreeBuilder.prototype._appendChild): (TreeBuilder.prototype._findBox): (TreeBuilder.prototype._findNode): (TreeBuilder): * LayoutReloaded/Utils.js: Added. (LayoutPoint): (LayoutPoint.prototype.setLeft): (LayoutPoint.prototype.setTop): (LayoutPoint.prototype.left): (LayoutPoint.prototype.top): (LayoutPoint.prototype.shiftLeft): (LayoutPoint.prototype.shiftTop): (LayoutPoint.prototype.moveBy): (LayoutPoint.prototype.equal): (LayoutPoint.prototype.clone): (LayoutSize): (LayoutSize.prototype.setWidth): (LayoutSize.prototype.setHeight): (LayoutSize.prototype.width): (LayoutSize.prototype.height): (LayoutSize.prototype.growBy): (LayoutSize.prototype.shrinkBy): (LayoutSize.prototype.isEmpty): (LayoutSize.prototype.equal): (LayoutSize.prototype.clone): (LayoutRect): (LayoutRect.prototype.setTop): (LayoutRect.prototype.setLeft): (LayoutRect.prototype.setBottom): (LayoutRect.prototype.setRight): (LayoutRect.prototype.left): (LayoutRect.prototype.top): (LayoutRect.prototype.bottom): (LayoutRect.prototype.right): (LayoutRect.prototype.setTopLeft): (LayoutRect.prototype.topLeft): (LayoutRect.prototype.topRight): (LayoutRect.prototype.bottomRight): (LayoutRect.prototype.setWidth): (LayoutRect.prototype.setHeight): (LayoutRect.prototype.setSize): (LayoutRect.prototype.size): (LayoutRect.prototype.width): (LayoutRect.prototype.height): (LayoutRect.prototype.growBy): (LayoutRect.prototype.shrinkBy): (LayoutRect.prototype.moveBy): (LayoutRect.prototype.isEmpty): (LayoutRect.prototype.equal): (LayoutRect.prototype.intersects): (LayoutRect.prototype.contains): (LayoutRect.prototype.clone): (ASSERT_NOT_REACHED): (ASSERT): (Utils.computedValue): (Utils.propertyIsAuto): (Utils.isWidthAuto): (Utils.isHeightAuto): (Utils.isTopAuto): (Utils.isLeftAuto): (Utils.isBottomAuto): (Utils.isRightAuto): (Utils.width): (Utils.height): (Utils.top): (Utils.bottom): (Utils.left): (Utils.right): (Utils.hasBorderTop): (Utils.hasBorderBottom): (Utils.hasPaddingTop): (Utils.hasPaddingBottom): (Utils.computedMarginTop): (Utils.computedMarginLeft): (Utils.computedMarginBottom): (Utils.computedMarginRight): (Utils.computedBorderTopLeft): (Utils.computedBorderBottomRight): (Utils.computedPaddingTopLeft): (Utils.computedPaddingBottomRight): (Utils.computedBorderAndPaddingTop): (Utils.computedBorderAndPaddingLeft): (Utils.computedBorderAndPaddingBottom): (Utils.computedBorderAndPaddingRight): (Utils.computedHorizontalBorderAndPadding): (Utils.computedVerticalBorderAndPadding): (Utils.hasClear): (Utils.hasClearLeft): (Utils.hasClearRight): (Utils.hasClearBoth): (Utils.isBlockLevelElement): (Utils.isBlockContainerElement): (Utils.isInlineLevelElement): (Utils.isTableElement): (Utils.isRelativePositioned): (Utils.isAbsolutePositioned): (Utils.isFixedPositioned): (Utils.isOverflowVisible): (Utils.isFloatingPositioned): (Utils.isFloatingLeft): (Utils.mapToContainer): (Utils.mapStaticToAbsolute): (Utils.collectOutOfFlowDescendants): (Utils.nextBreakingOpportunity): (Utils.measureText): (Utils.layoutTreeDump): (Utils._dumpBox): (Utils._dumpTree): (Utils): * LayoutReloaded/misc/LayoutReloadedWebKit.patch: Added. * LayoutReloaded/misc/headers/BlockContainer.h: Added. * LayoutReloaded/misc/headers/BlockFormattingContext.h: Added. * LayoutReloaded/misc/headers/BlockMarginCollapse.h: Added. * LayoutReloaded/misc/headers/Box.h: Added. * LayoutReloaded/misc/headers/Container.h: Added. * LayoutReloaded/misc/headers/FloatingContext.h: Added. * LayoutReloaded/misc/headers/FormattingContext.h: Added. * LayoutReloaded/misc/headers/InitialBlockContainer.h: Added. * LayoutReloaded/misc/headers/InlineBox.h: Added. * LayoutReloaded/misc/headers/LayoutContext.h: Added. * LayoutReloaded/misc/headers/Text.h: Added. * LayoutReloaded/test/TestHarness.js: Added. (verifyLayoutTreeDump): (runLayout): * LayoutReloaded/test/absolute-auto-with-sibling-margin-bottom.html: Added. * LayoutReloaded/test/absolute-bottom.html: Added. * LayoutReloaded/test/absolute-height-stretch.html: Added. * LayoutReloaded/test/absolute-left-auto.html: Added. * LayoutReloaded/test/absolute-left-right-top-bottom-auto.html: Added. * LayoutReloaded/test/absolute-nested.html: Added. * LayoutReloaded/test/absolute-nested2.html: Added. * LayoutReloaded/test/absolute-simple.html: Added. * LayoutReloaded/test/absolute-width-shrink-to-fit.html: Added. * LayoutReloaded/test/absolute-width-stretch.html: Added. * LayoutReloaded/test/absolute-with-inline-preferred-width.html: Added. * LayoutReloaded/test/absolute-with-static-block-position-nested.html: Added. * LayoutReloaded/test/almost-intruding-left-float-simple.html: Added. * LayoutReloaded/test/border-simple.html: Added. * LayoutReloaded/test/fixed-nested.html: Added. * LayoutReloaded/test/float-left-when-container-has-padding-margin.html: Added. * LayoutReloaded/test/floating-box-clear-both-simple.html: Added. * LayoutReloaded/test/floating-box-clear-right-simple.html: Added. * LayoutReloaded/test/floating-box-left-and-right-multiple-with-top-offset.html: Added. * LayoutReloaded/test/floating-box-left-and-right-multiple.html: Added. * LayoutReloaded/test/floating-box-right-simple.html: Added. * LayoutReloaded/test/floating-box-with-clear-siblings.html: Added. * LayoutReloaded/test/floating-box-with-clear-simple.html: Added. * LayoutReloaded/test/floating-box-with-new-formatting-context.html: Added. * LayoutReloaded/test/floating-box-with-relative-positioned-sibling.html: Added. * LayoutReloaded/test/floating-left-right-simple.html: Added. * LayoutReloaded/test/floating-left-right-with-all-margins.html: Added. * LayoutReloaded/test/floating-lefts-and-rights-simple.html: Added. * LayoutReloaded/test/floating-multiple-lefts-in-body.html: Added. * LayoutReloaded/test/floating-multiple-lefts-multiple-lines.html: Added. * LayoutReloaded/test/floating-multiple-lefts.html: Added. * LayoutReloaded/test/floating-sizing.html: Added. * LayoutReloaded/test/floating-sizing2.html: Added. * LayoutReloaded/test/floating-sizing3.html: Added. * LayoutReloaded/test/floating-with-new-block-formatting-context.html: Added. * LayoutReloaded/test/index.html: Added. * LayoutReloaded/test/inline-content-simple.html: Added. * LayoutReloaded/test/intruding-left-float-simple.html: Added. * LayoutReloaded/test/margin-collapse-bottom-bottom.html: Added. * LayoutReloaded/test/margin-collapse-bottom-nested.html: Added. * LayoutReloaded/test/margin-collapse-first-last-are-floating.html: Added. * LayoutReloaded/test/margin-collapse-simple.html: Added. * LayoutReloaded/test/margin-collapse-top-nested.html: Added. * LayoutReloaded/test/margin-collapse-when-child-has-padding-border.html: Added. * LayoutReloaded/test/margin-collapse-with-block-formatting-context.html: Added. * LayoutReloaded/test/margin-collapse-with-block-formatting-context2.html: Added. * LayoutReloaded/test/margin-left-right-sizing-out-of-flow.html: Added. * LayoutReloaded/test/margin-left-right-sizing.html: Added. * LayoutReloaded/test/margin-propagation-simple-content-height.html: Added. * LayoutReloaded/test/margin-sibling-collapse-propagated.html: Added. * LayoutReloaded/test/margin-simple.html: Added. * LayoutReloaded/test/negative-margin-simple.html: Added. * LayoutReloaded/test/padding-nested.html: Added. * LayoutReloaded/test/padding-simple.html: Added. * LayoutReloaded/test/relative-auto-with-parent-offset.html: Added. * LayoutReloaded/test/relative-auto.html: Added. * LayoutReloaded/test/relative-bottom.html: Added. * LayoutReloaded/test/relative-right.html: Added. * LayoutReloaded/test/relative-siblings.html: Added. * LayoutReloaded/test/relative-simple.html: Added. Canonical link: https://commits.webkit.org/199175@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229473 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-03-09 19:10:37 +00:00
}