diff options
author | Matt A. Tobin <email@mattatobin.com> | 2020-04-17 06:09:37 -0400 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2020-04-17 06:09:37 -0400 |
commit | 53428ad3f04ff1e01f0596ef0c592bdbe5fdd15b (patch) | |
tree | 7eda1d51e148d7dae5d02c143af323e78e4fe92f | |
parent | 0c99ad16fbb5c3b90ee140235159f9a0ee72397b (diff) | |
download | UXP-53428ad3f04ff1e01f0596ef0c592bdbe5fdd15b.tar UXP-53428ad3f04ff1e01f0596ef0c592bdbe5fdd15b.tar.gz UXP-53428ad3f04ff1e01f0596ef0c592bdbe5fdd15b.tar.lz UXP-53428ad3f04ff1e01f0596ef0c592bdbe5fdd15b.tar.xz UXP-53428ad3f04ff1e01f0596ef0c592bdbe5fdd15b.zip |
Bug 1377648 - Fix HTMLSummaryElement::IsSummary() on removing the element
* Use inFlowFrame to check the target frame is summary and its parent is details
* Check summary frame instead of summary element on removing the summary
Tag #1375
-rw-r--r-- | layout/base/nsCSSFrameConstructor.cpp | 28 | ||||
-rw-r--r-- | layout/generic/DetailsFrame.cpp | 9 | ||||
-rw-r--r-- | layout/generic/DetailsFrame.h | 6 | ||||
-rw-r--r-- | layout/reftests/details-summary/reftest.list | 4 |
4 files changed, 35 insertions, 12 deletions
diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 57410a55a..8b89b2a22 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -9395,16 +9395,27 @@ nsCSSFrameConstructor::MaybeRecreateContainerForFrameRemoval(nsIFrame* aFrame, return true; } - if (insertionFrame && - aFrame->GetParent()->GetType() == nsGkAtoms::detailsFrame) { + nsIFrame* inFlowFrame = + (aFrame->GetStateBits() & NS_FRAME_OUT_OF_FLOW) ? + aFrame->GetPlaceholderFrame() : aFrame; + MOZ_ASSERT(inFlowFrame, "How did that happen?"); + MOZ_ASSERT(inFlowFrame == inFlowFrame->FirstContinuation(), + "placeholder for primary frame has previous continuations?"); + nsIFrame* parent = inFlowFrame->GetParent(); + + if (parent && parent->GetType() == nsGkAtoms::detailsFrame) { HTMLSummaryElement* summary = - HTMLSummaryElement::FromContent(insertionFrame->GetContent()); + HTMLSummaryElement::FromContent(aFrame->GetContent()); + DetailsFrame* detailsFrame = static_cast<DetailsFrame*>(parent); - if (summary && summary->IsMainSummary()) { + // Unlike adding summary element cases, we need to check children of the + // parent details frame since at this moment the summary element has been + // already removed from the parent details element's child list. + if (summary && detailsFrame->HasMainSummaryFrame(aFrame)) { // When removing a summary, we should reframe the parent details frame to // ensure that another summary is used or the default summary is // generated. - RecreateFramesForContent(aFrame->GetParent()->GetContent(), + RecreateFramesForContent(parent->GetContent(), false, REMOVE_FOR_RECONSTRUCTION, aDestroyedFramesFor); return true; @@ -9412,13 +9423,6 @@ nsCSSFrameConstructor::MaybeRecreateContainerForFrameRemoval(nsIFrame* aFrame, } // Now check for possibly needing to reconstruct due to a pseudo parent - nsIFrame* inFlowFrame = - (aFrame->GetStateBits() & NS_FRAME_OUT_OF_FLOW) ? - aFrame->GetPlaceholderFrame() : aFrame; - MOZ_ASSERT(inFlowFrame, "How did that happen?"); - MOZ_ASSERT(inFlowFrame == inFlowFrame->FirstContinuation(), - "placeholder for primary frame has previous continuations?"); - nsIFrame* parent = inFlowFrame->GetParent(); // For the case of ruby pseudo parent, effectively, only pseudo rb/rt frame // need to be checked here, since all other types of parent will be catched // by "Check ruby containers" section below. diff --git a/layout/generic/DetailsFrame.cpp b/layout/generic/DetailsFrame.cpp index 1d28bbe96..389a476cb 100644 --- a/layout/generic/DetailsFrame.cpp +++ b/layout/generic/DetailsFrame.cpp @@ -129,3 +129,12 @@ DetailsFrame::AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements, aElements.AppendElement(mDefaultSummary); } } + +bool +DetailsFrame::HasMainSummaryFrame(nsIFrame* aSummaryFrame) +{ + nsIFrame* firstChild = + nsPlaceholderFrame::GetRealFrameFor(mFrames.FirstChild()); + + return aSummaryFrame == firstChild; +} diff --git a/layout/generic/DetailsFrame.h b/layout/generic/DetailsFrame.h index 1eb4ea87b..4ae177f16 100644 --- a/layout/generic/DetailsFrame.h +++ b/layout/generic/DetailsFrame.h @@ -54,6 +54,12 @@ public: void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements, uint32_t aFilter) override; + // Returns true if |aSummaryFrame| is the main summary (i.e. the first child + // of this details frame). + // This function is used when the summary element is removed from the parent + // details element since at that moment the summary element has been already + // removed from the details element children. + bool HasMainSummaryFrame(nsIFrame* aSummaryFrame); private: nsCOMPtr<nsIContent> mDefaultSummary; diff --git a/layout/reftests/details-summary/reftest.list b/layout/reftests/details-summary/reftest.list index e96581ad4..a972cf498 100644 --- a/layout/reftests/details-summary/reftest.list +++ b/layout/reftests/details-summary/reftest.list @@ -101,3 +101,7 @@ fuzzy(1,1) == mouse-click-twice-float-details.html float-details.html # Bug 1316 == details-before.html single-summary.html == open-details-after.html open-single-summary.html == open-details-before.html open-single-summary.html + +# Move summary element +== move-float-summary-to-different-details.html move-float-summary-to-different-details-ref.html +== move-position-absolute-summary-to-different-details.html move-position-absolute-summary-to-different-details-ref.html |