Bug 1377648 - Use inFlowFrame to check the target frame is summary and its parent is details. r?heycam draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Wed, 05 Jul 2017 12:39:32 +0900
changeset 604080 edf029c94e37d369039d45726a161ccf5035949f
parent 603793 acbd9a64c0fa4e1980c7732735d4f4c2761ca4c9
child 604081 0ffe978c99eeac3f981448ccd82a1b3264ee7133
push id66947
push userhikezoe@mozilla.com
push dateWed, 05 Jul 2017 08:39:33 +0000
reviewersheycam
bugs1377648
milestone56.0a1
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
layout/base/nsCSSFrameConstructor.cpp
--- 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.