Bug 1494330 Part 3 - Remove nsComboboxControlFrame::mListControlFrame. r=layout-reviewers,boris
authorTing-Yu Lin <tlin@mozilla.com>
Wed, 07 Jul 2021 03:11:06 +0000
changeset 584948 6ff478f9cce9079d913c4f966536b02f704d5f70
parent 584947 dd89d3803b2034b0a90c8280be72deea2594efe6
child 584949 701ca0fe4211ea49a095f1fd750a442faad02d4a
push id145893
push useraethanyc@gmail.com
push dateWed, 07 Jul 2021 03:13:42 +0000
treeherderautoland@6ff478f9cce9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslayout-reviewers, boris
bugs1494330
milestone91.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 1494330 Part 3 - Remove nsComboboxControlFrame::mListControlFrame. r=layout-reviewers,boris mListControlFrame is the same as mDropdownFrame. See SetDropDown(). Differential Revision: https://phabricator.services.mozilla.com/D119207
layout/forms/nsComboboxControlFrame.cpp
layout/forms/nsComboboxControlFrame.h
--- a/layout/forms/nsComboboxControlFrame.cpp
+++ b/layout/forms/nsComboboxControlFrame.cpp
@@ -222,17 +222,16 @@ static int32_t gReflowInx = -1;
 //------------------------------------------------------
 
 nsComboboxControlFrame::nsComboboxControlFrame(ComputedStyle* aStyle,
                                                nsPresContext* aPresContext)
     : nsBlockFrame(aStyle, aPresContext, kClassID),
       mDisplayFrame(nullptr),
       mButtonFrame(nullptr),
       mDropdownFrame(nullptr),
-      mListControlFrame(nullptr),
       mDisplayISize(0),
       mMaxDisplayISize(0),
       mRecentSelectedIndex(NS_SKIP_NOTIFY_INDEX),
       mDisplayedIndex(-1),
       mLastDropDownBeforeScreenBCoord(nscoord_MIN),
       mLastDropDownAfterScreenBCoord(nscoord_MIN),
       mDroppedDown(false),
       mInRedisplayText(false),
@@ -270,23 +269,23 @@ void nsComboboxControlFrame::SetFocus(bo
       if (!weakFrame.IsAlive()) {
         return;
       }
     }
   } else {
     sFocused = nullptr;
     mDelayedShowDropDown = false;
     if (mDroppedDown) {
-      mListControlFrame->ComboboxFinish(mDisplayedIndex);  // might destroy us
+      mDropdownFrame->ComboboxFinish(mDisplayedIndex);  // might destroy us
       if (!weakFrame.IsAlive()) {
         return;
       }
     }
     // May delete |this|.
-    mListControlFrame->FireOnInputAndOnChange();
+    mDropdownFrame->FireOnInputAndOnChange();
   }
 
   if (!weakFrame.IsAlive()) {
     return;
   }
 
   // This is needed on a temporary basis. It causes the focus
   // rect to be drawn. This is much faster than ReResolvingStyle
@@ -350,18 +349,18 @@ bool nsComboboxControlFrame::ShowList(bo
     return false;
   }
 
   mDroppedDown = aShowList;
   nsIWidget* widget = view->GetWidget();
   if (mDroppedDown) {
     // The listcontrol frame will call back to the nsComboboxControlFrame's
     // ListWasSelected which will stop the capture.
-    mListControlFrame->AboutToDropDown();
-    mListControlFrame->CaptureMouseEvents(true);
+    mDropdownFrame->AboutToDropDown();
+    mDropdownFrame->CaptureMouseEvents(true);
     if (widget) {
       widget->CaptureRollupEvents(this, true);
     }
   } else {
     if (widget) {
       view->DestroyWidget();
     }
   }
