Bug 1428297 - (Part 2) Ignore the widget/view usage that is used to show the dropdown menu when content-select is enabled.
MozReview-Commit-ID: 68HYWmniXwt
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -3249,17 +3249,20 @@ nsCSSFrameConstructor::ConstructSelectFr
// initialized as absolutely positioned.
nsContainerFrame* scrolledFrame =
NS_NewSelectsAreaFrame(mPresShell, styleContext, flags);
InitializeSelectFrame(aState, listFrame, scrolledFrame, content,
comboboxFrame, listStyle, true,
aItem.mPendingBinding, childItems);
- NS_ASSERTION(listFrame->GetView(), "ListFrame's view is nullptr");
+ if (!nsLayoutUtils::IsContentSelectEnabled()) {
+ // TODO(kuoe0) Remove this assertion when content-select is shipped.
+ 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).
//
// nsComboboxControlFrame needs special frame creation behavior for its first
// piece of anonymous content, which means that we can't take the normal
// ProcessChildren path.
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -7429,17 +7429,18 @@ nsLayoutUtils::GetFrameTransparency(nsIF
return eTransparencyTransparent;
return eTransparencyOpaque;
}
static bool IsPopupFrame(nsIFrame* aFrame)
{
// aFrame is a popup it's the list control frame dropdown for a combobox.
LayoutFrameType frameType = aFrame->Type();
- if (frameType == LayoutFrameType::ListControl) {
+ if (!nsLayoutUtils::IsContentSelectEnabled() &&
+ frameType == LayoutFrameType::ListControl) {
nsListControlFrame* lcf = static_cast<nsListControlFrame*>(aFrame);
return lcf->IsInDropDownMode();
}
// ... or if it's a XUL menupopup frame.
return frameType == LayoutFrameType::MenuPopup;
}
--- a/layout/forms/nsComboboxControlFrame.cpp
+++ b/layout/forms/nsComboboxControlFrame.cpp
@@ -302,16 +302,18 @@ nsComboboxControlFrame::SetFocus(bool aO
// rect to be drawn. This is much faster than ReResolvingStyle
// Bug 32920
InvalidateFrame();
}
void
nsComboboxControlFrame::ShowPopup(bool aShowPopup)
{
+ // TODO(kuoe0) Remove this function when content-select is enabled.
+
nsView* view = mDropdownFrame->GetView();
nsViewManager* viewManager = view->GetViewManager();
if (aShowPopup) {
nsRect rect = mDropdownFrame->GetRect();
rect.x = rect.y = 0;
viewManager->ResizeView(view, rect);
viewManager->SetViewVisibility(view, nsViewVisibility_kShow);
@@ -330,16 +332,26 @@ nsComboboxControlFrame::ShowPopup(bool a
shell->HandleDOMEventWithTarget(mContent, &event, &status);
}
}
bool
nsComboboxControlFrame::ShowList(bool aShowList)
{
+
+ // TODO(kuoe0) Remove this function when content-select is enabled.
+ //
+ // This function is used to handle the widget/view stuff, so we just return
+ // when content-select is enabled. And the following callee, ShowPopup(), will
+ // also be ignored, it is only used to show and hide the widget.
+ if (nsLayoutUtils::IsContentSelectEnabled()) {
+ return true;
+ }
+
nsView* view = mDropdownFrame->GetView();
if (aShowList) {
NS_ASSERTION(!view->HasWidget(),
"We shouldn't have a widget before we need to display the popup");
// Create the widget for the drop-down list
view->GetViewManager()->SetViewFloating(view, true);
@@ -447,17 +459,18 @@ nsComboboxControlFrame::ReflowDropdown(n
// both sets of mComputedBorderPadding.
nscoord forcedISize = aReflowInput.ComputedISize() +
aReflowInput.ComputedLogicalBorderPadding().IStartEnd(wm) -
kidReflowInput.ComputedLogicalBorderPadding().IStartEnd(wm);
kidReflowInput.SetComputedISize(std::max(kidReflowInput.ComputedISize(),
forcedISize));
// ensure we start off hidden
- if (!mDroppedDown && GetStateBits() & NS_FRAME_FIRST_REFLOW) {
+ if (!nsLayoutUtils::IsContentSelectEnabled() &&
+ !mDroppedDown && GetStateBits() & NS_FRAME_FIRST_REFLOW) {
nsView* view = mDropdownFrame->GetView();
nsViewManager* viewManager = view->GetViewManager();
viewManager->SetViewVisibility(view, nsViewVisibility_kHide);
nsRect emptyRect(0, 0, 0, 0);
viewManager->ResizeView(view, emptyRect);
}
// Allow the child to move/size/change-visibility its view if it's currently
@@ -650,17 +663,17 @@ nsComboboxControlFrame::AbsolutelyPositi
}
WritingMode wm = GetWritingMode();
LogicalPoint translation(wm);
nscoord before, after;
mLastDropDownAfterScreenBCoord = nscoord_MIN;
GetAvailableDropdownSpace(wm, &before, &after, &translation);
if (before <= 0 && after <= 0) {
- if (IsDroppedDown()) {
+ if (!nsLayoutUtils::IsContentSelectEnabled() && IsDroppedDown()) {
// Hide the view immediately to minimize flicker.
nsView* view = mDropdownFrame->GetView();
view->GetViewManager()->SetViewVisibility(view, nsViewVisibility_kHide);
NS_DispatchToCurrentThread(new nsAsyncRollup(this));
}
return eDropDownPositionSuppressed;
}
@@ -1401,17 +1414,17 @@ nsComboboxControlFrame::DestroyFrom(nsIF
sFocused = nullptr;
}
// Revoke any pending RedisplayTextEvent
mRedisplayTextEvent.Revoke();
nsCheckboxRadioFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), false);
- if (mDroppedDown) {
+ if (!nsLayoutUtils::IsContentSelectEnabled() && mDroppedDown) {
MOZ_ASSERT(mDropdownFrame, "mDroppedDown without frame");
nsView* view = mDropdownFrame->GetView();
MOZ_ASSERT(view);
nsIWidget* widget = view->GetWidget();
if (widget) {
widget->CaptureRollupEvents(this, false);
}
}
@@ -1480,17 +1493,18 @@ nsComboboxControlFrame::Rollup(uint32_t
if (!weakFrame.IsAlive()) {
return consume;
}
ShowDropDown(false); // might destroy us
if (weakFrame.IsAlive()) {
mListControlFrame->CaptureMouseEvents(false);
}
- if (aFlush && weakFrame.IsAlive()) {
+ if (!nsLayoutUtils::IsContentSelectEnabled() &&
+ aFlush && weakFrame.IsAlive()) {
// The popup's visibility doesn't update until the minimize animation has
// finished, so call UpdateWidgetGeometry to update it right away.
nsViewManager* viewManager = mDropdownFrame->GetView()->GetViewManager();
viewManager->UpdateWidgetGeometry(); // might destroy us
}
if (!weakFrame.IsAlive()) {
return consume;
@@ -1500,16 +1514,20 @@ nsComboboxControlFrame::Rollup(uint32_t
*aLastRolledUp = GetContent();
}
return consume;
}
nsIWidget*
nsComboboxControlFrame::GetRollupWidget()
{
+ if (nsLayoutUtils::IsContentSelectEnabled()) {
+ return nullptr;
+ }
+
nsView* view = mDropdownFrame->GetView();
MOZ_ASSERT(view);
return view->GetWidget();
}
void
nsComboboxControlFrame::RollupFromList()
{
--- a/layout/forms/nsListControlFrame.cpp
+++ b/layout/forms/nsListControlFrame.cpp
@@ -114,16 +114,22 @@ nsListControlFrame::nsListControlFrame(n
//---------------------------------------------------------
nsListControlFrame::~nsListControlFrame()
{
mComboboxFrame = nullptr;
}
static bool ShouldFireDropDownEvent() {
+ // We don't need to fire the event to SelectContentHelper when content-select
+ // is enabled.
+ if (nsLayoutUtils::IsContentSelectEnabled()) {
+ return false;
+ }
+
return (XRE_IsContentProcess() &&
Preferences::GetBool("browser.tabs.remote.desktopbehavior", false)) ||
Preferences::GetBool("dom.select_popup_in_parent.enabled", false);
}
// for Bug 47302 (remove this comment later)
void
nsListControlFrame::DestroyFrom(nsIFrame* aDestructRoot, PostDestroyData& aPostDestroyData)
@@ -964,17 +970,19 @@ nsListControlFrame::SetInitialChildList(
//---------------------------------------------------------
void
nsListControlFrame::Init(nsIContent* aContent,
nsContainerFrame* aParent,
nsIFrame* aPrevInFlow)
{
nsHTMLScrollFrame::Init(aContent, aParent, aPrevInFlow);
- if (IsInDropDownMode()) {
+ if (!nsLayoutUtils::IsContentSelectEnabled() &&
+ IsInDropDownMode()) {
+ // TODO(kuoe0) Remove the following code when content-select is enabled.
AddStateBits(NS_FRAME_IN_POPUP);
CreateView();
}
// we shouldn't have to unregister this listener because when
// our frame goes away all these content node go away as well
// because our frame is the only one who references them.
// we need to hook up our listeners before the editor is initialized