Bug 1425088 - (Part 3) Put the dropdown frame's placeholder into the principal child list of the combobox frame when content-select is enabled. draft
authorKuoE0 <kuoe0.tw@gmail.com>
Fri, 05 Jan 2018 17:50:38 +0800
changeset 717471 ecd0f9dd4923c6d456a13ecac746a58808324af9
parent 717470 351ef273f5df10268a205587d002f782572bfff9
child 717495 ac0414f09056f32789dfe51143d61196f7029ed1
push id94690
push userbmo:kuoe0@mozilla.com
push dateTue, 09 Jan 2018 02:16:54 +0000
bugs1425088
milestone59.0a1
Bug 1425088 - (Part 3) Put the dropdown frame's placeholder into the principal child list of the combobox frame when content-select is enabled. MozReview-Commit-ID: HJrltVmJCOj
layout/base/nsCSSFrameConstructor.cpp
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -3239,32 +3239,34 @@ nsCSSFrameConstructor::ConstructSelectFr
     if (!Preferences::GetBool(kPrefSelectPopupInContent)) {
       // TODO(kuoe0) Remove this assertion when content-select is shipped.
       NS_ASSERTION(!listFrame->IsAbsPosContainingBlock(),
                    "Ended up with positioned dropdown list somehow.");
     }
     NS_ASSERTION(!listFrame->IsFloating(),
                  "Ended up with floating dropdown list somehow.");
 
+    // child frames of combobox frame
+    nsFrameItems childItems;
+
     // Initialize the scroll frame positioned. Note that it is NOT
     // initialized as absolutely positioned.
     nsContainerFrame* scrolledFrame =
       NS_NewSelectsAreaFrame(mPresShell, styleContext, flags);
 
     InitializeSelectFrame(aState, listFrame, scrolledFrame, content,
                           comboboxFrame, listStyle, true,
-                          aItem.mPendingBinding, aFrameItems);
+                          aItem.mPendingBinding, childItems);
 
     NS_ASSERTION(listFrame->GetView(), "ListFrame's view is nullptr");
 
     // Create display and button frames from the combobox's anonymous content.
     // The anonymous content is appended to existing anonymous content for this
     // element (the scrollbars).
-    nsFrameItems childItems;
-
+    //
     // nsComboboxControlFrame needs special frame creation behavior for its first
     // piece of anonymous content, which means that we can't take the normal
     // ProcessChildren path.
     AutoTArray<nsIAnonymousContentCreator::ContentInfo, 2> newAnonymousItems;
     DebugOnly<nsresult> rv = GetAnonymousContent(content, comboboxFrame, newAnonymousItems);
     MOZ_ASSERT(NS_SUCCEEDED(rv));
     MOZ_ASSERT(newAnonymousItems.Length() == 2);
 
@@ -3281,22 +3283,24 @@ nsCSSFrameConstructor::ConstructSelectFr
     AddFCItemsForAnonymousContent(aState, comboboxFrame, newAnonymousItems,
                                   fcItems);
     ConstructFramesFromItemList(aState, fcItems, comboboxFrame,
                                 /* aParentIsWrapperAnonBox = */ false,
                                 childItems);
 
     comboboxFrame->SetInitialChildList(kPrincipalList, childItems);
 
-    // Initialize the additional popup child list which contains the
-    // dropdown list frame.
-    nsFrameItems popupItems;
-    popupItems.AddChild(listFrame);
-    comboboxFrame->SetInitialChildList(nsIFrame::kSelectPopupList,
-                                       popupItems);
+    if (!Preferences::GetBool(kPrefSelectPopupInContent)) {
+      // Initialize the additional popup child list which contains the
+      // dropdown list frame.
+      nsFrameItems popupItems;
+      popupItems.AddChild(listFrame);
+      comboboxFrame->SetInitialChildList(nsIFrame::kSelectPopupList,
+                                         popupItems);
+    }
 
     aState.mFrameState = historyState;
     if (aState.mFrameState) {
       // Restore frame state for the entire subtree of |comboboxFrame|.
       RestoreFrameState(comboboxFrame, aState.mFrameState);
     }
     return comboboxFrame;
   }
@@ -3338,17 +3342,17 @@ nsCSSFrameConstructor::InitializeSelectF
     aState.GetGeometricParent(aStyleContext->StyleDisplay(), aParentFrame);
 
   // We don't call InitAndRestoreFrame for scrollFrame because we can only
   // restore the frame state after its parts have been created (in particular,
   // the scrollable view). So we have to split Init and Restore.
 
   scrollFrame->Init(aContent, geometricParent, nullptr);
 
-  if (!aBuildCombobox) {
+  if (!aBuildCombobox || Preferences::GetBool(kPrefSelectPopupInContent)) {
     aState.AddChild(scrollFrame, aFrameItems, aContent, aParentFrame);
   }
 
   BuildScrollFrame(aState, aContent, aStyleContext, scrolledFrame,
                    geometricParent, scrollFrame);
 
   if (aState.mFrameState) {
     // Restore frame state for the scroll frame