Diff
Modified: trunk/Source/WTF/ChangeLog (283157 => 283158)
--- trunk/Source/WTF/ChangeLog 2021-09-28 05:17:12 UTC (rev 283157)
+++ trunk/Source/WTF/ChangeLog 2021-09-28 05:24:42 UTC (rev 283158)
@@ -1,3 +1,18 @@
+2021-09-27 Antti Koivisto <[email protected]>
+
+ [LFC] Use CheckedRef/Ptr instead of WeakPtr
+ https://bugs.webkit.org/show_bug.cgi?id=230821
+
+ Reviewed by Alan Bujtas.
+
+ * wtf/CheckedRef.h:
+ (WTF::CanMakeCheckedPtrBase::incrementPtrCount const):
+ (WTF::CanMakeCheckedPtrBase::decrementPtrCount const):
+ (WTF::CanMakeCheckedPtrBase::incrementPtrCount): Deleted.
+ (WTF::CanMakeCheckedPtrBase::decrementPtrCount): Deleted.
+
+ Make const so CheckedPtr<const Foo> works.
+
2021-09-27 Jean-Yves Avenard <[email protected]>
Vorbis decoder can't be instantiated - Remove workaround added in bug 228139
Modified: trunk/Source/WTF/wtf/CheckedRef.h (283157 => 283158)
--- trunk/Source/WTF/wtf/CheckedRef.h 2021-09-28 05:17:12 UTC (rev 283157)
+++ trunk/Source/WTF/wtf/CheckedRef.h 2021-09-28 05:24:42 UTC (rev 283158)
@@ -230,11 +230,11 @@
~CanMakeCheckedPtrBase() { RELEASE_ASSERT(!m_count); }
PtrCounterType ptrCount() const { return m_count; }
- void incrementPtrCount() { ++m_count; }
- void decrementPtrCount() { ASSERT(m_count); --m_count; }
+ void incrementPtrCount() const { ++m_count; }
+ void decrementPtrCount() const { ASSERT(m_count); --m_count; }
private:
- StorageType m_count { 0 };
+ mutable StorageType m_count { 0 };
};
template <typename IntegralType>
Modified: trunk/Source/WebCore/ChangeLog (283157 => 283158)
--- trunk/Source/WebCore/ChangeLog 2021-09-28 05:17:12 UTC (rev 283157)
+++ trunk/Source/WebCore/ChangeLog 2021-09-28 05:24:42 UTC (rev 283158)
@@ -1,3 +1,78 @@
+2021-09-27 Antti Koivisto <[email protected]>
+
+ [LFC] Use CheckedRef/Ptr instead of WeakPtr
+ https://bugs.webkit.org/show_bug.cgi?id=230821
+
+ Reviewed by Alan Bujtas.
+
+ WeakPtrs are used for layout boxes for safety only. Replace with simpler, faster CheckedPtr.
+
+ * display/DisplayTreeBuilder.cpp:
+ (WebCore::Display::TreeBuilder::build):
+ * editing/TextManipulationController.cpp:
+ (WebCore::TextManipulationController::replace):
+
+ This was leaving a text iterator in stack while mutating the render tree.
+
+ * layout/FormattingState.h:
+ (WebCore::Layout::FormattingState::addOutOfFlowBox):
+ * layout/LayoutState.cpp:
+ (WebCore::Layout::LayoutState::LayoutState):
+ (WebCore::Layout::LayoutState::formattingStateForFormattingContext const):
+ (WebCore::Layout::LayoutState::formattingStateForInlineFormattingContext const):
+ (WebCore::Layout::LayoutState::ensureInlineFormattingState):
+ * layout/LayoutState.h:
+ (WebCore::Layout::LayoutState::root const):
+ (WebCore::Layout::LayoutState::hasRoot const): Deleted.
+ * layout/floats/FloatAvoider.h:
+ * layout/floats/FloatingState.cpp:
+ (WebCore::Layout::FloatingState::FloatItem::FloatItem):
+ (WebCore::Layout::FloatingState::FloatingState):
+ * layout/floats/FloatingState.h:
+ (WebCore::Layout::FloatingState::root const):
+ * layout/formattingContexts/FormattingContext.cpp:
+ (WebCore::Layout::FormattingContext::FormattingContext):
+ (WebCore::Layout::FormattingContext::layoutOutOfFlowContent):
+ * layout/formattingContexts/FormattingContext.h:
+ (WebCore::Layout::FormattingContext::root const):
+ * layout/formattingContexts/block/BlockFormattingState.h:
+ * layout/formattingContexts/inline/InlineFormattingContext.cpp:
+ (WebCore::Layout::InlineFormattingContext::computeStaticPositionForOutOfFlowContent):
+ * layout/formattingContexts/inline/InlineLevelBox.h:
+ (WebCore::Layout::InlineLevelBox::layoutBox const):
+ (WebCore::Layout::InlineLevelBox::InlineLevelBox):
+ * layout/formattingContexts/inline/InlineLineBox.h:
+ * layout/formattingContexts/inline/display/InlineDisplayBox.h:
+ (WebCore::InlineDisplay::Box::layoutBox const):
+ (WebCore::InlineDisplay::Box::Box):
+ * layout/formattingContexts/table/TableGrid.cpp:
+ (WebCore::Layout::TableGrid::Column::Column):
+ (WebCore::Layout::TableGrid::Row::Row):
+ (WebCore::Layout::TableGrid::Cell::Cell):
+ * layout/formattingContexts/table/TableGrid.h:
+ (WebCore::Layout::TableGrid::Row::box const):
+ * layout/integration/LayoutIntegrationBoxTree.cpp:
+ (WebCore::LayoutIntegration::BoxTree::buildTree):
+ (WebCore::LayoutIntegration::BoxTree::appendChild):
+ (WebCore::LayoutIntegration::BoxTree::layoutBoxForRenderer):
+ (WebCore::LayoutIntegration::BoxTree::rendererForLayoutBox):
+ * layout/integration/LayoutIntegrationBoxTree.h:
+ * layout/integration/LayoutIntegrationInlineContent.cpp:
+ (WebCore::LayoutIntegration::InlineContent::InlineContent):
+ (WebCore::LayoutIntegration::InlineContent::rendererForLayoutBox const):
+ (WebCore::LayoutIntegration::InlineContent::containingBlock const):
+ (WebCore::LayoutIntegration::InlineContent::lineLayout const): Deleted.
+ * layout/integration/LayoutIntegrationInlineContent.h:
+ (WebCore::LayoutIntegration::InlineContent::lineLayout const):
+ * layout/integration/LayoutIntegrationLineLayout.cpp:
+ (WebCore::LayoutIntegration::LineLayout::constructContent):
+ * layout/integration/LayoutIntegrationLineLayout.h:
+ * layout/layouttree/LayoutBox.cpp:
+ (WebCore::Layout::Box::setCachedGeometryForLayoutState const):
+ * layout/layouttree/LayoutBox.h:
+ * layout/layouttree/LayoutReplacedBox.h:
+ * layout/layouttree/LayoutTreeBuilder.h:
+
2021-09-27 Myles C. Maxfield <[email protected]>
Add support for CSSFontPaletteValuesRule.name
Modified: trunk/Source/WebCore/display/DisplayTreeBuilder.cpp (283157 => 283158)
--- trunk/Source/WebCore/display/DisplayTreeBuilder.cpp 2021-09-28 05:17:12 UTC (rev 283157)
+++ trunk/Source/WebCore/display/DisplayTreeBuilder.cpp 2021-09-28 05:24:42 UTC (rev 283158)
@@ -119,8 +119,6 @@
std::unique_ptr<Tree> TreeBuilder::build(const Layout::LayoutState& layoutState)
{
- ASSERT(layoutState.hasRoot());
-
auto& rootLayoutBox = layoutState.root();
#if ENABLE(TREE_DEBUGGING)
Modified: trunk/Source/WebCore/editing/TextManipulationController.cpp (283157 => 283158)
--- trunk/Source/WebCore/editing/TextManipulationController.cpp 2021-09-28 05:17:12 UTC (rev 283157)
+++ trunk/Source/WebCore/editing/TextManipulationController.cpp 2021-09-28 05:24:42 UTC (rev 283158)
@@ -790,8 +790,8 @@
RefPtr<Node> firstContentNode;
RefPtr<Node> lastChildOfCommonAncestorInRange;
HashSet<Ref<Node>> nodesToRemove;
- ParagraphContentIterator iterator { item.start, item.end };
- for (; !iterator.atEnd(); iterator.advance()) {
+
+ for (ParagraphContentIterator iterator { item.start, item.end }; !iterator.atEnd(); iterator.advance()) {
auto content = iterator.currentContent();
ASSERT(content.node);
Modified: trunk/Source/WebCore/layout/FormattingState.h (283157 => 283158)
--- trunk/Source/WebCore/layout/FormattingState.h 2021-09-28 05:17:12 UTC (rev 283157)
+++ trunk/Source/WebCore/layout/FormattingState.h 2021-09-28 05:24:42 UTC (rev 283158)
@@ -30,7 +30,6 @@
#include "FormattingContext.h"
#include "LayoutState.h"
#include <wtf/IsoMalloc.h>
-#include <wtf/WeakPtr.h>
namespace WebCore {
namespace Layout {
@@ -65,8 +64,8 @@
// FIXME: We need to find a way to limit access to mutatable geometry.
BoxGeometry& boxGeometry(const Box& layoutBox);
// Since we layout the out-of-flow boxes at the end of the formatting context layout, it's okay to store them in the formatting state -as opposed to the containing block level.
- using OutOfFlowBoxList = Vector<WeakPtr<const Box>>;
- void addOutOfFlowBox(const Box& outOfFlowBox) { m_outOfFlowBoxes.append(makeWeakPtr(outOfFlowBox)); }
+ using OutOfFlowBoxList = Vector<CheckedRef<const Box>>;
+ void addOutOfFlowBox(const Box& outOfFlowBox) { m_outOfFlowBoxes.append(outOfFlowBox); }
void removeOutOfFlowBox(const Box&);
const OutOfFlowBoxList& outOfFlowBoxes() const { return m_outOfFlowBoxes; }
Modified: trunk/Source/WebCore/layout/LayoutState.cpp (283157 => 283158)
--- trunk/Source/WebCore/layout/LayoutState.cpp 2021-09-28 05:17:12 UTC (rev 283157)
+++ trunk/Source/WebCore/layout/LayoutState.cpp 2021-09-28 05:24:42 UTC (rev 283158)
@@ -46,7 +46,7 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(LayoutState);
LayoutState::LayoutState(const Document& document, const ContainerBox& rootContainer)
- : m_rootContainer(makeWeakPtr(rootContainer))
+ : m_rootContainer(rootContainer)
{
// It makes absolutely no sense to construct a dedicated layout state for a non-formatting context root (layout would be a no-op).
ASSERT(root().establishesFormattingContext());
@@ -101,7 +101,7 @@
{
ASSERT(formattingContextRoot.establishesFormattingContext());
if (RuntimeEnabledFeatures::sharedFeatures().layoutFormattingContextIntegrationEnabled()) {
- ASSERT(&formattingContextRoot == m_rootContainer.get());
+ ASSERT(&formattingContextRoot == m_rootContainer.ptr());
return *m_rootInlineFormattingStateForIntegration;
}
@@ -125,7 +125,7 @@
ASSERT(inlineFormattingContextRoot.establishesInlineFormattingContext());
if (RuntimeEnabledFeatures::sharedFeatures().layoutFormattingContextIntegrationEnabled()) {
- ASSERT(&inlineFormattingContextRoot == m_rootContainer.get());
+ ASSERT(&inlineFormattingContextRoot == m_rootContainer.ptr());
return *m_rootInlineFormattingStateForIntegration;
}
@@ -171,7 +171,7 @@
if (RuntimeEnabledFeatures::sharedFeatures().layoutFormattingContextIntegrationEnabled()) {
if (!m_rootInlineFormattingStateForIntegration) {
- ASSERT(&formattingContextRoot == m_rootContainer.get());
+ ASSERT(&formattingContextRoot == m_rootContainer.ptr());
m_rootInlineFormattingStateForIntegration = create();
}
return *m_rootInlineFormattingStateForIntegration;
Modified: trunk/Source/WebCore/layout/LayoutState.h (283157 => 283158)
--- trunk/Source/WebCore/layout/LayoutState.h 2021-09-28 05:17:12 UTC (rev 283157)
+++ trunk/Source/WebCore/layout/LayoutState.h 2021-09-28 05:24:42 UTC (rev 283158)
@@ -84,8 +84,7 @@
bool inLimitedQuirksMode() const { return m_quirksMode == QuirksMode::Limited; }
bool inStandardsMode() const { return m_quirksMode == QuirksMode::No; }
- bool hasRoot() const { return !!m_rootContainer; }
- const ContainerBox& root() const { return *m_rootContainer; }
+ const ContainerBox& root() const { return m_rootContainer; }
// LFC integration only. Full LFC has proper ICB access.
void setViewportSize(const LayoutSize&);
@@ -113,7 +112,7 @@
HashMap<const Box*, std::unique_ptr<BoxGeometry>> m_layoutBoxToBoxGeometry;
QuirksMode m_quirksMode { QuirksMode::No };
- WeakPtr<const ContainerBox> m_rootContainer;
+ CheckedRef<const ContainerBox> m_rootContainer;
// LFC integration only.
LayoutSize m_viewportSize;
Modified: trunk/Source/WebCore/layout/floats/FloatAvoider.h (283157 => 283158)
--- trunk/Source/WebCore/layout/floats/FloatAvoider.h 2021-09-28 05:17:12 UTC (rev 283157)
+++ trunk/Source/WebCore/layout/floats/FloatAvoider.h 2021-09-28 05:24:42 UTC (rev 283158)
@@ -32,7 +32,6 @@
#include "LayoutPoint.h"
#include "LayoutUnits.h"
#include <wtf/IsoMalloc.h>
-#include <wtf/WeakPtr.h>
namespace WebCore {
Modified: trunk/Source/WebCore/layout/floats/FloatingState.cpp (283157 => 283158)
--- trunk/Source/WebCore/layout/floats/FloatingState.cpp 2021-09-28 05:17:12 UTC (rev 283157)
+++ trunk/Source/WebCore/layout/floats/FloatingState.cpp 2021-09-28 05:24:42 UTC (rev 283158)
@@ -41,7 +41,7 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(FloatingState);
FloatingState::FloatItem::FloatItem(const Box& layoutBox, BoxGeometry absoluteBoxGeometry)
- : m_layoutBox(makeWeakPtr(layoutBox))
+ : m_layoutBox(layoutBox)
, m_position(layoutBox.isLeftFloatingPositioned() ? Position::Left : Position::Right)
, m_absoluteBoxGeometry(absoluteBoxGeometry)
{
@@ -55,7 +55,7 @@
FloatingState::FloatingState(LayoutState& layoutState, const ContainerBox& formattingContextRoot)
: m_layoutState(layoutState)
- , m_formattingContextRoot(makeWeakPtr(formattingContextRoot))
+ , m_formattingContextRoot(formattingContextRoot)
{
}
Modified: trunk/Source/WebCore/layout/floats/FloatingState.h (283157 => 283158)
--- trunk/Source/WebCore/layout/floats/FloatingState.h 2021-09-28 05:17:12 UTC (rev 283157)
+++ trunk/Source/WebCore/layout/floats/FloatingState.h 2021-09-28 05:24:42 UTC (rev 283158)
@@ -31,7 +31,6 @@
#include "LayoutContainerBox.h"
#include <wtf/IsoMalloc.h>
#include <wtf/Ref.h>
-#include <wtf/WeakPtr.h>
namespace WebCore {
@@ -49,7 +48,7 @@
public:
static Ref<FloatingState> create(LayoutState& layoutState, const ContainerBox& formattingContextRoot) { return adoptRef(*new FloatingState(layoutState, formattingContextRoot)); }
- const ContainerBox& root() const { return *m_formattingContextRoot; }
+ const ContainerBox& root() const { return m_formattingContextRoot; }
class FloatItem {
public:
@@ -70,7 +69,7 @@
const Box* floatBox() const { return m_layoutBox.get(); }
#endif
private:
- WeakPtr<const Box> m_layoutBox;
+ CheckedPtr<const Box> m_layoutBox;
Position m_position;
BoxGeometry m_absoluteBoxGeometry;
};
@@ -87,7 +86,7 @@
LayoutState& layoutState() const { return m_layoutState; }
LayoutState& m_layoutState;
- WeakPtr<const ContainerBox> m_formattingContextRoot;
+ CheckedRef<const ContainerBox> m_formattingContextRoot;
FloatList m_floats;
};
Modified: trunk/Source/WebCore/layout/formattingContexts/FormattingContext.cpp (283157 => 283158)
--- trunk/Source/WebCore/layout/formattingContexts/FormattingContext.cpp 2021-09-28 05:17:12 UTC (rev 283157)
+++ trunk/Source/WebCore/layout/formattingContexts/FormattingContext.cpp 2021-09-28 05:24:42 UTC (rev 283158)
@@ -49,7 +49,7 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(FormattingContext);
FormattingContext::FormattingContext(const ContainerBox& formattingContextRoot, FormattingState& formattingState)
- : m_root(makeWeakPtr(formattingContextRoot))
+ : m_root(formattingContextRoot)
, m_formattingState(formattingState)
{
ASSERT(formattingContextRoot.hasChild());
@@ -141,20 +141,20 @@
collectOutOfFlowDescendantsIfNeeded();
auto constraintsForLayoutBox = [&] (const auto& outOfFlowBox) {
- auto& containingBlock = outOfFlowBox.containingBlock();
+ auto& containingBlock = outOfFlowBox->containingBlock();
return &containingBlock == &root() ? constraints : formattingGeometry().constraintsForOutOfFlowContent(containingBlock);
};
for (auto& outOfFlowBox : formattingState().outOfFlowBoxes()) {
ASSERT(outOfFlowBox->establishesFormattingContext());
- auto containingBlockConstraints = constraintsForLayoutBox(*outOfFlowBox);
+ auto containingBlockConstraints = constraintsForLayoutBox(outOfFlowBox);
auto horizontalConstraintsForBorderAndPadding = HorizontalConstraints { containingBlockConstraints.horizontal.logicalLeft, containingBlockConstraints.borderAndPaddingConstraints };
- computeBorderAndPadding(*outOfFlowBox, horizontalConstraintsForBorderAndPadding);
+ computeBorderAndPadding(outOfFlowBox, horizontalConstraintsForBorderAndPadding);
- computeOutOfFlowHorizontalGeometry(*outOfFlowBox, containingBlockConstraints);
- auto outOfFlowBoxHasContent = is<ContainerBox>(*outOfFlowBox) && downcast<ContainerBox>(*outOfFlowBox).hasChild();
+ computeOutOfFlowHorizontalGeometry(outOfFlowBox, containingBlockConstraints);
+ auto outOfFlowBoxHasContent = is<ContainerBox>(outOfFlowBox.get()) && downcast<ContainerBox>(outOfFlowBox.get()).hasChild();
if (outOfFlowBoxHasContent) {
- auto& containerBox = downcast<ContainerBox>(*outOfFlowBox);
+ auto& containerBox = downcast<ContainerBox>(outOfFlowBox.get());
auto formattingContext = LayoutContext::createFormattingContext(containerBox, layoutState());
if (containerBox.hasInFlowOrFloatingChild())
formattingContext->layoutInFlowContent(formattingGeometry().constraintsForInFlowContent(containerBox));
@@ -161,7 +161,7 @@
computeOutOfFlowVerticalGeometry(containerBox, containingBlockConstraints);
formattingContext->layoutOutOfFlowContent(formattingGeometry().constraintsForOutOfFlowContent(containerBox));
} else
- computeOutOfFlowVerticalGeometry(*outOfFlowBox, containingBlockConstraints);
+ computeOutOfFlowVerticalGeometry(outOfFlowBox, containingBlockConstraints);
}
LOG_WITH_STREAM(FormattingContextLayout, stream << "End: layout out-of-flow content -> context: " << &layoutState() << " root: " << &root());
}
Modified: trunk/Source/WebCore/layout/formattingContexts/FormattingContext.h (283157 => 283158)
--- trunk/Source/WebCore/layout/formattingContexts/FormattingContext.h 2021-09-28 05:17:12 UTC (rev 283157)
+++ trunk/Source/WebCore/layout/formattingContexts/FormattingContext.h 2021-09-28 05:24:42 UTC (rev 283158)
@@ -32,7 +32,6 @@
#include "LayoutUnit.h"
#include "LayoutUnits.h"
#include <wtf/IsoMalloc.h>
-#include <wtf/WeakPtr.h>
namespace WebCore {
@@ -62,7 +61,7 @@
virtual IntrinsicWidthConstraints computedIntrinsicWidthConstraints() = 0;
virtual LayoutUnit usedContentHeight() const = 0;
- const ContainerBox& root() const { return *m_root; }
+ const ContainerBox& root() const { return m_root; }
LayoutState& layoutState() const;
const FormattingState& formattingState() const { return m_formattingState; }
virtual const FormattingGeometry& formattingGeometry() const = 0;
@@ -101,7 +100,7 @@
void computeOutOfFlowVerticalGeometry(const Box&, const ConstraintsForOutOfFlowContent&);
void computeOutOfFlowHorizontalGeometry(const Box&, const ConstraintsForOutOfFlowContent&);
- WeakPtr<const ContainerBox> m_root;
+ CheckedRef<const ContainerBox> m_root;
FormattingState& m_formattingState;
};
Modified: trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingState.h (283157 => 283158)
--- trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingState.h 2021-09-28 05:17:12 UTC (rev 283157)
+++ trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingState.h 2021-09-28 05:24:42 UTC (rev 283158)
@@ -28,8 +28,8 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
#include "FormattingState.h"
+#include <wtf/HashSet.h>
#include <wtf/IsoMalloc.h>
-#include <wtf/WeakHashSet.h>
namespace WebCore {
namespace Layout {
@@ -41,9 +41,9 @@
BlockFormattingState(Ref<FloatingState>&&, LayoutState&);
~BlockFormattingState();
- void setUsedVerticalMargin(const Box& layoutBox, const UsedVerticalMargin& usedVerticalMargin) { m_usedVerticalMargins.set(&layoutBox, usedVerticalMargin); }
- UsedVerticalMargin usedVerticalMargin(const Box& layoutBox) const { return m_usedVerticalMargins.get(&layoutBox); }
- bool hasUsedVerticalMargin(const Box& layoutBox) const { return m_usedVerticalMargins.contains(&layoutBox); }
+ void setUsedVerticalMargin(const Box& layoutBox, const UsedVerticalMargin& usedVerticalMargin) { m_usedVerticalMargins.set(layoutBox, usedVerticalMargin); }
+ UsedVerticalMargin usedVerticalMargin(const Box& layoutBox) const { return m_usedVerticalMargins.get(layoutBox); }
+ bool hasUsedVerticalMargin(const Box& layoutBox) const { return m_usedVerticalMargins.contains(layoutBox); }
void setHasClearance(const Box& layoutBox) { m_clearanceSet.add(layoutBox); }
void clearHasClearance(const Box& layoutBox) { m_clearanceSet.remove(layoutBox); }
@@ -50,8 +50,8 @@
bool hasClearance(const Box& layoutBox) const { return m_clearanceSet.contains(layoutBox); }
private:
- HashMap<const Box*, UsedVerticalMargin> m_usedVerticalMargins;
- WeakHashSet<const Box> m_clearanceSet;
+ HashMap<CheckedRef<const Box>, UsedVerticalMargin> m_usedVerticalMargins;
+ HashSet<CheckedRef<const Box>> m_clearanceSet;
};
}
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp (283157 => 283158)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp 2021-09-28 05:17:12 UTC (rev 283157)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp 2021-09-28 05:24:42 UTC (rev 283158)
@@ -270,7 +270,7 @@
auto& boxes = formattingState.boxes();
for (auto& outOfFlowBox : outOfFlowBoxes) {
- auto& outOfFlowGeometry = formattingState.boxGeometry(*outOfFlowBox);
+ auto& outOfFlowGeometry = formattingState.boxGeometry(outOfFlowBox);
// Both previous float and out-of-flow boxes are skipped here. A series of adjoining out-of-flow boxes should all be placed
// at the same static position (they don't affect next-sibling positions) and while floats do participate in the inline layout
// their positions have already been taken into account during the inline layout.
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLevelBox.h (283157 => 283158)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLevelBox.h 2021-09-28 05:17:12 UTC (rev 283157)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLevelBox.h 2021-09-28 05:24:42 UTC (rev 283158)
@@ -31,7 +31,6 @@
#include "InlineRect.h"
#include "LayoutBox.h"
#include "LayoutUnits.h"
-#include <wtf/WeakPtr.h>
namespace WebCore {
namespace Layout {
@@ -90,7 +89,7 @@
};
Type type() const { return m_type; }
- const Box& layoutBox() const { return *m_layoutBox; }
+ const Box& layoutBox() const { return m_layoutBox; }
InlineLevelBox(const Box&, const RenderStyle&, InlineLayoutUnit logicalLeft, InlineLayoutSize, Type);
@@ -115,7 +114,7 @@
void setLayoutBounds(const LayoutBounds& layoutBounds) { m_layoutBounds = { InlineLayoutUnit(roundToInt(layoutBounds.ascent)), InlineLayoutUnit(roundToInt(layoutBounds.descent)) }; }
private:
- WeakPtr<const Box> m_layoutBox;
+ CheckedRef<const Box> m_layoutBox;
// This is the combination of margin and border boxes. Inline level boxes are vertically aligned using their margin boxes.
InlineRect m_logicalRect;
LayoutBounds m_layoutBounds;
@@ -134,7 +133,7 @@
};
inline InlineLevelBox::InlineLevelBox(const Box& layoutBox, const RenderStyle& style, InlineLayoutUnit logicalLeft, InlineLayoutSize logicalSize, Type type)
- : m_layoutBox(makeWeakPtr(layoutBox))
+ : m_layoutBox(layoutBox)
, m_logicalRect({ }, logicalLeft, logicalSize.width(), logicalSize.height())
, m_type(type)
, m_style({ style.fontCascade().primaryFont().fontMetrics(), style.lineHeight(), InlineLayoutUnit(style.fontCascade().fontDescription().computedPixelSize()), { } })
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBox.h (283157 => 283158)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBox.h 2021-09-28 05:17:12 UTC (rev 283157)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBox.h 2021-09-28 05:24:42 UTC (rev 283158)
@@ -32,7 +32,6 @@
#include "InlineRect.h"
#include <wtf/IsoMallocInlines.h>
#include <wtf/UniqueRef.h>
-#include <wtf/WeakPtr.h>
namespace WebCore {
namespace Layout {
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayBox.h (283157 => 283158)
--- trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayBox.h 2021-09-28 05:17:12 UTC (rev 283157)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayBox.h 2021-09-28 05:24:42 UTC (rev 283158)
@@ -107,7 +107,7 @@
};
Expansion expansion() const { return m_expansion; }
- const Layout::Box& layoutBox() const { return *m_layoutBox; }
+ const Layout::Box& layoutBox() const { return m_layoutBox; }
const RenderStyle& style() const { return m_style; }
size_t lineIndex() const { return m_lineIndex; }
@@ -115,7 +115,7 @@
private:
const size_t m_lineIndex { 0 };
const Type m_type { Type::GenericInlineLevelBox };
- WeakPtr<const Layout::Box> m_layoutBox;
+ CheckedRef<const Layout::Box> m_layoutBox;
const RenderStyle& m_style;
Layout::InlineRect m_logicalRect;
Layout::InlineRect m_inkOverflow;
@@ -127,7 +127,7 @@
inline Box::Box(size_t lineIndex, Type type, const Layout::Box& layoutBox, const RenderStyle& style, const Layout::InlineRect& logicalRect, const Layout::InlineRect& inkOverflow, Expansion expansion, std::optional<Text> text, bool hasContent)
: m_lineIndex(lineIndex)
, m_type(type)
- , m_layoutBox(makeWeakPtr(layoutBox))
+ , m_layoutBox(layoutBox)
, m_style(style)
, m_logicalRect(logicalRect)
, m_inkOverflow(inkOverflow)
Modified: trunk/Source/WebCore/layout/formattingContexts/table/TableGrid.cpp (283157 => 283158)
--- trunk/Source/WebCore/layout/formattingContexts/table/TableGrid.cpp 2021-09-28 05:17:12 UTC (rev 283157)
+++ trunk/Source/WebCore/layout/formattingContexts/table/TableGrid.cpp 2021-09-28 05:24:42 UTC (rev 283158)
@@ -36,7 +36,7 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(TableGrid);
TableGrid::Column::Column(const ContainerBox* columnBox)
- : m_layoutBox(makeWeakPtr(columnBox))
+ : m_layoutBox(columnBox)
{
}
@@ -56,12 +56,12 @@
}
TableGrid::Row::Row(const ContainerBox& rowBox)
- : m_layoutBox(makeWeakPtr(rowBox))
+ : m_layoutBox(rowBox)
{
}
TableGrid::Cell::Cell(const ContainerBox& cellBox, SlotPosition position, CellSpan span)
- : m_layoutBox(makeWeakPtr(cellBox))
+ : m_layoutBox(cellBox)
, m_position(position)
, m_span(span)
{
Modified: trunk/Source/WebCore/layout/formattingContexts/table/TableGrid.h (283157 => 283158)
--- trunk/Source/WebCore/layout/formattingContexts/table/TableGrid.h 2021-09-28 05:17:12 UTC (rev 283157)
+++ trunk/Source/WebCore/layout/formattingContexts/table/TableGrid.h 2021-09-28 05:24:42 UTC (rev 283158)
@@ -82,7 +82,7 @@
LayoutUnit m_usedLogicalWidth;
LayoutUnit m_usedLogicalLeft;
Length m_computedLogicalWidth;
- WeakPtr<const ContainerBox> m_layoutBox;
+ CheckedPtr<const ContainerBox> m_layoutBox;
#if ASSERT_ENABLED
bool m_hasUsedWidth { false };
@@ -120,13 +120,13 @@
void setBaseline(InlineLayoutUnit baseline) { m_baseline = baseline; }
InlineLayoutUnit baseline() const { return m_baseline; }
- const ContainerBox& box() const { return *m_layoutBox.get(); }
+ const ContainerBox& box() const { return m_layoutBox; }
private:
LayoutUnit m_logicalTop;
LayoutUnit m_logicalHeight;
InlineLayoutUnit m_baseline { 0 };
- WeakPtr<const ContainerBox> m_layoutBox;
+ CheckedRef<const ContainerBox> m_layoutBox;
};
class Rows {
@@ -167,7 +167,7 @@
const ContainerBox& box() const { return *m_layoutBox.get(); }
private:
- WeakPtr<const ContainerBox> m_layoutBox;
+ CheckedPtr<const ContainerBox> m_layoutBox;
SlotPosition m_position;
CellSpan m_span;
InlineLayoutUnit m_baseline { 0 };
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp (283157 => 283158)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp 2021-09-28 05:17:12 UTC (rev 283157)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp 2021-09-28 05:24:42 UTC (rev 283158)
@@ -114,14 +114,14 @@
continue;
auto& childRenderer = *walker.current();
auto childBox = createChildBox(childRenderer);
- appendChild(WTFMove(childBox), childRenderer);
+ appendChild(makeUniqueRefFromNonNullUniquePtr(WTFMove(childBox)), childRenderer);
}
}
-void BoxTree::appendChild(std::unique_ptr<Layout::Box> childBox, RenderObject& childRenderer)
+void BoxTree::appendChild(UniqueRef<Layout::Box> childBox, RenderObject& childRenderer)
{
auto& parentBox = downcast<Layout::ContainerBox>(layoutBoxForRenderer(*childRenderer.parent()));
- parentBox.appendChild(*childBox);
+ parentBox.appendChild(childBox.get());
m_boxes.append({ WTFMove(childBox), &childRenderer });
@@ -161,7 +161,7 @@
return entry.renderer == &renderer;
});
RELEASE_ASSERT(index != notFound);
- return *m_boxes[index].box;
+ return m_boxes[index].box;
}
return *m_rendererToBoxMap.get(&renderer);
@@ -179,7 +179,7 @@
if (m_boxes.size() <= smallTreeThreshold) {
auto index = m_boxes.findMatching([&](auto& entry) {
- return entry.box.get() == &box;
+ return entry.box.ptr() == &box;
});
RELEASE_ASSERT(index != notFound);
return *m_boxes[index].renderer;
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.h (283157 => 283158)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.h 2021-09-28 05:17:12 UTC (rev 283157)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.h 2021-09-28 05:24:42 UTC (rev 283158)
@@ -29,6 +29,7 @@
#include "LayoutInitialContainingBlock.h"
#include <wtf/HashMap.h>
+#include <wtf/UniqueRef.h>
#include <wtf/Vector.h>
namespace WebCore {
@@ -59,7 +60,7 @@
size_t boxCount() const { return m_boxes.size(); }
struct BoxAndRenderer {
- std::unique_ptr<Layout::Box> box;
+ UniqueRef<Layout::Box> box;
RenderObject* renderer { nullptr };
};
const auto& boxAndRendererList() const { return m_boxes; }
@@ -66,14 +67,14 @@
private:
void buildTree();
- void appendChild(std::unique_ptr<Layout::Box>, RenderObject&);
+ void appendChild(UniqueRef<Layout::Box>, RenderObject&);
RenderBlockFlow& m_flow;
Layout::InitialContainingBlock m_root;
Vector<BoxAndRenderer, 1> m_boxes;
- HashMap<const RenderObject*, Layout::Box*> m_rendererToBoxMap;
- HashMap<const Layout::Box*, RenderObject*> m_boxToRendererMap;
+ HashMap<const RenderObject*, CheckedRef<Layout::Box>> m_rendererToBoxMap;
+ HashMap<CheckedRef<const Layout::Box>, RenderObject*> m_boxToRendererMap;
};
}
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContent.cpp (283157 => 283158)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContent.cpp 2021-09-28 05:17:12 UTC (rev 283157)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContent.cpp 2021-09-28 05:24:42 UTC (rev 283158)
@@ -37,7 +37,7 @@
namespace LayoutIntegration {
InlineContent::InlineContent(const LineLayout& lineLayout)
- : m_lineLayout(makeWeakPtr(lineLayout))
+ : m_lineLayout(lineLayout)
{
}
@@ -63,19 +63,14 @@
}
}
-const LineLayout& InlineContent::lineLayout() const
-{
- return *m_lineLayout;
-}
-
const RenderObject& InlineContent::rendererForLayoutBox(const Layout::Box& layoutBox) const
{
- return m_lineLayout->rendererForLayoutBox(layoutBox);
+ return lineLayout().rendererForLayoutBox(layoutBox);
}
const RenderBlockFlow& InlineContent::containingBlock() const
{
- return m_lineLayout->flow();
+ return lineLayout().flow();
}
size_t InlineContent::indexForBox(const InlineDisplay::Box& box) const
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContent.h (283157 => 283158)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContent.h 2021-09-28 05:17:12 UTC (rev 283157)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContent.h 2021-09-28 05:24:42 UTC (rev 283158)
@@ -29,10 +29,9 @@
#include "InlineDisplayBox.h"
#include "LayoutIntegrationLine.h"
+#include <wtf/HashMap.h>
#include <wtf/IteratorRange.h>
#include <wtf/Vector.h>
-#include <wtf/WeakHashMap.h>
-#include <wtf/WeakPtr.h>
namespace WebCore {
@@ -69,7 +68,7 @@
WTF::IteratorRange<const InlineDisplay::Box*> boxesForRect(const LayoutRect&) const;
void shrinkToFit();
- const LineLayout& lineLayout() const;
+ const LineLayout& lineLayout() const { return m_lineLayout; }
const RenderObject& rendererForLayoutBox(const Layout::Box&) const;
const RenderBlockFlow& containingBlock() const;
@@ -86,12 +85,12 @@
private:
InlineContent(const LineLayout&);
- WeakPtr<const LineLayout> m_lineLayout;
+ CheckedRef<const LineLayout> m_lineLayout;
- using FirstBoxIndexCache = WeakHashMap<Layout::Box, size_t>;
+ using FirstBoxIndexCache = HashMap<CheckedRef<const Layout::Box>, size_t>;
mutable std::unique_ptr<FirstBoxIndexCache> m_firstBoxIndexCache;
- using InlineBoxIndexCache = WeakHashMap<Layout::Box, Vector<size_t>>;
+ using InlineBoxIndexCache = HashMap<CheckedRef<const Layout::Box>, Vector<size_t>>;
mutable std::unique_ptr<InlineBoxIndexCache> m_inlineBoxIndexCache;
};
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (283157 => 283158)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp 2021-09-28 05:17:12 UTC (rev 283157)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp 2021-09-28 05:24:42 UTC (rev 283158)
@@ -239,7 +239,7 @@
auto& boxAndRendererList = m_boxTree.boxAndRendererList();
for (auto& boxAndRenderer : boxAndRendererList) {
- auto& layoutBox = *boxAndRenderer.box;
+ auto& layoutBox = boxAndRenderer.box.get();
if (!layoutBox.isReplacedBox())
continue;
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h (283157 => 283158)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h 2021-09-28 05:17:12 UTC (rev 283157)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h 2021-09-28 05:24:42 UTC (rev 283158)
@@ -34,7 +34,7 @@
#include "LayoutPoint.h"
#include "LayoutState.h"
#include "RenderObjectEnums.h"
-#include <wtf/WeakPtr.h>
+#include <wtf/CheckedPtr.h>
namespace WebCore {
@@ -57,7 +57,7 @@
struct InlineContent;
-class LineLayout : public CanMakeWeakPtr<LineLayout> {
+class LineLayout : public CanMakeCheckedPtr {
WTF_MAKE_FAST_ALLOCATED;
public:
LineLayout(RenderBlockFlow&);
Modified: trunk/Source/WebCore/layout/layouttree/LayoutBox.h (283157 => 283158)
--- trunk/Source/WebCore/layout/layouttree/LayoutBox.h 2021-09-28 05:17:12 UTC (rev 283157)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBox.h 2021-09-28 05:24:42 UTC (rev 283158)
@@ -29,8 +29,8 @@
#include "LayoutUnits.h"
#include "RenderStyle.h"
+#include <wtf/CheckedPtr.h>
#include <wtf/IsoMalloc.h>
-#include <wtf/WeakPtr.h>
namespace WebCore {
@@ -42,7 +42,7 @@
class LayoutState;
class TreeBuilder;
-class Box : public CanMakeWeakPtr<Box> {
+class Box : public CanMakeCheckedPtr {
WTF_MAKE_ISO_ALLOCATED(Box);
public:
enum class ElementType {
Modified: trunk/Source/WebCore/layout/layouttree/LayoutReplacedBox.h (283157 => 283158)
--- trunk/Source/WebCore/layout/layouttree/LayoutReplacedBox.h 2021-09-28 05:17:12 UTC (rev 283157)
+++ trunk/Source/WebCore/layout/layouttree/LayoutReplacedBox.h 2021-09-28 05:24:42 UTC (rev 283158)
@@ -32,7 +32,6 @@
#include "LayoutSize.h"
#include "LayoutUnit.h"
#include <wtf/IsoMalloc.h>
-#include <wtf/WeakPtr.h>
namespace WebCore {
namespace Layout {
Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.h (283157 => 283158)
--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.h 2021-09-28 05:17:12 UTC (rev 283157)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.h 2021-09-28 05:24:42 UTC (rev 283158)
@@ -29,7 +29,6 @@
#include "LayoutContainerBox.h"
#include <wtf/IsoMalloc.h>
-#include <wtf/WeakPtr.h>
namespace WebCore {
Modified: trunk/Source/WebCore/page/FrameViewLayoutContext.cpp (283157 => 283158)
--- trunk/Source/WebCore/page/FrameViewLayoutContext.cpp 2021-09-28 05:17:12 UTC (rev 283157)
+++ trunk/Source/WebCore/page/FrameViewLayoutContext.cpp 2021-09-28 05:24:42 UTC (rev 283158)
@@ -62,6 +62,9 @@
if (m_disableSetNeedsLayoutCount)
return;
+ m_layoutState = nullptr;
+ m_layoutTree = nullptr;
+
auto& renderView = *this->renderView();
m_layoutTree = Layout::TreeBuilder::buildLayoutTree(renderView);
m_layoutState = makeUnique<Layout::LayoutState>(*document(), m_layoutTree->root());
Modified: trunk/Source/WebCore/page/FrameViewLayoutContext.h (283157 => 283158)
--- trunk/Source/WebCore/page/FrameViewLayoutContext.h 2021-09-28 05:17:12 UTC (rev 283157)
+++ trunk/Source/WebCore/page/FrameViewLayoutContext.h 2021-09-28 05:24:42 UTC (rev 283158)
@@ -188,8 +188,8 @@
unsigned m_paintOffsetCacheDisableCount { 0 };
LayoutStateStack m_layoutStateStack;
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+ std::unique_ptr<Layout::LayoutTree> m_layoutTree;
std::unique_ptr<Layout::LayoutState> m_layoutState;
- std::unique_ptr<Layout::LayoutTree> m_layoutTree;
#endif
};