Diff
Modified: trunk/Source/WebCore/ChangeLog (268797 => 268798)
--- trunk/Source/WebCore/ChangeLog 2020-10-21 16:15:56 UTC (rev 268797)
+++ trunk/Source/WebCore/ChangeLog 2020-10-21 16:21:04 UTC (rev 268798)
@@ -1,3 +1,53 @@
+2020-10-21 Antti Koivisto <[email protected]>
+
+ [LFC][Integration] Update style of contained layout boxes
+ https://bugs.webkit.org/show_bug.cgi?id=218017
+
+ Reviewed by Zalan Bujtas.
+
+ Update layout box style on style change as needed. This fixes at least fast/replaced/max-width-percent.html with
+ image support enabled.
+
+ The patch also contains refactoring to make BoxTree non-const and moves the style update code there.
+
+ * layout/integration/LayoutIntegrationBoxTree.cpp:
+ (WebCore::LayoutIntegration::BoxTree::BoxTree):
+ (WebCore::LayoutIntegration::BoxTree::buildTree):
+ (WebCore::LayoutIntegration::BoxTree::updateStyle):
+ (WebCore::LayoutIntegration::BoxTree::layoutBoxForRenderer):
+ (WebCore::LayoutIntegration::BoxTree::layoutBoxForRenderer const):
+ (WebCore::LayoutIntegration::BoxTree::rendererForLayoutBox):
+ (WebCore::LayoutIntegration::BoxTree::rendererForLayoutBox const):
+ * layout/integration/LayoutIntegrationBoxTree.h:
+ (WebCore::LayoutIntegration::BoxTree::flow const):
+ (WebCore::LayoutIntegration::BoxTree::flow):
+ * layout/integration/LayoutIntegrationInlineContent.cpp:
+ (WebCore::LayoutIntegration::InlineContent::rendererForLayoutBox const):
+ * layout/integration/LayoutIntegrationInlineContent.h:
+ * layout/integration/LayoutIntegrationLineIteratorModernPath.h:
+ (WebCore::LayoutIntegration::LineIteratorModernPath::logicalStartRunWithNode const):
+ (WebCore::LayoutIntegration::LineIteratorModernPath::logicalEndRunWithNode const):
+ * layout/integration/LayoutIntegrationLineLayout.cpp:
+ (WebCore::LayoutIntegration::LineLayout::LineLayout):
+ (WebCore::LayoutIntegration::LineLayout::containing):
+ (WebCore::LayoutIntegration::LineLayout::updateReplacedDimensions):
+ (WebCore::LayoutIntegration::LineLayout::updateStyle):
+ (WebCore::LayoutIntegration::LineLayout::constructContent):
+ (WebCore::LayoutIntegration::LineLayout::textRunsFor const):
+ (WebCore::LayoutIntegration::LineLayout::runFor const):
+ (WebCore::LayoutIntegration::LineLayout::rendererForLayoutBox const):
+ (WebCore::LayoutIntegration::LineLayout::paint):
+ (WebCore::LayoutIntegration::LineLayout::hitTest):
+ * layout/integration/LayoutIntegrationLineLayout.h:
+ * layout/integration/LayoutIntegrationRunIteratorModernPath.h:
+ (WebCore::LayoutIntegration::RunIteratorModernPath::renderer const):
+ * rendering/RenderBlockFlow.cpp:
+ (WebCore::RenderBlockFlow::styleDidChange):
+ * rendering/RenderBox.cpp:
+ (WebCore::RenderBox::styleDidChange):
+
+ Update the line layout style.
+
2020-10-21 Philippe Normand <[email protected]>
Un-needed casts in Screen::{width,height}()
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp (268797 => 268798)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp 2020-10-21 16:15:56 UTC (rev 268797)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp 2020-10-21 16:21:04 UTC (rev 268798)
@@ -48,18 +48,19 @@
return clonedStyle;
}
-BoxTree::BoxTree(const RenderBlockFlow& flow)
- : m_root(rootBoxStyle(flow.style()))
+BoxTree::BoxTree(RenderBlockFlow& flow)
+ : m_flow(flow)
+ , m_root(rootBoxStyle(flow.style()))
{
if (flow.isAnonymous())
m_root.setIsAnonymous();
- buildTree(flow);
+ buildTree();
}
-void BoxTree::buildTree(const RenderBlockFlow& flow)
+void BoxTree::buildTree()
{
- for (auto& childRenderer : childrenOfType<RenderObject>(flow)) {
+ for (auto& childRenderer : childrenOfType<RenderObject>(m_flow)) {
std::unique_ptr<Layout::Box> childBox;
if (is<RenderText>(childRenderer)) {
auto& textRenderer = downcast<RenderText>(childRenderer);
@@ -82,15 +83,32 @@
}
}
-const Layout::Box* BoxTree::layoutBoxForRenderer(const RenderObject& renderer) const
+void BoxTree::updateStyle(const RenderBoxModelObject& renderer)
{
+ auto& layoutBox = layoutBoxForRenderer(renderer);
+ auto& style = renderer.style();
+
+ layoutBox.updateStyle(style);
+
+ if (&layoutBox == &m_root) {
+ for (auto* child = m_root.firstChild(); child; child = child->nextSibling()) {
+ if (child->isAnonymous())
+ child->updateStyle(RenderStyle::createAnonymousStyleWithDisplay(style, DisplayType::Inline));
+ }
+ }
+}
+
+Layout::Box& BoxTree::layoutBoxForRenderer(const RenderObject& renderer)
+{
+ if (&renderer == &m_flow)
+ return m_root;
+
if (m_boxes.size() <= smallTreeThreshold) {
auto index = m_boxes.findMatching([&](auto& entry) {
return entry.renderer == &renderer;
});
- if (index == notFound)
- return nullptr;
- return m_boxes[index].box.get();
+ ASSERT(index != notFound);
+ return *m_boxes[index].box;
}
if (m_rendererToBoxMap.isEmpty()) {
@@ -97,18 +115,25 @@
for (auto& entry : m_boxes)
m_rendererToBoxMap.add(entry.renderer, entry.box.get());
}
- return m_rendererToBoxMap.get(&renderer);
+ return *m_rendererToBoxMap.get(&renderer);
}
-const RenderObject* BoxTree::rendererForLayoutBox(const Layout::Box& box) const
+const Layout::Box& BoxTree::layoutBoxForRenderer(const RenderObject& renderer) const
{
+ return const_cast<BoxTree&>(*this).layoutBoxForRenderer(renderer);
+}
+
+RenderObject& BoxTree::rendererForLayoutBox(const Layout::Box& box)
+{
+ if (&box == &m_root)
+ return m_flow;
+
if (m_boxes.size() <= smallTreeThreshold) {
auto index = m_boxes.findMatching([&](auto& entry) {
return entry.box.get() == &box;
});
- if (index == notFound)
- return nullptr;
- return m_boxes[index].renderer;
+ ASSERT(index != notFound);
+ return *m_boxes[index].renderer;
}
if (m_boxToRendererMap.isEmpty()) {
@@ -115,11 +140,16 @@
for (auto& entry : m_boxes)
m_boxToRendererMap.add(entry.box.get(), entry.renderer);
}
- return m_boxToRendererMap.get(&box);
+ return *m_boxToRendererMap.get(&box);
}
+const RenderObject& BoxTree::rendererForLayoutBox(const Layout::Box& box) const
+{
+ return const_cast<BoxTree&>(*this).rendererForLayoutBox(box);
}
+
}
+}
#endif
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.h (268797 => 268798)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.h 2020-10-21 16:15:56 UTC (rev 268797)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.h 2020-10-21 16:21:04 UTC (rev 268798)
@@ -34,31 +34,41 @@
namespace WebCore {
class RenderBlockFlow;
+class RenderBoxModelObject;
namespace LayoutIntegration {
class BoxTree {
public:
- BoxTree(const RenderBlockFlow&);
+ BoxTree(RenderBlockFlow&);
+ void updateStyle(const RenderBoxModelObject&);
+
+ const RenderBlockFlow& flow() const { return m_flow; }
+ RenderBlockFlow& flow() { return m_flow; }
+
const Layout::InitialContainingBlock& rootLayoutBox() const { return m_root; }
Layout::InitialContainingBlock& rootLayoutBox() { return m_root; }
- const Layout::Box* layoutBoxForRenderer(const RenderObject&) const;
- const RenderObject* rendererForLayoutBox(const Layout::Box&) const;
+ const Layout::Box& layoutBoxForRenderer(const RenderObject&) const;
+ Layout::Box& layoutBoxForRenderer(const RenderObject&);
+ const RenderObject& rendererForLayoutBox(const Layout::Box&) const;
+ RenderObject& rendererForLayoutBox(const Layout::Box&);
+
private:
- void buildTree(const RenderBlockFlow&);
+ void buildTree();
+ RenderBlockFlow& m_flow;
Layout::InitialContainingBlock m_root;
struct BoxAndRenderer {
- std::unique_ptr<const Layout::Box> box;
- const RenderObject* renderer { nullptr };
+ std::unique_ptr<Layout::Box> box;
+ RenderObject* renderer { nullptr };
};
Vector<BoxAndRenderer, 1> m_boxes;
- mutable HashMap<const RenderObject*, const Layout::Box*> m_rendererToBoxMap;
- mutable HashMap<const Layout::Box*, const RenderObject*> m_boxToRendererMap;
+ HashMap<const RenderObject*, Layout::Box*> m_rendererToBoxMap;
+ HashMap<const Layout::Box*, RenderObject*> m_boxToRendererMap;
};
}
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContent.cpp (268797 => 268798)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContent.cpp 2020-10-21 16:15:56 UTC (rev 268797)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContent.cpp 2020-10-21 16:21:04 UTC (rev 268798)
@@ -61,7 +61,7 @@
return *m_lineLayout;
}
-const RenderObject* InlineContent::rendererForLayoutBox(const Layout::Box& layoutBox) const
+const RenderObject& InlineContent::rendererForLayoutBox(const Layout::Box& layoutBox) const
{
return m_lineLayout->rendererForLayoutBox(layoutBox);
}
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContent.h (268797 => 268798)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContent.h 2020-10-21 16:15:56 UTC (rev 268797)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContent.h 2020-10-21 16:21:04 UTC (rev 268798)
@@ -61,7 +61,7 @@
void shrinkToFit();
const LineLayout& lineLayout() const;
- const RenderObject* rendererForLayoutBox(const Layout::Box&) const;
+ const RenderObject& rendererForLayoutBox(const Layout::Box&) const;
private:
InlineContent(const LineLayout&);
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIteratorModernPath.h (268797 => 268798)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIteratorModernPath.h 2020-10-21 16:15:56 UTC (rev 268797)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIteratorModernPath.h 2020-10-21 16:21:04 UTC (rev 268798)
@@ -99,7 +99,7 @@
auto startIndex = line().firstRunIndex();
auto endIndex = startIndex + line().runCount();
for (auto runIndex = startIndex; runIndex < endIndex; ++runIndex) {
- auto& renderer = *m_inlineContent->rendererForLayoutBox(m_inlineContent->runs[runIndex].layoutBox());
+ auto& renderer = m_inlineContent->rendererForLayoutBox(m_inlineContent->runs[runIndex].layoutBox());
if (renderer.node())
return { *m_inlineContent, runIndex };
}
@@ -111,7 +111,7 @@
auto startIndex = line().firstRunIndex();
auto endIndex = startIndex + line().runCount();
for (auto runIndex = endIndex; runIndex-- > startIndex;) {
- auto& renderer = *m_inlineContent->rendererForLayoutBox(m_inlineContent->runs[runIndex].layoutBox());
+ auto& renderer = m_inlineContent->rendererForLayoutBox(m_inlineContent->runs[runIndex].layoutBox());
if (renderer.node())
return { *m_inlineContent, runIndex };
}
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (268797 => 268798)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp 2020-10-21 16:15:56 UTC (rev 268797)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp 2020-10-21 16:21:04 UTC (rev 268798)
@@ -55,17 +55,31 @@
namespace WebCore {
namespace LayoutIntegration {
-LineLayout::LineLayout(const RenderBlockFlow& flow)
- : m_flow(flow)
- , m_boxTree(flow)
- , m_layoutState(m_flow.document(), rootLayoutBox())
+LineLayout::LineLayout(RenderBlockFlow& flow)
+ : m_boxTree(flow)
+ , m_layoutState(flow.document(), rootLayoutBox())
, m_inlineFormattingState(m_layoutState.ensureInlineFormattingState(rootLayoutBox()))
{
- m_layoutState.setIsIntegratedRootBoxFirstChild(m_flow.parent()->firstChild() == &m_flow);
+ m_layoutState.setIsIntegratedRootBoxFirstChild(flow.parent()->firstChild() == &flow);
}
LineLayout::~LineLayout() = default;
+LineLayout* LineLayout::containing(RenderObject& renderer)
+{
+ if (auto* parent = renderer.parent()) {
+ if (is<RenderBlockFlow>(*parent))
+ return downcast<RenderBlockFlow>(*parent).layoutFormattingContextLineLayout();
+ }
+
+ return nullptr;
+}
+
+const LineLayout* LineLayout::containing(const RenderObject& renderer)
+{
+ return containing(const_cast<RenderObject&>(renderer));
+}
+
bool LineLayout::isEnabled()
{
return RuntimeEnabledFeatures::sharedFeatures().layoutFormattingContextIntegrationEnabled();
@@ -87,23 +101,15 @@
void LineLayout::updateReplacedDimensions(const RenderBox& replaced)
{
- auto& layoutBox = *m_boxTree.layoutBoxForRenderer(replaced);
- auto& replacedBox = const_cast<Layout::ReplacedBox&>(downcast<Layout::ReplacedBox>(layoutBox));
+ auto& layoutBox = m_boxTree.layoutBoxForRenderer(replaced);
+ auto& replacedBox = downcast<Layout::ReplacedBox>(layoutBox);
replacedBox.setContentSizeForIntegration({ replaced.contentLogicalWidth(), replaced.contentLogicalHeight() });
}
-void LineLayout::updateStyle()
+void LineLayout::updateStyle(const RenderBoxModelObject& renderer)
{
- auto& root = rootLayoutBox();
-
- // FIXME: Encapsulate style updates better.
- root.updateStyle(m_flow.style());
-
- for (auto* child = root.firstChild(); child; child = child->nextSibling()) {
- if (child->isAnonymous())
- child->updateStyle(RenderStyle::createAnonymousStyleWithDisplay(root.style(), DisplayType::Inline));
- }
+ m_boxTree.updateStyle(renderer);
}
void LineLayout::layout()
@@ -118,8 +124,8 @@
auto inlineFormattingContext = Layout::InlineFormattingContext { rootLayoutBox(), m_inlineFormattingState };
auto invalidationState = Layout::InvalidationState { };
- auto horizontalConstraints = Layout::HorizontalConstraints { m_flow.borderAndPaddingStart(), m_flow.contentSize().width() };
- auto verticalConstraints = Layout::VerticalConstraints { m_flow.borderAndPaddingBefore(), { } };
+ auto horizontalConstraints = Layout::HorizontalConstraints { flow().borderAndPaddingStart(), flow().contentSize().width() };
+ auto verticalConstraints = Layout::VerticalConstraints { flow().borderAndPaddingBefore(), { } };
inlineFormattingContext.layoutInFlowContent(invalidationState, { horizontalConstraints, verticalConstraints });
constructContent();
@@ -168,9 +174,9 @@
displayInlineContent.runs.append(displayRun);
if (layoutBox.isReplacedBox()) {
- auto& renderer = downcast<RenderBox>(*rendererForLayoutBox(layoutBox));
+ auto& renderer = downcast<RenderBox>(m_boxTree.rendererForLayoutBox(layoutBox));
auto borderBoxLocation = FloatPoint { runRect.x(), runRect.y() + m_layoutState.geometryForBox(layoutBox).marginBefore() };
- const_cast<RenderBox&>(renderer).setLocation(flooredLayoutPoint(borderBoxLocation));
+ renderer.setLocation(flooredLayoutPoint(borderBoxLocation));
}
}
};
@@ -186,10 +192,10 @@
// FIXME: This is where the logical to physical translate should happen.
auto overflowWidth = [&] {
// FIXME: It's the copy of the lets-adjust-overflow-for-the-caret behavior from ComplexLineLayout::addOverflowFromInlineChildren.
- auto endPadding = m_flow.hasOverflowClip() ? m_flow.paddingEnd() : 0_lu;
+ auto endPadding = flow().hasOverflowClip() ? flow().paddingEnd() : 0_lu;
if (!endPadding)
- endPadding = m_flow.endPaddingWidthForCaret();
- if (m_flow.hasOverflowClip() && !endPadding && m_flow.element() && m_flow.element()->isRootEditableElement())
+ endPadding = flow().endPaddingWidthForCaret();
+ if (flow().hasOverflowClip() && !endPadding && flow().element() && flow().element()->isRootEditableElement())
endPadding = 1;
auto lineBoxLogicalWidth = lineBoxLogicalRect.width() + endPadding;
return std::max(line.logicalWidth(), lineBoxLogicalWidth);
@@ -219,10 +225,10 @@
void LineLayout::prepareLayoutState()
{
- m_layoutState.setViewportSize(m_flow.frame().view()->size());
+ m_layoutState.setViewportSize(flow().frame().view()->size());
auto& rootGeometry = m_layoutState.ensureGeometryForBox(rootLayoutBox());
- rootGeometry.setContentBoxWidth(m_flow.contentSize().width());
+ rootGeometry.setContentBoxWidth(flow().contentSize().width());
rootGeometry.setPadding({ { } });
rootGeometry.setBorder({ });
rootGeometry.setHorizontalMargin({ });
@@ -234,10 +240,10 @@
auto& floatingState = m_inlineFormattingState.floatingState();
floatingState.clear();
- if (!m_flow.containsFloats())
+ if (!flow().containsFloats())
return;
- for (auto& floatingObject : *m_flow.floatingObjectSet()) {
+ for (auto& floatingObject : *flow().floatingObjectSet()) {
auto& rect = floatingObject->frameRect();
auto position = floatingObject->type() == FloatingObject::FloatRight
? Layout::FloatingState::FloatItem::Position::Right
@@ -301,10 +307,9 @@
return LayoutUnit { lastLine.rect().y() + lastLine.baseline() };
}
-void LineLayout::adjustForPagination(RenderBlockFlow& flow)
+void LineLayout::adjustForPagination()
{
- ASSERT(&flow == &m_flow);
- auto paginedInlineContent = adjustLinePositionsForPagination(*m_inlineContent, flow);
+ auto paginedInlineContent = adjustLinePositionsForPagination(*m_inlineContent, flow());
if (paginedInlineContent.ptr() == m_inlineContent) {
m_paginatedHeight = { };
return;
@@ -316,14 +321,12 @@
m_inlineContent = WTFMove(paginedInlineContent);
}
-void LineLayout::collectOverflow(RenderBlockFlow& flow)
+void LineLayout::collectOverflow()
{
- ASSERT(&flow == &m_flow);
-
for (auto& line : inlineContent()->lines) {
- flow.addLayoutOverflow(Layout::toLayoutRect(line.scrollableOverflow()));
- if (!flow.hasOverflowClip())
- flow.addVisualOverflow(Layout::toLayoutRect(line.inkOverflow()));
+ flow().addLayoutOverflow(Layout::toLayoutRect(line.scrollableOverflow()));
+ if (!flow().hasOverflowClip())
+ flow().addVisualOverflow(Layout::toLayoutRect(line.inkOverflow()));
}
}
@@ -338,12 +341,11 @@
{
if (!m_inlineContent)
return { };
- auto* layoutBox = m_boxTree.layoutBoxForRenderer(renderText);
- ASSERT(layoutBox);
+ auto& layoutBox = m_boxTree.layoutBoxForRenderer(renderText);
auto firstIndex = [&]() -> Optional<size_t> {
for (size_t i = 0; i < m_inlineContent->runs.size(); ++i) {
- if (&m_inlineContent->runs[i].layoutBox() == layoutBox)
+ if (&m_inlineContent->runs[i].layoutBox() == &layoutBox)
return i;
}
return { };
@@ -359,12 +361,11 @@
{
if (!m_inlineContent)
return { };
- auto* layoutBox = m_boxTree.layoutBoxForRenderer(renderElement);
- ASSERT(layoutBox);
+ auto& layoutBox = m_boxTree.layoutBoxForRenderer(renderElement);
for (size_t i = 0; i < m_inlineContent->runs.size(); ++i) {
auto& run = m_inlineContent->runs[i];
- if (&run.layoutBox() == layoutBox)
+ if (&run.layoutBox() == &layoutBox)
return { RunIteratorModernPath(*m_inlineContent, i) };
}
@@ -371,7 +372,7 @@
return { };
}
-const RenderObject* LineLayout::rendererForLayoutBox(const Layout::Box& layoutBox) const
+const RenderObject& LineLayout::rendererForLayoutBox(const Layout::Box& layoutBox) const
{
return m_boxTree.rendererForLayoutBox(layoutBox);
}
@@ -395,7 +396,7 @@
return;
auto& inlineContent = *m_inlineContent;
- float deviceScaleFactor = m_flow.document().deviceScaleFactor();
+ float deviceScaleFactor = flow().document().deviceScaleFactor();
auto paintRect = paintInfo.rect;
paintRect.moveBy(-paintOffset);
@@ -402,9 +403,9 @@
for (auto& run : inlineContent.runsForRect(paintRect)) {
if (!run.textContent()) {
- auto* renderer = m_boxTree.rendererForLayoutBox(run.layoutBox());
- if (renderer && renderer->isReplaced() && is<RenderBox>(*renderer)) {
- auto& renderBox = const_cast<RenderBox&>(downcast<RenderBox>(*renderer));
+ auto& renderer = m_boxTree.rendererForLayoutBox(run.layoutBox());
+ if (renderer.isReplaced() && is<RenderBox>(renderer)) {
+ auto& renderBox = downcast<RenderBox>(renderer);
if (renderBox.hasSelfPaintingLayer())
continue;
if (!paintInfo.shouldPaintWithinRoot(renderBox))
@@ -449,7 +450,7 @@
TextPainter textPainter(paintInfo.context());
textPainter.setFont(style.fontCascade());
- textPainter.setStyle(computeTextPaintStyle(m_flow.frame(), style, paintInfo));
+ textPainter.setStyle(computeTextPaintStyle(flow().frame(), style, paintInfo));
if (auto* debugShadow = debugTextShadow())
textPainter.setShadow(debugShadow);
@@ -458,7 +459,7 @@
if (!style.textDecorationsInEffect().isEmpty()) {
// FIXME: Use correct RenderText.
- if (auto* textRenderer = childrenOfType<RenderText>(m_flow).first()) {
+ if (auto* textRenderer = childrenOfType<RenderText>(flow()).first()) {
auto painter = TextDecorationPainter { paintInfo.context(), style.textDecorationsInEffect(), *textRenderer, false, style.fontCascade() };
painter.setWidth(rect.width());
painter.paintTextDecoration(textRun, textOrigin, rect.location() + paintOffset);
@@ -489,7 +490,7 @@
if (style.visibility() != Visibility::Visible || style.pointerEvents() == PointerEvents::None)
continue;
- auto& renderer = const_cast<RenderObject&>(*m_boxTree.rendererForLayoutBox(run.layoutBox()));
+ auto& renderer = m_boxTree.rendererForLayoutBox(run.layoutBox());
renderer.updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset));
if (result.addNodeToListBasedTestResult(renderer.nodeForHitTest(), request, locationInContainer, runRect) == HitTestProgress::Stop)
@@ -501,7 +502,7 @@
ShadowData* LineLayout::debugTextShadow()
{
- if (!m_flow.settings().simpleLineLayoutDebugBordersEnabled())
+ if (!flow().settings().simpleLineLayoutDebugBordersEnabled())
return nullptr;
static NeverDestroyed<ShadowData> debugTextShadow(IntPoint(0, 0), 10, 20, ShadowStyle::Normal, true, SRGBA<uint8_t> { 0, 0, 150, 150 });
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h (268797 => 268798)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h 2020-10-21 16:15:56 UTC (rev 268797)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h 2020-10-21 16:21:04 UTC (rev 268798)
@@ -42,6 +42,7 @@
class HitTestResult;
class RenderBlockFlow;
class RenderBox;
+class RenderBoxModelObject;
struct PaintInfo;
namespace LayoutIntegration {
@@ -51,15 +52,18 @@
class LineLayout : public CanMakeWeakPtr<LineLayout> {
WTF_MAKE_FAST_ALLOCATED;
public:
- LineLayout(const RenderBlockFlow&);
+ LineLayout(RenderBlockFlow&);
~LineLayout();
+ static LineLayout* containing(RenderObject&);
+ static const LineLayout* containing(const RenderObject&);
+
static bool isEnabled();
static bool canUseFor(const RenderBlockFlow&);
static bool canUseForAfterStyleChange(const RenderBlockFlow&, StyleDifference);
void updateReplacedDimensions(const RenderBox&);
- void updateStyle();
+ void updateStyle(const RenderBoxModelObject&);
void layout();
LayoutUnit contentLogicalHeight() const;
@@ -68,8 +72,8 @@
LayoutUnit firstLineBaseline() const;
LayoutUnit lastLineBaseline() const;
- void adjustForPagination(RenderBlockFlow&);
- void collectOverflow(RenderBlockFlow&);
+ void adjustForPagination();
+ void collectOverflow();
const InlineContent* inlineContent() const { return m_inlineContent.get(); }
bool isPaginated() const { return !!m_paginatedHeight; }
@@ -80,7 +84,7 @@
TextRunIterator textRunsFor(const RenderText&) const;
RunIterator runFor(const RenderElement&) const;
- const RenderObject* rendererForLayoutBox(const Layout::Box&) const;
+ const RenderObject& rendererForLayoutBox(const Layout::Box&) const;
static void releaseCaches(RenderView&);
@@ -90,12 +94,14 @@
void constructContent();
InlineContent& ensureInlineContent();
+ RenderBlockFlow& flow() { return m_boxTree.flow(); }
+ const RenderBlockFlow& flow() const { return m_boxTree.flow(); }
+
const Layout::ContainerBox& rootLayoutBox() const;
Layout::ContainerBox& rootLayoutBox();
ShadowData* debugTextShadow();
void releaseInlineItemCache();
- const RenderBlockFlow& m_flow;
BoxTree m_boxTree;
Layout::LayoutState m_layoutState;
Layout::InlineFormattingState& m_inlineFormattingState;
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h (268797 => 268798)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h 2020-10-21 16:15:56 UTC (rev 268797)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h 2020-10-21 16:21:04 UTC (rev 268798)
@@ -117,7 +117,7 @@
const RenderObject& renderer() const
{
- return *m_inlineContent->rendererForLayoutBox(run().layoutBox());
+ return m_inlineContent->rendererForLayoutBox(run().layoutBox());
}
void traverseNextTextRun()
Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (268797 => 268798)
--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2020-10-21 16:15:56 UTC (rev 268797)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2020-10-21 16:21:04 UTC (rev 268798)
@@ -2103,15 +2103,15 @@
};
if (shouldInvalidateLineLayoutPath())
invalidateLineLayoutPath();
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+ if (auto* lineLayout = layoutFormattingContextLineLayout())
+ lineLayout->updateStyle(*this);
+#endif
}
if (multiColumnFlow())
updateStylesForColumnChildren();
-
-#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
- if (layoutFormattingContextLineLayout())
- layoutFormattingContextLineLayout()->updateStyle();
-#endif
}
void RenderBlockFlow::updateStylesForColumnChildren()
@@ -2988,7 +2988,7 @@
{
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
if (layoutFormattingContextLineLayout()) {
- layoutFormattingContextLineLayout()->collectOverflow(*this);
+ layoutFormattingContextLineLayout()->collectOverflow();
return;
}
#endif
@@ -3676,7 +3676,7 @@
layoutFormattingContextLineLayout.layout();
if (view().frameView().layoutContext().layoutState()->isPaginated())
- layoutFormattingContextLineLayout.adjustForPagination(*this);
+ layoutFormattingContextLineLayout.adjustForPagination();
auto contentHeight = layoutFormattingContextLineLayout.contentLogicalHeight();
auto contentBoxTop = borderAndPaddingBefore();
Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (268797 => 268798)
--- trunk/Source/WebCore/rendering/RenderBox.cpp 2020-10-21 16:15:56 UTC (rev 268797)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp 2020-10-21 16:21:04 UTC (rev 268798)
@@ -47,6 +47,7 @@
#include "HTMLTextAreaElement.h"
#include "HitTestResult.h"
#include "InlineElementBox.h"
+#include "LayoutIntegrationLineLayout.h"
#include "Page.h"
#include "PaintInfo.h"
#include "RenderBoxFragmentInfo.h"
@@ -407,6 +408,11 @@
// any override content size set by our container, because it would likely be incorrect after the style change.
if (isOutOfFlowPositioned() && parent() && parent()->style().isDisplayFlexibleOrGridBox())
clearOverrideContentSize();
+
+ if (diff == StyleDifference::Layout) {
+ if (auto* lineLayout = LayoutIntegration::LineLayout::containing(*this))
+ lineLayout->updateStyle(*this);
+ }
}
void RenderBox::updateGridPositionAfterStyleChange(const RenderStyle& style, const RenderStyle* oldStyle)