2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 14:30:37 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-01-18 15:14:00 +00:00
|
|
|
*
|
2004-04-18 14:30:37 +00: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 15:14:00 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00: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 15:14:00 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-28 20:14:13 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:40:37 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Contributor(s):
|
2000-02-02 22:24:56 +00:00
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
2005-03-21 01:58:17 +00:00
|
|
|
* Mats Palmgren <mats.palmgren@bredband.net>
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 14:30:37 +00: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-28 20:14:13 +00: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 14:30:37 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-28 20:14:13 +00: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 14:30:37 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-02-12 17:45:58 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2001-09-29 08:28:41 +00:00
|
|
|
#include "nsReadableUtils.h"
|
1999-01-18 15:14:00 +00:00
|
|
|
#include "nsComboboxControlFrame.h"
|
2007-05-14 09:11:38 +00:00
|
|
|
#include "nsIDOMEventTarget.h"
|
2004-02-23 21:29:06 +00: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-14 22:00:24 +00:00
|
|
|
#include "nsFormControlFrame.h"
|
2005-12-12 23:53:06 +00:00
|
|
|
#include "nsGfxButtonControlFrame.h"
|
2007-01-30 00:06:41 +00:00
|
|
|
#include "nsGkAtoms.h"
|
2002-11-17 15:37:56 +00:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
1999-01-18 15:14:00 +00:00
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsIFormControl.h"
|
|
|
|
#include "nsINameSpaceManager.h"
|
|
|
|
#include "nsIDOMElement.h"
|
|
|
|
#include "nsIListControlFrame.h"
|
1999-04-12 22:14:31 +00: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 17:42:36 +00:00
|
|
|
#include "nsIDOMNSHTMLOptionCollectn.h"
|
2010-04-21 14:53:42 +00:00
|
|
|
#include "nsPIDOMWindow.h"
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsIView.h"
|
2007-02-12 19:31:59 +00:00
|
|
|
#include "nsIViewManager.h"
|
2006-03-07 17:08:51 +00:00
|
|
|
#include "nsEventDispatcher.h"
|
2005-02-07 23:11:30 +00:00
|
|
|
#include "nsIEventListenerManager.h"
|
1999-09-07 02:16:23 +00:00
|
|
|
#include "nsIDOMNode.h"
|
|
|
|
#include "nsIPrivateDOMEvent.h"
|
1999-09-15 05:31:31 +00:00
|
|
|
#include "nsISelectControlFrame.h"
|
2002-09-03 23:36:13 +00:00
|
|
|
#include "nsXPCOM.h"
|
1999-09-15 05:31:31 +00:00
|
|
|
#include "nsISupportsPrimitives.h"
|
|
|
|
#include "nsIComponentManager.h"
|
2006-03-14 21:02:42 +00:00
|
|
|
#include "nsContentUtils.h"
|
2000-03-07 15:54:31 +00:00
|
|
|
#include "nsTextFragment.h"
|
|
|
|
#include "nsCSSFrameConstructor.h"
|
|
|
|
#include "nsIDocument.h"
|
2000-05-10 13:13:39 +00:00
|
|
|
#include "nsINodeInfo.h"
|
2000-04-19 13:55:17 +00:00
|
|
|
#include "nsIScrollableFrame.h"
|
2001-02-23 01:45:45 +00:00
|
|
|
#include "nsListControlFrame.h"
|
2001-02-19 21:50:04 +00:00
|
|
|
#include "nsContentCID.h"
|
2001-08-17 03:13:07 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2011-01-28 04:38:14 +00:00
|
|
|
#include "nsAccessibilityService.h"
|
2001-08-17 03:13:07 +00:00
|
|
|
#endif
|
2001-04-01 01:01:33 +00:00
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIDOMNode.h"
|
2001-07-16 02:40:48 +00:00
|
|
|
#include "nsGUIEvent.h"
|
2003-02-22 00:32:13 +00:00
|
|
|
#include "nsAutoPtr.h"
|
2004-01-28 00:18:22 +00:00
|
|
|
#include "nsStyleSet.h"
|
2004-06-25 12:26:02 +00:00
|
|
|
#include "nsNodeInfoManager.h"
|
|
|
|
#include "nsContentCreatorFunctions.h"
|
2006-07-06 10:43:51 +00:00
|
|
|
#include "nsLayoutUtils.h"
|
2006-01-26 02:29:17 +00:00
|
|
|
#include "nsDisplayList.h"
|
2007-02-16 01:53:43 +00:00
|
|
|
#include "nsITheme.h"
|
|
|
|
#include "nsThemeConstants.h"
|
2009-12-18 19:27:57 +00:00
|
|
|
#include "nsPLDOMEvent.h"
|
2011-04-08 01:04:40 +00:00
|
|
|
#include "nsRenderingContext.h"
|
2001-04-01 01:01:33 +00:00
|
|
|
|
2010-10-25 12:17:38 +00:00
|
|
|
namespace dom = mozilla::dom;
|
|
|
|
|
2006-05-10 17:30:15 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsComboboxControlFrame::RedisplayTextEvent::Run()
|
2005-03-21 01:58:17 +00:00
|
|
|
{
|
2006-05-10 17:30:15 +00:00
|
|
|
if (mControlFrame)
|
|
|
|
mControlFrame->HandleRedisplayTextEvent();
|
|
|
|
return NS_OK;
|
2005-03-21 01:58:17 +00:00
|
|
|
}
|
|
|
|
|
2005-01-27 22:52:53 +00:00
|
|
|
class nsPresState;
|
1999-01-18 15:14:00 +00:00
|
|
|
|
2000-12-20 15:09:00 +00:00
|
|
|
#define FIX_FOR_BUG_53259
|
|
|
|
|
1999-05-27 21:17:10 +00:00
|
|
|
// Drop down list event management.
|
2000-03-07 15:54:31 +00:00
|
|
|
// The combo box uses the following strategy for managing the drop-down list.
|
1999-05-27 21:17:10 +00: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-14 22:00:24 +00:00
|
|
|
|
2004-12-19 21:45:51 +00: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-14 22:00:24 +00:00
|
|
|
|
2000-03-07 15:54:31 +00:00
|
|
|
const PRInt32 kSizeNotSet = -1;
|
|
|
|
|
2001-06-30 00:25:09 +00: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 01:52:03 +00:00
|
|
|
mComboBox->ShowDropDown(!mComboBox->IsDroppedDown());
|
2007-05-17 11:12:30 +00:00
|
|
|
return NS_OK;
|
2001-06-30 00:25:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsComboButtonListener(nsComboboxControlFrame* aCombobox)
|
|
|
|
{
|
|
|
|
mComboBox = aCombobox;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~nsComboButtonListener() {}
|
|
|
|
|
|
|
|
nsComboboxControlFrame* mComboBox;
|
|
|
|
};
|
|
|
|
|
2008-04-06 12:28:34 +00:00
|
|
|
NS_IMPL_ISUPPORTS2(nsComboButtonListener,
|
|
|
|
nsIDOMMouseListener,
|
|
|
|
nsIDOMEventListener)
|
2001-06-30 00:25:09 +00:00
|
|
|
|
2000-10-04 13:39:07 +00:00
|
|
|
// static class data member for Bug 32920
|
|
|
|
nsComboboxControlFrame * nsComboboxControlFrame::mFocused = nsnull;
|
|
|
|
|
2005-11-04 02:38:33 +00:00
|
|
|
nsIFrame*
|
2006-03-26 21:30:36 +00:00
|
|
|
NS_NewComboboxControlFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, PRUint32 aStateFlags)
|
1999-01-18 15:14:00 +00:00
|
|
|
{
|
2006-03-26 21:30:36 +00:00
|
|
|
nsComboboxControlFrame* it = new (aPresShell) nsComboboxControlFrame(aContext);
|
2005-11-04 02:38:33 +00:00
|
|
|
|
|
|
|
if (it) {
|
|
|
|
// set the state flags (if any are provided)
|
|
|
|
it->AddStateBits(aStateFlags);
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
2005-11-04 02:38:33 +00:00
|
|
|
|
|
|
|
return it;
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsComboboxControlFrame)
|
|
|
|
|
2000-03-07 15:54:31 +00: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-28 22:17:53 +00:00
|
|
|
printf("** Id:%5d %s RF: %d RQ: %d %d/%d %5.2f\n", \
|
2000-03-07 15:54:31 +00: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-28 22:17:53 +00: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 15:54:31 +00: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-28 22:17:53 +00: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 15:54:31 +00: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-26 21:30:36 +00:00
|
|
|
nsComboboxControlFrame::nsComboboxControlFrame(nsStyleContext* aContext)
|
2008-12-29 15:07:38 +00:00
|
|
|
: nsBlockFrame(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 05:38:33 +00:00
|
|
|
mDisplayWidth(0)
|
1999-01-18 15:14:00 +00:00
|
|
|
{
|
1999-04-12 22:14:31 +00: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-14 22:00:24 +00:00
|
|
|
mDroppedDown = PR_FALSE;
|
|
|
|
mDisplayFrame = nsnull;
|
|
|
|
mButtonFrame = nsnull;
|
|
|
|
mDropdownFrame = nsnull;
|
|
|
|
|
2005-02-19 23:54:36 +00:00
|
|
|
mInRedisplayText = PR_FALSE;
|
2000-10-04 13:39:07 +00:00
|
|
|
|
2006-09-30 05:07:49 +00:00
|
|
|
mRecentSelectedIndex = NS_SKIP_NOTIFY_INDEX;
|
2002-02-08 18:35:48 +00:00
|
|
|
|
2000-03-07 15:54:31 +00:00
|
|
|
REFLOW_COUNTER_INIT()
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
|
|
|
nsComboboxControlFrame::~nsComboboxControlFrame()
|
|
|
|
{
|
2000-03-07 15:54:31 +00:00
|
|
|
REFLOW_COUNTER_DUMP("nsCCF");
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
2009-01-12 19:20:59 +00:00
|
|
|
|
|
|
|
NS_QUERYFRAME_HEAD(nsComboboxControlFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIComboboxControlFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIFormControlFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsISelectControlFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIStatefulFrame)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrame)
|
|
|
|
|
2001-08-17 03:13:07 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2010-06-28 12:02:03 +00:00
|
|
|
already_AddRefed<nsAccessible>
|
|
|
|
nsComboboxControlFrame::CreateAccessible()
|
2001-05-17 23:52:32 +00:00
|
|
|
{
|
2011-01-28 04:38:14 +00:00
|
|
|
nsAccessibilityService* accService = nsIPresShell::AccService();
|
2001-05-17 23:52:32 +00:00
|
|
|
if (accService) {
|
2010-06-28 12:02:03 +00:00
|
|
|
return accService->CreateHTMLComboboxAccessible(mContent,
|
|
|
|
PresContext()->PresShell());
|
2001-05-17 23:52:32 +00:00
|
|
|
}
|
|
|
|
|
2010-06-28 12:02:03 +00:00
|
|
|
return nsnull;
|
2001-05-17 23:52:32 +00:00
|
|
|
}
|
2001-08-17 03:13:07 +00:00
|
|
|
#endif
|
2001-05-17 23:52:32 +00:00
|
|
|
|
1999-01-18 15:14:00 +00:00
|
|
|
void
|
|
|
|
nsComboboxControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
|
|
|
|
{
|
2006-08-11 12:09:30 +00:00
|
|
|
nsWeakFrame weakFrame(this);
|
2001-01-04 12:22:29 +00:00
|
|
|
if (aOn) {
|
2002-11-07 10:25:03 +00:00
|
|
|
nsListControlFrame::ComboboxFocusSet();
|
2004-07-23 08:25:44 +00:00
|
|
|
mFocused = this;
|
2001-01-04 12:22:29 +00:00
|
|
|
} else {
|
|
|
|
mFocused = nsnull;
|
|
|
|
if (mDroppedDown) {
|
2007-05-17 11:12:30 +00:00
|
|
|
mListControlFrame->ComboboxFinish(mDisplayedIndex); // might destroy us
|
|
|
|
if (!weakFrame.IsAlive()) {
|
|
|
|
return;
|
|
|
|
}
|
2002-02-08 18:35:48 +00:00
|
|
|
}
|
2006-08-11 12:09:30 +00:00
|
|
|
// May delete |this|.
|
2004-05-28 16:25:04 +00:00
|
|
|
mListControlFrame->FireOnChange();
|
2001-01-04 12:22:29 +00:00
|
|
|
}
|
2002-02-08 18:35:48 +00:00
|
|
|
|
2006-08-11 12:09:30 +00:00
|
|
|
if (!weakFrame.IsAlive()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-01-04 12:22:29 +00:00
|
|
|
// This is needed on a temporary basis. It causes the focus
|
2000-10-04 13:39:07 +00:00
|
|
|
// rect to be drawn. This is much faster than ReResolvingStyle
|
|
|
|
// Bug 32920
|
2008-09-18 09:47:21 +00:00
|
|
|
Invalidate(nsRect(0,0,mRect.width,mRect.height));
|
2001-06-14 02:08:40 +00: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 03:09:05 +00:00
|
|
|
// XXX this is rather inefficient
|
2009-03-11 15:43:08 +00:00
|
|
|
nsIViewManager* vm = PresContext()->GetPresShell()->GetViewManager();
|
2003-07-04 12:50:32 +00:00
|
|
|
if (vm) {
|
|
|
|
vm->UpdateAllViews(NS_VMREFRESH_NO_SYNC);
|
2001-06-14 02:08:40 +00:00
|
|
|
}
|
1999-01-18 15:14:00 +00: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-14 22:00:24 +00:00
|
|
|
void
|
|
|
|
nsComboboxControlFrame::ShowPopup(PRBool aShowPopup)
|
|
|
|
{
|
2003-07-04 12:50:32 +00:00
|
|
|
nsIView* view = mDropdownFrame->GetView();
|
|
|
|
nsIViewManager* viewManager = view->GetViewManager();
|
2000-05-26 06:42:29 +00:00
|
|
|
|
|
|
|
if (aShowPopup) {
|
2003-07-04 12:50:32 +00:00
|
|
|
nsRect rect = mDropdownFrame->GetRect();
|
2001-12-01 14:31:45 +00:00
|
|
|
rect.x = rect.y = 0;
|
|
|
|
viewManager->ResizeView(view, rect);
|
2000-05-26 06:42:29 +00:00
|
|
|
viewManager->SetViewVisibility(view, nsViewVisibility_kShow);
|
|
|
|
} else {
|
|
|
|
viewManager->SetViewVisibility(view, nsViewVisibility_kHide);
|
2001-12-01 14:31:45 +00:00
|
|
|
nsRect emptyRect(0, 0, 0, 0);
|
|
|
|
viewManager->ResizeView(view, emptyRect);
|
2000-05-26 06:42:29 +00:00
|
|
|
}
|
2001-04-01 01:01:33 +00:00
|
|
|
|
|
|
|
// fire a popup dom event
|
|
|
|
nsEventStatus status = nsEventStatus_eIgnore;
|
2005-04-28 23:48:28 +00:00
|
|
|
nsMouseEvent event(PR_TRUE, aShowPopup ?
|
|
|
|
NS_XUL_POPUP_SHOWING : NS_XUL_POPUP_HIDING, nsnull,
|
|
|
|
nsMouseEvent::eReal);
|
2001-04-01 01:01:33 +00:00
|
|
|
|
2007-03-30 21:11:41 +00:00
|
|
|
nsCOMPtr<nsIPresShell> shell = PresContext()->GetPresShell();
|
2003-12-21 05:36:36 +00:00
|
|
|
if (shell)
|
|
|
|
shell->HandleDOMEventWithTarget(mContent, &event, &status);
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
|
2007-05-17 11:12:30 +00:00
|
|
|
PRBool
|
2009-09-02 02:46:47 +00:00
|
|
|
nsComboboxControlFrame::ShowList(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-14 22:00:24 +00:00
|
|
|
{
|
2007-05-17 11:12:30 +00:00
|
|
|
nsCOMPtr<nsIPresShell> shell = PresContext()->GetPresShell();
|
1999-09-21 21:20:50 +00:00
|
|
|
|
2007-05-17 11:12:30 +00:00
|
|
|
nsWeakFrame weakFrame(this);
|
2011-03-21 18:28:10 +00:00
|
|
|
|
|
|
|
if (aShowList) {
|
|
|
|
nsIView* view = mDropdownFrame->GetView();
|
|
|
|
NS_ASSERTION(!view->HasWidget(),
|
|
|
|
"We shoudldn't have a widget before we need to display the popup");
|
|
|
|
|
|
|
|
// Create the widget for the drop-down list
|
|
|
|
view->GetViewManager()->SetViewFloating(view, PR_TRUE);
|
|
|
|
|
|
|
|
nsWidgetInitData widgetData;
|
|
|
|
widgetData.mWindowType = eWindowType_popup;
|
|
|
|
widgetData.mBorderStyle = eBorderStyle_default;
|
|
|
|
view->CreateWidgetForPopup(&widgetData);
|
|
|
|
}
|
|
|
|
|
2007-05-17 11:12:30 +00:00
|
|
|
ShowPopup(aShowList); // might destroy us
|
|
|
|
if (!weakFrame.IsAlive()) {
|
|
|
|
return PR_FALSE;
|
1999-09-21 21:20:50 +00:00
|
|
|
}
|
|
|
|
|
2007-05-17 11:12:30 +00:00
|
|
|
mDroppedDown = aShowList;
|
|
|
|
if (mDroppedDown) {
|
|
|
|
// The listcontrol frame will call back to the nsComboboxControlFrame's
|
|
|
|
// ListWasSelected which will stop the capture.
|
1999-09-08 14:27:38 +00:00
|
|
|
mListControlFrame->AboutToDropDown();
|
2006-03-01 01:00:29 +00:00
|
|
|
mListControlFrame->CaptureMouseEvents(PR_TRUE);
|
1999-05-07 20:30:16 +00:00
|
|
|
}
|
2000-02-11 22:26:36 +00:00
|
|
|
|
2007-08-22 02:57:06 +00:00
|
|
|
// XXXbz so why do we need to flush here, exactly?
|
|
|
|
shell->GetDocument()->FlushPendingNotifications(Flush_Layout);
|
2007-05-17 11:12:30 +00:00
|
|
|
if (!weakFrame.IsAlive()) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
2000-02-11 22:26:36 +00:00
|
|
|
|
2009-01-12 19:20:59 +00:00
|
|
|
nsIFrame* listFrame = do_QueryFrame(mListControlFrame);
|
2007-05-17 11:12:30 +00:00
|
|
|
if (listFrame) {
|
|
|
|
nsIView* view = listFrame->GetView();
|
|
|
|
NS_ASSERTION(view, "nsComboboxControlFrame view is null");
|
|
|
|
if (view) {
|
|
|
|
nsIWidget* widget = view->GetWidget();
|
2011-03-21 18:28:10 +00:00
|
|
|
if (widget) {
|
2009-12-22 23:49:33 +00:00
|
|
|
widget->CaptureRollupEvents(this, nsnull, mDroppedDown, mDroppedDown);
|
2011-03-21 18:28:10 +00:00
|
|
|
|
|
|
|
if (!aShowList) {
|
|
|
|
view->DestroyWidget();
|
|
|
|
}
|
|
|
|
}
|
2007-05-17 11:12:30 +00:00
|
|
|
}
|
|
|
|
}
|
2000-02-11 22:26:36 +00:00
|
|
|
|
2007-05-17 11:12:30 +00: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-14 22:00:24 +00:00
|
|
|
}
|
1999-05-07 20:30:16 +00: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-14 22:00:24 +00: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 05:38:33 +00: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-14 22:00:24 +00: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 05:38:33 +00: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 19:16:51 +00: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 05:38:33 +00: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-14 22:00:24 +00: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 05:38:33 +00: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 00:05:12 +00:00
|
|
|
nscoord forcedWidth = aReflowState.ComputedWidth() +
|
2007-01-11 17:59:41 +00:00
|
|
|
aReflowState.mComputedBorderPadding.LeftRight() -
|
|
|
|
kidReflowState.mComputedBorderPadding.LeftRight();
|
2009-09-16 15:01:36 +00:00
|
|
|
kidReflowState.SetComputedWidth(NS_MAX(kidReflowState.ComputedWidth(),
|
2007-01-26 00:05:12 +00:00
|
|
|
forcedWidth));
|
2000-05-26 06:42:29 +00: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 05:38:33 +00:00
|
|
|
if (GetStateBits() & NS_FRAME_FIRST_REFLOW) {
|
2003-07-04 12:50:32 +00:00
|
|
|
nsIView* view = mDropdownFrame->GetView();
|
|
|
|
nsIViewManager* viewManager = view->GetViewManager();
|
2000-05-26 06:42:29 +00:00
|
|
|
viewManager->SetViewVisibility(view, nsViewVisibility_kHide);
|
2001-12-01 14:31:45 +00:00
|
|
|
nsRect emptyRect(0, 0, 0, 0);
|
|
|
|
viewManager->ResizeView(view, emptyRect);
|
2000-05-26 06:42:29 +00:00
|
|
|
}
|
|
|
|
|
2005-06-22 01:38:49 +00:00
|
|
|
// Allow the child to move/size/change-visibility its view if it's currently
|
|
|
|
// dropped down
|
2008-09-03 21:35:52 +00:00
|
|
|
PRInt32 flags = NS_FRAME_NO_MOVE_FRAME | NS_FRAME_NO_VISIBILITY | NS_FRAME_NO_SIZE_VIEW;
|
2005-06-22 01:38:49 +00: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 05:38:33 +00: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 15:33:29 +00: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 05:38:33 +00: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-14 22:00:24 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2007-02-15 10:58:31 +00: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-14 22:00:24 +00: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 15:14:00 +00: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-14 22:00:24 +00:00
|
|
|
// Note: As first glance, it appears that you could simply get the absolute bounding box for the
|
2005-11-20 22:05:24 +00: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-14 22:00:24 +00: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 15:14:00 +00: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-14 22:00:24 +00:00
|
|
|
// Use the height calculated for the area frame so it includes both
|
|
|
|
// the display and button heights.
|
2007-02-15 10:58:31 +00:00
|
|
|
nscoord dropdownYOffset = GetRect().height;
|
|
|
|
nsSize dropdownSize = mDropdownFrame->GetSize();
|
1999-07-28 21:38:08 +00:00
|
|
|
|
2009-08-18 03:21:07 +00:00
|
|
|
nsRect screen = nsFormControlFrame::GetUsableScreenRect(PresContext());
|
|
|
|
|
|
|
|
// Check to see if the drop-down list will go offscreen
|
|
|
|
if (GetScreenRectInAppUnits().YMost() + dropdownSize.height > screen.YMost()) {
|
|
|
|
// move the dropdown list up
|
|
|
|
dropdownYOffset = - (dropdownSize.height);
|
2003-04-08 20:50:57 +00:00
|
|
|
}
|
2007-02-15 10:58:31 +00:00
|
|
|
|
|
|
|
nsPoint dropdownPosition;
|
2006-08-13 19:34:58 +00: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 10:58:31 +00:00
|
|
|
dropdownPosition.x = GetRect().width - dropdownSize.width;
|
2006-08-13 19:34:58 +00:00
|
|
|
} else {
|
2007-02-15 10:58:31 +00:00
|
|
|
dropdownPosition.x = 0;
|
2006-08-13 19:34:58 +00:00
|
|
|
}
|
2007-02-15 10:58:31 +00:00
|
|
|
dropdownPosition.y = dropdownYOffset;
|
1999-09-09 13:17:35 +00:00
|
|
|
|
2007-02-15 10:58:31 +00: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-14 22:00:24 +00:00
|
|
|
}
|
1999-01-18 15:14:00 +00:00
|
|
|
|
2000-03-07 15:54:31 +00:00
|
|
|
//----------------------------------------------------------
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------
|
|
|
|
#ifdef DO_REFLOW_DEBUG
|
2000-03-03 07:14:58 +00:00
|
|
|
static int myCounter = 0;
|
2000-03-07 15:54:31 +00:00
|
|
|
|
|
|
|
static void printSize(char * aDesc, nscoord aSize)
|
|
|
|
{
|
2000-10-28 22:17:53 +00:00
|
|
|
printf(" %s: ", aDesc);
|
2000-03-07 15:54:31 +00:00
|
|
|
if (aSize == NS_UNCONSTRAINEDSIZE) {
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("UC");
|
2000-03-07 15:54:31 +00:00
|
|
|
} else {
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("%d", PX(aSize));
|
2000-03-07 15:54:31 +00:00
|
|
|
}
|
|
|
|
}
|
2000-01-28 15:24:49 +00:00
|
|
|
#endif
|
|
|
|
|
2000-03-07 15:54:31 +00:00
|
|
|
//-------------------------------------------------------------------
|
|
|
|
//-- Main Reflow for the Combobox
|
|
|
|
//-------------------------------------------------------------------
|
2000-04-21 21:53:38 +00: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 05:38:33 +00:00
|
|
|
nscoord
|
2011-04-08 01:04:40 +00:00
|
|
|
nsComboboxControlFrame::GetIntrinsicWidth(nsRenderingContext* aRenderingContext,
|
2007-12-03 06:41:38 +00:00
|
|
|
nsLayoutUtils::IntrinsicWidthType aType)
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
{
|
2007-05-29 05:31:04 +00:00
|
|
|
// get the scrollbar width, we'll use this later
|
|
|
|
nscoord scrollbarWidth = 0;
|
|
|
|
nsPresContext* presContext = PresContext();
|
|
|
|
if (mListControlFrame) {
|
2009-01-12 19:20:59 +00:00
|
|
|
nsIScrollableFrame* scrollable = do_QueryFrame(mListControlFrame);
|
2007-05-29 05:31:04 +00:00
|
|
|
NS_ASSERTION(scrollable, "List must be a scrollable frame");
|
2008-04-10 04:39:41 +00:00
|
|
|
scrollbarWidth =
|
|
|
|
scrollable->GetDesiredScrollbarSizes(presContext, aRenderingContext).LeftRight();
|
2007-05-29 05:31:04 +00:00
|
|
|
}
|
2000-03-07 15:54:31 +00:00
|
|
|
|
2007-12-03 06:41:38 +00:00
|
|
|
nscoord displayWidth = 0;
|
2007-05-29 05:31:04 +00:00
|
|
|
if (NS_LIKELY(mDisplayFrame)) {
|
2007-12-03 06:41:38 +00:00
|
|
|
displayWidth = nsLayoutUtils::IntrinsicForContainer(aRenderingContext,
|
|
|
|
mDisplayFrame,
|
|
|
|
aType);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
}
|
2000-01-28 15:24:49 +00:00
|
|
|
|
2007-05-29 05:31:04 +00:00
|
|
|
if (mDropdownFrame) {
|
2007-12-03 06:41:38 +00: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 19:26:35 +00:00
|
|
|
dropdownContentWidth = NSCoordSaturatingSubtract(dropdownContentWidth,
|
|
|
|
scrollbarWidth,
|
|
|
|
nscoord_MAX);
|
2007-12-03 06:41:38 +00:00
|
|
|
|
2009-09-16 15:01:36 +00:00
|
|
|
displayWidth = NS_MAX(dropdownContentWidth, displayWidth);
|
2007-05-05 06:20:10 +00:00
|
|
|
}
|
|
|
|
|
2007-05-29 05:31:04 +00:00
|
|
|
// add room for the dropmarker button if there is one
|
|
|
|
if (!IsThemed() || presContext->GetTheme()->ThemeNeedsComboboxDropmarker())
|
2007-12-03 06:41:38 +00:00
|
|
|
displayWidth += scrollbarWidth;
|
|
|
|
|
|
|
|
return displayWidth;
|
2007-05-29 05:31:04 +00:00
|
|
|
|
2007-12-03 06:41:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
2011-04-08 01:04:40 +00:00
|
|
|
nsComboboxControlFrame::GetMinWidth(nsRenderingContext *aRenderingContext)
|
2007-12-03 06:41:38 +00:00
|
|
|
{
|
|
|
|
nscoord minWidth;
|
|
|
|
DISPLAY_MIN_WIDTH(this, minWidth);
|
|
|
|
minWidth = GetIntrinsicWidth(aRenderingContext, nsLayoutUtils::MIN_WIDTH);
|
|
|
|
return minWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
2011-04-08 01:04:40 +00:00
|
|
|
nsComboboxControlFrame::GetPrefWidth(nsRenderingContext *aRenderingContext)
|
2007-12-03 06:41:38 +00:00
|
|
|
{
|
|
|
|
nscoord prefWidth;
|
|
|
|
DISPLAY_PREF_WIDTH(this, prefWidth);
|
|
|
|
prefWidth = GetIntrinsicWidth(aRenderingContext, nsLayoutUtils::PREF_WIDTH);
|
|
|
|
return prefWidth;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
}
|
2000-03-07 15:54:31 +00: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 05:38:33 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsComboboxControlFrame::Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
// Constraints we try to satisfy:
|
2000-03-07 15:54:31 +00: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 05:38:33 +00: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 04:28:59 +00: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 05:38:33 +00: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 15:24:49 +00:00
|
|
|
}
|
|
|
|
|
2005-06-21 00:00:14 +00:00
|
|
|
// Make sure the displayed text is the same as the selected option, bug 297389.
|
|
|
|
PRInt32 selectedIndex;
|
|
|
|
nsAutoString selectedOptionText;
|
2005-10-22 03:47:00 +00:00
|
|
|
if (!mDroppedDown) {
|
2006-03-01 01:00:29 +00:00
|
|
|
selectedIndex = mListControlFrame->GetSelectedIndex();
|
2005-10-22 03:47:00 +00: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 00:00:14 +00: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 05:38:33 +00:00
|
|
|
// First reflow our dropdown so that we know how tall we should be.
|
|
|
|
ReflowDropdown(aPresContext, aReflowState);
|
2007-02-07 07:46:44 +00:00
|
|
|
|
2006-12-19 15:08:34 +00:00
|
|
|
// Get the width of the vertical scrollbar. That will be the width of the
|
|
|
|
// dropdown button.
|
2007-05-18 03:04:04 +00: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 05:38:33 +00:00
|
|
|
buttonWidth = 0;
|
2000-03-07 15:54:31 +00:00
|
|
|
}
|
2007-05-18 03:04:04 +00:00
|
|
|
else {
|
2009-01-12 19:20:59 +00:00
|
|
|
nsIScrollableFrame* scrollable = do_QueryFrame(mListControlFrame);
|
2007-05-18 03:04:04 +00:00
|
|
|
NS_ASSERTION(scrollable, "List must be a scrollable frame");
|
2008-04-10 04:39:41 +00:00
|
|
|
buttonWidth =
|
|
|
|
scrollable->GetDesiredScrollbarSizes(PresContext(),
|
|
|
|
aReflowState.rendContext).LeftRight();
|
2007-05-18 03:04:04 +00:00
|
|
|
if (buttonWidth > aReflowState.ComputedWidth()) {
|
|
|
|
buttonWidth = 0;
|
|
|
|
}
|
|
|
|
}
|
2000-08-03 14:13:40 +00:00
|
|
|
|
2007-01-26 00:05:12 +00:00
|
|
|
mDisplayWidth = aReflowState.ComputedWidth() - buttonWidth;
|
2000-08-03 14:13:40 +00:00
|
|
|
|
2008-12-29 15:07:38 +00:00
|
|
|
nsresult rv = nsBlockFrame::Reflow(aPresContext, aDesiredSize, aReflowState,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
aStatus);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2000-08-03 14:13:40 +00: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 05:38:33 +00: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 18:08:05 +00: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 05:38:33 +00: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 15:54:31 +00: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 05:38:33 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
else {
|
2007-04-26 01:17:05 +00: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 18:08:05 +00:00
|
|
|
(aReflowState.ComputedHeight() < buttonHeight &&
|
2007-04-26 01:17:05 +00:00
|
|
|
buttonHeight ==
|
|
|
|
mButtonFrame->GetUsedBorderAndPadding().TopBottom()) ||
|
2007-08-02 18:08:05 +00:00
|
|
|
(aReflowState.ComputedHeight() < displayHeight &&
|
2007-04-26 01:17:05 +00: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 05:38:33 +00:00
|
|
|
"Different heights?");
|
2000-01-28 15:24:49 +00:00
|
|
|
}
|
1999-12-22 19:46:28 +00: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 05:38:33 +00: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 15:54:31 +00: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 05:38:33 +00: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-14 22:00:24 +00:00
|
|
|
return rv;
|
|
|
|
}
|
2000-03-07 15:54:31 +00:00
|
|
|
|
1999-01-18 15:14:00 +00: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 05:38:33 +00:00
|
|
|
nsIAtom*
|
|
|
|
nsComboboxControlFrame::GetType() const
|
|
|
|
{
|
2006-12-26 17:47:52 +00: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 05:38:33 +00:00
|
|
|
}
|
|
|
|
|
1999-11-01 22:12:45 +00:00
|
|
|
#ifdef NS_DEBUG
|
1999-01-18 15:14:00 +00:00
|
|
|
NS_IMETHODIMP
|
2001-11-14 01:33:42 +00:00
|
|
|
nsComboboxControlFrame::GetFrameName(nsAString& aResult) const
|
1999-01-18 15:14:00 +00:00
|
|
|
{
|
2001-11-14 01:33:42 +00:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("ComboboxControl"), aResult);
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
1999-11-01 22:12:45 +00:00
|
|
|
#endif
|
1999-01-18 15:14:00 +00:00
|
|
|
|
2002-01-09 19:17:46 +00:00
|
|
|
|
1999-01-18 15:14:00 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIComboboxControlFrame
|
|
|
|
//----------------------------------------------------------------------
|
2006-02-18 01:52:03 +00:00
|
|
|
void
|
1999-08-26 14:54:07 +00:00
|
|
|
nsComboboxControlFrame::ShowDropDown(PRBool aDoDropDown)
|
2006-04-26 02:01:07 +00:00
|
|
|
{
|
2010-10-20 11:26:32 +00:00
|
|
|
nsEventStates eventStates = mContent->IntrinsicState();
|
|
|
|
if (eventStates.HasState(NS_EVENT_STATE_DISABLED)) {
|
2006-02-18 01:52:03 +00:00
|
|
|
return;
|
1999-08-26 14:54:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!mDroppedDown && aDoDropDown) {
|
1999-08-31 13:22:40 +00:00
|
|
|
if (mListControlFrame) {
|
2004-12-27 15:05:18 +00:00
|
|
|
mListControlFrame->SyncViewWithFrame();
|
1999-08-31 13:22:40 +00:00
|
|
|
}
|
2009-09-02 02:46:47 +00:00
|
|
|
ShowList(aDoDropDown); // might destroy us
|
1999-08-26 14:54:07 +00:00
|
|
|
} else if (mDroppedDown && !aDoDropDown) {
|
2009-09-02 02:46:47 +00:00
|
|
|
ShowList(aDoDropDown); // might destroy us
|
1999-08-26 14:54:07 +00:00
|
|
|
}
|
|
|
|
}
|
1999-01-18 15:14:00 +00:00
|
|
|
|
2006-02-18 01:52:03 +00: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-14 22:00:24 +00:00
|
|
|
nsComboboxControlFrame::SetDropDown(nsIFrame* aDropDownFrame)
|
1999-01-18 15:14:00 +00:00
|
|
|
{
|
1999-08-31 13:22:40 +00:00
|
|
|
mDropdownFrame = aDropDownFrame;
|
2009-01-12 19:20:59 +00:00
|
|
|
mListControlFrame = do_QueryFrame(mDropdownFrame);
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
|
2006-02-27 04:13:51 +00:00
|
|
|
nsIFrame*
|
|
|
|
nsComboboxControlFrame::GetDropDown()
|
|
|
|
{
|
|
|
|
return mDropdownFrame;
|
|
|
|
}
|
|
|
|
|
1999-08-31 13:22:40 +00:00
|
|
|
///////////////////////////////////////////////////////////////
|
|
|
|
|
1999-08-26 14:54:07 +00:00
|
|
|
NS_IMETHODIMP
|
2002-01-25 23:35:44 +00:00
|
|
|
nsComboboxControlFrame::RedisplaySelectedText()
|
1999-06-23 21:50:56 +00:00
|
|
|
{
|
2009-02-18 03:27:25 +00:00
|
|
|
nsAutoScriptBlocker scriptBlocker;
|
2006-03-01 01:00:29 +00:00
|
|
|
return RedisplayText(mListControlFrame->GetSelectedIndex());
|
2002-01-25 23:35:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsComboboxControlFrame::RedisplayText(PRInt32 aIndex)
|
|
|
|
{
|
|
|
|
// Get the text to display
|
|
|
|
if (aIndex != -1) {
|
2005-06-21 00:00:14 +00:00
|
|
|
mListControlFrame->GetOptionText(aIndex, mDisplayedOptionText);
|
|
|
|
} else {
|
|
|
|
mDisplayedOptionText.Truncate();
|
2002-01-25 23:35:44 +00:00
|
|
|
}
|
|
|
|
mDisplayedIndex = aIndex;
|
|
|
|
|
2005-06-21 00:00:14 +00:00
|
|
|
REFLOW_DEBUG_MSG2("RedisplayText \"%s\"\n",
|
2006-02-03 14:18:39 +00:00
|
|
|
NS_LossyConvertUTF16toASCII(mDisplayedOptionText).get());
|
2002-01-25 23:35:44 +00:00
|
|
|
|
1999-10-05 23:43:06 +00:00
|
|
|
// Send reflow command because the new text maybe larger
|
|
|
|
nsresult rv = NS_OK;
|
2006-03-14 21:02:42 +00:00
|
|
|
if (mDisplayContent) {
|
2005-06-21 00:00:14 +00:00
|
|
|
// Don't call ActuallyDisplayText(PR_TRUE) directly here since that
|
2005-04-03 19:58:40 +00:00
|
|
|
// could cause recursive frame construction. See bug 283117 and the comment in
|
|
|
|
// HandleRedisplayTextEvent() below.
|
2005-04-03 22:16:07 +00:00
|
|
|
|
2006-05-10 17:30:15 +00:00
|
|
|
// Revoke outstanding events to avoid out-of-order events which could mean
|
|
|
|
// displaying the wrong text.
|
|
|
|
mRedisplayTextEvent.Revoke();
|
2005-04-03 22:16:07 +00:00
|
|
|
|
2009-02-18 03:27:25 +00:00
|
|
|
NS_ASSERTION(!nsContentUtils::IsSafeToRunScript(),
|
|
|
|
"If we happen to run our redisplay event now, we might kill "
|
|
|
|
"ourselves!");
|
|
|
|
|
2006-05-10 17:30:15 +00:00
|
|
|
nsRefPtr<RedisplayTextEvent> event = new RedisplayTextEvent(this);
|
2009-02-18 03:27:25 +00:00
|
|
|
mRedisplayTextEvent = event;
|
|
|
|
if (!nsContentUtils::AddScriptRunner(event))
|
|
|
|
mRedisplayTextEvent.Forget();
|
1999-08-26 14:54:07 +00:00
|
|
|
}
|
1999-10-05 23:43:06 +00:00
|
|
|
return rv;
|
1999-08-26 14:54:07 +00:00
|
|
|
}
|
|
|
|
|
2005-03-21 01:58:17 +00:00
|
|
|
void
|
2005-06-21 00:00:14 +00:00
|
|
|
nsComboboxControlFrame::HandleRedisplayTextEvent()
|
2005-03-21 01:58:17 +00:00
|
|
|
{
|
2005-04-12 15:31:03 +00:00
|
|
|
// First, make sure that the content model is up to date and we've
|
|
|
|
// constructed the frames for all our content in the right places.
|
|
|
|
// Otherwise they'll end up under the wrong insertion frame when we
|
|
|
|
// ActuallyDisplayText, since that flushes out the content sink by
|
|
|
|
// calling SetText on a DOM node with aNotify set to true. See bug
|
|
|
|
// 289730.
|
2009-10-16 02:49:57 +00:00
|
|
|
nsWeakFrame weakThis(this);
|
2007-03-30 21:11:41 +00:00
|
|
|
PresContext()->Document()->
|
2005-04-12 15:31:03 +00:00
|
|
|
FlushPendingNotifications(Flush_ContentAndNotify);
|
2009-10-16 02:49:57 +00:00
|
|
|
if (!weakThis.IsAlive())
|
|
|
|
return;
|
|
|
|
|
2005-03-21 01:58:17 +00: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 17:30:15 +00:00
|
|
|
mRedisplayTextEvent.Forget();
|
2005-03-21 01:58:17 +00:00
|
|
|
|
2005-06-21 00:00:14 +00: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 05:38:33 +00:00
|
|
|
// XXXbz This should perhaps be eResize. Check.
|
2007-03-30 21:11:41 +00:00
|
|
|
PresContext()->PresShell()->FrameNeedsReflow(mDisplayFrame,
|
2007-05-06 19:16:51 +00:00
|
|
|
nsIPresShell::eStyleChange,
|
|
|
|
NS_FRAME_IS_DIRTY);
|
2005-03-21 01:58:17 +00:00
|
|
|
|
|
|
|
mInRedisplayText = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2005-06-21 00:00:14 +00:00
|
|
|
void
|
|
|
|
nsComboboxControlFrame::ActuallyDisplayText(PRBool aNotify)
|
2002-01-25 23:35:44 +00:00
|
|
|
{
|
2005-06-21 00:00:14 +00:00
|
|
|
if (mDisplayedOptionText.IsEmpty()) {
|
2002-11-12 19:17:51 +00:00
|
|
|
// Have to use a non-breaking space for line-height calculations
|
|
|
|
// to be right
|
2004-05-13 01:12:10 +00:00
|
|
|
static const PRUnichar space = 0xA0;
|
|
|
|
mDisplayContent->SetText(&space, 1, aNotify);
|
2002-01-25 23:35:44 +00:00
|
|
|
} else {
|
2005-06-21 00:00:14 +00:00
|
|
|
mDisplayContent->SetText(mDisplayedOptionText, aNotify);
|
2002-01-25 23:35:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-18 01:52:03 +00:00
|
|
|
PRInt32
|
|
|
|
nsComboboxControlFrame::GetIndexOfDisplayArea()
|
2000-12-20 23:25:40 +00:00
|
|
|
{
|
2006-02-18 01:52:03 +00:00
|
|
|
return mDisplayedIndex;
|
2000-12-20 23:25:40 +00:00
|
|
|
}
|
1999-08-26 14:54:07 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISelectControlFrame
|
|
|
|
//----------------------------------------------------------------------
|
1999-11-11 22:13:33 +00:00
|
|
|
NS_IMETHODIMP
|
2002-03-31 10:14:01 +00:00
|
|
|
nsComboboxControlFrame::DoneAddingChildren(PRBool aIsDone)
|
1999-11-11 22:13:33 +00:00
|
|
|
{
|
2009-01-12 19:20:59 +00:00
|
|
|
nsISelectControlFrame* listFrame = do_QueryFrame(mDropdownFrame);
|
|
|
|
if (!listFrame)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
return listFrame->DoneAddingChildren(aIsDone);
|
1999-11-11 22:13:33 +00:00
|
|
|
}
|
1999-08-26 14:54:07 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2009-02-18 03:27:25 +00:00
|
|
|
nsComboboxControlFrame::AddOption(PRInt32 aIndex)
|
1999-08-26 14:54:07 +00:00
|
|
|
{
|
2005-06-20 23:26:35 +00:00
|
|
|
if (aIndex <= mDisplayedIndex) {
|
|
|
|
++mDisplayedIndex;
|
|
|
|
}
|
|
|
|
|
2007-07-08 07:08:04 +00:00
|
|
|
nsListControlFrame* lcf = static_cast<nsListControlFrame*>(mDropdownFrame);
|
2009-02-18 03:27:25 +00:00
|
|
|
return lcf->AddOption(aIndex);
|
1999-08-26 14:54:07 +00: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-14 22:00:24 +00:00
|
|
|
|
1999-08-26 14:54:07 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2009-02-18 03:27:25 +00:00
|
|
|
nsComboboxControlFrame::RemoveOption(PRInt32 aIndex)
|
1999-08-26 14:54:07 +00:00
|
|
|
{
|
2009-10-16 02:49:57 +00:00
|
|
|
nsWeakFrame weakThis(this);
|
2006-03-01 01:00:29 +00:00
|
|
|
if (mListControlFrame->GetNumberOfOptions() > 0) {
|
2005-06-20 23:26:35 +00: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 00:58:31 +00:00
|
|
|
RedisplayText(-1);
|
1999-08-27 03:58:13 +00:00
|
|
|
}
|
2002-07-18 00:58:31 +00:00
|
|
|
|
2009-10-16 02:49:57 +00:00
|
|
|
if (!weakThis.IsAlive())
|
|
|
|
return NS_OK;
|
|
|
|
|
2007-07-08 07:08:04 +00:00
|
|
|
nsListControlFrame* lcf = static_cast<nsListControlFrame*>(mDropdownFrame);
|
2009-02-18 03:27:25 +00:00
|
|
|
return lcf->RemoveOption(aIndex);
|
1999-08-27 03:58:13 +00:00
|
|
|
}
|
|
|
|
|
2005-02-04 22:56:13 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsComboboxControlFrame::OnSetSelectedIndex(PRInt32 aOldIndex, PRInt32 aNewIndex)
|
|
|
|
{
|
2009-02-18 03:27:25 +00:00
|
|
|
nsAutoScriptBlocker scriptBlocker;
|
2007-08-22 03:25:42 +00:00
|
|
|
RedisplayText(aNewIndex);
|
2009-01-09 16:35:24 +00:00
|
|
|
NS_ASSERTION(mDropdownFrame, "No dropdown frame!");
|
2009-01-12 19:20:59 +00:00
|
|
|
|
|
|
|
nsISelectControlFrame* listFrame = do_QueryFrame(mDropdownFrame);
|
2005-02-04 22:56:13 +00:00
|
|
|
NS_ASSERTION(listFrame, "No list frame!");
|
|
|
|
|
|
|
|
return listFrame->OnSetSelectedIndex(aOldIndex, aNewIndex);
|
2000-04-28 23:24:59 +00:00
|
|
|
}
|
|
|
|
|
2001-11-02 07:40:01 +00:00
|
|
|
// End nsISelectControlFrame
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
NS_IMETHODIMP
|
2004-07-31 23:15:21 +00:00
|
|
|
nsComboboxControlFrame::HandleEvent(nsPresContext* aPresContext,
|
1999-07-28 21:38:08 +00:00
|
|
|
nsGUIEvent* aEvent,
|
1999-11-24 06:03:41 +00:00
|
|
|
nsEventStatus* aEventStatus)
|
1999-07-28 21:38:08 +00:00
|
|
|
{
|
1999-11-24 06:03:41 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aEventStatus);
|
2002-05-23 11:25:58 +00:00
|
|
|
|
1999-11-24 06:03:41 +00:00
|
|
|
if (nsEventStatus_eConsumeNoDefault == *aEventStatus) {
|
1999-07-28 21:38:08 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2010-09-19 01:43:15 +00:00
|
|
|
|
2010-10-20 11:26:32 +00:00
|
|
|
nsEventStates eventStates = mContent->IntrinsicState();
|
|
|
|
if (eventStates.HasState(NS_EVENT_STATE_DISABLED)) {
|
1999-08-10 19:25:22 +00:00
|
|
|
return NS_OK;
|
1999-07-28 21:38:08 +00:00
|
|
|
}
|
|
|
|
|
2000-09-07 04:39:02 +00: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 03:42:21 +00:00
|
|
|
const nsStyleUserInterface* uiStyle = GetStyleUserInterface();
|
2000-09-07 04:39:02 +00:00
|
|
|
if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE || uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
|
2008-12-29 15:07:38 +00:00
|
|
|
return nsBlockFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
2000-09-07 04:39:02 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
1999-07-28 21:38:08 +00: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-14 22:00:24 +00:00
|
|
|
|
2005-12-12 23:53:06 +00:00
|
|
|
nsresult
|
|
|
|
nsComboboxControlFrame::SetFormProperty(nsIAtom* aName, const nsAString& aValue)
|
1999-01-25 22:16:27 +00:00
|
|
|
{
|
2009-01-12 19:20:59 +00:00
|
|
|
nsIFormControlFrame* fcFrame = do_QueryFrame(mDropdownFrame);
|
|
|
|
if (!fcFrame) {
|
|
|
|
return NS_NOINTERFACE;
|
1999-04-12 22:14:31 +00:00
|
|
|
}
|
2009-01-12 19:20:59 +00:00
|
|
|
|
|
|
|
return fcFrame->SetFormProperty(aName, aValue);
|
1999-01-25 22:16:27 +00:00
|
|
|
}
|
|
|
|
|
2005-12-12 23:53:06 +00:00
|
|
|
nsresult
|
|
|
|
nsComboboxControlFrame::GetFormProperty(nsIAtom* aName, nsAString& aValue) const
|
1999-03-06 19:43:13 +00:00
|
|
|
{
|
2009-01-12 19:20:59 +00:00
|
|
|
nsIFormControlFrame* fcFrame = do_QueryFrame(mDropdownFrame);
|
|
|
|
if (!fcFrame) {
|
|
|
|
return NS_ERROR_FAILURE;
|
2009-01-09 16:35:24 +00:00
|
|
|
}
|
2009-01-12 19:20:59 +00:00
|
|
|
|
|
|
|
return fcFrame->GetFormProperty(aName, aValue);
|
1999-03-06 19:43:13 +00:00
|
|
|
}
|
|
|
|
|
2004-07-18 12:02:53 +00:00
|
|
|
nsIFrame*
|
|
|
|
nsComboboxControlFrame::GetContentInsertionFrame() {
|
2005-02-19 23:54:36 +00:00
|
|
|
return mInRedisplayText ? mDisplayFrame : mDropdownFrame->GetContentInsertionFrame();
|
2004-07-18 12:02:53 +00: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-14 22:00:24 +00:00
|
|
|
|
2007-02-18 17:34:09 +00:00
|
|
|
nsresult
|
2011-05-06 20:04:44 +00:00
|
|
|
nsComboboxControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00: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 14:13:20 +00:00
|
|
|
//nsIAtom* tag = NS_NewAtom("mozcombodisplay");
|
2000-02-15 15:04:38 +00:00
|
|
|
|
2000-03-07 15:54:31 +00:00
|
|
|
// Add a child text content node for the label
|
2004-08-10 10:22:36 +00:00
|
|
|
|
2005-09-24 18:43:15 +00:00
|
|
|
nsNodeInfoManager *nimgr = mContent->NodeInfo()->NodeInfoManager();
|
|
|
|
|
2007-02-18 17:34:09 +00:00
|
|
|
NS_NewTextNode(getter_AddRefs(mDisplayContent), nimgr);
|
|
|
|
if (!mDisplayContent)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2004-08-10 10:22:36 +00:00
|
|
|
|
2007-02-18 17:34:09 +00:00
|
|
|
// set the value of the text node
|
|
|
|
mDisplayedIndex = mListControlFrame->GetSelectedIndex();
|
|
|
|
if (mDisplayedIndex != -1) {
|
|
|
|
mListControlFrame->GetOptionText(mDisplayedIndex, mDisplayedOptionText);
|
|
|
|
}
|
|
|
|
ActuallyDisplayText(PR_FALSE);
|
2000-03-07 15:54:31 +00:00
|
|
|
|
2007-02-18 17:34:09 +00:00
|
|
|
if (!aElements.AppendElement(mDisplayContent))
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2000-05-10 13:13:39 +00:00
|
|
|
|
2007-02-18 17:34:09 +00:00
|
|
|
nsCOMPtr<nsINodeInfo> nodeInfo;
|
2011-03-26 01:05:56 +00:00
|
|
|
nodeInfo = nimgr->GetNodeInfo(nsGkAtoms::button, nsnull, kNameSpaceID_XHTML);
|
2000-03-07 15:54:31 +00:00
|
|
|
|
2007-02-18 17:34:09 +00:00
|
|
|
// create button which drops the list down
|
2010-07-23 09:49:57 +00:00
|
|
|
NS_NewHTMLElement(getter_AddRefs(mButtonContent), nodeInfo.forget(),
|
2010-10-25 12:17:38 +00:00
|
|
|
dom::NOT_FROM_PARSER);
|
2007-02-18 17:34:09 +00:00
|
|
|
if (!mButtonContent)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2004-06-25 12:26:02 +00:00
|
|
|
|
2007-02-18 17:34:09 +00: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 09:11:38 +00:00
|
|
|
mButtonListener = new nsComboButtonListener(this);
|
|
|
|
mButtonContent->AddEventListenerByIID(mButtonListener,
|
|
|
|
NS_GET_IID(nsIDOMMouseListener));
|
2004-06-25 12:26:02 +00:00
|
|
|
|
2007-02-18 17:34:09 +00: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 12:26:02 +00:00
|
|
|
|
2007-02-18 17:34:09 +00: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-14 22:00:24 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-02-11 17:34:01 +00:00
|
|
|
void
|
2010-10-15 15:34:35 +00:00
|
|
|
nsComboboxControlFrame::AppendAnonymousContentTo(nsBaseContentList& aElements,
|
|
|
|
PRUint32 aFilter)
|
2010-02-11 17:34:01 +00:00
|
|
|
{
|
|
|
|
aElements.MaybeAppendElement(mDisplayContent);
|
|
|
|
aElements.MaybeAppendElement(mButtonContent);
|
|
|
|
}
|
|
|
|
|
2007-02-18 23:53:25 +00: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 05:38:33 +00:00
|
|
|
class nsComboboxDisplayFrame : public nsBlockFrame {
|
|
|
|
public:
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsComboboxDisplayFrame (nsStyleContext* aContext,
|
|
|
|
nsComboboxControlFrame* aComboBox)
|
|
|
|
: nsBlockFrame(aContext),
|
|
|
|
mComboBox(aComboBox)
|
|
|
|
{}
|
|
|
|
|
2007-02-28 03:04:38 +00: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 18:33:33 +00: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 05:38:33 +00:00
|
|
|
|
|
|
|
NS_IMETHOD Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
|
|
|
|
2007-05-22 19:42:01 +00: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 05:38:33 +00:00
|
|
|
protected:
|
|
|
|
nsComboboxControlFrame* mComboBox;
|
|
|
|
};
|
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsComboboxDisplayFrame)
|
|
|
|
|
2007-02-28 03:04:38 +00: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 05:38:33 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsComboboxDisplayFrame::Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
nsHTMLReflowState state(aReflowState);
|
2007-08-02 18:08:05 +00: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 05:38:33 +00: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 18:08:05 +00: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 05:38:33 +00:00
|
|
|
}
|
2007-01-26 00:05:12 +00: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 05:38:33 +00:00
|
|
|
}
|
2007-01-26 00:05:12 +00: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 05:38:33 +00:00
|
|
|
|
|
|
|
return nsBlockFrame::Reflow(aPresContext, aDesiredSize, state, aStatus);
|
|
|
|
}
|
|
|
|
|
2007-05-22 19:42:01 +00: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 17:34:09 +00:00
|
|
|
nsIFrame*
|
|
|
|
nsComboboxControlFrame::CreateFrameFor(nsIContent* aContent)
|
2000-04-19 13:55:17 +00:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aContent, "null ptr");
|
|
|
|
|
2005-12-11 20:45:58 +00:00
|
|
|
NS_ASSERTION(mDisplayContent, "mDisplayContent can't be null!");
|
2000-04-19 13:55:17 +00:00
|
|
|
|
2006-07-19 08:55:36 +00:00
|
|
|
if (mDisplayContent != aContent) {
|
2005-12-11 20:45:58 +00:00
|
|
|
// We only handle the frames for mDisplayContent here
|
2007-02-18 17:34:09 +00:00
|
|
|
return nsnull;
|
2000-04-19 13:55:17 +00:00
|
|
|
}
|
2005-12-11 20:45:58 +00:00
|
|
|
|
|
|
|
// Get PresShell
|
2007-03-30 21:11:41 +00:00
|
|
|
nsIPresShell *shell = PresContext()->PresShell();
|
2005-12-11 20:45:58 +00:00
|
|
|
nsStyleSet *styleSet = shell->StyleSet();
|
2000-04-19 13:55:17 +00:00
|
|
|
|
2005-12-11 20:45:58 +00:00
|
|
|
// create the style contexts for the anonymous block frame and text frame
|
|
|
|
nsRefPtr<nsStyleContext> styleContext;
|
|
|
|
styleContext = styleSet->
|
2009-12-11 07:37:40 +00:00
|
|
|
ResolveAnonymousBoxStyle(nsCSSAnonBoxes::mozDisplayComboboxControlFrame,
|
|
|
|
mStyleContext);
|
2005-12-11 20:45:58 +00:00
|
|
|
if (NS_UNLIKELY(!styleContext)) {
|
2007-02-18 17:34:09 +00:00
|
|
|
return nsnull;
|
2005-12-11 20:45:58 +00:00
|
|
|
}
|
2005-11-04 02:38:33 +00:00
|
|
|
|
2005-12-11 20:45:58 +00:00
|
|
|
nsRefPtr<nsStyleContext> textStyleContext;
|
2007-06-16 05:11:20 +00:00
|
|
|
textStyleContext = styleSet->ResolveStyleForNonElement(mStyleContext);
|
2005-12-11 20:45:58 +00:00
|
|
|
if (NS_UNLIKELY(!textStyleContext)) {
|
2007-02-18 17:34:09 +00:00
|
|
|
return nsnull;
|
2005-12-11 20:45:58 +00:00
|
|
|
}
|
2000-04-19 13:55:17 +00:00
|
|
|
|
2005-12-11 20:45:58 +00:00
|
|
|
// Start by by creating our anonymous block frame
|
2007-02-18 23:53:25 +00:00
|
|
|
mDisplayFrame = new (shell) nsComboboxDisplayFrame(styleContext, this);
|
2005-12-11 20:45:58 +00:00
|
|
|
if (NS_UNLIKELY(!mDisplayFrame)) {
|
2007-02-18 17:34:09 +00:00
|
|
|
return nsnull;
|
2005-12-11 20:45:58 +00:00
|
|
|
}
|
2000-04-19 13:55:17 +00:00
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
nsresult rv = mDisplayFrame->Init(mContent, this, nsnull);
|
2005-12-11 20:45:58 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
2006-04-10 00:16:29 +00:00
|
|
|
mDisplayFrame->Destroy();
|
2005-12-11 20:45:58 +00:00
|
|
|
mDisplayFrame = nsnull;
|
2007-02-18 17:34:09 +00:00
|
|
|
return nsnull;
|
2005-12-11 20:45:58 +00:00
|
|
|
}
|
2000-04-19 13:55:17 +00:00
|
|
|
|
2005-12-11 20:45:58 +00:00
|
|
|
// Create a text frame and put it inside the block frame
|
2010-05-13 00:56:11 +00:00
|
|
|
nsIFrame* textFrame = NS_NewTextFrame(shell, textStyleContext);
|
|
|
|
if (NS_UNLIKELY(!textFrame)) {
|
2007-02-18 17:34:09 +00:00
|
|
|
return nsnull;
|
2005-12-11 20:45:58 +00:00
|
|
|
}
|
2000-04-19 13:55:17 +00:00
|
|
|
|
2005-12-11 20:45:58 +00:00
|
|
|
// initialize the text frame
|
2010-05-13 00:56:11 +00:00
|
|
|
rv = textFrame->Init(aContent, mDisplayFrame, nsnull);
|
2005-12-11 20:45:58 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
2006-04-10 00:16:29 +00:00
|
|
|
mDisplayFrame->Destroy();
|
2005-12-11 20:45:58 +00:00
|
|
|
mDisplayFrame = nsnull;
|
2010-05-13 00:56:11 +00:00
|
|
|
textFrame->Destroy();
|
|
|
|
textFrame = nsnull;
|
2007-02-18 17:34:09 +00:00
|
|
|
return nsnull;
|
2000-04-19 13:55:17 +00:00
|
|
|
}
|
2010-05-13 00:56:11 +00:00
|
|
|
mDisplayContent->SetPrimaryFrame(textFrame);
|
2000-04-19 13:55:17 +00:00
|
|
|
|
2010-05-13 00:56:11 +00:00
|
|
|
nsFrameList textList(textFrame, textFrame);
|
2009-07-28 12:53:20 +00:00
|
|
|
mDisplayFrame->SetInitialChildList(nsnull, textList);
|
2007-02-18 17:34:09 +00:00
|
|
|
return mDisplayFrame;
|
2000-04-19 13:55:17 +00:00
|
|
|
}
|
|
|
|
|
2006-04-10 00:16:29 +00:00
|
|
|
void
|
2009-12-24 05:21:15 +00:00
|
|
|
nsComboboxControlFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
{
|
2006-05-10 17:30:15 +00:00
|
|
|
// Revoke any pending RedisplayTextEvent
|
|
|
|
mRedisplayTextEvent.Revoke();
|
2005-03-21 01:58:17 +00:00
|
|
|
|
2007-07-08 07:08:04 +00:00
|
|
|
nsFormControlFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), PR_FALSE);
|
2000-08-03 14:13:40 +00:00
|
|
|
|
2000-03-28 14:29:15 +00:00
|
|
|
if (mDroppedDown) {
|
|
|
|
// Get parent view
|
2009-01-12 19:20:59 +00:00
|
|
|
nsIFrame * listFrame = do_QueryFrame(mListControlFrame);
|
|
|
|
if (listFrame) {
|
2003-07-04 12:50:32 +00:00
|
|
|
nsIView* view = listFrame->GetView();
|
|
|
|
NS_ASSERTION(view, "nsComboboxControlFrame view is null");
|
2000-03-28 14:29:15 +00:00
|
|
|
if (view) {
|
2007-02-18 17:34:09 +00:00
|
|
|
nsIWidget* widget = view->GetWidget();
|
2000-03-28 14:29:15 +00:00
|
|
|
if (widget)
|
2009-12-22 23:49:33 +00:00
|
|
|
widget->CaptureRollupEvents(this, nsnull, PR_FALSE, PR_TRUE);
|
2000-03-28 14:29:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-20 20:28:02 +00:00
|
|
|
// Cleanup frames in popup child list
|
2009-12-24 05:21:15 +00:00
|
|
|
mPopupFrames.DestroyFramesFrom(aDestructRoot);
|
2007-02-18 17:34:09 +00:00
|
|
|
nsContentUtils::DestroyAnonymousContent(&mDisplayContent);
|
|
|
|
nsContentUtils::DestroyAnonymousContent(&mButtonContent);
|
2009-12-24 05:21:15 +00:00
|
|
|
nsBlockFrame::DestroyFrom(aDestructRoot);
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-28 12:51:09 +00:00
|
|
|
nsFrameList
|
|
|
|
nsComboboxControlFrame::GetChildList(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-14 22:00:24 +00:00
|
|
|
{
|
2007-08-10 12:42:06 +00:00
|
|
|
if (nsGkAtoms::selectPopupList == aListName) {
|
2009-07-28 12:51:09 +00:00
|
|
|
return mPopupFrames;
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
}
|
2009-07-28 12:51:09 +00:00
|
|
|
return nsBlockFrame::GetChildList(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-14 22:00:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2006-04-10 00:16:29 +00:00
|
|
|
nsComboboxControlFrame::SetInitialChildList(nsIAtom* aListName,
|
2009-07-28 12:53:20 +00:00
|
|
|
nsFrameList& aChildList)
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
2007-08-10 12:42:06 +00: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-14 22:00:24 +00:00
|
|
|
mPopupFrames.SetFrames(aChildList);
|
|
|
|
} else {
|
2009-07-28 12:53:20 +00:00
|
|
|
for (nsFrameList::Enumerator e(aChildList); !e.AtEnd(); e.Next()) {
|
|
|
|
nsCOMPtr<nsIFormControl> formControl =
|
|
|
|
do_QueryInterface(e.get()->GetContent());
|
2011-03-26 01:05:56 +00:00
|
|
|
if (formControl && formControl->GetType() == NS_FORM_BUTTON_BUTTON) {
|
2009-07-28 12:53:20 +00:00
|
|
|
mButtonFrame = e.get();
|
2005-12-08 19:01:20 +00:00
|
|
|
break;
|
2000-04-19 13:55:17 +00:00
|
|
|
}
|
|
|
|
}
|
2005-12-08 19:01:20 +00:00
|
|
|
NS_ASSERTION(mButtonFrame, "missing button frame in initial child list");
|
2009-07-28 12:53:20 +00:00
|
|
|
rv = nsBlockFrame::SetInitialChildList(aListName, 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-14 22:00:24 +00:00
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2007-07-26 04:03:29 +00:00
|
|
|
#define NS_COMBO_FRAME_POPUP_LIST_INDEX (NS_BLOCK_LIST_COUNT)
|
|
|
|
|
2004-01-09 14:20:53 +00: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-14 22:00:24 +00:00
|
|
|
{
|
2003-03-24 04:15:34 +00: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-14 22:00:24 +00: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 04:03:29 +00:00
|
|
|
if (aIndex < NS_BLOCK_LIST_COUNT) {
|
2008-12-29 15:07:38 +00:00
|
|
|
return nsBlockFrame::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-14 22:00:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_COMBO_FRAME_POPUP_LIST_INDEX == aIndex) {
|
2007-08-10 12:42:06 +00: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-14 22:00:24 +00:00
|
|
|
}
|
2004-01-09 14:20:53 +00: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-14 22:00:24 +00:00
|
|
|
}
|
|
|
|
|
1999-09-21 21:20:50 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
//nsIRollupListener
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
2009-06-12 18:23:16 +00:00
|
|
|
nsComboboxControlFrame::Rollup(PRUint32 aCount,
|
|
|
|
nsIContent** aLastRolledUp)
|
1999-09-21 21:20:50 +00:00
|
|
|
{
|
2007-12-03 16:33:42 +00:00
|
|
|
if (aLastRolledUp)
|
|
|
|
*aLastRolledUp = nsnull;
|
|
|
|
|
1999-09-21 21:20:50 +00:00
|
|
|
if (mDroppedDown) {
|
2007-05-17 11:12:30 +00: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 01:00:29 +00:00
|
|
|
mListControlFrame->CaptureMouseEvents(PR_FALSE);
|
1999-09-21 21:20:50 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-02-18 01:52:03 +00:00
|
|
|
void
|
|
|
|
nsComboboxControlFrame::RollupFromList()
|
2002-01-25 23:35:44 +00:00
|
|
|
{
|
2009-09-02 02:46:47 +00:00
|
|
|
if (ShowList(PR_FALSE))
|
2007-05-17 11:12:30 +00:00
|
|
|
mListControlFrame->CaptureMouseEvents(PR_FALSE);
|
2002-01-25 23:35:44 +00:00
|
|
|
}
|
|
|
|
|
2006-02-18 01:52:03 +00:00
|
|
|
PRInt32
|
2004-07-23 08:25:44 +00:00
|
|
|
nsComboboxControlFrame::UpdateRecentIndex(PRInt32 aIndex)
|
2002-02-08 18:35:48 +00:00
|
|
|
{
|
2004-07-23 08:25:44 +00:00
|
|
|
PRInt32 index = mRecentSelectedIndex;
|
2006-09-30 05:07:49 +00:00
|
|
|
if (mRecentSelectedIndex == NS_SKIP_NOTIFY_INDEX || aIndex == NS_SKIP_NOTIFY_INDEX)
|
2004-07-23 08:25:44 +00:00
|
|
|
mRecentSelectedIndex = aIndex;
|
|
|
|
return index;
|
2002-02-08 18:35:48 +00:00
|
|
|
}
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
class nsDisplayComboboxFocus : public nsDisplayItem {
|
|
|
|
public:
|
2010-08-13 10:01:13 +00:00
|
|
|
nsDisplayComboboxFocus(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsComboboxControlFrame* aFrame)
|
|
|
|
: nsDisplayItem(aBuilder, aFrame) {
|
2006-01-29 18:48:58 +00:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayComboboxFocus);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayComboboxFocus() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayComboboxFocus);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-07 00:35:14 +00:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
2011-04-08 01:04:40 +00:00
|
|
|
nsRenderingContext* aCtx);
|
2010-07-15 21:07:49 +00:00
|
|
|
NS_DISPLAY_DECL_NAME("ComboboxFocus", TYPE_COMBOBOX_FOCUS)
|
2006-01-26 02:29:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void nsDisplayComboboxFocus::Paint(nsDisplayListBuilder* aBuilder,
|
2011-04-08 01:04:40 +00:00
|
|
|
nsRenderingContext* aCtx)
|
2006-01-26 02:29:17 +00:00
|
|
|
{
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsComboboxControlFrame*>(mFrame)
|
2010-08-13 10:01:58 +00:00
|
|
|
->PaintFocus(*aCtx, ToReferenceFrame());
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsComboboxControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
2000-03-07 15:54:31 +00:00
|
|
|
{
|
|
|
|
#ifdef NOISY
|
2006-01-26 02:29:17 +00:00
|
|
|
printf("%p paint at (%d, %d, %d, %d)\n", this,
|
2000-10-28 22:17:53 +00:00
|
|
|
aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height);
|
2000-03-07 15:54:31 +00:00
|
|
|
#endif
|
2006-01-26 02:29:17 +00: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.
|
2008-12-29 15:07:38 +00:00
|
|
|
nsresult rv = nsBlockFrame::BuildDisplayList(aBuilder, aDirtyRect, aLists);
|
2006-01-26 02:29:17 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2000-03-07 15:54:31 +00:00
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
|
2010-04-21 14:53:42 +00:00
|
|
|
// draw a focus indicator only when focus rings should be drawn
|
|
|
|
nsIDocument* doc = mContent->GetCurrentDoc();
|
|
|
|
if (doc) {
|
|
|
|
nsPIDOMWindow* window = doc->GetWindow();
|
|
|
|
if (window && window->ShouldShowFocusRing()) {
|
|
|
|
nsPresContext *presContext = PresContext();
|
|
|
|
const nsStyleDisplay *disp = GetStyleDisplay();
|
|
|
|
if ((!IsThemed(disp) ||
|
|
|
|
!presContext->GetTheme()->ThemeDrawsFocusForWidget(presContext, this, disp->mAppearance)) &&
|
|
|
|
mDisplayFrame && IsVisibleForPainting(aBuilder)) {
|
2010-08-13 10:01:13 +00:00
|
|
|
nsresult rv = aLists.Content()->AppendNewToTop(
|
|
|
|
new (aBuilder) nsDisplayComboboxFocus(aBuilder, this));
|
2010-04-21 14:53:42 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
|
|
|
|
2010-09-09 15:21:46 +00:00
|
|
|
return DisplaySelectionOverlay(aBuilder, aLists.Content());
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
|
|
|
|
2011-04-08 01:04:40 +00:00
|
|
|
void nsComboboxControlFrame::PaintFocus(nsRenderingContext& aRenderingContext,
|
2008-04-29 03:55:07 +00:00
|
|
|
nsPoint aPt)
|
|
|
|
{
|
|
|
|
/* Do we need to do anything? */
|
2010-10-20 11:26:32 +00:00
|
|
|
nsEventStates eventStates = mContent->IntrinsicState();
|
|
|
|
if (eventStates.HasState(NS_EVENT_STATE_DISABLED) || mFocused != this)
|
2008-04-29 03:55:07 +00:00
|
|
|
return;
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
aRenderingContext.PushState();
|
|
|
|
nsRect clipRect = mDisplayFrame->GetRect() + aPt;
|
2011-04-08 01:04:40 +00:00
|
|
|
aRenderingContext.IntersectClip(clipRect);
|
2006-01-26 02:29:17 +00:00
|
|
|
|
|
|
|
// REVIEW: Why does the old code paint mDisplayFrame again? We've
|
|
|
|
// already painted it in the children above. So clipping it here won't do
|
|
|
|
// us much good.
|
|
|
|
|
|
|
|
/////////////////////
|
|
|
|
// draw focus
|
2008-04-29 03:55:07 +00:00
|
|
|
|
|
|
|
aRenderingContext.SetLineStyle(nsLineStyle_kDotted);
|
|
|
|
aRenderingContext.SetColor(GetStyleColor()->mColor);
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
//aRenderingContext.DrawRect(clipRect);
|
2008-04-29 03:55:07 +00:00
|
|
|
|
2007-02-07 07:46:44 +00:00
|
|
|
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
|
2006-01-26 02:29:17 +00:00
|
|
|
clipRect.width -= onePixel;
|
|
|
|
clipRect.height -= onePixel;
|
2011-04-08 01:04:39 +00:00
|
|
|
aRenderingContext.DrawLine(clipRect.TopLeft(), clipRect.TopRight());
|
|
|
|
aRenderingContext.DrawLine(clipRect.TopRight(), clipRect.BottomRight());
|
|
|
|
aRenderingContext.DrawLine(clipRect.BottomRight(), clipRect.BottomLeft());
|
|
|
|
aRenderingContext.DrawLine(clipRect.BottomLeft(), clipRect.TopLeft());
|
2006-01-26 02:29:17 +00:00
|
|
|
|
|
|
|
aRenderingContext.PopState();
|
2000-03-07 15:54:31 +00:00
|
|
|
}
|
|
|
|
|
2001-11-02 07:40:01 +00:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// gets the content (an option) by index and then set it as
|
|
|
|
// being selected or not selected
|
|
|
|
//---------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
2009-02-18 03:27:25 +00:00
|
|
|
nsComboboxControlFrame::OnOptionSelected(PRInt32 aIndex, PRBool aSelected)
|
2001-11-02 07:40:01 +00:00
|
|
|
{
|
2003-03-14 06:18:20 +00:00
|
|
|
if (mDroppedDown) {
|
2009-01-12 19:20:59 +00:00
|
|
|
nsISelectControlFrame *selectFrame = do_QueryFrame(mListControlFrame);
|
2003-03-14 06:18:20 +00:00
|
|
|
if (selectFrame) {
|
2009-02-18 03:27:25 +00:00
|
|
|
selectFrame->OnOptionSelected(aIndex, aSelected);
|
2003-03-14 06:18:20 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (aSelected) {
|
2009-02-18 03:27:25 +00:00
|
|
|
nsAutoScriptBlocker blocker;
|
2002-01-25 23:35:44 +00:00
|
|
|
RedisplayText(aIndex);
|
|
|
|
} else {
|
2009-02-18 03:27:25 +00:00
|
|
|
nsWeakFrame weakFrame(this);
|
2003-03-14 06:18:20 +00:00
|
|
|
RedisplaySelectedText();
|
2009-02-18 03:27:25 +00:00
|
|
|
if (weakFrame.IsAlive()) {
|
|
|
|
FireValueChangeEvent(); // Fire after old option is unselected
|
|
|
|
}
|
2002-01-25 23:35:44 +00:00
|
|
|
}
|
2001-11-02 07:40:01 +00:00
|
|
|
}
|
2003-03-14 06:18:20 +00:00
|
|
|
|
2001-11-02 07:40:01 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-02-07 23:11:30 +00:00
|
|
|
void nsComboboxControlFrame::FireValueChangeEvent()
|
|
|
|
{
|
|
|
|
// Fire ValueChange event to indicate data value of combo box has changed
|
2010-02-25 02:45:43 +00:00
|
|
|
nsContentUtils::AddScriptRunner(
|
|
|
|
new nsPLDOMEvent(mContent, NS_LITERAL_STRING("ValueChange"), PR_TRUE,
|
|
|
|
PR_FALSE));
|
2005-02-07 23:11:30 +00:00
|
|
|
}
|
|
|
|
|
2005-12-12 23:53:06 +00:00
|
|
|
void
|
2001-11-02 07:40:01 +00:00
|
|
|
nsComboboxControlFrame::OnContentReset()
|
|
|
|
{
|
|
|
|
if (mListControlFrame) {
|
2005-12-12 23:53:06 +00:00
|
|
|
mListControlFrame->OnContentReset();
|
2001-11-02 07:40:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------
|
|
|
|
// nsIStatefulFrame
|
|
|
|
//--------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
2005-12-06 23:56:17 +00:00
|
|
|
nsComboboxControlFrame::SaveState(SpecialStateID aStateID,
|
2005-01-27 22:52:53 +00:00
|
|
|
nsPresState** aState)
|
2001-11-02 07:40:01 +00:00
|
|
|
{
|
2005-12-06 23:56:17 +00:00
|
|
|
if (!mListControlFrame)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2009-01-12 19:20:59 +00:00
|
|
|
nsIStatefulFrame* stateful = do_QueryFrame(mListControlFrame);
|
2005-12-06 23:56:17 +00:00
|
|
|
return stateful->SaveState(aStateID, aState);
|
2001-11-02 07:40:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2005-12-06 23:56:17 +00:00
|
|
|
nsComboboxControlFrame::RestoreState(nsPresState* aState)
|
2001-11-02 07:40:01 +00:00
|
|
|
{
|
2002-01-11 20:10:46 +00:00
|
|
|
if (!mListControlFrame)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2009-01-12 19:20:59 +00:00
|
|
|
nsIStatefulFrame* stateful = do_QueryFrame(mListControlFrame);
|
|
|
|
NS_ASSERTION(stateful, "Must implement nsIStatefulFrame");
|
|
|
|
return stateful->RestoreState(aState);
|
2001-11-02 07:40:01 +00:00
|
|
|
}
|
2005-02-16 05:13:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
//
|
2006-01-11 19:09:20 +00:00
|
|
|
// Camino uses a native widget for the combobox
|
|
|
|
// popup, which affects drawing and event
|
2005-02-16 05:13:16 +00:00
|
|
|
// handling here and in nsListControlFrame.
|
2009-07-06 13:39:54 +00:00
|
|
|
//
|
|
|
|
// Also, Fennec use a custom combobox built-in widget
|
2005-02-16 05:13:16 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
/* static */
|
|
|
|
PRBool
|
|
|
|
nsComboboxControlFrame::ToolkitHasNativePopup()
|
|
|
|
{
|
2007-03-30 19:51:51 +00:00
|
|
|
return nsContentUtils::GetBoolPref("ui.use_native_popup_windows");
|
2005-02-16 05:13:16 +00:00
|
|
|
}
|
|
|
|
|