@@ -734,25 +733,23 @@ nscoord nsComboboxControlFrame::DropDown
       presContext, this, StyleAppearance::MozMenulistArrowButton,
       &dropdownButtonSize, &canOverride);
 
   return presContext->DevPixelsToAppUnits(dropdownButtonSize.width);
 }
 
 nscoord nsComboboxControlFrame::GetIntrinsicISize(gfxContext* aRenderingContext,
                                                   IntrinsicISizeType aType) {
+  MOZ_ASSERT(mDropdownFrame, "No dropdown frame!");
+
   // get the scrollbar width, we'll use this later
   nscoord scrollbarWidth = 0;
   nsPresContext* presContext = PresContext();
-  if (mListControlFrame) {
-    nsIScrollableFrame* scrollable = do_QueryFrame(mListControlFrame);
-    NS_ASSERTION(scrollable, "List must be a scrollable frame");
-    scrollbarWidth = scrollable->GetNondisappearingScrollbarWidth(
-        presContext, aRenderingContext, GetWritingMode());
-  }
+  scrollbarWidth = mDropdownFrame->GetNondisappearingScrollbarWidth(
+      presContext, aRenderingContext, GetWritingMode());
 
   const bool isContainSize = StyleDisplay()->IsContainSize();
   nscoord displayISize = 0;
   if (MOZ_LIKELY(mDisplayFrame)) {
     if (isContainSize) {
       // Get padding from the inline-axis
       displayISize = mDisplayFrame->IntrinsicISizeOffsets().padding;
     } else {
@@ -816,27 +813,27 @@ void nsComboboxControlFrame::Reflow(nsPr
 
   // 1) Default inline size of button is the vertical scrollbar size
   // 2) If the inline size of button is bigger than our inline size, set
   //    inline size of button to 0.
   // 3) Default block size of button is block size of display area
   // 4) Inline size of display area is whatever is left over from our
   //    inline size after allocating inline size for the button.
   // 5) Block Size of display area is GetBSizeOfARow() on the
-  //    mListControlFrame.
+  //    mDropdownFrame.
 
   if (!mDisplayFrame || !mButtonFrame || !mDropdownFrame) {
     NS_ERROR("Why did the frame constructor allow this to happen?  Fix it!!");
     return;
   }
 
   // Make sure the displayed text is the same as the selected option,
   // bug 297389.
   if (!mDroppedDown) {
-    mDisplayedIndex = mListControlFrame->GetSelectedIndex();
+    mDisplayedIndex = mDropdownFrame->GetSelectedIndex();
   }
   // In dropped down mode the "selected index" is the hovered menu item,
   // we want the last selected item which is |mDisplayedIndex| in this case.
   RedisplayText();
 
   // First reflow our dropdown so that we know how tall we should be.
   ReflowDropdown(aPresContext, aReflowInput);
   RefPtr<nsResizeDropdownAtFinalPosition> resize =
@@ -916,45 +913,44 @@ void nsComboboxControlFrame::ShowDropDow
     }
   } else if (mDroppedDown && !aDoDropDown) {
     ShowList(aDoDropDown);  // might destroy us
   }
 }
 
 void nsComboboxControlFrame::SetDropDown(nsListControlFrame* aDropDownFrame) {
   mDropdownFrame = aDropDownFrame;
-  mListControlFrame = do_QueryFrame(mDropdownFrame);
   if (!sFocused && nsContentUtils::IsFocusedContent(GetContent())) {
     sFocused = this;
     nsListControlFrame::ComboboxFocusSet();
   }
 }
 
 nsIFrame* nsComboboxControlFrame::GetDropDown() { return mDropdownFrame; }
 
 ///////////////////////////////////////////////////////////////
 
 nsresult nsComboboxControlFrame::RedisplaySelectedText() {
   nsAutoScriptBlocker scriptBlocker;
-  mDisplayedIndex = mListControlFrame->GetSelectedIndex();
+  mDisplayedIndex = mDropdownFrame->GetSelectedIndex();
   return RedisplayText();
 }
 
 nsresult nsComboboxControlFrame::RedisplayText() {
   nsString previewValue;
   nsString previousText(mDisplayedOptionTextOrPreview);
 
   auto* selectElement = static_cast<dom::HTMLSelectElement*>(GetContent());
   selectElement->GetPreviewValue(previewValue);
   // Get the text to display
   if (!previewValue.IsEmpty()) {
     mDisplayedOptionTextOrPreview = previewValue;
   } else if (mDisplayedIndex != -1 && !StyleContent()->mContent.IsNone()) {
-    mListControlFrame->GetOptionText(mDisplayedIndex,
-                                     mDisplayedOptionTextOrPreview);
+    mDropdownFrame->GetOptionText(mDisplayedIndex,
+                                  mDisplayedOptionTextOrPreview);
   } else {
     mDisplayedOptionTextOrPreview.Truncate();
   }
 
   REFLOW_DEBUG_MSG2(
       "RedisplayText \"%s\"\n",
       NS_LossyConvertUTF16toASCII(mDisplayedOptionTextOrPreview).get());
 
@@ -1049,17 +1045,17 @@ nsComboboxControlFrame::AddOption(int32_
   }
 
   return mDropdownFrame->AddOption(aIndex);
 }
 
 NS_IMETHODIMP
 nsComboboxControlFrame::RemoveOption(int32_t aIndex) {
   AutoWeakFrame weakThis(this);
-  if (mListControlFrame->GetNumberOfOptions() > 0) {
+  if (mDropdownFrame->GetNumberOfOptions() > 0) {
     if (aIndex < mDisplayedIndex) {
       --mDisplayedIndex;
     } else if (aIndex == mDisplayedIndex) {
       mDisplayedIndex = 0;  // IE6 compat
       RedisplayText();
     }
   } else {
     // If we removed the last option, we need to blank things out
@@ -1157,20 +1153,20 @@ nsresult nsComboboxControlFrame::CreateA
 
   // Add a child text content node for the label
 
   nsNodeInfoManager* nimgr = mContent->NodeInfo()->NodeInfoManager();
 
   mDisplayContent = new (nimgr) nsTextNode(nimgr);
 
   // set the value of the text node
-  mDisplayedIndex = mListControlFrame->GetSelectedIndex();
+  mDisplayedIndex = mDropdownFrame->GetSelectedIndex();
   if (mDisplayedIndex != -1) {
-    mListControlFrame->GetOptionText(mDisplayedIndex,
-                                     mDisplayedOptionTextOrPreview);
+    mDropdownFrame->GetOptionText(mDisplayedIndex,
+                                  mDisplayedOptionTextOrPreview);
   }
   ActuallyDisplayText(false);
 
   // XXX(Bug 1631371) Check if this should use a fallible operation as it
   // pretended earlier.
   aElements.AppendElement(mDisplayContent);
 
   mButtonContent = mContent->OwnerDoc()->CreateHTMLElement(nsGkAtoms::button);
@@ -1424,23 +1420,23 @@ bool nsComboboxControlFrame::Rollup(uint
   }
 
   if (!mDroppedDown) {
     return false;
   }
 
   bool consume = !!COMBOBOX_ROLLUP_CONSUME_EVENT;
   AutoWeakFrame weakFrame(this);
-  mListControlFrame->AboutToRollup();  // might destroy us
+  mDropdownFrame->AboutToRollup();  // might destroy us
   if (!weakFrame.IsAlive()) {
     return consume;
   }
   ShowDropDown(false);  // might destroy us
   if (weakFrame.IsAlive()) {
-    mListControlFrame->CaptureMouseEvents(false);
+    mDropdownFrame->CaptureMouseEvents(false);
   }
 
   if (aFlush && weakFrame.IsAlive()) {
     // The popup's visibility doesn't update until the minimize animation has
     // finished, so call UpdateWidgetGeometry to update it right away.
     RefPtr<nsViewManager> viewManager =
         mDropdownFrame->GetView()->GetViewManager();
     viewManager->UpdateWidgetGeometry();  // might destroy us
@@ -1458,17 +1454,19 @@ bool nsComboboxControlFrame::Rollup(uint
 
 nsIWidget* nsComboboxControlFrame::GetRollupWidget() {
   nsView* view = mDropdownFrame->GetView();
   MOZ_ASSERT(view);
   return view->GetWidget();
 }
 
 void nsComboboxControlFrame::RollupFromList() {
-  if (ShowList(false)) mListControlFrame->CaptureMouseEvents(false);
+  if (ShowList(false)) {
+    mDropdownFrame->CaptureMouseEvents(false);
+  }
 }
 
 int32_t nsComboboxControlFrame::UpdateRecentIndex(int32_t aIndex) {
   int32_t index = mRecentSelectedIndex;
   if (mRecentSelectedIndex == NS_SKIP_NOTIFY_INDEX ||
       aIndex == NS_SKIP_NOTIFY_INDEX)
     mRecentSelectedIndex = aIndex;
   return index;
@@ -1552,20 +1550,17 @@ void nsComboboxControlFrame::PaintFocus(
 
 //---------------------------------------------------------
 // gets the content (an option) by index and then set it as
 // being selected or not selected
 //---------------------------------------------------------
 NS_IMETHODIMP
 nsComboboxControlFrame::OnOptionSelected(int32_t aIndex, bool aSelected) {
   if (mDroppedDown) {
-    nsISelectControlFrame* selectFrame = do_QueryFrame(mListControlFrame);
-    if (selectFrame) {
-      selectFrame->OnOptionSelected(aIndex, aSelected);
-    }
+    mDropdownFrame->OnOptionSelected(aIndex, aSelected);
   } else {
     if (aSelected) {
       nsAutoScriptBlocker blocker;
       mDisplayedIndex = aIndex;
       RedisplayText();
     } else {
       AutoWeakFrame weakFrame(this);
       RedisplaySelectedText();
@@ -1580,19 +1575,17 @@ nsComboboxControlFrame::OnOptionSelected
 
 void nsComboboxControlFrame::FireValueChangeEvent() {
   // Fire ValueChange event to indicate data value of combo box has changed
   nsContentUtils::AddScriptRunner(new AsyncEventDispatcher(
       mContent, u"ValueChange"_ns, CanBubble::eYes, ChromeOnlyDispatch::eNo));
 }
 
 void nsComboboxControlFrame::OnContentReset() {
-  if (mListControlFrame) {
-    mListControlFrame->OnContentReset();
-  }
+  mDropdownFrame->OnContentReset();
 }
 
 //--------------------------------------------------------
 // nsIStatefulFrame
 //--------------------------------------------------------
 UniquePtr<PresState> nsComboboxControlFrame::SaveState() {
   UniquePtr<PresState> state = NewPresState();
   state->droppedDown() = mDroppedDown;
--- a/layout/forms/nsComboboxControlFrame.h
+++ b/layout/forms/nsComboboxControlFrame.h
@@ -280,17 +280,16 @@ class nsComboboxControlFrame final : pub
  protected:
   nsFrameList mPopupFrames;            // additional named child list
   RefPtr<nsTextNode> mDisplayContent;  // Anonymous content used to display the
                                        // current selection
   RefPtr<Element> mButtonContent;      // Anonymous content for the button
   nsContainerFrame* mDisplayFrame;     // frame to display selection
   nsIFrame* mButtonFrame;              // button frame
   nsListControlFrame* mDropdownFrame;  // dropdown list frame
-  nsListControlFrame* mListControlFrame;  // ListControl for the dropdown frame
 
   // The inline size of our display area.  Used by that frame's reflow
   // to size to the full inline size except the drop-marker.
   nscoord mDisplayISize;
   // The maximum inline size of our display area, which is the
   // nsComoboxControlFrame's border-box.
   //
   // Going over this would be observable via DOM APIs like client / scrollWidth.