Commit 980f75a2 authored by Alison Maher's avatar Alison Maher Committed by Chromium LUCI CQ

[LayoutNG] Update the type of stored inner multicols with pending OOFs

Update the stored type of inner multicols with pending OOFs added in
CL:2612392 from NGBlockNode to LayoutBox*. This was requested as it
makes converting NGBlockNode to a GarbageCollected class easier.

Bug: 1079031
Change-Id: If2bf19de5774b7f003650b2c8f923cba4adfbe3c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2630730
Commit-Queue: Alison Maher <almaher@microsoft.com>
Reviewed-by: default avatarYuki Yamada <yukiy@chromium.org>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844189}
parent ae51cb4a
...@@ -244,18 +244,6 @@ class CORE_EXPORT NGBlockNode : public NGLayoutInputNode { ...@@ -244,18 +244,6 @@ class CORE_EXPORT NGBlockNode : public NGLayoutInputNode {
LayoutUnit percentage_resolution_inline_size) const; LayoutUnit percentage_resolution_inline_size) const;
}; };
// The NGBlockNode hash is based on its LayoutBox member.
struct NGBlockNodeHash : PtrHash<const LayoutBox*> {
STATIC_ONLY(NGBlockNodeHash);
static unsigned GetHash(const NGBlockNode& key) {
return PtrHash<const LayoutBox>::GetHash(key.GetLayoutBox());
}
static bool Equal(const NGBlockNode& a, const NGBlockNode& b) {
return PtrHash<const LayoutBox>::Equal(a.GetLayoutBox(), b.GetLayoutBox());
}
static const bool safe_to_compare_to_empty_or_deleted = true;
};
template <> template <>
struct DowncastTraits<NGBlockNode> { struct DowncastTraits<NGBlockNode> {
static bool AllowFrom(const NGLayoutInputNode& node) { static bool AllowFrom(const NGLayoutInputNode& node) {
...@@ -265,31 +253,4 @@ struct DowncastTraits<NGBlockNode> { ...@@ -265,31 +253,4 @@ struct DowncastTraits<NGBlockNode> {
} // namespace blink } // namespace blink
namespace WTF {
template <>
struct DefaultHash<blink::NGBlockNode> {
STATIC_ONLY(DefaultHash);
typedef blink::NGBlockNodeHash Hash;
};
template <>
struct HashTraits<blink::NGBlockNode>
: public GenericHashTraits<blink::NGBlockNode> {
static const bool kEmptyValueIsZero = false;
static const bool kHasIsEmptyValueFunction = true;
static bool IsEmptyValue(const blink::NGBlockNode& value) {
return !value.GetLayoutBox();
}
static blink::NGBlockNode EmptyValue() { return nullptr; }
static void ConstructDeletedValue(blink::NGBlockNode& slot, bool) {
slot = blink::NGBlockNode(reinterpret_cast<blink::LayoutBox*>(-1));
}
static bool IsDeletedValue(const blink::NGBlockNode& value) {
return value.GetLayoutBox() == reinterpret_cast<blink::LayoutBox*>(-1);
}
};
} // namespace WTF
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_NG_BLOCK_NODE_H_ #endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_NG_BLOCK_NODE_H_
...@@ -243,11 +243,11 @@ void NGContainerFragmentBuilder::SwapOutOfFlowPositionedCandidates( ...@@ -243,11 +243,11 @@ void NGContainerFragmentBuilder::SwapOutOfFlowPositionedCandidates(
void NGContainerFragmentBuilder::AddMulticolWithPendingOOFs( void NGContainerFragmentBuilder::AddMulticolWithPendingOOFs(
const NGBlockNode& multicol) { const NGBlockNode& multicol) {
DCHECK(To<LayoutBlockFlow>(multicol.GetLayoutBox())->MultiColumnFlowThread()); DCHECK(To<LayoutBlockFlow>(multicol.GetLayoutBox())->MultiColumnFlowThread());
multicols_with_pending_oofs_.insert(multicol); multicols_with_pending_oofs_.insert(multicol.GetLayoutBox());
} }
void NGContainerFragmentBuilder::SwapMulticolsWithPendingOOFs( void NGContainerFragmentBuilder::SwapMulticolsWithPendingOOFs(
HashSet<NGBlockNode>* multicols_with_pending_oofs) { MulticolCollection* multicols_with_pending_oofs) {
DCHECK(multicols_with_pending_oofs->IsEmpty()); DCHECK(multicols_with_pending_oofs->IsEmpty());
std::swap(multicols_with_pending_oofs_, *multicols_with_pending_oofs); std::swap(multicols_with_pending_oofs_, *multicols_with_pending_oofs);
} }
...@@ -297,8 +297,8 @@ void NGContainerFragmentBuilder::PropagateOOFPositionedInfo( ...@@ -297,8 +297,8 @@ void NGContainerFragmentBuilder::PropagateOOFPositionedInfo(
if (box_fragment->HasMulticolsWithPendingOOFs()) { if (box_fragment->HasMulticolsWithPendingOOFs()) {
const auto& multicols_with_pending_oofs = const auto& multicols_with_pending_oofs =
box_fragment->MulticolsWithPendingOOFs(); box_fragment->MulticolsWithPendingOOFs();
for (const NGBlockNode& multicol : multicols_with_pending_oofs) for (LayoutBox* multicol : multicols_with_pending_oofs)
AddMulticolWithPendingOOFs(multicol); AddMulticolWithPendingOOFs(NGBlockNode(multicol));
} }
// If we find a multicol with OOF positioned fragmentainer descendants, // If we find a multicol with OOF positioned fragmentainer descendants,
......
...@@ -45,6 +45,7 @@ class CORE_EXPORT NGContainerFragmentBuilder : public NGFragmentBuilder { ...@@ -45,6 +45,7 @@ class CORE_EXPORT NGContainerFragmentBuilder : public NGFragmentBuilder {
scoped_refptr<const NGPhysicalFragment> fragment; scoped_refptr<const NGPhysicalFragment> fragment;
}; };
typedef Vector<ChildWithOffset, 4> ChildrenVector; typedef Vector<ChildWithOffset, 4> ChildrenVector;
using MulticolCollection = HashSet<LayoutBox*>;
LayoutUnit BfcLineOffset() const { return bfc_line_offset_; } LayoutUnit BfcLineOffset() const { return bfc_line_offset_; }
void SetBfcLineOffset(LayoutUnit bfc_line_offset) { void SetBfcLineOffset(LayoutUnit bfc_line_offset) {
...@@ -142,7 +143,7 @@ class CORE_EXPORT NGContainerFragmentBuilder : public NGFragmentBuilder { ...@@ -142,7 +143,7 @@ class CORE_EXPORT NGContainerFragmentBuilder : public NGFragmentBuilder {
Vector<NGLogicalOutOfFlowPositionedNode>* descendants); Vector<NGLogicalOutOfFlowPositionedNode>* descendants);
void SwapMulticolsWithPendingOOFs( void SwapMulticolsWithPendingOOFs(
HashSet<NGBlockNode>* multicols_with_pending_oofs); MulticolCollection* multicols_with_pending_oofs);
bool HasOutOfFlowPositionedCandidates() const { bool HasOutOfFlowPositionedCandidates() const {
return !oof_positioned_candidates_.IsEmpty(); return !oof_positioned_candidates_.IsEmpty();
...@@ -260,7 +261,7 @@ class CORE_EXPORT NGContainerFragmentBuilder : public NGFragmentBuilder { ...@@ -260,7 +261,7 @@ class CORE_EXPORT NGContainerFragmentBuilder : public NGFragmentBuilder {
oof_positioned_fragmentainer_descendants_; oof_positioned_fragmentainer_descendants_;
Vector<NGLogicalOutOfFlowPositionedNode> oof_positioned_descendants_; Vector<NGLogicalOutOfFlowPositionedNode> oof_positioned_descendants_;
HashSet<NGBlockNode> multicols_with_pending_oofs_; MulticolCollection multicols_with_pending_oofs_;
NGUnpositionedListMarker unpositioned_list_marker_; NGUnpositionedListMarker unpositioned_list_marker_;
......
...@@ -145,12 +145,13 @@ void NGOutOfFlowLayoutPart::Run(const LayoutBox* only_layout) { ...@@ -145,12 +145,13 @@ void NGOutOfFlowLayoutPart::Run(const LayoutBox* only_layout) {
} }
if (container_builder_->HasMulticolsWithPendingOOFs()) { if (container_builder_->HasMulticolsWithPendingOOFs()) {
HashSet<NGBlockNode> multicols_with_pending_oofs; NGContainerFragmentBuilder::MulticolCollection
multicols_with_pending_oofs;
container_builder_->SwapMulticolsWithPendingOOFs( container_builder_->SwapMulticolsWithPendingOOFs(
&multicols_with_pending_oofs); &multicols_with_pending_oofs);
DCHECK(!multicols_with_pending_oofs.IsEmpty()); DCHECK(!multicols_with_pending_oofs.IsEmpty());
for (const NGBlockNode& multicol : multicols_with_pending_oofs) for (LayoutBox* multicol : multicols_with_pending_oofs)
LayoutOOFsInMulticol(multicol); LayoutOOFsInMulticol(NGBlockNode(multicol));
} }
} }
......
...@@ -34,6 +34,7 @@ class CORE_EXPORT NGPhysicalBoxFragment final ...@@ -34,6 +34,7 @@ class CORE_EXPORT NGPhysicalBoxFragment final
const base::Optional<PhysicalRect> const base::Optional<PhysicalRect>
updated_layout_overflow = base::nullopt); updated_layout_overflow = base::nullopt);
using MulticolCollection = NGContainerFragmentBuilder::MulticolCollection;
using PassKey = base::PassKey<NGPhysicalBoxFragment>; using PassKey = base::PassKey<NGPhysicalBoxFragment>;
NGPhysicalBoxFragment(PassKey, NGPhysicalBoxFragment(PassKey,
NGBoxFragmentBuilder* builder, NGBoxFragmentBuilder* builder,
...@@ -161,10 +162,10 @@ class CORE_EXPORT NGPhysicalBoxFragment final ...@@ -161,10 +162,10 @@ class CORE_EXPORT NGPhysicalBoxFragment final
return !ComputeRareDataAddress()->multicols_with_pending_oofs.IsEmpty(); return !ComputeRareDataAddress()->multicols_with_pending_oofs.IsEmpty();
} }
HashSet<NGBlockNode> MulticolsWithPendingOOFs() const { MulticolCollection MulticolsWithPendingOOFs() const {
if (!has_rare_data_) if (!has_rare_data_)
return HashSet<NGBlockNode>(); return MulticolCollection();
return const_cast<HashSet<NGBlockNode>&>( return const_cast<MulticolCollection&>(
ComputeRareDataAddress()->multicols_with_pending_oofs); ComputeRareDataAddress()->multicols_with_pending_oofs);
} }
...@@ -319,7 +320,7 @@ class CORE_EXPORT NGPhysicalBoxFragment final ...@@ -319,7 +320,7 @@ class CORE_EXPORT NGPhysicalBoxFragment final
Vector<NGPhysicalOutOfFlowPositionedNode> Vector<NGPhysicalOutOfFlowPositionedNode>
oof_positioned_fragmentainer_descendants; oof_positioned_fragmentainer_descendants;
HashSet<NGBlockNode> multicols_with_pending_oofs; MulticolCollection multicols_with_pending_oofs;
const std::unique_ptr<const NGMathMLPaintInfo> mathml_paint_info; const std::unique_ptr<const NGMathMLPaintInfo> mathml_paint_info;
// TablesNG rare data. // TablesNG rare data.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment