Bug 1377648 - Use inFlowFrame to check the target frame is summary and its parent is details. r?heycam
Considering the case where the summary element has position:absolute, we need
to use inFlowFrame and its parent instead of aFrame itself.
MozReview-Commit-ID: Ds8xxyBuyO5
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -9716,39 +9716,40 @@ nsCSSFrameConstructor::MaybeRecreateCont
aFrame->GetParent()->IsFieldSetFrame()) {
// When we remove the legend for a fieldset, we should reframe
// the fieldset to ensure another legend is used, if there is one
RecreateFramesForContent(aFrame->GetParent()->GetContent(), false,
aFlags, aDestroyedFramesFor);
return true;
}
- if (insertionFrame && aFrame->GetParent()->IsDetailsFrame()) {
+ 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->IsDetailsFrame()) {
HTMLSummaryElement* summary =
- HTMLSummaryElement::FromContent(insertionFrame->GetContent());
+ HTMLSummaryElement::FromContent(aFrame->GetContent());
if (summary && summary->IsMainSummary()) {
// 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;
}
}
// 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.
if (IsTableOrRubyPseudo(parent)) {
if (FindFirstNonWhitespaceChild(parent) == inFlowFrame ||
!FindNextNonWhitespaceSibling(inFlowFrame->LastContinuation()) ||
// If it is a whitespace, and is the only child of the parent, the
// pseudo parent was created for the space, and should now be removed.