2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:30:37 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-01-18 18:14:00 +03:00
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1999-01-18 18:14:00 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1999-01-18 18:14:00 +03:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
2000-02-03 01:24:56 +03:00
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
2005-03-21 04:58:17 +03:00
|
|
|
* Mats Palmgren <mats.palmgren@bredband.net>
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 18:30:37 +04:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-29 00:14:13 +04:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 18:30:37 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 18:30:37 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-02-12 20:45:58 +03:00
|
|
|
#include "nsCOMPtr.h"
|
2001-09-29 12:28:41 +04:00
|
|
|
#include "nsReadableUtils.h"
|
1999-01-18 18:14:00 +03:00
|
|
|
#include "nsComboboxControlFrame.h"
|
2007-05-14 13:11:38 +04:00
|
|
|
#include "nsIDOMEventTarget.h"
|
2004-02-24 00:29:06 +03:00
|
|
|
#include "nsFrameManager.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"
|
2005-12-13 02:53:06 +03:00
|
|
|
#include "nsGfxButtonControlFrame.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"
|
|
|
|
#include "nsINameSpaceManager.h"
|
|
|
|
#include "nsIDOMElement.h"
|
|
|
|
#include "nsIListControlFrame.h"
|
1999-04-13 02:14:31 +04:00
|
|
|
#include "nsIDOMHTMLCollection.h"
|
|
|
|
#include "nsIDOMHTMLSelectElement.h"
|
|
|
|
#include "nsIDOMHTMLOptionElement.h"
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
#include "nsIDOMNSHTMLOptionCollectn.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"
|
|
|
|
#include "nsIDeviceContext.h"
|
|
|
|
#include "nsIView.h"
|
2007-02-12 22:31:59 +03:00
|
|
|
#include "nsIViewManager.h"
|
1999-07-29 01:38:08 +04:00
|
|
|
#include "nsIScrollableView.h"
|
2006-03-07 20:08:51 +03:00
|
|
|
#include "nsEventDispatcher.h"
|
1999-08-06 18:13:20 +04:00
|
|
|
#include "nsIEventStateManager.h"
|
2005-02-08 02:11:30 +03:00
|
|
|
#include "nsIEventListenerManager.h"
|
1999-09-07 06:16:23 +04:00
|
|
|
#include "nsIDOMNode.h"
|
|
|
|
#include "nsIPrivateDOMEvent.h"
|
1999-09-15 09:31:31 +04:00
|
|
|
#include "nsISelectControlFrame.h"
|
2002-09-04 03:36:13 +04:00
|
|
|
#include "nsXPCOM.h"
|
1999-09-15 09:31:31 +04:00
|
|
|
#include "nsISupportsPrimitives.h"
|
|
|
|
#include "nsIComponentManager.h"
|
2006-03-15 00:02:42 +03:00
|
|
|
#include "nsContentUtils.h"
|
2000-03-07 18:54:31 +03:00
|
|
|
#include "nsTextFragment.h"
|
|
|
|
#include "nsCSSFrameConstructor.h"
|
|
|
|
#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"
|
2001-02-20 00:50:04 +03:00
|
|
|
#include "nsContentCID.h"
|
2001-08-17 07:13:07 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2001-04-01 05:01:33 +04:00
|
|
|
#include "nsIAccessibilityService.h"
|
2001-08-17 07:13:07 +04:00
|
|
|
#endif
|
2001-04-01 05:01:33 +04:00
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIDOMNode.h"
|
2001-07-16 06:40:48 +04:00
|
|
|
#include "nsGUIEvent.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"
|
|
|
|
#include "nsThemeConstants.h"
|
2001-04-01 05:01:33 +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.
|
1999-05-28 01:17:10 +04:00
|
|
|
// If the combo box or it's arrow button is clicked on the drop-down list is displayed
|
|
|
|
// If mouse exit's the combo box with the drop-down list displayed the drop-down list
|
|
|
|
// 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
|
|
|
|
2004-12-20 00:45:51 +03:00
|
|
|
//XXX: This is temporary. It simulates pseudo states by using a attribute selector on
|
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
|
|
|
const PRInt32 kSizeNotSet = -1;
|
|
|
|
|
2001-06-30 04:25:09 +04:00
|
|
|
/**
|
|
|
|
* Helper class that listens to the combo boxes button. If the button is pressed the
|
|
|
|
* combo box is toggled to open or close. this is used by Accessibility which presses
|
|
|
|
* that button Programmatically.
|
|
|
|
*/
|
|
|
|
class nsComboButtonListener: public nsIDOMMouseListener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_IMETHOD HandleEvent(nsIDOMEvent* anEvent) { return PR_FALSE; }
|
|
|
|
NS_IMETHOD MouseDown(nsIDOMEvent* aMouseEvent) { return PR_FALSE; }
|
|
|
|
NS_IMETHOD MouseUp(nsIDOMEvent* aMouseEvent) { return PR_FALSE; }
|
|
|
|
NS_IMETHOD MouseDblClick(nsIDOMEvent* aMouseEvent) { return PR_FALSE; }
|
|
|
|
NS_IMETHOD MouseOver(nsIDOMEvent* aMouseEvent) { return PR_FALSE; }
|
|
|
|
NS_IMETHOD MouseOut(nsIDOMEvent* aMouseEvent) { return PR_FALSE; }
|
|
|
|
|
|
|
|
NS_IMETHOD MouseClick(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
2006-02-18 04:52:03 +03:00
|
|
|
mComboBox->ShowDropDown(!mComboBox->IsDroppedDown());
|
2007-05-17 15:12:30 +04:00
|
|
|
return NS_OK;
|
2001-06-30 04:25:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsComboButtonListener(nsComboboxControlFrame* aCombobox)
|
|
|
|
{
|
|
|
|
mComboBox = aCombobox;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~nsComboButtonListener() {}
|
|
|
|
|
|
|
|
nsComboboxControlFrame* mComboBox;
|
|
|
|
};
|
|
|
|
|
2008-04-06 16:28:34 +04:00
|
|
|
NS_IMPL_ISUPPORTS2(nsComboButtonListener,
|
|
|
|
nsIDOMMouseListener,
|
|
|
|
nsIDOMEventListener)
|
2001-06-30 04:25:09 +04:00
|
|
|
|
2000-10-04 17:39:07 +04:00
|
|
|
// static class data member for Bug 32920
|
|
|
|
nsComboboxControlFrame * nsComboboxControlFrame::mFocused = nsnull;
|
|
|
|
|
2005-11-04 05:38:33 +03:00
|
|
|
nsIFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewComboboxControlFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, PRUint32 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
|
|
|
}
|
|
|
|
|
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
|
|
|
|
static PRInt32 gTotalReqs = 0;;
|
|
|
|
static PRInt32 gTotalReflows = 0;;
|
|
|
|
static PRInt32 gReflowControlCntRQ[MAX_REFLOW_CNT];
|
|
|
|
static PRInt32 gReflowControlCnt[MAX_REFLOW_CNT];
|
|
|
|
static PRInt32 gReflowInx = -1;
|
|
|
|
|
|
|
|
#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 //-------------
|
|
|
|
|
|
|
|
#define REFLOW_COUNTER_REQUEST()
|
|
|
|
#define REFLOW_COUNTER()
|
|
|
|
#define REFLOW_COUNTER_DUMP(__desc)
|
|
|
|
#define REFLOW_COUNTER_INIT()
|
|
|
|
|
|
|
|
#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)
|
|
|
|
|
|
|
|
|
|
|
|
#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
|
|
|
|
#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)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//------------------------------------------
|
|
|
|
// Displays value in pixels or twips
|
|
|
|
//------------------------------------------
|
|
|
|
#ifdef DO_PIXELS
|
|
|
|
#define PX(__v) __v / 15
|
|
|
|
#else
|
|
|
|
#define PX(__v) __v
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//------------------------------------------------------
|
|
|
|
//-- Done with macros
|
|
|
|
//------------------------------------------------------
|
|
|
|
|
2006-03-27 01:30:36 +04:00
|
|
|
nsComboboxControlFrame::nsComboboxControlFrame(nsStyleContext* aContext)
|
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
|
|
|
: nsAreaFrame(aContext),
|
|
|
|
mDisplayWidth(0)
|
1999-01-18 18:14:00 +03:00
|
|
|
{
|
1999-04-13 02:14:31 +04:00
|
|
|
mListControlFrame = nsnull;
|
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
|
|
|
mDroppedDown = PR_FALSE;
|
|
|
|
mDisplayFrame = nsnull;
|
|
|
|
mButtonFrame = nsnull;
|
|
|
|
mDropdownFrame = nsnull;
|
|
|
|
|
2005-02-20 02:54:36 +03:00
|
|
|
mInRedisplayText = PR_FALSE;
|
2000-10-04 17:39:07 +04:00
|
|
|
|
2006-09-30 09:07:49 +04:00
|
|
|
mRecentSelectedIndex = NS_SKIP_NOTIFY_INDEX;
|
2002-02-08 21:35:48 +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
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
1999-11-02 04:50:15 +03:00
|
|
|
// Frames are not refcounted, no need to AddRef
|
|
|
|
NS_IMETHODIMP
|
1999-01-18 18:14:00 +03:00
|
|
|
nsComboboxControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|
|
|
{
|
2007-07-04 06:15:31 +04:00
|
|
|
NS_PRECONDITION(aInstancePtr, "null out param");
|
2006-02-27 07:13:51 +03:00
|
|
|
|
|
|
|
if (aIID.Equals(NS_GET_IID(nsIComboboxControlFrame))) {
|
2007-07-08 11:08:04 +04:00
|
|
|
*aInstancePtr = static_cast<nsIComboboxControlFrame*>(this);
|
1999-01-18 18:14:00 +03:00
|
|
|
return NS_OK;
|
2001-01-04 23:44:42 +03:00
|
|
|
} else if (aIID.Equals(NS_GET_IID(nsIFormControlFrame))) {
|
2007-07-08 11:08:04 +04:00
|
|
|
*aInstancePtr = static_cast<nsIFormControlFrame*>(this);
|
1999-01-18 18:14:00 +03:00
|
|
|
return NS_OK;
|
2001-01-04 23:44:42 +03:00
|
|
|
} else if (aIID.Equals(NS_GET_IID(nsIAnonymousContentCreator))) {
|
2007-07-08 11:08:04 +04:00
|
|
|
*aInstancePtr = static_cast<nsIAnonymousContentCreator*>(this);
|
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;
|
1999-09-15 09:31:31 +04:00
|
|
|
} else if (aIID.Equals(NS_GET_IID(nsISelectControlFrame))) {
|
2007-07-08 11:08:04 +04:00
|
|
|
*aInstancePtr = static_cast<nsISelectControlFrame*>(this);
|
1999-09-15 09:31:31 +04:00
|
|
|
return NS_OK;
|
|
|
|
} else if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
|
2007-07-08 11:08:04 +04:00
|
|
|
*aInstancePtr = static_cast<nsIStatefulFrame*>(this);
|
1999-08-26 18:54:07 +04:00
|
|
|
return NS_OK;
|
2000-02-03 01:24:56 +03:00
|
|
|
} else if (aIID.Equals(NS_GET_IID(nsIRollupListener))) {
|
2007-07-08 11:08:04 +04:00
|
|
|
*aInstancePtr = static_cast<nsIRollupListener*>(this);
|
1999-09-22 01:20:50 +04:00
|
|
|
return NS_OK;
|
2000-12-09 10:28:19 +03:00
|
|
|
} else if (aIID.Equals(NS_GET_IID(nsIScrollableViewProvider))) {
|
2007-07-08 11:08:04 +04:00
|
|
|
*aInstancePtr = static_cast<nsIScrollableViewProvider*>(this);
|
2000-12-09 10:28:19 +03:00
|
|
|
return NS_OK;
|
2001-04-01 05:01:33 +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
|
|
|
return nsAreaFrame::QueryInterface(aIID, aInstancePtr);
|
|
|
|
}
|
|
|
|
|
2001-08-17 07:13:07 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2001-05-18 03:52:32 +04:00
|
|
|
NS_IMETHODIMP nsComboboxControlFrame::GetAccessible(nsIAccessible** aAccessible)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAccessibilityService> accService = do_GetService("@mozilla.org/accessibilityService;1");
|
|
|
|
|
|
|
|
if (accService) {
|
|
|
|
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(mContent);
|
2007-03-31 01:11:41 +04:00
|
|
|
nsCOMPtr<nsIWeakReference> weakShell(do_GetWeakReference(PresContext()->PresShell()));
|
2005-12-02 15:02:44 +03:00
|
|
|
return accService->CreateHTMLComboboxAccessible(node, weakShell, aAccessible);
|
2001-05-18 03:52:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2001-08-17 07:13:07 +04:00
|
|
|
#endif
|
2001-05-18 03:52:32 +04:00
|
|
|
|
1999-01-18 18:14:00 +03:00
|
|
|
void
|
|
|
|
nsComboboxControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
|
|
|
|
{
|
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();
|
2004-07-23 12:25:44 +04:00
|
|
|
mFocused = this;
|
2001-01-04 15:22:29 +03:00
|
|
|
} else {
|
|
|
|
mFocused = nsnull;
|
|
|
|
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
|
2008-09-18 13:47:21 +04:00
|
|
|
Invalidate(nsRect(0,0,mRect.width,mRect.height));
|
2001-06-14 06:08:40 +04:00
|
|
|
|
|
|
|
// Make sure the content area gets updated for where the dropdown was
|
|
|
|
// This is only needed for embedding, the focus may go to
|
|
|
|
// the chrome that is not part of the Gecko system (Bug 83493)
|
2004-03-10 06:09:05 +03:00
|
|
|
// XXX this is rather inefficient
|
2007-03-31 01:11:41 +04:00
|
|
|
nsIViewManager* vm = PresContext()->GetViewManager();
|
2003-07-04 16:50:32 +04:00
|
|
|
if (vm) {
|
|
|
|
vm->UpdateAllViews(NS_VMREFRESH_NO_SYNC);
|
2001-06-14 06:08:40 +04:00
|
|
|
}
|
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
|
|
|
|
nsComboboxControlFrame::ShowPopup(PRBool aShowPopup)
|
|
|
|
{
|
2003-07-04 16:50:32 +04:00
|
|
|
nsIView* view = mDropdownFrame->GetView();
|
|
|
|
nsIViewManager* 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;
|
2005-04-29 03:48:28 +04:00
|
|
|
nsMouseEvent event(PR_TRUE, aShowPopup ?
|
|
|
|
NS_XUL_POPUP_SHOWING : NS_XUL_POPUP_HIDING, nsnull,
|
|
|
|
nsMouseEvent::eReal);
|
2001-04-01 05:01:33 +04:00
|
|
|
|
2007-03-31 01:11:41 +04:00
|
|
|
nsCOMPtr<nsIPresShell> shell = PresContext()->GetPresShell();
|
2003-12-21 08:36:36 +03:00
|
|
|
if (shell)
|
|
|
|
shell->HandleDOMEventWithTarget(mContent, &event, &status);
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
2007-05-17 15:12:30 +04:00
|
|
|
PRBool
|
2004-08-01 03:15:21 +04:00
|
|
|
nsComboboxControlFrame::ShowList(nsPresContext* aPresContext, PRBool 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
|
|
|
{
|
2007-05-17 15:12:30 +04:00
|
|
|
nsCOMPtr<nsIPresShell> shell = PresContext()->GetPresShell();
|
1999-09-22 01:20:50 +04:00
|
|
|
|
2007-05-17 15:12:30 +04:00
|
|
|
nsWeakFrame weakFrame(this);
|
|
|
|
ShowPopup(aShowList); // might destroy us
|
|
|
|
if (!weakFrame.IsAlive()) {
|
|
|
|
return PR_FALSE;
|
1999-09-22 01:20:50 +04:00
|
|
|
}
|
|
|
|
|
2007-05-17 15:12:30 +04:00
|
|
|
mDroppedDown = aShowList;
|
|
|
|
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();
|
2006-03-01 04:00:29 +03:00
|
|
|
mListControlFrame->CaptureMouseEvents(PR_TRUE);
|
2007-05-17 15:12:31 +04:00
|
|
|
}
|
2000-02-12 01:26:36 +03:00
|
|
|
|
2007-08-22 06:57:06 +04:00
|
|
|
// XXXbz so why do we need to flush here, exactly?
|
|
|
|
shell->GetDocument()->FlushPendingNotifications(Flush_Layout);
|
2007-05-17 15:12:30 +04:00
|
|
|
if (!weakFrame.IsAlive()) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
2007-03-23 02:01:14 +03:00
|
|
|
|
2007-05-17 15:12:30 +04:00
|
|
|
nsIFrame* listFrame;
|
|
|
|
CallQueryInterface(mListControlFrame, &listFrame);
|
|
|
|
if (listFrame) {
|
|
|
|
nsIView* view = listFrame->GetView();
|
|
|
|
NS_ASSERTION(view, "nsComboboxControlFrame view is null");
|
|
|
|
if (view) {
|
|
|
|
nsIWidget* widget = view->GetWidget();
|
|
|
|
if (widget)
|
|
|
|
widget->CaptureRollupEvents(this, mDroppedDown, mDroppedDown);
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
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
|
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
|
|
|
nsComboboxControlFrame::ReflowDropdown(nsPresContext* aPresContext,
|
|
|
|
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)) {
|
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 NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
nsSize availSize(aReflowState.availableWidth, NS_UNCONSTRAINEDSIZE);
|
|
|
|
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() +
|
2007-01-11 20:59:41 +03:00
|
|
|
aReflowState.mComputedBorderPadding.LeftRight() -
|
|
|
|
kidReflowState.mComputedBorderPadding.LeftRight();
|
2007-01-26 03:05:12 +03:00
|
|
|
kidReflowState.SetComputedWidth(PR_MAX(kidReflowState.ComputedWidth(),
|
|
|
|
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) {
|
2003-07-04 16:50:32 +04:00
|
|
|
nsIView* view = mDropdownFrame->GetView();
|
|
|
|
nsIViewManager* 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
|
|
|
}
|
|
|
|
|
2005-06-22 05:38:49 +04:00
|
|
|
// Allow the child to move/size/change-visibility its view if it's currently
|
|
|
|
// dropped down
|
2008-09-04 01:35:52 +04:00
|
|
|
PRInt32 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();
|
|
|
|
nsHTMLReflowMetrics desiredSize;
|
|
|
|
nsReflowStatus ignoredStatus;
|
|
|
|
nsresult rv = ReflowChild(mDropdownFrame, aPresContext, desiredSize,
|
|
|
|
kidReflowState, rect.x, rect.y, flags,
|
|
|
|
ignoredStatus);
|
1999-11-19 18:33:29 +03:00
|
|
|
|
|
|
|
// Set the child's width and height to it's desired size
|
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
|
|
|
FinishReflowChild(mDropdownFrame, aPresContext, &kidReflowState,
|
|
|
|
desiredSize, 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
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2007-02-15 13:58:31 +03:00
|
|
|
void
|
|
|
|
nsComboboxControlFrame::AbsolutelyPositionDropDown()
|
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
|
|
|
{
|
|
|
|
// Position the dropdown list. It is positioned below the display frame if there is enough
|
|
|
|
// room on the screen to display the entire list. Otherwise it is placed above the display
|
|
|
|
// frame.
|
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
|
|
|
// Note: As first glance, it appears that you could simply get the absolute bounding box for the
|
2005-11-21 01:05:24 +03:00
|
|
|
// dropdown list by first getting its view, then getting the view's nsIWidget, then asking the nsIWidget
|
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
|
|
|
// for it's 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 use the absolute position of the display frame and use it's location
|
|
|
|
// to determine if the dropdown will go offscreen.
|
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
|
|
|
// Use the height calculated for the area frame so it includes both
|
|
|
|
// the display and button heights.
|
2007-02-15 13:58:31 +03:00
|
|
|
nscoord dropdownYOffset = GetRect().height;
|
2007-03-31 01:11:41 +04:00
|
|
|
nsPresContext* presContext = PresContext();
|
1999-07-29 01:38:08 +04:00
|
|
|
// XXX: Enable this code to debug popping up above the display frame, rather than below it
|
2007-02-15 13:58:31 +03:00
|
|
|
nsSize dropdownSize = mDropdownFrame->GetSize();
|
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
|
|
|
nscoord screenHeightInPixels = 0;
|
2007-02-15 13:58:31 +03:00
|
|
|
if (NS_SUCCEEDED(nsFormControlFrame::GetScreenHeight(presContext, screenHeightInPixels))) {
|
|
|
|
// Get the height of the dropdown list in pixels.
|
|
|
|
nscoord absoluteDropDownHeight = presContext->AppUnitsToDevPixels(dropdownSize.height);
|
|
|
|
// Check to see if the drop-down list will go offscreen
|
|
|
|
if (GetScreenRect().YMost() + absoluteDropDownHeight > screenHeightInPixels) {
|
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
|
|
|
// move the dropdown list up
|
2007-02-15 13:58:31 +03:00
|
|
|
dropdownYOffset = - (dropdownSize.height);
|
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
|
|
|
}
|
2003-04-09 00:50:57 +04:00
|
|
|
}
|
2007-02-15 13:58:31 +03:00
|
|
|
|
|
|
|
nsPoint dropdownPosition;
|
2006-08-13 23:34:58 +04:00
|
|
|
const nsStyleVisibility* vis = GetStyleVisibility();
|
|
|
|
if (vis->mDirection == NS_STYLE_DIRECTION_RTL) {
|
|
|
|
// 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
|
|
|
} else {
|
2007-02-15 13:58:31 +03:00
|
|
|
dropdownPosition.x = 0;
|
2006-08-13 23:34:58 +04:00
|
|
|
}
|
2007-02-15 13:58:31 +03:00
|
|
|
dropdownPosition.y = dropdownYOffset;
|
1999-09-09 17:17:35 +04:00
|
|
|
|
2007-02-15 13:58:31 +03:00
|
|
|
mDropdownFrame->SetPosition(dropdownPosition);
|
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-01-18 18:14:00 +03: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
|
|
|
|
|
|
|
static void printSize(char * aDesc, nscoord aSize)
|
|
|
|
{
|
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
|
2007-12-03 09:41:38 +03:00
|
|
|
nsComboboxControlFrame::GetIntrinsicWidth(nsIRenderingContext* aRenderingContext,
|
|
|
|
nsLayoutUtils::IntrinsicWidthType aType)
|
2007-12-03 09:41:39 +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) {
|
|
|
|
nsIScrollableFrame* scrollable;
|
|
|
|
CallQueryInterface(mListControlFrame, &scrollable);
|
|
|
|
NS_ASSERTION(scrollable, "List must be a scrollable frame");
|
2008-04-10 08:39:41 +04:00
|
|
|
scrollbarWidth =
|
|
|
|
scrollable->GetDesiredScrollbarSizes(presContext, aRenderingContext).LeftRight();
|
2007-05-29 09:31:04 +04:00
|
|
|
}
|
2007-03-23 02:01:14 +03:00
|
|
|
|
2007-12-03 09:41:38 +03:00
|
|
|
nscoord displayWidth = 0;
|
2007-05-29 09:31:04 +04:00
|
|
|
if (NS_LIKELY(mDisplayFrame)) {
|
2007-12-03 09:41:38 +03:00
|
|
|
displayWidth = nsLayoutUtils::IntrinsicForContainer(aRenderingContext,
|
|
|
|
mDisplayFrame,
|
|
|
|
aType);
|
2007-03-23 02:01:14 +03:00
|
|
|
}
|
|
|
|
|
2007-05-29 09:31:04 +04:00
|
|
|
if (mDropdownFrame) {
|
2007-12-03 09:41:38 +03:00
|
|
|
nscoord dropdownContentWidth;
|
|
|
|
if (aType == nsLayoutUtils::MIN_WIDTH) {
|
|
|
|
dropdownContentWidth = mDropdownFrame->GetMinWidth(aRenderingContext);
|
|
|
|
} else {
|
|
|
|
NS_ASSERTION(aType == nsLayoutUtils::PREF_WIDTH, "Unexpected type");
|
|
|
|
dropdownContentWidth = mDropdownFrame->GetPrefWidth(aRenderingContext);
|
|
|
|
}
|
2007-12-18 22:26:35 +03:00
|
|
|
dropdownContentWidth = NSCoordSaturatingSubtract(dropdownContentWidth,
|
|
|
|
scrollbarWidth,
|
|
|
|
nscoord_MAX);
|
2007-12-03 09:41:38 +03:00
|
|
|
|
|
|
|
displayWidth = PR_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
|
|
|
|
nsComboboxControlFrame::GetMinWidth(nsIRenderingContext *aRenderingContext)
|
|
|
|
{
|
|
|
|
nscoord minWidth;
|
|
|
|
DISPLAY_MIN_WIDTH(this, minWidth);
|
|
|
|
minWidth = GetIntrinsicWidth(aRenderingContext, nsLayoutUtils::MIN_WIDTH);
|
|
|
|
return minWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
|
|
|
nsComboboxControlFrame::GetPrefWidth(nsIRenderingContext *aRenderingContext)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
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
|
|
|
NS_IMETHODIMP
|
|
|
|
nsComboboxControlFrame::Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
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!!");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
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.
|
|
|
|
PRInt32 selectedIndex;
|
|
|
|
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);
|
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;
|
|
|
|
const nsStyleDisplay *disp = GetStyleDisplay();
|
|
|
|
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 {
|
|
|
|
nsIScrollableFrame* scrollable;
|
|
|
|
CallQueryInterface(mListControlFrame, &scrollable);
|
|
|
|
NS_ASSERTION(scrollable, "List must be a scrollable frame");
|
2008-04-10 08:39:41 +04:00
|
|
|
buttonWidth =
|
|
|
|
scrollable->GetDesiredScrollbarSizes(PresContext(),
|
|
|
|
aReflowState.rendContext).LeftRight();
|
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
|
|
|
|
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
|
|
|
nsresult rv = nsAreaFrame::Reflow(aPresContext, aDesiredSize, aReflowState,
|
|
|
|
aStatus);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2000-08-03 18:13:40 +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
|
|
|
// Now set the correct width and height on our button. The width we need to
|
|
|
|
// set always, the height only if we had an auto height.
|
|
|
|
nsRect buttonRect = mButtonFrame->GetRect();
|
|
|
|
// If we have a non-intrinsic computed height, our kids should have sized
|
|
|
|
// themselves properly on their own.
|
2007-08-02 22:08:05 +04:00
|
|
|
if (aReflowState.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
|
|
|
// The display frame is going to be the right height and width at this
|
|
|
|
// point. Use its height as the button height.
|
|
|
|
nsRect displayRect = mDisplayFrame->GetRect();
|
|
|
|
buttonRect.height = displayRect.height;
|
|
|
|
buttonRect.y = displayRect.y;
|
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
|
|
|
#ifdef DEBUG
|
|
|
|
else {
|
2007-04-26 05:17:05 +04:00
|
|
|
nscoord buttonHeight = mButtonFrame->GetSize().height;
|
|
|
|
nscoord displayHeight = mDisplayFrame->GetSize().height;
|
|
|
|
|
|
|
|
// The button and display area should be equal heights, unless the computed
|
|
|
|
// height on the combobox is too small to fit their borders and padding.
|
|
|
|
NS_ASSERTION(buttonHeight == displayHeight ||
|
2007-08-02 22:08:05 +04:00
|
|
|
(aReflowState.ComputedHeight() < buttonHeight &&
|
2007-04-26 05:17:05 +04:00
|
|
|
buttonHeight ==
|
|
|
|
mButtonFrame->GetUsedBorderAndPadding().TopBottom()) ||
|
2007-08-02 22:08:05 +04:00
|
|
|
(aReflowState.ComputedHeight() < displayHeight &&
|
2007-04-26 05:17:05 +04:00
|
|
|
displayHeight ==
|
|
|
|
mDisplayFrame->GetUsedBorderAndPadding().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
|
|
|
"Different heights?");
|
2000-01-28 18:24:49 +03:00
|
|
|
}
|
1999-12-22 22:46:28 +03:00
|
|
|
#endif
|
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 (GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL) {
|
|
|
|
// Make sure the right edge of the button frame stays where it is now
|
|
|
|
buttonRect.x -= buttonWidth - buttonRect.width;
|
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;
|
|
|
|
mButtonFrame->SetRect(buttonRect);
|
|
|
|
|
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;
|
|
|
|
}
|
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
|
|
|
|
{
|
2006-12-26 20:47:52 +03: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
|
|
|
}
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef NS_DEBUG
|
1999-01-18 18:14:00 +03:00
|
|
|
NS_IMETHODIMP
|
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
|
1999-08-26 18:54:07 +04:00
|
|
|
nsComboboxControlFrame::ShowDropDown(PRBool aDoDropDown)
|
2006-04-26 06:01:07 +04:00
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
if (mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::disabled)) {
|
2006-02-18 04:52:03 +03:00
|
|
|
return;
|
1999-08-26 18:54:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!mDroppedDown && aDoDropDown) {
|
1999-08-31 17:22:40 +04:00
|
|
|
if (mListControlFrame) {
|
2004-12-27 18:05:18 +03:00
|
|
|
mListControlFrame->SyncViewWithFrame();
|
1999-08-31 17:22:40 +04:00
|
|
|
}
|
2007-05-17 15:12:30 +04:00
|
|
|
ShowList(PresContext(), aDoDropDown); // might destroy us
|
1999-08-26 18:54:07 +04:00
|
|
|
} else if (mDroppedDown && !aDoDropDown) {
|
2007-05-17 15:12:30 +04:00
|
|
|
ShowList(PresContext(), 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;
|
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-02-18 04:52:03 +03:00
|
|
|
CallQueryInterface(mDropdownFrame, &mListControlFrame);
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
2006-02-27 07:13:51 +03:00
|
|
|
nsIFrame*
|
|
|
|
nsComboboxControlFrame::GetDropDown()
|
|
|
|
{
|
|
|
|
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
|
|
|
{
|
2006-03-01 04:00:29 +03:00
|
|
|
return RedisplayText(mListControlFrame->GetSelectedIndex());
|
2002-01-26 02:35:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsComboboxControlFrame::RedisplayText(PRInt32 aIndex)
|
|
|
|
{
|
|
|
|
// 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) {
|
2005-06-21 04:00:14 +04:00
|
|
|
// Don't call ActuallyDisplayText(PR_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
|
|
|
|
2006-05-10 21:30:15 +04:00
|
|
|
nsRefPtr<RedisplayTextEvent> event = new RedisplayTextEvent(this);
|
|
|
|
rv = NS_DispatchToCurrentThread(event);
|
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
mRedisplayTextEvent = event;
|
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.
|
2007-03-31 01:11:41 +04:00
|
|
|
PresContext()->Document()->
|
2005-04-12 19:31:03 +04:00
|
|
|
FlushPendingNotifications(Flush_ContentAndNotify);
|
|
|
|
|
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");
|
|
|
|
mInRedisplayText = PR_TRUE;
|
2006-05-10 21:30:15 +04:00
|
|
|
mRedisplayTextEvent.Forget();
|
2005-03-21 04:58:17 +03:00
|
|
|
|
2005-06-21 04:00:14 +04:00
|
|
|
ActuallyDisplayText(PR_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
|
|
|
|
|
|
|
mInRedisplayText = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2005-06-21 04:00:14 +04:00
|
|
|
void
|
|
|
|
nsComboboxControlFrame::ActuallyDisplayText(PRBool 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
|
2004-05-13 05:12:10 +04:00
|
|
|
static const PRUnichar space = 0xA0;
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-18 04:52:03 +03:00
|
|
|
PRInt32
|
|
|
|
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
|
2002-03-31 14:14:01 +04:00
|
|
|
nsComboboxControlFrame::DoneAddingChildren(PRBool aIsDone)
|
1999-11-12 01:13:33 +03:00
|
|
|
{
|
|
|
|
nsISelectControlFrame* listFrame = nsnull;
|
2000-02-15 18:04:38 +03:00
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
2000-09-10 02:15:57 +04:00
|
|
|
if (mDropdownFrame != nsnull) {
|
2002-07-18 04:58:31 +04:00
|
|
|
rv = CallQueryInterface(mDropdownFrame, &listFrame);
|
|
|
|
if (listFrame) {
|
2002-03-31 14:14:01 +04:00
|
|
|
rv = listFrame->DoneAddingChildren(aIsDone);
|
2000-02-15 18:04:38 +03:00
|
|
|
}
|
1999-11-12 01:13:33 +03:00
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
1999-08-26 18:54:07 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsComboboxControlFrame::AddOption(nsPresContext* aPresContext, PRInt32 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);
|
2002-07-18 04:58:31 +04:00
|
|
|
return lcf->AddOption(aPresContext, aIndex);
|
1999-08-26 18:54:07 +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
|
|
|
|
1999-08-26 18:54:07 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsComboboxControlFrame::RemoveOption(nsPresContext* aPresContext, PRInt32 aIndex)
|
1999-08-26 18:54:07 +04:00
|
|
|
{
|
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
|
|
|
|
2007-07-08 11:08:04 +04:00
|
|
|
nsListControlFrame* lcf = static_cast<nsListControlFrame*>(mDropdownFrame);
|
2002-07-18 04:58:31 +04:00
|
|
|
return lcf->RemoveOption(aPresContext, aIndex);
|
1999-08-27 07:58:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-11-02 10:40:01 +03:00
|
|
|
nsComboboxControlFrame::GetOptionSelected(PRInt32 aIndex, PRBool* aValue)
|
1999-08-27 07:58:13 +04:00
|
|
|
{
|
|
|
|
nsISelectControlFrame* listFrame = nsnull;
|
2005-02-05 01:56:13 +03:00
|
|
|
NS_ASSERTION(mDropdownFrame, "No dropdown frame!");
|
|
|
|
|
|
|
|
CallQueryInterface(mDropdownFrame, &listFrame);
|
|
|
|
NS_ASSERTION(listFrame, "No list frame!");
|
|
|
|
|
|
|
|
return listFrame->GetOptionSelected(aIndex, aValue);
|
1999-09-15 09:31:31 +04:00
|
|
|
}
|
|
|
|
|
2005-02-05 01:56:13 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsComboboxControlFrame::OnSetSelectedIndex(PRInt32 aOldIndex, PRInt32 aNewIndex)
|
|
|
|
{
|
2007-08-22 07:25:42 +04:00
|
|
|
RedisplayText(aNewIndex);
|
|
|
|
|
2005-02-05 01:56:13 +03:00
|
|
|
nsISelectControlFrame* listFrame = nsnull;
|
|
|
|
NS_ASSERTION(mDropdownFrame, "No dropdown frame!");
|
|
|
|
|
|
|
|
CallQueryInterface(mDropdownFrame, &listFrame);
|
|
|
|
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
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsComboboxControlFrame::HandleEvent(nsPresContext* aPresContext,
|
1999-07-29 01:38:08 +04:00
|
|
|
nsGUIEvent* aEvent,
|
1999-11-24 09:03:41 +03:00
|
|
|
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;
|
|
|
|
}
|
2006-12-26 20:47:52 +03:00
|
|
|
if (mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::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.
|
2003-05-15 07:42:21 +04:00
|
|
|
const nsStyleUserInterface* uiStyle = GetStyleUserInterface();
|
2000-09-07 08:39:02 +04:00
|
|
|
if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE || uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
|
|
|
|
return nsAreaFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
|
|
|
|
|
|
|
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
|
|
|
{
|
1999-04-13 02:14:31 +04:00
|
|
|
nsIFormControlFrame* fcFrame = nsnull;
|
2002-07-18 04:58:31 +04:00
|
|
|
nsresult result = CallQueryInterface(mDropdownFrame, &fcFrame);
|
2005-12-13 02:53:06 +03:00
|
|
|
if (NS_FAILED(result)) {
|
|
|
|
return result;
|
1999-04-13 02:14:31 +04:00
|
|
|
}
|
2005-12-13 02:53:06 +03:00
|
|
|
if (fcFrame) {
|
|
|
|
return fcFrame->SetFormProperty(aName, aValue);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
1999-01-26 01:16:27 +03:00
|
|
|
}
|
|
|
|
|
2005-12-13 02:53:06 +03:00
|
|
|
nsresult
|
|
|
|
nsComboboxControlFrame::GetFormProperty(nsIAtom* aName, nsAString& aValue) const
|
1999-03-06 22:43:13 +03:00
|
|
|
{
|
1999-04-13 02:14:31 +04:00
|
|
|
nsIFormControlFrame* fcFrame = nsnull;
|
2002-07-18 04:58:31 +04:00
|
|
|
nsresult result = CallQueryInterface(mDropdownFrame, &fcFrame);
|
2005-12-13 02:53:06 +03:00
|
|
|
if(NS_FAILED(result)) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
if (fcFrame) {
|
|
|
|
return fcFrame->GetFormProperty(aName, aValue);
|
1999-04-13 02:14:31 +04:00
|
|
|
}
|
2005-12-13 02:53:06 +03:00
|
|
|
return NS_OK;
|
1999-03-06 22:43:13 +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
|
|
|
|
nsComboboxControlFrame::CreateAnonymousContent(nsTArray<nsIContent*>& 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
|
|
|
|
// content because it's frame is initialized specifically for the drop-down case and it is placed
|
|
|
|
// a special list referenced through NS_COMBO_FRAME_POPUP_LIST_INDEX to keep separate from the
|
|
|
|
// layout of the display and button.
|
|
|
|
//
|
|
|
|
// 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();
|
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
NS_NewTextNode(getter_AddRefs(mDisplayContent), nimgr);
|
|
|
|
if (!mDisplayContent)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
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);
|
|
|
|
}
|
|
|
|
ActuallyDisplayText(PR_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
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
nsCOMPtr<nsINodeInfo> nodeInfo;
|
2008-09-13 02:32:18 +04:00
|
|
|
nodeInfo = nimgr->GetNodeInfo(nsGkAtoms::input, nsnull, kNameSpaceID_None);
|
2000-03-07 18:54:31 +03:00
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
// create button which drops the list down
|
2008-04-18 02:30:51 +04:00
|
|
|
NS_NewHTMLElement(getter_AddRefs(mButtonContent), nodeInfo, PR_FALSE);
|
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);
|
|
|
|
if (!mButtonListener)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
mButtonContent->AddEventListenerByIID(mButtonListener,
|
|
|
|
NS_GET_IID(nsIDOMMouseListener));
|
2004-06-25 16:26:02 +04:00
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
mButtonContent->SetAttr(kNameSpaceID_None, nsGkAtoms::type,
|
|
|
|
NS_LITERAL_STRING("button"), PR_FALSE);
|
|
|
|
// Set tabindex="-1" so that the button is not tabbable
|
|
|
|
mButtonContent->SetAttr(kNameSpaceID_None, nsGkAtoms::tabindex,
|
|
|
|
NS_LITERAL_STRING("-1"), PR_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;
|
|
|
|
}
|
|
|
|
|
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:
|
|
|
|
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.
|
|
|
|
virtual nsIAtom* GetType() const;
|
|
|
|
|
2007-02-24 21:33:33 +03:00
|
|
|
virtual PRBool IsFrameOfType(PRUint32 aFlags) const
|
|
|
|
{
|
|
|
|
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
|
|
|
|
|
|
|
NS_IMETHOD Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
|
|
|
|
2007-05-22 23:42:01 +04:00
|
|
|
NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists);
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2007-02-28 06:04:38 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsComboboxDisplayFrame::GetType() const
|
|
|
|
{
|
|
|
|
return nsGkAtoms::comboboxDisplayFrame;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
NS_IMETHODIMP
|
|
|
|
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 -
|
|
|
|
state.mComputedBorderPadding.LeftRight();
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2007-05-22 23:42:01 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsComboboxDisplayFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
|
|
|
nsDisplayListCollection set;
|
|
|
|
nsresult rv = nsBlockFrame::BuildDisplayList(aBuilder, aDirtyRect, set);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
// remove background items if parent frame is themed
|
|
|
|
if (mComboBox->IsThemed()) {
|
|
|
|
set.BorderBackground()->DeleteAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
set.MoveTo(aLists);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
nsIFrame*
|
|
|
|
nsComboboxControlFrame::CreateFrameFor(nsIContent* aContent)
|
2000-04-19 17:55:17 +04:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aContent, "null ptr");
|
|
|
|
|
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
|
2007-02-18 20:34:09 +03:00
|
|
|
return nsnull;
|
2000-04-19 17:55:17 +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->
|
|
|
|
ResolvePseudoStyleFor(mContent,
|
|
|
|
nsCSSAnonBoxes::mozDisplayComboboxControlFrame,
|
|
|
|
mStyleContext);
|
|
|
|
if (NS_UNLIKELY(!styleContext)) {
|
2007-02-18 20:34:09 +03:00
|
|
|
return nsnull;
|
2005-12-11 23:45:58 +03:00
|
|
|
}
|
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);
|
2005-12-11 23:45:58 +03:00
|
|
|
if (NS_UNLIKELY(!textStyleContext)) {
|
2007-02-18 20:34:09 +03:00
|
|
|
return nsnull;
|
2005-12-11 23:45:58 +03:00
|
|
|
}
|
2000-04-19 17:55:17 +04:00
|
|
|
|
2005-12-11 23:45:58 +03:00
|
|
|
// Start by by creating our anonymous block frame
|
2007-02-19 02:53:25 +03:00
|
|
|
mDisplayFrame = new (shell) nsComboboxDisplayFrame(styleContext, this);
|
2005-12-11 23:45:58 +03:00
|
|
|
if (NS_UNLIKELY(!mDisplayFrame)) {
|
2007-02-18 20:34:09 +03:00
|
|
|
return nsnull;
|
2005-12-11 23:45:58 +03:00
|
|
|
}
|
2000-04-19 17:55:17 +04:00
|
|
|
|
2006-03-27 01:30:36 +04:00
|
|
|
nsresult rv = mDisplayFrame->Init(mContent, this, nsnull);
|
2005-12-11 23:45:58 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
2006-04-10 04:16:29 +04:00
|
|
|
mDisplayFrame->Destroy();
|
2005-12-11 23:45:58 +03:00
|
|
|
mDisplayFrame = nsnull;
|
2007-02-18 20:34:09 +03:00
|
|
|
return nsnull;
|
2005-12-11 23:45:58 +03:00
|
|
|
}
|
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
|
2006-03-27 01:30:36 +04:00
|
|
|
mTextFrame = NS_NewTextFrame(shell, textStyleContext);
|
2005-12-11 23:45:58 +03:00
|
|
|
if (NS_UNLIKELY(!mTextFrame)) {
|
2007-02-18 20:34:09 +03:00
|
|
|
return nsnull;
|
2005-12-11 23:45:58 +03:00
|
|
|
}
|
2000-04-19 17:55:17 +04:00
|
|
|
|
2005-12-11 23:45:58 +03:00
|
|
|
// initialize the text frame
|
2006-03-27 01:30:36 +04:00
|
|
|
rv = mTextFrame->Init(aContent, mDisplayFrame, nsnull);
|
2005-12-11 23:45:58 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
2006-04-10 04:16:29 +04:00
|
|
|
mDisplayFrame->Destroy();
|
2005-12-11 23:45:58 +03:00
|
|
|
mDisplayFrame = nsnull;
|
2006-04-10 04:16:29 +04:00
|
|
|
mTextFrame->Destroy();
|
2005-12-11 23:45:58 +03:00
|
|
|
mTextFrame = nsnull;
|
2007-02-18 20:34:09 +03:00
|
|
|
return nsnull;
|
2000-04-19 17:55:17 +04:00
|
|
|
}
|
|
|
|
|
2006-04-10 04:16:29 +04:00
|
|
|
mDisplayFrame->SetInitialChildList(nsnull, mTextFrame);
|
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
|
|
|
|
nsComboboxControlFrame::Destroy()
|
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
|
|
|
|
2007-07-08 11:08:04 +04:00
|
|
|
nsFormControlFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), PR_FALSE);
|
2000-08-03 18:13:40 +04:00
|
|
|
|
2000-03-28 18:29:15 +04:00
|
|
|
if (mDroppedDown) {
|
|
|
|
// Get parent view
|
|
|
|
nsIFrame * listFrame;
|
2001-01-04 23:44:42 +03:00
|
|
|
if (NS_OK == mListControlFrame->QueryInterface(NS_GET_IID(nsIFrame), (void **)&listFrame)) {
|
2003-07-04 16:50:32 +04:00
|
|
|
nsIView* view = listFrame->GetView();
|
|
|
|
NS_ASSERTION(view, "nsComboboxControlFrame view is null");
|
2000-03-28 18:29:15 +04:00
|
|
|
if (view) {
|
2007-02-18 20:34:09 +03:00
|
|
|
nsIWidget* widget = view->GetWidget();
|
2000-03-28 18:29:15 +04:00
|
|
|
if (widget)
|
2007-05-17 15:12:30 +04:00
|
|
|
widget->CaptureRollupEvents(this, PR_FALSE, PR_TRUE);
|
2000-03-28 18:29:15 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-21 00:28:02 +04:00
|
|
|
// Cleanup frames in popup child list
|
2006-04-10 04:16:29 +04:00
|
|
|
mPopupFrames.DestroyFrames();
|
2007-02-18 20:34:09 +03:00
|
|
|
nsContentUtils::DestroyAnonymousContent(&mDisplayContent);
|
|
|
|
nsContentUtils::DestroyAnonymousContent(&mButtonContent);
|
2006-04-10 04:16:29 +04:00
|
|
|
nsAreaFrame::Destroy();
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-01-09 17:20:53 +03:00
|
|
|
nsIFrame*
|
|
|
|
nsComboboxControlFrame::GetFirstChild(nsIAtom* aListName) 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
|
|
|
{
|
2007-08-10 16:42:06 +04:00
|
|
|
if (nsGkAtoms::selectPopupList == aListName) {
|
2004-01-09 17:20:53 +03:00
|
|
|
return mPopupFrames.FirstChild();
|
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
|
|
|
}
|
2004-01-09 17:20:53 +03:00
|
|
|
return nsAreaFrame::GetFirstChild(aListName);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2006-04-10 04:16:29 +04:00
|
|
|
nsComboboxControlFrame::SetInitialChildList(nsIAtom* aListName,
|
|
|
|
nsIFrame* 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;
|
2007-08-10 16:42:06 +04:00
|
|
|
if (nsGkAtoms::selectPopupList == aListName) {
|
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 {
|
2006-04-10 04:16:29 +04:00
|
|
|
rv = nsAreaFrame::SetInitialChildList(aListName, aChildList);
|
2000-04-19 17:55:17 +04:00
|
|
|
|
2003-07-04 16:50:32 +04:00
|
|
|
for (nsIFrame * child = aChildList; child;
|
|
|
|
child = child->GetNextSibling()) {
|
2005-12-13 02:53:06 +03:00
|
|
|
nsCOMPtr<nsIFormControl> formControl = do_QueryInterface(child->GetContent());
|
|
|
|
if (formControl && formControl->GetType() == NS_FORM_INPUT_BUTTON) {
|
2005-12-08 22:01:20 +03:00
|
|
|
mButtonFrame = child;
|
|
|
|
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");
|
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;
|
|
|
|
}
|
|
|
|
|
2007-07-26 08:03:29 +04:00
|
|
|
#define NS_COMBO_FRAME_POPUP_LIST_INDEX (NS_BLOCK_LIST_COUNT)
|
|
|
|
|
2004-01-09 17:20:53 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsComboboxControlFrame::GetAdditionalChildListName(PRInt32 aIndex) 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
|
|
|
{
|
2003-03-24 07:15:34 +03:00
|
|
|
// Maintain a separate child list for the dropdown list (i.e. popup listbox)
|
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
|
|
|
// This is necessary because we don't want the listbox to be included in the layout
|
|
|
|
// of the combox's children because it would take up space, when it is suppose to
|
|
|
|
// be floating above the display.
|
2007-07-26 08:03:29 +04:00
|
|
|
if (aIndex < NS_BLOCK_LIST_COUNT) {
|
2004-01-09 17:20:53 +03:00
|
|
|
return nsAreaFrame::GetAdditionalChildListName(aIndex);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_COMBO_FRAME_POPUP_LIST_INDEX == aIndex) {
|
2007-08-10 16:42:06 +04:00
|
|
|
return nsGkAtoms::selectPopupList;
|
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
|
|
|
}
|
2004-01-09 17:20:53 +03:00
|
|
|
return nsnull;
|
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-09-22 01:20:50 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
//nsIRollupListener
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
2007-12-03 19:33:42 +03:00
|
|
|
nsComboboxControlFrame::Rollup(nsIContent** aLastRolledUp)
|
1999-09-22 01:20:50 +04:00
|
|
|
{
|
2007-12-03 19:33:42 +03:00
|
|
|
if (aLastRolledUp)
|
|
|
|
*aLastRolledUp = nsnull;
|
|
|
|
|
1999-09-22 01:20:50 +04:00
|
|
|
if (mDroppedDown) {
|
2007-05-17 15:12:30 +04:00
|
|
|
nsWeakFrame weakFrame(this);
|
|
|
|
mListControlFrame->AboutToRollup(); // might destroy us
|
|
|
|
if (!weakFrame.IsAlive())
|
|
|
|
return NS_OK;
|
|
|
|
ShowDropDown(PR_FALSE); // might destroy us
|
|
|
|
if (!weakFrame.IsAlive())
|
|
|
|
return NS_OK;
|
2006-03-01 04:00:29 +03:00
|
|
|
mListControlFrame->CaptureMouseEvents(PR_FALSE);
|
1999-09-22 01:20:50 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-02-18 04:52:03 +03:00
|
|
|
void
|
|
|
|
nsComboboxControlFrame::RollupFromList()
|
2002-01-26 02:35:44 +03:00
|
|
|
{
|
2007-05-17 15:12:30 +04:00
|
|
|
if (ShowList(PresContext(), PR_FALSE))
|
|
|
|
mListControlFrame->CaptureMouseEvents(PR_FALSE);
|
2002-01-26 02:35:44 +03:00
|
|
|
}
|
|
|
|
|
2006-02-18 04:52:03 +03:00
|
|
|
PRInt32
|
2004-07-23 12:25:44 +04:00
|
|
|
nsComboboxControlFrame::UpdateRecentIndex(PRInt32 aIndex)
|
2002-02-08 21:35:48 +03:00
|
|
|
{
|
2004-07-23 12:25:44 +04:00
|
|
|
PRInt32 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:
|
2006-01-29 21:48:58 +03:00
|
|
|
nsDisplayComboboxFocus(nsComboboxControlFrame* aFrame)
|
2006-03-14 23:43:18 +03:00
|
|
|
: nsDisplayItem(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
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx,
|
|
|
|
const nsRect& aDirtyRect);
|
|
|
|
NS_DISPLAY_DECL_NAME("ComboboxFocus")
|
|
|
|
};
|
|
|
|
|
|
|
|
void nsDisplayComboboxFocus::Paint(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsIRenderingContext* aCtx, const nsRect& aDirtyRect)
|
|
|
|
{
|
2007-07-08 11:08:04 +04:00
|
|
|
static_cast<nsComboboxControlFrame*>(mFrame)
|
2006-03-15 00:02:42 +03:00
|
|
|
->PaintFocus(*aCtx, aBuilder->ToReferenceFrame(mFrame));
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
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
|
|
|
|
nsresult rv = DisplayBorderBackgroundOutline(aBuilder, aLists);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
} 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.
|
|
|
|
nsresult rv = nsAreaFrame::BuildDisplayList(aBuilder, aDirtyRect, aLists);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2000-03-07 18:54:31 +03:00
|
|
|
}
|
2006-01-26 05:29:17 +03:00
|
|
|
|
2007-03-31 01:11:41 +04:00
|
|
|
nsPresContext *presContext = PresContext();
|
2007-02-16 04:53:43 +03:00
|
|
|
const nsStyleDisplay *disp = GetStyleDisplay();
|
|
|
|
if ((!IsThemed(disp) ||
|
|
|
|
!presContext->GetTheme()->ThemeDrawsFocusForWidget(presContext, this, disp->mAppearance)) &&
|
|
|
|
mDisplayFrame && IsVisibleForPainting(aBuilder)) {
|
2006-01-26 05:29:17 +03:00
|
|
|
nsresult rv = aLists.Content()->AppendNewToTop(new (aBuilder)
|
2007-02-16 04:53:43 +03:00
|
|
|
nsDisplayComboboxFocus(this));
|
2006-01-26 05:29:17 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
return DisplaySelectionOverlay(aBuilder, aLists);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsComboboxControlFrame::PaintFocus(nsIRenderingContext& aRenderingContext,
|
2008-04-29 07:55:07 +04:00
|
|
|
nsPoint aPt)
|
|
|
|
{
|
|
|
|
/* Do we need to do anything? */
|
|
|
|
if (mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::disabled) ||
|
|
|
|
mFocused != this)
|
|
|
|
return;
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
aRenderingContext.PushState();
|
|
|
|
nsRect clipRect = mDisplayFrame->GetRect() + aPt;
|
|
|
|
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect);
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
aRenderingContext.SetColor(GetStyleColor()->mColor);
|
|
|
|
|
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;
|
|
|
|
aRenderingContext.DrawLine(clipRect.x, clipRect.y,
|
|
|
|
clipRect.x+clipRect.width, clipRect.y);
|
|
|
|
aRenderingContext.DrawLine(clipRect.x+clipRect.width, clipRect.y,
|
|
|
|
clipRect.x+clipRect.width, clipRect.y+clipRect.height);
|
|
|
|
aRenderingContext.DrawLine(clipRect.x+clipRect.width, clipRect.y+clipRect.height,
|
|
|
|
clipRect.x, clipRect.y+clipRect.height);
|
|
|
|
aRenderingContext.DrawLine(clipRect.x, clipRect.y+clipRect.height,
|
|
|
|
clipRect.x, clipRect.y);
|
|
|
|
aRenderingContext.DrawLine(clipRect.x, clipRect.y+clipRect.height,
|
|
|
|
clipRect.x, clipRect.y);
|
|
|
|
|
|
|
|
aRenderingContext.PopState();
|
2000-03-07 18:54:31 +03:00
|
|
|
}
|
|
|
|
|
2000-12-09 10:28:19 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
//nsIScrollableViewProvider
|
|
|
|
//----------------------------------------------------------------------
|
2004-09-06 06:44:43 +04:00
|
|
|
nsIScrollableView* nsComboboxControlFrame::GetScrollableView()
|
2000-12-09 10:28:19 +03:00
|
|
|
{
|
2003-04-09 00:50:57 +04:00
|
|
|
if (!mDropdownFrame)
|
2004-09-06 06:44:43 +04:00
|
|
|
return nsnull;
|
2003-04-09 00:50:57 +04:00
|
|
|
|
|
|
|
nsIScrollableFrame* scrollable = nsnull;
|
|
|
|
nsresult rv = CallQueryInterface(mDropdownFrame, &scrollable);
|
|
|
|
if (NS_FAILED(rv))
|
2004-09-06 06:44:43 +04:00
|
|
|
return nsnull;
|
2003-04-09 00:50:57 +04:00
|
|
|
|
2004-09-06 06:44:43 +04:00
|
|
|
return scrollable->GetScrollableView();
|
2000-12-09 10:28:19 +03:00
|
|
|
}
|
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
|
2004-08-01 03:15:21 +04:00
|
|
|
nsComboboxControlFrame::OnOptionSelected(nsPresContext* aPresContext,
|
2001-11-02 10:40:01 +03:00
|
|
|
PRInt32 aIndex,
|
|
|
|
PRBool aSelected)
|
|
|
|
{
|
2003-03-14 09:18:20 +03:00
|
|
|
if (mDroppedDown) {
|
|
|
|
nsCOMPtr<nsISelectControlFrame> selectFrame
|
|
|
|
= do_QueryInterface(mListControlFrame);
|
|
|
|
if (selectFrame) {
|
|
|
|
selectFrame->OnOptionSelected(aPresContext, aIndex, aSelected);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (aSelected) {
|
2002-01-26 02:35:44 +03:00
|
|
|
RedisplayText(aIndex);
|
|
|
|
} else {
|
2003-03-14 09:18:20 +03:00
|
|
|
RedisplaySelectedText();
|
2005-05-05 19:05:34 +04:00
|
|
|
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
|
|
|
|
nsCOMPtr<nsIDOMEvent> event;
|
2007-03-31 01:11:41 +04:00
|
|
|
nsPresContext* presContext = PresContext();
|
2006-03-07 20:08:51 +03:00
|
|
|
if (NS_SUCCEEDED(nsEventDispatcher::CreateEvent(presContext, nsnull,
|
|
|
|
NS_LITERAL_STRING("Events"),
|
|
|
|
getter_AddRefs(event)))) {
|
2005-02-08 02:11:30 +03:00
|
|
|
event->InitEvent(NS_LITERAL_STRING("ValueChange"), PR_TRUE, PR_TRUE);
|
2005-04-29 03:48:28 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(event));
|
|
|
|
privateEvent->SetTrusted(PR_TRUE);
|
2006-03-07 20:08:51 +03:00
|
|
|
nsEventDispatcher::DispatchDOMEvent(mContent, nsnull, event, nsnull,
|
|
|
|
nsnull);
|
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
|
2005-12-07 02:56:17 +03:00
|
|
|
nsComboboxControlFrame::SaveState(SpecialStateID aStateID,
|
2005-01-28 01:52:53 +03:00
|
|
|
nsPresState** aState)
|
2001-11-02 10:40:01 +03:00
|
|
|
{
|
2005-12-07 02:56:17 +03:00
|
|
|
if (!mListControlFrame)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsIStatefulFrame* stateful;
|
|
|
|
CallQueryInterface(mListControlFrame, &stateful);
|
|
|
|
return stateful->SaveState(aStateID, 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;
|
|
|
|
|
|
|
|
nsIStatefulFrame* stateful;
|
|
|
|
nsresult rv = CallQueryInterface(mListControlFrame, &stateful);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "Must implement nsIStatefulFrame");
|
2005-12-07 02:56:17 +03:00
|
|
|
rv = stateful->RestoreState(aState);
|
2002-01-11 23:10:46 +03:00
|
|
|
return rv;
|
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.
|
|
|
|
//
|
|
|
|
|
|
|
|
/* static */
|
|
|
|
PRBool
|
|
|
|
nsComboboxControlFrame::ToolkitHasNativePopup()
|
|
|
|
{
|
2007-03-30 23:51:51 +04:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
return nsContentUtils::GetBoolPref("ui.use_native_popup_windows");
|
2005-02-16 08:13:16 +03:00
|
|
|
#else
|
|
|
|
return PR_FALSE;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|