Diff
Modified: trunk/Source/WebCore/ChangeLog (249544 => 249545)
--- trunk/Source/WebCore/ChangeLog 2019-09-05 21:19:32 UTC (rev 249544)
+++ trunk/Source/WebCore/ChangeLog 2019-09-05 21:29:14 UTC (rev 249545)
@@ -1,3 +1,26 @@
+2019-09-05 Zalan Bujtas <za...@apple.com>
+
+ [LFC] LayoutState should not need the initial containing block
+ https://bugs.webkit.org/show_bug.cgi?id=201511
+ <rdar://problem/55079241>
+
+ Reviewed by Antti Koivisto.
+
+ Throw-away layouts should just be able to initialize a dedicated LayoutState without passing in the ICB.
+
+ * layout/LayoutState.cpp:
+ (WebCore::Layout::LayoutState::markNeedsUpdate):
+ (WebCore::Layout::LayoutState::run):
+ (WebCore::Layout::LayoutState::LayoutState): Deleted.
+ * layout/LayoutState.h:
+ (WebCore::Layout::LayoutState::initialContainingBlock const): Deleted.
+ * layout/Verification.cpp:
+ (WebCore::Layout::LayoutState::verifyAndOutputMismatchingLayoutTree const):
+ * layout/floats/FloatingContext.cpp: Fix a (very sad)typo.
+ (WebCore::Layout::FloatingContext::constraints const):
+ * layout/layouttree/LayoutTreeBuilder.cpp:
+ (WebCore::Layout::printLayoutTreeForLiveDocuments):
+
2019-09-05 Justin Fan <justin_...@apple.com>
[WebGPU] Implement GPUUncapturedErrorEvent
Modified: trunk/Source/WebCore/layout/LayoutState.cpp (249544 => 249545)
--- trunk/Source/WebCore/layout/LayoutState.cpp 2019-09-05 21:19:32 UTC (rev 249544)
+++ trunk/Source/WebCore/layout/LayoutState.cpp 2019-09-05 21:29:14 UTC (rev 249545)
@@ -50,26 +50,6 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(LayoutState);
-LayoutState::LayoutState(const Container& initialContainingBlock)
- : m_initialContainingBlock(makeWeakPtr(initialContainingBlock))
-{
- // LayoutState is always initiated with the ICB.
- ASSERT(!initialContainingBlock.parent());
- ASSERT(initialContainingBlock.establishesBlockFormattingContext());
-
- auto& displayBox = displayBoxForLayoutBox(initialContainingBlock);
- displayBox.setHorizontalMargin({ });
- displayBox.setHorizontalComputedMargin({ });
- displayBox.setVerticalMargin({ });
- displayBox.setBorder({ });
- displayBox.setPadding({ });
- displayBox.setTopLeft({ });
- displayBox.setContentBoxHeight(LayoutUnit(initialContainingBlock.style().logicalHeight().value()));
- displayBox.setContentBoxWidth(LayoutUnit(initialContainingBlock.style().logicalWidth().value()));
-
- m_formattingContextRootListForLayout.add(&initialContainingBlock);
-}
-
void LayoutState::updateLayout()
{
PhaseScope scope(Phase::Type::Layout);
@@ -111,8 +91,10 @@
m_formattingContextRootListForLayout.addVoid(invalidationRoot);
}
-void LayoutState::markNeedsUpdate(const Box&, OptionSet<UpdateType>)
+void LayoutState::markNeedsUpdate(const Box& layoutBox, OptionSet<UpdateType>)
{
+ // FIXME: This should trigger proper invalidation instead of just adding the formatting context root to the dirty list.
+ m_formattingContextRootListForLayout.addVoid(&(layoutBox.isInitialContainingBlock() ? downcast<Container>(layoutBox) : layoutBox.formattingContextRoot()));
}
FormattingState& LayoutState::formattingStateForBox(const Box& layoutBox) const
@@ -193,8 +175,21 @@
void LayoutState::run(const RenderView& renderView)
{
+ auto layoutState = LayoutState { };
+
auto initialContainingBlock = TreeBuilder::createLayoutTree(renderView);
- auto layoutState = LayoutState(*initialContainingBlock);
+ layoutState.createFormattingStateForFormattingRootIfNeeded(*initialContainingBlock);
+
+ auto& displayBox = layoutState.displayBoxForLayoutBox(*initialContainingBlock);
+ displayBox.setHorizontalMargin({ });
+ displayBox.setHorizontalComputedMargin({ });
+ displayBox.setVerticalMargin({ });
+ displayBox.setBorder({ });
+ displayBox.setPadding({ });
+ displayBox.setTopLeft({ });
+ displayBox.setContentBoxHeight(LayoutUnit(initialContainingBlock->style().logicalHeight().value()));
+ displayBox.setContentBoxWidth(LayoutUnit(initialContainingBlock->style().logicalWidth().value()));
+
// Not efficient, but this is temporary anyway.
// Collect the out-of-flow descendants at the formatting root level (as opposed to at the containing block level, though they might be the same).
for (auto& descendant : descendantsOfType<Box>(*initialContainingBlock)) {
@@ -212,8 +207,9 @@
return QuirksMode::No;
};
layoutState.setQuirksMode(quirksMode());
+ layoutState.markNeedsUpdate(*initialContainingBlock);
layoutState.updateLayout();
- layoutState.verifyAndOutputMismatchingLayoutTree(renderView);
+ layoutState.verifyAndOutputMismatchingLayoutTree(renderView, *initialContainingBlock);
}
}
Modified: trunk/Source/WebCore/layout/LayoutState.h (249544 => 249545)
--- trunk/Source/WebCore/layout/LayoutState.h 2019-09-05 21:19:32 UTC (rev 249544)
+++ trunk/Source/WebCore/layout/LayoutState.h 2019-09-05 21:29:14 UTC (rev 249545)
@@ -58,8 +58,6 @@
class LayoutState {
WTF_MAKE_ISO_ALLOCATED(LayoutState);
public:
- LayoutState(const Container& initialContainingBlock);
-
// FIXME: This is a temporary entry point for LFC layout.
static void run(const RenderView&);
@@ -71,10 +69,10 @@
enum class UpdateType {
Overflow = 1 << 0,
Position = 1 << 1,
- Size = 1 << 2,
- All = Overflow | Position | Size
+ Size = 1 << 2
};
- void markNeedsUpdate(const Box&, OptionSet<UpdateType>);
+ static constexpr OptionSet<UpdateType> updateAll() { return { UpdateType::Overflow, UpdateType::Position, UpdateType::Size }; }
+ void markNeedsUpdate(const Box&, OptionSet<UpdateType> = updateAll());
bool needsUpdate(const Box&) const;
FormattingState& formattingStateForBox(const Box&) const;
@@ -95,13 +93,11 @@
bool inLimitedQuirksMode() const { return m_quirksMode == QuirksMode::Limited; }
bool inNoQuirksMode() const { return m_quirksMode == QuirksMode::No; }
// For testing purposes only
- void verifyAndOutputMismatchingLayoutTree(const RenderView&) const;
+ void verifyAndOutputMismatchingLayoutTree(const RenderView&, const Container& initialContainingBlock) const;
private:
- const Container& initialContainingBlock() const { return *m_initialContainingBlock; }
void layoutFormattingContextSubtree(const Box&);
- WeakPtr<const Container> m_initialContainingBlock;
HashSet<const Container*> m_formattingContextRootListForLayout;
HashMap<const Box*, std::unique_ptr<FormattingState>> m_formattingStates;
#ifndef NDEBUG
Modified: trunk/Source/WebCore/layout/Verification.cpp (249544 => 249545)
--- trunk/Source/WebCore/layout/Verification.cpp 2019-09-05 21:19:32 UTC (rev 249544)
+++ trunk/Source/WebCore/layout/Verification.cpp 2019-09-05 21:29:14 UTC (rev 249545)
@@ -314,15 +314,15 @@
return mismtachingGeometry;
}
-void LayoutState::verifyAndOutputMismatchingLayoutTree(const RenderView& renderView) const
+void LayoutState::verifyAndOutputMismatchingLayoutTree(const RenderView& renderView, const Container& initialContainingBlock) const
{
TextStream stream;
- auto mismatchingGeometry = verifyAndOutputSubtree(stream, *this, renderView, initialContainingBlock());
+ auto mismatchingGeometry = verifyAndOutputSubtree(stream, *this, renderView, initialContainingBlock);
if (!mismatchingGeometry)
return;
#if ENABLE(TREE_DEBUGGING)
showRenderTree(&renderView);
- showLayoutTree(initialContainingBlock(), this);
+ showLayoutTree(initialContainingBlock, this);
#endif
WTFLogAlways("%s", stream.release().utf8().data());
ASSERT_NOT_REACHED();
Modified: trunk/Source/WebCore/layout/blockformatting/BlockInvalidation.cpp (249544 => 249545)
--- trunk/Source/WebCore/layout/blockformatting/BlockInvalidation.cpp 2019-09-05 21:19:32 UTC (rev 249544)
+++ trunk/Source/WebCore/layout/blockformatting/BlockInvalidation.cpp 2019-09-05 21:29:14 UTC (rev 249545)
@@ -48,14 +48,14 @@
return true;
}
-static LayoutState::UpdateType computeUpdateType(const Box&, StyleDiff, BlockFormattingState&)
+static OptionSet<LayoutState::UpdateType> computeUpdateType(const Box&, StyleDiff, BlockFormattingState&)
{
- return LayoutState::UpdateType::All;
+ return LayoutState::updateAll();
}
-static LayoutState::UpdateType computeUpdateTypeForAncestor(const Container&, StyleDiff, BlockFormattingState&)
+static OptionSet<LayoutState::UpdateType> computeUpdateTypeForAncestor(const Container&, StyleDiff, BlockFormattingState&)
{
- return LayoutState::UpdateType::All;
+ return LayoutState::updateAll();
}
InvalidationResult BlockInvalidation::invalidate(const Box& layoutBox, StyleDiff styleDiff, LayoutState& layoutState,
Modified: trunk/Source/WebCore/layout/floats/FloatingContext.cpp (249544 => 249545)
--- trunk/Source/WebCore/layout/floats/FloatingContext.cpp 2019-09-05 21:19:32 UTC (rev 249544)
+++ trunk/Source/WebCore/layout/floats/FloatingContext.cpp 2019-09-05 21:29:14 UTC (rev 249545)
@@ -295,7 +295,7 @@
Constraints constraints;
auto& floats = floatingState().floats();
- for (auto index = floats.size() - 1; --index;) {
+ for (auto index = floats.size(); index--;) {
auto& floatItem = floats[index];
if (constraints.left && floatItem.isLeftPositioned())
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineInvalidation.cpp (249544 => 249545)
--- trunk/Source/WebCore/layout/inlineformatting/InlineInvalidation.cpp 2019-09-05 21:19:32 UTC (rev 249544)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineInvalidation.cpp 2019-09-05 21:29:14 UTC (rev 249545)
@@ -41,7 +41,7 @@
InvalidationResult InlineInvalidation::invalidate(const Box& layoutBox, StyleDiff, LayoutState& layoutState, InlineFormattingState&)
{
- layoutState.markNeedsUpdate(layoutBox, LayoutState::UpdateType::All);
+ layoutState.markNeedsUpdate(layoutBox);
return { nullptr };
}
Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp (249544 => 249545)
--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp 2019-09-05 21:19:32 UTC (rev 249544)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp 2019-09-05 21:29:14 UTC (rev 249545)
@@ -377,10 +377,10 @@
// FIXME: Need to find a way to output geometry without layout context.
auto& renderView = *document->renderView();
auto initialContainingBlock = TreeBuilder::createLayoutTree(renderView);
- auto layoutState = makeUnique<Layout::LayoutState>(*initialContainingBlock);
- layoutState->setQuirksMode(renderView.document().inLimitedQuirksMode() ? LayoutState::QuirksMode::Limited : (renderView.document().inQuirksMode() ? LayoutState::QuirksMode::Yes : LayoutState::QuirksMode::No));
- layoutState->updateLayout();
- showLayoutTree(*initialContainingBlock, layoutState.get());
+ auto layoutState = LayoutState { };
+ layoutState.setQuirksMode(renderView.document().inLimitedQuirksMode() ? LayoutState::QuirksMode::Limited : (renderView.document().inQuirksMode() ? LayoutState::QuirksMode::Yes : LayoutState::QuirksMode::No));
+ layoutState.updateLayout();
+ showLayoutTree(*initialContainingBlock, &layoutState);
}
}
#endif
Modified: trunk/Source/WebCore/layout/tableformatting/TableInvalidation.cpp (249544 => 249545)
--- trunk/Source/WebCore/layout/tableformatting/TableInvalidation.cpp 2019-09-05 21:19:32 UTC (rev 249544)
+++ trunk/Source/WebCore/layout/tableformatting/TableInvalidation.cpp 2019-09-05 21:29:14 UTC (rev 249545)
@@ -41,7 +41,7 @@
InvalidationResult TableInvalidation::invalidate(const Box& layoutBox, StyleDiff, LayoutState& layoutState, TableFormattingState&)
{
- layoutState.markNeedsUpdate(layoutBox, LayoutState::UpdateType::All);
+ layoutState.markNeedsUpdate(layoutBox);
return { nullptr };
}