2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
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-02-12 20:45:58 +03:00
|
|
|
#include "nsCOMPtr.h"
|
1999-01-18 18:14:00 +03:00
|
|
|
#include "nsComboboxControlFrame.h"
|
2012-11-02 04:52:59 +04:00
|
|
|
#include "nsFocusManager.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 "nsFormControlFrame.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2002-11-17 18:37:56 +03:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
1999-01-18 18:14:00 +03:00
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsIFormControl.h"
|
2014-02-28 03:04:46 +04:00
|
|
|
#include "nsNameSpaceManager.h"
|
1999-01-18 18:14:00 +03:00
|
|
|
#include "nsIListControlFrame.h"
|
2010-04-21 18:53:42 +04:00
|
|
|
#include "nsPIDOMWindow.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 "nsIPresShell.h"
|
2012-07-02 03:45:59 +04:00
|
|
|
#include "nsContentList.h"
|
2013-01-03 17:23:11 +04:00
|
|
|
#include "nsView.h"
|
2013-01-05 07:12:24 +04:00
|
|
|
#include "nsViewManager.h"
|
2014-03-17 10:56:53 +04:00
|
|
|
#include "nsIDOMEventListener.h"
|
1999-09-07 06:16:23 +04:00
|
|
|
#include "nsIDOMNode.h"
|
1999-09-15 09:31:31 +04:00
|
|
|
#include "nsISelectControlFrame.h"
|
2006-03-15 00:02:42 +03:00
|
|
|
#include "nsContentUtils.h"
|
2000-03-07 18:54:31 +03:00
|
|
|
#include "nsIDocument.h"
|
2000-05-10 17:13:39 +04:00
|
|
|
#include "nsINodeInfo.h"
|
2000-04-19 17:55:17 +04:00
|
|
|
#include "nsIScrollableFrame.h"
|
2001-02-23 04:45:45 +03:00
|
|
|
#include "nsListControlFrame.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsAutoPtr.h"
|
2004-01-28 03:18:22 +03:00
|
|
|
#include "nsStyleSet.h"
|
2004-06-25 16:26:02 +04:00
|
|
|
#include "nsNodeInfoManager.h"
|
|
|
|
#include "nsContentCreatorFunctions.h"
|
2006-07-06 14:43:51 +04:00
|
|
|
#include "nsLayoutUtils.h"
|
2006-01-26 05:29:17 +03:00
|
|
|
#include "nsDisplayList.h"
|
2007-02-16 04:53:43 +03:00
|
|
|
#include "nsITheme.h"
|
2011-04-08 05:04:40 +04:00
|
|
|
#include "nsRenderingContext.h"
|
2012-10-26 17:32:10 +04:00
|
|
|
#include "mozilla/Likely.h"
|
2013-01-15 16:22:03 +04:00
|
|
|
#include <algorithm>
|
2013-04-04 16:01:08 +04:00
|
|
|
#include "nsTextNode.h"
|
2014-03-17 10:56:54 +04:00
|
|
|
#include "mozilla/AsyncEventDispatcher.h"
|
2014-04-03 08:18:36 +04:00
|
|
|
#include "mozilla/EventStates.h"
|
2013-05-27 02:05:10 +04:00
|
|
|
#include "mozilla/LookAndFeel.h"
|
2013-09-25 15:21:18 +04:00
|
|
|
#include "mozilla/MouseEvents.h"
|
2014-03-15 23:00:16 +04:00
|
|
|
#include "mozilla/unused.h"
|
2001-04-01 05:01:33 +04:00
|
|
|
|
2011-05-25 10:31:59 +04:00
|
|
|
using namespace mozilla;
|
2010-10-25 16:17:38 +04:00
|
|
|
|
2006-05-10 21:30:15 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsComboboxControlFrame::RedisplayTextEvent::Run()
|
2005-03-21 04:58:17 +03:00
|
|
|
{
|
2006-05-10 21:30:15 +04:00
|
|
|
if (mControlFrame)
|
|
|
|
mControlFrame->HandleRedisplayTextEvent();
|
|
|
|
return NS_OK;
|
2005-03-21 04:58:17 +03:00
|
|
|
}
|
|
|
|
|
2005-01-28 01:52:53 +03:00
|
|
|
class nsPresState;
|
1999-01-18 18:14:00 +03:00
|
|
|
|
2000-12-20 18:09:00 +03:00
|
|
|
#define FIX_FOR_BUG_53259
|
|
|
|
|
1999-05-28 01:17:10 +04:00
|
|
|
// Drop down list event management.
|
2000-03-07 18:54:31 +03:00
|
|
|
// The combo box uses the following strategy for managing the drop-down list.
|
2014-01-15 10:06:47 +04:00
|
|
|
// If the combo box or its arrow button is clicked on the drop-down list is displayed
|
|
|
|
// If mouse exits the combo box with the drop-down list displayed the drop-down list
|
1999-05-28 01:17:10 +04:00
|
|
|
// is asked to capture events
|
|
|
|
// The drop-down list will capture all events including mouse down and up and will always
|
|
|
|
// return with ListWasSelected method call regardless of whether an item in the list was
|
|
|
|
// actually selected.
|
|
|
|
// The ListWasSelected code will turn off mouse-capture for the drop-down list.
|
|
|
|
// The drop-down list does not explicitly set capture when it is in the drop-down mode.
|
|
|
|
|
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-06-30 04:25:09 +04:00
|
|
|
/**
|
2012-10-05 10:12:15 +04:00
|
|
|
* Helper class that listens to the combo boxes button. If the button is pressed the
|
2001-06-30 04:25:09 +04:00
|
|
|
* combo box is toggled to open or close. this is used by Accessibility which presses
|
|
|
|
* that button Programmatically.
|
|
|
|
*/
|
2011-06-29 22:07:25 +04:00
|
|
|
class nsComboButtonListener : public nsIDOMEventListener
|
2001-06-30 04:25:09 +04:00
|
|
|
{
|
2011-06-29 22:07:25 +04:00
|
|
|
public:
|
2001-06-30 04:25:09 +04:00
|
|
|
NS_DECL_ISUPPORTS
|
2011-06-29 22:07:25 +04:00
|
|
|
|
2014-02-24 18:41:56 +04:00
|
|
|
NS_IMETHOD HandleEvent(nsIDOMEvent*) MOZ_OVERRIDE
|
2001-06-30 04:25:09 +04:00
|
|
|
{
|
2006-02-18 04:52:03 +03:00
|
|
|
mComboBox->ShowDropDown(!mComboBox->IsDroppedDown());
|
2012-10-05 10:12:15 +04:00
|
|
|
return NS_OK;
|
2001-06-30 04:25:09 +04:00
|
|
|
}
|
|
|
|
|
2012-10-05 10:12:15 +04:00
|
|
|
nsComboButtonListener(nsComboboxControlFrame* aCombobox)
|
|
|
|
{
|
|
|
|
mComboBox = aCombobox;
|
2001-06-30 04:25:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~nsComboButtonListener() {}
|
|
|
|
|
|
|
|
nsComboboxControlFrame* mComboBox;
|
|
|
|
};
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(nsComboButtonListener,
|
|
|
|
nsIDOMEventListener)
|
2001-06-30 04:25:09 +04:00
|
|
|
|
2000-10-04 17:39:07 +04:00
|
|
|
// static class data member for Bug 32920
|
2012-07-30 18:20:58 +04:00
|
|
|
nsComboboxControlFrame* nsComboboxControlFrame::sFocused = nullptr;
|
2000-10-04 17:39:07 +04:00
|
|
|
|
2005-11-04 05:38:33 +03:00
|
|
|
nsIFrame*
|
2014-02-05 05:59:39 +04:00
|
|
|
NS_NewComboboxControlFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, nsFrameState aStateFlags)
|
1999-01-18 18:14:00 +03:00
|
|
|
{
|
2006-03-27 01:30:36 +04:00
|
|
|
nsComboboxControlFrame* it = new (aPresShell) nsComboboxControlFrame(aContext);
|
2005-11-04 05:38:33 +03:00
|
|
|
|
|
|
|
if (it) {
|
|
|
|
// set the state flags (if any are provided)
|
|
|
|
it->AddStateBits(aStateFlags);
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
2005-11-04 05:38:33 +03:00
|
|
|
|
|
|
|
return it;
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsComboboxControlFrame)
|
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
// Reflow Debugging Macros
|
|
|
|
// These let us "see" how many reflow counts are happening
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
#ifdef DO_REFLOW_COUNTER
|
|
|
|
|
|
|
|
#define MAX_REFLOW_CNT 1024
|
2012-08-22 19:56:38 +04:00
|
|
|
static int32_t gTotalReqs = 0;;
|
|
|
|
static int32_t gTotalReflows = 0;;
|
|
|
|
static int32_t gReflowControlCntRQ[MAX_REFLOW_CNT];
|
|
|
|
static int32_t gReflowControlCnt[MAX_REFLOW_CNT];
|
|
|
|
static int32_t gReflowInx = -1;
|
2000-03-07 18:54:31 +03:00
|
|
|
|
|
|
|
#define REFLOW_COUNTER() \
|
|
|
|
if (mReflowId > -1) \
|
|
|
|
gReflowControlCnt[mReflowId]++;
|
|
|
|
|
|
|
|
#define REFLOW_COUNTER_REQUEST() \
|
|
|
|
if (mReflowId > -1) \
|
|
|
|
gReflowControlCntRQ[mReflowId]++;
|
|
|
|
|
|
|
|
#define REFLOW_COUNTER_DUMP(__desc) \
|
|
|
|
if (mReflowId > -1) {\
|
|
|
|
gTotalReqs += gReflowControlCntRQ[mReflowId];\
|
|
|
|
gTotalReflows += gReflowControlCnt[mReflowId];\
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("** Id:%5d %s RF: %d RQ: %d %d/%d %5.2f\n", \
|
2000-03-07 18:54:31 +03:00
|
|
|
mReflowId, (__desc), \
|
|
|
|
gReflowControlCnt[mReflowId], \
|
|
|
|
gReflowControlCntRQ[mReflowId],\
|
|
|
|
gTotalReflows, gTotalReqs, float(gTotalReflows)/float(gTotalReqs)*100.0f);\
|
|
|
|
}
|
|
|
|
|
|
|
|
#define REFLOW_COUNTER_INIT() \
|
|
|
|
if (gReflowInx < MAX_REFLOW_CNT) { \
|
|
|
|
gReflowInx++; \
|
|
|
|
mReflowId = gReflowInx; \
|
|
|
|
gReflowControlCnt[mReflowId] = 0; \
|
|
|
|
gReflowControlCntRQ[mReflowId] = 0; \
|
|
|
|
} else { \
|
|
|
|
mReflowId = -1; \
|
|
|
|
}
|
|
|
|
|
|
|
|
// reflow messages
|
2000-10-29 02:17:53 +04:00
|
|
|
#define REFLOW_DEBUG_MSG(_msg1) printf((_msg1))
|
|
|
|
#define REFLOW_DEBUG_MSG2(_msg1, _msg2) printf((_msg1), (_msg2))
|
|
|
|
#define REFLOW_DEBUG_MSG3(_msg1, _msg2, _msg3) printf((_msg1), (_msg2), (_msg3))
|
|
|
|
#define REFLOW_DEBUG_MSG4(_msg1, _msg2, _msg3, _msg4) printf((_msg1), (_msg2), (_msg3), (_msg4))
|
2000-03-07 18:54:31 +03:00
|
|
|
|
|
|
|
#else //-------------
|
|
|
|
|
2012-10-05 10:12:15 +04:00
|
|
|
#define REFLOW_COUNTER_REQUEST()
|
|
|
|
#define REFLOW_COUNTER()
|
|
|
|
#define REFLOW_COUNTER_DUMP(__desc)
|
|
|
|
#define REFLOW_COUNTER_INIT()
|
2000-03-07 18:54:31 +03:00
|
|
|
|
2012-10-05 10:12:15 +04:00
|
|
|
#define REFLOW_DEBUG_MSG(_msg)
|
|
|
|
#define REFLOW_DEBUG_MSG2(_msg1, _msg2)
|
|
|
|
#define REFLOW_DEBUG_MSG3(_msg1, _msg2, _msg3)
|
|
|
|
#define REFLOW_DEBUG_MSG4(_msg1, _msg2, _msg3, _msg4)
|
2000-03-07 18:54:31 +03:00
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//------------------------------------------
|
|
|
|
// This is for being VERY noisy
|
|
|
|
//------------------------------------------
|
|
|
|
#ifdef DO_VERY_NOISY
|
2000-10-29 02:17:53 +04:00
|
|
|
#define REFLOW_NOISY_MSG(_msg1) printf((_msg1))
|
|
|
|
#define REFLOW_NOISY_MSG2(_msg1, _msg2) printf((_msg1), (_msg2))
|
|
|
|
#define REFLOW_NOISY_MSG3(_msg1, _msg2, _msg3) printf((_msg1), (_msg2), (_msg3))
|
|
|
|
#define REFLOW_NOISY_MSG4(_msg1, _msg2, _msg3, _msg4) printf((_msg1), (_msg2), (_msg3), (_msg4))
|
2000-03-07 18:54:31 +03:00
|
|
|
#else
|
2012-10-05 10:12:15 +04:00
|
|
|
#define REFLOW_NOISY_MSG(_msg)
|
|
|
|
#define REFLOW_NOISY_MSG2(_msg1, _msg2)
|
|
|
|
#define REFLOW_NOISY_MSG3(_msg1, _msg2, _msg3)
|
|
|
|
#define REFLOW_NOISY_MSG4(_msg1, _msg2, _msg3, _msg4)
|
2000-03-07 18:54:31 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
//------------------------------------------
|
|
|
|
// Displays value in pixels or twips
|
|
|
|
//------------------------------------------
|
|
|
|
#ifdef DO_PIXELS
|
|
|
|
#define PX(__v) __v / 15
|
|
|
|
#else
|
2012-10-05 10:12:15 +04:00
|
|
|
#define PX(__v) __v
|
2000-03-07 18:54:31 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
//------------------------------------------------------
|
|
|
|
//-- Done with macros
|
|
|
|
//------------------------------------------------------
|
|
|
|
|
2006-03-27 01:30:36 +04:00
|
|
|
nsComboboxControlFrame::nsComboboxControlFrame(nsStyleContext* aContext)
|
2012-06-23 05:13:56 +04:00
|
|
|
: nsBlockFrame(aContext)
|
2012-07-30 18:20:58 +04:00
|
|
|
, mDisplayFrame(nullptr)
|
|
|
|
, mButtonFrame(nullptr)
|
|
|
|
, mDropdownFrame(nullptr)
|
|
|
|
, mListControlFrame(nullptr)
|
2012-06-23 05:13:56 +04:00
|
|
|
, mDisplayWidth(0)
|
|
|
|
, mRecentSelectedIndex(NS_SKIP_NOTIFY_INDEX)
|
|
|
|
, mDisplayedIndex(-1)
|
2012-09-06 04:17:57 +04:00
|
|
|
, mLastDropDownAboveScreenY(nscoord_MIN)
|
|
|
|
, mLastDropDownBelowScreenY(nscoord_MIN)
|
2012-06-23 05:13:56 +04:00
|
|
|
, mDroppedDown(false)
|
|
|
|
, mInRedisplayText(false)
|
|
|
|
, mDelayedShowDropDown(false)
|
1999-01-18 18:14:00 +03:00
|
|
|
{
|
2000-03-07 18:54:31 +03:00
|
|
|
REFLOW_COUNTER_INIT()
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
|
|
|
nsComboboxControlFrame::~nsComboboxControlFrame()
|
|
|
|
{
|
2000-03-07 18:54:31 +03:00
|
|
|
REFLOW_COUNTER_DUMP("nsCCF");
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
2009-01-12 22:20:59 +03:00
|
|
|
|
|
|
|
NS_QUERYFRAME_HEAD(nsComboboxControlFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIComboboxControlFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIFormControlFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsISelectControlFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIStatefulFrame)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrame)
|
|
|
|
|
2001-08-17 07:13:07 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2012-09-29 01:53:44 +04:00
|
|
|
a11y::AccType
|
|
|
|
nsComboboxControlFrame::AccessibleType()
|
2001-05-18 03:52:32 +04:00
|
|
|
{
|
2012-12-18 05:25:52 +04:00
|
|
|
return a11y::eHTMLComboboxType;
|
2001-05-18 03:52:32 +04:00
|
|
|
}
|
2001-08-17 07:13:07 +04:00
|
|
|
#endif
|
2001-05-18 03:52:32 +04:00
|
|
|
|
2012-06-23 05:13:56 +04:00
|
|
|
void
|
2011-09-29 10:19:26 +04:00
|
|
|
nsComboboxControlFrame::SetFocus(bool aOn, bool aRepaint)
|
1999-01-18 18:14:00 +03:00
|
|
|
{
|
2006-08-11 16:09:30 +04:00
|
|
|
nsWeakFrame weakFrame(this);
|
2001-01-04 15:22:29 +03:00
|
|
|
if (aOn) {
|
2002-11-07 13:25:03 +03:00
|
|
|
nsListControlFrame::ComboboxFocusSet();
|
2012-06-23 05:13:56 +04:00
|
|
|
sFocused = this;
|
2012-06-23 05:13:56 +04:00
|
|
|
if (mDelayedShowDropDown) {
|
|
|
|
ShowDropDown(true); // might destroy us
|
|
|
|
if (!weakFrame.IsAlive()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2001-01-04 15:22:29 +03:00
|
|
|
} else {
|
2012-07-30 18:20:58 +04:00
|
|
|
sFocused = nullptr;
|
2012-06-23 05:13:56 +04:00
|
|
|
mDelayedShowDropDown = false;
|
2001-01-04 15:22:29 +03:00
|
|
|
if (mDroppedDown) {
|
2007-05-17 15:12:30 +04:00
|
|
|
mListControlFrame->ComboboxFinish(mDisplayedIndex); // might destroy us
|
|
|
|
if (!weakFrame.IsAlive()) {
|
|
|
|
return;
|
|
|
|
}
|
2002-02-08 21:35:48 +03:00
|
|
|
}
|
2006-08-11 16:09:30 +04:00
|
|
|
// May delete |this|.
|
2004-05-28 20:25:04 +04:00
|
|
|
mListControlFrame->FireOnChange();
|
2001-01-04 15:22:29 +03:00
|
|
|
}
|
2002-02-08 21:35:48 +03:00
|
|
|
|
2006-08-11 16:09:30 +04:00
|
|
|
if (!weakFrame.IsAlive()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-01-04 15:22:29 +03:00
|
|
|
// This is needed on a temporary basis. It causes the focus
|
2000-10-04 17:39:07 +04:00
|
|
|
// rect to be drawn. This is much faster than ReResolvingStyle
|
|
|
|
// Bug 32920
|
2012-08-29 09:39:31 +04:00
|
|
|
InvalidateFrame();
|
1999-01-18 18:14:00 +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
|
|
|
void
|
2011-09-29 10:19:26 +04:00
|
|
|
nsComboboxControlFrame::ShowPopup(bool aShowPopup)
|
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
|
|
|
{
|
2013-01-03 17:23:11 +04:00
|
|
|
nsView* view = mDropdownFrame->GetView();
|
2013-01-05 07:12:24 +04:00
|
|
|
nsViewManager* viewManager = view->GetViewManager();
|
2000-05-26 10:42:29 +04:00
|
|
|
|
|
|
|
if (aShowPopup) {
|
2003-07-04 16:50:32 +04:00
|
|
|
nsRect rect = mDropdownFrame->GetRect();
|
2001-12-01 17:31:45 +03:00
|
|
|
rect.x = rect.y = 0;
|
|
|
|
viewManager->ResizeView(view, rect);
|
2000-05-26 10:42:29 +04:00
|
|
|
viewManager->SetViewVisibility(view, nsViewVisibility_kShow);
|
|
|
|
} else {
|
|
|
|
viewManager->SetViewVisibility(view, nsViewVisibility_kHide);
|
2001-12-01 17:31:45 +03:00
|
|
|
nsRect emptyRect(0, 0, 0, 0);
|
|
|
|
viewManager->ResizeView(view, emptyRect);
|
2000-05-26 10:42:29 +04:00
|
|
|
}
|
2001-04-01 05:01:33 +04:00
|
|
|
|
|
|
|
// fire a popup dom event
|
|
|
|
nsEventStatus status = nsEventStatus_eIgnore;
|
2013-10-02 10:38:27 +04:00
|
|
|
WidgetMouseEvent event(true, aShowPopup ?
|
|
|
|
NS_XUL_POPUP_SHOWING : NS_XUL_POPUP_HIDING, nullptr,
|
|
|
|
WidgetMouseEvent::eReal);
|
2001-04-01 05:01:33 +04:00
|
|
|
|
2007-03-31 01:11:41 +04:00
|
|
|
nsCOMPtr<nsIPresShell> shell = PresContext()->GetPresShell();
|
2012-10-05 10:12:15 +04:00
|
|
|
if (shell)
|
2003-12-21 08:36:36 +03:00
|
|
|
shell->HandleDOMEventWithTarget(mContent, &event, &status);
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
|
|
|
nsComboboxControlFrame::ShowList(bool aShowList)
|
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
|
|
|
{
|
2013-02-05 21:19:15 +04:00
|
|
|
nsView* view = mDropdownFrame->GetView();
|
2011-03-21 21:28:10 +03:00
|
|
|
if (aShowList) {
|
|
|
|
NS_ASSERTION(!view->HasWidget(),
|
2012-10-05 10:12:15 +04:00
|
|
|
"We shouldn't have a widget before we need to display the popup");
|
2011-03-21 21:28:10 +03:00
|
|
|
|
|
|
|
// Create the widget for the drop-down list
|
2011-10-17 18:59:28 +04:00
|
|
|
view->GetViewManager()->SetViewFloating(view, true);
|
2011-03-21 21:28:10 +03:00
|
|
|
|
|
|
|
nsWidgetInitData widgetData;
|
|
|
|
widgetData.mWindowType = eWindowType_popup;
|
|
|
|
widgetData.mBorderStyle = eBorderStyle_default;
|
|
|
|
view->CreateWidgetForPopup(&widgetData);
|
2013-02-05 21:19:15 +04:00
|
|
|
} else {
|
|
|
|
nsIWidget* widget = view->GetWidget();
|
|
|
|
if (widget) {
|
|
|
|
// We must do this before ShowPopup in case it destroys us (bug 813442).
|
|
|
|
widget->CaptureRollupEvents(this, false);
|
|
|
|
}
|
2011-03-21 21:28:10 +03:00
|
|
|
}
|
|
|
|
|
2013-02-05 21:19:15 +04:00
|
|
|
nsWeakFrame weakFrame(this);
|
2007-05-17 15:12:30 +04:00
|
|
|
ShowPopup(aShowList); // might destroy us
|
|
|
|
if (!weakFrame.IsAlive()) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
1999-09-22 01:20:50 +04:00
|
|
|
}
|
|
|
|
|
2007-05-17 15:12:30 +04:00
|
|
|
mDroppedDown = aShowList;
|
2013-02-05 21:19:15 +04:00
|
|
|
nsIWidget* widget = view->GetWidget();
|
2007-05-17 15:12:30 +04:00
|
|
|
if (mDroppedDown) {
|
|
|
|
// The listcontrol frame will call back to the nsComboboxControlFrame's
|
|
|
|
// ListWasSelected which will stop the capture.
|
1999-09-08 18:27:38 +04:00
|
|
|
mListControlFrame->AboutToDropDown();
|
2011-10-17 18:59:28 +04:00
|
|
|
mListControlFrame->CaptureMouseEvents(true);
|
2013-02-05 21:19:15 +04:00
|
|
|
if (widget) {
|
|
|
|
widget->CaptureRollupEvents(this, true);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (widget) {
|
|
|
|
view->DestroyWidget();
|
2007-05-17 15:12:30 +04:00
|
|
|
}
|
|
|
|
}
|
2000-02-12 01:26:36 +03:00
|
|
|
|
2007-05-17 15:12:30 +04:00
|
|
|
return weakFrame.IsAlive();
|
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
|
|
|
}
|
1999-05-08 00:30:16 +04:00
|
|
|
|
2012-06-23 05:13:56 +04:00
|
|
|
class nsResizeDropdownAtFinalPosition
|
|
|
|
: public nsIReflowCallback, public nsRunnable
|
2012-06-23 05:13:56 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsResizeDropdownAtFinalPosition(nsComboboxControlFrame* aFrame)
|
2012-06-23 05:13:56 +04:00
|
|
|
: mFrame(aFrame)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsResizeDropdownAtFinalPosition);
|
|
|
|
}
|
|
|
|
~nsResizeDropdownAtFinalPosition()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsResizeDropdownAtFinalPosition);
|
|
|
|
}
|
2012-06-23 05:13:56 +04:00
|
|
|
|
2014-02-24 18:41:56 +04:00
|
|
|
virtual bool ReflowFinished() MOZ_OVERRIDE
|
2012-06-23 05:13:56 +04:00
|
|
|
{
|
2012-06-23 05:13:56 +04:00
|
|
|
Run();
|
|
|
|
NS_RELEASE_THIS();
|
2012-06-23 05:13:56 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-02-24 18:41:56 +04:00
|
|
|
virtual void ReflowCallbackCanceled() MOZ_OVERRIDE
|
2012-06-23 05:13:56 +04:00
|
|
|
{
|
2012-06-23 05:13:56 +04:00
|
|
|
NS_RELEASE_THIS();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP Run()
|
|
|
|
{
|
|
|
|
if (mFrame.IsAlive()) {
|
|
|
|
static_cast<nsComboboxControlFrame*>(mFrame.GetFrame())->
|
|
|
|
AbsolutelyPositionDropDown();
|
|
|
|
}
|
|
|
|
return NS_OK;
|
2012-06-23 05:13:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsWeakFrame mFrame;
|
|
|
|
};
|
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
void
|
2012-10-05 10:12:15 +04:00
|
|
|
nsComboboxControlFrame::ReflowDropdown(nsPresContext* aPresContext,
|
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
|
|
|
const nsHTMLReflowState& aReflowState)
|
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
|
|
|
{
|
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
|
|
|
// All we want out of it later on, really, is the height of a row, so we
|
|
|
|
// don't even need to cache mDropdownFrame's ascent or anything. If we don't
|
|
|
|
// need to reflow it, just bail out here.
|
|
|
|
if (!aReflowState.ShouldReflowAllKids() &&
|
2007-05-06 23:16:51 +04:00
|
|
|
!NS_SUBTREE_DIRTY(mDropdownFrame)) {
|
2014-05-13 04:47:52 +04:00
|
|
|
return;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
// XXXbz this will, for small-height dropdowns, have extra space on the right
|
|
|
|
// edge for the scrollbar we don't show... but that's the best we can do here
|
|
|
|
// for now.
|
2013-12-27 21:59:21 +04:00
|
|
|
nsSize availSize(aReflowState.AvailableWidth(), NS_UNCONSTRAINEDSIZE);
|
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
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, mDropdownFrame,
|
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
|
|
|
availSize);
|
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
|
|
|
|
|
|
|
// If the dropdown's intrinsic width is narrower than our specified width,
|
|
|
|
// then expand it out. We want our border-box width to end up the same as
|
|
|
|
// the dropdown's so account for both sets of mComputedBorderPadding.
|
2007-01-26 03:05:12 +03:00
|
|
|
nscoord forcedWidth = aReflowState.ComputedWidth() +
|
2013-12-27 21:59:21 +04:00
|
|
|
aReflowState.ComputedPhysicalBorderPadding().LeftRight() -
|
|
|
|
kidReflowState.ComputedPhysicalBorderPadding().LeftRight();
|
2013-01-15 16:22:03 +04:00
|
|
|
kidReflowState.SetComputedWidth(std::max(kidReflowState.ComputedWidth(),
|
2007-01-26 03:05:12 +03:00
|
|
|
forcedWidth));
|
2000-05-26 10:42:29 +04:00
|
|
|
|
|
|
|
// ensure we start off hidden
|
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
|
|
|
if (GetStateBits() & NS_FRAME_FIRST_REFLOW) {
|
2013-01-03 17:23:11 +04:00
|
|
|
nsView* view = mDropdownFrame->GetView();
|
2013-01-05 07:12:24 +04:00
|
|
|
nsViewManager* viewManager = view->GetViewManager();
|
2000-05-26 10:42:29 +04:00
|
|
|
viewManager->SetViewVisibility(view, nsViewVisibility_kHide);
|
2001-12-01 17:31:45 +03:00
|
|
|
nsRect emptyRect(0, 0, 0, 0);
|
|
|
|
viewManager->ResizeView(view, emptyRect);
|
2000-05-26 10:42:29 +04:00
|
|
|
}
|
2012-10-05 10:12:15 +04:00
|
|
|
|
2005-06-22 05:38:49 +04:00
|
|
|
// Allow the child to move/size/change-visibility its view if it's currently
|
|
|
|
// dropped down
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t flags = NS_FRAME_NO_MOVE_FRAME | NS_FRAME_NO_VISIBILITY | NS_FRAME_NO_SIZE_VIEW;
|
2005-06-22 05:38:49 +04:00
|
|
|
if (mDroppedDown) {
|
|
|
|
flags = 0;
|
|
|
|
}
|
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
|
|
|
nsRect rect = mDropdownFrame->GetRect();
|
2013-12-31 17:50:31 +04:00
|
|
|
nsHTMLReflowMetrics desiredSize(aReflowState);
|
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
|
|
|
nsReflowStatus ignoredStatus;
|
2014-05-13 04:47:52 +04:00
|
|
|
ReflowChild(mDropdownFrame, aPresContext, desiredSize,
|
|
|
|
kidReflowState, rect.x, rect.y, flags, ignoredStatus);
|
2012-10-05 10:12:15 +04:00
|
|
|
|
2014-01-15 10:06:47 +04:00
|
|
|
// Set the child's width and height to its desired size
|
2014-01-17 05:34:44 +04:00
|
|
|
FinishReflowChild(mDropdownFrame, aPresContext, desiredSize,
|
|
|
|
&kidReflowState, rect.x, rect.y, flags);
|
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
|
|
|
}
|
|
|
|
|
2011-09-18 22:16:47 +04:00
|
|
|
nsPoint
|
2011-09-18 22:20:09 +04:00
|
|
|
nsComboboxControlFrame::GetCSSTransformTranslation()
|
2011-09-18 22:16:47 +04:00
|
|
|
{
|
|
|
|
nsIFrame* frame = this;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool is3DTransform = false;
|
2011-09-18 22:16:47 +04:00
|
|
|
gfxMatrix transform;
|
|
|
|
while (frame) {
|
2011-12-28 07:24:18 +04:00
|
|
|
nsIFrame* parent;
|
2012-07-30 18:20:58 +04:00
|
|
|
gfx3DMatrix ctm = frame->GetTransformMatrix(nullptr, &parent);
|
2011-09-18 22:16:47 +04:00
|
|
|
gfxMatrix matrix;
|
|
|
|
if (ctm.Is2D(&matrix)) {
|
|
|
|
transform = transform * matrix;
|
|
|
|
} else {
|
2011-10-17 18:59:28 +04:00
|
|
|
is3DTransform = true;
|
2011-09-18 22:16:47 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
frame = parent;
|
|
|
|
}
|
|
|
|
nsPoint translation;
|
|
|
|
if (!is3DTransform && !transform.HasNonTranslation()) {
|
|
|
|
nsPresContext* pc = PresContext();
|
|
|
|
gfxPoint pixelTranslation = transform.GetTranslation();
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t apd = pc->AppUnitsPerDevPixel();
|
2011-09-18 22:16:47 +04:00
|
|
|
translation.x = NSFloatPixelsToAppUnits(float(pixelTranslation.x), apd);
|
|
|
|
translation.y = NSFloatPixelsToAppUnits(float(pixelTranslation.y), apd);
|
|
|
|
// To get the translation introduced only by transforms we subtract the
|
|
|
|
// regular non-transform translation.
|
|
|
|
nsRootPresContext* rootPC = pc->GetRootPresContext();
|
|
|
|
if (rootPC) {
|
|
|
|
translation -= GetOffsetToCrossDoc(rootPC->PresShell()->GetRootFrame());
|
|
|
|
} else {
|
|
|
|
translation.x = translation.y = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return translation;
|
|
|
|
}
|
|
|
|
|
2012-06-23 05:13:56 +04:00
|
|
|
class nsAsyncRollup : public nsRunnable
|
2012-06-02 03:41:54 +04:00
|
|
|
{
|
2012-06-23 05:13:56 +04:00
|
|
|
public:
|
|
|
|
nsAsyncRollup(nsComboboxControlFrame* aFrame) : mFrame(aFrame) {}
|
|
|
|
NS_IMETHODIMP Run()
|
|
|
|
{
|
|
|
|
if (mFrame.IsAlive()) {
|
|
|
|
static_cast<nsComboboxControlFrame*>(mFrame.GetFrame())
|
|
|
|
->RollupFromList();
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
nsWeakFrame mFrame;
|
|
|
|
};
|
|
|
|
|
|
|
|
class nsAsyncResize : public nsRunnable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsAsyncResize(nsComboboxControlFrame* aFrame) : mFrame(aFrame) {}
|
|
|
|
NS_IMETHODIMP Run()
|
|
|
|
{
|
|
|
|
if (mFrame.IsAlive()) {
|
|
|
|
nsComboboxControlFrame* combo =
|
|
|
|
static_cast<nsComboboxControlFrame*>(mFrame.GetFrame());
|
|
|
|
static_cast<nsListControlFrame*>(combo->mDropdownFrame)->
|
|
|
|
SetSuppressScrollbarUpdate(true);
|
|
|
|
nsCOMPtr<nsIPresShell> shell = mFrame->PresContext()->PresShell();
|
|
|
|
shell->FrameNeedsReflow(combo->mDropdownFrame, nsIPresShell::eResize,
|
|
|
|
NS_FRAME_IS_DIRTY);
|
|
|
|
shell->FlushPendingNotifications(Flush_Layout);
|
|
|
|
if (mFrame.IsAlive()) {
|
|
|
|
combo = static_cast<nsComboboxControlFrame*>(mFrame.GetFrame());
|
|
|
|
static_cast<nsListControlFrame*>(combo->mDropdownFrame)->
|
|
|
|
SetSuppressScrollbarUpdate(false);
|
|
|
|
if (combo->mDelayedShowDropDown) {
|
|
|
|
combo->ShowDropDown(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
nsWeakFrame mFrame;
|
|
|
|
};
|
2012-06-03 20:05:00 +04:00
|
|
|
|
2012-06-23 05:13:56 +04:00
|
|
|
void
|
|
|
|
nsComboboxControlFrame::GetAvailableDropdownSpace(nscoord* aAbove,
|
|
|
|
nscoord* aBelow,
|
|
|
|
nsPoint* aTranslation)
|
|
|
|
{
|
2012-06-23 05:13:56 +04:00
|
|
|
// Note: At first glance, it appears that you could simply get the absolute
|
2012-06-23 05:13:56 +04:00
|
|
|
// bounding box for the dropdown list by first getting its view, then getting
|
|
|
|
// the view's nsIWidget, then asking the nsIWidget for its AbsoluteBounds.
|
|
|
|
// The problem with this approach, is that the dropdown lists y location can
|
|
|
|
// change based on whether the dropdown is placed below or above the display
|
|
|
|
// frame. The approach, taken here is to get the absolute position of the
|
|
|
|
// display frame and use its location to determine if the dropdown will go
|
|
|
|
// offscreen.
|
1999-01-18 18:14:00 +03:00
|
|
|
|
2011-09-18 22:16:47 +04:00
|
|
|
// Normal frame geometry (eg GetOffsetTo, mRect) doesn't include transforms.
|
|
|
|
// In the special case that our transform is only a 2D translation we
|
|
|
|
// introduce this hack so that the dropdown will show up in the right place.
|
2012-06-23 05:13:56 +04:00
|
|
|
*aTranslation = GetCSSTransformTranslation();
|
|
|
|
*aAbove = 0;
|
|
|
|
*aBelow = 0;
|
2012-10-05 10:12:15 +04:00
|
|
|
|
2012-06-03 20:05:00 +04:00
|
|
|
nsRect screen = nsFormControlFrame::GetUsableScreenRect(PresContext());
|
2012-09-06 04:17:57 +04:00
|
|
|
if (mLastDropDownBelowScreenY == nscoord_MIN) {
|
|
|
|
nsRect thisScreenRect = GetScreenRectInAppUnits();
|
|
|
|
mLastDropDownBelowScreenY = thisScreenRect.YMost() + aTranslation->y;
|
|
|
|
mLastDropDownAboveScreenY = thisScreenRect.y + aTranslation->y;
|
|
|
|
}
|
2012-06-23 05:13:56 +04:00
|
|
|
|
|
|
|
nscoord minY;
|
2012-10-31 09:10:38 +04:00
|
|
|
nsPresContext* pc = PresContext()->GetToplevelContentDocumentPresContext();
|
|
|
|
nsIFrame* root = pc ? pc->PresShell()->GetRootFrame() : nullptr;
|
|
|
|
if (root) {
|
2012-06-23 05:13:56 +04:00
|
|
|
minY = root->GetScreenRectInAppUnits().y;
|
2012-10-31 09:10:38 +04:00
|
|
|
if (mLastDropDownBelowScreenY < minY) {
|
|
|
|
// Don't allow the drop-down to be placed above the content area.
|
2012-06-23 05:13:56 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
minY = screen.y;
|
|
|
|
}
|
2012-10-05 10:12:15 +04:00
|
|
|
|
2012-09-06 04:17:57 +04:00
|
|
|
nscoord below = screen.YMost() - mLastDropDownBelowScreenY;
|
|
|
|
nscoord above = mLastDropDownAboveScreenY - minY;
|
2012-06-23 05:13:56 +04:00
|
|
|
|
|
|
|
// If the difference between the space above and below is less
|
|
|
|
// than a row-height, then we favor the space below.
|
|
|
|
if (above >= below) {
|
|
|
|
nsListControlFrame* lcf = static_cast<nsListControlFrame*>(mDropdownFrame);
|
|
|
|
nscoord rowHeight = lcf->GetHeightOfARow();
|
|
|
|
if (above < below + rowHeight) {
|
|
|
|
above -= rowHeight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*aBelow = below;
|
|
|
|
*aAbove = above;
|
|
|
|
}
|
2012-06-03 20:05:00 +04:00
|
|
|
|
2012-06-23 05:13:56 +04:00
|
|
|
nsComboboxControlFrame::DropDownPositionState
|
|
|
|
nsComboboxControlFrame::AbsolutelyPositionDropDown()
|
|
|
|
{
|
|
|
|
nsPoint translation;
|
|
|
|
nscoord above, below;
|
2012-09-06 04:17:57 +04:00
|
|
|
mLastDropDownBelowScreenY = nscoord_MIN;
|
2012-06-23 05:13:56 +04:00
|
|
|
GetAvailableDropdownSpace(&above, &below, &translation);
|
|
|
|
if (above <= 0 && below <= 0) {
|
2012-10-31 09:10:38 +04:00
|
|
|
if (IsDroppedDown()) {
|
|
|
|
// Hide the view immediately to minimize flicker.
|
2013-01-03 17:23:11 +04:00
|
|
|
nsView* view = mDropdownFrame->GetView();
|
2012-10-31 09:10:38 +04:00
|
|
|
view->GetViewManager()->SetViewVisibility(view, nsViewVisibility_kHide);
|
|
|
|
NS_DispatchToCurrentThread(new nsAsyncRollup(this));
|
|
|
|
}
|
2012-06-23 05:13:56 +04:00
|
|
|
return eDropDownPositionSuppressed;
|
2003-04-09 00:50:57 +04:00
|
|
|
}
|
2007-02-15 13:58:31 +03:00
|
|
|
|
2012-06-23 05:13:56 +04:00
|
|
|
nsSize dropdownSize = mDropdownFrame->GetSize();
|
2013-01-15 16:22:03 +04:00
|
|
|
nscoord height = std::max(above, below);
|
2012-06-23 05:13:56 +04:00
|
|
|
nsListControlFrame* lcf = static_cast<nsListControlFrame*>(mDropdownFrame);
|
|
|
|
if (height < dropdownSize.height) {
|
|
|
|
if (lcf->GetNumDisplayRows() > 1) {
|
|
|
|
// The drop-down doesn't fit and currently shows more than 1 row -
|
|
|
|
// schedule a resize to show fewer rows.
|
|
|
|
NS_DispatchToCurrentThread(new nsAsyncResize(this));
|
|
|
|
return eDropDownPositionPendingResize;
|
|
|
|
}
|
|
|
|
} else if (height > (dropdownSize.height + lcf->GetHeightOfARow() * 1.5) &&
|
|
|
|
lcf->GetDropdownCanGrow()) {
|
|
|
|
// The drop-down fits but there is room for at least 1.5 more rows -
|
|
|
|
// schedule a resize to show more rows if it has more rows to show.
|
|
|
|
// (1.5 rows for good measure to avoid any rounding issues that would
|
|
|
|
// lead to a loop of reflow requests)
|
|
|
|
NS_DispatchToCurrentThread(new nsAsyncResize(this));
|
|
|
|
return eDropDownPositionPendingResize;
|
|
|
|
}
|
|
|
|
|
2013-07-25 16:55:32 +04:00
|
|
|
// Position the drop-down below if there is room, otherwise place it above
|
|
|
|
// if there is room. If there is no room for it on either side then place
|
|
|
|
// it below (to avoid overlapping UI like the URL bar).
|
|
|
|
bool b = dropdownSize.height <= below || dropdownSize.height > above;
|
2012-06-23 05:13:56 +04:00
|
|
|
nsPoint dropdownPosition(0, b ? GetRect().height : -dropdownSize.height);
|
2013-02-17 01:51:02 +04:00
|
|
|
if (StyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL) {
|
2006-08-13 23:34:58 +04:00
|
|
|
// Align the right edge of the drop-down with the right edge of the control.
|
2007-02-15 13:58:31 +03:00
|
|
|
dropdownPosition.x = GetRect().width - dropdownSize.width;
|
2006-08-13 23:34:58 +04:00
|
|
|
}
|
2012-08-15 06:28:23 +04:00
|
|
|
|
|
|
|
// Don't position the view unless the position changed since it might cause
|
|
|
|
// a call to NotifyGeometryChange() and an infinite loop here.
|
|
|
|
const nsPoint currentPos = mDropdownFrame->GetPosition();
|
|
|
|
const nsPoint newPos = dropdownPosition + translation;
|
|
|
|
if (currentPos != newPos) {
|
|
|
|
mDropdownFrame->SetPosition(newPos);
|
|
|
|
nsContainerFrame::PositionFrameView(mDropdownFrame);
|
|
|
|
}
|
2012-06-23 05:13:56 +04:00
|
|
|
return eDropDownPositionFinal;
|
2012-06-02 03:41:54 +04:00
|
|
|
}
|
|
|
|
|
2012-06-23 05:13:56 +04:00
|
|
|
void
|
|
|
|
nsComboboxControlFrame::NotifyGeometryChange()
|
|
|
|
{
|
|
|
|
// We don't need to resize if we're not dropped down since ShowDropDown
|
|
|
|
// does that, or if we're dirty then the reflow callback does it,
|
|
|
|
// or if we have a delayed ShowDropDown pending.
|
|
|
|
if (IsDroppedDown() &&
|
|
|
|
!(GetStateBits() & NS_FRAME_IS_DIRTY) &&
|
|
|
|
!mDelayedShowDropDown) {
|
|
|
|
// Async because we're likely in a middle of a scroll here so
|
|
|
|
// frame/view positions are in flux.
|
|
|
|
nsRefPtr<nsResizeDropdownAtFinalPosition> resize =
|
|
|
|
new nsResizeDropdownAtFinalPosition(this);
|
|
|
|
NS_DispatchToCurrentThread(resize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
//----------------------------------------------------------
|
2012-10-05 10:12:15 +04:00
|
|
|
//
|
2000-03-07 18:54:31 +03:00
|
|
|
//----------------------------------------------------------
|
|
|
|
#ifdef DO_REFLOW_DEBUG
|
2000-03-03 10:14:58 +03:00
|
|
|
static int myCounter = 0;
|
2000-03-07 18:54:31 +03:00
|
|
|
|
2012-10-05 10:12:15 +04:00
|
|
|
static void printSize(char * aDesc, nscoord aSize)
|
2000-03-07 18:54:31 +03:00
|
|
|
{
|
2000-10-29 02:17:53 +04:00
|
|
|
printf(" %s: ", aDesc);
|
2000-03-07 18:54:31 +03:00
|
|
|
if (aSize == NS_UNCONSTRAINEDSIZE) {
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("UC");
|
2000-03-07 18:54:31 +03:00
|
|
|
} else {
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("%d", PX(aSize));
|
2000-03-07 18:54:31 +03:00
|
|
|
}
|
|
|
|
}
|
2000-01-28 18:24:49 +03:00
|
|
|
#endif
|
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
//-------------------------------------------------------------------
|
|
|
|
//-- Main Reflow for the Combobox
|
|
|
|
//-------------------------------------------------------------------
|
2000-04-22 01:53:38 +04: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
|
|
|
nscoord
|
2011-04-08 05:04:40 +04:00
|
|
|
nsComboboxControlFrame::GetIntrinsicWidth(nsRenderingContext* aRenderingContext,
|
2007-12-03 09:41:38 +03:00
|
|
|
nsLayoutUtils::IntrinsicWidthType aType)
|
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
|
|
|
{
|
2007-05-29 09:31:04 +04:00
|
|
|
// get the scrollbar width, we'll use this later
|
|
|
|
nscoord scrollbarWidth = 0;
|
|
|
|
nsPresContext* presContext = PresContext();
|
|
|
|
if (mListControlFrame) {
|
2009-01-12 22:20:59 +03:00
|
|
|
nsIScrollableFrame* scrollable = do_QueryFrame(mListControlFrame);
|
2007-05-29 09:31:04 +04:00
|
|
|
NS_ASSERTION(scrollable, "List must be a scrollable frame");
|
2013-05-27 02:05:10 +04:00
|
|
|
scrollbarWidth = scrollable->GetNondisappearingScrollbarWidth(
|
|
|
|
presContext, aRenderingContext);
|
2007-05-29 09:31:04 +04:00
|
|
|
}
|
2000-03-07 18:54:31 +03:00
|
|
|
|
2007-12-03 09:41:38 +03:00
|
|
|
nscoord displayWidth = 0;
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(mDisplayFrame)) {
|
2007-12-03 09:41:38 +03:00
|
|
|
displayWidth = nsLayoutUtils::IntrinsicForContainer(aRenderingContext,
|
|
|
|
mDisplayFrame,
|
|
|
|
aType);
|
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
|
|
|
}
|
2000-01-28 18:24:49 +03:00
|
|
|
|
2007-05-29 09:31:04 +04:00
|
|
|
if (mDropdownFrame) {
|
2007-12-03 09:41:38 +03:00
|
|
|
nscoord dropdownContentWidth;
|
2013-05-27 02:05:10 +04:00
|
|
|
bool isUsingOverlayScrollbars =
|
|
|
|
LookAndFeel::GetInt(LookAndFeel::eIntID_UseOverlayScrollbars) != 0;
|
2007-12-03 09:41:38 +03:00
|
|
|
if (aType == nsLayoutUtils::MIN_WIDTH) {
|
|
|
|
dropdownContentWidth = mDropdownFrame->GetMinWidth(aRenderingContext);
|
2013-05-27 02:05:10 +04:00
|
|
|
if (isUsingOverlayScrollbars) {
|
|
|
|
dropdownContentWidth += scrollbarWidth;
|
|
|
|
}
|
2007-12-03 09:41:38 +03:00
|
|
|
} else {
|
|
|
|
NS_ASSERTION(aType == nsLayoutUtils::PREF_WIDTH, "Unexpected type");
|
|
|
|
dropdownContentWidth = mDropdownFrame->GetPrefWidth(aRenderingContext);
|
2013-05-27 02:05:10 +04:00
|
|
|
if (isUsingOverlayScrollbars) {
|
|
|
|
dropdownContentWidth += scrollbarWidth;
|
|
|
|
}
|
2007-12-03 09:41:38 +03:00
|
|
|
}
|
2012-10-05 10:12:15 +04:00
|
|
|
dropdownContentWidth = NSCoordSaturatingSubtract(dropdownContentWidth,
|
2007-12-18 22:26:35 +03:00
|
|
|
scrollbarWidth,
|
|
|
|
nscoord_MAX);
|
2012-10-05 10:12:15 +04:00
|
|
|
|
2013-01-15 16:22:03 +04:00
|
|
|
displayWidth = std::max(dropdownContentWidth, displayWidth);
|
2007-05-05 10:20:10 +04:00
|
|
|
}
|
|
|
|
|
2007-05-29 09:31:04 +04:00
|
|
|
// add room for the dropmarker button if there is one
|
|
|
|
if (!IsThemed() || presContext->GetTheme()->ThemeNeedsComboboxDropmarker())
|
2007-12-03 09:41:38 +03:00
|
|
|
displayWidth += scrollbarWidth;
|
|
|
|
|
|
|
|
return displayWidth;
|
2007-05-29 09:31:04 +04:00
|
|
|
|
2007-12-03 09:41:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
2011-04-08 05:04:40 +04:00
|
|
|
nsComboboxControlFrame::GetMinWidth(nsRenderingContext *aRenderingContext)
|
2007-12-03 09:41:38 +03:00
|
|
|
{
|
|
|
|
nscoord minWidth;
|
|
|
|
DISPLAY_MIN_WIDTH(this, minWidth);
|
|
|
|
minWidth = GetIntrinsicWidth(aRenderingContext, nsLayoutUtils::MIN_WIDTH);
|
|
|
|
return minWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
2011-04-08 05:04:40 +04:00
|
|
|
nsComboboxControlFrame::GetPrefWidth(nsRenderingContext *aRenderingContext)
|
2007-12-03 09:41:38 +03:00
|
|
|
{
|
|
|
|
nscoord prefWidth;
|
|
|
|
DISPLAY_PREF_WIDTH(this, prefWidth);
|
|
|
|
prefWidth = GetIntrinsicWidth(aRenderingContext, nsLayoutUtils::PREF_WIDTH);
|
|
|
|
return prefWidth;
|
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
|
|
|
}
|
2000-03-07 18:54:31 +03:00
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
void
|
2012-10-05 10:12:15 +04:00
|
|
|
nsComboboxControlFrame::Reflow(nsPresContext* aPresContext,
|
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
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
2012-10-05 10:12:15 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
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
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
// Constraints we try to satisfy:
|
2000-03-07 18:54:31 +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
|
|
|
// 1) Default width of button is the vertical scrollbar size
|
|
|
|
// 2) If the width of button is bigger than our width, set width of
|
|
|
|
// button to 0.
|
|
|
|
// 3) Default height of button is height of display area
|
|
|
|
// 4) Width of display area is whatever is left over from our width after
|
|
|
|
// allocating width for the button.
|
|
|
|
// 5) Height of display area is GetHeightOfARow() on the
|
|
|
|
// mListControlFrame.
|
2000-03-03 07:28:59 +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
|
|
|
if (!mDisplayFrame || !mButtonFrame || !mDropdownFrame) {
|
|
|
|
NS_ERROR("Why did the frame constructor allow this to happen? Fix it!!");
|
2014-05-13 04:47:52 +04:00
|
|
|
return;
|
2000-01-28 18:24:49 +03:00
|
|
|
}
|
|
|
|
|
2005-06-21 04:00:14 +04:00
|
|
|
// Make sure the displayed text is the same as the selected option, bug 297389.
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t selectedIndex;
|
2005-06-21 04:00:14 +04:00
|
|
|
nsAutoString selectedOptionText;
|
2005-10-22 07:47:00 +04:00
|
|
|
if (!mDroppedDown) {
|
2006-03-01 04:00:29 +03:00
|
|
|
selectedIndex = mListControlFrame->GetSelectedIndex();
|
2005-10-22 07:47:00 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// In dropped down mode the "selected index" is the hovered menu item,
|
|
|
|
// we want the last selected item which is |mDisplayedIndex| in this case.
|
|
|
|
selectedIndex = mDisplayedIndex;
|
|
|
|
}
|
2005-06-21 04:00:14 +04:00
|
|
|
if (selectedIndex != -1) {
|
|
|
|
mListControlFrame->GetOptionText(selectedIndex, selectedOptionText);
|
|
|
|
}
|
|
|
|
if (mDisplayedOptionText != selectedOptionText) {
|
|
|
|
RedisplayText(selectedIndex);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
// First reflow our dropdown so that we know how tall we should be.
|
|
|
|
ReflowDropdown(aPresContext, aReflowState);
|
2012-06-23 05:13:56 +04:00
|
|
|
nsRefPtr<nsResizeDropdownAtFinalPosition> resize =
|
|
|
|
new nsResizeDropdownAtFinalPosition(this);
|
|
|
|
if (NS_SUCCEEDED(aPresContext->PresShell()->PostReflowCallback(resize))) {
|
|
|
|
// The reflow callback queue doesn't AddRef so we keep it alive until
|
|
|
|
// it's released in its ReflowFinished / ReflowCallbackCanceled.
|
2014-03-15 23:00:16 +04:00
|
|
|
unused << resize.forget();
|
2012-06-23 05:13:56 +04:00
|
|
|
}
|
2007-02-07 10:46:44 +03:00
|
|
|
|
2006-12-19 18:08:34 +03:00
|
|
|
// Get the width of the vertical scrollbar. That will be the width of the
|
|
|
|
// dropdown button.
|
2007-05-18 07:04:04 +04:00
|
|
|
nscoord buttonWidth;
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleDisplay *disp = StyleDisplay();
|
2007-05-18 07:04:04 +04:00
|
|
|
if (IsThemed(disp) && !aPresContext->GetTheme()->ThemeNeedsComboboxDropmarker()) {
|
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
|
|
|
buttonWidth = 0;
|
2000-03-07 18:54:31 +03:00
|
|
|
}
|
2007-05-18 07:04:04 +04:00
|
|
|
else {
|
2009-01-12 22:20:59 +03:00
|
|
|
nsIScrollableFrame* scrollable = do_QueryFrame(mListControlFrame);
|
2007-05-18 07:04:04 +04:00
|
|
|
NS_ASSERTION(scrollable, "List must be a scrollable frame");
|
2013-05-27 02:05:10 +04:00
|
|
|
buttonWidth = scrollable->GetNondisappearingScrollbarWidth(
|
|
|
|
PresContext(), aReflowState.rendContext);
|
2007-05-18 07:04:04 +04:00
|
|
|
if (buttonWidth > aReflowState.ComputedWidth()) {
|
|
|
|
buttonWidth = 0;
|
|
|
|
}
|
|
|
|
}
|
2000-08-03 18:13:40 +04:00
|
|
|
|
2007-01-26 03:05:12 +03:00
|
|
|
mDisplayWidth = aReflowState.ComputedWidth() - buttonWidth;
|
2000-08-03 18:13:40 +04:00
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
nsBlockFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
2000-08-03 18:13:40 +04:00
|
|
|
|
2014-03-07 03:24:01 +04:00
|
|
|
// The button should occupy the same space as a scrollbar
|
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
|
|
|
nsRect buttonRect = mButtonFrame->GetRect();
|
2012-10-05 10:12:15 +04:00
|
|
|
|
2013-02-17 01:51:02 +04:00
|
|
|
if (StyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL) {
|
2014-03-07 03:24:01 +04:00
|
|
|
buttonRect.x = aReflowState.ComputedPhysicalBorderPadding().left -
|
|
|
|
aReflowState.ComputedPhysicalPadding().left;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
buttonRect.x = aReflowState.ComputedPhysicalBorderPadding().LeftRight() +
|
|
|
|
mDisplayWidth -
|
|
|
|
(aReflowState.ComputedPhysicalBorderPadding().right -
|
|
|
|
aReflowState.ComputedPhysicalPadding().right);
|
2000-03-07 18:54:31 +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
|
|
|
buttonRect.width = buttonWidth;
|
2014-03-07 03:24:01 +04:00
|
|
|
|
|
|
|
buttonRect.y = this->GetUsedBorder().top;
|
|
|
|
buttonRect.height = mDisplayFrame->GetRect().height +
|
|
|
|
this->GetUsedPadding().TopBottom();
|
|
|
|
|
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
|
|
|
mButtonFrame->SetRect(buttonRect);
|
2012-10-05 10:12:15 +04:00
|
|
|
|
2014-01-30 16:12:02 +04:00
|
|
|
if (!NS_INLINE_IS_BREAK_BEFORE(aStatus) &&
|
|
|
|
!NS_FRAME_IS_FULLY_COMPLETE(aStatus)) {
|
|
|
|
// This frame didn't fit inside a fragmentation container. Splitting
|
|
|
|
// a nsComboboxControlFrame makes no sense, so we override the status here.
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
}
|
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
|
|
|
}
|
2000-03-07 18:54:31 +03:00
|
|
|
|
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
|
|
|
nsIAtom*
|
|
|
|
nsComboboxControlFrame::GetType() const
|
|
|
|
{
|
2012-10-05 10:12:15 +04:00
|
|
|
return nsGkAtoms::comboboxControlFrame;
|
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
|
|
|
}
|
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2001-11-14 04:33:42 +03:00
|
|
|
nsComboboxControlFrame::GetFrameName(nsAString& aResult) const
|
1999-01-18 18:14:00 +03:00
|
|
|
{
|
2001-11-14 04:33:42 +03:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("ComboboxControl"), aResult);
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1999-01-18 18:14:00 +03:00
|
|
|
|
2002-01-09 22:17:46 +03:00
|
|
|
|
1999-01-18 18:14:00 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIComboboxControlFrame
|
|
|
|
//----------------------------------------------------------------------
|
2006-02-18 04:52:03 +03:00
|
|
|
void
|
2012-10-05 10:12:15 +04:00
|
|
|
nsComboboxControlFrame::ShowDropDown(bool aDoDropDown)
|
2006-04-26 06:01:07 +04:00
|
|
|
{
|
2012-06-23 05:13:56 +04:00
|
|
|
mDelayedShowDropDown = false;
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates eventStates = mContent->AsElement()->State();
|
2012-06-23 05:13:56 +04:00
|
|
|
if (aDoDropDown && eventStates.HasState(NS_EVENT_STATE_DISABLED)) {
|
2006-02-18 04:52:03 +03:00
|
|
|
return;
|
1999-08-26 18:54:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!mDroppedDown && aDoDropDown) {
|
2012-11-02 04:52:59 +04:00
|
|
|
nsFocusManager* fm = nsFocusManager::GetFocusManager();
|
|
|
|
if (!fm || fm->GetFocusedContent() == GetContent()) {
|
2012-06-23 05:13:56 +04:00
|
|
|
DropDownPositionState state = AbsolutelyPositionDropDown();
|
|
|
|
if (state == eDropDownPositionFinal) {
|
|
|
|
ShowList(aDoDropDown); // might destroy us
|
|
|
|
} else if (state == eDropDownPositionPendingResize) {
|
|
|
|
// Delay until after the resize reflow, see nsAsyncResize.
|
|
|
|
mDelayedShowDropDown = true;
|
2012-06-23 05:13:56 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Delay until we get focus, see SetFocus().
|
|
|
|
mDelayedShowDropDown = true;
|
1999-08-31 17:22:40 +04:00
|
|
|
}
|
1999-08-26 18:54:07 +04:00
|
|
|
} else if (mDroppedDown && !aDoDropDown) {
|
2009-09-02 06:46:47 +04:00
|
|
|
ShowList(aDoDropDown); // might destroy us
|
1999-08-26 18:54:07 +04:00
|
|
|
}
|
|
|
|
}
|
1999-01-18 18:14:00 +03:00
|
|
|
|
2006-02-18 04:52:03 +03:00
|
|
|
void
|
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
|
|
|
nsComboboxControlFrame::SetDropDown(nsIFrame* aDropDownFrame)
|
1999-01-18 18:14:00 +03:00
|
|
|
{
|
1999-08-31 17:22:40 +04:00
|
|
|
mDropdownFrame = aDropDownFrame;
|
2009-01-12 22:20:59 +03:00
|
|
|
mListControlFrame = do_QueryFrame(mDropdownFrame);
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
2006-02-27 07:13:51 +03:00
|
|
|
nsIFrame*
|
2012-10-05 10:12:15 +04:00
|
|
|
nsComboboxControlFrame::GetDropDown()
|
2006-02-27 07:13:51 +03:00
|
|
|
{
|
|
|
|
return mDropdownFrame;
|
|
|
|
}
|
|
|
|
|
1999-08-31 17:22:40 +04:00
|
|
|
///////////////////////////////////////////////////////////////
|
|
|
|
|
1999-08-26 18:54:07 +04:00
|
|
|
NS_IMETHODIMP
|
2002-01-26 02:35:44 +03:00
|
|
|
nsComboboxControlFrame::RedisplaySelectedText()
|
1999-06-24 01:50:56 +04:00
|
|
|
{
|
2009-02-18 06:27:25 +03:00
|
|
|
nsAutoScriptBlocker scriptBlocker;
|
2006-03-01 04:00:29 +03:00
|
|
|
return RedisplayText(mListControlFrame->GetSelectedIndex());
|
2002-01-26 02:35:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2012-08-22 19:56:38 +04:00
|
|
|
nsComboboxControlFrame::RedisplayText(int32_t aIndex)
|
2002-01-26 02:35:44 +03:00
|
|
|
{
|
|
|
|
// Get the text to display
|
|
|
|
if (aIndex != -1) {
|
2005-06-21 04:00:14 +04:00
|
|
|
mListControlFrame->GetOptionText(aIndex, mDisplayedOptionText);
|
|
|
|
} else {
|
|
|
|
mDisplayedOptionText.Truncate();
|
2002-01-26 02:35:44 +03:00
|
|
|
}
|
|
|
|
mDisplayedIndex = aIndex;
|
|
|
|
|
2005-06-21 04:00:14 +04:00
|
|
|
REFLOW_DEBUG_MSG2("RedisplayText \"%s\"\n",
|
2006-02-03 17:18:39 +03:00
|
|
|
NS_LossyConvertUTF16toASCII(mDisplayedOptionText).get());
|
2002-01-26 02:35:44 +03:00
|
|
|
|
1999-10-06 03:43:06 +04:00
|
|
|
// Send reflow command because the new text maybe larger
|
|
|
|
nsresult rv = NS_OK;
|
2006-03-15 00:02:42 +03:00
|
|
|
if (mDisplayContent) {
|
2011-10-17 18:59:28 +04:00
|
|
|
// Don't call ActuallyDisplayText(true) directly here since that
|
2005-04-03 23:58:40 +04:00
|
|
|
// could cause recursive frame construction. See bug 283117 and the comment in
|
|
|
|
// HandleRedisplayTextEvent() below.
|
2005-04-04 02:16:07 +04:00
|
|
|
|
2006-05-10 21:30:15 +04:00
|
|
|
// Revoke outstanding events to avoid out-of-order events which could mean
|
|
|
|
// displaying the wrong text.
|
|
|
|
mRedisplayTextEvent.Revoke();
|
2005-04-04 02:16:07 +04:00
|
|
|
|
2009-02-18 06:27:25 +03:00
|
|
|
NS_ASSERTION(!nsContentUtils::IsSafeToRunScript(),
|
|
|
|
"If we happen to run our redisplay event now, we might kill "
|
|
|
|
"ourselves!");
|
|
|
|
|
2006-05-10 21:30:15 +04:00
|
|
|
nsRefPtr<RedisplayTextEvent> event = new RedisplayTextEvent(this);
|
2009-02-18 06:27:25 +03:00
|
|
|
mRedisplayTextEvent = event;
|
|
|
|
if (!nsContentUtils::AddScriptRunner(event))
|
|
|
|
mRedisplayTextEvent.Forget();
|
1999-08-26 18:54:07 +04:00
|
|
|
}
|
1999-10-06 03:43:06 +04:00
|
|
|
return rv;
|
1999-08-26 18:54:07 +04:00
|
|
|
}
|
|
|
|
|
2005-03-21 04:58:17 +03:00
|
|
|
void
|
2005-06-21 04:00:14 +04:00
|
|
|
nsComboboxControlFrame::HandleRedisplayTextEvent()
|
2005-03-21 04:58:17 +03:00
|
|
|
{
|
2005-04-12 19:31:03 +04:00
|
|
|
// First, make sure that the content model is up to date and we've
|
|
|
|
// constructed the frames for all our content in the right places.
|
|
|
|
// Otherwise they'll end up under the wrong insertion frame when we
|
|
|
|
// ActuallyDisplayText, since that flushes out the content sink by
|
|
|
|
// calling SetText on a DOM node with aNotify set to true. See bug
|
|
|
|
// 289730.
|
2009-10-16 06:49:57 +04:00
|
|
|
nsWeakFrame weakThis(this);
|
2007-03-31 01:11:41 +04:00
|
|
|
PresContext()->Document()->
|
2005-04-12 19:31:03 +04:00
|
|
|
FlushPendingNotifications(Flush_ContentAndNotify);
|
2009-10-16 06:49:57 +04:00
|
|
|
if (!weakThis.IsAlive())
|
|
|
|
return;
|
|
|
|
|
2005-03-21 04:58:17 +03:00
|
|
|
// Redirect frame insertions during this method (see GetContentInsertionFrame())
|
|
|
|
// so that any reframing that the frame constructor forces upon us is inserted
|
|
|
|
// into the correct parent (mDisplayFrame). See bug 282607.
|
|
|
|
NS_PRECONDITION(!mInRedisplayText, "Nested RedisplayText");
|
2011-10-17 18:59:28 +04:00
|
|
|
mInRedisplayText = true;
|
2006-05-10 21:30:15 +04:00
|
|
|
mRedisplayTextEvent.Forget();
|
2005-03-21 04:58:17 +03:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
ActuallyDisplayText(true);
|
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
|
|
|
// XXXbz This should perhaps be eResize. Check.
|
2007-03-31 01:11:41 +04:00
|
|
|
PresContext()->PresShell()->FrameNeedsReflow(mDisplayFrame,
|
2007-05-06 23:16:51 +04:00
|
|
|
nsIPresShell::eStyleChange,
|
|
|
|
NS_FRAME_IS_DIRTY);
|
2005-03-21 04:58:17 +03:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
mInRedisplayText = false;
|
2005-03-21 04:58:17 +03:00
|
|
|
}
|
|
|
|
|
2005-06-21 04:00:14 +04:00
|
|
|
void
|
2011-09-29 10:19:26 +04:00
|
|
|
nsComboboxControlFrame::ActuallyDisplayText(bool aNotify)
|
2002-01-26 02:35:44 +03:00
|
|
|
{
|
2005-06-21 04:00:14 +04:00
|
|
|
if (mDisplayedOptionText.IsEmpty()) {
|
2002-11-12 22:17:51 +03:00
|
|
|
// Have to use a non-breaking space for line-height calculations
|
|
|
|
// to be right
|
2014-01-04 19:02:17 +04:00
|
|
|
static const char16_t space = 0xA0;
|
2004-05-13 05:12:10 +04:00
|
|
|
mDisplayContent->SetText(&space, 1, aNotify);
|
2002-01-26 02:35:44 +03:00
|
|
|
} else {
|
2005-06-21 04:00:14 +04:00
|
|
|
mDisplayContent->SetText(mDisplayedOptionText, aNotify);
|
2002-01-26 02:35:44 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t
|
2006-02-18 04:52:03 +03:00
|
|
|
nsComboboxControlFrame::GetIndexOfDisplayArea()
|
2000-12-21 02:25:40 +03:00
|
|
|
{
|
2006-02-18 04:52:03 +03:00
|
|
|
return mDisplayedIndex;
|
2000-12-21 02:25:40 +03:00
|
|
|
}
|
1999-08-26 18:54:07 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISelectControlFrame
|
|
|
|
//----------------------------------------------------------------------
|
1999-11-12 01:13:33 +03:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsComboboxControlFrame::DoneAddingChildren(bool aIsDone)
|
1999-11-12 01:13:33 +03:00
|
|
|
{
|
2009-01-12 22:20:59 +03:00
|
|
|
nsISelectControlFrame* listFrame = do_QueryFrame(mDropdownFrame);
|
|
|
|
if (!listFrame)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
return listFrame->DoneAddingChildren(aIsDone);
|
1999-11-12 01:13:33 +03:00
|
|
|
}
|
1999-08-26 18:54:07 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsComboboxControlFrame::AddOption(int32_t aIndex)
|
1999-08-26 18:54:07 +04:00
|
|
|
{
|
2005-06-21 03:26:35 +04:00
|
|
|
if (aIndex <= mDisplayedIndex) {
|
|
|
|
++mDisplayedIndex;
|
|
|
|
}
|
|
|
|
|
2007-07-08 11:08:04 +04:00
|
|
|
nsListControlFrame* lcf = static_cast<nsListControlFrame*>(mDropdownFrame);
|
2009-02-18 06:27:25 +03:00
|
|
|
return lcf->AddOption(aIndex);
|
1999-08-26 18:54:07 +04:00
|
|
|
}
|
2012-10-05 10:12:15 +04:00
|
|
|
|
1999-08-26 18:54:07 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsComboboxControlFrame::RemoveOption(int32_t aIndex)
|
1999-08-26 18:54:07 +04:00
|
|
|
{
|
2009-10-16 06:49:57 +04:00
|
|
|
nsWeakFrame weakThis(this);
|
2006-03-01 04:00:29 +03:00
|
|
|
if (mListControlFrame->GetNumberOfOptions() > 0) {
|
2005-06-21 03:26:35 +04:00
|
|
|
if (aIndex < mDisplayedIndex) {
|
|
|
|
--mDisplayedIndex;
|
|
|
|
} else if (aIndex == mDisplayedIndex) {
|
|
|
|
mDisplayedIndex = 0; // IE6 compat
|
|
|
|
RedisplayText(mDisplayedIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// If we removed the last option, we need to blank things out
|
2002-07-18 04:58:31 +04:00
|
|
|
RedisplayText(-1);
|
1999-08-27 07:58:13 +04:00
|
|
|
}
|
2002-07-18 04:58:31 +04:00
|
|
|
|
2009-10-16 06:49:57 +04:00
|
|
|
if (!weakThis.IsAlive())
|
|
|
|
return NS_OK;
|
|
|
|
|
2007-07-08 11:08:04 +04:00
|
|
|
nsListControlFrame* lcf = static_cast<nsListControlFrame*>(mDropdownFrame);
|
2009-02-18 06:27:25 +03:00
|
|
|
return lcf->RemoveOption(aIndex);
|
1999-08-27 07:58:13 +04:00
|
|
|
}
|
|
|
|
|
2005-02-05 01:56:13 +03:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsComboboxControlFrame::OnSetSelectedIndex(int32_t aOldIndex, int32_t aNewIndex)
|
2005-02-05 01:56:13 +03:00
|
|
|
{
|
2009-02-18 06:27:25 +03:00
|
|
|
nsAutoScriptBlocker scriptBlocker;
|
2007-08-22 07:25:42 +04:00
|
|
|
RedisplayText(aNewIndex);
|
2009-01-09 19:35:24 +03:00
|
|
|
NS_ASSERTION(mDropdownFrame, "No dropdown frame!");
|
2012-10-05 10:12:15 +04:00
|
|
|
|
2009-01-12 22:20:59 +03:00
|
|
|
nsISelectControlFrame* listFrame = do_QueryFrame(mDropdownFrame);
|
2005-02-05 01:56:13 +03:00
|
|
|
NS_ASSERTION(listFrame, "No list frame!");
|
|
|
|
|
|
|
|
return listFrame->OnSetSelectedIndex(aOldIndex, aNewIndex);
|
2000-04-29 03:24:59 +04:00
|
|
|
}
|
|
|
|
|
2001-11-02 10:40:01 +03:00
|
|
|
// End nsISelectControlFrame
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2012-10-05 10:12:15 +04:00
|
|
|
nsComboboxControlFrame::HandleEvent(nsPresContext* aPresContext,
|
2013-10-02 07:46:03 +04:00
|
|
|
WidgetGUIEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus)
|
1999-07-29 01:38:08 +04:00
|
|
|
{
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(aEventStatus);
|
2002-05-23 15:25:58 +04:00
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
if (nsEventStatus_eConsumeNoDefault == *aEventStatus) {
|
1999-07-29 01:38:08 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2010-09-19 05:43:15 +04:00
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates eventStates = mContent->AsElement()->State();
|
2010-10-20 15:26:32 +04:00
|
|
|
if (eventStates.HasState(NS_EVENT_STATE_DISABLED)) {
|
1999-08-10 23:25:22 +04:00
|
|
|
return NS_OK;
|
1999-07-29 01:38:08 +04:00
|
|
|
}
|
|
|
|
|
2000-09-07 08:39:02 +04:00
|
|
|
// If we have style that affects how we are selected, feed event down to
|
|
|
|
// nsFrame::HandleEvent so that selection takes place when appropriate.
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleUserInterface* uiStyle = StyleUserInterface();
|
2000-09-07 08:39:02 +04:00
|
|
|
if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE || uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
|
2008-12-29 18:07:38 +03:00
|
|
|
return nsBlockFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
2012-10-05 10:12:15 +04:00
|
|
|
|
2000-09-07 08:39:02 +04:00
|
|
|
return NS_OK;
|
1999-07-29 01:38:08 +04: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
|
|
|
|
2005-12-13 02:53:06 +03:00
|
|
|
nsresult
|
|
|
|
nsComboboxControlFrame::SetFormProperty(nsIAtom* aName, const nsAString& aValue)
|
1999-01-26 01:16:27 +03:00
|
|
|
{
|
2009-01-12 22:20:59 +03:00
|
|
|
nsIFormControlFrame* fcFrame = do_QueryFrame(mDropdownFrame);
|
|
|
|
if (!fcFrame) {
|
|
|
|
return NS_NOINTERFACE;
|
1999-04-13 02:14:31 +04:00
|
|
|
}
|
2009-01-12 22:20:59 +03:00
|
|
|
|
|
|
|
return fcFrame->SetFormProperty(aName, aValue);
|
1999-01-26 01:16:27 +03:00
|
|
|
}
|
|
|
|
|
2004-07-18 16:02:53 +04:00
|
|
|
nsIFrame*
|
|
|
|
nsComboboxControlFrame::GetContentInsertionFrame() {
|
2005-02-20 02:54:36 +03:00
|
|
|
return mInRedisplayText ? mDisplayFrame : mDropdownFrame->GetContentInsertionFrame();
|
2004-07-18 16:02:53 +04: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
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
nsresult
|
2011-05-07 00:04:44 +04:00
|
|
|
nsComboboxControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
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
|
|
|
{
|
|
|
|
// The frames used to display the combo box and the button used to popup the dropdown list
|
|
|
|
// are created through anonymous content. The dropdown list is not created through anonymous
|
2014-01-15 10:06:47 +04:00
|
|
|
// content because its frame is initialized specifically for the drop-down case and it is placed
|
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
|
|
|
// a special list referenced through NS_COMBO_FRAME_POPUP_LIST_INDEX to keep separate from the
|
2012-10-05 10:12:15 +04:00
|
|
|
// layout of the display and button.
|
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
|
|
|
//
|
|
|
|
// Note: The value attribute of the display content is set when an item is selected in the dropdown list.
|
|
|
|
// If the content specified below does not honor the value attribute than nothing will be displayed.
|
|
|
|
|
|
|
|
// For now the content that is created corresponds to two input buttons. It would be better to create the
|
|
|
|
// tag as something other than input, but then there isn't any way to create a button frame since it
|
|
|
|
// isn't possible to set the display type in CSS2 to create a button frame.
|
|
|
|
|
|
|
|
// create content used for display
|
1999-08-06 18:13:20 +04:00
|
|
|
//nsIAtom* tag = NS_NewAtom("mozcombodisplay");
|
2000-02-15 18:04:38 +03:00
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
// Add a child text content node for the label
|
2004-08-10 14:22:36 +04:00
|
|
|
|
2005-09-24 22:43:15 +04:00
|
|
|
nsNodeInfoManager *nimgr = mContent->NodeInfo()->NodeInfoManager();
|
|
|
|
|
2013-04-04 16:01:08 +04:00
|
|
|
mDisplayContent = new nsTextNode(nimgr);
|
2004-08-10 14:22:36 +04:00
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
// set the value of the text node
|
|
|
|
mDisplayedIndex = mListControlFrame->GetSelectedIndex();
|
|
|
|
if (mDisplayedIndex != -1) {
|
|
|
|
mListControlFrame->GetOptionText(mDisplayedIndex, mDisplayedOptionText);
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
ActuallyDisplayText(false);
|
2000-03-07 18:54:31 +03:00
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
if (!aElements.AppendElement(mDisplayContent))
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2000-05-10 17:13:39 +04:00
|
|
|
|
2013-12-03 18:40:10 +04:00
|
|
|
mButtonContent = mContent->OwnerDoc()->CreateHTMLElement(nsGkAtoms::button);
|
2007-02-18 20:34:09 +03:00
|
|
|
if (!mButtonContent)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2004-06-25 16:26:02 +04:00
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
// make someone to listen to the button. If its pressed by someone like Accessibility
|
|
|
|
// then open or close the combo box.
|
2007-05-14 13:11:38 +04:00
|
|
|
mButtonListener = new nsComboButtonListener(this);
|
2011-06-29 22:07:25 +04:00
|
|
|
mButtonContent->AddEventListener(NS_LITERAL_STRING("click"), mButtonListener,
|
2011-10-17 18:59:28 +04:00
|
|
|
false, false);
|
2004-06-25 16:26:02 +04:00
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
mButtonContent->SetAttr(kNameSpaceID_None, nsGkAtoms::type,
|
2011-10-17 18:59:28 +04:00
|
|
|
NS_LITERAL_STRING("button"), false);
|
2007-02-18 20:34:09 +03:00
|
|
|
// Set tabindex="-1" so that the button is not tabbable
|
|
|
|
mButtonContent->SetAttr(kNameSpaceID_None, nsGkAtoms::tabindex,
|
2011-10-17 18:59:28 +04:00
|
|
|
NS_LITERAL_STRING("-1"), false);
|
2004-06-25 16:26:02 +04:00
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
if (!aElements.AppendElement(mButtonContent))
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
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
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-02-11 20:34:01 +03:00
|
|
|
void
|
2010-10-15 19:34:35 +04:00
|
|
|
nsComboboxControlFrame::AppendAnonymousContentTo(nsBaseContentList& aElements,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aFilter)
|
2010-02-11 20:34:01 +03:00
|
|
|
{
|
|
|
|
aElements.MaybeAppendElement(mDisplayContent);
|
|
|
|
aElements.MaybeAppendElement(mButtonContent);
|
|
|
|
}
|
|
|
|
|
2007-02-19 02:53:25 +03:00
|
|
|
// XXXbz this is a for-now hack. Now that display:inline-block works,
|
|
|
|
// need to revisit this.
|
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 : public nsBlockFrame {
|
|
|
|
public:
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
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
|
|
|
nsComboboxDisplayFrame (nsStyleContext* aContext,
|
|
|
|
nsComboboxControlFrame* aComboBox)
|
|
|
|
: nsBlockFrame(aContext),
|
|
|
|
mComboBox(aComboBox)
|
|
|
|
{}
|
|
|
|
|
2007-02-28 06:04:38 +03:00
|
|
|
// Need this so that line layout knows that this block's width
|
|
|
|
// depends on the available width.
|
2014-02-24 18:41:56 +04:00
|
|
|
virtual nsIAtom* GetType() const MOZ_OVERRIDE;
|
2007-02-28 06:04:38 +03:00
|
|
|
|
2014-02-24 18:41:56 +04:00
|
|
|
virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
|
2007-02-24 21:33:33 +03:00
|
|
|
{
|
|
|
|
return nsBlockFrame::IsFrameOfType(aFlags &
|
|
|
|
~(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
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
virtual void Reflow(nsPresContext* aPresContext,
|
2014-02-18 12:36:33 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
2014-02-24 18:41:56 +04:00
|
|
|
nsReflowStatus& aStatus) MOZ_OVERRIDE;
|
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
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists) MOZ_OVERRIDE;
|
2007-05-22 23:42:01 +04: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
|
|
|
protected:
|
|
|
|
nsComboboxControlFrame* mComboBox;
|
|
|
|
};
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsComboboxDisplayFrame)
|
|
|
|
|
2007-02-28 06:04:38 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsComboboxDisplayFrame::GetType() const
|
|
|
|
{
|
|
|
|
return nsGkAtoms::comboboxDisplayFrame;
|
|
|
|
}
|
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
void
|
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
|
|
|
nsComboboxDisplayFrame::Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
nsHTMLReflowState state(aReflowState);
|
2007-08-02 22:08:05 +04:00
|
|
|
if (state.ComputedHeight() == NS_INTRINSICSIZE) {
|
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
|
|
|
// Note that the only way we can have a computed height here is if the
|
|
|
|
// combobox had a specified height. If it didn't, size based on what our
|
|
|
|
// rows look like, for lack of anything better.
|
2007-08-02 22:08:05 +04:00
|
|
|
state.SetComputedHeight(mComboBox->mListControlFrame->GetHeightOfARow());
|
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
|
|
|
}
|
2007-01-26 03:05:12 +03:00
|
|
|
nscoord computedWidth = mComboBox->mDisplayWidth -
|
2013-12-27 21:59:21 +04:00
|
|
|
state.ComputedPhysicalBorderPadding().LeftRight();
|
2007-01-26 03:05:12 +03:00
|
|
|
if (computedWidth < 0) {
|
|
|
|
computedWidth = 0;
|
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
|
|
|
}
|
2007-01-26 03:05:12 +03:00
|
|
|
state.SetComputedWidth(computedWidth);
|
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
|
|
|
|
|
|
|
return nsBlockFrame::Reflow(aPresContext, aDesiredSize, state, aStatus);
|
|
|
|
}
|
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
void
|
2007-05-22 23:42:01 +04:00
|
|
|
nsComboboxDisplayFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
|
|
|
nsDisplayListCollection set;
|
2013-02-14 15:08:08 +04:00
|
|
|
nsBlockFrame::BuildDisplayList(aBuilder, aDirtyRect, set);
|
2007-05-22 23:42:01 +04:00
|
|
|
|
|
|
|
// remove background items if parent frame is themed
|
|
|
|
if (mComboBox->IsThemed()) {
|
|
|
|
set.BorderBackground()->DeleteAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
set.MoveTo(aLists);
|
|
|
|
}
|
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
nsIFrame*
|
|
|
|
nsComboboxControlFrame::CreateFrameFor(nsIContent* aContent)
|
2012-10-05 10:12:15 +04:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_PRECONDITION(nullptr != aContent, "null ptr");
|
2000-04-19 17:55:17 +04:00
|
|
|
|
2005-12-11 23:45:58 +03:00
|
|
|
NS_ASSERTION(mDisplayContent, "mDisplayContent can't be null!");
|
2000-04-19 17:55:17 +04:00
|
|
|
|
2006-07-19 12:55:36 +04:00
|
|
|
if (mDisplayContent != aContent) {
|
2005-12-11 23:45:58 +03:00
|
|
|
// We only handle the frames for mDisplayContent here
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2000-04-19 17:55:17 +04:00
|
|
|
}
|
2012-10-05 10:12:15 +04:00
|
|
|
|
2005-12-11 23:45:58 +03:00
|
|
|
// Get PresShell
|
2007-03-31 01:11:41 +04:00
|
|
|
nsIPresShell *shell = PresContext()->PresShell();
|
2005-12-11 23:45:58 +03:00
|
|
|
nsStyleSet *styleSet = shell->StyleSet();
|
2000-04-19 17:55:17 +04:00
|
|
|
|
2005-12-11 23:45:58 +03:00
|
|
|
// create the style contexts for the anonymous block frame and text frame
|
|
|
|
nsRefPtr<nsStyleContext> styleContext;
|
|
|
|
styleContext = styleSet->
|
2009-12-11 10:37:40 +03:00
|
|
|
ResolveAnonymousBoxStyle(nsCSSAnonBoxes::mozDisplayComboboxControlFrame,
|
|
|
|
mStyleContext);
|
2005-11-04 05:38:33 +03:00
|
|
|
|
2005-12-11 23:45:58 +03:00
|
|
|
nsRefPtr<nsStyleContext> textStyleContext;
|
2007-06-16 09:11:20 +04:00
|
|
|
textStyleContext = styleSet->ResolveStyleForNonElement(mStyleContext);
|
2000-04-19 17:55:17 +04:00
|
|
|
|
2013-08-03 08:11:06 +04:00
|
|
|
// Start by creating our anonymous block frame
|
2007-02-19 02:53:25 +03:00
|
|
|
mDisplayFrame = new (shell) nsComboboxDisplayFrame(styleContext, this);
|
2013-03-20 05:47:48 +04:00
|
|
|
mDisplayFrame->Init(mContent, this, nullptr);
|
2000-04-19 17:55:17 +04:00
|
|
|
|
2005-12-11 23:45:58 +03:00
|
|
|
// Create a text frame and put it inside the block frame
|
2010-05-13 04:56:11 +04:00
|
|
|
nsIFrame* textFrame = NS_NewTextFrame(shell, textStyleContext);
|
2000-04-19 17:55:17 +04:00
|
|
|
|
2005-12-11 23:45:58 +03:00
|
|
|
// initialize the text frame
|
2013-03-20 05:47:48 +04:00
|
|
|
textFrame->Init(aContent, mDisplayFrame, nullptr);
|
2010-05-13 04:56:11 +04:00
|
|
|
mDisplayContent->SetPrimaryFrame(textFrame);
|
2000-04-19 17:55:17 +04:00
|
|
|
|
2010-05-13 04:56:11 +04:00
|
|
|
nsFrameList textList(textFrame, textFrame);
|
2011-08-25 00:54:30 +04:00
|
|
|
mDisplayFrame->SetInitialChildList(kPrincipalList, textList);
|
2007-02-18 20:34:09 +03:00
|
|
|
return mDisplayFrame;
|
2000-04-19 17:55:17 +04:00
|
|
|
}
|
|
|
|
|
2006-04-10 04:16:29 +04:00
|
|
|
void
|
2009-12-24 08:21:15 +03:00
|
|
|
nsComboboxControlFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
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
|
|
|
{
|
2006-05-10 21:30:15 +04:00
|
|
|
// Revoke any pending RedisplayTextEvent
|
|
|
|
mRedisplayTextEvent.Revoke();
|
2005-03-21 04:58:17 +03:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
nsFormControlFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), false);
|
2000-08-03 18:13:40 +04:00
|
|
|
|
2000-03-28 18:29:15 +04:00
|
|
|
if (mDroppedDown) {
|
2013-02-05 21:19:15 +04:00
|
|
|
MOZ_ASSERT(mDropdownFrame, "mDroppedDown without frame");
|
|
|
|
nsView* view = mDropdownFrame->GetView();
|
|
|
|
MOZ_ASSERT(view);
|
|
|
|
nsIWidget* widget = view->GetWidget();
|
|
|
|
if (widget) {
|
|
|
|
widget->CaptureRollupEvents(this, false);
|
2000-03-28 18:29:15 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-21 00:28:02 +04:00
|
|
|
// Cleanup frames in popup child list
|
2009-12-24 08:21:15 +03:00
|
|
|
mPopupFrames.DestroyFramesFrom(aDestructRoot);
|
2007-02-18 20:34:09 +03:00
|
|
|
nsContentUtils::DestroyAnonymousContent(&mDisplayContent);
|
|
|
|
nsContentUtils::DestroyAnonymousContent(&mButtonContent);
|
2009-12-24 08:21:15 +03:00
|
|
|
nsBlockFrame::DestroyFrom(aDestructRoot);
|
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
|
|
|
}
|
|
|
|
|
2012-03-08 05:57:37 +04:00
|
|
|
const nsFrameList&
|
2011-08-25 00:54:29 +04:00
|
|
|
nsComboboxControlFrame::GetChildList(ChildListID aListID) const
|
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
|
|
|
{
|
2011-08-25 00:54:29 +04:00
|
|
|
if (kSelectPopupList == aListID) {
|
2009-07-28 16:51:09 +04:00
|
|
|
return mPopupFrames;
|
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
|
|
|
}
|
2011-08-25 00:54:29 +04:00
|
|
|
return nsBlockFrame::GetChildList(aListID);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsComboboxControlFrame::GetChildLists(nsTArray<ChildList>* aLists) const
|
|
|
|
{
|
|
|
|
nsBlockFrame::GetChildLists(aLists);
|
|
|
|
mPopupFrames.AppendIfNonempty(aLists, kSelectPopupList);
|
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
|
|
|
}
|
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2011-08-25 00:54:30 +04:00
|
|
|
nsComboboxControlFrame::SetInitialChildList(ChildListID aListID,
|
2009-07-28 16:53:20 +04:00
|
|
|
nsFrameList& aChildList)
|
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
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
2011-08-25 00:54:30 +04:00
|
|
|
if (kSelectPopupList == aListID) {
|
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
|
|
|
mPopupFrames.SetFrames(aChildList);
|
|
|
|
} else {
|
2009-07-28 16:53:20 +04:00
|
|
|
for (nsFrameList::Enumerator e(aChildList); !e.AtEnd(); e.Next()) {
|
|
|
|
nsCOMPtr<nsIFormControl> formControl =
|
|
|
|
do_QueryInterface(e.get()->GetContent());
|
2011-03-26 04:05:56 +03:00
|
|
|
if (formControl && formControl->GetType() == NS_FORM_BUTTON_BUTTON) {
|
2009-07-28 16:53:20 +04:00
|
|
|
mButtonFrame = e.get();
|
2005-12-08 22:01:20 +03:00
|
|
|
break;
|
2000-04-19 17:55:17 +04:00
|
|
|
}
|
|
|
|
}
|
2005-12-08 22:01:20 +03:00
|
|
|
NS_ASSERTION(mButtonFrame, "missing button frame in initial child list");
|
2011-08-25 00:54:30 +04:00
|
|
|
rv = nsBlockFrame::SetInitialChildList(aListID, aChildList);
|
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
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-09-22 01:20:50 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
//nsIRollupListener
|
|
|
|
//----------------------------------------------------------------------
|
2012-10-26 17:15:22 +04:00
|
|
|
bool
|
2013-11-04 20:22:24 +04:00
|
|
|
nsComboboxControlFrame::Rollup(uint32_t aCount, const nsIntPoint* pos, nsIContent** aLastRolledUp)
|
1999-09-22 01:20:50 +04:00
|
|
|
{
|
2012-10-26 17:15:22 +04:00
|
|
|
if (!mDroppedDown)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
nsWeakFrame weakFrame(this);
|
|
|
|
mListControlFrame->AboutToRollup(); // might destroy us
|
|
|
|
if (!weakFrame.IsAlive())
|
|
|
|
return true;
|
|
|
|
ShowDropDown(false); // might destroy us
|
|
|
|
if (weakFrame.IsAlive()) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mListControlFrame->CaptureMouseEvents(false);
|
1999-09-22 01:20:50 +04:00
|
|
|
}
|
2011-11-08 23:59:07 +04:00
|
|
|
|
2012-10-26 17:15:22 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIWidget*
|
|
|
|
nsComboboxControlFrame::GetRollupWidget()
|
|
|
|
{
|
2013-02-05 21:19:15 +04:00
|
|
|
nsView* view = mDropdownFrame->GetView();
|
2012-10-26 17:15:22 +04:00
|
|
|
MOZ_ASSERT(view);
|
|
|
|
return view->GetWidget();
|
1999-09-22 01:20:50 +04:00
|
|
|
}
|
|
|
|
|
2006-02-18 04:52:03 +03:00
|
|
|
void
|
|
|
|
nsComboboxControlFrame::RollupFromList()
|
2002-01-26 02:35:44 +03:00
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
if (ShowList(false))
|
|
|
|
mListControlFrame->CaptureMouseEvents(false);
|
2002-01-26 02:35:44 +03:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t
|
|
|
|
nsComboboxControlFrame::UpdateRecentIndex(int32_t aIndex)
|
2002-02-08 21:35:48 +03:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t index = mRecentSelectedIndex;
|
2006-09-30 09:07:49 +04:00
|
|
|
if (mRecentSelectedIndex == NS_SKIP_NOTIFY_INDEX || aIndex == NS_SKIP_NOTIFY_INDEX)
|
2004-07-23 12:25:44 +04:00
|
|
|
mRecentSelectedIndex = aIndex;
|
|
|
|
return index;
|
2002-02-08 21:35:48 +03:00
|
|
|
}
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
class nsDisplayComboboxFocus : public nsDisplayItem {
|
|
|
|
public:
|
2010-08-13 14:01:13 +04:00
|
|
|
nsDisplayComboboxFocus(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsComboboxControlFrame* aFrame)
|
|
|
|
: nsDisplayItem(aBuilder, aFrame) {
|
2006-01-29 21:48:58 +03:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayComboboxFocus);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayComboboxFocus() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayComboboxFocus);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-07 04:35:14 +04:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
2014-02-24 18:41:56 +04:00
|
|
|
nsRenderingContext* aCtx) MOZ_OVERRIDE;
|
2010-07-16 01:07:49 +04:00
|
|
|
NS_DISPLAY_DECL_NAME("ComboboxFocus", TYPE_COMBOBOX_FOCUS)
|
2006-01-26 05:29:17 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
void nsDisplayComboboxFocus::Paint(nsDisplayListBuilder* aBuilder,
|
2011-04-08 05:04:40 +04:00
|
|
|
nsRenderingContext* aCtx)
|
2006-01-26 05:29:17 +03:00
|
|
|
{
|
2007-07-08 11:08:04 +04:00
|
|
|
static_cast<nsComboboxControlFrame*>(mFrame)
|
2010-08-13 14:01:58 +04:00
|
|
|
->PaintFocus(*aCtx, ToReferenceFrame());
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
void
|
2006-01-26 05:29:17 +03:00
|
|
|
nsComboboxControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
2000-03-07 18:54:31 +03:00
|
|
|
{
|
|
|
|
#ifdef NOISY
|
2006-01-26 05:29:17 +03:00
|
|
|
printf("%p paint at (%d, %d, %d, %d)\n", this,
|
2000-10-29 02:17:53 +04:00
|
|
|
aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height);
|
2000-03-07 18:54:31 +03:00
|
|
|
#endif
|
2006-01-26 05:29:17 +03:00
|
|
|
|
|
|
|
if (aBuilder->IsForEventDelivery()) {
|
|
|
|
// Don't allow children to receive events.
|
|
|
|
// REVIEW: following old GetFrameForPoint
|
2013-02-14 15:08:08 +04:00
|
|
|
DisplayBorderBackgroundOutline(aBuilder, aLists);
|
2006-01-26 05:29:17 +03:00
|
|
|
} else {
|
|
|
|
// REVIEW: Our in-flow child frames are inline-level so they will paint in our
|
|
|
|
// content list, so we don't need to mess with layers.
|
2013-02-14 15:08:08 +04:00
|
|
|
nsBlockFrame::BuildDisplayList(aBuilder, aDirtyRect, aLists);
|
2000-03-07 18:54:31 +03:00
|
|
|
}
|
2006-01-26 05:29:17 +03:00
|
|
|
|
2010-04-21 18:53:42 +04:00
|
|
|
// draw a focus indicator only when focus rings should be drawn
|
|
|
|
nsIDocument* doc = mContent->GetCurrentDoc();
|
|
|
|
if (doc) {
|
|
|
|
nsPIDOMWindow* window = doc->GetWindow();
|
|
|
|
if (window && window->ShouldShowFocusRing()) {
|
|
|
|
nsPresContext *presContext = PresContext();
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleDisplay *disp = StyleDisplay();
|
2010-04-21 18:53:42 +04:00
|
|
|
if ((!IsThemed(disp) ||
|
2013-05-14 03:47:03 +04:00
|
|
|
!presContext->GetTheme()->ThemeDrawsFocusForWidget(disp->mAppearance)) &&
|
2010-04-21 18:53:42 +04:00
|
|
|
mDisplayFrame && IsVisibleForPainting(aBuilder)) {
|
2013-02-14 15:08:08 +04:00
|
|
|
aLists.Content()->AppendNewToTop(
|
|
|
|
new (aBuilder) nsDisplayComboboxFocus(aBuilder, this));
|
2010-04-21 18:53:42 +04:00
|
|
|
}
|
|
|
|
}
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
|
|
|
|
2013-02-14 15:08:08 +04:00
|
|
|
DisplaySelectionOverlay(aBuilder, aLists.Content());
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
|
|
|
|
2011-04-08 05:04:40 +04:00
|
|
|
void nsComboboxControlFrame::PaintFocus(nsRenderingContext& aRenderingContext,
|
2008-04-29 07:55:07 +04:00
|
|
|
nsPoint aPt)
|
|
|
|
{
|
|
|
|
/* Do we need to do anything? */
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates eventStates = mContent->AsElement()->State();
|
2012-06-23 05:13:56 +04:00
|
|
|
if (eventStates.HasState(NS_EVENT_STATE_DISABLED) || sFocused != this)
|
2008-04-29 07:55:07 +04:00
|
|
|
return;
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
aRenderingContext.PushState();
|
|
|
|
nsRect clipRect = mDisplayFrame->GetRect() + aPt;
|
2011-04-08 05:04:40 +04:00
|
|
|
aRenderingContext.IntersectClip(clipRect);
|
2006-01-26 05:29:17 +03:00
|
|
|
|
|
|
|
// REVIEW: Why does the old code paint mDisplayFrame again? We've
|
|
|
|
// already painted it in the children above. So clipping it here won't do
|
|
|
|
// us much good.
|
|
|
|
|
|
|
|
/////////////////////
|
|
|
|
// draw focus
|
2008-04-29 07:55:07 +04:00
|
|
|
|
|
|
|
aRenderingContext.SetLineStyle(nsLineStyle_kDotted);
|
2013-02-17 01:51:02 +04:00
|
|
|
aRenderingContext.SetColor(StyleColor()->mColor);
|
2008-04-29 07:55:07 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
//aRenderingContext.DrawRect(clipRect);
|
2008-04-29 07:55:07 +04:00
|
|
|
|
2007-02-07 10:46:44 +03:00
|
|
|
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
|
2006-01-26 05:29:17 +03:00
|
|
|
clipRect.width -= onePixel;
|
|
|
|
clipRect.height -= onePixel;
|
2011-04-08 05:04:39 +04:00
|
|
|
aRenderingContext.DrawLine(clipRect.TopLeft(), clipRect.TopRight());
|
|
|
|
aRenderingContext.DrawLine(clipRect.TopRight(), clipRect.BottomRight());
|
|
|
|
aRenderingContext.DrawLine(clipRect.BottomRight(), clipRect.BottomLeft());
|
|
|
|
aRenderingContext.DrawLine(clipRect.BottomLeft(), clipRect.TopLeft());
|
2006-01-26 05:29:17 +03:00
|
|
|
|
|
|
|
aRenderingContext.PopState();
|
2000-03-07 18:54:31 +03:00
|
|
|
}
|
|
|
|
|
2001-11-02 10:40:01 +03:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// gets the content (an option) by index and then set it as
|
|
|
|
// being selected or not selected
|
|
|
|
//---------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsComboboxControlFrame::OnOptionSelected(int32_t aIndex, bool aSelected)
|
2001-11-02 10:40:01 +03:00
|
|
|
{
|
2003-03-14 09:18:20 +03:00
|
|
|
if (mDroppedDown) {
|
2009-01-12 22:20:59 +03:00
|
|
|
nsISelectControlFrame *selectFrame = do_QueryFrame(mListControlFrame);
|
2003-03-14 09:18:20 +03:00
|
|
|
if (selectFrame) {
|
2009-02-18 06:27:25 +03:00
|
|
|
selectFrame->OnOptionSelected(aIndex, aSelected);
|
2003-03-14 09:18:20 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (aSelected) {
|
2009-02-18 06:27:25 +03:00
|
|
|
nsAutoScriptBlocker blocker;
|
2002-01-26 02:35:44 +03:00
|
|
|
RedisplayText(aIndex);
|
|
|
|
} else {
|
2009-02-18 06:27:25 +03:00
|
|
|
nsWeakFrame weakFrame(this);
|
2003-03-14 09:18:20 +03:00
|
|
|
RedisplaySelectedText();
|
2009-02-18 06:27:25 +03:00
|
|
|
if (weakFrame.IsAlive()) {
|
|
|
|
FireValueChangeEvent(); // Fire after old option is unselected
|
|
|
|
}
|
2002-01-26 02:35:44 +03:00
|
|
|
}
|
2001-11-02 10:40:01 +03:00
|
|
|
}
|
2003-03-14 09:18:20 +03:00
|
|
|
|
2001-11-02 10:40:01 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-02-08 02:11:30 +03:00
|
|
|
void nsComboboxControlFrame::FireValueChangeEvent()
|
|
|
|
{
|
|
|
|
// Fire ValueChange event to indicate data value of combo box has changed
|
2010-02-25 05:45:43 +03:00
|
|
|
nsContentUtils::AddScriptRunner(
|
2014-03-17 10:56:54 +04:00
|
|
|
new AsyncEventDispatcher(mContent, NS_LITERAL_STRING("ValueChange"), true,
|
|
|
|
false));
|
2005-02-08 02:11:30 +03:00
|
|
|
}
|
|
|
|
|
2005-12-13 02:53:06 +03:00
|
|
|
void
|
2001-11-02 10:40:01 +03:00
|
|
|
nsComboboxControlFrame::OnContentReset()
|
|
|
|
{
|
|
|
|
if (mListControlFrame) {
|
2005-12-13 02:53:06 +03:00
|
|
|
mListControlFrame->OnContentReset();
|
2001-11-02 10:40:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------
|
|
|
|
// nsIStatefulFrame
|
|
|
|
//--------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
2012-11-15 10:40:17 +04:00
|
|
|
nsComboboxControlFrame::SaveState(nsPresState** aState)
|
2001-11-02 10:40:01 +03:00
|
|
|
{
|
2005-12-07 02:56:17 +03:00
|
|
|
if (!mListControlFrame)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2009-01-12 22:20:59 +03:00
|
|
|
nsIStatefulFrame* stateful = do_QueryFrame(mListControlFrame);
|
2012-11-15 10:40:17 +04:00
|
|
|
return stateful->SaveState(aState);
|
2001-11-02 10:40:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2005-12-07 02:56:17 +03:00
|
|
|
nsComboboxControlFrame::RestoreState(nsPresState* aState)
|
2001-11-02 10:40:01 +03:00
|
|
|
{
|
2002-01-11 23:10:46 +03:00
|
|
|
if (!mListControlFrame)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2009-01-12 22:20:59 +03:00
|
|
|
nsIStatefulFrame* stateful = do_QueryFrame(mListControlFrame);
|
|
|
|
NS_ASSERTION(stateful, "Must implement nsIStatefulFrame");
|
|
|
|
return stateful->RestoreState(aState);
|
2001-11-02 10:40:01 +03:00
|
|
|
}
|
2005-02-16 08:13:16 +03:00
|
|
|
|
|
|
|
|
|
|
|
//
|
2006-01-11 22:09:20 +03:00
|
|
|
// Camino uses a native widget for the combobox
|
|
|
|
// popup, which affects drawing and event
|
2005-02-16 08:13:16 +03:00
|
|
|
// handling here and in nsListControlFrame.
|
2009-07-06 17:39:54 +04:00
|
|
|
//
|
|
|
|
// Also, Fennec use a custom combobox built-in widget
|
2012-10-05 10:12:15 +04:00
|
|
|
//
|
2005-02-16 08:13:16 +03:00
|
|
|
|
|
|
|
/* static */
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2005-02-16 08:13:16 +03:00
|
|
|
nsComboboxControlFrame::ToolkitHasNativePopup()
|
|
|
|
{
|
2011-06-22 01:00:47 +04:00
|
|
|
#ifdef MOZ_USE_NATIVE_POPUP_WINDOWS
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2011-06-22 01:00:47 +04:00
|
|
|
#else
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2011-06-22 01:00:47 +04:00
|
|
|
#endif /* MOZ_USE_NATIVE_POPUP_WINDOWS */
|
2005-02-16 08:13:16 +03:00
|
|
|
}
|
|
|
|
|