Diff
Modified: trunk/Tools/ChangeLog (230579 => 230580)
--- trunk/Tools/ChangeLog 2018-04-12 16:35:32 UTC (rev 230579)
+++ trunk/Tools/ChangeLog 2018-04-12 17:26:55 UTC (rev 230580)
@@ -1,5 +1,33 @@
2018-04-12 Zalan Bujtas <[email protected]>
+ [LayoutReloaded] Minor cleanup in LayoutSate
+ https://bugs.webkit.org/show_bug.cgi?id=184546
+
+ Reviewed by Antti Koivisto.
+
+ * LayoutReloaded/FormattingContext/FormattingContext.js:
+ (FormattingContext.isInFormattingContext):
+ * LayoutReloaded/FormattingState/FormattingState.js:
+ (FormattingState.prototype.displayBoxes):
+ (FormattingState.prototype.displayBox):
+ (FormattingState.prototype._markSubTreeNeedsLayout):
+ (FormattingState):
+ (FormattingState.prototype.displayBoxMap): Deleted.
+ * LayoutReloaded/LayoutState.js:
+ (LayoutState.prototype.formattingStateForBox):
+ (LayoutState.prototype.needsLayout):
+ (LayoutState.prototype.displayBox):
+ (LayoutState.prototype._createFormattingState):
+ (LayoutState):
+ * LayoutReloaded/LayoutTree/Box.js:
+ (Layout.Box.prototype.isFormattingContextDescendant): Deleted.
+ * LayoutReloaded/LayoutTree/Container.js:
+ (Layout.Container.prototype.isContainingBlockDescendant): Deleted.
+ * LayoutReloaded/Utils.js:
+ (Utils._findDisplayBox):
+
+2018-04-12 Zalan Bujtas <[email protected]>
+
[LayoutReloaded] Introduce needsLayout to InlineFormattingContext
https://bugs.webkit.org/show_bug.cgi?id=184538
Modified: trunk/Tools/LayoutReloaded/FormattingContext/FormattingContext.js (230579 => 230580)
--- trunk/Tools/LayoutReloaded/FormattingContext/FormattingContext.js 2018-04-12 16:35:32 UTC (rev 230579)
+++ trunk/Tools/LayoutReloaded/FormattingContext/FormattingContext.js 2018-04-12 17:26:55 UTC (rev 230580)
@@ -72,6 +72,18 @@
return Utils.computedMarginRight(layoutBox.node());
}
+ static isInFormattingContext(layoutBox, formattingContextRoot) {
+ ASSERT(formattingContextRoot.establishesFormattingContext());
+ // If we hit the "this" while climbing up on the containing block chain and we don't pass a formatting context root -> box is part of this box's formatting context.
+ for (let containingBlock = layoutBox.containingBlock(); containingBlock; containingBlock = containingBlock.containingBlock()) {
+ if (containingBlock == formattingContextRoot)
+ return true;
+ if (containingBlock.establishesFormattingContext())
+ return false;
+ }
+ return false;
+ }
+
_descendantNeedsLayout() {
return this.m_layoutStack.length;
}
Modified: trunk/Tools/LayoutReloaded/FormattingState/FormattingState.js (230579 => 230580)
--- trunk/Tools/LayoutReloaded/FormattingState/FormattingState.js 2018-04-12 16:35:32 UTC (rev 230579)
+++ trunk/Tools/LayoutReloaded/FormattingState/FormattingState.js 2018-04-12 17:26:55 UTC (rev 230580)
@@ -62,7 +62,7 @@
return displayBox;
}
- displayBoxMap() {
+ displayBoxes() {
return this.m_displayToLayout;
}
@@ -71,22 +71,12 @@
// 1. Normally we only need to access boxes within the same formatting context
// 2. In some cases we need size information about the root container -which is in the parent formatting context
// 3. In inline formatting with parent floating state, we need display boxes from the parent formatting context
- // 3. In rare cases (statically positioned out-of-flow box), we need position information on sibling formatting context
+ // 4. In rare cases (statically positioned out-of-flow box), we need position information on sibling formatting context
// but in all cases it needs to be a descendant of the root container (or the container itself)
- // ASSERT(layoutBox == this.formattingRoot() || layoutBox.isDescendantOf(this.formattingRoot()));
let displayBox = this.m_displayToLayout.get(layoutBox);
if (displayBox)
return displayBox;
-
- let formattingStates = this.layoutState().formattingStates();
- for (let formattingState of formattingStates) {
- let displayBox = formattingState[1].displayBoxMap().get(layoutBox);
- if (displayBox)
- return displayBox;
- }
- // It must be the ICB.
- ASSERT(!layoutBox.parent());
- return this.layoutState().initialDisplayBox();
+ return this.layoutState().displayBox(layoutBox);
}
markNeedsLayout(layoutBox) {
@@ -110,7 +100,7 @@
if (!subTreeRoot)
return;
// Only mark children that actually belong to this formatting context/state.
- if (this.formattingRoot().isFormattingContextDescendant(subTreeRoot))
+ if (FormattingContext.isInFormattingContext(subTreeRoot, this.formattingRoot()))
this.markNeedsLayout(subTreeRoot);
if (!subTreeRoot.isContainer() || !subTreeRoot.hasChild())
return;
Modified: trunk/Tools/LayoutReloaded/LayoutState.js (230579 => 230580)
--- trunk/Tools/LayoutReloaded/LayoutState.js 2018-04-12 16:35:32 UTC (rev 230579)
+++ trunk/Tools/LayoutReloaded/LayoutState.js 2018-04-12 17:26:55 UTC (rev 230580)
@@ -35,16 +35,6 @@
this.formattingContext(formattingState).layout();
}
- _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);
@@ -64,9 +54,11 @@
}
formattingStateForBox(layoutBox) {
- for (let formattingState of this.formattingStates()) {
- if (formattingState[0].isFormattingContextDescendant(layoutBox))
- return formattingState[1];
+ for (let formattingEntry of this.formattingStates()) {
+ let formattingRoot = formattingEntry[0];
+ let formattingState = formattingEntry[1];
+ if (FormattingContext.isInFormattingContext(layoutBox, formattingRoot))
+ return formattingState;
}
ASSERT_NOT_REACHED();
return null;
@@ -81,14 +73,38 @@
}
needsLayout() {
- for (let formattingState of this.formattingStates()) {
- if (formattingState[1].layoutNeeded())
+ for (let formattingEntry of this.formattingStates()) {
+ let formattingState = formattingEntry[1];
+ if (formattingState.layoutNeeded())
return true;
}
return false;
}
+ displayBox(layoutBox) {
+ for (let formattingEntry of this.formattingStates()) {
+ let formattingState = formattingEntry[1];
+ let displayBox = formattingState.displayBoxes().get(layoutBox);
+ if (displayBox)
+ return displayBox;
+ }
+ // It must be the ICB.
+ ASSERT(!layoutBox.parent());
+ return this.initialDisplayBox();
+ }
+
initialDisplayBox() {
return this.m_initialDisplayBox;
}
+
+ _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;
+ }
+
}
Modified: trunk/Tools/LayoutReloaded/LayoutTree/Box.js (230579 => 230580)
--- trunk/Tools/LayoutReloaded/LayoutTree/Box.js 2018-04-12 16:35:32 UTC (rev 230579)
+++ trunk/Tools/LayoutReloaded/LayoutTree/Box.js 2018-04-12 17:26:55 UTC (rev 230580)
@@ -165,18 +165,6 @@
return false;
}
- isFormattingContextDescendant(layoutBox) {
- ASSERT(this.establishesFormattingContext());
- // If we hit the "this" while climbing up on the containing block chain and we don't pass a formatting context root -> box is part of this box's formatting context.
- for (let containingBlock = layoutBox.containingBlock(); containingBlock; containingBlock = containingBlock.containingBlock()) {
- if (containingBlock == this)
- return true;
- if (containingBlock.establishesFormattingContext())
- return false;
- }
- return false;
- }
-
isPositioned() {
return this.isOutOfFlowPositioned() || this.isRelativelyPositioned();
}
Modified: trunk/Tools/LayoutReloaded/LayoutTree/Container.js (230579 => 230580)
--- trunk/Tools/LayoutReloaded/LayoutTree/Container.js 2018-04-12 16:35:32 UTC (rev 230579)
+++ trunk/Tools/LayoutReloaded/LayoutTree/Container.js 2018-04-12 17:26:55 UTC (rev 230580)
@@ -85,18 +85,6 @@
return !!this.firstInFlowOrFloatChild();
}
- isContainingBlockDescendant(layoutBox) {
- ASSERT(layoutBox);
- // If we hit the "this" while climbing up on the containing block chain -> box is part of this box's containing block subtree.
- let containingBlock = layoutBox.containingBlock();
- while (containingBlock) {
- if (containingBlock == this)
- return true;
- containingBlock = containingBlock.containingBlock();
- }
- return false;
- }
-
outOfFlowDescendants() {
if (!this.isPositioned())
return new Array();
Modified: trunk/Tools/LayoutReloaded/Utils.js (230579 => 230580)
--- trunk/Tools/LayoutReloaded/Utils.js 2018-04-12 16:35:32 UTC (rev 230579)
+++ trunk/Tools/LayoutReloaded/Utils.js 2018-04-12 17:26:55 UTC (rev 230580)
@@ -554,8 +554,9 @@
}
static _findDisplayBox(layoutState, box) {
- for (let formattingState of layoutState.formattingStates()) {
- let displayBox = formattingState[1].displayBoxMap().get(box);
+ for (let formattingEntry of layoutState.formattingStates()) {
+ let formattingState = formattingEntry[1];
+ let displayBox = formattingState.displayBoxes().get(box);
if (displayBox)
return displayBox;
}