Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (282661 => 282662)
--- trunk/Source/WebCore/CMakeLists.txt 2021-09-17 15:01:00 UTC (rev 282661)
+++ trunk/Source/WebCore/CMakeLists.txt 2021-09-17 15:03:12 UTC (rev 282662)
@@ -112,7 +112,7 @@
"${WEBCORE_DIR}/layout/formattingContexts/flex"
"${WEBCORE_DIR}/layout/floats"
"${WEBCORE_DIR}/layout/formattingContexts/inline"
- "${WEBCORE_DIR}/layout/formattingContexts/invalidation"
+ "${WEBCORE_DIR}/layout/formattingContexts/inline/invalidation"
"${WEBCORE_DIR}/layout/formattingContexts/inline/text"
"${WEBCORE_DIR}/layout/integration"
"${WEBCORE_DIR}/layout/layouttree"
Modified: trunk/Source/WebCore/ChangeLog (282661 => 282662)
--- trunk/Source/WebCore/ChangeLog 2021-09-17 15:01:00 UTC (rev 282661)
+++ trunk/Source/WebCore/ChangeLog 2021-09-17 15:03:12 UTC (rev 282662)
@@ -1,3 +1,33 @@
+2021-09-17 Alan Bujtas <[email protected]>
+
+ [LFC][Integration] Start using InlineInvalidation to clean runs and lines
+ https://bugs.webkit.org/show_bug.cgi?id=229294
+ <rdar://problem/82395169>
+
+ Reviewed by Antti Koivisto.
+
+ This patch is in preparation for supporting partial line layout.
+ No change in functionality yet.
+
+ * layout/formattingContexts/inline/InlineFormattingContext.cpp:
+ (WebCore::Layout::InlineFormattingContext::InlineFormattingContext):
+ (WebCore::Layout::InlineFormattingContext::invalidateFormattingState):
+ * layout/formattingContexts/inline/InlineFormattingContext.h:
+ * layout/formattingContexts/inline/InlineFormattingState.h:
+ (WebCore::Layout::InlineFormattingState::clearInlineItems):
+ * layout/integration/LayoutIntegrationLineLayout.cpp:
+ (WebCore::LayoutIntegration::LineLayout::updateStyle):
+ (WebCore::LayoutIntegration::LineLayout::layout):
+ (WebCore::LayoutIntegration::LineLayout::prepareLayoutState):
+ (WebCore::LayoutIntegration::LineLayout::ensureLineDamage):
+ * layout/integration/LayoutIntegrationLineLayout.h:
+ * rendering/RenderBlockFlow.cpp:
+ (WebCore::RenderBlockFlow::styleDidChange): The initial styleDidChange (when oldStyle is nullptr) does not go through the integration codepath.
+ * rendering/RenderBox.cpp:
+ (WebCore::RenderBox::styleDidChange):
+ * rendering/RenderInline.cpp:
+ (WebCore::RenderInline::styleDidChange):
+
2021-09-17 Antti Koivisto <[email protected]>
[LFC][Integration] Add some useful functions to iterators
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp (282661 => 282662)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp 2021-09-17 15:01:00 UTC (rev 282661)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp 2021-09-17 15:03:12 UTC (rev 282662)
@@ -30,6 +30,7 @@
#include "FloatingContext.h"
#include "FontCascade.h"
+#include "InlineDamage.h"
#include "InlineDisplayContentBuilder.h"
#include "InlineFormattingState.h"
#include "InlineLineBox.h"
@@ -55,8 +56,9 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(InlineFormattingContext);
-InlineFormattingContext::InlineFormattingContext(const ContainerBox& formattingContextRoot, InlineFormattingState& formattingState)
+InlineFormattingContext::InlineFormattingContext(const ContainerBox& formattingContextRoot, InlineFormattingState& formattingState, const InlineDamage* lineDamage)
: FormattingContext(formattingContextRoot, formattingState)
+ , m_lineDamage(lineDamage)
, m_inlineFormattingGeometry(*this)
, m_inlineFormattingQuirks(*this)
{
@@ -584,10 +586,26 @@
void InlineFormattingContext::invalidateFormattingState()
{
- // Find out what we need to invalidate. This is where we add some smarts to do partial line layout.
- // For now let's just clear the runs.
- formattingState().clearLineAndRuns();
- // FIXME: This is also where we would delete inline items if their content changed.
+ if (!m_lineDamage) {
+ // Non-empty formatting state with no damage means we are trying to layout a clean tree.
+ // FIXME: Add ASSERT(formattingState().inlineItems().isEmpty()) when all the codepaths are covered.
+ formattingState().clearLineAndRuns();
+ return;
+ }
+ // FIXME: Lines and runs are moved out to under Integration::InlineContent in the integration codepath, so clearLineAndRuns is no-op.
+ switch (m_lineDamage->type()) {
+ case InlineDamage::Type::NeedsContentUpdateAndLineLayout:
+ formattingState().clearInlineItems();
+ FALLTHROUGH;
+ case InlineDamage::Type::NeedsLineLayout:
+ formattingState().clearLineAndRuns();
+ break;
+ case InlineDamage::Type::NeedsVerticalAdjustment:
+ case InlineDamage::Type::NeedsHorizontalAdjustment:
+ default:
+ ASSERT_NOT_IMPLEMENTED_YET();
+ break;
+ }
}
}
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.h (282661 => 282662)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.h 2021-09-17 15:01:00 UTC (rev 282661)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.h 2021-09-17 15:03:12 UTC (rev 282662)
@@ -37,6 +37,7 @@
namespace WebCore {
namespace Layout {
+class InlineDamage;
class InlineFormattingState;
class LineBox;
@@ -45,7 +46,7 @@
class InlineFormattingContext final : public FormattingContext {
WTF_MAKE_ISO_ALLOCATED(InlineFormattingContext);
public:
- InlineFormattingContext(const ContainerBox& formattingContextRoot, InlineFormattingState&);
+ InlineFormattingContext(const ContainerBox& formattingContextRoot, InlineFormattingState&, const InlineDamage* = nullptr);
void layoutInFlowContent(const ConstraintsForInFlowContent&) override;
LayoutUnit usedContentHeight() const override;
@@ -74,6 +75,7 @@
InlineRect computeGeometryForLineContent(const LineBuilder::LineContent&);
void invalidateFormattingState();
+ const InlineDamage* m_lineDamage { nullptr };
const InlineFormattingGeometry m_inlineFormattingGeometry;
const InlineFormattingQuirks m_inlineFormattingQuirks;
};
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingState.h (282661 => 282662)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingState.h 2021-09-17 15:01:00 UTC (rev 282661)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingState.h 2021-09-17 15:03:12 UTC (rev 282662)
@@ -67,6 +67,7 @@
void setClearGapAfterLastLine(InlineLayoutUnit verticalGap);
InlineLayoutUnit clearGapAfterLastLine() const { return m_clearGapAfterLastLine; }
+ void clearInlineItems() { m_inlineItems.clear(); }
void clearLineAndRuns();
void shrinkToFit();
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (282661 => 282662)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp 2021-09-17 15:01:00 UTC (rev 282661)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp 2021-09-17 15:03:12 UTC (rev 282662)
@@ -33,8 +33,10 @@
#include "HitTestLocation.h"
#include "HitTestRequest.h"
#include "HitTestResult.h"
+#include "InlineDamage.h"
#include "InlineFormattingContext.h"
#include "InlineFormattingState.h"
+#include "InlineInvalidation.h"
#include "LayoutBoxGeometry.h"
#include "LayoutIntegrationCoverage.h"
#include "LayoutIntegrationInlineContentBuilder.h"
@@ -197,8 +199,11 @@
boxGeometry.setVerticalMargin({ });
}
-void LineLayout::updateStyle(const RenderBoxModelObject& renderer)
+void LineLayout::updateStyle(const RenderBoxModelObject& renderer, const RenderStyle& oldStyle)
{
+ auto invalidation = Layout::InlineInvalidation { ensureLineDamage() };
+ invalidation.styleChanged(m_boxTree.layoutBoxForRenderer(renderer), oldStyle);
+
m_boxTree.updateStyle(renderer);
}
@@ -211,9 +216,10 @@
prepareLayoutState();
prepareFloatingState();
+ // FIXME: Do not clear the lines and runs here unconditionally, but consult with the damage object instead.
m_inlineContent = nullptr;
auto& rootGeometry = m_layoutState.geometryForBox(rootLayoutBox);
- auto inlineFormattingContext = Layout::InlineFormattingContext { rootLayoutBox, m_inlineFormattingState };
+ auto inlineFormattingContext = Layout::InlineFormattingContext { rootLayoutBox, m_inlineFormattingState, m_lineDamage.get() };
auto horizontalConstraints = Layout::HorizontalConstraints { rootGeometry.contentBoxLeft(), rootGeometry.contentBoxWidth() };
@@ -220,6 +226,8 @@
inlineFormattingContext.lineLayoutForIntergration({ horizontalConstraints, rootGeometry.contentBoxTop() });
constructContent();
+
+ m_lineDamage = { };
}
void LineLayout::constructContent()
@@ -248,6 +256,9 @@
auto& flow = this->flow();
m_layoutState.setViewportSize(flow.frame().view()->size());
+ // FIXME: Turn prepareLayoutState to a setter and call it when the flow size changes so that we can do proper invalidation and not "force-constructing" the line damage object here.
+ ensureLineDamage();
+
auto& rootGeometry = m_layoutState.ensureGeometryForBox(rootLayoutBox());
rootGeometry.setContentBoxWidth(flow.contentSize().width());
rootGeometry.setPadding(Layout::Edges { { flow.paddingStart(), flow.paddingEnd() }, { flow.paddingBefore(), flow.paddingAfter() } });
@@ -626,6 +637,13 @@
}
}
+Layout::InlineDamage& LineLayout::ensureLineDamage()
+{
+ if (!m_lineDamage)
+ m_lineDamage = makeUnique<Layout::InlineDamage>();
+ return *m_lineDamage;
+}
+
#if ENABLE(TREE_DEBUGGING)
void LineLayout::outputLineTree(WTF::TextStream& stream, size_t depth) const
{
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h (282661 => 282662)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h 2021-09-17 15:01:00 UTC (rev 282661)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h 2021-09-17 15:03:12 UTC (rev 282662)
@@ -49,6 +49,10 @@
class RenderLineBreak;
struct PaintInfo;
+namespace Layout {
+class InlineDamage;
+}
+
namespace LayoutIntegration {
struct InlineContent;
@@ -73,7 +77,7 @@
void updateInlineBlockDimensions(const RenderBlock&);
void updateLineBreakBoxDimensions(const RenderLineBreak&);
void updateInlineBoxDimensions(const RenderInline&);
- void updateStyle(const RenderBoxModelObject&);
+ void updateStyle(const RenderBoxModelObject&, const RenderStyle& oldStyle);
void layout();
LayoutUnit contentLogicalHeight() const;
@@ -120,6 +124,8 @@
void paintTextRunUsingPhysicalCoordinates(PaintInfo&, const LayoutPoint& paintOffset, const Line&, const Layout::Run&);
+ Layout::InlineDamage& ensureLineDamage();
+
const Layout::ContainerBox& rootLayoutBox() const;
Layout::ContainerBox& rootLayoutBox();
void releaseCaches();
@@ -127,6 +133,8 @@
BoxTree m_boxTree;
Layout::LayoutState m_layoutState;
Layout::InlineFormattingState& m_inlineFormattingState;
+ // FIXME: This should be part of LayoutState.
+ std::unique_ptr<Layout::InlineDamage> m_lineDamage;
RefPtr<InlineContent> m_inlineContent;
std::optional<LayoutUnit> m_paginatedHeight;
};
Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (282661 => 282662)
--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2021-09-17 15:01:00 UTC (rev 282661)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2021-09-17 15:03:12 UTC (rev 282662)
@@ -2146,7 +2146,7 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
if (auto* lineLayout = modernLineLayout())
- lineLayout->updateStyle(*this);
+ lineLayout->updateStyle(*this, *oldStyle);
#endif
if (multiColumnFlow())
Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (282661 => 282662)
--- trunk/Source/WebCore/rendering/RenderBox.cpp 2021-09-17 15:01:00 UTC (rev 282661)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp 2021-09-17 15:03:12 UTC (rev 282662)
@@ -414,7 +414,7 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
if (auto* lineLayout = LayoutIntegration::LineLayout::containing(*this))
- lineLayout->updateStyle(*this);
+ lineLayout->updateStyle(*this, *oldStyle);
#endif
}
Modified: trunk/Source/WebCore/rendering/RenderInline.cpp (282661 => 282662)
--- trunk/Source/WebCore/rendering/RenderInline.cpp 2021-09-17 15:01:00 UTC (rev 282661)
+++ trunk/Source/WebCore/rendering/RenderInline.cpp 2021-09-17 15:03:12 UTC (rev 282662)
@@ -193,7 +193,7 @@
if (auto* container = LayoutIntegration::LineLayout::blockContainer(*this))
container->invalidateLineLayoutPath();
} else
- lineLayout->updateStyle(*this);
+ lineLayout->updateStyle(*this, *oldStyle);
}
#endif
}