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>
|
2011-08-25 00:54:30 +04:00
|
|
|
* Mats Palmgren <matspal@gmail.com>
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 18:30:37 +04:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-29 00:14:13 +04:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 18:30:37 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 18:30:37 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-02-12 20:45:58 +03:00
|
|
|
#include "nsCOMPtr.h"
|
2001-09-29 12:28:41 +04:00
|
|
|
#include "nsReadableUtils.h"
|
1999-01-18 18:14:00 +03:00
|
|
|
#include "nsComboboxControlFrame.h"
|
2007-05-14 13:11:38 +04:00
|
|
|
#include "nsIDOMEventTarget.h"
|
2004-02-24 00:29:06 +03:00
|
|
|
#include "nsFrameManager.h"
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
#include "nsFormControlFrame.h"
|
2005-12-13 02:53:06 +03:00
|
|
|
#include "nsGfxButtonControlFrame.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2002-11-17 18:37:56 +03:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
1999-01-18 18:14:00 +03:00
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsIFormControl.h"
|
|
|
|
#include "nsINameSpaceManager.h"
|
|
|
|
#include "nsIDOMElement.h"
|
|
|
|
#include "nsIListControlFrame.h"
|
1999-04-13 02:14:31 +04:00
|
|
|
#include "nsIDOMHTMLCollection.h"
|
|
|
|
#include "nsIDOMHTMLSelectElement.h"
|
|
|
|
#include "nsIDOMHTMLOptionElement.h"
|
2010-04-21 18:53:42 +04:00
|
|
|
#include "nsPIDOMWindow.h"
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsIView.h"
|
2007-02-12 22:31:59 +03:00
|
|
|
#include "nsIViewManager.h"
|
2006-03-07 20:08:51 +03:00
|
|
|
#include "nsEventDispatcher.h"
|
2011-06-24 06:18:01 +04:00
|
|
|
#include "nsEventListenerManager.h"
|
1999-09-07 06:16:23 +04:00
|
|
|
#include "nsIDOMNode.h"
|
|
|
|
#include "nsIPrivateDOMEvent.h"
|
1999-09-15 09:31:31 +04:00
|
|
|
#include "nsISelectControlFrame.h"
|
2002-09-04 03:36:13 +04:00
|
|
|
#include "nsXPCOM.h"
|
1999-09-15 09:31:31 +04:00
|
|
|
#include "nsISupportsPrimitives.h"
|
|
|
|
#include "nsIComponentManager.h"
|
2006-03-15 00:02:42 +03:00
|
|
|
#include "nsContentUtils.h"
|
2000-03-07 18:54:31 +03:00
|
|
|
#include "nsTextFragment.h"
|
|
|
|
#include "nsCSSFrameConstructor.h"
|
|
|
|
#include "nsIDocument.h"
|
2000-05-10 17:13:39 +04:00
|
|
|
#include "nsINodeInfo.h"
|
2000-04-19 17:55:17 +04:00
|
|
|
#include "nsIScrollableFrame.h"
|
2001-02-23 04:45:45 +03:00
|
|
|
#include "nsListControlFrame.h"
|
2001-02-20 00:50:04 +03:00
|
|
|
#include "nsContentCID.h"
|
2001-08-17 07:13:07 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2011-01-28 07:38:14 +03:00
|
|
|
#include "nsAccessibilityService.h"
|
2001-08-17 07:13:07 +04:00
|
|
|
#endif
|
2001-04-01 05:01:33 +04:00
|
|
|
#include "nsIServiceManager.h"
|
2001-07-16 06:40:48 +04:00
|
|
|
#include "nsGUIEvent.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsAutoPtr.h"
|
2004-01-28 03:18:22 +03:00
|
|
|
#include "nsStyleSet.h"
|
2004-06-25 16:26:02 +04:00
|
|
|
#include "nsNodeInfoManager.h"
|
|
|
|
#include "nsContentCreatorFunctions.h"
|
2006-07-06 14:43:51 +04:00
|
|
|
#include "nsLayoutUtils.h"
|
2006-01-26 05:29:17 +03:00
|
|
|
#include "nsDisplayList.h"
|
2007-02-16 04:53:43 +03:00
|
|
|
#include "nsITheme.h"
|
|
|
|
#include "nsThemeConstants.h"
|
2011-12-17 10:02:05 +04:00
|
|
|
#include "nsAsyncDOMEvent.h"
|
2011-04-08 05:04:40 +04:00
|
|
|
#include "nsRenderingContext.h"
|
2011-05-25 10:31:59 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2001-04-01 05:01:33 +04:00
|
|
|
|
2011-05-25 10:31:59 +04:00
|
|
|
using namespace mozilla;
|
2010-10-25 16:17:38 +04:00
|
|
|
|
2006-05-10 21:30:15 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsComboboxControlFrame::RedisplayTextEvent::Run()
|
2005-03-21 04:58:17 +03:00
|
|
|
{
|
2006-05-10 21:30:15 +04:00
|
|
|
if (mControlFrame)
|
|
|
|
mControlFrame->HandleRedisplayTextEvent();
|
|
|
|
return NS_OK;
|
2005-03-21 04:58:17 +03:00
|
|
|
}
|
|
|
|
|
2005-01-28 01:52:53 +03:00
|
|
|
class nsPresState;
|
1999-01-18 18:14:00 +03:00
|
|
|
|
2000-12-20 18:09:00 +03:00
|
|
|
#define FIX_FOR_BUG_53259
|
|
|
|
|
1999-05-28 01:17:10 +04:00
|
|
|
// Drop down list event management.
|
2000-03-07 18:54:31 +03:00
|
|
|
// The combo box uses the following strategy for managing the drop-down list.
|
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.
|
|
|
|
*/
|
2011-06-29 22:07:25 +04:00
|
|
|
class nsComboButtonListener : public nsIDOMEventListener
|
2001-06-30 04:25:09 +04:00
|
|
|
{
|
2011-06-29 22:07:25 +04:00
|
|
|
public:
|
2001-06-30 04:25:09 +04:00
|
|
|
NS_DECL_ISUPPORTS
|
2011-06-29 22:07:25 +04:00
|
|
|
|
|
|
|
NS_IMETHOD HandleEvent(nsIDOMEvent*)
|
2001-06-30 04:25:09 +04:00
|
|
|
{
|
2006-02-18 04:52:03 +03:00
|
|
|
mComboBox->ShowDropDown(!mComboBox->IsDroppedDown());
|
2007-05-17 15:12:30 +04:00
|
|
|
return NS_OK;
|
2001-06-30 04:25:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsComboButtonListener(nsComboboxControlFrame* aCombobox)
|
|
|
|
{
|
|
|
|
mComboBox = aCombobox;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~nsComboButtonListener() {}
|
|
|
|
|
|
|
|
nsComboboxControlFrame* mComboBox;
|
|
|
|
};
|
|
|
|
|
2011-06-29 22:07:25 +04:00
|
|
|
NS_IMPL_ISUPPORTS1(nsComboButtonListener,
|
2008-04-06 16:28:34 +04:00
|
|
|
nsIDOMEventListener)
|
2001-06-30 04:25:09 +04:00
|
|
|
|
2000-10-04 17:39:07 +04:00
|
|
|
// static class data member for Bug 32920
|
|
|
|
nsComboboxControlFrame * nsComboboxControlFrame::mFocused = nsnull;
|
|
|
|
|
2005-11-04 05:38:33 +03:00
|
|
|
nsIFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewComboboxControlFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, PRUint32 aStateFlags)
|
1999-01-18 18:14:00 +03:00
|
|
|
{
|
2006-03-27 01:30:36 +04:00
|
|
|
nsComboboxControlFrame* it = new (aPresShell) nsComboboxControlFrame(aContext);
|
2005-11-04 05:38:33 +03:00
|
|
|
|
|
|
|
if (it) {
|
|
|
|
// set the state flags (if any are provided)
|
|
|
|
it->AddStateBits(aStateFlags);
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
2005-11-04 05:38:33 +03:00
|
|
|
|
|
|
|
return it;
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsComboboxControlFrame)
|
|
|
|
|
2011-09-08 19:35:33 +04:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
class DestroyWidgetRunnable : public nsRunnable {
|
|
|
|
public:
|
|
|
|
NS_DECL_NSIRUNNABLE
|
|
|
|
|
|
|
|
explicit DestroyWidgetRunnable(nsIContent* aCombobox) :
|
|
|
|
mCombobox(aCombobox),
|
|
|
|
mWidget(GetWidget())
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsIWidget* GetWidget(nsIView** aOutView = nsnull) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsCOMPtr<nsIContent> mCombobox;
|
|
|
|
nsIWidget* mWidget;
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMETHODIMP DestroyWidgetRunnable::Run()
|
|
|
|
{
|
|
|
|
nsIView* view = nsnull;
|
|
|
|
nsIWidget* currentWidget = GetWidget(&view);
|
|
|
|
// Make sure that we are destroying the same widget as what was requested
|
|
|
|
// when the event was fired.
|
|
|
|
if (view && mWidget && mWidget == currentWidget) {
|
|
|
|
view->DestroyWidget();
|
|
|
|
}
|
2011-09-09 04:08:40 +04:00
|
|
|
return NS_OK;
|
2011-09-08 19:35:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsIWidget* DestroyWidgetRunnable::GetWidget(nsIView** aOutView) const
|
|
|
|
{
|
|
|
|
nsIFrame* primaryFrame = mCombobox->GetPrimaryFrame();
|
|
|
|
nsIComboboxControlFrame* comboboxFrame = do_QueryFrame(primaryFrame);
|
|
|
|
if (comboboxFrame) {
|
|
|
|
nsIFrame* dropdown = comboboxFrame->GetDropDown();
|
|
|
|
if (dropdown) {
|
|
|
|
nsIView* view = dropdown->GetView();
|
|
|
|
NS_ASSERTION(view, "nsComboboxControlFrame view is null");
|
|
|
|
if (aOutView) {
|
|
|
|
*aOutView = view;
|
|
|
|
}
|
|
|
|
if (view) {
|
|
|
|
return view->GetWidget();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
// Reflow Debugging Macros
|
|
|
|
// These let us "see" how many reflow counts are happening
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
#ifdef DO_REFLOW_COUNTER
|
|
|
|
|
|
|
|
#define MAX_REFLOW_CNT 1024
|
|
|
|
static PRInt32 gTotalReqs = 0;;
|
|
|
|
static PRInt32 gTotalReflows = 0;;
|
|
|
|
static PRInt32 gReflowControlCntRQ[MAX_REFLOW_CNT];
|
|
|
|
static PRInt32 gReflowControlCnt[MAX_REFLOW_CNT];
|
|
|
|
static PRInt32 gReflowInx = -1;
|
|
|
|
|
|
|
|
#define REFLOW_COUNTER() \
|
|
|
|
if (mReflowId > -1) \
|
|
|
|
gReflowControlCnt[mReflowId]++;
|
|
|
|
|
|
|
|
#define REFLOW_COUNTER_REQUEST() \
|
|
|
|
if (mReflowId > -1) \
|
|
|
|
gReflowControlCntRQ[mReflowId]++;
|
|
|
|
|
|
|
|
#define REFLOW_COUNTER_DUMP(__desc) \
|
|
|
|
if (mReflowId > -1) {\
|
|
|
|
gTotalReqs += gReflowControlCntRQ[mReflowId];\
|
|
|
|
gTotalReflows += gReflowControlCnt[mReflowId];\
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("** Id:%5d %s RF: %d RQ: %d %d/%d %5.2f\n", \
|
2000-03-07 18:54:31 +03:00
|
|
|
mReflowId, (__desc), \
|
|
|
|
gReflowControlCnt[mReflowId], \
|
|
|
|
gReflowControlCntRQ[mReflowId],\
|
|
|
|
gTotalReflows, gTotalReqs, float(gTotalReflows)/float(gTotalReqs)*100.0f);\
|
|
|
|
}
|
|
|
|
|
|
|
|
#define REFLOW_COUNTER_INIT() \
|
|
|
|
if (gReflowInx < MAX_REFLOW_CNT) { \
|
|
|
|
gReflowInx++; \
|
|
|
|
mReflowId = gReflowInx; \
|
|
|
|
gReflowControlCnt[mReflowId] = 0; \
|
|
|
|
gReflowControlCntRQ[mReflowId] = 0; \
|
|
|
|
} else { \
|
|
|
|
mReflowId = -1; \
|
|
|
|
}
|
|
|
|
|
|
|
|
// reflow messages
|
2000-10-29 02:17:53 +04:00
|
|
|
#define REFLOW_DEBUG_MSG(_msg1) printf((_msg1))
|
|
|
|
#define REFLOW_DEBUG_MSG2(_msg1, _msg2) printf((_msg1), (_msg2))
|
|
|
|
#define REFLOW_DEBUG_MSG3(_msg1, _msg2, _msg3) printf((_msg1), (_msg2), (_msg3))
|
|
|
|
#define REFLOW_DEBUG_MSG4(_msg1, _msg2, _msg3, _msg4) printf((_msg1), (_msg2), (_msg3), (_msg4))
|
2000-03-07 18:54:31 +03:00
|
|
|
|
|
|
|
#else //-------------
|
|
|
|
|
|
|
|
#define REFLOW_COUNTER_REQUEST()
|
|
|
|
#define REFLOW_COUNTER()
|
|
|
|
#define REFLOW_COUNTER_DUMP(__desc)
|
|
|
|
#define REFLOW_COUNTER_INIT()
|
|
|
|
|
|
|
|
#define REFLOW_DEBUG_MSG(_msg)
|
|
|
|
#define REFLOW_DEBUG_MSG2(_msg1, _msg2)
|
|
|
|
#define REFLOW_DEBUG_MSG3(_msg1, _msg2, _msg3)
|
|
|
|
#define REFLOW_DEBUG_MSG4(_msg1, _msg2, _msg3, _msg4)
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//------------------------------------------
|
|
|
|
// This is for being VERY noisy
|
|
|
|
//------------------------------------------
|
|
|
|
#ifdef DO_VERY_NOISY
|
2000-10-29 02:17:53 +04:00
|
|
|
#define REFLOW_NOISY_MSG(_msg1) printf((_msg1))
|
|
|
|
#define REFLOW_NOISY_MSG2(_msg1, _msg2) printf((_msg1), (_msg2))
|
|
|
|
#define REFLOW_NOISY_MSG3(_msg1, _msg2, _msg3) printf((_msg1), (_msg2), (_msg3))
|
|
|
|
#define REFLOW_NOISY_MSG4(_msg1, _msg2, _msg3, _msg4) printf((_msg1), (_msg2), (_msg3), (_msg4))
|
2000-03-07 18:54:31 +03:00
|
|
|
#else
|
|
|
|
#define REFLOW_NOISY_MSG(_msg)
|
|
|
|
#define REFLOW_NOISY_MSG2(_msg1, _msg2)
|
|
|
|
#define REFLOW_NOISY_MSG3(_msg1, _msg2, _msg3)
|
|
|
|
#define REFLOW_NOISY_MSG4(_msg1, _msg2, _msg3, _msg4)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//------------------------------------------
|
|
|
|
// Displays value in pixels or twips
|
|
|
|
//------------------------------------------
|
|
|
|
#ifdef DO_PIXELS
|
|
|
|
#define PX(__v) __v / 15
|
|
|
|
#else
|
|
|
|
#define PX(__v) __v
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//------------------------------------------------------
|
|
|
|
//-- Done with macros
|
|
|
|
//------------------------------------------------------
|
|
|
|
|
2006-03-27 01:30:36 +04:00
|
|
|
nsComboboxControlFrame::nsComboboxControlFrame(nsStyleContext* aContext)
|
2008-12-29 18:07:38 +03:00
|
|
|
: nsBlockFrame(aContext),
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
mDisplayWidth(0)
|
1999-01-18 18:14:00 +03:00
|
|
|
{
|
1999-04-13 02:14:31 +04:00
|
|
|
mListControlFrame = nsnull;
|
2011-10-17 18:59:28 +04:00
|
|
|
mDroppedDown = false;
|
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
|
|
|
mDisplayFrame = nsnull;
|
|
|
|
mButtonFrame = nsnull;
|
|
|
|
mDropdownFrame = nsnull;
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
mInRedisplayText = false;
|
2000-10-04 17:39:07 +04:00
|
|
|
|
2006-09-30 09:07:49 +04:00
|
|
|
mRecentSelectedIndex = NS_SKIP_NOTIFY_INDEX;
|
2002-02-08 21:35:48 +03:00
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
REFLOW_COUNTER_INIT()
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
|
|
|
nsComboboxControlFrame::~nsComboboxControlFrame()
|
|
|
|
{
|
2000-03-07 18:54:31 +03:00
|
|
|
REFLOW_COUNTER_DUMP("nsCCF");
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
2009-01-12 22:20:59 +03:00
|
|
|
|
|
|
|
NS_QUERYFRAME_HEAD(nsComboboxControlFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIComboboxControlFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIFormControlFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsISelectControlFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIStatefulFrame)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrame)
|
|
|
|
|
2001-08-17 07:13:07 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2010-06-28 16:02:03 +04:00
|
|
|
already_AddRefed<nsAccessible>
|
|
|
|
nsComboboxControlFrame::CreateAccessible()
|
2001-05-18 03:52:32 +04:00
|
|
|
{
|
2011-01-28 07:38:14 +03:00
|
|
|
nsAccessibilityService* accService = nsIPresShell::AccService();
|
2001-05-18 03:52:32 +04:00
|
|
|
if (accService) {
|
2010-06-28 16:02:03 +04:00
|
|
|
return accService->CreateHTMLComboboxAccessible(mContent,
|
|
|
|
PresContext()->PresShell());
|
2001-05-18 03:52:32 +04:00
|
|
|
}
|
|
|
|
|
2010-06-28 16:02:03 +04:00
|
|
|
return nsnull;
|
2001-05-18 03:52:32 +04:00
|
|
|
}
|
2001-08-17 07:13:07 +04:00
|
|
|
#endif
|
2001-05-18 03:52:32 +04:00
|
|
|
|
1999-01-18 18:14:00 +03:00
|
|
|
void
|
2011-09-29 10:19:26 +04:00
|
|
|
nsComboboxControlFrame::SetFocus(bool aOn, bool aRepaint)
|
1999-01-18 18:14:00 +03:00
|
|
|
{
|
2006-08-11 16:09:30 +04:00
|
|
|
nsWeakFrame weakFrame(this);
|
2001-01-04 15:22:29 +03:00
|
|
|
if (aOn) {
|
2002-11-07 13:25:03 +03:00
|
|
|
nsListControlFrame::ComboboxFocusSet();
|
2004-07-23 12:25:44 +04:00
|
|
|
mFocused = this;
|
2001-01-04 15:22:29 +03:00
|
|
|
} else {
|
|
|
|
mFocused = nsnull;
|
|
|
|
if (mDroppedDown) {
|
2007-05-17 15:12:30 +04:00
|
|
|
mListControlFrame->ComboboxFinish(mDisplayedIndex); // might destroy us
|
|
|
|
if (!weakFrame.IsAlive()) {
|
|
|
|
return;
|
|
|
|
}
|
2002-02-08 21:35:48 +03:00
|
|
|
}
|
2006-08-11 16:09:30 +04:00
|
|
|
// May delete |this|.
|
2004-05-28 20:25:04 +04:00
|
|
|
mListControlFrame->FireOnChange();
|
2001-01-04 15:22:29 +03:00
|
|
|
}
|
2002-02-08 21:35:48 +03:00
|
|
|
|
2006-08-11 16:09:30 +04:00
|
|
|
if (!weakFrame.IsAlive()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-01-04 15:22:29 +03:00
|
|
|
// This is needed on a temporary basis. It causes the focus
|
2000-10-04 17:39:07 +04:00
|
|
|
// rect to be drawn. This is much faster than ReResolvingStyle
|
|
|
|
// Bug 32920
|
2008-09-18 13:47:21 +04:00
|
|
|
Invalidate(nsRect(0,0,mRect.width,mRect.height));
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
void
|
2011-09-29 10:19:26 +04:00
|
|
|
nsComboboxControlFrame::ShowPopup(bool aShowPopup)
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
{
|
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;
|
2011-10-17 18:59:28 +04:00
|
|
|
nsMouseEvent event(true, aShowPopup ?
|
2005-04-29 03:48:28 +04:00
|
|
|
NS_XUL_POPUP_SHOWING : NS_XUL_POPUP_HIDING, nsnull,
|
|
|
|
nsMouseEvent::eReal);
|
2001-04-01 05:01:33 +04:00
|
|
|
|
2007-03-31 01:11:41 +04:00
|
|
|
nsCOMPtr<nsIPresShell> shell = PresContext()->GetPresShell();
|
2003-12-21 08:36:36 +03:00
|
|
|
if (shell)
|
|
|
|
shell->HandleDOMEventWithTarget(mContent, &event, &status);
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
|
|
|
nsComboboxControlFrame::ShowList(bool aShowList)
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
{
|
2007-05-17 15:12:30 +04:00
|
|
|
nsCOMPtr<nsIPresShell> shell = PresContext()->GetPresShell();
|
1999-09-22 01:20:50 +04:00
|
|
|
|
2007-05-17 15:12:30 +04:00
|
|
|
nsWeakFrame weakFrame(this);
|
2011-03-21 21:28:10 +03:00
|
|
|
|
|
|
|
if (aShowList) {
|
|
|
|
nsIView* view = mDropdownFrame->GetView();
|
|
|
|
NS_ASSERTION(!view->HasWidget(),
|
|
|
|
"We shoudldn't have a widget before we need to display the popup");
|
|
|
|
|
|
|
|
// Create the widget for the drop-down list
|
2011-10-17 18:59:28 +04:00
|
|
|
view->GetViewManager()->SetViewFloating(view, true);
|
2011-03-21 21:28:10 +03:00
|
|
|
|
|
|
|
nsWidgetInitData widgetData;
|
|
|
|
widgetData.mWindowType = eWindowType_popup;
|
|
|
|
widgetData.mBorderStyle = eBorderStyle_default;
|
|
|
|
view->CreateWidgetForPopup(&widgetData);
|
|
|
|
}
|
|
|
|
|
2007-05-17 15:12:30 +04:00
|
|
|
ShowPopup(aShowList); // might destroy us
|
|
|
|
if (!weakFrame.IsAlive()) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
1999-09-22 01:20:50 +04:00
|
|
|
}
|
|
|
|
|
2007-05-17 15:12:30 +04:00
|
|
|
mDroppedDown = aShowList;
|
|
|
|
if (mDroppedDown) {
|
|
|
|
// The listcontrol frame will call back to the nsComboboxControlFrame's
|
|
|
|
// ListWasSelected which will stop the capture.
|
1999-09-08 18:27:38 +04:00
|
|
|
mListControlFrame->AboutToDropDown();
|
2011-10-17 18:59:28 +04:00
|
|
|
mListControlFrame->CaptureMouseEvents(true);
|
2007-05-17 15:12:31 +04:00
|
|
|
}
|
2000-02-12 01:26:36 +03:00
|
|
|
|
2007-08-22 06:57:06 +04:00
|
|
|
// XXXbz so why do we need to flush here, exactly?
|
|
|
|
shell->GetDocument()->FlushPendingNotifications(Flush_Layout);
|
2007-05-17 15:12:30 +04:00
|
|
|
if (!weakFrame.IsAlive()) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2007-05-17 15:12:30 +04:00
|
|
|
}
|
2007-03-23 02:01:14 +03:00
|
|
|
|
2009-01-12 22:20:59 +03:00
|
|
|
nsIFrame* listFrame = do_QueryFrame(mListControlFrame);
|
2007-05-17 15:12:30 +04:00
|
|
|
if (listFrame) {
|
|
|
|
nsIView* view = listFrame->GetView();
|
|
|
|
NS_ASSERTION(view, "nsComboboxControlFrame view is null");
|
|
|
|
if (view) {
|
|
|
|
nsIWidget* widget = view->GetWidget();
|
2011-03-21 21:28:10 +03:00
|
|
|
if (widget) {
|
2011-11-08 23:59:07 +04:00
|
|
|
widget->CaptureRollupEvents(this, mDroppedDown, mDroppedDown);
|
2011-03-21 21:28:10 +03:00
|
|
|
|
|
|
|
if (!aShowList) {
|
2011-09-08 19:35:33 +04:00
|
|
|
nsCOMPtr<nsIRunnable> widgetDestroyer =
|
|
|
|
new DestroyWidgetRunnable(GetContent());
|
|
|
|
NS_DispatchToMainThread(widgetDestroyer);
|
2011-03-21 21:28:10 +03:00
|
|
|
}
|
|
|
|
}
|
2007-05-17 15:12:30 +04:00
|
|
|
}
|
|
|
|
}
|
2000-02-12 01:26:36 +03:00
|
|
|
|
2007-05-17 15:12:30 +04:00
|
|
|
return weakFrame.IsAlive();
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
}
|
1999-05-08 00:30:16 +04:00
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
nsresult
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nsComboboxControlFrame::ReflowDropdown(nsPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aReflowState)
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
// All we want out of it later on, really, is the height of a row, so we
|
|
|
|
// don't even need to cache mDropdownFrame's ascent or anything. If we don't
|
|
|
|
// need to reflow it, just bail out here.
|
|
|
|
if (!aReflowState.ShouldReflowAllKids() &&
|
2007-05-06 23:16:51 +04:00
|
|
|
!NS_SUBTREE_DIRTY(mDropdownFrame)) {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// XXXbz this will, for small-height dropdowns, have extra space on the right
|
|
|
|
// edge for the scrollbar we don't show... but that's the best we can do here
|
|
|
|
// for now.
|
|
|
|
nsSize availSize(aReflowState.availableWidth, NS_UNCONSTRAINEDSIZE);
|
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, mDropdownFrame,
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
availSize);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
|
|
|
// If the dropdown's intrinsic width is narrower than our specified width,
|
|
|
|
// then expand it out. We want our border-box width to end up the same as
|
|
|
|
// the dropdown's so account for both sets of mComputedBorderPadding.
|
2007-01-26 03:05:12 +03:00
|
|
|
nscoord forcedWidth = aReflowState.ComputedWidth() +
|
2007-01-11 20:59:41 +03:00
|
|
|
aReflowState.mComputedBorderPadding.LeftRight() -
|
|
|
|
kidReflowState.mComputedBorderPadding.LeftRight();
|
2009-09-16 19:01:36 +04:00
|
|
|
kidReflowState.SetComputedWidth(NS_MAX(kidReflowState.ComputedWidth(),
|
2007-01-26 03:05:12 +03:00
|
|
|
forcedWidth));
|
2000-05-26 10:42:29 +04:00
|
|
|
|
|
|
|
// ensure we start off hidden
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
if (GetStateBits() & NS_FRAME_FIRST_REFLOW) {
|
2003-07-04 16:50:32 +04:00
|
|
|
nsIView* view = mDropdownFrame->GetView();
|
|
|
|
nsIViewManager* viewManager = view->GetViewManager();
|
2000-05-26 10:42:29 +04:00
|
|
|
viewManager->SetViewVisibility(view, nsViewVisibility_kHide);
|
2001-12-01 17:31:45 +03:00
|
|
|
nsRect emptyRect(0, 0, 0, 0);
|
|
|
|
viewManager->ResizeView(view, emptyRect);
|
2000-05-26 10:42:29 +04:00
|
|
|
}
|
|
|
|
|
2005-06-22 05:38:49 +04:00
|
|
|
// Allow the child to move/size/change-visibility its view if it's currently
|
|
|
|
// dropped down
|
2008-09-04 01:35:52 +04:00
|
|
|
PRInt32 flags = NS_FRAME_NO_MOVE_FRAME | NS_FRAME_NO_VISIBILITY | NS_FRAME_NO_SIZE_VIEW;
|
2005-06-22 05:38:49 +04:00
|
|
|
if (mDroppedDown) {
|
|
|
|
flags = 0;
|
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nsRect rect = mDropdownFrame->GetRect();
|
|
|
|
nsHTMLReflowMetrics desiredSize;
|
|
|
|
nsReflowStatus ignoredStatus;
|
|
|
|
nsresult rv = ReflowChild(mDropdownFrame, aPresContext, desiredSize,
|
|
|
|
kidReflowState, rect.x, rect.y, flags,
|
|
|
|
ignoredStatus);
|
1999-11-19 18:33:29 +03:00
|
|
|
|
|
|
|
// Set the child's width and height to it's desired size
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
FinishReflowChild(mDropdownFrame, aPresContext, &kidReflowState,
|
|
|
|
desiredSize, rect.x, rect.y, flags);
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2011-09-18 22:16:47 +04:00
|
|
|
nsPoint
|
2011-09-18 22:20:09 +04:00
|
|
|
nsComboboxControlFrame::GetCSSTransformTranslation()
|
2011-09-18 22:16:47 +04:00
|
|
|
{
|
|
|
|
nsIFrame* frame = this;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool is3DTransform = false;
|
2011-09-18 22:16:47 +04:00
|
|
|
gfxMatrix transform;
|
|
|
|
while (frame) {
|
2011-12-28 07:24:18 +04:00
|
|
|
nsIFrame* parent;
|
|
|
|
gfx3DMatrix ctm = frame->GetTransformMatrix(nsnull, &parent);
|
2011-09-18 22:16:47 +04:00
|
|
|
gfxMatrix matrix;
|
|
|
|
if (ctm.Is2D(&matrix)) {
|
|
|
|
transform = transform * matrix;
|
|
|
|
} else {
|
2011-10-17 18:59:28 +04:00
|
|
|
is3DTransform = true;
|
2011-09-18 22:16:47 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
frame = parent;
|
|
|
|
}
|
|
|
|
nsPoint translation;
|
|
|
|
if (!is3DTransform && !transform.HasNonTranslation()) {
|
|
|
|
nsPresContext* pc = PresContext();
|
|
|
|
gfxPoint pixelTranslation = transform.GetTranslation();
|
|
|
|
PRInt32 apd = pc->AppUnitsPerDevPixel();
|
|
|
|
translation.x = NSFloatPixelsToAppUnits(float(pixelTranslation.x), apd);
|
|
|
|
translation.y = NSFloatPixelsToAppUnits(float(pixelTranslation.y), apd);
|
|
|
|
// To get the translation introduced only by transforms we subtract the
|
|
|
|
// regular non-transform translation.
|
|
|
|
nsRootPresContext* rootPC = pc->GetRootPresContext();
|
|
|
|
if (rootPC) {
|
|
|
|
translation -= GetOffsetToCrossDoc(rootPC->PresShell()->GetRootFrame());
|
|
|
|
} else {
|
|
|
|
translation.x = translation.y = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return translation;
|
|
|
|
}
|
|
|
|
|
2007-02-15 13:58:31 +03:00
|
|
|
void
|
|
|
|
nsComboboxControlFrame::AbsolutelyPositionDropDown()
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
{
|
|
|
|
// Position the dropdown list. It is positioned below the display frame if there is enough
|
|
|
|
// room on the screen to display the entire list. Otherwise it is placed above the display
|
|
|
|
// frame.
|
1999-01-18 18:14:00 +03:00
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
// Note: As first glance, it appears that you could simply get the absolute bounding box for the
|
2005-11-21 01:05:24 +03:00
|
|
|
// dropdown list by first getting its view, then getting the view's nsIWidget, then asking the nsIWidget
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
// for it's AbsoluteBounds. The problem with this approach, is that the dropdown lists y location can
|
|
|
|
// change based on whether the dropdown is placed below or above the display frame.
|
|
|
|
// The approach, taken here is to get use the absolute position of the display frame and use it's location
|
|
|
|
// to determine if the dropdown will go offscreen.
|
1999-01-18 18:14:00 +03:00
|
|
|
|
2011-09-18 22:16:47 +04:00
|
|
|
// Normal frame geometry (eg GetOffsetTo, mRect) doesn't include transforms.
|
|
|
|
// In the special case that our transform is only a 2D translation we
|
|
|
|
// introduce this hack so that the dropdown will show up in the right place.
|
|
|
|
nsPoint translation = GetCSSTransformTranslation();
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
// Use the height calculated for the area frame so it includes both
|
|
|
|
// the display and button heights.
|
2007-02-15 13:58:31 +03:00
|
|
|
nscoord dropdownYOffset = GetRect().height;
|
|
|
|
nsSize dropdownSize = mDropdownFrame->GetSize();
|
1999-07-29 01:38:08 +04:00
|
|
|
|
2009-08-18 07:21:07 +04:00
|
|
|
nsRect screen = nsFormControlFrame::GetUsableScreenRect(PresContext());
|
|
|
|
|
|
|
|
// Check to see if the drop-down list will go offscreen
|
2011-09-18 22:16:47 +04:00
|
|
|
if ((GetScreenRectInAppUnits() + translation).YMost() + dropdownSize.height > screen.YMost()) {
|
2009-08-18 07:21:07 +04:00
|
|
|
// move the dropdown list up
|
|
|
|
dropdownYOffset = - (dropdownSize.height);
|
2003-04-09 00:50:57 +04:00
|
|
|
}
|
2007-02-15 13:58:31 +03:00
|
|
|
|
|
|
|
nsPoint dropdownPosition;
|
2006-08-13 23:34:58 +04:00
|
|
|
const nsStyleVisibility* vis = GetStyleVisibility();
|
|
|
|
if (vis->mDirection == NS_STYLE_DIRECTION_RTL) {
|
|
|
|
// Align the right edge of the drop-down with the right edge of the control.
|
2007-02-15 13:58:31 +03:00
|
|
|
dropdownPosition.x = GetRect().width - dropdownSize.width;
|
2006-08-13 23:34:58 +04:00
|
|
|
} else {
|
2007-02-15 13:58:31 +03:00
|
|
|
dropdownPosition.x = 0;
|
2006-08-13 23:34:58 +04:00
|
|
|
}
|
2007-02-15 13:58:31 +03:00
|
|
|
dropdownPosition.y = dropdownYOffset;
|
1999-09-09 17:17:35 +04:00
|
|
|
|
2011-09-18 22:16:47 +04:00
|
|
|
mDropdownFrame->SetPosition(dropdownPosition + translation);
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
}
|
1999-01-18 18:14:00 +03:00
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
//----------------------------------------------------------
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------
|
|
|
|
#ifdef DO_REFLOW_DEBUG
|
2000-03-03 10:14:58 +03:00
|
|
|
static int myCounter = 0;
|
2000-03-07 18:54:31 +03:00
|
|
|
|
|
|
|
static void printSize(char * aDesc, nscoord aSize)
|
|
|
|
{
|
2000-10-29 02:17:53 +04:00
|
|
|
printf(" %s: ", aDesc);
|
2000-03-07 18:54:31 +03:00
|
|
|
if (aSize == NS_UNCONSTRAINEDSIZE) {
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("UC");
|
2000-03-07 18:54:31 +03:00
|
|
|
} else {
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("%d", PX(aSize));
|
2000-03-07 18:54:31 +03:00
|
|
|
}
|
|
|
|
}
|
2000-01-28 18:24:49 +03:00
|
|
|
#endif
|
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
//-------------------------------------------------------------------
|
|
|
|
//-- Main Reflow for the Combobox
|
|
|
|
//-------------------------------------------------------------------
|
2000-04-22 01:53:38 +04:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nscoord
|
2011-04-08 05:04:40 +04:00
|
|
|
nsComboboxControlFrame::GetIntrinsicWidth(nsRenderingContext* aRenderingContext,
|
2007-12-03 09:41:38 +03:00
|
|
|
nsLayoutUtils::IntrinsicWidthType aType)
|
2007-12-03 09:41:39 +03:00
|
|
|
{
|
2007-05-29 09:31:04 +04:00
|
|
|
// get the scrollbar width, we'll use this later
|
|
|
|
nscoord scrollbarWidth = 0;
|
|
|
|
nsPresContext* presContext = PresContext();
|
|
|
|
if (mListControlFrame) {
|
2009-01-12 22:20:59 +03:00
|
|
|
nsIScrollableFrame* scrollable = do_QueryFrame(mListControlFrame);
|
2007-05-29 09:31:04 +04:00
|
|
|
NS_ASSERTION(scrollable, "List must be a scrollable frame");
|
2008-04-10 08:39:41 +04:00
|
|
|
scrollbarWidth =
|
|
|
|
scrollable->GetDesiredScrollbarSizes(presContext, aRenderingContext).LeftRight();
|
2007-05-29 09:31:04 +04:00
|
|
|
}
|
2007-03-23 02:01:14 +03:00
|
|
|
|
2007-12-03 09:41:38 +03:00
|
|
|
nscoord displayWidth = 0;
|
2007-05-29 09:31:04 +04:00
|
|
|
if (NS_LIKELY(mDisplayFrame)) {
|
2007-12-03 09:41:38 +03:00
|
|
|
displayWidth = nsLayoutUtils::IntrinsicForContainer(aRenderingContext,
|
|
|
|
mDisplayFrame,
|
|
|
|
aType);
|
2007-03-23 02:01:14 +03:00
|
|
|
}
|
|
|
|
|
2007-05-29 09:31:04 +04:00
|
|
|
if (mDropdownFrame) {
|
2007-12-03 09:41:38 +03:00
|
|
|
nscoord dropdownContentWidth;
|
|
|
|
if (aType == nsLayoutUtils::MIN_WIDTH) {
|
|
|
|
dropdownContentWidth = mDropdownFrame->GetMinWidth(aRenderingContext);
|
|
|
|
} else {
|
|
|
|
NS_ASSERTION(aType == nsLayoutUtils::PREF_WIDTH, "Unexpected type");
|
|
|
|
dropdownContentWidth = mDropdownFrame->GetPrefWidth(aRenderingContext);
|
|
|
|
}
|
2007-12-18 22:26:35 +03:00
|
|
|
dropdownContentWidth = NSCoordSaturatingSubtract(dropdownContentWidth,
|
|
|
|
scrollbarWidth,
|
|
|
|
nscoord_MAX);
|
2007-12-03 09:41:38 +03:00
|
|
|
|
2009-09-16 19:01:36 +04:00
|
|
|
displayWidth = NS_MAX(dropdownContentWidth, displayWidth);
|
2007-05-05 10:20:10 +04:00
|
|
|
}
|
|
|
|
|
2007-05-29 09:31:04 +04:00
|
|
|
// add room for the dropmarker button if there is one
|
|
|
|
if (!IsThemed() || presContext->GetTheme()->ThemeNeedsComboboxDropmarker())
|
2007-12-03 09:41:38 +03:00
|
|
|
displayWidth += scrollbarWidth;
|
|
|
|
|
|
|
|
return displayWidth;
|
2007-05-29 09:31:04 +04:00
|
|
|
|
2007-12-03 09:41:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
2011-04-08 05:04:40 +04:00
|
|
|
nsComboboxControlFrame::GetMinWidth(nsRenderingContext *aRenderingContext)
|
2007-12-03 09:41:38 +03:00
|
|
|
{
|
|
|
|
nscoord minWidth;
|
|
|
|
DISPLAY_MIN_WIDTH(this, minWidth);
|
|
|
|
minWidth = GetIntrinsicWidth(aRenderingContext, nsLayoutUtils::MIN_WIDTH);
|
|
|
|
return minWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
2011-04-08 05:04:40 +04:00
|
|
|
nsComboboxControlFrame::GetPrefWidth(nsRenderingContext *aRenderingContext)
|
2007-12-03 09:41:38 +03:00
|
|
|
{
|
|
|
|
nscoord prefWidth;
|
|
|
|
DISPLAY_PREF_WIDTH(this, prefWidth);
|
|
|
|
prefWidth = GetIntrinsicWidth(aRenderingContext, nsLayoutUtils::PREF_WIDTH);
|
|
|
|
return prefWidth;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
}
|
2000-03-07 18:54:31 +03:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsComboboxControlFrame::Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
// Constraints we try to satisfy:
|
2000-03-07 18:54:31 +03:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
// 1) Default width of button is the vertical scrollbar size
|
|
|
|
// 2) If the width of button is bigger than our width, set width of
|
|
|
|
// button to 0.
|
|
|
|
// 3) Default height of button is height of display area
|
|
|
|
// 4) Width of display area is whatever is left over from our width after
|
|
|
|
// allocating width for the button.
|
|
|
|
// 5) Height of display area is GetHeightOfARow() on the
|
|
|
|
// mListControlFrame.
|
2000-03-03 07:28:59 +03:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
if (!mDisplayFrame || !mButtonFrame || !mDropdownFrame) {
|
|
|
|
NS_ERROR("Why did the frame constructor allow this to happen? Fix it!!");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2000-01-28 18:24:49 +03:00
|
|
|
}
|
|
|
|
|
2005-06-21 04:00:14 +04:00
|
|
|
// Make sure the displayed text is the same as the selected option, bug 297389.
|
|
|
|
PRInt32 selectedIndex;
|
|
|
|
nsAutoString selectedOptionText;
|
2005-10-22 07:47:00 +04:00
|
|
|
if (!mDroppedDown) {
|
2006-03-01 04:00:29 +03:00
|
|
|
selectedIndex = mListControlFrame->GetSelectedIndex();
|
2005-10-22 07:47:00 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// In dropped down mode the "selected index" is the hovered menu item,
|
|
|
|
// we want the last selected item which is |mDisplayedIndex| in this case.
|
|
|
|
selectedIndex = mDisplayedIndex;
|
|
|
|
}
|
2005-06-21 04:00:14 +04:00
|
|
|
if (selectedIndex != -1) {
|
|
|
|
mListControlFrame->GetOptionText(selectedIndex, selectedOptionText);
|
|
|
|
}
|
|
|
|
if (mDisplayedOptionText != selectedOptionText) {
|
|
|
|
RedisplayText(selectedIndex);
|
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
// First reflow our dropdown so that we know how tall we should be.
|
|
|
|
ReflowDropdown(aPresContext, aReflowState);
|
2007-02-07 10:46:44 +03:00
|
|
|
|
2006-12-19 18:08:34 +03:00
|
|
|
// Get the width of the vertical scrollbar. That will be the width of the
|
|
|
|
// dropdown button.
|
2007-05-18 07:04:04 +04:00
|
|
|
nscoord buttonWidth;
|
|
|
|
const nsStyleDisplay *disp = GetStyleDisplay();
|
|
|
|
if (IsThemed(disp) && !aPresContext->GetTheme()->ThemeNeedsComboboxDropmarker()) {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
buttonWidth = 0;
|
2000-03-07 18:54:31 +03:00
|
|
|
}
|
2007-05-18 07:04:04 +04:00
|
|
|
else {
|
2009-01-12 22:20:59 +03:00
|
|
|
nsIScrollableFrame* scrollable = do_QueryFrame(mListControlFrame);
|
2007-05-18 07:04:04 +04:00
|
|
|
NS_ASSERTION(scrollable, "List must be a scrollable frame");
|
2008-04-10 08:39:41 +04:00
|
|
|
buttonWidth =
|
|
|
|
scrollable->GetDesiredScrollbarSizes(PresContext(),
|
|
|
|
aReflowState.rendContext).LeftRight();
|
2007-05-18 07:04:04 +04:00
|
|
|
if (buttonWidth > aReflowState.ComputedWidth()) {
|
|
|
|
buttonWidth = 0;
|
|
|
|
}
|
|
|
|
}
|
2000-08-03 18:13:40 +04:00
|
|
|
|
2007-01-26 03:05:12 +03:00
|
|
|
mDisplayWidth = aReflowState.ComputedWidth() - buttonWidth;
|
2000-08-03 18:13:40 +04:00
|
|
|
|
2008-12-29 18:07:38 +03:00
|
|
|
nsresult rv = nsBlockFrame::Reflow(aPresContext, aDesiredSize, aReflowState,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
aStatus);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2000-08-03 18:13:40 +04:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
// Now set the correct width and height on our button. The width we need to
|
|
|
|
// set always, the height only if we had an auto height.
|
|
|
|
nsRect buttonRect = mButtonFrame->GetRect();
|
|
|
|
// If we have a non-intrinsic computed height, our kids should have sized
|
|
|
|
// themselves properly on their own.
|
2007-08-02 22:08:05 +04:00
|
|
|
if (aReflowState.ComputedHeight() == NS_INTRINSICSIZE) {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
// The display frame is going to be the right height and width at this
|
|
|
|
// point. Use its height as the button height.
|
|
|
|
nsRect displayRect = mDisplayFrame->GetRect();
|
|
|
|
buttonRect.height = displayRect.height;
|
|
|
|
buttonRect.y = displayRect.y;
|
2000-03-07 18:54:31 +03:00
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
else {
|
2007-04-26 05:17:05 +04:00
|
|
|
nscoord buttonHeight = mButtonFrame->GetSize().height;
|
|
|
|
nscoord displayHeight = mDisplayFrame->GetSize().height;
|
|
|
|
|
|
|
|
// The button and display area should be equal heights, unless the computed
|
|
|
|
// height on the combobox is too small to fit their borders and padding.
|
|
|
|
NS_ASSERTION(buttonHeight == displayHeight ||
|
2007-08-02 22:08:05 +04:00
|
|
|
(aReflowState.ComputedHeight() < buttonHeight &&
|
2007-04-26 05:17:05 +04:00
|
|
|
buttonHeight ==
|
|
|
|
mButtonFrame->GetUsedBorderAndPadding().TopBottom()) ||
|
2007-08-02 22:08:05 +04:00
|
|
|
(aReflowState.ComputedHeight() < displayHeight &&
|
2007-04-26 05:17:05 +04:00
|
|
|
displayHeight ==
|
|
|
|
mDisplayFrame->GetUsedBorderAndPadding().TopBottom()),
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
"Different heights?");
|
2000-01-28 18:24:49 +03:00
|
|
|
}
|
1999-12-22 22:46:28 +03:00
|
|
|
#endif
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
|
|
|
if (GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL) {
|
|
|
|
// Make sure the right edge of the button frame stays where it is now
|
|
|
|
buttonRect.x -= buttonWidth - buttonRect.width;
|
2000-03-07 18:54:31 +03:00
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
buttonRect.width = buttonWidth;
|
|
|
|
mButtonFrame->SetRect(buttonRect);
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
return rv;
|
|
|
|
}
|
2000-03-07 18:54:31 +03:00
|
|
|
|
1999-01-18 18:14:00 +03:00
|
|
|
//--------------------------------------------------------------
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsComboboxControlFrame::GetType() const
|
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
return nsGkAtoms::comboboxControlFrame;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
}
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef NS_DEBUG
|
1999-01-18 18:14:00 +03:00
|
|
|
NS_IMETHODIMP
|
2001-11-14 04:33:42 +03:00
|
|
|
nsComboboxControlFrame::GetFrameName(nsAString& aResult) const
|
1999-01-18 18:14:00 +03:00
|
|
|
{
|
2001-11-14 04:33:42 +03:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("ComboboxControl"), aResult);
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1999-01-18 18:14:00 +03:00
|
|
|
|
2002-01-09 22:17:46 +03:00
|
|
|
|
1999-01-18 18:14:00 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIComboboxControlFrame
|
|
|
|
//----------------------------------------------------------------------
|
2006-02-18 04:52:03 +03:00
|
|
|
void
|
2011-09-29 10:19:26 +04:00
|
|
|
nsComboboxControlFrame::ShowDropDown(bool aDoDropDown)
|
2006-04-26 06:01:07 +04:00
|
|
|
{
|
2011-06-01 05:46:57 +04:00
|
|
|
nsEventStates eventStates = mContent->AsElement()->State();
|
2010-10-20 15:26:32 +04:00
|
|
|
if (eventStates.HasState(NS_EVENT_STATE_DISABLED)) {
|
2006-02-18 04:52:03 +03:00
|
|
|
return;
|
1999-08-26 18:54:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!mDroppedDown && aDoDropDown) {
|
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
|
|
|
}
|
2009-09-02 06:46:47 +04:00
|
|
|
ShowList(aDoDropDown); // might destroy us
|
1999-08-26 18:54:07 +04:00
|
|
|
} else if (mDroppedDown && !aDoDropDown) {
|
2009-09-02 06:46:47 +04:00
|
|
|
ShowList(aDoDropDown); // might destroy us
|
1999-08-26 18:54:07 +04:00
|
|
|
}
|
|
|
|
}
|
1999-01-18 18:14:00 +03:00
|
|
|
|
2006-02-18 04:52:03 +03:00
|
|
|
void
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
nsComboboxControlFrame::SetDropDown(nsIFrame* aDropDownFrame)
|
1999-01-18 18:14:00 +03:00
|
|
|
{
|
1999-08-31 17:22:40 +04:00
|
|
|
mDropdownFrame = aDropDownFrame;
|
2009-01-12 22:20:59 +03:00
|
|
|
mListControlFrame = do_QueryFrame(mDropdownFrame);
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
2006-02-27 07:13:51 +03:00
|
|
|
nsIFrame*
|
|
|
|
nsComboboxControlFrame::GetDropDown()
|
|
|
|
{
|
|
|
|
return mDropdownFrame;
|
|
|
|
}
|
|
|
|
|
1999-08-31 17:22:40 +04:00
|
|
|
///////////////////////////////////////////////////////////////
|
|
|
|
|
1999-08-26 18:54:07 +04:00
|
|
|
NS_IMETHODIMP
|
2002-01-26 02:35:44 +03:00
|
|
|
nsComboboxControlFrame::RedisplaySelectedText()
|
1999-06-24 01:50:56 +04:00
|
|
|
{
|
2009-02-18 06:27:25 +03:00
|
|
|
nsAutoScriptBlocker scriptBlocker;
|
2006-03-01 04:00:29 +03:00
|
|
|
return RedisplayText(mListControlFrame->GetSelectedIndex());
|
2002-01-26 02:35:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsComboboxControlFrame::RedisplayText(PRInt32 aIndex)
|
|
|
|
{
|
|
|
|
// Get the text to display
|
|
|
|
if (aIndex != -1) {
|
2005-06-21 04:00:14 +04:00
|
|
|
mListControlFrame->GetOptionText(aIndex, mDisplayedOptionText);
|
|
|
|
} else {
|
|
|
|
mDisplayedOptionText.Truncate();
|
2002-01-26 02:35:44 +03:00
|
|
|
}
|
|
|
|
mDisplayedIndex = aIndex;
|
|
|
|
|
2005-06-21 04:00:14 +04:00
|
|
|
REFLOW_DEBUG_MSG2("RedisplayText \"%s\"\n",
|
2006-02-03 17:18:39 +03:00
|
|
|
NS_LossyConvertUTF16toASCII(mDisplayedOptionText).get());
|
2002-01-26 02:35:44 +03:00
|
|
|
|
1999-10-06 03:43:06 +04:00
|
|
|
// Send reflow command because the new text maybe larger
|
|
|
|
nsresult rv = NS_OK;
|
2006-03-15 00:02:42 +03:00
|
|
|
if (mDisplayContent) {
|
2011-10-17 18:59:28 +04:00
|
|
|
// Don't call ActuallyDisplayText(true) directly here since that
|
2005-04-03 23:58:40 +04:00
|
|
|
// could cause recursive frame construction. See bug 283117 and the comment in
|
|
|
|
// HandleRedisplayTextEvent() below.
|
2005-04-04 02:16:07 +04:00
|
|
|
|
2006-05-10 21:30:15 +04:00
|
|
|
// Revoke outstanding events to avoid out-of-order events which could mean
|
|
|
|
// displaying the wrong text.
|
|
|
|
mRedisplayTextEvent.Revoke();
|
2005-04-04 02:16:07 +04:00
|
|
|
|
2009-02-18 06:27:25 +03:00
|
|
|
NS_ASSERTION(!nsContentUtils::IsSafeToRunScript(),
|
|
|
|
"If we happen to run our redisplay event now, we might kill "
|
|
|
|
"ourselves!");
|
|
|
|
|
2006-05-10 21:30:15 +04:00
|
|
|
nsRefPtr<RedisplayTextEvent> event = new RedisplayTextEvent(this);
|
2009-02-18 06:27:25 +03:00
|
|
|
mRedisplayTextEvent = event;
|
|
|
|
if (!nsContentUtils::AddScriptRunner(event))
|
|
|
|
mRedisplayTextEvent.Forget();
|
1999-08-26 18:54:07 +04:00
|
|
|
}
|
1999-10-06 03:43:06 +04:00
|
|
|
return rv;
|
1999-08-26 18:54:07 +04:00
|
|
|
}
|
|
|
|
|
2005-03-21 04:58:17 +03:00
|
|
|
void
|
2005-06-21 04:00:14 +04:00
|
|
|
nsComboboxControlFrame::HandleRedisplayTextEvent()
|
2005-03-21 04:58:17 +03:00
|
|
|
{
|
2005-04-12 19:31:03 +04:00
|
|
|
// First, make sure that the content model is up to date and we've
|
|
|
|
// constructed the frames for all our content in the right places.
|
|
|
|
// Otherwise they'll end up under the wrong insertion frame when we
|
|
|
|
// ActuallyDisplayText, since that flushes out the content sink by
|
|
|
|
// calling SetText on a DOM node with aNotify set to true. See bug
|
|
|
|
// 289730.
|
2009-10-16 06:49:57 +04:00
|
|
|
nsWeakFrame weakThis(this);
|
2007-03-31 01:11:41 +04:00
|
|
|
PresContext()->Document()->
|
2005-04-12 19:31:03 +04:00
|
|
|
FlushPendingNotifications(Flush_ContentAndNotify);
|
2009-10-16 06:49:57 +04:00
|
|
|
if (!weakThis.IsAlive())
|
|
|
|
return;
|
|
|
|
|
2005-03-21 04:58:17 +03:00
|
|
|
// Redirect frame insertions during this method (see GetContentInsertionFrame())
|
|
|
|
// so that any reframing that the frame constructor forces upon us is inserted
|
|
|
|
// into the correct parent (mDisplayFrame). See bug 282607.
|
|
|
|
NS_PRECONDITION(!mInRedisplayText, "Nested RedisplayText");
|
2011-10-17 18:59:28 +04:00
|
|
|
mInRedisplayText = true;
|
2006-05-10 21:30:15 +04:00
|
|
|
mRedisplayTextEvent.Forget();
|
2005-03-21 04:58:17 +03:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
ActuallyDisplayText(true);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
// XXXbz This should perhaps be eResize. Check.
|
2007-03-31 01:11:41 +04:00
|
|
|
PresContext()->PresShell()->FrameNeedsReflow(mDisplayFrame,
|
2007-05-06 23:16:51 +04:00
|
|
|
nsIPresShell::eStyleChange,
|
|
|
|
NS_FRAME_IS_DIRTY);
|
2005-03-21 04:58:17 +03:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
mInRedisplayText = false;
|
2005-03-21 04:58:17 +03:00
|
|
|
}
|
|
|
|
|
2005-06-21 04:00:14 +04:00
|
|
|
void
|
2011-09-29 10:19:26 +04:00
|
|
|
nsComboboxControlFrame::ActuallyDisplayText(bool aNotify)
|
2002-01-26 02:35:44 +03:00
|
|
|
{
|
2005-06-21 04:00:14 +04:00
|
|
|
if (mDisplayedOptionText.IsEmpty()) {
|
2002-11-12 22:17:51 +03:00
|
|
|
// Have to use a non-breaking space for line-height calculations
|
|
|
|
// to be right
|
2004-05-13 05:12:10 +04:00
|
|
|
static const PRUnichar space = 0xA0;
|
|
|
|
mDisplayContent->SetText(&space, 1, aNotify);
|
2002-01-26 02:35:44 +03:00
|
|
|
} else {
|
2005-06-21 04:00:14 +04:00
|
|
|
mDisplayContent->SetText(mDisplayedOptionText, aNotify);
|
2002-01-26 02:35:44 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-18 04:52:03 +03:00
|
|
|
PRInt32
|
|
|
|
nsComboboxControlFrame::GetIndexOfDisplayArea()
|
2000-12-21 02:25:40 +03:00
|
|
|
{
|
2006-02-18 04:52:03 +03:00
|
|
|
return mDisplayedIndex;
|
2000-12-21 02:25:40 +03:00
|
|
|
}
|
1999-08-26 18:54:07 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISelectControlFrame
|
|
|
|
//----------------------------------------------------------------------
|
1999-11-12 01:13:33 +03:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsComboboxControlFrame::DoneAddingChildren(bool aIsDone)
|
1999-11-12 01:13:33 +03:00
|
|
|
{
|
2009-01-12 22:20:59 +03:00
|
|
|
nsISelectControlFrame* listFrame = do_QueryFrame(mDropdownFrame);
|
|
|
|
if (!listFrame)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
return listFrame->DoneAddingChildren(aIsDone);
|
1999-11-12 01:13:33 +03:00
|
|
|
}
|
1999-08-26 18:54:07 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2009-02-18 06:27:25 +03:00
|
|
|
nsComboboxControlFrame::AddOption(PRInt32 aIndex)
|
1999-08-26 18:54:07 +04:00
|
|
|
{
|
2005-06-21 03:26:35 +04:00
|
|
|
if (aIndex <= mDisplayedIndex) {
|
|
|
|
++mDisplayedIndex;
|
|
|
|
}
|
|
|
|
|
2007-07-08 11:08:04 +04:00
|
|
|
nsListControlFrame* lcf = static_cast<nsListControlFrame*>(mDropdownFrame);
|
2009-02-18 06:27:25 +03:00
|
|
|
return lcf->AddOption(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
|
2009-02-18 06:27:25 +03:00
|
|
|
nsComboboxControlFrame::RemoveOption(PRInt32 aIndex)
|
1999-08-26 18:54:07 +04:00
|
|
|
{
|
2009-10-16 06:49:57 +04:00
|
|
|
nsWeakFrame weakThis(this);
|
2006-03-01 04:00:29 +03:00
|
|
|
if (mListControlFrame->GetNumberOfOptions() > 0) {
|
2005-06-21 03:26:35 +04:00
|
|
|
if (aIndex < mDisplayedIndex) {
|
|
|
|
--mDisplayedIndex;
|
|
|
|
} else if (aIndex == mDisplayedIndex) {
|
|
|
|
mDisplayedIndex = 0; // IE6 compat
|
|
|
|
RedisplayText(mDisplayedIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// If we removed the last option, we need to blank things out
|
2002-07-18 04:58:31 +04:00
|
|
|
RedisplayText(-1);
|
1999-08-27 07:58:13 +04:00
|
|
|
}
|
2002-07-18 04:58:31 +04:00
|
|
|
|
2009-10-16 06:49:57 +04:00
|
|
|
if (!weakThis.IsAlive())
|
|
|
|
return NS_OK;
|
|
|
|
|
2007-07-08 11:08:04 +04:00
|
|
|
nsListControlFrame* lcf = static_cast<nsListControlFrame*>(mDropdownFrame);
|
2009-02-18 06:27:25 +03:00
|
|
|
return lcf->RemoveOption(aIndex);
|
1999-08-27 07:58:13 +04:00
|
|
|
}
|
|
|
|
|
2005-02-05 01:56:13 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsComboboxControlFrame::OnSetSelectedIndex(PRInt32 aOldIndex, PRInt32 aNewIndex)
|
|
|
|
{
|
2009-02-18 06:27:25 +03:00
|
|
|
nsAutoScriptBlocker scriptBlocker;
|
2007-08-22 07:25:42 +04:00
|
|
|
RedisplayText(aNewIndex);
|
2009-01-09 19:35:24 +03:00
|
|
|
NS_ASSERTION(mDropdownFrame, "No dropdown frame!");
|
2009-01-12 22:20:59 +03:00
|
|
|
|
|
|
|
nsISelectControlFrame* listFrame = do_QueryFrame(mDropdownFrame);
|
2005-02-05 01:56:13 +03:00
|
|
|
NS_ASSERTION(listFrame, "No list frame!");
|
|
|
|
|
|
|
|
return listFrame->OnSetSelectedIndex(aOldIndex, aNewIndex);
|
2000-04-29 03:24:59 +04:00
|
|
|
}
|
|
|
|
|
2001-11-02 10:40:01 +03:00
|
|
|
// End nsISelectControlFrame
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
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;
|
|
|
|
}
|
2010-09-19 05:43:15 +04:00
|
|
|
|
2011-06-01 05:46:57 +04:00
|
|
|
nsEventStates eventStates = mContent->AsElement()->State();
|
2010-10-20 15:26:32 +04:00
|
|
|
if (eventStates.HasState(NS_EVENT_STATE_DISABLED)) {
|
1999-08-10 23:25:22 +04:00
|
|
|
return NS_OK;
|
1999-07-29 01:38:08 +04:00
|
|
|
}
|
|
|
|
|
2000-09-07 08:39:02 +04:00
|
|
|
// If we have style that affects how we are selected, feed event down to
|
|
|
|
// nsFrame::HandleEvent so that selection takes place when appropriate.
|
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)
|
2008-12-29 18:07:38 +03:00
|
|
|
return nsBlockFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
2000-09-07 08:39:02 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
1999-07-29 01:38:08 +04:00
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
|
2005-12-13 02:53:06 +03:00
|
|
|
nsresult
|
|
|
|
nsComboboxControlFrame::SetFormProperty(nsIAtom* aName, const nsAString& aValue)
|
1999-01-26 01:16:27 +03:00
|
|
|
{
|
2009-01-12 22:20:59 +03:00
|
|
|
nsIFormControlFrame* fcFrame = do_QueryFrame(mDropdownFrame);
|
|
|
|
if (!fcFrame) {
|
|
|
|
return NS_NOINTERFACE;
|
1999-04-13 02:14:31 +04:00
|
|
|
}
|
2009-01-12 22:20:59 +03:00
|
|
|
|
|
|
|
return fcFrame->SetFormProperty(aName, aValue);
|
1999-01-26 01:16:27 +03:00
|
|
|
}
|
|
|
|
|
2005-12-13 02:53:06 +03:00
|
|
|
nsresult
|
|
|
|
nsComboboxControlFrame::GetFormProperty(nsIAtom* aName, nsAString& aValue) const
|
1999-03-06 22:43:13 +03:00
|
|
|
{
|
2009-01-12 22:20:59 +03:00
|
|
|
nsIFormControlFrame* fcFrame = do_QueryFrame(mDropdownFrame);
|
|
|
|
if (!fcFrame) {
|
|
|
|
return NS_ERROR_FAILURE;
|
2009-01-09 19:35:24 +03:00
|
|
|
}
|
2009-01-12 22:20:59 +03:00
|
|
|
|
|
|
|
return fcFrame->GetFormProperty(aName, aValue);
|
1999-03-06 22:43:13 +03:00
|
|
|
}
|
|
|
|
|
2004-07-18 16:02:53 +04:00
|
|
|
nsIFrame*
|
|
|
|
nsComboboxControlFrame::GetContentInsertionFrame() {
|
2005-02-20 02:54:36 +03:00
|
|
|
return mInRedisplayText ? mDisplayFrame : mDropdownFrame->GetContentInsertionFrame();
|
2004-07-18 16:02:53 +04:00
|
|
|
}
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
nsresult
|
2011-05-07 00:04:44 +04:00
|
|
|
nsComboboxControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
{
|
|
|
|
// The frames used to display the combo box and the button used to popup the dropdown list
|
|
|
|
// are created through anonymous content. The dropdown list is not created through anonymous
|
|
|
|
// content because it's frame is initialized specifically for the drop-down case and it is placed
|
|
|
|
// a special list referenced through NS_COMBO_FRAME_POPUP_LIST_INDEX to keep separate from the
|
|
|
|
// layout of the display and button.
|
|
|
|
//
|
|
|
|
// Note: The value attribute of the display content is set when an item is selected in the dropdown list.
|
|
|
|
// If the content specified below does not honor the value attribute than nothing will be displayed.
|
|
|
|
|
|
|
|
// For now the content that is created corresponds to two input buttons. It would be better to create the
|
|
|
|
// tag as something other than input, but then there isn't any way to create a button frame since it
|
|
|
|
// isn't possible to set the display type in CSS2 to create a button frame.
|
|
|
|
|
|
|
|
// create content used for display
|
1999-08-06 18:13:20 +04:00
|
|
|
//nsIAtom* tag = NS_NewAtom("mozcombodisplay");
|
2000-02-15 18:04:38 +03:00
|
|
|
|
2000-03-07 18:54:31 +03:00
|
|
|
// Add a child text content node for the label
|
2004-08-10 14:22:36 +04:00
|
|
|
|
2005-09-24 22:43:15 +04:00
|
|
|
nsNodeInfoManager *nimgr = mContent->NodeInfo()->NodeInfoManager();
|
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
NS_NewTextNode(getter_AddRefs(mDisplayContent), nimgr);
|
|
|
|
if (!mDisplayContent)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2004-08-10 14:22:36 +04:00
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
// set the value of the text node
|
|
|
|
mDisplayedIndex = mListControlFrame->GetSelectedIndex();
|
|
|
|
if (mDisplayedIndex != -1) {
|
|
|
|
mListControlFrame->GetOptionText(mDisplayedIndex, mDisplayedOptionText);
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
ActuallyDisplayText(false);
|
2000-03-07 18:54:31 +03:00
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
if (!aElements.AppendElement(mDisplayContent))
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2000-05-10 17:13:39 +04:00
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
nsCOMPtr<nsINodeInfo> nodeInfo;
|
2011-06-14 11:56:49 +04:00
|
|
|
nodeInfo = nimgr->GetNodeInfo(nsGkAtoms::button, nsnull, kNameSpaceID_XHTML,
|
|
|
|
nsIDOMNode::ELEMENT_NODE);
|
2000-03-07 18:54:31 +03:00
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
// create button which drops the list down
|
2010-07-23 13:49:57 +04:00
|
|
|
NS_NewHTMLElement(getter_AddRefs(mButtonContent), nodeInfo.forget(),
|
2010-10-25 16:17:38 +04:00
|
|
|
dom::NOT_FROM_PARSER);
|
2007-02-18 20:34:09 +03:00
|
|
|
if (!mButtonContent)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2004-06-25 16:26:02 +04:00
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
// make someone to listen to the button. If its pressed by someone like Accessibility
|
|
|
|
// then open or close the combo box.
|
2007-05-14 13:11:38 +04:00
|
|
|
mButtonListener = new nsComboButtonListener(this);
|
2011-06-29 22:07:25 +04:00
|
|
|
mButtonContent->AddEventListener(NS_LITERAL_STRING("click"), mButtonListener,
|
2011-10-17 18:59:28 +04:00
|
|
|
false, false);
|
2004-06-25 16:26:02 +04:00
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
mButtonContent->SetAttr(kNameSpaceID_None, nsGkAtoms::type,
|
2011-10-17 18:59:28 +04:00
|
|
|
NS_LITERAL_STRING("button"), false);
|
2007-02-18 20:34:09 +03:00
|
|
|
// Set tabindex="-1" so that the button is not tabbable
|
|
|
|
mButtonContent->SetAttr(kNameSpaceID_None, nsGkAtoms::tabindex,
|
2011-10-17 18:59:28 +04:00
|
|
|
NS_LITERAL_STRING("-1"), false);
|
2004-06-25 16:26:02 +04:00
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
if (!aElements.AppendElement(mButtonContent))
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-02-11 20:34:01 +03:00
|
|
|
void
|
2010-10-15 19:34:35 +04:00
|
|
|
nsComboboxControlFrame::AppendAnonymousContentTo(nsBaseContentList& aElements,
|
|
|
|
PRUint32 aFilter)
|
2010-02-11 20:34:01 +03:00
|
|
|
{
|
|
|
|
aElements.MaybeAppendElement(mDisplayContent);
|
|
|
|
aElements.MaybeAppendElement(mButtonContent);
|
|
|
|
}
|
|
|
|
|
2007-02-19 02:53:25 +03:00
|
|
|
// XXXbz this is a for-now hack. Now that display:inline-block works,
|
|
|
|
// need to revisit this.
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
class nsComboboxDisplayFrame : public nsBlockFrame {
|
|
|
|
public:
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nsComboboxDisplayFrame (nsStyleContext* aContext,
|
|
|
|
nsComboboxControlFrame* aComboBox)
|
|
|
|
: nsBlockFrame(aContext),
|
|
|
|
mComboBox(aComboBox)
|
|
|
|
{}
|
|
|
|
|
2007-02-28 06:04:38 +03:00
|
|
|
// Need this so that line layout knows that this block's width
|
|
|
|
// depends on the available width.
|
|
|
|
virtual nsIAtom* GetType() const;
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
virtual bool IsFrameOfType(PRUint32 aFlags) const
|
2007-02-24 21:33:33 +03:00
|
|
|
{
|
|
|
|
return nsBlockFrame::IsFrameOfType(aFlags &
|
|
|
|
~(nsIFrame::eReplacedContainsBlock));
|
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
|
|
|
NS_IMETHOD Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
|
|
|
|
2007-05-22 23:42:01 +04:00
|
|
|
NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists);
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
protected:
|
|
|
|
nsComboboxControlFrame* mComboBox;
|
|
|
|
};
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsComboboxDisplayFrame)
|
|
|
|
|
2007-02-28 06:04:38 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsComboboxDisplayFrame::GetType() const
|
|
|
|
{
|
|
|
|
return nsGkAtoms::comboboxDisplayFrame;
|
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsComboboxDisplayFrame::Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
nsHTMLReflowState state(aReflowState);
|
2007-08-02 22:08:05 +04:00
|
|
|
if (state.ComputedHeight() == NS_INTRINSICSIZE) {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
// Note that the only way we can have a computed height here is if the
|
|
|
|
// combobox had a specified height. If it didn't, size based on what our
|
|
|
|
// rows look like, for lack of anything better.
|
2007-08-02 22:08:05 +04:00
|
|
|
state.SetComputedHeight(mComboBox->mListControlFrame->GetHeightOfARow());
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
}
|
2007-01-26 03:05:12 +03:00
|
|
|
nscoord computedWidth = mComboBox->mDisplayWidth -
|
|
|
|
state.mComputedBorderPadding.LeftRight();
|
|
|
|
if (computedWidth < 0) {
|
|
|
|
computedWidth = 0;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
}
|
2007-01-26 03:05:12 +03:00
|
|
|
state.SetComputedWidth(computedWidth);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
|
|
|
return nsBlockFrame::Reflow(aPresContext, aDesiredSize, state, aStatus);
|
|
|
|
}
|
|
|
|
|
2007-05-22 23:42:01 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsComboboxDisplayFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
|
|
|
nsDisplayListCollection set;
|
|
|
|
nsresult rv = nsBlockFrame::BuildDisplayList(aBuilder, aDirtyRect, set);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
// remove background items if parent frame is themed
|
|
|
|
if (mComboBox->IsThemed()) {
|
|
|
|
set.BorderBackground()->DeleteAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
set.MoveTo(aLists);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
nsIFrame*
|
|
|
|
nsComboboxControlFrame::CreateFrameFor(nsIContent* aContent)
|
2000-04-19 17:55:17 +04:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aContent, "null ptr");
|
|
|
|
|
2005-12-11 23:45:58 +03:00
|
|
|
NS_ASSERTION(mDisplayContent, "mDisplayContent can't be null!");
|
2000-04-19 17:55:17 +04:00
|
|
|
|
2006-07-19 12:55:36 +04:00
|
|
|
if (mDisplayContent != aContent) {
|
2005-12-11 23:45:58 +03:00
|
|
|
// We only handle the frames for mDisplayContent here
|
2007-02-18 20:34:09 +03:00
|
|
|
return nsnull;
|
2000-04-19 17:55:17 +04:00
|
|
|
}
|
2005-12-11 23:45:58 +03:00
|
|
|
|
|
|
|
// Get PresShell
|
2007-03-31 01:11:41 +04:00
|
|
|
nsIPresShell *shell = PresContext()->PresShell();
|
2005-12-11 23:45:58 +03:00
|
|
|
nsStyleSet *styleSet = shell->StyleSet();
|
2000-04-19 17:55:17 +04:00
|
|
|
|
2005-12-11 23:45:58 +03:00
|
|
|
// create the style contexts for the anonymous block frame and text frame
|
|
|
|
nsRefPtr<nsStyleContext> styleContext;
|
|
|
|
styleContext = styleSet->
|
2009-12-11 10:37:40 +03:00
|
|
|
ResolveAnonymousBoxStyle(nsCSSAnonBoxes::mozDisplayComboboxControlFrame,
|
|
|
|
mStyleContext);
|
2005-12-11 23:45:58 +03:00
|
|
|
if (NS_UNLIKELY(!styleContext)) {
|
2007-02-18 20:34:09 +03:00
|
|
|
return nsnull;
|
2005-12-11 23:45:58 +03:00
|
|
|
}
|
2005-11-04 05:38:33 +03:00
|
|
|
|
2005-12-11 23:45:58 +03:00
|
|
|
nsRefPtr<nsStyleContext> textStyleContext;
|
2007-06-16 09:11:20 +04:00
|
|
|
textStyleContext = styleSet->ResolveStyleForNonElement(mStyleContext);
|
2005-12-11 23:45:58 +03:00
|
|
|
if (NS_UNLIKELY(!textStyleContext)) {
|
2007-02-18 20:34:09 +03:00
|
|
|
return nsnull;
|
2005-12-11 23:45:58 +03:00
|
|
|
}
|
2000-04-19 17:55:17 +04:00
|
|
|
|
2005-12-11 23:45:58 +03:00
|
|
|
// Start by by creating our anonymous block frame
|
2007-02-19 02:53:25 +03:00
|
|
|
mDisplayFrame = new (shell) nsComboboxDisplayFrame(styleContext, this);
|
2005-12-11 23:45:58 +03:00
|
|
|
if (NS_UNLIKELY(!mDisplayFrame)) {
|
2007-02-18 20:34:09 +03:00
|
|
|
return nsnull;
|
2005-12-11 23:45:58 +03:00
|
|
|
}
|
2000-04-19 17:55:17 +04:00
|
|
|
|
2006-03-27 01:30:36 +04:00
|
|
|
nsresult rv = mDisplayFrame->Init(mContent, this, nsnull);
|
2005-12-11 23:45:58 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
2006-04-10 04:16:29 +04:00
|
|
|
mDisplayFrame->Destroy();
|
2005-12-11 23:45:58 +03:00
|
|
|
mDisplayFrame = nsnull;
|
2007-02-18 20:34:09 +03:00
|
|
|
return nsnull;
|
2005-12-11 23:45:58 +03:00
|
|
|
}
|
2000-04-19 17:55:17 +04:00
|
|
|
|
2005-12-11 23:45:58 +03:00
|
|
|
// Create a text frame and put it inside the block frame
|
2010-05-13 04:56:11 +04:00
|
|
|
nsIFrame* textFrame = NS_NewTextFrame(shell, textStyleContext);
|
|
|
|
if (NS_UNLIKELY(!textFrame)) {
|
2007-02-18 20:34:09 +03:00
|
|
|
return nsnull;
|
2005-12-11 23:45:58 +03:00
|
|
|
}
|
2000-04-19 17:55:17 +04:00
|
|
|
|
2005-12-11 23:45:58 +03:00
|
|
|
// initialize the text frame
|
2010-05-13 04:56:11 +04:00
|
|
|
rv = textFrame->Init(aContent, mDisplayFrame, nsnull);
|
2005-12-11 23:45:58 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
2006-04-10 04:16:29 +04:00
|
|
|
mDisplayFrame->Destroy();
|
2005-12-11 23:45:58 +03:00
|
|
|
mDisplayFrame = nsnull;
|
2010-05-13 04:56:11 +04:00
|
|
|
textFrame->Destroy();
|
|
|
|
textFrame = nsnull;
|
2007-02-18 20:34:09 +03:00
|
|
|
return nsnull;
|
2000-04-19 17:55:17 +04:00
|
|
|
}
|
2010-05-13 04:56:11 +04:00
|
|
|
mDisplayContent->SetPrimaryFrame(textFrame);
|
2000-04-19 17:55:17 +04:00
|
|
|
|
2010-05-13 04:56:11 +04:00
|
|
|
nsFrameList textList(textFrame, textFrame);
|
2011-08-25 00:54:30 +04:00
|
|
|
mDisplayFrame->SetInitialChildList(kPrincipalList, textList);
|
2007-02-18 20:34:09 +03:00
|
|
|
return mDisplayFrame;
|
2000-04-19 17:55:17 +04:00
|
|
|
}
|
|
|
|
|
2006-04-10 04:16:29 +04:00
|
|
|
void
|
2009-12-24 08:21:15 +03:00
|
|
|
nsComboboxControlFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
{
|
2006-05-10 21:30:15 +04:00
|
|
|
// Revoke any pending RedisplayTextEvent
|
|
|
|
mRedisplayTextEvent.Revoke();
|
2005-03-21 04:58:17 +03:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
nsFormControlFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), false);
|
2000-08-03 18:13:40 +04:00
|
|
|
|
2000-03-28 18:29:15 +04:00
|
|
|
if (mDroppedDown) {
|
|
|
|
// Get parent view
|
2009-01-12 22:20:59 +03:00
|
|
|
nsIFrame * listFrame = do_QueryFrame(mListControlFrame);
|
|
|
|
if (listFrame) {
|
2003-07-04 16:50:32 +04:00
|
|
|
nsIView* view = listFrame->GetView();
|
|
|
|
NS_ASSERTION(view, "nsComboboxControlFrame view is null");
|
2000-03-28 18:29:15 +04:00
|
|
|
if (view) {
|
2007-02-18 20:34:09 +03:00
|
|
|
nsIWidget* widget = view->GetWidget();
|
2000-03-28 18:29:15 +04:00
|
|
|
if (widget)
|
2011-11-08 23:59:07 +04:00
|
|
|
widget->CaptureRollupEvents(this, false, true);
|
2000-03-28 18:29:15 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-21 00:28:02 +04:00
|
|
|
// Cleanup frames in popup child list
|
2009-12-24 08:21:15 +03:00
|
|
|
mPopupFrames.DestroyFramesFrom(aDestructRoot);
|
2007-02-18 20:34:09 +03:00
|
|
|
nsContentUtils::DestroyAnonymousContent(&mDisplayContent);
|
|
|
|
nsContentUtils::DestroyAnonymousContent(&mButtonContent);
|
2009-12-24 08:21:15 +03:00
|
|
|
nsBlockFrame::DestroyFrom(aDestructRoot);
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
}
|
|
|
|
|
2012-03-08 05:57:37 +04:00
|
|
|
const nsFrameList&
|
2011-08-25 00:54:29 +04:00
|
|
|
nsComboboxControlFrame::GetChildList(ChildListID aListID) const
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
{
|
2011-08-25 00:54:29 +04:00
|
|
|
if (kSelectPopupList == aListID) {
|
2009-07-28 16:51:09 +04:00
|
|
|
return mPopupFrames;
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
}
|
2011-08-25 00:54:29 +04:00
|
|
|
return nsBlockFrame::GetChildList(aListID);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsComboboxControlFrame::GetChildLists(nsTArray<ChildList>* aLists) const
|
|
|
|
{
|
|
|
|
nsBlockFrame::GetChildLists(aLists);
|
|
|
|
mPopupFrames.AppendIfNonempty(aLists, kSelectPopupList);
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-08-25 00:54:30 +04:00
|
|
|
nsComboboxControlFrame::SetInitialChildList(ChildListID aListID,
|
2009-07-28 16:53:20 +04:00
|
|
|
nsFrameList& aChildList)
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
2011-08-25 00:54:30 +04:00
|
|
|
if (kSelectPopupList == aListID) {
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
mPopupFrames.SetFrames(aChildList);
|
|
|
|
} else {
|
2009-07-28 16:53:20 +04:00
|
|
|
for (nsFrameList::Enumerator e(aChildList); !e.AtEnd(); e.Next()) {
|
|
|
|
nsCOMPtr<nsIFormControl> formControl =
|
|
|
|
do_QueryInterface(e.get()->GetContent());
|
2011-03-26 04:05:56 +03:00
|
|
|
if (formControl && formControl->GetType() == NS_FORM_BUTTON_BUTTON) {
|
2009-07-28 16:53:20 +04:00
|
|
|
mButtonFrame = e.get();
|
2005-12-08 22:01:20 +03:00
|
|
|
break;
|
2000-04-19 17:55:17 +04:00
|
|
|
}
|
|
|
|
}
|
2005-12-08 22:01:20 +03:00
|
|
|
NS_ASSERTION(mButtonFrame, "missing button frame in initial child list");
|
2011-08-25 00:54:30 +04:00
|
|
|
rv = nsBlockFrame::SetInitialChildList(aListID, aChildList);
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-09-22 01:20:50 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
//nsIRollupListener
|
|
|
|
//----------------------------------------------------------------------
|
2011-11-08 23:59:07 +04:00
|
|
|
nsIContent*
|
|
|
|
nsComboboxControlFrame::Rollup(PRUint32 aCount, bool aGetLastRolledUp)
|
1999-09-22 01:20:50 +04:00
|
|
|
{
|
|
|
|
if (mDroppedDown) {
|
2007-05-17 15:12:30 +04:00
|
|
|
nsWeakFrame weakFrame(this);
|
|
|
|
mListControlFrame->AboutToRollup(); // might destroy us
|
|
|
|
if (!weakFrame.IsAlive())
|
2011-11-08 23:59:07 +04:00
|
|
|
return nsnull;
|
2011-10-17 18:59:28 +04:00
|
|
|
ShowDropDown(false); // might destroy us
|
2007-05-17 15:12:30 +04:00
|
|
|
if (!weakFrame.IsAlive())
|
2011-11-08 23:59:07 +04:00
|
|
|
return nsnull;
|
2011-10-17 18:59:28 +04:00
|
|
|
mListControlFrame->CaptureMouseEvents(false);
|
1999-09-22 01:20:50 +04:00
|
|
|
}
|
2011-11-08 23:59:07 +04:00
|
|
|
|
|
|
|
return nsnull;
|
1999-09-22 01:20:50 +04:00
|
|
|
}
|
|
|
|
|
2006-02-18 04:52:03 +03:00
|
|
|
void
|
|
|
|
nsComboboxControlFrame::RollupFromList()
|
2002-01-26 02:35:44 +03:00
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
if (ShowList(false))
|
|
|
|
mListControlFrame->CaptureMouseEvents(false);
|
2002-01-26 02:35:44 +03:00
|
|
|
}
|
|
|
|
|
2006-02-18 04:52:03 +03:00
|
|
|
PRInt32
|
2004-07-23 12:25:44 +04:00
|
|
|
nsComboboxControlFrame::UpdateRecentIndex(PRInt32 aIndex)
|
2002-02-08 21:35:48 +03:00
|
|
|
{
|
2004-07-23 12:25:44 +04:00
|
|
|
PRInt32 index = mRecentSelectedIndex;
|
2006-09-30 09:07:49 +04:00
|
|
|
if (mRecentSelectedIndex == NS_SKIP_NOTIFY_INDEX || aIndex == NS_SKIP_NOTIFY_INDEX)
|
2004-07-23 12:25:44 +04:00
|
|
|
mRecentSelectedIndex = aIndex;
|
|
|
|
return index;
|
2002-02-08 21:35:48 +03:00
|
|
|
}
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
class nsDisplayComboboxFocus : public nsDisplayItem {
|
|
|
|
public:
|
2010-08-13 14:01:13 +04:00
|
|
|
nsDisplayComboboxFocus(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsComboboxControlFrame* aFrame)
|
|
|
|
: nsDisplayItem(aBuilder, aFrame) {
|
2006-01-29 21:48:58 +03:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayComboboxFocus);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayComboboxFocus() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayComboboxFocus);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-07 04:35:14 +04:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
2011-04-08 05:04:40 +04:00
|
|
|
nsRenderingContext* aCtx);
|
2010-07-16 01:07:49 +04:00
|
|
|
NS_DISPLAY_DECL_NAME("ComboboxFocus", TYPE_COMBOBOX_FOCUS)
|
2006-01-26 05:29:17 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
void nsDisplayComboboxFocus::Paint(nsDisplayListBuilder* aBuilder,
|
2011-04-08 05:04:40 +04:00
|
|
|
nsRenderingContext* aCtx)
|
2006-01-26 05:29:17 +03:00
|
|
|
{
|
2007-07-08 11:08:04 +04:00
|
|
|
static_cast<nsComboboxControlFrame*>(mFrame)
|
2010-08-13 14:01:58 +04:00
|
|
|
->PaintFocus(*aCtx, ToReferenceFrame());
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsComboboxControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
2000-03-07 18:54:31 +03:00
|
|
|
{
|
|
|
|
#ifdef NOISY
|
2006-01-26 05:29:17 +03:00
|
|
|
printf("%p paint at (%d, %d, %d, %d)\n", this,
|
2000-10-29 02:17:53 +04:00
|
|
|
aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height);
|
2000-03-07 18:54:31 +03:00
|
|
|
#endif
|
2006-01-26 05:29:17 +03:00
|
|
|
|
|
|
|
if (aBuilder->IsForEventDelivery()) {
|
|
|
|
// Don't allow children to receive events.
|
|
|
|
// REVIEW: following old GetFrameForPoint
|
|
|
|
nsresult rv = DisplayBorderBackgroundOutline(aBuilder, aLists);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
} else {
|
|
|
|
// REVIEW: Our in-flow child frames are inline-level so they will paint in our
|
|
|
|
// content list, so we don't need to mess with layers.
|
2008-12-29 18:07:38 +03:00
|
|
|
nsresult rv = nsBlockFrame::BuildDisplayList(aBuilder, aDirtyRect, aLists);
|
2006-01-26 05:29:17 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2000-03-07 18:54:31 +03:00
|
|
|
}
|
2006-01-26 05:29:17 +03:00
|
|
|
|
2010-04-21 18:53:42 +04:00
|
|
|
// draw a focus indicator only when focus rings should be drawn
|
|
|
|
nsIDocument* doc = mContent->GetCurrentDoc();
|
|
|
|
if (doc) {
|
|
|
|
nsPIDOMWindow* window = doc->GetWindow();
|
|
|
|
if (window && window->ShouldShowFocusRing()) {
|
|
|
|
nsPresContext *presContext = PresContext();
|
|
|
|
const nsStyleDisplay *disp = GetStyleDisplay();
|
|
|
|
if ((!IsThemed(disp) ||
|
|
|
|
!presContext->GetTheme()->ThemeDrawsFocusForWidget(presContext, this, disp->mAppearance)) &&
|
|
|
|
mDisplayFrame && IsVisibleForPainting(aBuilder)) {
|
2010-08-13 14:01:13 +04:00
|
|
|
nsresult rv = aLists.Content()->AppendNewToTop(
|
|
|
|
new (aBuilder) nsDisplayComboboxFocus(aBuilder, this));
|
2010-04-21 18:53:42 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
}
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
|
|
|
|
2010-09-09 19:21:46 +04:00
|
|
|
return DisplaySelectionOverlay(aBuilder, aLists.Content());
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
|
|
|
|
2011-04-08 05:04:40 +04:00
|
|
|
void nsComboboxControlFrame::PaintFocus(nsRenderingContext& aRenderingContext,
|
2008-04-29 07:55:07 +04:00
|
|
|
nsPoint aPt)
|
|
|
|
{
|
|
|
|
/* Do we need to do anything? */
|
2011-06-01 05:46:57 +04:00
|
|
|
nsEventStates eventStates = mContent->AsElement()->State();
|
2010-10-20 15:26:32 +04:00
|
|
|
if (eventStates.HasState(NS_EVENT_STATE_DISABLED) || mFocused != this)
|
2008-04-29 07:55:07 +04:00
|
|
|
return;
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
aRenderingContext.PushState();
|
|
|
|
nsRect clipRect = mDisplayFrame->GetRect() + aPt;
|
2011-04-08 05:04:40 +04:00
|
|
|
aRenderingContext.IntersectClip(clipRect);
|
2006-01-26 05:29:17 +03:00
|
|
|
|
|
|
|
// REVIEW: Why does the old code paint mDisplayFrame again? We've
|
|
|
|
// already painted it in the children above. So clipping it here won't do
|
|
|
|
// us much good.
|
|
|
|
|
|
|
|
/////////////////////
|
|
|
|
// draw focus
|
2008-04-29 07:55:07 +04:00
|
|
|
|
|
|
|
aRenderingContext.SetLineStyle(nsLineStyle_kDotted);
|
|
|
|
aRenderingContext.SetColor(GetStyleColor()->mColor);
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
//aRenderingContext.DrawRect(clipRect);
|
2008-04-29 07:55:07 +04:00
|
|
|
|
2007-02-07 10:46:44 +03:00
|
|
|
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
|
2006-01-26 05:29:17 +03:00
|
|
|
clipRect.width -= onePixel;
|
|
|
|
clipRect.height -= onePixel;
|
2011-04-08 05:04:39 +04:00
|
|
|
aRenderingContext.DrawLine(clipRect.TopLeft(), clipRect.TopRight());
|
|
|
|
aRenderingContext.DrawLine(clipRect.TopRight(), clipRect.BottomRight());
|
|
|
|
aRenderingContext.DrawLine(clipRect.BottomRight(), clipRect.BottomLeft());
|
|
|
|
aRenderingContext.DrawLine(clipRect.BottomLeft(), clipRect.TopLeft());
|
2006-01-26 05:29:17 +03:00
|
|
|
|
|
|
|
aRenderingContext.PopState();
|
2000-03-07 18:54:31 +03:00
|
|
|
}
|
|
|
|
|
2001-11-02 10:40:01 +03:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// gets the content (an option) by index and then set it as
|
|
|
|
// being selected or not selected
|
|
|
|
//---------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsComboboxControlFrame::OnOptionSelected(PRInt32 aIndex, bool aSelected)
|
2001-11-02 10:40:01 +03:00
|
|
|
{
|
2003-03-14 09:18:20 +03:00
|
|
|
if (mDroppedDown) {
|
2009-01-12 22:20:59 +03:00
|
|
|
nsISelectControlFrame *selectFrame = do_QueryFrame(mListControlFrame);
|
2003-03-14 09:18:20 +03:00
|
|
|
if (selectFrame) {
|
2009-02-18 06:27:25 +03:00
|
|
|
selectFrame->OnOptionSelected(aIndex, aSelected);
|
2003-03-14 09:18:20 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (aSelected) {
|
2009-02-18 06:27:25 +03:00
|
|
|
nsAutoScriptBlocker blocker;
|
2002-01-26 02:35:44 +03:00
|
|
|
RedisplayText(aIndex);
|
|
|
|
} else {
|
2009-02-18 06:27:25 +03:00
|
|
|
nsWeakFrame weakFrame(this);
|
2003-03-14 09:18:20 +03:00
|
|
|
RedisplaySelectedText();
|
2009-02-18 06:27:25 +03:00
|
|
|
if (weakFrame.IsAlive()) {
|
|
|
|
FireValueChangeEvent(); // Fire after old option is unselected
|
|
|
|
}
|
2002-01-26 02:35:44 +03:00
|
|
|
}
|
2001-11-02 10:40:01 +03:00
|
|
|
}
|
2003-03-14 09:18:20 +03:00
|
|
|
|
2001-11-02 10:40:01 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-02-08 02:11:30 +03:00
|
|
|
void nsComboboxControlFrame::FireValueChangeEvent()
|
|
|
|
{
|
|
|
|
// Fire ValueChange event to indicate data value of combo box has changed
|
2010-02-25 05:45:43 +03:00
|
|
|
nsContentUtils::AddScriptRunner(
|
2011-12-17 10:02:05 +04:00
|
|
|
new nsAsyncDOMEvent(mContent, NS_LITERAL_STRING("ValueChange"), true,
|
|
|
|
false));
|
2005-02-08 02:11:30 +03:00
|
|
|
}
|
|
|
|
|
2005-12-13 02:53:06 +03:00
|
|
|
void
|
2001-11-02 10:40:01 +03:00
|
|
|
nsComboboxControlFrame::OnContentReset()
|
|
|
|
{
|
|
|
|
if (mListControlFrame) {
|
2005-12-13 02:53:06 +03:00
|
|
|
mListControlFrame->OnContentReset();
|
2001-11-02 10:40:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------
|
|
|
|
// nsIStatefulFrame
|
|
|
|
//--------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
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;
|
|
|
|
|
2009-01-12 22:20:59 +03:00
|
|
|
nsIStatefulFrame* stateful = do_QueryFrame(mListControlFrame);
|
2005-12-07 02:56:17 +03:00
|
|
|
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;
|
|
|
|
|
2009-01-12 22:20:59 +03:00
|
|
|
nsIStatefulFrame* stateful = do_QueryFrame(mListControlFrame);
|
|
|
|
NS_ASSERTION(stateful, "Must implement nsIStatefulFrame");
|
|
|
|
return stateful->RestoreState(aState);
|
2001-11-02 10:40:01 +03:00
|
|
|
}
|
2005-02-16 08:13:16 +03:00
|
|
|
|
|
|
|
|
|
|
|
//
|
2006-01-11 22:09:20 +03:00
|
|
|
// Camino uses a native widget for the combobox
|
|
|
|
// popup, which affects drawing and event
|
2005-02-16 08:13:16 +03:00
|
|
|
// handling here and in nsListControlFrame.
|
2009-07-06 17:39:54 +04:00
|
|
|
//
|
|
|
|
// Also, Fennec use a custom combobox built-in widget
|
2005-02-16 08:13:16 +03:00
|
|
|
//
|
|
|
|
|
|
|
|
/* static */
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2005-02-16 08:13:16 +03:00
|
|
|
nsComboboxControlFrame::ToolkitHasNativePopup()
|
|
|
|
{
|
2011-06-22 01:00:47 +04:00
|
|
|
#ifdef MOZ_USE_NATIVE_POPUP_WINDOWS
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2011-06-22 01:00:47 +04:00
|
|
|
#else
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2011-06-22 01:00:47 +04:00
|
|
|
#endif /* MOZ_USE_NATIVE_POPUP_WINDOWS */
|
2005-02-16 08:13:16 +03:00
|
|
|
}
|
|
|
|
|