2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:30:37 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-01-18 18:14:00 +03:00
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1999-01-18 18:14:00 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1999-01-18 18:14:00 +03:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
2000-02-03 01:24:56 +03:00
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
2005-03-21 04:58:17 +03:00
|
|
|
* Mats Palmgren <mats.palmgren@bredband.net>
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 18:30:37 +04:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-29 00:14:13 +04:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 18:30:37 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 18:30:37 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-02-12 20:45:58 +03:00
|
|
|
#include "nsCOMPtr.h"
|
2001-09-29 12:28:41 +04:00
|
|
|
#include "nsReadableUtils.h"
|
1999-01-18 18:14:00 +03:00
|
|
|
#include "nsComboboxControlFrame.h"
|
2001-06-30 04:25:09 +04:00
|
|
|
#include "nsIDOMEventReceiver.h"
|
2004-02-24 00:29:06 +03:00
|
|
|
#include "nsFrameManager.h"
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
#include "nsFormControlFrame.h"
|
2005-12-13 02:53:06 +03:00
|
|
|
#include "nsGfxButtonControlFrame.h"
|
1999-01-18 18:14:00 +03:00
|
|
|
#include "nsHTMLAtoms.h"
|
2002-11-17 18:37:56 +03:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
1999-01-18 18:14:00 +03:00
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsIFormControl.h"
|
|
|
|
#include "nsINameSpaceManager.h"
|
2002-01-09 22:17:46 +03:00
|
|
|
#include "nsLayoutAtoms.h"
|
1999-01-18 18:14:00 +03:00
|
|
|
#include "nsIDOMElement.h"
|
|
|
|
#include "nsIListControlFrame.h"
|
1999-04-13 02:14:31 +04:00
|
|
|
#include "nsIDOMHTMLCollection.h"
|
|
|
|
#include "nsIDOMHTMLSelectElement.h"
|
|
|
|
#include "nsIDOMHTMLOptionElement.h"
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
#include "nsIDOMNSHTMLOptionCollectn.h"
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsIDeviceContext.h"
|
|
|
|
#include "nsIView.h"
|
1999-07-29 01:38:08 +04:00
|
|
|
#include "nsIScrollableView.h"
|
1999-08-06 18:13:20 +04:00
|
|
|
#include "nsIEventStateManager.h"
|
2005-02-08 02:11:30 +03:00
|
|
|
#include "nsIEventListenerManager.h"
|
1999-09-07 06:16:23 +04:00
|
|
|
#include "nsIDOMNode.h"
|
|
|
|
#include "nsIPrivateDOMEvent.h"
|
1999-09-15 09:31:31 +04:00
|
|
|
#include "nsISupportsArray.h"
|
|
|
|
#include "nsISelectControlFrame.h"
|
2002-09-04 03:36:13 +04:00
|
|
|
#include "nsXPCOM.h"
|
1999-09-15 09:31:31 +04:00
|
|
|
#include "nsISupportsPrimitives.h"
|
|
|
|
#include "nsIComponentManager.h"
|
2000-03-07 18:54:31 +03:00
|
|
|
#include "nsITextContent.h"
|
|
|
|
#include "nsTextFragment.h"
|
|
|
|
#include "nsCSSFrameConstructor.h"
|
|
|
|
#include "nsIDocument.h"
|
2000-05-10 17:13:39 +04:00
|
|
|
#include "nsINodeInfo.h"
|
2000-04-19 17:55:17 +04:00
|
|
|
#include "nsIScrollableFrame.h"
|
2001-02-23 04:45:45 +03:00
|
|
|
#include "nsListControlFrame.h"
|
2001-02-20 00:50:04 +03:00
|
|
|
#include "nsContentCID.h"
|
2001-08-17 07:13:07 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2001-04-01 05:01:33 +04:00
|
|
|
#include "nsIAccessibilityService.h"
|
2001-08-17 07:13:07 +04:00
|
|
|
#endif
|
2001-04-01 05:01:33 +04:00
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIDOMNode.h"
|
2001-07-16 06:40:48 +04:00
|
|
|
#include "nsGUIEvent.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsAutoPtr.h"
|
2004-01-28 03:18:22 +03:00
|
|
|
#include "nsStyleSet.h"
|
2004-06-25 16:26:02 +04:00
|
|
|
#include "nsNodeInfoManager.h"
|
|
|
|
#include "nsContentCreatorFunctions.h"
|
2001-04-01 05:01:33 +04:00
|
|
|
|
2003-04-11 04:56:27 +04:00
|
|
|
#ifdef MOZ_XUL
|
2000-05-09 00:32:11 +04:00
|
|
|
#include "nsIXULDocument.h" // Temporary fix for Bug 36558
|
2003-04-11 04:56:27 +04:00
|
|
|
#endif
|
2000-05-09 00:32:11 +04:00
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
#ifdef DO_NEW_REFLOW
|
|
|
|
#include "nsIFontMetrics.h"
|
|
|
|
#endif
|
|
|
|
|
2005-03-21 04:58:17 +03:00
|
|
|
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
|
|
|
|
|
|
|
class RedisplayTextEvent : public PLEvent
|
|
|
|
{
|
|
|
|
public:
|
2005-06-21 04:00:14 +04:00
|
|
|
RedisplayTextEvent(nsComboboxControlFrame* aComboboxControlFrame);
|
2005-03-21 04:58:17 +03:00
|
|
|
|
|
|
|
void HandleEvent()
|
|
|
|
{
|
|
|
|
NS_STATIC_CAST(nsComboboxControlFrame*, owner) ->
|
2005-06-21 04:00:14 +04:00
|
|
|
HandleRedisplayTextEvent();
|
2005-03-21 04:58:17 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
PR_STATIC_CALLBACK(void*)
|
|
|
|
HandleRedisplayTextPLEvent(PLEvent* aEvent)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(nsnull != aEvent, "Event is null");
|
|
|
|
RedisplayTextEvent* event = NS_STATIC_CAST(RedisplayTextEvent*, aEvent);
|
|
|
|
|
|
|
|
event->HandleEvent();
|
|
|
|
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
PR_STATIC_CALLBACK(void)
|
|
|
|
DestroyRedisplayTextPLEvent(PLEvent* aEvent)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(nsnull != aEvent, "Event is null");
|
|
|
|
RedisplayTextEvent* event = NS_STATIC_CAST(RedisplayTextEvent*, aEvent);
|
|
|
|
|
|
|
|
delete event;
|
|
|
|
}
|
|
|
|
|
2005-06-21 04:00:14 +04:00
|
|
|
RedisplayTextEvent::RedisplayTextEvent(nsComboboxControlFrame* aComboboxControlFrame)
|
2005-03-21 04:58:17 +03:00
|
|
|
{
|
|
|
|
PL_InitEvent(this, aComboboxControlFrame,
|
|
|
|
::HandleRedisplayTextPLEvent,
|
|
|
|
::DestroyRedisplayTextPLEvent);
|
|
|
|
}
|
|
|
|
|
2005-01-28 01:52:53 +03:00
|
|
|
class nsPresState;
|
1999-01-18 18:14:00 +03:00
|
|
|
|
2000-12-20 18:09:00 +03:00
|
|
|
#define FIX_FOR_BUG_53259
|
|
|
|
|
1999-05-28 01:17:10 +04:00
|
|
|
// Drop down list event management.
|
2000-03-07 18:54:31 +03:00
|
|
|
// The combo box uses the following strategy for managing the drop-down list.
|
1999-05-28 01:17:10 +04:00
|
|
|
// If the combo box or it's arrow button is clicked on the drop-down list is displayed
|
|
|
|
// If mouse exit's the combo box with the drop-down list displayed the drop-down list
|
|
|
|
// is asked to capture events
|
|
|
|
// The drop-down list will capture all events including mouse down and up and will always
|
|
|
|
// return with ListWasSelected method call regardless of whether an item in the list was
|
|
|
|
// actually selected.
|
|
|
|
// The ListWasSelected code will turn off mouse-capture for the drop-down list.
|
|
|
|
// The drop-down list does not explicitly set capture when it is in the drop-down mode.
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
|
2004-12-20 00:45:51 +03:00
|
|
|
//XXX: This is temporary. It simulates pseudo states by using a attribute selector on
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
const PRInt32 kSizeNotSet = -1;
|
|
|
|
|
2001-06-30 04:25:09 +04:00
|
|
|
/**
|
|
|
|
* Helper class that listens to the combo boxes button. If the button is pressed the
|
|
|
|
* combo box is toggled to open or close. this is used by Accessibility which presses
|
|
|
|
* that button Programmatically.
|
|
|
|
*/
|
|
|
|
class nsComboButtonListener: public nsIDOMMouseListener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_IMETHOD HandleEvent(nsIDOMEvent* anEvent) { return PR_FALSE; }
|
|
|
|
NS_IMETHOD MouseDown(nsIDOMEvent* aMouseEvent) { return PR_FALSE; }
|
|
|
|
NS_IMETHOD MouseUp(nsIDOMEvent* aMouseEvent) { return PR_FALSE; }
|
|
|
|
NS_IMETHOD MouseDblClick(nsIDOMEvent* aMouseEvent) { return PR_FALSE; }
|
|
|
|
NS_IMETHOD MouseOver(nsIDOMEvent* aMouseEvent) { return PR_FALSE; }
|
|
|
|
NS_IMETHOD MouseOut(nsIDOMEvent* aMouseEvent) { return PR_FALSE; }
|
|
|
|
|
|
|
|
NS_IMETHOD MouseClick(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
|
|
|
PRBool isDroppedDown;
|
|
|
|
mComboBox->IsDroppedDown(&isDroppedDown);
|
|
|
|
mComboBox->ShowDropDown(!isDroppedDown);
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsComboButtonListener(nsComboboxControlFrame* aCombobox)
|
|
|
|
{
|
|
|
|
mComboBox = aCombobox;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~nsComboButtonListener() {}
|
|
|
|
|
|
|
|
nsComboboxControlFrame* mComboBox;
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS1(nsComboButtonListener, nsIDOMMouseListener)
|
|
|
|
|
2000-10-04 17:39:07 +04:00
|
|
|
// static class data member for Bug 32920
|
|
|
|
nsComboboxControlFrame * nsComboboxControlFrame::mFocused = nsnull;
|
|
|
|
|
2005-11-04 05:38:33 +03:00
|
|
|
nsIFrame*
|
|
|
|
NS_NewComboboxControlFrame(nsIPresShell* aPresShell, PRUint32 aStateFlags)
|
1999-01-18 18:14:00 +03:00
|
|
|
{
|
1999-12-05 02:49:50 +03:00
|
|
|
nsComboboxControlFrame* it = new (aPresShell) nsComboboxControlFrame;
|
2005-11-04 05:38:33 +03:00
|
|
|
|
|
|
|
if (it) {
|
|
|
|
// set the state flags (if any are provided)
|
|
|
|
it->AddStateBits(aStateFlags);
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
2005-11-04 05:38:33 +03:00
|
|
|
|
|
|
|
return it;
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
// Reflow Debugging Macros
|
|
|
|
// These let us "see" how many reflow counts are happening
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
#ifdef DO_REFLOW_COUNTER
|
|
|
|
|
|
|
|
#define MAX_REFLOW_CNT 1024
|
|
|
|
static PRInt32 gTotalReqs = 0;;
|
|
|
|
static PRInt32 gTotalReflows = 0;;
|
|
|
|
static PRInt32 gReflowControlCntRQ[MAX_REFLOW_CNT];
|
|
|
|
static PRInt32 gReflowControlCnt[MAX_REFLOW_CNT];
|
|
|
|
static PRInt32 gReflowInx = -1;
|
|
|
|
|
|
|
|
#define REFLOW_COUNTER() \
|
|
|
|
if (mReflowId > -1) \
|
|
|
|
gReflowControlCnt[mReflowId]++;
|
|
|
|
|
|
|
|
#define REFLOW_COUNTER_REQUEST() \
|
|
|
|
if (mReflowId > -1) \
|
|
|
|
gReflowControlCntRQ[mReflowId]++;
|
|
|
|
|
|
|
|
#define REFLOW_COUNTER_DUMP(__desc) \
|
|
|
|
if (mReflowId > -1) {\
|
|
|
|
gTotalReqs += gReflowControlCntRQ[mReflowId];\
|
|
|
|
gTotalReflows += gReflowControlCnt[mReflowId];\
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("** Id:%5d %s RF: %d RQ: %d %d/%d %5.2f\n", \
|
2000-03-07 18:54:31 +03:00
|
|
|
mReflowId, (__desc), \
|
|
|
|
gReflowControlCnt[mReflowId], \
|
|
|
|
gReflowControlCntRQ[mReflowId],\
|
|
|
|
gTotalReflows, gTotalReqs, float(gTotalReflows)/float(gTotalReqs)*100.0f);\
|
|
|
|
}
|
|
|
|
|
|
|
|
#define REFLOW_COUNTER_INIT() \
|
|
|
|
if (gReflowInx < MAX_REFLOW_CNT) { \
|
|
|
|
gReflowInx++; \
|
|
|
|
mReflowId = gReflowInx; \
|
|
|
|
gReflowControlCnt[mReflowId] = 0; \
|
|
|
|
gReflowControlCntRQ[mReflowId] = 0; \
|
|
|
|
} else { \
|
|
|
|
mReflowId = -1; \
|
|
|
|
}
|
|
|
|
|
|
|
|
// reflow messages
|
2000-10-29 02:17:53 +04:00
|
|
|
#define REFLOW_DEBUG_MSG(_msg1) printf((_msg1))
|
|
|
|
#define REFLOW_DEBUG_MSG2(_msg1, _msg2) printf((_msg1), (_msg2))
|
|
|
|
#define REFLOW_DEBUG_MSG3(_msg1, _msg2, _msg3) printf((_msg1), (_msg2), (_msg3))
|
|
|
|
#define REFLOW_DEBUG_MSG4(_msg1, _msg2, _msg3, _msg4) printf((_msg1), (_msg2), (_msg3), (_msg4))
|
2000-03-07 18:54:31 +03:00
|
|
|
|
|
|
|
#else //-------------
|
|
|
|
|
|
|
|
#define REFLOW_COUNTER_REQUEST()
|
|
|
|
#define REFLOW_COUNTER()
|
|
|
|
#define REFLOW_COUNTER_DUMP(__desc)
|
|
|
|
#define REFLOW_COUNTER_INIT()
|
|
|
|
|
|
|
|
#define REFLOW_DEBUG_MSG(_msg)
|
|
|
|
#define REFLOW_DEBUG_MSG2(_msg1, _msg2)
|
|
|
|
#define REFLOW_DEBUG_MSG3(_msg1, _msg2, _msg3)
|
|
|
|
#define REFLOW_DEBUG_MSG4(_msg1, _msg2, _msg3, _msg4)
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//------------------------------------------
|
|
|
|
// This is for being VERY noisy
|
|
|
|
//------------------------------------------
|
|
|
|
#ifdef DO_VERY_NOISY
|
2000-10-29 02:17:53 +04:00
|
|
|
#define REFLOW_NOISY_MSG(_msg1) printf((_msg1))
|
|
|
|
#define REFLOW_NOISY_MSG2(_msg1, _msg2) printf((_msg1), (_msg2))
|
|
|
|
#define REFLOW_NOISY_MSG3(_msg1, _msg2, _msg3) printf((_msg1), (_msg2), (_msg3))
|
|
|
|
#define REFLOW_NOISY_MSG4(_msg1, _msg2, _msg3, _msg4) printf((_msg1), (_msg2), (_msg3), (_msg4))
|
2000-03-07 18:54:31 +03:00
|
|
|
#else
|
|
|
|
#define REFLOW_NOISY_MSG(_msg)
|
|
|
|
#define REFLOW_NOISY_MSG2(_msg1, _msg2)
|
|
|
|
#define REFLOW_NOISY_MSG3(_msg1, _msg2, _msg3)
|
|
|
|
#define REFLOW_NOISY_MSG4(_msg1, _msg2, _msg3, _msg4)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//------------------------------------------
|
|
|
|
// Displays value in pixels or twips
|
|
|
|
//------------------------------------------
|
|
|
|
#ifdef DO_PIXELS
|
|
|
|
#define PX(__v) __v / 15
|
|
|
|
#else
|
|
|
|
#define PX(__v) __v
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//------------------------------------------
|
|
|
|
// Asserts if we return a desired size that
|
|
|
|
// doesn't correctly match the mComputedWidth
|
|
|
|
//------------------------------------------
|
|
|
|
#ifdef DO_UNCONSTRAINED_CHECK
|
|
|
|
#define UNCONSTRAINED_CHECK() \
|
|
|
|
if (aReflowState.mComputedWidth != NS_UNCONSTRAINEDSIZE) { \
|
|
|
|
nscoord width = aDesiredSize.width - borderPadding.left - borderPadding.right; \
|
|
|
|
if (width != aReflowState.mComputedWidth) { \
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("aDesiredSize.width %d %d != aReflowState.mComputedWidth %d\n", aDesiredSize.width, width, aReflowState.mComputedWidth); \
|
2000-03-07 18:54:31 +03:00
|
|
|
} \
|
|
|
|
NS_ASSERTION(width == aReflowState.mComputedWidth, "Returning bad value when constrained!"); \
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define UNCONSTRAINED_CHECK()
|
|
|
|
#endif
|
|
|
|
//------------------------------------------------------
|
|
|
|
//-- Done with macros
|
|
|
|
//------------------------------------------------------
|
|
|
|
|
1999-01-18 18:14:00 +03:00
|
|
|
nsComboboxControlFrame::nsComboboxControlFrame()
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
: nsAreaFrame()
|
1999-01-18 18:14:00 +03:00
|
|
|
{
|
1999-04-13 02:14:31 +04:00
|
|
|
mListControlFrame = nsnull;
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
mDroppedDown = PR_FALSE;
|
|
|
|
mDisplayFrame = nsnull;
|
|
|
|
mButtonFrame = nsnull;
|
|
|
|
mDropdownFrame = nsnull;
|
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
mCacheSize.width = kSizeNotSet;
|
|
|
|
mCacheSize.height = kSizeNotSet;
|
2002-11-12 22:17:51 +03:00
|
|
|
mCachedAscent = kSizeNotSet;
|
2003-01-09 17:26:32 +03:00
|
|
|
mCachedMaxElementWidth = kSizeNotSet;
|
2000-03-07 18:54:31 +03:00
|
|
|
mCachedAvailableSize.width = kSizeNotSet;
|
|
|
|
mCachedAvailableSize.height = kSizeNotSet;
|
|
|
|
mCachedUncDropdownSize.width = kSizeNotSet;
|
|
|
|
mCachedUncDropdownSize.height = kSizeNotSet;
|
|
|
|
mCachedUncComboSize.width = kSizeNotSet;
|
|
|
|
mCachedUncComboSize.height = kSizeNotSet;
|
|
|
|
mItemDisplayWidth = 0;
|
2000-05-09 00:32:11 +04:00
|
|
|
|
2005-02-20 02:54:36 +03:00
|
|
|
mInRedisplayText = PR_FALSE;
|
2005-04-04 02:16:07 +04:00
|
|
|
mRedisplayTextEventPosted = PR_FALSE;
|
2000-10-04 17:39:07 +04:00
|
|
|
|
2002-02-08 21:35:48 +03:00
|
|
|
mRecentSelectedIndex = -1;
|
|
|
|
|
2005-11-21 01:05:24 +03:00
|
|
|
//Shrink the area around its contents
|
1999-12-05 23:43:18 +03:00
|
|
|
//SetFlags(NS_BLOCK_SHRINK_WRAP);
|
2000-03-07 18:54:31 +03:00
|
|
|
|
|
|
|
REFLOW_COUNTER_INIT()
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
|
|
|
nsComboboxControlFrame::~nsComboboxControlFrame()
|
|
|
|
{
|
2000-03-07 18:54:31 +03:00
|
|
|
REFLOW_COUNTER_DUMP("nsCCF");
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
1999-11-02 04:50:15 +03:00
|
|
|
// Frames are not refcounted, no need to AddRef
|
|
|
|
NS_IMETHODIMP
|
1999-01-18 18:14:00 +03:00
|
|
|
nsComboboxControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(0 != aInstancePtr, "null ptr");
|
|
|
|
if (NULL == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-08-06 18:13:20 +04:00
|
|
|
|
2001-01-04 23:44:42 +03:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIComboboxControlFrame))) {
|
2001-11-02 10:40:01 +03:00
|
|
|
*aInstancePtr = (void*)(nsIComboboxControlFrame*)this;
|
1999-01-18 18:14:00 +03:00
|
|
|
return NS_OK;
|
2001-01-04 23:44:42 +03:00
|
|
|
} else if (aIID.Equals(NS_GET_IID(nsIFormControlFrame))) {
|
2001-11-02 10:40:01 +03:00
|
|
|
*aInstancePtr = (void*)(nsIFormControlFrame*)this;
|
1999-01-18 18:14:00 +03:00
|
|
|
return NS_OK;
|
2001-01-04 23:44:42 +03:00
|
|
|
} else if (aIID.Equals(NS_GET_IID(nsIAnonymousContentCreator))) {
|
2001-11-02 10:40:01 +03:00
|
|
|
*aInstancePtr = (void*)(nsIAnonymousContentCreator*)this;
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
return NS_OK;
|
1999-09-15 09:31:31 +04:00
|
|
|
} else if (aIID.Equals(NS_GET_IID(nsISelectControlFrame))) {
|
|
|
|
*aInstancePtr = (void *)(nsISelectControlFrame*)this;
|
|
|
|
return NS_OK;
|
|
|
|
} else if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
|
2001-11-02 10:40:01 +03:00
|
|
|
*aInstancePtr = (void*)(nsIStatefulFrame*)this;
|
1999-08-26 18:54:07 +04:00
|
|
|
return NS_OK;
|
2000-02-03 01:24:56 +03:00
|
|
|
} else if (aIID.Equals(NS_GET_IID(nsIRollupListener))) {
|
1999-09-22 01:20:50 +04:00
|
|
|
*aInstancePtr = (void*)(nsIRollupListener*)this;
|
|
|
|
return NS_OK;
|
2000-12-09 10:28:19 +03:00
|
|
|
} else if (aIID.Equals(NS_GET_IID(nsIScrollableViewProvider))) {
|
|
|
|
*aInstancePtr = (void*)(nsIScrollableViewProvider*)this;
|
|
|
|
return NS_OK;
|
2001-04-01 05:01:33 +04:00
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
return nsAreaFrame::QueryInterface(aIID, aInstancePtr);
|
|
|
|
}
|
|
|
|
|
2001-08-17 07:13:07 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2001-05-18 03:52:32 +04:00
|
|
|
NS_IMETHODIMP nsComboboxControlFrame::GetAccessible(nsIAccessible** aAccessible)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAccessibilityService> accService = do_GetService("@mozilla.org/accessibilityService;1");
|
|
|
|
|
|
|
|
if (accService) {
|
|
|
|
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(mContent);
|
2005-12-02 15:02:44 +03:00
|
|
|
nsCOMPtr<nsIWeakReference> weakShell(do_GetWeakReference(GetPresContext()->PresShell()));
|
|
|
|
return accService->CreateHTMLComboboxAccessible(node, weakShell, aAccessible);
|
2001-05-18 03:52:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2001-08-17 07:13:07 +04:00
|
|
|
#endif
|
2001-05-18 03:52:32 +04:00
|
|
|
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsComboboxControlFrame::Init(nsPresContext* aPresContext,
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext,
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
2005-03-21 04:58:17 +03:00
|
|
|
mEventQueueService = do_GetService(kEventQueueServiceCID);
|
2000-05-09 00:32:11 +04:00
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
return nsAreaFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsComboboxControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
|
|
|
|
{
|
2001-01-04 15:22:29 +03:00
|
|
|
if (aOn) {
|
2002-11-07 13:25:03 +03:00
|
|
|
nsListControlFrame::ComboboxFocusSet();
|
2004-07-23 12:25:44 +04:00
|
|
|
mFocused = this;
|
2001-01-04 15:22:29 +03:00
|
|
|
} else {
|
|
|
|
mFocused = nsnull;
|
|
|
|
if (mDroppedDown) {
|
2002-02-20 08:59:46 +03:00
|
|
|
mListControlFrame->ComboboxFinish(mDisplayedIndex);
|
2002-02-08 21:35:48 +03:00
|
|
|
}
|
2004-05-28 20:25:04 +04:00
|
|
|
mListControlFrame->FireOnChange();
|
2001-01-04 15:22:29 +03:00
|
|
|
}
|
2002-02-08 21:35:48 +03:00
|
|
|
|
2001-01-04 15:22:29 +03:00
|
|
|
// This is needed on a temporary basis. It causes the focus
|
2000-10-04 17:39:07 +04:00
|
|
|
// rect to be drawn. This is much faster than ReResolvingStyle
|
|
|
|
// Bug 32920
|
2004-03-10 06:09:05 +03:00
|
|
|
Invalidate(nsRect(0,0,mRect.width,mRect.height), PR_TRUE);
|
2001-06-14 06:08:40 +04:00
|
|
|
|
|
|
|
// Make sure the content area gets updated for where the dropdown was
|
|
|
|
// This is only needed for embedding, the focus may go to
|
|
|
|
// the chrome that is not part of the Gecko system (Bug 83493)
|
2004-03-10 06:09:05 +03:00
|
|
|
// XXX this is rather inefficient
|
2003-07-04 16:50:32 +04:00
|
|
|
nsIViewManager* vm = GetPresContext()->GetViewManager();
|
|
|
|
if (vm) {
|
|
|
|
vm->UpdateAllViews(NS_VMREFRESH_NO_SYNC);
|
2001-06-14 06:08:40 +04:00
|
|
|
}
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
void
|
|
|
|
nsComboboxControlFrame::ShowPopup(PRBool aShowPopup)
|
|
|
|
{
|
2003-07-04 16:50:32 +04:00
|
|
|
nsIView* view = mDropdownFrame->GetView();
|
|
|
|
nsIViewManager* viewManager = view->GetViewManager();
|
2000-05-26 10:42:29 +04:00
|
|
|
|
|
|
|
if (aShowPopup) {
|
2003-07-04 16:50:32 +04:00
|
|
|
nsRect rect = mDropdownFrame->GetRect();
|
2001-12-01 17:31:45 +03:00
|
|
|
rect.x = rect.y = 0;
|
|
|
|
viewManager->ResizeView(view, rect);
|
2000-05-26 10:42:29 +04:00
|
|
|
viewManager->SetViewVisibility(view, nsViewVisibility_kShow);
|
|
|
|
} else {
|
|
|
|
viewManager->SetViewVisibility(view, nsViewVisibility_kHide);
|
2001-12-01 17:31:45 +03:00
|
|
|
nsRect emptyRect(0, 0, 0, 0);
|
|
|
|
viewManager->ResizeView(view, emptyRect);
|
2000-05-26 10:42:29 +04:00
|
|
|
}
|
2001-04-01 05:01:33 +04:00
|
|
|
|
|
|
|
// fire a popup dom event
|
|
|
|
nsEventStatus status = nsEventStatus_eIgnore;
|
2005-04-29 03:48:28 +04:00
|
|
|
nsMouseEvent event(PR_TRUE, aShowPopup ?
|
|
|
|
NS_XUL_POPUP_SHOWING : NS_XUL_POPUP_HIDING, nsnull,
|
|
|
|
nsMouseEvent::eReal);
|
2001-04-01 05:01:33 +04:00
|
|
|
|
2005-08-16 16:20:58 +04:00
|
|
|
nsIPresShell *shell = GetPresContext()->GetPresShell();
|
2003-12-21 08:36:36 +03:00
|
|
|
if (shell)
|
|
|
|
shell->HandleDOMEventWithTarget(mContent, &event, &status);
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
// Show the dropdown list
|
1999-04-13 02:14:31 +04:00
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsComboboxControlFrame::ShowList(nsPresContext* aPresContext, PRBool aShowList)
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
{
|
2003-07-04 16:50:32 +04:00
|
|
|
nsIWidget* widget = nsnull;
|
1999-09-22 01:20:50 +04:00
|
|
|
|
|
|
|
// Get parent view
|
|
|
|
nsIFrame * listFrame;
|
2001-01-04 23:44:42 +03:00
|
|
|
if (NS_OK == mListControlFrame->QueryInterface(NS_GET_IID(nsIFrame), (void **)&listFrame)) {
|
2003-07-04 16:50:32 +04:00
|
|
|
nsIView* view = listFrame->GetView();
|
|
|
|
NS_ASSERTION(view, "nsComboboxControlFrame view is null");
|
1999-12-01 06:08:04 +03:00
|
|
|
if (view) {
|
2003-07-04 16:50:32 +04:00
|
|
|
widget = view->GetWidget();
|
1999-09-22 01:20:50 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
if (PR_TRUE == aShowList) {
|
|
|
|
ShowPopup(PR_TRUE);
|
|
|
|
mDroppedDown = PR_TRUE;
|
2000-02-12 01:26:36 +03:00
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
// The listcontrol frame will call back to the nsComboboxControlFrame's ListWasSelected
|
|
|
|
// which will stop the capture.
|
1999-09-08 18:27:38 +04:00
|
|
|
mListControlFrame->AboutToDropDown();
|
1999-10-26 08:44:41 +04:00
|
|
|
mListControlFrame->CaptureMouseEvents(aPresContext, PR_TRUE);
|
2000-02-12 01:26:36 +03:00
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
} else {
|
|
|
|
ShowPopup(PR_FALSE);
|
|
|
|
mDroppedDown = PR_FALSE;
|
1999-05-08 00:30:16 +04:00
|
|
|
}
|
2000-02-12 01:26:36 +03:00
|
|
|
|
2004-05-28 02:08:42 +04:00
|
|
|
// Don't flush anything but reflows lest it destroy us
|
|
|
|
aPresContext->PresShell()->
|
|
|
|
GetDocument()->FlushPendingNotifications(Flush_OnlyReflow);
|
2000-02-12 01:26:36 +03:00
|
|
|
|
|
|
|
if (widget)
|
2003-09-02 19:21:13 +04:00
|
|
|
widget->CaptureRollupEvents((nsIRollupListener *)this, mDroppedDown, aShowList);
|
2000-02-12 01:26:36 +03:00
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
}
|
1999-05-08 00:30:16 +04:00
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
nsresult
|
|
|
|
nsComboboxControlFrame::ReflowComboChildFrame(nsIFrame* aFrame,
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext* aPresContext,
|
2000-03-07 18:54:31 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
nscoord aAvailableWidth,
|
|
|
|
nscoord aAvailableHeight)
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
{
|
|
|
|
// Constrain the child's width and height to aAvailableWidth and aAvailableHeight
|
|
|
|
nsSize availSize(aAvailableWidth, aAvailableHeight);
|
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, aFrame,
|
|
|
|
availSize);
|
1999-07-20 07:41:03 +04:00
|
|
|
kidReflowState.mComputedWidth = aAvailableWidth;
|
|
|
|
kidReflowState.mComputedHeight = aAvailableHeight;
|
2000-05-26 10:42:29 +04:00
|
|
|
|
|
|
|
// ensure we start off hidden
|
|
|
|
if (aReflowState.reason == eReflowReason_Initial) {
|
2003-07-04 16:50:32 +04:00
|
|
|
nsIView* view = mDropdownFrame->GetView();
|
|
|
|
nsIViewManager* viewManager = view->GetViewManager();
|
2000-05-26 10:42:29 +04:00
|
|
|
viewManager->SetViewVisibility(view, nsViewVisibility_kHide);
|
2001-12-01 17:31:45 +03:00
|
|
|
nsRect emptyRect(0, 0, 0, 0);
|
|
|
|
viewManager->ResizeView(view, emptyRect);
|
2000-05-26 10:42:29 +04:00
|
|
|
}
|
|
|
|
|
2005-06-22 05:38:49 +04:00
|
|
|
// Allow the child to move/size/change-visibility its view if it's currently
|
|
|
|
// dropped down
|
|
|
|
PRInt32 flags = NS_FRAME_NO_MOVE_VIEW | NS_FRAME_NO_VISIBILITY | NS_FRAME_NO_SIZE_VIEW;
|
|
|
|
if (mDroppedDown) {
|
|
|
|
flags = 0;
|
|
|
|
}
|
2003-07-04 16:50:32 +04:00
|
|
|
nsRect rect = aFrame->GetRect();
|
1999-11-19 18:33:29 +03:00
|
|
|
nsresult rv = ReflowChild(aFrame, aPresContext, aDesiredSize, kidReflowState,
|
2005-06-22 05:38:49 +04:00
|
|
|
rect.x, rect.y, flags, aStatus);
|
1999-11-19 18:33:29 +03:00
|
|
|
|
|
|
|
// Set the child's width and height to it's desired size
|
2001-12-07 17:51:12 +03:00
|
|
|
FinishReflowChild(aFrame, aPresContext, &kidReflowState, aDesiredSize,
|
2005-06-22 05:38:49 +04:00
|
|
|
rect.x, rect.y, flags);
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2005-12-13 02:53:06 +03:00
|
|
|
// Resize the child button frame to the specified size.
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
void
|
2005-12-13 02:53:06 +03:00
|
|
|
nsComboboxControlFrame::SetButtonFrameSize(const nsSize& aSize)
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
{
|
2005-12-13 02:53:06 +03:00
|
|
|
// Check that the child frame being resized is an nsGfxButtonControlFrame.
|
|
|
|
if (mButtonFrame->GetType() == nsLayoutAtoms::gfxButtonControlFrame) {
|
|
|
|
NS_STATIC_CAST(nsGfxButtonControlFrame*, mButtonFrame)->SetSuggestedSize(aSize);
|
|
|
|
} else {
|
|
|
|
// This function should never be called with another frame type.
|
|
|
|
NS_NOTREACHED("Wrong type in SetButtonFrameSize");
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2004-08-01 03:15:21 +04:00
|
|
|
nsComboboxControlFrame::GetPrimaryComboFrame(nsPresContext* aPresContext, nsIContent* aContent, nsIFrame** aFrame)
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
{
|
|
|
|
// Get the primary frame from the presentation shell.
|
2003-12-21 08:36:36 +03:00
|
|
|
nsIPresShell *presShell = aPresContext->GetPresShell();
|
|
|
|
if (presShell) {
|
2005-08-23 02:24:29 +04:00
|
|
|
*aFrame = presShell->GetPrimaryFrameFor(aContent);
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
2003-12-21 08:36:36 +03:00
|
|
|
return NS_OK;
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2004-08-01 03:15:21 +04:00
|
|
|
nsComboboxControlFrame::PositionDropdown(nsPresContext* aPresContext,
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
nscoord aHeight,
|
|
|
|
nsRect aAbsoluteTwipsRect,
|
|
|
|
nsRect aAbsolutePixelRect)
|
|
|
|
{
|
|
|
|
// Position the dropdown list. It is positioned below the display frame if there is enough
|
|
|
|
// room on the screen to display the entire list. Otherwise it is placed above the display
|
|
|
|
// frame.
|
1999-01-18 18:14:00 +03:00
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
// Note: As first glance, it appears that you could simply get the absolute bounding box for the
|
2005-11-21 01:05:24 +03:00
|
|
|
// dropdown list by first getting its view, then getting the view's nsIWidget, then asking the nsIWidget
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
// for it's AbsoluteBounds. The problem with this approach, is that the dropdown lists y location can
|
|
|
|
// change based on whether the dropdown is placed below or above the display frame.
|
|
|
|
// The approach, taken here is to get use the absolute position of the display frame and use it's location
|
|
|
|
// to determine if the dropdown will go offscreen.
|
1999-01-18 18:14:00 +03:00
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
// Use the height calculated for the area frame so it includes both
|
|
|
|
// the display and button heights.
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nscoord dropdownYOffset = aHeight;
|
1999-07-29 01:38:08 +04:00
|
|
|
// XXX: Enable this code to debug popping up above the display frame, rather than below it
|
2003-07-04 16:50:32 +04:00
|
|
|
nsRect dropdownRect = mDropdownFrame->GetRect();
|
1999-07-29 01:38:08 +04:00
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
nscoord screenHeightInPixels = 0;
|
2000-03-18 17:20:03 +03:00
|
|
|
if (NS_SUCCEEDED(nsFormControlFrame::GetScreenHeight(aPresContext, screenHeightInPixels))) {
|
1999-08-26 18:54:07 +04:00
|
|
|
// Get the height of the dropdown list in pixels.
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
float t2p;
|
2004-02-11 07:57:07 +03:00
|
|
|
t2p = aPresContext->TwipsToPixels();
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
nscoord absoluteDropDownHeight = NSTwipsToIntPixels(dropdownRect.height, t2p);
|
|
|
|
|
|
|
|
// Check to see if the drop-down list will go offscreen
|
|
|
|
if (NS_SUCCEEDED(rv) && ((aAbsolutePixelRect.y + aAbsolutePixelRect.height + absoluteDropDownHeight) > screenHeightInPixels)) {
|
|
|
|
// move the dropdown list up
|
1999-07-29 01:38:08 +04:00
|
|
|
dropdownYOffset = - (dropdownRect.height);
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
}
|
2003-04-09 00:50:57 +04:00
|
|
|
}
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
|
|
|
|
dropdownRect.x = 0;
|
|
|
|
dropdownRect.y = dropdownYOffset;
|
1999-09-09 17:17:35 +04:00
|
|
|
|
2003-07-04 16:50:32 +04:00
|
|
|
mDropdownFrame->SetRect(dropdownRect);
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
return rv;
|
|
|
|
}
|
1999-01-18 18:14:00 +03:00
|
|
|
|
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
////////////////////////////////////////////////////////////////
|
|
|
|
// Experimental Reflow
|
|
|
|
////////////////////////////////////////////////////////////////
|
|
|
|
#if defined(DO_NEW_REFLOW) || defined(DO_REFLOW_COUNTER)
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// Returns the nsIDOMHTMLOptionElement for a given index
|
|
|
|
// in the select's collection
|
|
|
|
//---------------------------------------------------------
|
|
|
|
static nsIDOMHTMLOptionElement*
|
2005-02-20 02:54:36 +03:00
|
|
|
GetOption(nsIDOMHTMLOptionsCollection& aCollection, PRInt32 aIndex)
|
2000-03-07 18:54:31 +03:00
|
|
|
{
|
|
|
|
nsIDOMNode* node = nsnull;
|
|
|
|
if (NS_SUCCEEDED(aCollection.Item(aIndex, &node))) {
|
|
|
|
if (nsnull != node) {
|
|
|
|
nsIDOMHTMLOptionElement* option = nsnull;
|
|
|
|
node->QueryInterface(NS_GET_IID(nsIDOMHTMLOptionElement), (void**)&option);
|
|
|
|
NS_RELEASE(node);
|
|
|
|
return option;
|
|
|
|
}
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
}
|
2000-03-07 18:54:31 +03:00
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// for a given piece of content it returns nsIDOMHTMLSelectElement object
|
|
|
|
// or null
|
|
|
|
//---------------------------------------------------------
|
|
|
|
static nsIDOMHTMLSelectElement*
|
|
|
|
GetSelect(nsIContent * aContent)
|
|
|
|
{
|
|
|
|
nsIDOMHTMLSelectElement* selectElement = nsnull;
|
|
|
|
nsresult result = aContent->QueryInterface(NS_GET_IID(nsIDOMHTMLSelectElement),
|
|
|
|
(void**)&selectElement);
|
|
|
|
if (NS_SUCCEEDED(result) && selectElement) {
|
|
|
|
return selectElement;
|
|
|
|
} else {
|
|
|
|
return nsnull;
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
}
|
2000-03-07 18:54:31 +03:00
|
|
|
}
|
|
|
|
//---------------------------------------------------------
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// This returns the collection for nsIDOMHTMLSelectElement or
|
|
|
|
// the nsIContent object is the select is null (AddRefs)
|
|
|
|
//---------------------------------------------------------
|
2005-02-20 02:54:36 +03:00
|
|
|
static nsIDOMHTMLOptionsCollection*
|
2000-03-07 18:54:31 +03:00
|
|
|
GetOptions(nsIContent * aContent, nsIDOMHTMLSelectElement* aSelect = nsnull)
|
|
|
|
{
|
2005-02-20 02:54:36 +03:00
|
|
|
nsIDOMHTMLOptionsCollection* options = nsnull;
|
2000-03-07 18:54:31 +03:00
|
|
|
if (!aSelect) {
|
|
|
|
nsCOMPtr<nsIDOMHTMLSelectElement> selectElement = getter_AddRefs(GetSelect(aContent));
|
|
|
|
if (selectElement) {
|
2001-06-08 06:25:22 +04:00
|
|
|
selectElement->GetOptions(&options); // AddRefs (1)
|
2000-03-07 18:54:31 +03:00
|
|
|
}
|
|
|
|
} else {
|
2001-06-08 06:25:22 +04:00
|
|
|
aSelect->GetOptions(&options); // AddRefs (1)
|
2000-03-03 10:14:58 +03:00
|
|
|
}
|
2000-03-07 18:54:31 +03:00
|
|
|
return options;
|
|
|
|
}
|
2000-03-03 10:14:58 +03:00
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
#ifdef DO_NEW_REFLOW
|
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsComboboxControlFrame::ReflowItems(nsPresContext* aPresContext,
|
2000-03-07 18:54:31 +03:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize)
|
|
|
|
{
|
2000-10-29 02:17:53 +04:00
|
|
|
//printf("*****************\n");
|
2004-07-21 05:05:44 +04:00
|
|
|
nscoord visibleHeight = 0;
|
|
|
|
nsCOMPtr<nsIFontMetrics> fontMet;
|
|
|
|
nsresult res = nsFormControlHelper::GetFrameFontFM(mDisplayFrame, getter_AddRefs(fontMet));
|
2000-03-07 18:54:31 +03:00
|
|
|
if (fontMet) {
|
|
|
|
fontMet->GetHeight(visibleHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoString maxStr;
|
|
|
|
nscoord maxWidth = 0;
|
|
|
|
//nsIRenderingContext * rc = aReflowState.rendContext;
|
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
2005-02-20 02:54:36 +03:00
|
|
|
nsCOMPtr<nsIDOMHTMLOptionsCollection> options = getter_AddRefs(GetOptions(mContent));
|
2000-03-07 18:54:31 +03:00
|
|
|
if (options) {
|
|
|
|
PRUint32 numOptions;
|
|
|
|
options->GetLength(&numOptions);
|
2000-10-29 02:17:53 +04:00
|
|
|
//printf("--- Num of Items %d ---\n", numOptions);
|
2000-03-07 18:54:31 +03:00
|
|
|
for (PRUint32 i=0;i<numOptions;i++) {
|
|
|
|
nsCOMPtr<nsIDOMHTMLOptionElement> optionElement = getter_AddRefs(GetOption(*options, i));
|
|
|
|
if (optionElement) {
|
|
|
|
nsAutoString text;
|
2005-10-28 15:25:24 +04:00
|
|
|
optionElement->GetLabel(text);
|
|
|
|
if (text.IsEmpty() &&
|
|
|
|
NS_SUCCEEDED(optionElement->GetText(text))) {
|
|
|
|
nscoord width;
|
|
|
|
aReflowState.rendContext->GetWidth(text, width);
|
|
|
|
if (width > maxWidth) {
|
|
|
|
maxStr = text;
|
|
|
|
maxWidth = width;
|
2000-03-07 18:54:31 +03:00
|
|
|
}
|
2005-10-28 15:25:24 +04:00
|
|
|
//maxWidth = PR_MAX(width, maxWidth);
|
|
|
|
//printf("[%d] - %d %s \n", i, width, NS_LossyConvertUCS2toASCII(text).get());
|
|
|
|
}
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-03-07 18:54:31 +03:00
|
|
|
if (maxWidth == 0) {
|
|
|
|
maxWidth = 11 * 15;
|
|
|
|
}
|
2001-09-29 12:28:41 +04:00
|
|
|
char * str = ToNewCString(maxStr);
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("id: %d maxWidth %d [%s]\n", mReflowId, maxWidth, str);
|
2000-03-07 18:54:31 +03:00
|
|
|
delete [] str;
|
|
|
|
|
|
|
|
// get the borderPadding for the display area
|
2001-02-07 12:57:26 +03:00
|
|
|
nsMargin dspBorderPadding(0, 0, 0, 0);
|
|
|
|
mDisplayFrame->CalcBorderPadding(dspBorderPadding);
|
2000-03-07 18:54:31 +03:00
|
|
|
|
|
|
|
nscoord frmWidth = maxWidth+dspBorderPadding.left+dspBorderPadding.right+
|
|
|
|
aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right;
|
|
|
|
nscoord frmHeight = visibleHeight+dspBorderPadding.top+dspBorderPadding.bottom+
|
|
|
|
aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom;
|
1999-01-18 18:14:00 +03:00
|
|
|
|
2000-05-27 03:34:59 +04:00
|
|
|
#if 0
|
2000-03-07 18:54:31 +03:00
|
|
|
aDesiredSize.width = frmWidth;
|
|
|
|
aDesiredSize.height = frmHeight;
|
|
|
|
#else
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("Size frm:%d,%d DS:%d,%d DIF:%d,%d(tp) %d,%d(px)\n",
|
2000-03-07 18:54:31 +03:00
|
|
|
frmWidth, frmHeight,
|
|
|
|
aDesiredSize.width, aDesiredSize.height,
|
|
|
|
frmWidth-aDesiredSize.width, frmHeight-aDesiredSize.height,
|
|
|
|
(frmWidth-aDesiredSize.width)/15, (frmHeight-aDesiredSize.height)/15);
|
|
|
|
#endif
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
#endif
|
1999-01-18 18:14:00 +03:00
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
#endif
|
1999-01-18 18:14:00 +03:00
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
// This Method reflow just the contents of the ComboBox
|
|
|
|
// The contents are a Block frame containing a Text Frame - This is the display area
|
|
|
|
// and then the GfxButton - The dropdown button
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsComboboxControlFrame::ReflowCombobox(nsPresContext * aPresContext,
|
2000-03-07 18:54:31 +03:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
nsIFrame * aDisplayFrame,
|
|
|
|
nscoord& aDisplayWidth,
|
|
|
|
nscoord aBtnWidth,
|
|
|
|
const nsMargin& aBorderPadding,
|
|
|
|
nscoord aFallBackHgt,
|
|
|
|
PRBool aCheckHeight)
|
|
|
|
{
|
|
|
|
// start out by using the cached height
|
|
|
|
// XXX later this will change when we better handle constrained height
|
|
|
|
nscoord dispHeight = mCacheSize.height - aBorderPadding.top - aBorderPadding.bottom;
|
|
|
|
nscoord dispWidth = aDisplayWidth;
|
|
|
|
|
|
|
|
REFLOW_NOISY_MSG3("+++1 AdjustCombo DW:%d DH:%d ", PX(dispWidth), PX(dispHeight));
|
|
|
|
REFLOW_NOISY_MSG3("BW:%d BH:%d ", PX(aBtnWidth), PX(dispHeight));
|
|
|
|
REFLOW_NOISY_MSG3("mCacheSize.height:%d - %d\n", PX(mCacheSize.height), PX((aBorderPadding.top + aBorderPadding.bottom)));
|
|
|
|
|
|
|
|
// get the border and padding for the DisplayArea (block frame & textframe)
|
2001-02-07 12:57:26 +03:00
|
|
|
nsMargin dspBorderPadding(0, 0, 0, 0);
|
|
|
|
mDisplayFrame->CalcBorderPadding(dspBorderPadding);
|
2000-03-07 18:54:31 +03:00
|
|
|
|
|
|
|
// adjust the height
|
|
|
|
if (mCacheSize.height == kSizeNotSet) {
|
|
|
|
if (aFallBackHgt == kSizeNotSet) {
|
|
|
|
NS_ASSERTION(aFallBackHgt != kSizeNotSet, "Fallback can't be kSizeNotSet when mCacheSize.height == kSizeNotSet");
|
|
|
|
} else {
|
|
|
|
dispHeight = aFallBackHgt;
|
|
|
|
REFLOW_NOISY_MSG2("+++3 Adding (dspBorderPadding.top + dspBorderPadding.bottom): %d\n", (dspBorderPadding.top + dspBorderPadding.bottom));
|
|
|
|
dispHeight += (dspBorderPadding.top + dspBorderPadding.bottom);
|
2000-03-03 10:14:58 +03:00
|
|
|
}
|
2000-03-07 18:54:31 +03:00
|
|
|
}
|
1999-01-18 18:14:00 +03:00
|
|
|
|
2000-12-20 18:09:00 +03:00
|
|
|
// Fix for Bug 58220 (part of it)
|
|
|
|
// make sure we size correctly if the CSS width is set to something really small like 0, 1, or 2 pixels
|
|
|
|
nscoord computedWidth = aReflowState.mComputedWidth + aBorderPadding.left + aBorderPadding.right;
|
2002-02-12 18:24:37 +03:00
|
|
|
if ((aReflowState.mComputedWidth != NS_UNCONSTRAINEDSIZE && computedWidth <= 0) || aReflowState.mComputedWidth == 0) {
|
2000-12-20 18:09:00 +03:00
|
|
|
nsRect buttonRect(0,0,0,0);
|
|
|
|
nsRect displayRect(0,0,0,0);
|
|
|
|
aBtnWidth = 0;
|
2003-07-04 16:50:32 +04:00
|
|
|
aDisplayFrame->SetRect(displayRect);
|
2005-12-13 02:53:06 +03:00
|
|
|
mButtonFrame->SetRect(buttonRect);
|
|
|
|
SetButtonFrameSize(nsSize(aBtnWidth, aDesiredSize.height));
|
2000-12-20 18:09:00 +03:00
|
|
|
aDesiredSize.width = 0;
|
2003-10-21 23:37:48 +04:00
|
|
|
aDesiredSize.height = dispHeight + aBorderPadding.top + aBorderPadding.bottom;
|
2002-11-12 22:17:51 +03:00
|
|
|
// XXX What about ascent and descent?
|
2000-12-20 18:09:00 +03:00
|
|
|
return;
|
|
|
|
}
|
2000-03-07 18:54:31 +03:00
|
|
|
|
|
|
|
REFLOW_NOISY_MSG3("+++2 AdjustCombo DW:%d DH:%d ", PX(dispWidth), PX(dispHeight));
|
|
|
|
REFLOW_NOISY_MSG3(" BW:%d BH:%d\n", PX(aBtnWidth), PX(dispHeight));
|
|
|
|
|
|
|
|
// This sets the button to be a specific size
|
|
|
|
// so no matter what it reflows at these values
|
2005-12-13 02:53:06 +03:00
|
|
|
SetButtonFrameSize(nsSize(aBtnWidth, dispHeight));
|
2000-03-07 18:54:31 +03:00
|
|
|
|
2000-12-20 18:09:00 +03:00
|
|
|
#ifdef FIX_FOR_BUG_53259
|
|
|
|
// Make sure we obey min/max-width and min/max-height
|
|
|
|
if (dispWidth > aReflowState.mComputedMaxWidth) {
|
|
|
|
dispWidth = aReflowState.mComputedMaxWidth - aBorderPadding.left - aBorderPadding.right;
|
|
|
|
}
|
|
|
|
if (dispWidth < aReflowState.mComputedMinWidth) {
|
|
|
|
dispWidth = aReflowState.mComputedMinWidth - aBorderPadding.left - aBorderPadding.right;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dispHeight > aReflowState.mComputedMaxHeight) {
|
|
|
|
dispHeight = aReflowState.mComputedMaxHeight - aBorderPadding.top - aBorderPadding.bottom;
|
|
|
|
}
|
|
|
|
if (dispHeight < aReflowState.mComputedMinHeight) {
|
|
|
|
dispHeight = aReflowState.mComputedMinHeight - aBorderPadding.top - aBorderPadding.bottom;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-07-10 02:32:32 +04:00
|
|
|
// Make sure we get the reflow reason right. If an incremental
|
|
|
|
// reflow arrives that's targeted directly at the top-level combobox
|
|
|
|
// frame, then we can't pass it down to the children ``as is'':
|
|
|
|
// we're the last frame in the reflow command's chain. So, convert
|
|
|
|
// it to a resize reflow.
|
|
|
|
nsReflowReason reason = aReflowState.reason;
|
|
|
|
if (reason == eReflowReason_Incremental) {
|
2002-05-10 22:22:41 +04:00
|
|
|
if (aReflowState.path->mReflowCommand)
|
2001-07-10 02:32:32 +04:00
|
|
|
reason = eReflowReason_Resize;
|
|
|
|
}
|
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
// now that we know what the overall display width & height will be
|
|
|
|
// set up a new reflow state and reflow the area frame at that size
|
|
|
|
nsSize availSize(dispWidth + aBorderPadding.left + aBorderPadding.right,
|
|
|
|
dispHeight + aBorderPadding.top + aBorderPadding.bottom);
|
2002-05-10 22:22:41 +04:00
|
|
|
nsHTMLReflowState kidReflowState(aReflowState);
|
|
|
|
kidReflowState.availableWidth = availSize.width;
|
|
|
|
kidReflowState.availableHeight = availSize.height;
|
2000-03-07 18:54:31 +03:00
|
|
|
kidReflowState.mComputedWidth = dispWidth;
|
|
|
|
kidReflowState.mComputedHeight = dispHeight;
|
2002-05-10 22:22:41 +04:00
|
|
|
kidReflowState.reason = reason;
|
2000-03-07 18:54:31 +03:00
|
|
|
|
2001-03-20 02:20:21 +03:00
|
|
|
#ifdef IBMBIDI
|
2003-05-15 07:42:21 +04:00
|
|
|
const nsStyleVisibility* vis = GetStyleVisibility();
|
2001-03-20 02:20:21 +03:00
|
|
|
|
|
|
|
// M14 didn't calculate the RightEdge in the reflow
|
|
|
|
// Unless we set the width to some thing other than unrestricted
|
|
|
|
// the code changed this may not be the best place to put it
|
|
|
|
// in this->Reflow like this :
|
|
|
|
//
|
|
|
|
// Reflow display + button
|
|
|
|
// nsAreaFrame::Reflow(aPresContext, aDesiredSize, firstPassState, aStatus);
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (vis->mDirection == NS_STYLE_DIRECTION_RTL)
|
2001-03-20 02:20:21 +03:00
|
|
|
{
|
|
|
|
kidReflowState.mComputedWidth = 0;
|
|
|
|
}
|
|
|
|
#endif // IBMBIDI
|
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
// do reflow
|
|
|
|
nsAreaFrame::Reflow(aPresContext, aDesiredSize, kidReflowState, aStatus);
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////
|
|
|
|
// The DisplayFrame is a Block frame containing a TextFrame
|
|
|
|
// and it is completely anonymous, so we must manually reflow it
|
2003-01-09 17:26:32 +03:00
|
|
|
nsHTMLReflowMetrics txtKidSize(PR_TRUE);
|
2000-03-07 18:54:31 +03:00
|
|
|
nsSize txtAvailSize(dispWidth - aBtnWidth, dispHeight);
|
2002-05-10 22:22:41 +04:00
|
|
|
nsHTMLReflowState txtKidReflowState(aPresContext, aReflowState, aDisplayFrame, txtAvailSize, reason);
|
2000-03-07 18:54:31 +03:00
|
|
|
|
|
|
|
aDisplayFrame->WillReflow(aPresContext);
|
2003-07-04 16:50:32 +04:00
|
|
|
//aDisplayFrame->SetPosition(nsPoint(dspBorderPadding.left + aBorderPadding.left, dspBorderPadding.top + aBorderPadding.top));
|
|
|
|
aDisplayFrame->SetPosition(nsPoint(aBorderPadding.left, aBorderPadding.top));
|
2004-12-27 18:05:18 +03:00
|
|
|
nsAreaFrame::PositionFrameView(aDisplayFrame);
|
2000-03-07 18:54:31 +03:00
|
|
|
nsReflowStatus status;
|
|
|
|
nsresult rv = aDisplayFrame->Reflow(aPresContext, txtKidSize, txtKidReflowState, status);
|
2000-03-28 18:29:15 +04:00
|
|
|
if (NS_FAILED(rv)) return;
|
2000-03-07 18:54:31 +03:00
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////
|
|
|
|
// If we are Constrained then the AreaFrame Reflow is the correct size
|
|
|
|
// if we are unconstrained then
|
|
|
|
//if (aReflowState.mComputedWidth == NS_UNCONSTRAINEDSIZE) {
|
|
|
|
// aDesiredSize.width += txtKidSize.width;
|
|
|
|
//}
|
2000-01-09 04:52:17 +03:00
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
// Apparently, XUL lays out differently than HTML
|
|
|
|
// (the code above works for HTML and not XUL),
|
|
|
|
// so instead of using the above calculation
|
|
|
|
// I just set it to what it should be.
|
|
|
|
aDesiredSize.width = availSize.width;
|
|
|
|
//aDesiredSize.height = availSize.height;
|
1999-01-18 18:14:00 +03:00
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
// now we need to adjust layout, because the AreaFrame
|
|
|
|
// doesn't position things exactly where we want them
|
|
|
|
nscoord insideHeight = aDesiredSize.height - aBorderPadding.top - aBorderPadding.bottom;
|
2000-03-03 10:14:58 +03:00
|
|
|
|
2000-12-20 18:09:00 +03:00
|
|
|
// If the css width has been set to something very small
|
|
|
|
//i.e. smaller than the dropdown button, set the button's width to zero
|
|
|
|
if (aBtnWidth > dispWidth) {
|
|
|
|
aBtnWidth = 0;
|
|
|
|
}
|
2000-03-07 18:54:31 +03:00
|
|
|
// set the display rect to be left justifed and
|
|
|
|
// fills the entire area except the button
|
2003-07-04 16:50:32 +04:00
|
|
|
nscoord x = aBorderPadding.left;
|
|
|
|
nsRect displayRect(x, aBorderPadding.top, PR_MAX(dispWidth - aBtnWidth, 0), insideHeight);
|
|
|
|
aDisplayFrame->SetRect(displayRect);
|
|
|
|
x += displayRect.width;
|
2000-03-07 18:54:31 +03:00
|
|
|
|
|
|
|
// right justify the button
|
2003-07-04 16:50:32 +04:00
|
|
|
nsRect buttonRect(x, aBorderPadding.top, aBtnWidth, insideHeight);
|
2001-03-20 02:20:21 +03:00
|
|
|
#ifdef IBMBIDI
|
2001-06-01 02:19:43 +04:00
|
|
|
if (vis->mDirection == NS_STYLE_DIRECTION_RTL)
|
2001-03-20 02:20:21 +03:00
|
|
|
{
|
|
|
|
if (buttonRect.x > displayRect.x)
|
|
|
|
{
|
|
|
|
buttonRect.x = displayRect.x;
|
|
|
|
displayRect.x += buttonRect.width;
|
2003-07-04 16:50:32 +04:00
|
|
|
aDisplayFrame->SetRect(displayRect);
|
2001-03-20 02:20:21 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // IBMBIDI
|
2005-12-13 02:53:06 +03:00
|
|
|
mButtonFrame->SetRect(buttonRect);
|
2000-03-07 18:54:31 +03:00
|
|
|
|
|
|
|
// since we have changed the height of the button
|
|
|
|
// make sure it has these new values
|
2005-12-13 02:53:06 +03:00
|
|
|
SetButtonFrameSize(nsSize(aBtnWidth, aDesiredSize.height));
|
2000-12-20 18:09:00 +03:00
|
|
|
|
|
|
|
// This is a last minute adjustment, if the CSS width was set and
|
|
|
|
// we calculated it to be a little big, then make sure we are no bigger the computed size
|
|
|
|
// this only comes into play when the css width has been set to something smaller than
|
|
|
|
// the dropdown arrow
|
|
|
|
if (aReflowState.mComputedWidth != NS_UNCONSTRAINEDSIZE && aDesiredSize.width > computedWidth) {
|
|
|
|
aDesiredSize.width = computedWidth;
|
|
|
|
}
|
2000-03-07 18:54:31 +03:00
|
|
|
|
|
|
|
REFLOW_NOISY_MSG3("**AdjustCombobox - Reflow: WW: %d HH: %d\n", aDesiredSize.width, aDesiredSize.height);
|
|
|
|
|
2003-01-09 17:26:32 +03:00
|
|
|
if (aDesiredSize.mComputeMEW) {
|
2004-08-31 22:50:40 +04:00
|
|
|
aDesiredSize.SetMEWToActualWidth(aReflowState.mStylePosition->mWidth.GetUnit());
|
2000-03-10 07:46:16 +03:00
|
|
|
}
|
2002-11-12 22:17:51 +03:00
|
|
|
|
|
|
|
aDesiredSize.ascent =
|
|
|
|
txtKidSize.ascent + aReflowState.mComputedBorderPadding.top;
|
|
|
|
aDesiredSize.descent = aDesiredSize.height - aDesiredSize.ascent;
|
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
// Now cache the available height as our height without border and padding
|
|
|
|
// This sets up the optimization for if a new available width comes in and we are equal or
|
|
|
|
// less than it we can bail
|
|
|
|
if (aDesiredSize.width != mCacheSize.width || aDesiredSize.height != mCacheSize.height) {
|
|
|
|
if (aReflowState.availableWidth != NS_UNCONSTRAINEDSIZE) {
|
|
|
|
mCachedAvailableSize.width = aDesiredSize.width - (aBorderPadding.left + aBorderPadding.right);
|
1999-09-30 15:36:32 +04:00
|
|
|
}
|
2000-03-07 18:54:31 +03:00
|
|
|
if (aReflowState.availableHeight != NS_UNCONSTRAINEDSIZE) {
|
|
|
|
mCachedAvailableSize.height = aDesiredSize.height - (aBorderPadding.top + aBorderPadding.bottom);
|
2000-01-09 04:52:17 +03:00
|
|
|
}
|
2002-11-12 22:17:51 +03:00
|
|
|
nsFormControlFrame::SetupCachedSizes(mCacheSize, mCachedAscent,
|
2003-01-09 17:26:32 +03:00
|
|
|
mCachedMaxElementWidth, aDesiredSize);
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
2000-01-09 04:52:17 +03:00
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
// This is an experimental reflow that is turned off in the build
|
2000-05-27 03:34:59 +04:00
|
|
|
#ifdef DO_NEW_REFLOW
|
2000-03-07 18:54:31 +03:00
|
|
|
ReflowItems(aPresContext, aReflowState, aDesiredSize);
|
2000-01-28 18:24:49 +03:00
|
|
|
#endif
|
2000-03-07 18:54:31 +03:00
|
|
|
///////////////////////////////////////////////////////////////////
|
2000-03-03 07:28:59 +03:00
|
|
|
}
|
2000-03-03 10:14:58 +03:00
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
//----------------------------------------------------------
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------
|
|
|
|
#ifdef DO_REFLOW_DEBUG
|
2000-03-03 10:14:58 +03:00
|
|
|
static int myCounter = 0;
|
2000-03-07 18:54:31 +03:00
|
|
|
|
|
|
|
static void printSize(char * aDesc, nscoord aSize)
|
|
|
|
{
|
2000-10-29 02:17:53 +04:00
|
|
|
printf(" %s: ", aDesc);
|
2000-03-07 18:54:31 +03:00
|
|
|
if (aSize == NS_UNCONSTRAINEDSIZE) {
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("UC");
|
2000-03-07 18:54:31 +03:00
|
|
|
} else {
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("%d", PX(aSize));
|
2000-03-07 18:54:31 +03:00
|
|
|
}
|
|
|
|
}
|
2000-01-28 18:24:49 +03:00
|
|
|
#endif
|
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
//-------------------------------------------------------------------
|
|
|
|
//-- Main Reflow for the Combobox
|
|
|
|
//-------------------------------------------------------------------
|
2000-01-28 18:24:49 +03:00
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsComboboxControlFrame::Reflow(nsPresContext* aPresContext,
|
2000-01-28 18:24:49 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
2000-04-22 01:53:38 +04:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsComboboxControlFrame", aReflowState.reason);
|
2001-11-14 16:40:03 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
2000-04-22 01:53:38 +04:00
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
|
|
|
|
REFLOW_COUNTER_REQUEST();
|
|
|
|
|
|
|
|
#ifdef DO_REFLOW_DEBUG
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("-------------Starting Combobox Reflow ----------------------------\n");
|
|
|
|
printf("%p ** Id: %d nsCCF::Reflow %d R: ", this, mReflowId, myCounter++);
|
2000-01-28 18:24:49 +03:00
|
|
|
switch (aReflowState.reason) {
|
|
|
|
case eReflowReason_Initial:
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("Ini");break;
|
2000-01-28 18:24:49 +03:00
|
|
|
case eReflowReason_Incremental:
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("Inc");break;
|
2000-01-28 18:24:49 +03:00
|
|
|
case eReflowReason_Resize:
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("Rsz");break;
|
2000-03-07 18:54:31 +03:00
|
|
|
case eReflowReason_StyleChange:
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("Sty");break;
|
2000-03-07 18:54:31 +03:00
|
|
|
case eReflowReason_Dirty:
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("Drt ");
|
2000-01-28 18:24:49 +03:00
|
|
|
break;
|
2000-10-29 02:17:53 +04:00
|
|
|
default:printf("<unknown>%d", aReflowState.reason);break;
|
2000-01-28 18:24:49 +03:00
|
|
|
}
|
2000-03-07 18:54:31 +03:00
|
|
|
|
|
|
|
printSize("AW", aReflowState.availableWidth);
|
|
|
|
printSize("AH", aReflowState.availableHeight);
|
|
|
|
printSize("CW", aReflowState.mComputedWidth);
|
|
|
|
printSize("CH", aReflowState.mComputedHeight);
|
|
|
|
|
2005-02-20 02:54:36 +03:00
|
|
|
nsCOMPtr<nsIDOMHTMLOptionsCollection> optionsTemp = getter_AddRefs(GetOptions(mContent));
|
2000-03-07 18:54:31 +03:00
|
|
|
PRUint32 numOptions;
|
|
|
|
optionsTemp->GetLength(&numOptions);
|
|
|
|
printSize("NO", (nscoord)numOptions);
|
|
|
|
|
2000-10-29 02:17:53 +04:00
|
|
|
printf(" *\n");
|
2000-03-07 18:54:31 +03:00
|
|
|
|
2000-01-28 18:24:49 +03:00
|
|
|
#endif
|
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
|
|
|
|
PRBool bailOnWidth;
|
|
|
|
PRBool bailOnHeight;
|
|
|
|
|
|
|
|
// Do initial check to see if we can bail out
|
|
|
|
// If it is an Initial or Incremental Reflow we never bail out here
|
|
|
|
// XXX right now we only bail if the width meets the criteria
|
|
|
|
//
|
|
|
|
// We bail:
|
|
|
|
// if mComputedWidth == NS_UNCONSTRAINEDSIZE and
|
|
|
|
// availableWidth == NS_UNCONSTRAINEDSIZE and
|
|
|
|
// we have cached an available size
|
|
|
|
//
|
|
|
|
// We bail:
|
|
|
|
// if mComputedWidth == NS_UNCONSTRAINEDSIZE and
|
|
|
|
// availableWidth != NS_UNCONSTRAINEDSIZE and
|
|
|
|
// availableWidth minus its border equals our cached available size
|
|
|
|
//
|
|
|
|
// We bail:
|
|
|
|
// if mComputedWidth != NS_UNCONSTRAINEDSIZE and
|
|
|
|
// cached availableSize.width == aReflowState.mComputedWidth and
|
|
|
|
// cached AvailableSize.width == aCacheSize.width
|
|
|
|
//
|
|
|
|
// NOTE: this returns whether we are doing an Incremental reflow
|
2002-11-12 22:17:51 +03:00
|
|
|
nsFormControlFrame::SkipResizeReflow(mCacheSize,
|
|
|
|
mCachedAscent,
|
2003-01-09 17:26:32 +03:00
|
|
|
mCachedMaxElementWidth,
|
2000-03-07 18:54:31 +03:00
|
|
|
mCachedAvailableSize,
|
|
|
|
aDesiredSize, aReflowState,
|
|
|
|
aStatus,
|
|
|
|
bailOnWidth, bailOnHeight);
|
|
|
|
if (bailOnWidth) {
|
|
|
|
#ifdef DO_REFLOW_DEBUG // check or size
|
2001-02-07 12:57:26 +03:00
|
|
|
nsMargin borderPadding(0, 0, 0, 0);
|
|
|
|
CalcBorderPadding(borderPadding);
|
2000-03-07 18:54:31 +03:00
|
|
|
UNCONSTRAINED_CHECK();
|
2000-03-03 10:14:58 +03:00
|
|
|
#endif
|
2000-03-07 18:54:31 +03:00
|
|
|
REFLOW_DEBUG_MSG3("^** Done nsCCF DW: %d DH: %d\n\n", PX(aDesiredSize.width), PX(aDesiredSize.height));
|
2000-05-27 03:34:59 +04:00
|
|
|
NS_ASSERTION(aDesiredSize.width != kSizeNotSet, "aDesiredSize.width != kSizeNotSet");
|
|
|
|
NS_ASSERTION(aDesiredSize.height != kSizeNotSet, "aDesiredSize.height != kSizeNotSet");
|
|
|
|
aDesiredSize.mOverflowArea.x = 0;
|
|
|
|
aDesiredSize.mOverflowArea.y = 0;
|
|
|
|
aDesiredSize.mOverflowArea.width = aDesiredSize.width;
|
|
|
|
aDesiredSize.mOverflowArea.height = aDesiredSize.height;
|
2004-12-01 19:17:44 +03:00
|
|
|
FinishAndStoreOverflow(&aDesiredSize);
|
2000-03-07 18:54:31 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-03-03 07:28:59 +03:00
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
// Go get all of the important frame
|
2000-01-28 18:24:49 +03:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
// Don't try to do any special sizing and positioning unless all of the frames
|
|
|
|
// have been created.
|
2000-03-07 18:54:31 +03:00
|
|
|
if ((nsnull == mDisplayFrame) ||
|
2000-09-10 02:15:57 +04:00
|
|
|
(nsnull == mButtonFrame) ||
|
|
|
|
(nsnull == mDropdownFrame))
|
2000-01-28 18:24:49 +03:00
|
|
|
{
|
|
|
|
// Since combobox frames are missing just do a normal area frame reflow
|
|
|
|
return nsAreaFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
|
|
|
}
|
|
|
|
|
2005-06-21 04:00:14 +04:00
|
|
|
// Make sure the displayed text is the same as the selected option, bug 297389.
|
|
|
|
PRInt32 selectedIndex;
|
|
|
|
nsAutoString selectedOptionText;
|
2005-10-22 07:47:00 +04:00
|
|
|
if (!mDroppedDown) {
|
|
|
|
mListControlFrame->GetSelectedIndex(&selectedIndex);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// In dropped down mode the "selected index" is the hovered menu item,
|
|
|
|
// we want the last selected item which is |mDisplayedIndex| in this case.
|
|
|
|
selectedIndex = mDisplayedIndex;
|
|
|
|
}
|
2005-06-21 04:00:14 +04:00
|
|
|
if (selectedIndex != -1) {
|
|
|
|
mListControlFrame->GetOptionText(selectedIndex, selectedOptionText);
|
|
|
|
}
|
|
|
|
if (mDisplayedOptionText != selectedOptionText) {
|
|
|
|
RedisplayText(selectedIndex);
|
|
|
|
}
|
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
// We should cache this instead getting it everytime
|
2000-01-28 18:24:49 +03:00
|
|
|
// the default size of the of scrollbar
|
|
|
|
// that will be the default width of the dropdown button
|
|
|
|
// the height will be the height of the text
|
2004-02-03 01:17:21 +03:00
|
|
|
float w, h;
|
|
|
|
// Get the width in Device pixels times p2t
|
|
|
|
aPresContext->DeviceContext()->GetScrollBarDimensions(w, h);
|
|
|
|
nscoord scrollbarWidth = NSToCoordRound(w);
|
2000-03-07 18:54:31 +03:00
|
|
|
|
|
|
|
// set up a new reflow state for use throughout
|
|
|
|
nsHTMLReflowState firstPassState(aReflowState);
|
|
|
|
nsHTMLReflowMetrics dropdownDesiredSize(nsnull);
|
2000-02-09 22:34:39 +03:00
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
// Check to see if this a fully unconstrained reflow
|
2005-06-17 06:42:29 +04:00
|
|
|
PRBool fullyUnconstrained = firstPassState.mComputedWidth == NS_UNCONSTRAINEDSIZE;
|
2000-01-28 18:24:49 +03:00
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
PRBool forceReflow = PR_FALSE;
|
2000-01-28 18:24:49 +03:00
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
// Only reflow the display and button
|
|
|
|
// if they are the target of the incremental reflow, unless they change size.
|
|
|
|
if (eReflowReason_Incremental == aReflowState.reason) {
|
2002-05-10 22:22:41 +04:00
|
|
|
nsHTMLReflowCommand *command = firstPassState.path->mReflowCommand;
|
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
// Check to see if we are the target of the Incremental Reflow
|
2002-05-10 22:22:41 +04:00
|
|
|
if (command) {
|
2000-03-07 18:54:31 +03:00
|
|
|
// We need to check here to see if we can get away with just reflowing
|
|
|
|
// the combobox and not the dropdown
|
|
|
|
REFLOW_DEBUG_MSG("-----------------Target is Combobox------------\n");
|
|
|
|
|
|
|
|
// If the mComputedWidth matches our cached display width
|
|
|
|
// then we get away with bailing out
|
|
|
|
PRBool doFullReflow = firstPassState.mComputedWidth != NS_UNCONSTRAINEDSIZE &&
|
|
|
|
firstPassState.mComputedWidth != mItemDisplayWidth;
|
|
|
|
if (!doFullReflow) {
|
|
|
|
// OK, so we got lucky and the size didn't change
|
|
|
|
// so do a simple reflow and bail out
|
|
|
|
REFLOW_DEBUG_MSG("------------Reflowing AreaFrame and bailing----\n\n");
|
|
|
|
ReflowCombobox(aPresContext, firstPassState, aDesiredSize, aStatus,
|
2005-12-13 02:53:06 +03:00
|
|
|
mDisplayFrame, mItemDisplayWidth,
|
2002-11-12 22:17:51 +03:00
|
|
|
scrollbarWidth, aReflowState.mComputedBorderPadding);
|
2000-03-07 18:54:31 +03:00
|
|
|
REFLOW_COUNTER();
|
|
|
|
UNCONSTRAINED_CHECK();
|
|
|
|
REFLOW_DEBUG_MSG3("&** Done nsCCF DW: %d DH: %d\n\n", PX(aDesiredSize.width), PX(aDesiredSize.height));
|
2000-05-27 03:34:59 +04:00
|
|
|
NS_ASSERTION(aDesiredSize.width != kSizeNotSet, "aDesiredSize.width != kSizeNotSet");
|
|
|
|
NS_ASSERTION(aDesiredSize.height != kSizeNotSet, "aDesiredSize.height != kSizeNotSet");
|
|
|
|
aDesiredSize.mOverflowArea.x = 0;
|
|
|
|
aDesiredSize.mOverflowArea.y = 0;
|
|
|
|
aDesiredSize.mOverflowArea.width = aDesiredSize.width;
|
|
|
|
aDesiredSize.mOverflowArea.height = aDesiredSize.height;
|
2000-03-07 18:54:31 +03:00
|
|
|
}
|
2002-05-10 22:22:41 +04:00
|
|
|
else {
|
|
|
|
// Nope, something changed that affected our size
|
|
|
|
// so we need to do a full reflow and resize ourself
|
|
|
|
REFLOW_DEBUG_MSG("------------Do Full Reflow----\n\n");
|
|
|
|
firstPassState.reason = eReflowReason_StyleChange;
|
|
|
|
firstPassState.path = nsnull;
|
|
|
|
forceReflow = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
2000-01-28 18:24:49 +03:00
|
|
|
|
2002-05-10 22:22:41 +04:00
|
|
|
// See if any of the children are targets, as well.
|
|
|
|
nsReflowPath::iterator iter = aReflowState.path->FirstChild();
|
|
|
|
nsReflowPath::iterator end = aReflowState.path->EndChildren();
|
|
|
|
for ( ; iter != end; ++iter) {
|
2000-03-07 18:54:31 +03:00
|
|
|
// Now, see if our target is the dropdown
|
|
|
|
// If so, maybe an items was added or some style changed etc.
|
|
|
|
// OR
|
|
|
|
// We get an Incremental reflow on the dropdown when it is being
|
|
|
|
// shown or hidden.
|
2002-05-10 22:22:41 +04:00
|
|
|
if (*iter == mDropdownFrame) {
|
2000-03-07 18:54:31 +03:00
|
|
|
REFLOW_DEBUG_MSG("---------Target is Dropdown (Clearing Unc DD Size)---\n");
|
|
|
|
// Nope, we were unlucky so now we do a full reflow
|
|
|
|
mCachedUncDropdownSize.width = kSizeNotSet;
|
|
|
|
mCachedUncDropdownSize.height = kSizeNotSet;
|
|
|
|
REFLOW_DEBUG_MSG("---- Doing Full Reflow\n");
|
|
|
|
// This is an incremental reflow targeted at the dropdown list
|
|
|
|
// and it didn't have anything to do with being show or hidden.
|
|
|
|
//
|
|
|
|
// The incremental reflow will not get to the dropdown list
|
|
|
|
// because it is in the "popup" list
|
|
|
|
// when this flow of control drops out of this if it will do a reflow
|
|
|
|
// on the AreaFrame which SHOULD make it get tothe drop down
|
|
|
|
// except that it is in the popup list, so we have it reflowed as
|
2005-11-21 01:05:24 +03:00
|
|
|
// a StyleChange, this is not as efficient as doing an Incremental
|
2000-03-07 18:54:31 +03:00
|
|
|
//
|
|
|
|
// At this point we want to by pass the reflow optimization in the dropdown
|
|
|
|
// because we aren't why it is getting an incremental reflow, but we do
|
|
|
|
// know that it needs to be resized or restyled
|
|
|
|
//mListControlFrame->SetOverrideReflowOptimization(PR_TRUE);
|
|
|
|
|
2002-05-10 22:22:41 +04:00
|
|
|
} else if (*iter == mDisplayFrame || *iter == mButtonFrame) {
|
|
|
|
REFLOW_DEBUG_MSG2("-----------------Target is %s------------\n", (*iter == mDisplayFrame?"DisplayItem Frame":"DropDown Btn Frame"));
|
2000-06-15 17:02:10 +04:00
|
|
|
// The incremental reflow is targeted at either the block or the button
|
2000-03-07 18:54:31 +03:00
|
|
|
REFLOW_DEBUG_MSG("---- Doing AreaFrame Reflow and then bailing out\n");
|
|
|
|
// Do simple reflow and bail out
|
|
|
|
ReflowCombobox(aPresContext, firstPassState, aDesiredSize, aStatus,
|
2005-12-13 02:53:06 +03:00
|
|
|
mDisplayFrame, mItemDisplayWidth, scrollbarWidth,
|
2002-11-12 22:17:51 +03:00
|
|
|
aReflowState.mComputedBorderPadding,
|
|
|
|
kSizeNotSet, PR_TRUE);
|
2000-03-07 18:54:31 +03:00
|
|
|
REFLOW_DEBUG_MSG3("+** Done nsCCF DW: %d DH: %d\n\n", PX(aDesiredSize.width), PX(aDesiredSize.height));
|
|
|
|
REFLOW_COUNTER();
|
|
|
|
UNCONSTRAINED_CHECK();
|
2000-05-27 03:34:59 +04:00
|
|
|
NS_ASSERTION(aDesiredSize.width != kSizeNotSet, "aDesiredSize.width != kSizeNotSet");
|
|
|
|
NS_ASSERTION(aDesiredSize.height != kSizeNotSet, "aDesiredSize.height != kSizeNotSet");
|
|
|
|
aDesiredSize.mOverflowArea.x = 0;
|
|
|
|
aDesiredSize.mOverflowArea.y = 0;
|
|
|
|
aDesiredSize.mOverflowArea.width = aDesiredSize.width;
|
|
|
|
aDesiredSize.mOverflowArea.height = aDesiredSize.height;
|
2002-05-10 22:22:41 +04:00
|
|
|
continue;
|
2000-03-07 18:54:31 +03:00
|
|
|
} else {
|
2000-04-19 17:55:17 +04:00
|
|
|
nsIFrame * plainLstFrame;
|
2001-01-04 23:44:42 +03:00
|
|
|
if (NS_SUCCEEDED(mListControlFrame->QueryInterface(NS_GET_IID(nsIFrame), (void**)&plainLstFrame))) {
|
2004-01-09 17:20:53 +03:00
|
|
|
nsIFrame * frame = plainLstFrame->GetFirstChild(nsnull);
|
2000-04-19 17:55:17 +04:00
|
|
|
nsIScrollableFrame * scrollFrame;
|
|
|
|
if (NS_SUCCEEDED(frame->QueryInterface(NS_GET_IID(nsIScrollableFrame), (void**)&scrollFrame))) {
|
2001-03-21 08:32:22 +03:00
|
|
|
plainLstFrame->Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
2000-04-19 17:55:17 +04:00
|
|
|
|
|
|
|
aDesiredSize.width = mCacheSize.width;
|
|
|
|
aDesiredSize.height = mCacheSize.height;
|
2002-11-12 22:17:51 +03:00
|
|
|
aDesiredSize.ascent = mCachedAscent;
|
|
|
|
aDesiredSize.descent = aDesiredSize.height - aDesiredSize.ascent;
|
2000-04-19 17:55:17 +04:00
|
|
|
|
2003-01-09 17:26:32 +03:00
|
|
|
if (aDesiredSize.mComputeMEW) {
|
|
|
|
aDesiredSize.mMaxElementWidth = mCachedMaxElementWidth;
|
2000-04-19 17:55:17 +04:00
|
|
|
}
|
2000-05-27 03:34:59 +04:00
|
|
|
NS_ASSERTION(aDesiredSize.width != kSizeNotSet, "aDesiredSize.width != kSizeNotSet");
|
|
|
|
NS_ASSERTION(aDesiredSize.height != kSizeNotSet, "aDesiredSize.height != kSizeNotSet");
|
|
|
|
aDesiredSize.mOverflowArea.x = 0;
|
|
|
|
aDesiredSize.mOverflowArea.y = 0;
|
|
|
|
aDesiredSize.mOverflowArea.width = aDesiredSize.width;
|
|
|
|
aDesiredSize.mOverflowArea.height = aDesiredSize.height;
|
2002-05-10 22:22:41 +04:00
|
|
|
continue;
|
2000-04-19 17:55:17 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
// Here the target of the reflow was a child of the dropdown list
|
|
|
|
// so we must do a full reflow
|
|
|
|
REFLOW_DEBUG_MSG("-----------------Target is Dropdown's Child (Option Item)------------\n");
|
|
|
|
REFLOW_DEBUG_MSG("---- Doing Reflow as StyleChange\n");
|
|
|
|
}
|
|
|
|
firstPassState.reason = eReflowReason_StyleChange;
|
2002-05-10 22:22:41 +04:00
|
|
|
firstPassState.path = nsnull;
|
2000-03-07 18:54:31 +03:00
|
|
|
mListControlFrame->SetOverrideReflowOptimization(PR_TRUE);
|
|
|
|
forceReflow = PR_TRUE;
|
2000-01-28 18:24:49 +03:00
|
|
|
}
|
2000-03-07 18:54:31 +03:00
|
|
|
}
|
2000-01-28 18:24:49 +03:00
|
|
|
|
2001-03-20 02:20:21 +03:00
|
|
|
#ifdef IBMBIDI
|
|
|
|
else if (eReflowReason_StyleChange == aReflowState.reason) {
|
|
|
|
forceReflow = PR_TRUE;
|
|
|
|
}
|
|
|
|
#endif // IBMBIDI
|
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
// Here is another special optimization
|
|
|
|
// Only reflow the dropdown if it has never been reflowed unconstrained
|
|
|
|
//
|
|
|
|
// Or someone up above here may want to force it to be reflowed
|
|
|
|
// by setting one or both of these to kSizeNotSet
|
|
|
|
if ((mCachedUncDropdownSize.width == kSizeNotSet &&
|
|
|
|
mCachedUncDropdownSize.height == kSizeNotSet) || forceReflow) {
|
|
|
|
REFLOW_DEBUG_MSG3("---Re %d,%d\n", PX(mCachedUncDropdownSize.width), PX(mCachedUncDropdownSize.height));
|
2001-02-23 04:45:45 +03:00
|
|
|
|
|
|
|
// Tell it we are doing the first pass, which means it will
|
|
|
|
// do the unconstained reflow and skip the second reflow this time around
|
|
|
|
nsListControlFrame * lcf = NS_STATIC_CAST(nsListControlFrame*, mDropdownFrame);
|
|
|
|
lcf->SetPassId(1);
|
2000-03-07 18:54:31 +03:00
|
|
|
// A width has not been specified for the select so size the display area
|
|
|
|
// to match the width of the longest item in the drop-down list. The dropdown
|
|
|
|
// list has already been reflowed and sized to shrink around its contents above.
|
2000-09-10 02:15:57 +04:00
|
|
|
ReflowComboChildFrame(mDropdownFrame, aPresContext, dropdownDesiredSize, firstPassState,
|
2000-03-07 18:54:31 +03:00
|
|
|
aStatus, NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
|
2001-02-23 04:45:45 +03:00
|
|
|
lcf->SetPassId(0); // reset it back
|
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
if (forceReflow) {
|
|
|
|
mCachedUncDropdownSize.width = dropdownDesiredSize.width;
|
|
|
|
mCachedUncDropdownSize.height = dropdownDesiredSize.height;
|
|
|
|
}
|
2000-01-28 18:24:49 +03:00
|
|
|
} else {
|
2000-03-07 18:54:31 +03:00
|
|
|
// Here we pretended we did an unconstrained reflow
|
|
|
|
// so we set the cached values and continue on
|
|
|
|
REFLOW_DEBUG_MSG3("--- Using Cached ListBox Size %d,%d\n", PX(mCachedUncDropdownSize.width), PX(mCachedUncDropdownSize.height));
|
|
|
|
dropdownDesiredSize.width = mCachedUncDropdownSize.width;
|
|
|
|
dropdownDesiredSize.height = mCachedUncDropdownSize.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
// XXX - I need to clean this nect part up a little it is very redundant
|
|
|
|
|
|
|
|
// Check here to if this is a mComputed unconstrained reflow
|
2005-06-17 06:42:29 +04:00
|
|
|
PRBool computedUnconstrained = firstPassState.mComputedWidth == NS_UNCONSTRAINEDSIZE;
|
2000-03-07 18:54:31 +03:00
|
|
|
if (computedUnconstrained && !forceReflow) {
|
|
|
|
// Because Incremental reflows aren't actually getting to the dropdown
|
|
|
|
// we cache the size from when it did a fully unconstrained reflow
|
|
|
|
// we then check to see if the size changed at all,
|
|
|
|
// if not then bail out we don't need to worry
|
|
|
|
if (mCachedUncDropdownSize.width == kSizeNotSet && mCachedUncDropdownSize.height == kSizeNotSet) {
|
|
|
|
mCachedUncDropdownSize.width = dropdownDesiredSize.width;
|
|
|
|
mCachedUncDropdownSize.height = dropdownDesiredSize.height;
|
|
|
|
REFLOW_DEBUG_MSG3("---1 Caching mCachedUncDropdownSize %d,%d\n", PX(mCachedUncDropdownSize.width), PX(mCachedUncDropdownSize.height));
|
|
|
|
|
|
|
|
} else if (mCachedUncDropdownSize.width == dropdownDesiredSize.width &&
|
|
|
|
mCachedUncDropdownSize.height == dropdownDesiredSize.height) {
|
|
|
|
|
|
|
|
if (mCachedUncComboSize.width != kSizeNotSet && mCachedUncComboSize.height != kSizeNotSet) {
|
|
|
|
REFLOW_DEBUG_MSG3("--- Bailing because of mCachedUncDropdownSize %d,%d\n\n", PX(mCachedUncDropdownSize.width), PX(mCachedUncDropdownSize.height));
|
|
|
|
aDesiredSize.width = mCachedUncComboSize.width;
|
|
|
|
aDesiredSize.height = mCachedUncComboSize.height;
|
2002-11-14 01:34:09 +03:00
|
|
|
aDesiredSize.ascent = mCachedAscent;
|
|
|
|
aDesiredSize.descent = aDesiredSize.height - aDesiredSize.ascent;
|
2000-03-07 18:54:31 +03:00
|
|
|
|
2003-01-09 17:26:32 +03:00
|
|
|
if (aDesiredSize.mComputeMEW) {
|
|
|
|
aDesiredSize.mMaxElementWidth = mCachedMaxElementWidth;
|
2000-03-07 18:54:31 +03:00
|
|
|
}
|
|
|
|
UNCONSTRAINED_CHECK();
|
|
|
|
REFLOW_DEBUG_MSG3("#** Done nsCCF DW: %d DH: %d\n\n", PX(aDesiredSize.width), PX(aDesiredSize.height));
|
2000-05-27 03:34:59 +04:00
|
|
|
NS_ASSERTION(aDesiredSize.width != kSizeNotSet, "aDesiredSize.width != kSizeNotSet");
|
|
|
|
NS_ASSERTION(aDesiredSize.height != kSizeNotSet, "aDesiredSize.height != kSizeNotSet");
|
|
|
|
aDesiredSize.mOverflowArea.x = 0;
|
|
|
|
aDesiredSize.mOverflowArea.y = 0;
|
|
|
|
aDesiredSize.mOverflowArea.width = aDesiredSize.width;
|
|
|
|
aDesiredSize.mOverflowArea.height = aDesiredSize.height;
|
2004-12-01 19:17:44 +03:00
|
|
|
FinishAndStoreOverflow(&aDesiredSize);
|
2000-03-07 18:54:31 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
mCachedUncDropdownSize.width = dropdownDesiredSize.width;
|
|
|
|
mCachedUncDropdownSize.height = dropdownDesiredSize.height;
|
2000-01-28 18:24:49 +03:00
|
|
|
}
|
2000-03-07 18:54:31 +03:00
|
|
|
}
|
|
|
|
// clean up stops here
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// So this point we know we flowed the dropdown unconstrained
|
|
|
|
// now we get to figure out how big we need to be and
|
|
|
|
//
|
|
|
|
// We don't reflow the combobox here at the new size
|
|
|
|
// we cache its new size and reflow it on the dropdown
|
|
|
|
nsSize size;
|
|
|
|
PRInt32 length = 0;
|
|
|
|
mListControlFrame->GetNumberOfOptions(&length);
|
|
|
|
|
|
|
|
// dropdownRect will hold the content size (minus border padding)
|
|
|
|
// for the display area
|
2003-07-04 16:50:32 +04:00
|
|
|
nsRect dropdownRect = mDropdownFrame->GetRect();
|
2001-10-16 04:32:14 +04:00
|
|
|
if (eReflowReason_Resize == aReflowState.reason) {
|
2002-11-12 22:17:51 +03:00
|
|
|
dropdownRect.Deflate(aReflowState.mComputedBorderPadding);
|
2001-10-16 04:32:14 +04:00
|
|
|
}
|
2000-03-07 18:54:31 +03:00
|
|
|
|
|
|
|
// Get maximum size of the largest item in the dropdown
|
|
|
|
// The height of the display frame will be that height
|
|
|
|
// the width will be the same as
|
|
|
|
// the dropdown width (minus its borderPadding) OR
|
|
|
|
// a caculation off the mComputedWidth from reflow
|
|
|
|
mListControlFrame->GetMaximumSize(size);
|
|
|
|
|
|
|
|
// the variable "size" will now be
|
|
|
|
// the default size of the dropdown btn
|
2002-10-01 18:24:15 +04:00
|
|
|
if (scrollbarWidth > 0) {
|
|
|
|
size.width = scrollbarWidth;
|
2000-03-07 18:54:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get the border and padding for the dropdown
|
2001-02-07 12:57:26 +03:00
|
|
|
nsMargin dropBorderPadding(0, 0, 0, 0);
|
|
|
|
mDropdownFrame->CalcBorderPadding(dropBorderPadding);
|
2000-03-07 18:54:31 +03:00
|
|
|
|
|
|
|
// get the borderPadding for the display area
|
2001-02-07 12:57:26 +03:00
|
|
|
nsMargin dspBorderPadding(0, 0, 0, 0);
|
|
|
|
mDisplayFrame->CalcBorderPadding(dspBorderPadding);
|
2000-03-07 18:54:31 +03:00
|
|
|
|
2005-11-21 01:05:24 +03:00
|
|
|
// Subtract dropdown's borderPadding from the width of the dropdown rect
|
2000-03-07 18:54:31 +03:00
|
|
|
// to get the size of the content area
|
|
|
|
//
|
|
|
|
// the height will come from the mDisplayFrame's height
|
|
|
|
// declare a size for the item display frame
|
|
|
|
|
|
|
|
//Set the desired size for the button and display frame
|
|
|
|
if (NS_UNCONSTRAINEDSIZE == firstPassState.mComputedWidth) {
|
|
|
|
REFLOW_DEBUG_MSG("Unconstrained.....\n");
|
|
|
|
REFLOW_DEBUG_MSG4("*B mItemDisplayWidth %d dropdownRect.width:%d dropdownRect.w+h %d\n", PX(mItemDisplayWidth), PX(dropdownRect.width), PX((dropBorderPadding.left + dropBorderPadding.right)));
|
2000-03-03 07:28:59 +03:00
|
|
|
|
2003-04-09 00:50:57 +04:00
|
|
|
// Start with the dropdown rect's width (at this stage, it's the
|
|
|
|
// natural width of the content in the list, i.e., the width of
|
|
|
|
// the widest content, i.e. the preferred width for the display
|
|
|
|
// frame) and add room for the button, which is assumed to match
|
|
|
|
// the width of the scrollbar (note that the scrollbarWidth is
|
|
|
|
// passed as aBtnWidth to ReflowCombobox). (When the dropdown was
|
|
|
|
// an nsScrollFrame the scrollbar width seems to have already been
|
|
|
|
// added to its unconstrained width.)
|
|
|
|
mItemDisplayWidth = dropdownRect.width + scrollbarWidth;
|
2000-03-07 18:54:31 +03:00
|
|
|
|
|
|
|
REFLOW_DEBUG_MSG2("* mItemDisplayWidth %d\n", PX(mItemDisplayWidth));
|
|
|
|
|
2000-12-20 18:09:00 +03:00
|
|
|
// mItemDisplayWidth must be the size of the "display" frame including it's
|
|
|
|
// border and padding, but NOT including the comboboxes border and padding
|
|
|
|
mItemDisplayWidth += dspBorderPadding.left + dspBorderPadding.right;
|
|
|
|
mItemDisplayWidth -= aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right;
|
2000-03-07 18:54:31 +03:00
|
|
|
|
|
|
|
REFLOW_DEBUG_MSG2("*A mItemDisplayWidth %d\n", PX(mItemDisplayWidth));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
REFLOW_DEBUG_MSG("Constrained.....\n");
|
2000-01-28 18:24:49 +03:00
|
|
|
if (firstPassState.mComputedWidth > 0) {
|
2000-03-07 18:54:31 +03:00
|
|
|
// Compute the display item's width from reflow's mComputedWidth
|
|
|
|
// mComputedWidth has already excluded border and padding
|
|
|
|
// so subtract off the button's size
|
|
|
|
REFLOW_DEBUG_MSG3("B mItemDisplayWidth %d %d\n", PX(mItemDisplayWidth), PX(dspBorderPadding.right));
|
2000-12-20 18:09:00 +03:00
|
|
|
// Display Frame's width comes from the mComputedWidth and therefore implies that it
|
|
|
|
// includes the "display" frame's border and padding.
|
|
|
|
mItemDisplayWidth = firstPassState.mComputedWidth;
|
2000-03-07 18:54:31 +03:00
|
|
|
REFLOW_DEBUG_MSG2("A mItemDisplayWidth %d\n", PX(mItemDisplayWidth));
|
|
|
|
REFLOW_DEBUG_MSG4("firstPassState.mComputedWidth %d - size.width %d dspBorderPadding.right %d\n", PX(firstPassState.mComputedWidth), PX(size.width), PX(dspBorderPadding.right));
|
|
|
|
}
|
|
|
|
}
|
2000-08-03 18:13:40 +04:00
|
|
|
|
|
|
|
// Fix for Bug 44788 (remove this comment later)
|
|
|
|
if (firstPassState.mComputedHeight > 0 && NS_UNCONSTRAINEDSIZE != firstPassState.mComputedHeight) {
|
|
|
|
size.height = firstPassState.mComputedHeight;
|
|
|
|
}
|
|
|
|
|
2004-09-29 05:44:29 +04:00
|
|
|
if (mCacheSize.height != size.height) {
|
|
|
|
// if the cached height is not equal to the current height,
|
|
|
|
// the cached height is reset.
|
|
|
|
mCacheSize.height = kSizeNotSet;
|
|
|
|
}
|
2000-08-03 18:13:40 +04:00
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
// this reflows and makes and last minute adjustments
|
|
|
|
ReflowCombobox(aPresContext, firstPassState, aDesiredSize, aStatus,
|
2005-12-13 02:53:06 +03:00
|
|
|
mDisplayFrame, mItemDisplayWidth, scrollbarWidth,
|
2002-11-12 22:17:51 +03:00
|
|
|
aReflowState.mComputedBorderPadding, size.height);
|
2000-01-28 18:24:49 +03:00
|
|
|
|
2005-11-15 07:03:08 +03:00
|
|
|
// The dropdown was reflowed UNCONSTRAINED before, now we need to reflow it
|
|
|
|
// so that all children match the desired width.
|
|
|
|
// The dropdown MUST always be either the same size as the combo or larger
|
|
|
|
// if necessary. Note that individual children can be narrower in case they
|
|
|
|
// are constrained by 'width', 'max-width' etc.
|
|
|
|
if (eReflowReason_Initial == firstPassState.reason) {
|
|
|
|
firstPassState.reason = eReflowReason_Resize;
|
2000-03-07 18:54:31 +03:00
|
|
|
}
|
2005-11-15 07:03:08 +03:00
|
|
|
REFLOW_DEBUG_MSG3("*** Reflowing ListBox to width: %d it was %d\n", PX(aDesiredSize.width), PX(dropdownDesiredSize.width));
|
|
|
|
|
|
|
|
// Tell it we are doing the second pass, which means we will skip
|
|
|
|
// doing the unconstained reflow, we already know that size
|
|
|
|
nsListControlFrame * lcf = NS_STATIC_CAST(nsListControlFrame*, mDropdownFrame);
|
|
|
|
lcf->SetPassId(2);
|
|
|
|
// Reflow the dropdown list to be
|
|
|
|
// MAX(width of the display + button, width of the widest option). bug 305705.
|
|
|
|
const nscoord availableWidth =
|
|
|
|
PR_MAX(aDesiredSize.width, dropdownDesiredSize.width -
|
|
|
|
aReflowState.mComputedBorderPadding.left -
|
|
|
|
aReflowState.mComputedBorderPadding.right);
|
|
|
|
ReflowComboChildFrame(mDropdownFrame, aPresContext, dropdownDesiredSize,
|
|
|
|
firstPassState, aStatus,
|
|
|
|
availableWidth, NS_UNCONSTRAINEDSIZE);
|
|
|
|
lcf->SetPassId(0);
|
2000-01-28 18:24:49 +03:00
|
|
|
|
|
|
|
// Set the max element size to be the same as the desired element size.
|
2003-01-09 17:26:32 +03:00
|
|
|
if (aDesiredSize.mComputeMEW) {
|
2004-08-31 22:50:40 +04:00
|
|
|
aDesiredSize.SetMEWToActualWidth(aReflowState.mStylePosition->mWidth.GetUnit());
|
2000-01-28 18:24:49 +03:00
|
|
|
}
|
|
|
|
|
1999-11-12 01:13:33 +03:00
|
|
|
#if 0
|
2000-01-09 04:52:17 +03:00
|
|
|
COMPARE_QUIRK_SIZE("nsComboboxControlFrame", 127, 22)
|
1999-12-22 22:46:28 +03:00
|
|
|
#endif
|
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
// cache the availabe size to be our desired size minus the borders
|
2003-03-19 07:35:08 +03:00
|
|
|
// this is so if our cached available size is ever equal to or less
|
|
|
|
// than the real available size we can bail out
|
2000-03-07 18:54:31 +03:00
|
|
|
if (aReflowState.availableWidth != NS_UNCONSTRAINEDSIZE) {
|
2002-11-12 22:17:51 +03:00
|
|
|
mCachedAvailableSize.width = aDesiredSize.width -
|
|
|
|
(aReflowState.mComputedBorderPadding.left +
|
|
|
|
aReflowState.mComputedBorderPadding.right);
|
2000-03-07 18:54:31 +03:00
|
|
|
}
|
|
|
|
if (aReflowState.availableHeight != NS_UNCONSTRAINEDSIZE) {
|
2002-11-12 22:17:51 +03:00
|
|
|
mCachedAvailableSize.height = aDesiredSize.height -
|
|
|
|
(aReflowState.mComputedBorderPadding.top +
|
|
|
|
aReflowState.mComputedBorderPadding.bottom);
|
2000-03-07 18:54:31 +03:00
|
|
|
}
|
|
|
|
|
2003-01-09 17:26:32 +03:00
|
|
|
nsFormControlFrame::SetupCachedSizes(mCacheSize, mCachedAscent, mCachedMaxElementWidth, aDesiredSize);
|
2000-03-07 18:54:31 +03:00
|
|
|
|
|
|
|
REFLOW_DEBUG_MSG3("** Done nsCCF DW: %d DH: %d\n\n", PX(aDesiredSize.width), PX(aDesiredSize.height));
|
|
|
|
REFLOW_COUNTER();
|
|
|
|
UNCONSTRAINED_CHECK();
|
|
|
|
|
|
|
|
// If this was a fully unconstrained reflow we cache
|
|
|
|
// the combobox's unconstrained size
|
|
|
|
if (fullyUnconstrained) {
|
|
|
|
mCachedUncComboSize.width = aDesiredSize.width;
|
|
|
|
mCachedUncComboSize.height = aDesiredSize.height;
|
|
|
|
}
|
|
|
|
|
2000-05-27 03:34:59 +04:00
|
|
|
NS_ASSERTION(aDesiredSize.width != kSizeNotSet, "aDesiredSize.width != kSizeNotSet");
|
|
|
|
NS_ASSERTION(aDesiredSize.height != kSizeNotSet, "aDesiredSize.height != kSizeNotSet");
|
|
|
|
aDesiredSize.mOverflowArea.x = 0;
|
|
|
|
aDesiredSize.mOverflowArea.y = 0;
|
|
|
|
aDesiredSize.mOverflowArea.width = aDesiredSize.width;
|
|
|
|
aDesiredSize.mOverflowArea.height = aDesiredSize.height;
|
2002-05-29 02:50:43 +04:00
|
|
|
|
2004-08-31 22:50:40 +04:00
|
|
|
FinishAndStoreOverflow(&aDesiredSize);
|
2002-05-29 02:50:43 +04:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
return rv;
|
1999-01-18 18:14:00 +03:00
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
}
|
2000-03-07 18:54:31 +03:00
|
|
|
|
1999-01-18 18:14:00 +03:00
|
|
|
//--------------------------------------------------------------
|
|
|
|
|
2005-09-19 06:15:54 +04:00
|
|
|
nsIFrame*
|
2005-01-02 18:46:53 +03:00
|
|
|
nsComboboxControlFrame::GetFrameForPoint(const nsPoint& aPoint,
|
2005-09-19 06:15:54 +04:00
|
|
|
nsFramePaintLayer aWhichLayer)
|
1999-08-10 23:25:22 +04:00
|
|
|
{
|
2000-08-06 23:24:48 +04:00
|
|
|
// The button is getting the hover events so...
|
|
|
|
// None of the children frames of the combobox get
|
|
|
|
// the events. (like the button frame), that way
|
|
|
|
// all event based style rules affect the combobox
|
|
|
|
// and not the any of the child frames. (The inability
|
|
|
|
// of the parent to be in the :hover state at the same
|
|
|
|
// time as its children is really a bug (#5693 / #33736)
|
|
|
|
// in the implementation of :hover.)
|
|
|
|
|
|
|
|
// It would be theoretically more elegant to check the
|
|
|
|
// children when not disabled, and then use event
|
|
|
|
// capturing. It would correctly handle situations (obscure!!)
|
|
|
|
// where the children were visible but the parent was not.
|
|
|
|
// Now the functionality of the OPTIONs depends on the SELECT
|
|
|
|
// being visible. Oh well...
|
|
|
|
|
2005-09-19 06:15:54 +04:00
|
|
|
return nsFrame::GetFrameForPoint(aPoint, aWhichLayer);
|
1999-08-10 23:25:22 +04:00
|
|
|
}
|
|
|
|
|
1999-01-18 18:14:00 +03:00
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
1999-11-02 01:12:45 +03:00
|
|
|
|
|
|
|
#ifdef NS_DEBUG
|
1999-01-18 18:14:00 +03:00
|
|
|
NS_IMETHODIMP
|
2001-11-14 04:33:42 +03:00
|
|
|
nsComboboxControlFrame::GetFrameName(nsAString& aResult) const
|
1999-01-18 18:14:00 +03:00
|
|
|
{
|
2001-11-14 04:33:42 +03:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("ComboboxControl"), aResult);
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1999-01-18 18:14:00 +03:00
|
|
|
|
2002-01-09 22:17:46 +03:00
|
|
|
|
1999-01-18 18:14:00 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIComboboxControlFrame
|
|
|
|
//----------------------------------------------------------------------
|
1999-08-26 18:54:07 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsComboboxControlFrame::ShowDropDown(PRBool aDoDropDown)
|
|
|
|
{
|
2002-06-04 04:44:04 +04:00
|
|
|
if (nsFormControlHelper::GetDisabled(mContent)) {
|
1999-08-26 18:54:07 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mDroppedDown && aDoDropDown) {
|
1999-08-31 17:22:40 +04:00
|
|
|
if (mListControlFrame) {
|
2004-12-27 18:05:18 +03:00
|
|
|
mListControlFrame->SyncViewWithFrame();
|
1999-08-31 17:22:40 +04:00
|
|
|
}
|
2005-08-16 16:20:58 +04:00
|
|
|
ToggleList(GetPresContext());
|
1999-08-26 18:54:07 +04:00
|
|
|
return NS_OK;
|
|
|
|
} else if (mDroppedDown && !aDoDropDown) {
|
2005-08-16 16:20:58 +04:00
|
|
|
ToggleList(GetPresContext());
|
1999-08-26 18:54:07 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
1999-01-18 18:14:00 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
nsComboboxControlFrame::SetDropDown(nsIFrame* aDropDownFrame)
|
1999-01-18 18:14:00 +03:00
|
|
|
{
|
1999-08-31 17:22:40 +04:00
|
|
|
mDropdownFrame = aDropDownFrame;
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
|
2002-07-18 04:58:31 +04:00
|
|
|
if (NS_OK != CallQueryInterface(mDropdownFrame, &mListControlFrame)) {
|
1999-01-18 18:14:00 +03:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2000-03-07 18:54:31 +03:00
|
|
|
|
1999-01-18 18:14:00 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-23 18:05:37 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsComboboxControlFrame::GetDropDown(nsIFrame** aDropDownFrame)
|
|
|
|
{
|
|
|
|
if (nsnull == aDropDownFrame) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aDropDownFrame = mDropdownFrame;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-26 18:54:07 +04:00
|
|
|
// Toggle dropdown list.
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsComboboxControlFrame::ToggleList(nsPresContext* aPresContext)
|
1999-08-26 18:54:07 +04:00
|
|
|
{
|
1999-09-22 01:20:50 +04:00
|
|
|
ShowList(aPresContext, (PR_FALSE == mDroppedDown));
|
|
|
|
|
1999-08-26 18:54:07 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-31 17:22:40 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsComboboxControlFrame::AbsolutelyPositionDropDown()
|
|
|
|
{
|
|
|
|
nsRect absoluteTwips;
|
|
|
|
nsRect absolutePixels;
|
2000-03-07 18:54:31 +03:00
|
|
|
|
2005-08-16 16:20:58 +04:00
|
|
|
if (NS_SUCCEEDED(nsFormControlFrame::GetAbsoluteFramePosition(GetPresContext(), this, absoluteTwips, absolutePixels))) {
|
|
|
|
PositionDropdown(GetPresContext(), GetRect().height, absoluteTwips, absolutePixels);
|
2000-03-21 18:19:40 +03:00
|
|
|
}
|
1999-08-31 17:22:40 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-09-14 03:20:50 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsComboboxControlFrame::GetAbsoluteRect(nsRect* aRect)
|
|
|
|
{
|
|
|
|
nsRect absoluteTwips;
|
2005-08-16 16:20:58 +04:00
|
|
|
return nsFormControlFrame::GetAbsoluteFramePosition(GetPresContext(), this, absoluteTwips, *aRect);
|
1999-09-14 03:20:50 +04:00
|
|
|
}
|
|
|
|
|
1999-08-31 17:22:40 +04:00
|
|
|
///////////////////////////////////////////////////////////////
|
|
|
|
|
1999-08-26 18:54:07 +04:00
|
|
|
NS_IMETHODIMP
|
2002-01-26 02:35:44 +03:00
|
|
|
nsComboboxControlFrame::RedisplaySelectedText()
|
1999-06-24 01:50:56 +04:00
|
|
|
{
|
2002-01-26 02:35:44 +03:00
|
|
|
PRInt32 selectedIndex;
|
|
|
|
mListControlFrame->GetSelectedIndex(&selectedIndex);
|
|
|
|
|
|
|
|
return RedisplayText(selectedIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsComboboxControlFrame::RedisplayText(PRInt32 aIndex)
|
|
|
|
{
|
|
|
|
// Get the text to display
|
|
|
|
if (aIndex != -1) {
|
2005-06-21 04:00:14 +04:00
|
|
|
mListControlFrame->GetOptionText(aIndex, mDisplayedOptionText);
|
|
|
|
} else {
|
|
|
|
mDisplayedOptionText.Truncate();
|
2002-01-26 02:35:44 +03:00
|
|
|
}
|
|
|
|
mDisplayedIndex = aIndex;
|
|
|
|
|
2005-06-21 04:00:14 +04:00
|
|
|
REFLOW_DEBUG_MSG2("RedisplayText \"%s\"\n",
|
|
|
|
NS_LossyConvertUCS2toASCII(mDisplayedOptionText).get());
|
2002-01-26 02:35:44 +03:00
|
|
|
|
1999-10-06 03:43:06 +04:00
|
|
|
// Send reflow command because the new text maybe larger
|
|
|
|
nsresult rv = NS_OK;
|
2005-04-03 23:58:40 +04:00
|
|
|
if (mDisplayContent && mEventQueueService) {
|
2005-06-21 04:00:14 +04:00
|
|
|
// Don't call ActuallyDisplayText(PR_TRUE) directly here since that
|
2005-04-03 23:58:40 +04:00
|
|
|
// could cause recursive frame construction. See bug 283117 and the comment in
|
|
|
|
// HandleRedisplayTextEvent() below.
|
|
|
|
nsCOMPtr<nsIEventQueue> eventQueue;
|
|
|
|
rv = mEventQueueService->GetSpecialEventQueue(nsIEventQueueService::UI_THREAD_EVENT_QUEUE,
|
|
|
|
getter_AddRefs(eventQueue));
|
|
|
|
if (eventQueue) {
|
2005-06-21 04:00:14 +04:00
|
|
|
RedisplayTextEvent* event = new RedisplayTextEvent(this);
|
2005-04-03 23:58:40 +04:00
|
|
|
if (event) {
|
2005-04-04 02:16:07 +04:00
|
|
|
// Revoke outstanding events to avoid out-of-order events which could mean
|
|
|
|
// displaying the wrong text.
|
|
|
|
if (mRedisplayTextEventPosted) {
|
|
|
|
eventQueue->RevokeEvents(this);
|
|
|
|
mRedisplayTextEventPosted = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2005-04-03 23:58:40 +04:00
|
|
|
rv = eventQueue->PostEvent(event);
|
2005-04-04 02:16:07 +04:00
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
mRedisplayTextEventPosted = PR_TRUE;
|
|
|
|
} else {
|
2005-04-03 23:58:40 +04:00
|
|
|
PL_DestroyEvent(event);
|
2005-03-21 04:58:17 +03:00
|
|
|
}
|
2005-04-03 23:58:40 +04:00
|
|
|
} else {
|
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
2005-03-21 04:58:17 +03:00
|
|
|
}
|
1999-08-26 18:54:07 +04:00
|
|
|
}
|
|
|
|
}
|
1999-10-06 03:43:06 +04:00
|
|
|
return rv;
|
1999-08-26 18:54:07 +04:00
|
|
|
}
|
|
|
|
|
2005-03-21 04:58:17 +03:00
|
|
|
void
|
2005-06-21 04:00:14 +04:00
|
|
|
nsComboboxControlFrame::HandleRedisplayTextEvent()
|
2005-03-21 04:58:17 +03:00
|
|
|
{
|
2005-04-12 19:31:03 +04:00
|
|
|
// First, make sure that the content model is up to date and we've
|
|
|
|
// constructed the frames for all our content in the right places.
|
|
|
|
// Otherwise they'll end up under the wrong insertion frame when we
|
|
|
|
// ActuallyDisplayText, since that flushes out the content sink by
|
|
|
|
// calling SetText on a DOM node with aNotify set to true. See bug
|
|
|
|
// 289730.
|
|
|
|
GetPresContext()->GetDocument()->
|
|
|
|
FlushPendingNotifications(Flush_ContentAndNotify);
|
|
|
|
|
2005-03-21 04:58:17 +03:00
|
|
|
// Redirect frame insertions during this method (see GetContentInsertionFrame())
|
|
|
|
// so that any reframing that the frame constructor forces upon us is inserted
|
|
|
|
// into the correct parent (mDisplayFrame). See bug 282607.
|
|
|
|
NS_PRECONDITION(!mInRedisplayText, "Nested RedisplayText");
|
|
|
|
mInRedisplayText = PR_TRUE;
|
2005-04-04 02:16:07 +04:00
|
|
|
mRedisplayTextEventPosted = PR_FALSE;
|
2005-03-21 04:58:17 +03:00
|
|
|
|
2005-06-21 04:00:14 +04:00
|
|
|
ActuallyDisplayText(PR_TRUE);
|
2005-03-21 04:58:17 +03:00
|
|
|
mDisplayFrame->AddStateBits(NS_FRAME_IS_DIRTY);
|
|
|
|
ReflowDirtyChild(GetPresContext()->PresShell(), mDisplayFrame);
|
|
|
|
|
|
|
|
mInRedisplayText = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2005-06-21 04:00:14 +04:00
|
|
|
void
|
|
|
|
nsComboboxControlFrame::ActuallyDisplayText(PRBool aNotify)
|
2002-01-26 02:35:44 +03:00
|
|
|
{
|
2005-06-21 04:00:14 +04:00
|
|
|
if (mDisplayedOptionText.IsEmpty()) {
|
2002-11-12 22:17:51 +03:00
|
|
|
// Have to use a non-breaking space for line-height calculations
|
|
|
|
// to be right
|
2004-05-13 05:12:10 +04:00
|
|
|
static const PRUnichar space = 0xA0;
|
|
|
|
mDisplayContent->SetText(&space, 1, aNotify);
|
2002-01-26 02:35:44 +03:00
|
|
|
} else {
|
2005-06-21 04:00:14 +04:00
|
|
|
mDisplayContent->SetText(mDisplayedOptionText, aNotify);
|
2002-01-26 02:35:44 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-12-21 02:25:40 +03:00
|
|
|
NS_IMETHODIMP
|
2002-07-18 04:58:31 +04:00
|
|
|
nsComboboxControlFrame::GetIndexOfDisplayArea(PRInt32* aDisplayedIndex)
|
2000-12-21 02:25:40 +03:00
|
|
|
{
|
2002-07-18 04:58:31 +04:00
|
|
|
NS_ENSURE_ARG_POINTER(aDisplayedIndex);
|
|
|
|
*aDisplayedIndex = mDisplayedIndex;
|
2000-12-21 02:25:40 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-08-26 18:54:07 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISelectControlFrame
|
|
|
|
//----------------------------------------------------------------------
|
1999-11-12 01:13:33 +03:00
|
|
|
NS_IMETHODIMP
|
2002-03-31 14:14:01 +04:00
|
|
|
nsComboboxControlFrame::DoneAddingChildren(PRBool aIsDone)
|
1999-11-12 01:13:33 +03:00
|
|
|
{
|
|
|
|
nsISelectControlFrame* listFrame = nsnull;
|
2000-02-15 18:04:38 +03:00
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
2000-09-10 02:15:57 +04:00
|
|
|
if (mDropdownFrame != nsnull) {
|
2002-07-18 04:58:31 +04:00
|
|
|
rv = CallQueryInterface(mDropdownFrame, &listFrame);
|
|
|
|
if (listFrame) {
|
2002-03-31 14:14:01 +04:00
|
|
|
rv = listFrame->DoneAddingChildren(aIsDone);
|
2000-02-15 18:04:38 +03:00
|
|
|
}
|
1999-11-12 01:13:33 +03:00
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
1999-08-26 18:54:07 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsComboboxControlFrame::AddOption(nsPresContext* aPresContext, PRInt32 aIndex)
|
1999-08-26 18:54:07 +04:00
|
|
|
{
|
2005-06-21 03:26:35 +04:00
|
|
|
if (aIndex <= mDisplayedIndex) {
|
|
|
|
++mDisplayedIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsListControlFrame* lcf = NS_STATIC_CAST(nsListControlFrame*, mDropdownFrame);
|
2002-07-18 04:58:31 +04:00
|
|
|
return lcf->AddOption(aPresContext, aIndex);
|
1999-08-26 18:54:07 +04:00
|
|
|
}
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
|
1999-08-26 18:54:07 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsComboboxControlFrame::RemoveOption(nsPresContext* aPresContext, PRInt32 aIndex)
|
1999-08-26 18:54:07 +04:00
|
|
|
{
|
2002-07-18 04:58:31 +04:00
|
|
|
PRInt32 len;
|
|
|
|
mListControlFrame->GetNumberOfOptions(&len);
|
2005-06-21 03:26:35 +04:00
|
|
|
if (len > 0) {
|
|
|
|
if (aIndex < mDisplayedIndex) {
|
|
|
|
--mDisplayedIndex;
|
|
|
|
} else if (aIndex == mDisplayedIndex) {
|
|
|
|
mDisplayedIndex = 0; // IE6 compat
|
|
|
|
RedisplayText(mDisplayedIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// If we removed the last option, we need to blank things out
|
2002-07-18 04:58:31 +04:00
|
|
|
RedisplayText(-1);
|
1999-08-27 07:58:13 +04:00
|
|
|
}
|
2002-07-18 04:58:31 +04:00
|
|
|
|
|
|
|
nsListControlFrame* lcf = NS_STATIC_CAST(nsListControlFrame*, mDropdownFrame);
|
|
|
|
return lcf->RemoveOption(aPresContext, aIndex);
|
1999-08-27 07:58:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-11-02 10:40:01 +03:00
|
|
|
nsComboboxControlFrame::GetOptionSelected(PRInt32 aIndex, PRBool* aValue)
|
1999-08-27 07:58:13 +04:00
|
|
|
{
|
|
|
|
nsISelectControlFrame* listFrame = nsnull;
|
2005-02-05 01:56:13 +03:00
|
|
|
NS_ASSERTION(mDropdownFrame, "No dropdown frame!");
|
|
|
|
|
|
|
|
CallQueryInterface(mDropdownFrame, &listFrame);
|
|
|
|
NS_ASSERTION(listFrame, "No list frame!");
|
|
|
|
|
|
|
|
return listFrame->GetOptionSelected(aIndex, aValue);
|
1999-09-15 09:31:31 +04:00
|
|
|
}
|
|
|
|
|
2005-02-05 01:56:13 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsComboboxControlFrame::OnSetSelectedIndex(PRInt32 aOldIndex, PRInt32 aNewIndex)
|
|
|
|
{
|
|
|
|
nsISelectControlFrame* listFrame = nsnull;
|
|
|
|
NS_ASSERTION(mDropdownFrame, "No dropdown frame!");
|
|
|
|
|
|
|
|
CallQueryInterface(mDropdownFrame, &listFrame);
|
|
|
|
NS_ASSERTION(listFrame, "No list frame!");
|
|
|
|
|
|
|
|
return listFrame->OnSetSelectedIndex(aOldIndex, aNewIndex);
|
2000-04-29 03:24:59 +04:00
|
|
|
}
|
|
|
|
|
2001-11-02 10:40:01 +03:00
|
|
|
// End nsISelectControlFrame
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsComboboxControlFrame::HandleEvent(nsPresContext* aPresContext,
|
1999-07-29 01:38:08 +04:00
|
|
|
nsGUIEvent* aEvent,
|
1999-11-24 09:03:41 +03:00
|
|
|
nsEventStatus* aEventStatus)
|
1999-07-29 01:38:08 +04:00
|
|
|
{
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(aEventStatus);
|
2002-05-23 15:25:58 +04:00
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
if (nsEventStatus_eConsumeNoDefault == *aEventStatus) {
|
1999-07-29 01:38:08 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2002-06-04 04:44:04 +04:00
|
|
|
if (nsFormControlHelper::GetDisabled(mContent)) {
|
1999-08-10 23:25:22 +04:00
|
|
|
return NS_OK;
|
1999-07-29 01:38:08 +04:00
|
|
|
}
|
|
|
|
|
2000-09-07 08:39:02 +04:00
|
|
|
// If we have style that affects how we are selected, feed event down to
|
|
|
|
// nsFrame::HandleEvent so that selection takes place when appropriate.
|
2003-05-15 07:42:21 +04:00
|
|
|
const nsStyleUserInterface* uiStyle = GetStyleUserInterface();
|
2000-09-07 08:39:02 +04:00
|
|
|
if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE || uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
|
|
|
|
return nsAreaFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
|
|
|
|
|
|
|
return NS_OK;
|
1999-07-29 01:38:08 +04:00
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
|
2005-12-13 02:53:06 +03:00
|
|
|
nsresult
|
|
|
|
nsComboboxControlFrame::SetFormProperty(nsIAtom* aName, const nsAString& aValue)
|
1999-01-26 01:16:27 +03:00
|
|
|
{
|
1999-04-13 02:14:31 +04:00
|
|
|
nsIFormControlFrame* fcFrame = nsnull;
|
2002-07-18 04:58:31 +04:00
|
|
|
nsresult result = CallQueryInterface(mDropdownFrame, &fcFrame);
|
2005-12-13 02:53:06 +03:00
|
|
|
if (NS_FAILED(result)) {
|
|
|
|
return result;
|
1999-04-13 02:14:31 +04:00
|
|
|
}
|
2005-12-13 02:53:06 +03:00
|
|
|
if (fcFrame) {
|
|
|
|
return fcFrame->SetFormProperty(aName, aValue);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
1999-01-26 01:16:27 +03:00
|
|
|
}
|
|
|
|
|
2005-12-13 02:53:06 +03:00
|
|
|
nsresult
|
|
|
|
nsComboboxControlFrame::GetFormProperty(nsIAtom* aName, nsAString& aValue) const
|
1999-03-06 22:43:13 +03:00
|
|
|
{
|
1999-04-13 02:14:31 +04:00
|
|
|
nsIFormControlFrame* fcFrame = nsnull;
|
2002-07-18 04:58:31 +04:00
|
|
|
nsresult result = CallQueryInterface(mDropdownFrame, &fcFrame);
|
2005-12-13 02:53:06 +03:00
|
|
|
if(NS_FAILED(result)) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
if (fcFrame) {
|
|
|
|
return fcFrame->GetFormProperty(aName, aValue);
|
1999-04-13 02:14:31 +04:00
|
|
|
}
|
2005-12-13 02:53:06 +03:00
|
|
|
return NS_OK;
|
1999-03-06 22:43:13 +03:00
|
|
|
}
|
|
|
|
|
2004-07-18 16:02:53 +04:00
|
|
|
nsIFrame*
|
|
|
|
nsComboboxControlFrame::GetContentInsertionFrame() {
|
2005-02-20 02:54:36 +03:00
|
|
|
return mInRedisplayText ? mDisplayFrame : mDropdownFrame->GetContentInsertionFrame();
|
2004-07-18 16:02:53 +04:00
|
|
|
}
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsComboboxControlFrame::CreateAnonymousContent(nsPresContext* aPresContext,
|
2000-01-22 04:16:50 +03:00
|
|
|
nsISupportsArray& aChildList)
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
{
|
|
|
|
// 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.
|
2005-12-13 02:53:06 +03:00
|
|
|
// In addition, if the frame created by content below for the button is not an nsGfxScrollFrame
|
|
|
|
// things will go wrong ... see SetButtonFrameSize.
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
|
|
|
|
// For now the content that is created corresponds to two input buttons. It would be better to create the
|
|
|
|
// tag as something other than input, but then there isn't any way to create a button frame since it
|
|
|
|
// isn't possible to set the display type in CSS2 to create a button frame.
|
|
|
|
|
|
|
|
// create content used for display
|
1999-08-06 18:13:20 +04:00
|
|
|
//nsIAtom* tag = NS_NewAtom("mozcombodisplay");
|
2000-02-15 18:04:38 +03:00
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
// Add a child text content node for the label
|
2004-08-10 14:22:36 +04:00
|
|
|
|
2005-09-24 22:43:15 +04:00
|
|
|
nsNodeInfoManager *nimgr = mContent->NodeInfo()->NodeInfoManager();
|
|
|
|
|
2004-08-10 14:22:36 +04:00
|
|
|
nsCOMPtr<nsITextContent> labelContent;
|
2005-09-24 22:43:15 +04:00
|
|
|
NS_NewTextNode(getter_AddRefs(labelContent), nimgr);
|
2004-08-10 14:22:36 +04:00
|
|
|
|
|
|
|
if (labelContent) {
|
2000-03-07 18:54:31 +03:00
|
|
|
// set the value of the text node
|
2004-08-10 14:22:36 +04:00
|
|
|
mDisplayContent.swap(labelContent);
|
2005-10-21 03:19:22 +04:00
|
|
|
mListControlFrame->GetSelectedIndex(&mDisplayedIndex);
|
|
|
|
if (mDisplayedIndex != -1) {
|
|
|
|
mListControlFrame->GetOptionText(mDisplayedIndex, mDisplayedOptionText);
|
|
|
|
}
|
2005-06-21 04:00:14 +04:00
|
|
|
ActuallyDisplayText(PR_FALSE);
|
2000-03-07 18:54:31 +03:00
|
|
|
|
2000-05-10 17:13:39 +04:00
|
|
|
nsCOMPtr<nsINodeInfo> nodeInfo;
|
2005-09-24 22:43:15 +04:00
|
|
|
nimgr->GetNodeInfo(nsHTMLAtoms::input, nsnull, kNameSpaceID_None,
|
|
|
|
getter_AddRefs(nodeInfo));
|
2000-05-10 17:13:39 +04:00
|
|
|
|
2004-08-10 14:22:36 +04:00
|
|
|
aChildList.AppendElement(mDisplayContent);
|
2000-03-07 18:54:31 +03:00
|
|
|
|
|
|
|
// create button which drops the list down
|
2004-06-25 16:26:02 +04:00
|
|
|
nsCOMPtr<nsIContent> btnContent;
|
2004-08-10 14:22:36 +04:00
|
|
|
nsresult rv = NS_NewHTMLElement(getter_AddRefs(btnContent), nodeInfo);
|
2004-06-25 16:26:02 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
// make someone to listen to the button. If its pressed by someone like Accessibility
|
|
|
|
// then open or close the combo box.
|
|
|
|
nsCOMPtr<nsIDOMEventReceiver> eventReceiver(do_QueryInterface(btnContent));
|
|
|
|
if (eventReceiver) {
|
|
|
|
mButtonListener = new nsComboButtonListener(this);
|
|
|
|
eventReceiver->AddEventListenerByIID(mButtonListener, NS_GET_IID(nsIDOMMouseListener));
|
2000-03-07 18:54:31 +03:00
|
|
|
}
|
2004-06-25 16:26:02 +04:00
|
|
|
|
|
|
|
btnContent->SetAttr(kNameSpaceID_None, nsHTMLAtoms::type, NS_LITERAL_STRING("button"), PR_FALSE);
|
2004-09-08 23:32:29 +04:00
|
|
|
// Set tabindex="-1" so that the button is not tabbable
|
|
|
|
btnContent->SetAttr(kNameSpaceID_None, nsHTMLAtoms::tabindex,
|
|
|
|
NS_LITERAL_STRING("-1"), PR_FALSE);
|
2004-06-25 16:26:02 +04:00
|
|
|
|
|
|
|
aChildList.AppendElement(btnContent);
|
2000-03-07 18:54:31 +03:00
|
|
|
}
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-04-19 17:55:17 +04:00
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsComboboxControlFrame::CreateFrameFor(nsPresContext* aPresContext,
|
2000-04-19 17:55:17 +04:00
|
|
|
nsIContent * aContent,
|
|
|
|
nsIFrame** aFrame)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aFrame, "null ptr");
|
|
|
|
NS_PRECONDITION(nsnull != aContent, "null ptr");
|
|
|
|
NS_PRECONDITION(nsnull != aPresContext, "null ptr");
|
|
|
|
|
|
|
|
*aFrame = nsnull;
|
2005-12-11 23:45:58 +03:00
|
|
|
NS_ASSERTION(mDisplayContent, "mDisplayContent can't be null!");
|
2000-04-19 17:55:17 +04:00
|
|
|
|
2005-12-11 23:45:58 +03:00
|
|
|
if (!SameCOMIdentity(mDisplayContent, aContent)) {
|
|
|
|
// We only handle the frames for mDisplayContent here
|
2000-04-19 17:55:17 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2005-12-11 23:45:58 +03:00
|
|
|
|
|
|
|
// Get PresShell
|
|
|
|
nsIPresShell *shell = aPresContext->PresShell();
|
|
|
|
nsStyleSet *styleSet = shell->StyleSet();
|
2000-04-19 17:55:17 +04:00
|
|
|
|
2005-12-11 23:45:58 +03:00
|
|
|
// create the style contexts for the anonymous block frame and text frame
|
|
|
|
nsRefPtr<nsStyleContext> styleContext;
|
|
|
|
styleContext = styleSet->
|
|
|
|
ResolvePseudoStyleFor(mContent,
|
|
|
|
nsCSSAnonBoxes::mozDisplayComboboxControlFrame,
|
|
|
|
mStyleContext);
|
|
|
|
if (NS_UNLIKELY(!styleContext)) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
2005-11-04 05:38:33 +03:00
|
|
|
|
2005-12-11 23:45:58 +03:00
|
|
|
nsRefPtr<nsStyleContext> textStyleContext;
|
|
|
|
textStyleContext = styleSet->ResolveStyleForNonElement(styleContext);
|
|
|
|
if (NS_UNLIKELY(!textStyleContext)) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
2000-04-19 17:55:17 +04:00
|
|
|
|
2005-12-11 23:45:58 +03:00
|
|
|
// Start by by creating our anonymous block frame
|
|
|
|
mDisplayFrame = NS_NewBlockFrame(shell, NS_BLOCK_SPACE_MGR);
|
|
|
|
if (NS_UNLIKELY(!mDisplayFrame)) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2000-04-19 17:55:17 +04:00
|
|
|
|
2005-12-11 23:45:58 +03:00
|
|
|
nsresult rv = mDisplayFrame->Init(aPresContext, mContent, this, styleContext,
|
|
|
|
nsnull);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
mDisplayFrame->Destroy(aPresContext);
|
|
|
|
mDisplayFrame = nsnull;
|
|
|
|
return rv;
|
|
|
|
}
|
2000-04-19 17:55:17 +04:00
|
|
|
|
2005-12-11 23:45:58 +03:00
|
|
|
// Create a text frame and put it inside the block frame
|
|
|
|
mTextFrame = NS_NewTextFrame(shell);
|
|
|
|
if (NS_UNLIKELY(!mTextFrame)) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2000-04-19 17:55:17 +04:00
|
|
|
|
2005-12-11 23:45:58 +03:00
|
|
|
// initialize the text frame
|
|
|
|
rv = mTextFrame->Init(aPresContext, aContent, mDisplayFrame,
|
|
|
|
textStyleContext, nsnull);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
mDisplayFrame->Destroy(aPresContext);
|
|
|
|
mDisplayFrame = nsnull;
|
|
|
|
mTextFrame->Destroy(aPresContext);
|
|
|
|
mTextFrame = nsnull;
|
|
|
|
return rv;
|
2000-04-19 17:55:17 +04:00
|
|
|
}
|
|
|
|
|
2005-12-11 23:45:58 +03:00
|
|
|
mDisplayFrame->SetInitialChildList(aPresContext, nsnull, mTextFrame);
|
|
|
|
*aFrame = mDisplayFrame;
|
|
|
|
return NS_OK;
|
2000-04-19 17:55:17 +04:00
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsComboboxControlFrame::Destroy(nsPresContext* aPresContext)
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
{
|
2005-03-21 04:58:17 +03:00
|
|
|
// Revoke queued RedisplayTextEvents
|
|
|
|
if (mEventQueueService) {
|
|
|
|
nsCOMPtr<nsIEventQueue> eventQueue;
|
|
|
|
mEventQueueService->GetSpecialEventQueue(nsIEventQueueService::UI_THREAD_EVENT_QUEUE,
|
|
|
|
getter_AddRefs(eventQueue));
|
|
|
|
if (eventQueue) {
|
|
|
|
eventQueue->RevokeEvents(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-16 16:20:58 +04:00
|
|
|
nsFormControlFrame::RegUnRegAccessKey(GetPresContext(), NS_STATIC_CAST(nsIFrame*, this), PR_FALSE);
|
2000-08-03 18:13:40 +04:00
|
|
|
|
2000-03-28 18:29:15 +04:00
|
|
|
if (mDroppedDown) {
|
|
|
|
// Get parent view
|
|
|
|
nsIFrame * listFrame;
|
2001-01-04 23:44:42 +03:00
|
|
|
if (NS_OK == mListControlFrame->QueryInterface(NS_GET_IID(nsIFrame), (void **)&listFrame)) {
|
2003-07-04 16:50:32 +04:00
|
|
|
nsIView* view = listFrame->GetView();
|
|
|
|
NS_ASSERTION(view, "nsComboboxControlFrame view is null");
|
2000-03-28 18:29:15 +04:00
|
|
|
if (view) {
|
2003-07-04 16:50:32 +04:00
|
|
|
nsIWidget* widget = view->GetWidget();
|
2000-03-28 18:29:15 +04:00
|
|
|
if (widget)
|
|
|
|
widget->CaptureRollupEvents((nsIRollupListener *)this, PR_FALSE, PR_TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-21 00:28:02 +04:00
|
|
|
// Cleanup frames in popup child list
|
1999-07-22 08:00:57 +04:00
|
|
|
mPopupFrames.DestroyFrames(aPresContext);
|
2000-04-20 07:42:12 +04:00
|
|
|
|
1999-07-22 06:24:52 +04:00
|
|
|
return nsAreaFrame::Destroy(aPresContext);
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-01-09 17:20:53 +03:00
|
|
|
nsIFrame*
|
|
|
|
nsComboboxControlFrame::GetFirstChild(nsIAtom* aListName) const
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
{
|
|
|
|
if (nsLayoutAtoms::popupList == aListName) {
|
2004-01-09 17:20:53 +03:00
|
|
|
return mPopupFrames.FirstChild();
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
}
|
2004-01-09 17:20:53 +03:00
|
|
|
return nsAreaFrame::GetFirstChild(aListName);
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsComboboxControlFrame::SetInitialChildList(nsPresContext* aPresContext,
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
if (nsLayoutAtoms::popupList == aListName) {
|
|
|
|
mPopupFrames.SetFrames(aChildList);
|
|
|
|
} else {
|
|
|
|
rv = nsAreaFrame::SetInitialChildList(aPresContext, aListName, aChildList);
|
2000-04-19 17:55:17 +04:00
|
|
|
|
2003-07-04 16:50:32 +04:00
|
|
|
for (nsIFrame * child = aChildList; child;
|
|
|
|
child = child->GetNextSibling()) {
|
2005-12-13 02:53:06 +03:00
|
|
|
nsCOMPtr<nsIFormControl> formControl = do_QueryInterface(child->GetContent());
|
|
|
|
if (formControl && formControl->GetType() == NS_FORM_INPUT_BUTTON) {
|
2005-12-08 22:01:20 +03:00
|
|
|
mButtonFrame = child;
|
|
|
|
break;
|
2000-04-19 17:55:17 +04:00
|
|
|
}
|
|
|
|
}
|
2005-12-08 22:01:20 +03:00
|
|
|
NS_ASSERTION(mButtonFrame, "missing button frame in initial child list");
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2004-01-09 17:20:53 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsComboboxControlFrame::GetAdditionalChildListName(PRInt32 aIndex) const
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
{
|
2003-03-24 07:15:34 +03:00
|
|
|
// Maintain a separate child list for the dropdown list (i.e. popup listbox)
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
// This is necessary because we don't want the listbox to be included in the layout
|
|
|
|
// of the combox's children because it would take up space, when it is suppose to
|
|
|
|
// be floating above the display.
|
2000-05-09 09:11:12 +04:00
|
|
|
if (aIndex <= NS_BLOCK_FRAME_ABSOLUTE_LIST_INDEX) {
|
2004-01-09 17:20:53 +03:00
|
|
|
return nsAreaFrame::GetAdditionalChildListName(aIndex);
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_COMBO_FRAME_POPUP_LIST_INDEX == aIndex) {
|
2004-01-09 17:20:53 +03:00
|
|
|
return nsLayoutAtoms::popupList;
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
}
|
2004-01-09 17:20:53 +03:00
|
|
|
return nsnull;
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
PRIntn
|
|
|
|
nsComboboxControlFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
// Don't skip any sides during border rendering
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-09-22 01:20:50 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
//nsIRollupListener
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsComboboxControlFrame::Rollup()
|
|
|
|
{
|
|
|
|
if (mDroppedDown) {
|
1999-10-01 18:30:33 +04:00
|
|
|
mListControlFrame->AboutToRollup();
|
1999-09-22 01:20:50 +04:00
|
|
|
ShowDropDown(PR_FALSE);
|
2005-08-16 16:20:58 +04:00
|
|
|
mListControlFrame->CaptureMouseEvents(GetPresContext(), PR_FALSE);
|
1999-09-22 01:20:50 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-01-26 02:35:44 +03:00
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsComboboxControlFrame::RollupFromList(nsPresContext* aPresContext)
|
2002-01-26 02:35:44 +03:00
|
|
|
{
|
|
|
|
ShowList(aPresContext, PR_FALSE);
|
|
|
|
mListControlFrame->CaptureMouseEvents(aPresContext, PR_FALSE);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2004-07-23 12:25:44 +04:00
|
|
|
NS_IMETHODIMP_(PRInt32)
|
|
|
|
nsComboboxControlFrame::UpdateRecentIndex(PRInt32 aIndex)
|
2002-02-08 21:35:48 +03:00
|
|
|
{
|
2004-07-23 12:25:44 +04:00
|
|
|
PRInt32 index = mRecentSelectedIndex;
|
|
|
|
if (mRecentSelectedIndex == -1 || aIndex == -1)
|
|
|
|
mRecentSelectedIndex = aIndex;
|
|
|
|
return index;
|
2002-02-08 21:35:48 +03:00
|
|
|
}
|
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
NS_METHOD
|
2004-08-01 03:15:21 +04:00
|
|
|
nsComboboxControlFrame::Paint(nsPresContext* aPresContext,
|
2000-03-07 18:54:31 +03:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
2001-09-19 16:35:19 +04:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags)
|
2000-03-07 18:54:31 +03:00
|
|
|
{
|
2001-01-27 17:09:34 +03:00
|
|
|
PRBool isVisible;
|
|
|
|
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible)) && !isVisible) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-03-07 18:54:31 +03:00
|
|
|
#ifdef NOISY
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("%p paint layer %d at (%d, %d, %d, %d)\n", this, aWhichLayer,
|
|
|
|
aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height);
|
2000-03-07 18:54:31 +03:00
|
|
|
#endif
|
2002-04-05 08:29:05 +04:00
|
|
|
// We paint everything in the foreground so that the form control's
|
|
|
|
// parents cannot paint over it in other passes (bug 95826).
|
2000-03-07 18:54:31 +03:00
|
|
|
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) {
|
2002-04-05 08:29:05 +04:00
|
|
|
nsAreaFrame::Paint(aPresContext, aRenderingContext, aDirtyRect,
|
|
|
|
NS_FRAME_PAINT_LAYER_BACKGROUND);
|
|
|
|
nsAreaFrame::Paint(aPresContext, aRenderingContext, aDirtyRect,
|
2003-10-14 01:51:02 +04:00
|
|
|
NS_FRAME_PAINT_LAYER_FLOATS);
|
2002-04-05 08:29:05 +04:00
|
|
|
nsAreaFrame::Paint(aPresContext, aRenderingContext, aDirtyRect,
|
|
|
|
NS_FRAME_PAINT_LAYER_FOREGROUND);
|
|
|
|
|
2003-03-12 07:57:33 +03:00
|
|
|
// nsITheme should take care of drawing the focus border, but currently does so only on Mac.
|
|
|
|
// If all of the nsITheme implementations are fixed to draw the focus border correctly,
|
|
|
|
// this #ifdef should be replaced with a -moz-appearance / ThemeSupportsWidget() check.
|
|
|
|
|
2005-02-16 08:13:16 +03:00
|
|
|
if (!ToolkitHasNativePopup() && mDisplayFrame) {
|
2000-03-07 18:54:31 +03:00
|
|
|
aRenderingContext.PushState();
|
2003-07-04 16:50:32 +04:00
|
|
|
nsRect clipRect = mDisplayFrame->GetRect();
|
2004-04-23 19:21:24 +04:00
|
|
|
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect);
|
2000-03-07 18:54:31 +03:00
|
|
|
PaintChild(aPresContext, aRenderingContext, aDirtyRect,
|
|
|
|
mDisplayFrame, NS_FRAME_PAINT_LAYER_BACKGROUND);
|
|
|
|
PaintChild(aPresContext, aRenderingContext, aDirtyRect,
|
|
|
|
mDisplayFrame, NS_FRAME_PAINT_LAYER_FOREGROUND);
|
2000-04-19 17:55:17 +04:00
|
|
|
|
|
|
|
/////////////////////
|
|
|
|
// draw focus
|
|
|
|
// XXX This is only temporary
|
2001-02-01 15:24:35 +03:00
|
|
|
// Only paint the focus if we're visible
|
2003-05-15 07:42:21 +04:00
|
|
|
if (GetStyleVisibility()->IsVisible()) {
|
2004-02-27 20:17:37 +03:00
|
|
|
if (!nsFormControlHelper::GetDisabled(mContent) && mFocused == this) {
|
|
|
|
aRenderingContext.SetLineStyle(nsLineStyle_kDotted);
|
|
|
|
aRenderingContext.SetColor(0);
|
|
|
|
} else {
|
|
|
|
aRenderingContext.SetColor(GetStyleBackground()->mBackgroundColor);
|
|
|
|
aRenderingContext.SetLineStyle(nsLineStyle_kSolid);
|
2000-04-19 17:55:17 +04:00
|
|
|
}
|
2004-02-27 20:17:37 +03:00
|
|
|
//aRenderingContext.DrawRect(clipRect);
|
|
|
|
float p2t = aPresContext->PixelsToTwips();
|
|
|
|
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
|
|
|
|
clipRect.width -= onePixel;
|
|
|
|
clipRect.height -= onePixel;
|
|
|
|
aRenderingContext.DrawLine(clipRect.x, clipRect.y,
|
|
|
|
clipRect.x+clipRect.width, clipRect.y);
|
|
|
|
aRenderingContext.DrawLine(clipRect.x+clipRect.width, clipRect.y,
|
|
|
|
clipRect.x+clipRect.width, clipRect.y+clipRect.height);
|
|
|
|
aRenderingContext.DrawLine(clipRect.x+clipRect.width, clipRect.y+clipRect.height,
|
|
|
|
clipRect.x, clipRect.y+clipRect.height);
|
|
|
|
aRenderingContext.DrawLine(clipRect.x, clipRect.y+clipRect.height,
|
|
|
|
clipRect.x, clipRect.y);
|
|
|
|
aRenderingContext.DrawLine(clipRect.x, clipRect.y+clipRect.height,
|
|
|
|
clipRect.x, clipRect.y);
|
2000-04-19 17:55:17 +04:00
|
|
|
}
|
|
|
|
/////////////////////
|
2004-04-18 17:13:35 +04:00
|
|
|
aRenderingContext.PopState();
|
2000-03-07 18:54:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-08-09 03:38:00 +04:00
|
|
|
// Call to the base class to draw selection borders when appropriate
|
|
|
|
return nsFrame::Paint(aPresContext,aRenderingContext,aDirtyRect,aWhichLayer);
|
2000-03-07 18:54:31 +03:00
|
|
|
}
|
|
|
|
|
2000-12-09 10:28:19 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
//nsIScrollableViewProvider
|
|
|
|
//----------------------------------------------------------------------
|
2004-09-06 06:44:43 +04:00
|
|
|
nsIScrollableView* nsComboboxControlFrame::GetScrollableView()
|
2000-12-09 10:28:19 +03:00
|
|
|
{
|
2003-04-09 00:50:57 +04:00
|
|
|
if (!mDropdownFrame)
|
2004-09-06 06:44:43 +04:00
|
|
|
return nsnull;
|
2003-04-09 00:50:57 +04:00
|
|
|
|
|
|
|
nsIScrollableFrame* scrollable = nsnull;
|
|
|
|
nsresult rv = CallQueryInterface(mDropdownFrame, &scrollable);
|
|
|
|
if (NS_FAILED(rv))
|
2004-09-06 06:44:43 +04:00
|
|
|
return nsnull;
|
2003-04-09 00:50:57 +04:00
|
|
|
|
2004-09-06 06:44:43 +04:00
|
|
|
return scrollable->GetScrollableView();
|
2000-12-09 10:28:19 +03:00
|
|
|
}
|
2000-03-07 18:54:31 +03:00
|
|
|
|
2001-11-02 10:40:01 +03:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// gets the content (an option) by index and then set it as
|
|
|
|
// being selected or not selected
|
|
|
|
//---------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsComboboxControlFrame::OnOptionSelected(nsPresContext* aPresContext,
|
2001-11-02 10:40:01 +03:00
|
|
|
PRInt32 aIndex,
|
|
|
|
PRBool aSelected)
|
|
|
|
{
|
2003-03-14 09:18:20 +03:00
|
|
|
if (mDroppedDown) {
|
|
|
|
nsCOMPtr<nsISelectControlFrame> selectFrame
|
|
|
|
= do_QueryInterface(mListControlFrame);
|
|
|
|
if (selectFrame) {
|
|
|
|
selectFrame->OnOptionSelected(aPresContext, aIndex, aSelected);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (aSelected) {
|
2002-01-26 02:35:44 +03:00
|
|
|
RedisplayText(aIndex);
|
|
|
|
} else {
|
2003-03-14 09:18:20 +03:00
|
|
|
RedisplaySelectedText();
|
2005-05-05 19:05:34 +04:00
|
|
|
FireValueChangeEvent(); // Fire after old option is unselected
|
2002-01-26 02:35:44 +03:00
|
|
|
}
|
2001-11-02 10:40:01 +03:00
|
|
|
}
|
2003-03-14 09:18:20 +03:00
|
|
|
|
2001-11-02 10:40:01 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-02-08 02:11:30 +03:00
|
|
|
void nsComboboxControlFrame::FireValueChangeEvent()
|
|
|
|
{
|
|
|
|
// Fire ValueChange event to indicate data value of combo box has changed
|
|
|
|
nsCOMPtr<nsIDOMEvent> event;
|
|
|
|
nsCOMPtr<nsIEventListenerManager> manager;
|
|
|
|
mContent->GetListenerManager(getter_AddRefs(manager));
|
|
|
|
nsPresContext* presContext = GetPresContext();
|
|
|
|
if (manager &&
|
2005-08-16 16:42:34 +04:00
|
|
|
NS_SUCCEEDED(manager->CreateEvent(presContext, nsnull, NS_LITERAL_STRING("Events"), getter_AddRefs(event)))) {
|
2005-02-08 02:11:30 +03:00
|
|
|
event->InitEvent(NS_LITERAL_STRING("ValueChange"), PR_TRUE, PR_TRUE);
|
2005-04-29 03:48:28 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(event));
|
|
|
|
privateEvent->SetTrusted(PR_TRUE);
|
|
|
|
|
2005-03-04 05:01:54 +03:00
|
|
|
PRBool defaultActionEnabled;
|
|
|
|
presContext->EventStateManager()->DispatchNewEvent(mContent, event,
|
|
|
|
&defaultActionEnabled);
|
2005-02-08 02:11:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-12-13 02:53:06 +03:00
|
|
|
void
|
2001-11-02 10:40:01 +03:00
|
|
|
nsComboboxControlFrame::OnContentReset()
|
|
|
|
{
|
|
|
|
if (mListControlFrame) {
|
2005-12-13 02:53:06 +03:00
|
|
|
mListControlFrame->OnContentReset();
|
2001-11-02 10:40:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------
|
|
|
|
// nsIStatefulFrame
|
|
|
|
//--------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
2005-12-07 02:56:17 +03:00
|
|
|
nsComboboxControlFrame::SaveState(SpecialStateID aStateID,
|
2005-01-28 01:52:53 +03:00
|
|
|
nsPresState** aState)
|
2001-11-02 10:40:01 +03:00
|
|
|
{
|
2005-12-07 02:56:17 +03:00
|
|
|
if (!mListControlFrame)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsIStatefulFrame* stateful;
|
|
|
|
CallQueryInterface(mListControlFrame, &stateful);
|
|
|
|
return stateful->SaveState(aStateID, aState);
|
2001-11-02 10:40:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2005-12-07 02:56:17 +03:00
|
|
|
nsComboboxControlFrame::RestoreState(nsPresState* aState)
|
2001-11-02 10:40:01 +03:00
|
|
|
{
|
2002-01-11 23:10:46 +03:00
|
|
|
if (!mListControlFrame)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsIStatefulFrame* stateful;
|
|
|
|
nsresult rv = CallQueryInterface(mListControlFrame, &stateful);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "Must implement nsIStatefulFrame");
|
2005-12-07 02:56:17 +03:00
|
|
|
rv = stateful->RestoreState(aState);
|
2002-01-11 23:10:46 +03:00
|
|
|
return rv;
|
2001-11-02 10:40:01 +03:00
|
|
|
}
|
2005-02-16 08:13:16 +03:00
|
|
|
|
|
|
|
|
|
|
|
//
|
2006-01-11 22:09:20 +03:00
|
|
|
// Camino uses a native widget for the combobox
|
|
|
|
// popup, which affects drawing and event
|
2005-02-16 08:13:16 +03:00
|
|
|
// handling here and in nsListControlFrame.
|
|
|
|
//
|
|
|
|
|
|
|
|
/* static */
|
|
|
|
PRBool
|
|
|
|
nsComboboxControlFrame::ToolkitHasNativePopup()
|
|
|
|
{
|
2006-01-11 22:09:20 +03:00
|
|
|
#ifdef MOZ_MACBROWSER
|
2005-02-16 08:13:16 +03:00
|
|
|
return PR_TRUE;
|
|
|
|
#else
|
|
|
|
return PR_FALSE;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|