diff options
Diffstat (limited to 'layout/base/nsCSSFrameConstructor.cpp')
-rw-r--r-- | layout/base/nsCSSFrameConstructor.cpp | 46 |
1 files changed, 20 insertions, 26 deletions
diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 149f2f24bf..ba43eb70b9 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -1537,12 +1537,11 @@ already_AddRefed<nsIContent> nsCSSFrameConstructor::CreateGenConTextNode( void nsCSSFrameConstructor::CreateGeneratedContent( nsFrameConstructorState& aState, Element& aOriginatingElement, - ComputedStyle& aPseudoStyle, uint32_t aContentIndex, - const FunctionRef<void(nsIContent*)> aAddChild) { + ComputedStyle& aPseudoStyle, const StyleContentItem& aItem, + size_t aContentIndex, const FunctionRef<void(nsIContent*)> aAddChild) { using Type = StyleContentItem::Tag; // Get the content value - const auto& item = aPseudoStyle.StyleContent()->ContentAt(aContentIndex); - const Type type = item.tag; + const Type type = aItem.tag; switch (type) { case Type::Image: { @@ -1552,7 +1551,7 @@ void nsCSSFrameConstructor::CreateGeneratedContent( } case Type::String: { - const auto string = item.AsString().AsString(); + const auto string = aItem.AsString().AsString(); if (string.IsEmpty()) { return; } @@ -1563,7 +1562,7 @@ void nsCSSFrameConstructor::CreateGeneratedContent( } case Type::Attr: { - const auto& attr = item.AsAttr(); + const auto& attr = aItem.AsAttr(); RefPtr<nsAtom> attrName = attr.attribute.AsAtom(); int32_t attrNameSpace = kNameSpaceID_None; RefPtr<nsAtom> ns = attr.namespace_url.AsAtom(); @@ -1592,11 +1591,11 @@ void nsCSSFrameConstructor::CreateGeneratedContent( CounterStylePtr ptr; nsString separator; if (type == Type::Counter) { - auto& counter = item.AsCounter(); + auto& counter = aItem.AsCounter(); name = counter._0.AsAtom(); ptr = CounterStylePtr::FromStyle(counter._1); } else { - auto& counters = item.AsCounters(); + auto& counters = aItem.AsCounters(); name = counters._0.AsAtom(); CopyUTF8toUTF16(counters._1.AsString(), separator); ptr = CounterStylePtr::FromStyle(counters._2); @@ -1947,13 +1946,14 @@ void nsCSSFrameConstructor::CreateGeneratedContentItem( mPresShell->StyleSet()->StyleNewSubtree(childElement); } }; - const uint32_t contentCount = pseudoStyle->StyleContent()->ContentCount(); - for (uint32_t contentIndex = 0; contentIndex < contentCount; contentIndex++) { - CreateGeneratedContent(aState, aOriginatingElement, *pseudoStyle, - contentIndex, AppendChild); + auto items = pseudoStyle->StyleContent()->NonAltContentItems(); + size_t index = 0; + for (const auto& item : items) { + CreateGeneratedContent(aState, aOriginatingElement, *pseudoStyle, item, + index++, AppendChild); } // If a ::marker has no 'content' then generate it from its 'list-style-*'. - if (contentCount == 0 && aPseudoElement == PseudoStyleType::marker) { + if (index == 0 && aPseudoElement == PseudoStyleType::marker) { CreateGeneratedContentFromListStyle(aState, aOriginatingElement, *pseudoStyle, AppendChild); } @@ -4985,9 +4985,8 @@ nsCSSFrameConstructor::FindSVGData(const Element& aElement, return data; } -void nsCSSFrameConstructor::InsertPageBreakItem( - nsIContent* aContent, FrameConstructionItemList& aItems, - InsertPageBreakLocation location) { +void nsCSSFrameConstructor::AppendPageBreakItem( + nsIContent* aContent, FrameConstructionItemList& aItems) { RefPtr<ComputedStyle> pseudoStyle = mPresShell->StyleSet()->ResolveNonInheritingAnonymousBoxStyle( PseudoStyleType::pageBreak); @@ -4997,13 +4996,8 @@ void nsCSSFrameConstructor::InsertPageBreakItem( static constexpr FrameConstructionData sPageBreakData(NS_NewPageBreakFrame, FCDATA_SKIP_FRAMESET); - if (location == InsertPageBreakLocation::eBefore) { - aItems.PrependItem(this, &sPageBreakData, aContent, pseudoStyle.forget(), - true); - } else { - aItems.AppendItem(this, &sPageBreakData, aContent, pseudoStyle.forget(), - true); - } + aItems.AppendItem(this, &sPageBreakData, aContent, pseudoStyle.forget(), + true); } bool nsCSSFrameConstructor::ShouldCreateItemsForChild( @@ -5289,7 +5283,7 @@ void nsCSSFrameConstructor::AddFrameConstructionItemsInternal( aFlags.contains(ItemFlag::AllowPageBreak) && aState.mPresContext->IsPaginated() && !display.IsAbsolutelyPositionedStyle() && - !(aParentFrame && aParentFrame->IsGridContainerFrame()) && + !(aParentFrame && aParentFrame->IsFlexOrGridContainer()) && !(bits & FCDATA_IS_TABLE_PART) && !(bits & FCDATA_IS_SVG_TEXT); if (canHavePageBreak && display.BreakBefore()) { AppendPageBreakItem(aContent, aItems); @@ -6012,7 +6006,7 @@ nsIFrame* nsCSSFrameConstructor::GetInsertionPrevSibling( // Find the frame that precedes the insertion point. FlattenedChildIterator iter(aInsertion->mContainer); - if (iter.ShadowDOMInvolved() || !aChild->IsRootOfNativeAnonymousSubtree()) { + if (!aChild->IsRootOfNativeAnonymousSubtree()) { // The check for IsRootOfNativeAnonymousSubtree() is because editor is // severely broken and calls us directly for native anonymous // nodes that it creates. @@ -8390,7 +8384,7 @@ void nsCSSFrameConstructor::RecreateFramesForContent( } // TODO(emilio): We technically can find the right insertion point nowadays - // using StyleChildrenIterator rather than FlattenedTreeIterator. But we'd + // using StyleChildrenIterator rather than FlattenedChildIterator. But we'd // need to tweak the setup to insert into replaced elements to filter which // anonymous roots can be allowed, and which can't. // |