Bug 1425088 - (Part 2) Change the dropdown frame to a top-level absolute frame when content-select is enabled. r=mats
authorKuoE0 <kuoe0.tw@gmail.com>
Wed, 13 Dec 2017 17:59:29 -0600
changeset 452580 a395a065bdd3bdb47b54a9e4848392d7eb6f98e1
parent 452579 f0fc447f97238c68f4482cdf9f02a3ca9e96c1ee
child 452581 75edc4a8cbc37016ec33bcb513a0b6a7859879f1
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs1425088
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1425088 - (Part 2) Change the dropdown frame to a top-level absolute frame when content-select is enabled. r=mats MozReview-Commit-ID: E77XdiELqhm
layout/base/nsCSSFrameConstructor.cpp
layout/style/res/forms.css
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -102,16 +102,17 @@
 #include "nsPageFrame.h"
 #include "nsSimplePageSequenceFrame.h"
 #include "nsTableWrapperFrame.h"
 #include "nsIScrollableFrame.h"
 #include "nsBackdropFrame.h"
 #include "nsTransitionManager.h"
 #include "DetailsFrame.h"
 #include "nsThemeConstants.h"
+#include "mozilla/Preferences.h"
 
 #ifdef MOZ_XUL
 #include "nsIRootBox.h"
 #endif
 #ifdef ACCESSIBILITY
 #include "nsAccessibilityService.h"
 #endif
 
@@ -129,16 +130,17 @@
 #include "ActiveLayerTracker.h"
 #include "nsIPresShellInlines.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 // An alias for convenience.
 static const nsIFrame::ChildListID kPrincipalList = nsIFrame::kPrincipalList;
+static const char* kPrefSelectPopupInContent = "dom.select_popup_in_content.enabled";
 
 nsIFrame*
 NS_NewHTMLCanvasFrame (nsIPresShell* aPresShell, nsStyleContext* aContext);
 
 nsIFrame*
 NS_NewHTMLVideoFrame (nsIPresShell* aPresShell, nsStyleContext* aContext);
 
 nsContainerFrame*
@@ -3229,18 +3231,21 @@ nsCSSFrameConstructor::ConstructSelectFr
     // Notify the listbox that it is being used as a dropdown list.
     nsIListControlFrame * listControlFrame = do_QueryFrame(listFrame);
     if (listControlFrame) {
       listControlFrame->SetComboboxFrame(comboboxFrame);
     }
     // Notify combobox that it should use the listbox as it's popup
     comboboxFrame->SetDropDown(listFrame);
 
-    NS_ASSERTION(!listFrame->IsAbsPosContainingBlock(),
-                 "Ended up with positioned dropdown list somehow.");
+    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.");
 
     // Initialize the scroll frame positioned. Note that it is NOT
     // initialized as absolutely positioned.
     nsContainerFrame* scrolledFrame =
       NS_NewSelectsAreaFrame(mPresShell, styleContext, flags);
 
--- a/layout/style/res/forms.css
+++ b/layout/style/res/forms.css
@@ -417,16 +417,23 @@ optgroup:before {
    * to make sure that our inline-start border+padding matches the inline-start
    * border+padding of a combobox so that our scrollbar will line up
    * with the dropmarker.  So set our inline-start border to 2px.
    */
   border: 1px outset black !important;
   border-inline-start-width: 2px ! important;
 }
 
+@supports -moz-bool-pref("dom.select_popup_in_content.enabled") {
+  select::-moz-dropdown-list {
+    -moz-top-layer: top !important;
+    position: absolute !important;
+  }
+}
+
 input:disabled,
 textarea:disabled,
 option:disabled,
 optgroup:disabled,
 select:disabled:disabled /* Need the pseudo-class twice to have the specificity
                             be at least the same as select[size][multiple] above */
 {
   -moz-user-input: disabled;