2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-01-18 18:14:00 +03:00
|
|
|
|
|
|
|
#ifndef nsComboboxControlFrame_h___
|
|
|
|
#define nsComboboxControlFrame_h___
|
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
#ifdef DEBUG_evaughan
|
|
|
|
//#define DEBUG_rods
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef DEBUG_rods
|
2000-10-04 17:39:07 +04:00
|
|
|
//#define DO_REFLOW_DEBUG
|
|
|
|
//#define DO_REFLOW_COUNTER
|
2000-03-15 18:47:11 +03:00
|
|
|
//#define DO_UNCONSTRAINED_CHECK
|
2000-03-07 18:54:31 +03:00
|
|
|
//#define DO_PIXELS
|
|
|
|
//#define DO_NEW_REFLOW
|
|
|
|
#endif
|
2000-01-05 19:42:47 +03:00
|
|
|
|
2006-09-30 09:07:49 +04:00
|
|
|
// Mark used to indicate when onchange has been fired for current combobox item
|
|
|
|
#define NS_SKIP_NOTIFY_INDEX -2
|
|
|
|
|
2012-09-14 20:10:08 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2008-12-29 18:07:38 +03:00
|
|
|
#include "nsBlockFrame.h"
|
1999-01-18 18:14:00 +03:00
|
|
|
#include "nsIFormControlFrame.h"
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
#include "nsIAnonymousContentCreator.h"
|
1999-08-26 18:54:07 +04:00
|
|
|
#include "nsISelectControlFrame.h"
|
1999-09-22 01:20:50 +04:00
|
|
|
#include "nsIRollupListener.h"
|
2006-05-10 21:30:15 +04:00
|
|
|
#include "nsThreadUtils.h"
|
1999-01-18 18:14:00 +03:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
class nsComboboxDisplayFrame;
|
2018-03-29 01:01:46 +03:00
|
|
|
class nsTextNode;
|
1999-01-18 18:14:00 +03:00
|
|
|
|
2015-01-21 19:23:28 +03:00
|
|
|
namespace mozilla {
|
2019-04-16 10:24:49 +03:00
|
|
|
class PresShell;
|
Bug 1744009 - Simplify combobox <select> code. r=mconley,dholbert
With this patch on its own we get some a11y tests failures, but those
are fixed on a later patch.
Combobox select no longer creates frames for its <options>, nor an
nsListControlFrame. Instead, it computes its right intrinsic size using
the largest size of the options. This is better, because we render the
option text using the select style so if the select and option styles
are mismatched it'd cause changes in the size of the select when text
changes. See the following in a build without the patch, for example:
<select>
<option>ABC</option>
<option style="font-size: 1px">Something long</option>
</select>
This seems like a rather obscure case, but it's important to get it
right, see bug 1741888.
With this patch we use the same setup in content and parent processes
(this needs bug 1596852 and bug 1744152). This means we can remove a
bunch of the native view and popup code in nsListControlFrame. A couple
browser_* tests are affected by this change and have been tweaked
appropriately (the changes there are trivial).
Not creating an nsListControlFrame for dropdown select means that we
need to move a bunch of the event handling code from nsListControlFrame
to a common place that nsComboboxControlFrame can also use. That place
is HTMLSelectEventListener, and I think the setup is much nicer than
having the code intertwined with nsListControlFrame. It should be
relatively straight-forward to review, mostly moving code from one part
to another.
Another thing that we need to do in HTMLSelectEventListener that we
didn't use to do is listening for DOM mutations on the dropdown. Before,
we were relying on changes like text mutations triggering a reflow of
the listcontrolframe, which also triggered a reflow of the
comboboxcontrolframe, which in turn updated the text of the anonymous
content. Now we need to trigger that reflow manually.
There are some further simplifications that can be done after this
lands (cleanup naming of openInParentProcess and so on, among others),
but I'd rather land this first (after the merge of course) and work on
them separately.
Differential Revision: https://phabricator.services.mozilla.com/D132719
2022-01-17 14:10:05 +03:00
|
|
|
class HTMLSelectEventListener;
|
|
|
|
namespace dom {
|
|
|
|
class HTMLSelectElement;
|
|
|
|
}
|
|
|
|
|
2015-01-21 19:23:28 +03:00
|
|
|
namespace gfx {
|
|
|
|
class DrawTarget;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|
2015-01-21 19:23:28 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsComboboxControlFrame final : public nsBlockFrame,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsIFormControlFrame,
|
|
|
|
public nsIAnonymousContentCreator,
|
Bug 1744009 - Simplify combobox <select> code. r=mconley,dholbert
With this patch on its own we get some a11y tests failures, but those
are fixed on a later patch.
Combobox select no longer creates frames for its <options>, nor an
nsListControlFrame. Instead, it computes its right intrinsic size using
the largest size of the options. This is better, because we render the
option text using the select style so if the select and option styles
are mismatched it'd cause changes in the size of the select when text
changes. See the following in a build without the patch, for example:
<select>
<option>ABC</option>
<option style="font-size: 1px">Something long</option>
</select>
This seems like a rather obscure case, but it's important to get it
right, see bug 1741888.
With this patch we use the same setup in content and parent processes
(this needs bug 1596852 and bug 1744152). This means we can remove a
bunch of the native view and popup code in nsListControlFrame. A couple
browser_* tests are affected by this change and have been tweaked
appropriately (the changes there are trivial).
Not creating an nsListControlFrame for dropdown select means that we
need to move a bunch of the event handling code from nsListControlFrame
to a common place that nsComboboxControlFrame can also use. That place
is HTMLSelectEventListener, and I think the setup is much nicer than
having the code intertwined with nsListControlFrame. It should be
relatively straight-forward to review, mostly moving code from one part
to another.
Another thing that we need to do in HTMLSelectEventListener that we
didn't use to do is listening for DOM mutations on the dropdown. Before,
we were relying on changes like text mutations triggering a reflow of
the listcontrolframe, which also triggered a reflow of the
comboboxcontrolframe, which in turn updated the text of the anonymous
content. Now we need to trigger that reflow manually.
There are some further simplifications that can be done after this
lands (cleanup naming of openInParentProcess and so on, among others),
but I'd rather land this first (after the merge of course) and work on
them separately.
Differential Revision: https://phabricator.services.mozilla.com/D132719
2022-01-17 14:10:05 +03:00
|
|
|
public nsISelectControlFrame {
|
2019-11-29 23:39:36 +03:00
|
|
|
using DrawTarget = mozilla::gfx::DrawTarget;
|
|
|
|
using Element = mozilla::dom::Element;
|
2015-01-21 19:23:28 +03:00
|
|
|
|
1999-01-18 18:14:00 +03:00
|
|
|
public:
|
2017-01-27 04:47:52 +03:00
|
|
|
friend nsComboboxControlFrame* NS_NewComboboxControlFrame(
|
2019-04-16 10:24:49 +03:00
|
|
|
mozilla::PresShell* aPresShell, ComputedStyle* aStyle,
|
|
|
|
nsFrameState aFlags);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
friend class nsComboboxDisplayFrame;
|
1999-12-05 23:43:18 +03:00
|
|
|
|
2019-02-05 19:45:54 +03:00
|
|
|
explicit nsComboboxControlFrame(ComputedStyle* aStyle,
|
|
|
|
nsPresContext* aPresContext);
|
1999-01-18 18:14:00 +03:00
|
|
|
~nsComboboxControlFrame();
|
|
|
|
|
2009-01-12 22:20:59 +03:00
|
|
|
NS_DECL_QUERYFRAME
|
2017-05-26 13:11:11 +03:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(nsComboboxControlFrame)
|
2007-02-18 20:34:09 +03:00
|
|
|
|
|
|
|
// nsIAnonymousContentCreator
|
2021-07-08 20:58:42 +03:00
|
|
|
nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) final;
|
|
|
|
void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements,
|
|
|
|
uint32_t aFilter) final;
|
2017-01-27 00:12:42 +03:00
|
|
|
|
2018-03-29 01:01:46 +03:00
|
|
|
nsIContent* GetDisplayNode() const;
|
2017-01-27 00:12:42 +03:00
|
|
|
nsIFrame* CreateFrameForDisplayNode();
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
|
2001-08-17 07:13:07 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2021-07-08 20:58:42 +03:00
|
|
|
mozilla::a11y::AccType AccessibleType() final;
|
2001-08-17 07:13:07 +04:00
|
|
|
#endif
|
2001-05-18 03:52:32 +04:00
|
|
|
|
2021-07-08 20:58:42 +03:00
|
|
|
nscoord GetMinISize(gfxContext* aRenderingContext) final;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
2021-07-08 20:58:42 +03:00
|
|
|
nscoord GetPrefISize(gfxContext* aRenderingContext) final;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
2021-07-08 20:58:42 +03:00
|
|
|
void Reflow(nsPresContext* aCX, ReflowOutput& aDesiredSize,
|
|
|
|
const ReflowInput& aReflowInput, nsReflowStatus& aStatus) final;
|
1999-01-18 18:14:00 +03:00
|
|
|
|
2019-05-09 23:21:28 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
2021-07-08 20:58:42 +03:00
|
|
|
nsresult HandleEvent(nsPresContext* aPresContext,
|
|
|
|
mozilla::WidgetGUIEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus) final;
|
1999-07-29 01:38:08 +04:00
|
|
|
|
2021-07-08 20:58:42 +03:00
|
|
|
void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aLists) final;
|
2006-01-26 05:29:17 +03:00
|
|
|
|
2015-01-21 19:23:28 +03:00
|
|
|
void PaintFocus(DrawTarget& aDrawTarget, nsPoint aPt);
|
2006-01-26 05:29:17 +03:00
|
|
|
|
2021-07-08 20:58:42 +03:00
|
|
|
bool IsFrameOfType(uint32_t aFlags) const final {
|
2008-12-29 18:07:38 +03:00
|
|
|
return nsBlockFrame::IsFrameOfType(
|
2007-02-24 21:33:33 +03:00
|
|
|
aFlags & ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock));
|
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
Bug 1744009 - Simplify combobox <select> code. r=mconley,dholbert
With this patch on its own we get some a11y tests failures, but those
are fixed on a later patch.
Combobox select no longer creates frames for its <options>, nor an
nsListControlFrame. Instead, it computes its right intrinsic size using
the largest size of the options. This is better, because we render the
option text using the select style so if the select and option styles
are mismatched it'd cause changes in the size of the select when text
changes. See the following in a build without the patch, for example:
<select>
<option>ABC</option>
<option style="font-size: 1px">Something long</option>
</select>
This seems like a rather obscure case, but it's important to get it
right, see bug 1741888.
With this patch we use the same setup in content and parent processes
(this needs bug 1596852 and bug 1744152). This means we can remove a
bunch of the native view and popup code in nsListControlFrame. A couple
browser_* tests are affected by this change and have been tweaked
appropriately (the changes there are trivial).
Not creating an nsListControlFrame for dropdown select means that we
need to move a bunch of the event handling code from nsListControlFrame
to a common place that nsComboboxControlFrame can also use. That place
is HTMLSelectEventListener, and I think the setup is much nicer than
having the code intertwined with nsListControlFrame. It should be
relatively straight-forward to review, mostly moving code from one part
to another.
Another thing that we need to do in HTMLSelectEventListener that we
didn't use to do is listening for DOM mutations on the dropdown. Before,
we were relying on changes like text mutations triggering a reflow of
the listcontrolframe, which also triggered a reflow of the
comboboxcontrolframe, which in turn updated the text of the anonymous
content. Now we need to trigger that reflow manually.
There are some further simplifications that can be done after this
lands (cleanup naming of openInParentProcess and so on, among others),
but I'd rather land this first (after the merge of course) and work on
them separately.
Differential Revision: https://phabricator.services.mozilla.com/D132719
2022-01-17 14:10:05 +03:00
|
|
|
void Init(nsIContent* aContent, nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow) final;
|
2009-09-01 15:22:31 +04:00
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2021-07-08 20:58:42 +03:00
|
|
|
nsresult GetFrameName(nsAString& aResult) const final;
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
2021-07-08 20:58:42 +03:00
|
|
|
void DestroyFrom(nsIFrame* aDestructRoot,
|
|
|
|
PostDestroyData& aPostDestroyData) final;
|
|
|
|
void SetInitialChildList(ChildListID aListID, nsFrameList& aChildList) final;
|
|
|
|
const nsFrameList& GetChildList(ChildListID aListID) const final;
|
|
|
|
void GetChildLists(nsTArray<ChildList>* aLists) const final;
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
|
2021-07-08 20:58:42 +03:00
|
|
|
nsContainerFrame* GetContentInsertionFrame() final;
|
2004-07-18 16:02:53 +04:00
|
|
|
|
2017-06-16 12:22:33 +03:00
|
|
|
// Return the dropdown and display frame.
|
2021-07-08 20:58:42 +03:00
|
|
|
void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) final;
|
2017-03-15 21:00:43 +03:00
|
|
|
|
2005-12-13 02:53:06 +03:00
|
|
|
// nsIFormControlFrame
|
Bug 1744009 - Simplify combobox <select> code. r=mconley,dholbert
With this patch on its own we get some a11y tests failures, but those
are fixed on a later patch.
Combobox select no longer creates frames for its <options>, nor an
nsListControlFrame. Instead, it computes its right intrinsic size using
the largest size of the options. This is better, because we render the
option text using the select style so if the select and option styles
are mismatched it'd cause changes in the size of the select when text
changes. See the following in a build without the patch, for example:
<select>
<option>ABC</option>
<option style="font-size: 1px">Something long</option>
</select>
This seems like a rather obscure case, but it's important to get it
right, see bug 1741888.
With this patch we use the same setup in content and parent processes
(this needs bug 1596852 and bug 1744152). This means we can remove a
bunch of the native view and popup code in nsListControlFrame. A couple
browser_* tests are affected by this change and have been tweaked
appropriately (the changes there are trivial).
Not creating an nsListControlFrame for dropdown select means that we
need to move a bunch of the event handling code from nsListControlFrame
to a common place that nsComboboxControlFrame can also use. That place
is HTMLSelectEventListener, and I think the setup is much nicer than
having the code intertwined with nsListControlFrame. It should be
relatively straight-forward to review, mostly moving code from one part
to another.
Another thing that we need to do in HTMLSelectEventListener that we
didn't use to do is listening for DOM mutations on the dropdown. Before,
we were relying on changes like text mutations triggering a reflow of
the listcontrolframe, which also triggered a reflow of the
comboboxcontrolframe, which in turn updated the text of the anonymous
content. Now we need to trigger that reflow manually.
There are some further simplifications that can be done after this
lands (cleanup naming of openInParentProcess and so on, among others),
but I'd rather land this first (after the merge of course) and work on
them separately.
Differential Revision: https://phabricator.services.mozilla.com/D132719
2022-01-17 14:10:05 +03:00
|
|
|
nsresult SetFormProperty(nsAtom* aName, const nsAString& aValue) final {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-05-17 15:12:30 +04:00
|
|
|
/**
|
|
|
|
* Inform the control that it got (or lost) focus.
|
|
|
|
* If it lost focus, the dropdown menu will be rolled up if needed,
|
|
|
|
* and FireOnChange() will be called.
|
2011-10-17 18:59:28 +04:00
|
|
|
* @param aOn true if got focus, false if lost focus.
|
2018-11-28 01:08:11 +03:00
|
|
|
* @param aRepaint if true then force repaint (NOTE: we always force repaint
|
2018-12-21 06:07:05 +03:00
|
|
|
* currently)
|
2007-05-17 15:12:30 +04:00
|
|
|
* @note This method might destroy |this|.
|
|
|
|
*/
|
2018-11-21 06:59:02 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
2021-07-08 20:58:42 +03:00
|
|
|
void SetFocus(bool aOn, bool aRepaint) final;
|
1999-03-06 22:43:13 +03:00
|
|
|
|
2012-06-23 05:13:56 +04:00
|
|
|
/**
|
2015-02-08 18:31:14 +03:00
|
|
|
* Return the available space before and after this frame for
|
2012-06-23 05:13:56 +04:00
|
|
|
* placing the drop-down list, and the current 2D translation.
|
|
|
|
* Note that either or both can be less than or equal to zero,
|
|
|
|
* if both are then the drop-down should be closed.
|
|
|
|
*/
|
2015-02-08 18:31:14 +03:00
|
|
|
void GetAvailableDropdownSpace(mozilla::WritingMode aWM, nscoord* aBefore,
|
|
|
|
nscoord* aAfter,
|
|
|
|
mozilla::LogicalPoint* aTranslation);
|
2018-09-26 17:41:12 +03:00
|
|
|
int32_t GetIndexOfDisplayArea();
|
2009-02-18 06:27:25 +03:00
|
|
|
/**
|
|
|
|
* @note This method might destroy |this|.
|
|
|
|
*/
|
2018-09-26 17:41:12 +03:00
|
|
|
nsresult RedisplaySelectedText();
|
|
|
|
int32_t UpdateRecentIndex(int32_t aIndex);
|
1999-08-26 18:54:07 +04:00
|
|
|
|
2022-02-16 01:00:27 +03:00
|
|
|
bool IsDroppedDown() const;
|
2016-08-03 14:45:46 +03:00
|
|
|
|
1999-08-26 18:54:07 +04:00
|
|
|
// nsISelectControlFrame
|
2021-07-08 20:58:42 +03:00
|
|
|
NS_IMETHOD AddOption(int32_t index) final;
|
|
|
|
NS_IMETHOD RemoveOption(int32_t index) final;
|
|
|
|
NS_IMETHOD DoneAddingChildren(bool aIsDone) final;
|
|
|
|
NS_IMETHOD OnOptionSelected(int32_t aIndex, bool aSelected) final;
|
2019-01-22 22:03:07 +03:00
|
|
|
NS_IMETHOD_(void)
|
2021-07-08 20:58:42 +03:00
|
|
|
OnSetSelectedIndex(int32_t aOldIndex, int32_t aNewIndex) final;
|
1999-09-15 09:31:31 +04:00
|
|
|
|
Bug 1744009 - Simplify combobox <select> code. r=mconley,dholbert
With this patch on its own we get some a11y tests failures, but those
are fixed on a later patch.
Combobox select no longer creates frames for its <options>, nor an
nsListControlFrame. Instead, it computes its right intrinsic size using
the largest size of the options. This is better, because we render the
option text using the select style so if the select and option styles
are mismatched it'd cause changes in the size of the select when text
changes. See the following in a build without the patch, for example:
<select>
<option>ABC</option>
<option style="font-size: 1px">Something long</option>
</select>
This seems like a rather obscure case, but it's important to get it
right, see bug 1741888.
With this patch we use the same setup in content and parent processes
(this needs bug 1596852 and bug 1744152). This means we can remove a
bunch of the native view and popup code in nsListControlFrame. A couple
browser_* tests are affected by this change and have been tweaked
appropriately (the changes there are trivial).
Not creating an nsListControlFrame for dropdown select means that we
need to move a bunch of the event handling code from nsListControlFrame
to a common place that nsComboboxControlFrame can also use. That place
is HTMLSelectEventListener, and I think the setup is much nicer than
having the code intertwined with nsListControlFrame. It should be
relatively straight-forward to review, mostly moving code from one part
to another.
Another thing that we need to do in HTMLSelectEventListener that we
didn't use to do is listening for DOM mutations on the dropdown. Before,
we were relying on changes like text mutations triggering a reflow of
the listcontrolframe, which also triggered a reflow of the
comboboxcontrolframe, which in turn updated the text of the anonymous
content. Now we need to trigger that reflow manually.
There are some further simplifications that can be done after this
lands (cleanup naming of openInParentProcess and so on, among others),
but I'd rather land this first (after the merge of course) and work on
them separately.
Differential Revision: https://phabricator.services.mozilla.com/D132719
2022-01-17 14:10:05 +03:00
|
|
|
int32_t CharCountOfLargestOptionForInflation() const;
|
2005-02-16 08:13:16 +03:00
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
protected:
|
2012-06-23 05:13:56 +04:00
|
|
|
friend class RedisplayTextEvent;
|
|
|
|
friend class nsAsyncResize;
|
|
|
|
friend class nsResizeDropdownAtFinalPosition;
|
2002-01-26 02:35:44 +03:00
|
|
|
|
2018-01-10 22:09:18 +03:00
|
|
|
// Return true if we should render a dropdown button.
|
|
|
|
bool HasDropDownButton() const;
|
2020-07-30 20:02:02 +03:00
|
|
|
nscoord DropDownButtonISize();
|
2018-01-10 22:09:18 +03:00
|
|
|
|
2012-06-23 05:13:56 +04:00
|
|
|
enum DropDownPositionState {
|
|
|
|
// can't show the dropdown at its current position
|
|
|
|
eDropDownPositionSuppressed,
|
|
|
|
// a resize reflow is pending, don't show it yet
|
|
|
|
eDropDownPositionPendingResize,
|
|
|
|
// the dropdown has its final size and position and can be displayed here
|
|
|
|
eDropDownPositionFinal
|
|
|
|
};
|
|
|
|
DropDownPositionState AbsolutelyPositionDropDown();
|
|
|
|
|
2022-08-17 21:36:40 +03:00
|
|
|
nscoord GetLongestOptionISize(gfxContext*) const;
|
|
|
|
|
2014-07-24 21:03:25 +04:00
|
|
|
// Helper for GetMinISize/GetPrefISize
|
2017-06-09 22:14:53 +03:00
|
|
|
nscoord GetIntrinsicISize(gfxContext* aRenderingContext,
|
2020-09-26 21:19:14 +03:00
|
|
|
mozilla::IntrinsicISizeType aType);
|
2006-05-10 21:30:15 +04:00
|
|
|
|
2016-04-26 03:23:21 +03:00
|
|
|
class RedisplayTextEvent : public mozilla::Runnable {
|
2006-05-10 21:30:15 +04:00
|
|
|
public:
|
|
|
|
NS_DECL_NSIRUNNABLE
|
2017-06-12 22:34:10 +03:00
|
|
|
explicit RedisplayTextEvent(nsComboboxControlFrame* c)
|
|
|
|
: mozilla::Runnable("nsComboboxControlFrame::RedisplayTextEvent"),
|
|
|
|
mControlFrame(c) {}
|
2012-07-30 18:20:58 +04:00
|
|
|
void Revoke() { mControlFrame = nullptr; }
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2006-05-10 21:30:15 +04:00
|
|
|
private:
|
|
|
|
nsComboboxControlFrame* mControlFrame;
|
|
|
|
};
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2002-06-14 10:50:22 +04:00
|
|
|
void CheckFireOnChange();
|
2005-02-08 02:11:30 +03:00
|
|
|
void FireValueChangeEvent();
|
2017-05-03 12:08:44 +03:00
|
|
|
nsresult RedisplayText();
|
2005-06-21 04:00:14 +04:00
|
|
|
void HandleRedisplayTextEvent();
|
2011-09-29 10:19:26 +04:00
|
|
|
void ActuallyDisplayText(bool aNotify);
|
1999-01-18 18:14:00 +03:00
|
|
|
|
2011-09-18 22:16:47 +04:00
|
|
|
// If our total transform to the root frame of the root document is only a 2d
|
|
|
|
// translation then return that translation, otherwise returns (0,0).
|
|
|
|
nsPoint GetCSSTransformTranslation();
|
|
|
|
|
Bug 1744009 - Simplify combobox <select> code. r=mconley,dholbert
With this patch on its own we get some a11y tests failures, but those
are fixed on a later patch.
Combobox select no longer creates frames for its <options>, nor an
nsListControlFrame. Instead, it computes its right intrinsic size using
the largest size of the options. This is better, because we render the
option text using the select style so if the select and option styles
are mismatched it'd cause changes in the size of the select when text
changes. See the following in a build without the patch, for example:
<select>
<option>ABC</option>
<option style="font-size: 1px">Something long</option>
</select>
This seems like a rather obscure case, but it's important to get it
right, see bug 1741888.
With this patch we use the same setup in content and parent processes
(this needs bug 1596852 and bug 1744152). This means we can remove a
bunch of the native view and popup code in nsListControlFrame. A couple
browser_* tests are affected by this change and have been tweaked
appropriately (the changes there are trivial).
Not creating an nsListControlFrame for dropdown select means that we
need to move a bunch of the event handling code from nsListControlFrame
to a common place that nsComboboxControlFrame can also use. That place
is HTMLSelectEventListener, and I think the setup is much nicer than
having the code intertwined with nsListControlFrame. It should be
relatively straight-forward to review, mostly moving code from one part
to another.
Another thing that we need to do in HTMLSelectEventListener that we
didn't use to do is listening for DOM mutations on the dropdown. Before,
we were relying on changes like text mutations triggering a reflow of
the listcontrolframe, which also triggered a reflow of the
comboboxcontrolframe, which in turn updated the text of the anonymous
content. Now we need to trigger that reflow manually.
There are some further simplifications that can be done after this
lands (cleanup naming of openInParentProcess and so on, among others),
but I'd rather land this first (after the merge of course) and work on
them separately.
Differential Revision: https://phabricator.services.mozilla.com/D132719
2022-01-17 14:10:05 +03:00
|
|
|
mozilla::dom::HTMLSelectElement& Select() const;
|
|
|
|
void GetOptionText(uint32_t aIndex, nsAString& aText) const;
|
|
|
|
|
2018-03-29 01:01:46 +03:00
|
|
|
RefPtr<nsTextNode> mDisplayContent; // Anonymous content used to display the
|
|
|
|
// current selection
|
2017-12-05 20:05:51 +03:00
|
|
|
RefPtr<Element> mButtonContent; // Anonymous content for the button
|
2014-05-25 02:20:39 +04:00
|
|
|
nsContainerFrame* mDisplayFrame; // frame to display selection
|
2000-03-07 18:54:31 +03:00
|
|
|
nsIFrame* mButtonFrame; // button frame
|
1999-01-18 18:14:00 +03:00
|
|
|
|
2015-02-08 18:31:14 +03:00
|
|
|
// 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;
|
2019-07-20 17:54:33 +03:00
|
|
|
// 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.
|
|
|
|
nscoord mMaxDisplayISize;
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2006-05-10 21:30:15 +04:00
|
|
|
nsRevocableEventPtr<RedisplayTextEvent> mRedisplayTextEvent;
|
2000-05-09 00:32:11 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mRecentSelectedIndex;
|
|
|
|
int32_t mDisplayedIndex;
|
2017-05-03 12:08:44 +03:00
|
|
|
nsString mDisplayedOptionTextOrPreview;
|
2002-01-26 02:35:44 +03:00
|
|
|
|
Bug 1744009 - Simplify combobox <select> code. r=mconley,dholbert
With this patch on its own we get some a11y tests failures, but those
are fixed on a later patch.
Combobox select no longer creates frames for its <options>, nor an
nsListControlFrame. Instead, it computes its right intrinsic size using
the largest size of the options. This is better, because we render the
option text using the select style so if the select and option styles
are mismatched it'd cause changes in the size of the select when text
changes. See the following in a build without the patch, for example:
<select>
<option>ABC</option>
<option style="font-size: 1px">Something long</option>
</select>
This seems like a rather obscure case, but it's important to get it
right, see bug 1741888.
With this patch we use the same setup in content and parent processes
(this needs bug 1596852 and bug 1744152). This means we can remove a
bunch of the native view and popup code in nsListControlFrame. A couple
browser_* tests are affected by this change and have been tweaked
appropriately (the changes there are trivial).
Not creating an nsListControlFrame for dropdown select means that we
need to move a bunch of the event handling code from nsListControlFrame
to a common place that nsComboboxControlFrame can also use. That place
is HTMLSelectEventListener, and I think the setup is much nicer than
having the code intertwined with nsListControlFrame. It should be
relatively straight-forward to review, mostly moving code from one part
to another.
Another thing that we need to do in HTMLSelectEventListener that we
didn't use to do is listening for DOM mutations on the dropdown. Before,
we were relying on changes like text mutations triggering a reflow of
the listcontrolframe, which also triggered a reflow of the
comboboxcontrolframe, which in turn updated the text of the anonymous
content. Now we need to trigger that reflow manually.
There are some further simplifications that can be done after this
lands (cleanup naming of openInParentProcess and so on, among others),
but I'd rather land this first (after the merge of course) and work on
them separately.
Differential Revision: https://phabricator.services.mozilla.com/D132719
2022-01-17 14:10:05 +03:00
|
|
|
RefPtr<mozilla::HTMLSelectEventListener> mEventListener;
|
|
|
|
|
2012-06-23 05:13:56 +04:00
|
|
|
// See comment in HandleRedisplayTextEvent().
|
|
|
|
bool mInRedisplayText;
|
2016-08-03 14:45:46 +03:00
|
|
|
bool mIsOpenInParentProcess;
|
|
|
|
|
2000-10-04 17:39:07 +04:00
|
|
|
// static class data member for Bug 32920
|
|
|
|
// only one control can be focused at a time
|
2012-06-23 05:13:56 +04:00
|
|
|
static nsComboboxControlFrame* sFocused;
|
2000-10-04 17:39:07 +04:00
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
#ifdef DO_REFLOW_COUNTER
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mReflowId;
|
2000-03-07 18:54:31 +03:00
|
|
|
#endif
|
1999-01-18 18:14:00 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|