1999-01-18 15:14:00 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The contents of this file are subject to the Netscape 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/NPL/
|
1999-01-18 15:14:00 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
1999-01-18 15:14:00 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape Communications
|
1999-11-06 03:40:37 +00:00
|
|
|
* Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
2000-02-02 22:24:56 +00:00
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
1999-01-18 15:14:00 +00:00
|
|
|
*/
|
1999-02-12 17:45:58 +00:00
|
|
|
#include "nsCOMPtr.h"
|
1999-01-18 15:14:00 +00:00
|
|
|
#include "nsListControlFrame.h"
|
1999-10-07 21:39:50 +00:00
|
|
|
#include "nsFormControlFrame.h" // for COMPARE macro
|
1999-01-18 15:14:00 +00:00
|
|
|
#include "nsFormControlHelper.h"
|
|
|
|
#include "nsHTMLIIDs.h"
|
|
|
|
#include "nsHTMLAtoms.h"
|
|
|
|
#include "nsIHTMLContent.h"
|
|
|
|
#include "nsIFormControl.h"
|
|
|
|
#include "nsINameSpaceManager.h"
|
1999-03-22 21:32:12 +00:00
|
|
|
#include "nsIDeviceContext.h"
|
|
|
|
#include "nsIDOMHTMLCollection.h"
|
2000-02-24 00:08:00 +00:00
|
|
|
#include "nsIDOMNSHTMLOptionCollection.h"
|
1999-03-22 21:32:12 +00:00
|
|
|
#include "nsIDOMHTMLSelectElement.h"
|
|
|
|
#include "nsIDOMHTMLOptionElement.h"
|
1999-01-18 15:14:00 +00:00
|
|
|
#include "nsIComboboxControlFrame.h"
|
|
|
|
#include "nsIViewManager.h"
|
|
|
|
#include "nsFormFrame.h"
|
1999-03-22 21:32:12 +00:00
|
|
|
#include "nsIScrollableView.h"
|
1999-05-07 20:30:16 +00:00
|
|
|
#include "nsIDOMHTMLOptGroupElement.h"
|
1999-05-27 21:17:10 +00:00
|
|
|
#include "nsWidgetsCID.h"
|
|
|
|
#include "nsIReflowCommand.h"
|
1999-08-06 14:14:38 +00:00
|
|
|
#include "nsIPresShell.h"
|
1999-08-26 14:54:07 +00:00
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsIDOMEventReceiver.h"
|
|
|
|
#include "nsIEventStateManager.h"
|
1999-11-03 07:11:45 +00:00
|
|
|
#include "nsIDOMKeyEvent.h"
|
|
|
|
#include "nsIDOMMouseEvent.h"
|
1999-10-05 23:43:06 +00:00
|
|
|
#include "nsIPrivateDOMEvent.h"
|
1999-09-15 05:31:31 +00:00
|
|
|
#include "nsIStatefulFrame.h"
|
|
|
|
#include "nsISupportsArray.h"
|
|
|
|
#include "nsISupportsPrimitives.h"
|
|
|
|
#include "nsIComponentManager.h"
|
1999-10-07 21:39:50 +00:00
|
|
|
#include "nsILookAndFeel.h"
|
1999-12-06 22:59:43 +00:00
|
|
|
#include "nsLayoutAtoms.h"
|
1999-12-22 19:49:36 +00:00
|
|
|
#include "nsIFontMetrics.h"
|
2000-02-15 15:04:38 +00:00
|
|
|
#include "nsVoidArray.h"
|
2000-04-19 13:55:17 +00:00
|
|
|
#include "nsIScrollableFrame.h"
|
2000-05-16 11:35:12 +00:00
|
|
|
#include "nsIDOMEventTarget.h"
|
1999-08-26 14:54:07 +00:00
|
|
|
|
1999-11-11 22:13:33 +00:00
|
|
|
#include "nsISelectElement.h"
|
2000-05-26 23:31:25 +00:00
|
|
|
#include "nsIPrivateDOMEvent.h"
|
1999-11-11 22:13:33 +00:00
|
|
|
|
|
|
|
//static NS_DEFINE_IID(kBlockFrameCID, NS_BLOCK_FRAME_CID);
|
1999-05-07 20:30:16 +00:00
|
|
|
|
1999-01-18 15:14:00 +00:00
|
|
|
// Constants
|
1999-07-28 21:38:08 +00:00
|
|
|
const nscoord kMaxDropDownRows = 20; // This matches the setting for 4.x browsers
|
1999-07-20 22:32:41 +00:00
|
|
|
const PRInt32 kDefaultMultiselectHeight = 4; // This is compatible with 4.x browsers
|
1999-07-28 21:38:08 +00:00
|
|
|
const PRInt32 kNothingSelected = -1;
|
|
|
|
const PRInt32 kMaxZ = 0x7fffffff; //XXX: Shouldn't there be a define somewhere for MaxInt for PRInt32
|
|
|
|
const PRInt32 kNoSizeSpecified = -1;
|
1999-05-07 20:30:16 +00:00
|
|
|
|
1999-04-12 22:14:31 +00:00
|
|
|
//XXX: This is temporary. It simulates psuedo states by using a attribute selector on
|
|
|
|
// -moz-option-selected in the ua.css style sheet. This will not be needed when
|
|
|
|
//The event state manager is functional. KMM
|
1999-12-06 22:59:43 +00:00
|
|
|
//const char * kMozSelected = "-moz-option-selected";
|
|
|
|
// it is now using "nsLayoutAtoms::optionSelectedPseudo"
|
1999-03-02 22:43:26 +00:00
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 15:14:00 +00:00
|
|
|
nsresult
|
1999-12-04 23:49:50 +00:00
|
|
|
NS_NewListControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
1999-01-18 15:14:00 +00:00
|
|
|
{
|
1999-05-11 22:03:29 +00:00
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-12-04 23:49:50 +00:00
|
|
|
nsListControlFrame* it = new (aPresShell) nsListControlFrame;
|
1999-05-11 22:03:29 +00:00
|
|
|
if (!it) {
|
1999-01-18 15:14:00 +00:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2000-03-03 04:28:59 +00:00
|
|
|
#if 0
|
|
|
|
// set the state flags (if any are provided)
|
|
|
|
nsFrameState state;
|
|
|
|
it->GetFrameState( &state );
|
|
|
|
state |= NS_BLOCK_SPACE_MGR;
|
|
|
|
it->SetFrameState( state );
|
|
|
|
#endif
|
1999-05-11 22:03:29 +00:00
|
|
|
*aNewFrame = it;
|
1999-01-18 15:14:00 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-03-03 04:28:59 +00:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
// Reflow Debugging Macros
|
|
|
|
// These let us "see" how many reflow counts are happening
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
#ifdef DO_REFLOW_COUNTER
|
|
|
|
|
|
|
|
#define MAX_REFLOW_CNT 1024
|
|
|
|
static PRInt32 gTotalReqs = 0;;
|
|
|
|
static PRInt32 gTotalReflows = 0;;
|
|
|
|
static PRInt32 gReflowControlCntRQ[MAX_REFLOW_CNT];
|
|
|
|
static PRInt32 gReflowControlCnt[MAX_REFLOW_CNT];
|
|
|
|
static PRInt32 gReflowInx = -1;
|
|
|
|
|
|
|
|
#define REFLOW_COUNTER() \
|
|
|
|
if (mReflowId > -1) \
|
|
|
|
gReflowControlCnt[mReflowId]++;
|
|
|
|
|
|
|
|
#define REFLOW_COUNTER_REQUEST() \
|
|
|
|
if (mReflowId > -1) \
|
|
|
|
gReflowControlCntRQ[mReflowId]++;
|
|
|
|
|
|
|
|
#define REFLOW_COUNTER_DUMP(__desc) \
|
|
|
|
if (mReflowId > -1) {\
|
|
|
|
gTotalReqs += gReflowControlCntRQ[mReflowId];\
|
|
|
|
gTotalReflows += gReflowControlCnt[mReflowId];\
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("** Id:%5d %s RF: %d RQ: %d %d/%d %5.2f\n", \
|
2000-03-03 04:28:59 +00:00
|
|
|
mReflowId, (__desc), \
|
|
|
|
gReflowControlCnt[mReflowId], \
|
|
|
|
gReflowControlCntRQ[mReflowId],\
|
|
|
|
gTotalReflows, gTotalReqs, float(gTotalReflows)/float(gTotalReqs)*100.0f);\
|
|
|
|
}
|
|
|
|
|
|
|
|
#define REFLOW_COUNTER_INIT() \
|
|
|
|
if (gReflowInx < MAX_REFLOW_CNT) { \
|
|
|
|
gReflowInx++; \
|
|
|
|
mReflowId = gReflowInx; \
|
|
|
|
gReflowControlCnt[mReflowId] = 0; \
|
|
|
|
gReflowControlCntRQ[mReflowId] = 0; \
|
|
|
|
} else { \
|
|
|
|
mReflowId = -1; \
|
|
|
|
}
|
|
|
|
|
|
|
|
// reflow messages
|
2000-10-28 22:17:53 +00:00
|
|
|
#define REFLOW_DEBUG_MSG(_msg1) printf((_msg1))
|
|
|
|
#define REFLOW_DEBUG_MSG2(_msg1, _msg2) printf((_msg1), (_msg2))
|
|
|
|
#define REFLOW_DEBUG_MSG3(_msg1, _msg2, _msg3) printf((_msg1), (_msg2), (_msg3))
|
|
|
|
#define REFLOW_DEBUG_MSG4(_msg1, _msg2, _msg3, _msg4) printf((_msg1), (_msg2), (_msg3), (_msg4))
|
2000-03-03 04:28:59 +00:00
|
|
|
|
|
|
|
#else //-------------
|
|
|
|
|
|
|
|
#define REFLOW_COUNTER_REQUEST()
|
|
|
|
#define REFLOW_COUNTER()
|
|
|
|
#define REFLOW_COUNTER_DUMP(__desc)
|
|
|
|
#define REFLOW_COUNTER_INIT()
|
|
|
|
|
|
|
|
#define REFLOW_DEBUG_MSG(_msg)
|
|
|
|
#define REFLOW_DEBUG_MSG2(_msg1, _msg2)
|
|
|
|
#define REFLOW_DEBUG_MSG3(_msg1, _msg2, _msg3)
|
|
|
|
#define REFLOW_DEBUG_MSG4(_msg1, _msg2, _msg3, _msg4)
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//------------------------------------------
|
|
|
|
// This is for being VERY noisy
|
|
|
|
//------------------------------------------
|
|
|
|
#ifdef DO_VERY_NOISY
|
2000-10-28 22:17:53 +00:00
|
|
|
#define REFLOW_NOISY_MSG(_msg1) printf((_msg1))
|
|
|
|
#define REFLOW_NOISY_MSG2(_msg1, _msg2) printf((_msg1), (_msg2))
|
|
|
|
#define REFLOW_NOISY_MSG3(_msg1, _msg2, _msg3) printf((_msg1), (_msg2), (_msg3))
|
|
|
|
#define REFLOW_NOISY_MSG4(_msg1, _msg2, _msg3, _msg4) printf((_msg1), (_msg2), (_msg3), (_msg4))
|
2000-03-03 04:28:59 +00:00
|
|
|
#else
|
|
|
|
#define REFLOW_NOISY_MSG(_msg)
|
|
|
|
#define REFLOW_NOISY_MSG2(_msg1, _msg2)
|
|
|
|
#define REFLOW_NOISY_MSG3(_msg1, _msg2, _msg3)
|
|
|
|
#define REFLOW_NOISY_MSG4(_msg1, _msg2, _msg3, _msg4)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//------------------------------------------
|
|
|
|
// Displays value in pixels or twips
|
|
|
|
//------------------------------------------
|
|
|
|
#ifdef DO_PIXELS
|
|
|
|
#define PX(__v) __v / 15
|
|
|
|
#else
|
|
|
|
#define PX(__v) __v
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//------------------------------------------
|
|
|
|
// Asserts if we return a desired size that
|
|
|
|
// doesn't correctly match the mComputedWidth
|
|
|
|
//------------------------------------------
|
|
|
|
#ifdef DO_UNCONSTRAINED_CHECK
|
|
|
|
#define UNCONSTRAINED_CHECK() \
|
|
|
|
if (aReflowState.mComputedWidth != NS_UNCONSTRAINEDSIZE) { \
|
|
|
|
nscoord width = aDesiredSize.width - borderPadding.left - borderPadding.right; \
|
|
|
|
if (width != aReflowState.mComputedWidth) { \
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("aDesiredSize.width %d %d != aReflowState.mComputedWidth %d\n", aDesiredSize.width, width, aReflowState.mComputedWidth); \
|
2000-03-03 04:28:59 +00:00
|
|
|
} \
|
|
|
|
NS_ASSERTION(width == aReflowState.mComputedWidth, "Returning bad value when constrained!"); \
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define UNCONSTRAINED_CHECK()
|
|
|
|
#endif
|
|
|
|
//------------------------------------------------------
|
|
|
|
//-- Done with macros
|
|
|
|
//------------------------------------------------------
|
|
|
|
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 15:14:00 +00:00
|
|
|
nsListControlFrame::nsListControlFrame()
|
2000-08-14 14:42:12 +00:00
|
|
|
: mWeakReferent(this)
|
1999-01-18 15:14:00 +00:00
|
|
|
{
|
1999-08-26 14:54:07 +00:00
|
|
|
mSelectedIndex = kNothingSelected;
|
|
|
|
mComboboxFrame = nsnull;
|
|
|
|
mFormFrame = nsnull;
|
|
|
|
mButtonDown = PR_FALSE;
|
|
|
|
mMaxWidth = 0;
|
|
|
|
mMaxHeight = 0;
|
|
|
|
mPresContext = nsnull;
|
|
|
|
mEndExtendedIndex = kNothingSelected;
|
|
|
|
mStartExtendedIndex = kNothingSelected;
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
mIsCapturingMouseEvents = PR_FALSE;
|
2000-04-19 13:55:17 +00:00
|
|
|
mDelayedIndexSetting = kNothingSelected;
|
|
|
|
mDelayedValueSetting = PR_FALSE;
|
2000-02-15 15:04:38 +00:00
|
|
|
|
|
|
|
mSelectionCache = new nsVoidArray();
|
|
|
|
mSelectionCacheLength = 0;
|
1999-11-11 22:13:33 +00:00
|
|
|
|
|
|
|
mIsAllContentHere = PR_FALSE;
|
|
|
|
mIsAllFramesHere = PR_FALSE;
|
|
|
|
mHasBeenInitialized = PR_FALSE;
|
2001-03-09 03:21:51 +00:00
|
|
|
mDoneWithInitialReflow = PR_FALSE;
|
2000-01-09 01:41:11 +00:00
|
|
|
|
|
|
|
mCacheSize.width = -1;
|
|
|
|
mCacheSize.height = -1;
|
|
|
|
mCachedMaxElementSize.width = -1;
|
|
|
|
mCachedMaxElementSize.height = -1;
|
2000-03-03 04:28:59 +00:00
|
|
|
mCachedAvailableSize.width = -1;
|
|
|
|
mCachedAvailableSize.height = -1;
|
|
|
|
mCachedUnconstrainedSize.width = -1;
|
|
|
|
mCachedUnconstrainedSize.height = -1;
|
|
|
|
|
|
|
|
mOverrideReflowOpt = PR_FALSE;
|
2001-02-23 01:45:45 +00:00
|
|
|
mPassId = 0;
|
2000-03-03 04:28:59 +00:00
|
|
|
|
|
|
|
REFLOW_COUNTER_INIT()
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 15:14:00 +00:00
|
|
|
nsListControlFrame::~nsListControlFrame()
|
|
|
|
{
|
2000-03-03 04:28:59 +00:00
|
|
|
REFLOW_COUNTER_DUMP("nsLCF");
|
2000-02-09 19:34:39 +00:00
|
|
|
|
1999-05-07 20:30:16 +00:00
|
|
|
mComboboxFrame = nsnull;
|
1999-11-04 23:16:47 +00:00
|
|
|
if (mFormFrame) {
|
|
|
|
mFormFrame->RemoveFormControlFrame(*this);
|
|
|
|
mFormFrame = nsnull;
|
|
|
|
}
|
1999-08-26 14:54:07 +00:00
|
|
|
NS_IF_RELEASE(mPresContext);
|
1999-10-05 23:43:06 +00:00
|
|
|
if (mSelectionCache) {
|
2000-02-15 15:04:38 +00:00
|
|
|
delete mSelectionCache;
|
1999-10-05 23:43:06 +00:00
|
|
|
}
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
|
2000-08-03 14:13:58 +00:00
|
|
|
// for Bug 47302 (remove this comment later)
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::Destroy(nsIPresContext *aPresContext)
|
|
|
|
{
|
2000-08-14 22:05:28 +00:00
|
|
|
// get the reciever interface from the browser button's content node
|
|
|
|
nsCOMPtr<nsIDOMEventReceiver> reciever(do_QueryInterface(mContent));
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMMouseListener> mouseListener = do_QueryInterface(mEventListener);
|
|
|
|
if (!mouseListener) { return NS_ERROR_NO_INTERFACE; }
|
|
|
|
reciever->RemoveEventListenerByIID(mouseListener, NS_GET_IID(nsIDOMMouseListener));
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMMouseMotionListener> mouseMotionListener = do_QueryInterface(mEventListener);
|
|
|
|
if (!mouseMotionListener) { return NS_ERROR_NO_INTERFACE; }
|
|
|
|
reciever->RemoveEventListenerByIID(mouseMotionListener, NS_GET_IID(nsIDOMMouseMotionListener));
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMKeyListener> keyListener = do_QueryInterface(mEventListener);
|
|
|
|
if (!keyListener) { return NS_ERROR_NO_INTERFACE; }
|
|
|
|
reciever->RemoveEventListenerByIID(keyListener, NS_GET_IID(nsIDOMKeyListener));
|
|
|
|
|
2000-08-03 14:13:58 +00:00
|
|
|
if (IsInDropDownMode() == PR_FALSE) {
|
|
|
|
nsFormControlFrame::RegUnRegAccessKey(aPresContext, NS_STATIC_CAST(nsIFrame*, this), PR_FALSE);
|
|
|
|
}
|
|
|
|
return nsScrollFrame::Destroy(aPresContext);
|
|
|
|
}
|
|
|
|
|
2001-01-27 14:09:34 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::Paint(nsIPresContext* aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer)
|
|
|
|
{
|
|
|
|
nsIStyleContext* sc = mStyleContext;
|
|
|
|
const nsStyleDisplay* disp = (const nsStyleDisplay*)sc->GetStyleData(eStyleStruct_Display);
|
|
|
|
if (!disp->IsVisible()) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Start by assuming we are visible and need to be painted
|
|
|
|
PRBool isVisible = PR_TRUE;
|
|
|
|
|
|
|
|
PRBool isPaginated;
|
|
|
|
aPresContext->IsPaginated(&isPaginated);
|
|
|
|
if (isPaginated) {
|
|
|
|
PRBool isRendingSelection;;
|
|
|
|
aPresContext->IsRenderingOnlySelection(&isRendingSelection);
|
|
|
|
if (isRendingSelection) {
|
|
|
|
// Check the quick way first
|
|
|
|
PRBool isSelected = (mState & NS_FRAME_SELECTED_CONTENT) == NS_FRAME_SELECTED_CONTENT;
|
|
|
|
// if we aren't selected in the mState we could be a container
|
|
|
|
// so check to see if we are in the selection range
|
|
|
|
if (!isSelected) {
|
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
aPresContext->GetShell(getter_AddRefs(shell));
|
|
|
|
nsCOMPtr<nsISelectionController> selcon;
|
|
|
|
selcon = do_QueryInterface(shell);
|
|
|
|
if (selcon) {
|
|
|
|
nsCOMPtr<nsISelection> selection;
|
|
|
|
selcon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection));
|
|
|
|
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(mContent));
|
|
|
|
selection->ContainsNode(node, PR_TRUE, &isVisible);
|
|
|
|
} else {
|
|
|
|
isVisible = PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isVisible) {
|
|
|
|
return nsScrollFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
|
|
|
}
|
|
|
|
|
2001-03-13 01:47:22 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT_DSP("nsListControlFrame", &aRenderingContext);
|
2001-01-27 14:09:34 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
}
|
1999-01-18 15:14:00 +00:00
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-11-02 01:50:15 +00:00
|
|
|
// Frames are not refcounted, no need to AddRef
|
1999-01-18 15:14:00 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|
|
|
{
|
|
|
|
if (NULL == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
2000-02-02 22:24:56 +00:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIFormControlFrame))) {
|
1999-01-18 15:14:00 +00:00
|
|
|
*aInstancePtr = (void*) ((nsIFormControlFrame*) this);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-02-02 22:24:56 +00:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIListControlFrame))) {
|
1999-01-18 15:14:00 +00:00
|
|
|
*aInstancePtr = (void *)((nsIListControlFrame*)this);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-02-02 22:24:56 +00:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsISelectControlFrame))) {
|
1999-08-26 14:54:07 +00:00
|
|
|
*aInstancePtr = (void *)((nsISelectControlFrame*)this);
|
1999-01-18 15:14:00 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-01-04 20:44:42 +00:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIDOMMouseListener))) {
|
1999-08-26 14:54:07 +00:00
|
|
|
*aInstancePtr = (void*)(nsIDOMMouseListener*) this;
|
|
|
|
return NS_OK;
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
2001-01-04 20:44:42 +00:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIDOMMouseMotionListener))) {
|
1999-08-26 14:54:07 +00:00
|
|
|
*aInstancePtr = (void*)(nsIDOMMouseMotionListener*) this;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-01-04 20:44:42 +00:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIDOMKeyListener))) {
|
1999-08-27 14:42:27 +00:00
|
|
|
*aInstancePtr = (void*)(nsIDOMKeyListener*) this;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-09-15 05:31:31 +00:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
|
|
|
|
*aInstancePtr = (void*)(nsIStatefulFrame*) this;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-08-26 14:54:07 +00:00
|
|
|
return nsScrollFrame::QueryInterface(aIID, aInstancePtr);
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-03-22 21:32:12 +00:00
|
|
|
// Reflow is overriden to constrain the listbox height to the number of rows and columns
|
|
|
|
// specified.
|
2000-03-03 04:28:59 +00:00
|
|
|
#ifdef DO_REFLOW_DEBUG
|
|
|
|
static int myCounter = 0;
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
|
2000-03-03 04:28:59 +00:00
|
|
|
static void printSize(char * aDesc, nscoord aSize)
|
|
|
|
{
|
2000-10-28 22:17:53 +00:00
|
|
|
printf(" %s: ", aDesc);
|
2000-03-03 04:28:59 +00:00
|
|
|
if (aSize == NS_UNCONSTRAINEDSIZE) {
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("UNC");
|
2000-03-03 04:28:59 +00:00
|
|
|
} else {
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("%d", aSize);
|
2000-03-03 04:28:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------
|
|
|
|
// Main Reflow for ListBox/Dropdown
|
|
|
|
//-----------------------------------------------------------------
|
1999-01-18 15:14:00 +00:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsListControlFrame::Reflow(nsIPresContext* aPresContext,
|
1999-07-28 21:38:08 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1999-01-18 15:14:00 +00:00
|
|
|
{
|
2000-04-21 22:16:23 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsListControlFrame", aReflowState.reason);
|
2000-03-03 04:28:59 +00:00
|
|
|
REFLOW_COUNTER_REQUEST();
|
|
|
|
|
2000-03-07 15:54:31 +00:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
|
2000-03-03 04:28:59 +00:00
|
|
|
#ifdef DO_REFLOW_DEBUG
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("%p ** Id: %d nsLCF::Reflow %d R: ", this, mReflowId, myCounter++);
|
1999-08-31 13:22:50 +00:00
|
|
|
switch (aReflowState.reason) {
|
2000-03-03 04:28:59 +00:00
|
|
|
case eReflowReason_Initial:
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("Initia");break;
|
2000-03-03 04:28:59 +00:00
|
|
|
case eReflowReason_Incremental:
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("Increm");break;
|
2000-03-03 04:28:59 +00:00
|
|
|
case eReflowReason_Resize:
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("Resize");break;
|
2000-01-31 23:36:50 +00:00
|
|
|
case eReflowReason_StyleChange:
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("StyleC");break;
|
2000-03-03 04:28:59 +00:00
|
|
|
case eReflowReason_Dirty:
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("Dirty ");break;
|
|
|
|
default:printf("<unknown>%d", aReflowState.reason);break;
|
1999-08-31 13:22:50 +00:00
|
|
|
}
|
2000-03-03 04:28:59 +00:00
|
|
|
|
|
|
|
printSize("AW", aReflowState.availableWidth);
|
|
|
|
printSize("AH", aReflowState.availableHeight);
|
|
|
|
printSize("CW", aReflowState.mComputedWidth);
|
|
|
|
printSize("CH", aReflowState.mComputedHeight);
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("\n");
|
2000-04-19 13:55:17 +00:00
|
|
|
#if 0
|
|
|
|
{
|
|
|
|
const nsStyleDisplay* display;
|
|
|
|
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display);
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("+++++++++++++++++++++++++++++++++ ");
|
2000-04-19 13:55:17 +00:00
|
|
|
switch (display->mVisible) {
|
2000-10-28 22:17:53 +00:00
|
|
|
case NS_STYLE_VISIBILITY_COLLAPSE: printf("NS_STYLE_VISIBILITY_COLLAPSE\n");break;
|
|
|
|
case NS_STYLE_VISIBILITY_HIDDEN: printf("NS_STYLE_VISIBILITY_HIDDEN\n");break;
|
|
|
|
case NS_STYLE_VISIBILITY_VISIBLE: printf("NS_STYLE_VISIBILITY_VISIBLE\n");break;
|
2000-04-19 13:55:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
1999-11-11 22:13:33 +00:00
|
|
|
#endif // DEBUG_rodsXXX
|
|
|
|
|
2000-03-03 04:28:59 +00:00
|
|
|
PRBool bailOnWidth;
|
|
|
|
PRBool bailOnHeight;
|
|
|
|
// This ifdef is for turning off the optimization
|
|
|
|
// so we can check timings against the old version
|
2000-03-07 15:54:31 +00:00
|
|
|
#if 1
|
2000-03-03 04:28:59 +00:00
|
|
|
|
|
|
|
nsFormControlFrame::SkipResizeReflow(mCacheSize,
|
|
|
|
mCachedMaxElementSize,
|
|
|
|
mCachedAvailableSize,
|
|
|
|
aDesiredSize, aReflowState,
|
|
|
|
aStatus,
|
|
|
|
bailOnWidth, bailOnHeight);
|
|
|
|
|
|
|
|
// Here we bail if both the height and the width haven't changed
|
|
|
|
// also we see if we should override the optimization
|
|
|
|
//
|
|
|
|
// The optimization can get overridden by the combobox
|
|
|
|
// sometime the combobox knows that the list MUST do a full reflow
|
|
|
|
// no matter what
|
|
|
|
if (!mOverrideReflowOpt && bailOnWidth && bailOnHeight) {
|
|
|
|
REFLOW_DEBUG_MSG3("*** Done nsLCF - Bailing on DW: %d DH: %d ", PX(aDesiredSize.width), PX(aDesiredSize.height));
|
|
|
|
REFLOW_DEBUG_MSG3("bailOnWidth %d bailOnHeight %d\n", PX(bailOnWidth), PX(bailOnHeight));
|
2000-04-21 22:16:23 +00:00
|
|
|
NS_ASSERTION(aDesiredSize.width < 100000, "Width is still NS_UNCONSTRAINEDSIZE");
|
|
|
|
NS_ASSERTION(aDesiredSize.height < 100000, "Height is still NS_UNCONSTRAINEDSIZE");
|
2000-03-03 04:28:59 +00:00
|
|
|
return NS_OK;
|
|
|
|
} else if (mOverrideReflowOpt) {
|
|
|
|
mOverrideReflowOpt = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
bailOnWidth = PR_FALSE;
|
|
|
|
bailOnHeight = PR_FALSE;
|
|
|
|
#endif
|
|
|
|
|
2000-01-31 23:36:50 +00:00
|
|
|
#ifdef DEBUG_rodsXXX
|
2000-03-03 04:28:59 +00:00
|
|
|
// Lists out all the options
|
2000-01-31 23:36:50 +00:00
|
|
|
{
|
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
2000-02-12 16:21:37 +00:00
|
|
|
nsCOMPtr<nsIDOMHTMLCollection> options = getter_AddRefs(GetOptions(mContent));
|
|
|
|
if (options) {
|
2000-01-31 23:36:50 +00:00
|
|
|
PRUint32 numOptions;
|
|
|
|
options->GetLength(&numOptions);
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("--- Num of Items %d ---\n", numOptions);
|
2000-01-31 23:36:50 +00:00
|
|
|
for (PRUint32 i=0;i<numOptions;i++) {
|
2000-02-12 16:21:37 +00:00
|
|
|
nsCOMPtr<nsIDOMHTMLOptionElement> optionElement = getter_AddRefs(GetOption(*options, i));
|
|
|
|
if (optionElement) {
|
2000-01-31 23:36:50 +00:00
|
|
|
nsAutoString text;
|
|
|
|
rv = optionElement->GetLabel(text);
|
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE != rv || 0 == text.Length()) {
|
|
|
|
if (NS_OK != optionElement->GetText(text)) {
|
|
|
|
text = "No Value";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
text = "No Value";
|
|
|
|
}
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("[%d] - %s\n", i, text.ToNewCString());
|
2000-01-31 23:36:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // DEBUG_rodsXXX
|
|
|
|
|
|
|
|
|
2000-04-19 13:55:17 +00:00
|
|
|
if (mDelayedIndexSetting != kNothingSelected) {
|
|
|
|
SetOptionSelected(mDelayedIndexSetting, mDelayedValueSetting);
|
|
|
|
mDelayedIndexSetting = kNothingSelected;
|
|
|
|
}
|
|
|
|
|
1999-11-11 22:13:33 +00:00
|
|
|
// If all the content and frames are here
|
|
|
|
// then initialize it before reflow
|
2000-01-28 19:03:34 +00:00
|
|
|
if (mIsAllContentHere && !mHasBeenInitialized) {
|
1999-11-11 22:13:33 +00:00
|
|
|
if (PR_FALSE == mIsAllFramesHere) {
|
|
|
|
CheckIfAllFramesHere();
|
|
|
|
}
|
|
|
|
if (mIsAllFramesHere && !mHasBeenInitialized) {
|
|
|
|
mHasBeenInitialized = PR_TRUE;
|
2000-03-03 04:28:59 +00:00
|
|
|
Reset(aPresContext);
|
1999-11-11 22:13:33 +00:00
|
|
|
}
|
|
|
|
}
|
2000-01-09 01:41:11 +00:00
|
|
|
|
2000-01-31 23:36:50 +00:00
|
|
|
|
|
|
|
if (eReflowReason_Incremental == aReflowState.reason) {
|
|
|
|
nsIFrame* targetFrame;
|
|
|
|
aReflowState.reflowCommand->GetTarget(targetFrame);
|
|
|
|
if (targetFrame == this) {
|
|
|
|
// XXX So this may do it too often
|
|
|
|
// the side effect of this is if the user has scrolled to some other place in the list and
|
|
|
|
// an incremental reflow comes through the list gets scrolled to the first selected item
|
|
|
|
// I haven't been able to make it do it, but it will do it
|
|
|
|
// basically the real solution is to know when all the reframes are there.
|
|
|
|
nsCOMPtr<nsIContent> content = getter_AddRefs(GetOptionContent(mSelectedIndex));
|
|
|
|
if (content) {
|
|
|
|
ScrollToFrame(content);
|
|
|
|
}
|
2000-01-18 23:33:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-03-22 21:32:12 +00:00
|
|
|
// Strategy: Let the inherited reflow happen as though the width and height of the
|
|
|
|
// ScrollFrame are big enough to allow the listbox to
|
|
|
|
// shrink to fit the longest option element line in the list.
|
|
|
|
// The desired width and height returned by the inherited reflow is returned,
|
|
|
|
// unless one of the following has been specified.
|
|
|
|
// 1. A css width has been specified.
|
|
|
|
// 2. The size has been specified.
|
|
|
|
// 3. The css height has been specified, but the number of rows has not.
|
|
|
|
// The size attribute overrides the height setting but the height setting
|
|
|
|
// should be honored if there isn't a size specified.
|
|
|
|
|
|
|
|
// Determine the desired width + height for the listbox +
|
1999-01-18 15:14:00 +00:00
|
|
|
aDesiredSize.width = 0;
|
|
|
|
aDesiredSize.height = 0;
|
|
|
|
|
1999-08-10 19:22:51 +00:00
|
|
|
// Add the list frame as a child of the form
|
2000-02-12 16:21:37 +00:00
|
|
|
if (eReflowReason_Initial == aReflowState.reason) {
|
|
|
|
if (mPresState) {
|
|
|
|
RestoreState(aPresContext, mPresState);
|
|
|
|
mPresState = do_QueryInterface(nsnull);
|
|
|
|
}
|
|
|
|
if (IsInDropDownMode() == PR_FALSE && !mFormFrame) {
|
|
|
|
nsFormControlFrame::RegUnRegAccessKey(aPresContext, NS_STATIC_CAST(nsIFrame*, this), PR_TRUE);
|
|
|
|
nsFormFrame::AddFormControlFrame(aPresContext, *NS_STATIC_CAST(nsIFrame*, this));
|
|
|
|
}
|
1999-08-10 19:22:51 +00:00
|
|
|
}
|
|
|
|
|
1999-03-22 21:32:12 +00:00
|
|
|
//--Calculate a width just big enough for the scrollframe to shrink around the
|
|
|
|
//longest element in the list
|
1999-05-07 20:30:16 +00:00
|
|
|
nsHTMLReflowState secondPassState(aReflowState);
|
|
|
|
nsHTMLReflowState firstPassState(aReflowState);
|
1999-12-05 20:45:58 +00:00
|
|
|
|
1999-09-08 14:27:38 +00:00
|
|
|
//nsHTMLReflowState firstPassState(aPresContext, nsnull,
|
|
|
|
// this, aDesiredSize);
|
1999-07-20 22:32:41 +00:00
|
|
|
|
1999-05-07 20:30:16 +00:00
|
|
|
// Get the size of option elements inside the listbox
|
1999-03-22 21:32:12 +00:00
|
|
|
// Compute the width based on the longest line in the listbox.
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
firstPassState.mComputedWidth = NS_UNCONSTRAINEDSIZE;
|
1999-07-20 03:41:03 +00:00
|
|
|
firstPassState.mComputedHeight = NS_UNCONSTRAINEDSIZE;
|
1999-07-28 21:38:08 +00:00
|
|
|
firstPassState.availableWidth = NS_UNCONSTRAINEDSIZE;
|
1999-05-07 20:30:16 +00:00
|
|
|
firstPassState.availableHeight = NS_UNCONSTRAINEDSIZE;
|
1999-07-20 22:32:41 +00:00
|
|
|
|
1999-05-07 20:30:16 +00:00
|
|
|
nsSize scrolledAreaSize(0,0);
|
|
|
|
nsHTMLReflowMetrics scrolledAreaDesiredSize(&scrolledAreaSize);
|
1999-05-27 21:17:10 +00:00
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
|
2000-03-03 04:28:59 +00:00
|
|
|
if (eReflowReason_Incremental == aReflowState.reason) {
|
1999-05-27 21:17:10 +00:00
|
|
|
nsIFrame* targetFrame;
|
|
|
|
firstPassState.reflowCommand->GetTarget(targetFrame);
|
|
|
|
if (this == targetFrame) {
|
|
|
|
nsIReflowCommand::ReflowType type;
|
|
|
|
aReflowState.reflowCommand->GetType(type);
|
|
|
|
firstPassState.reason = eReflowReason_StyleChange;
|
|
|
|
firstPassState.reflowCommand = nsnull;
|
2000-03-21 15:22:53 +00:00
|
|
|
} else {
|
|
|
|
nsresult res = nsScrollFrame::Reflow(aPresContext,
|
|
|
|
scrolledAreaDesiredSize,
|
|
|
|
aReflowState,
|
|
|
|
aStatus);
|
|
|
|
if (NS_FAILED(res)) {
|
2000-04-21 22:16:23 +00:00
|
|
|
NS_ASSERTION(aDesiredSize.width < 100000, "Width is still NS_UNCONSTRAINEDSIZE");
|
|
|
|
NS_ASSERTION(aDesiredSize.height < 100000, "Height is still NS_UNCONSTRAINEDSIZE");
|
2000-03-21 15:22:53 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
nsIReflowCommand::ReflowType type;
|
|
|
|
aReflowState.reflowCommand->GetType(type);
|
|
|
|
firstPassState.reason = eReflowReason_StyleChange;
|
|
|
|
firstPassState.reflowCommand = nsnull;
|
1999-05-27 21:17:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-23 01:45:45 +00:00
|
|
|
if (mPassId == 0 || mPassId == 1) {
|
|
|
|
nsresult res = nsScrollFrame::Reflow(aPresContext,
|
|
|
|
scrolledAreaDesiredSize,
|
|
|
|
firstPassState,
|
|
|
|
aStatus);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
NS_ASSERTION(aDesiredSize.width < 100000, "Width is still NS_UNCONSTRAINEDSIZE");
|
|
|
|
NS_ASSERTION(aDesiredSize.height < 100000, "Height is still NS_UNCONSTRAINEDSIZE");
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
mCachedUnconstrainedSize.width = scrolledAreaDesiredSize.width;
|
|
|
|
mCachedUnconstrainedSize.height = scrolledAreaDesiredSize.height;
|
|
|
|
mCachedDesiredMaxSize.width = scrolledAreaDesiredSize.maxElementSize->width;
|
|
|
|
mCachedDesiredMaxSize.height = scrolledAreaDesiredSize.maxElementSize->height;
|
2000-04-19 13:55:17 +00:00
|
|
|
} else {
|
2001-02-23 01:45:45 +00:00
|
|
|
scrolledAreaDesiredSize.width = mCachedUnconstrainedSize.width;
|
|
|
|
scrolledAreaDesiredSize.height = mCachedUnconstrainedSize.height;
|
|
|
|
scrolledAreaDesiredSize.maxElementSize->width = mCachedDesiredMaxSize.width;
|
|
|
|
scrolledAreaDesiredSize.maxElementSize->height = mCachedDesiredMaxSize.height;
|
2000-04-19 13:55:17 +00:00
|
|
|
}
|
2001-02-23 01:45:45 +00:00
|
|
|
|
1999-10-07 21:39:50 +00:00
|
|
|
// Compute the bounding box of the contents of the list using the area
|
|
|
|
// calculated by the first reflow as a starting point.
|
|
|
|
//
|
|
|
|
// The nsScrollFrame::REflow adds in the scrollbar width and border dimensions
|
|
|
|
// to the maxElementSize, so these need to be subtracted
|
2001-02-23 01:45:45 +00:00
|
|
|
nscoord scrolledAreaWidth = scrolledAreaDesiredSize.maxElementSize->width -
|
|
|
|
(aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right);
|
|
|
|
nscoord scrolledAreaHeight = scrolledAreaDesiredSize.height -
|
|
|
|
(aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom);
|
2000-01-05 16:42:47 +00:00
|
|
|
|
2001-02-23 01:45:45 +00:00
|
|
|
// Set up max values
|
1999-10-07 21:39:50 +00:00
|
|
|
mMaxWidth = scrolledAreaWidth;
|
2001-02-23 01:45:45 +00:00
|
|
|
mMaxHeight = scrolledAreaDesiredSize.maxElementSize->height -
|
|
|
|
(aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom);
|
1999-03-22 21:32:12 +00:00
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
// Now the scrolledAreaWidth and scrolledAreaHeight are exactly
|
|
|
|
// wide and high enough to enclose their contents
|
1999-08-06 14:14:38 +00:00
|
|
|
PRBool isInDropDownMode = IsInDropDownMode();
|
|
|
|
|
1999-05-07 20:30:16 +00:00
|
|
|
nscoord visibleWidth = 0;
|
1999-08-06 14:14:38 +00:00
|
|
|
if (isInDropDownMode) {
|
1999-07-20 03:41:03 +00:00
|
|
|
if (NS_UNCONSTRAINEDSIZE == aReflowState.mComputedWidth) {
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
visibleWidth = scrolledAreaWidth;
|
|
|
|
} else {
|
2000-01-09 01:41:11 +00:00
|
|
|
visibleWidth = aReflowState.mComputedWidth;
|
2000-12-20 15:15:28 +00:00
|
|
|
visibleWidth -= aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right;
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
}
|
1999-05-07 20:30:16 +00:00
|
|
|
} else {
|
1999-07-20 03:41:03 +00:00
|
|
|
if (NS_UNCONSTRAINEDSIZE == aReflowState.mComputedWidth) {
|
1999-05-07 20:30:16 +00:00
|
|
|
visibleWidth = scrolledAreaWidth;
|
|
|
|
} else {
|
2001-02-23 01:45:45 +00:00
|
|
|
visibleWidth = aReflowState.mComputedWidth;
|
1999-04-16 19:28:12 +00:00
|
|
|
}
|
|
|
|
}
|
2000-01-09 01:41:11 +00:00
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
// Determine if a scrollbar will be needed, If so we need to add
|
|
|
|
// enough the width to allow for the scrollbar.
|
|
|
|
// The scrollbar will be needed under two conditions:
|
|
|
|
// (size * heightOfaRow) < scrolledAreaHeight or
|
|
|
|
// the height set through Style < scrolledAreaHeight.
|
1999-05-07 20:30:16 +00:00
|
|
|
|
1999-05-17 22:36:08 +00:00
|
|
|
// Calculate the height of a single row in the listbox or dropdown list
|
|
|
|
// Note: It is calculated based on what layout returns for the maxElement
|
|
|
|
// size, rather than trying to take the scrolledAreaHeight and dividing by the number
|
|
|
|
// of option elements. The reason is that their may be option groups in addition to
|
|
|
|
// option elements. Either of which may be visible or invisible.
|
|
|
|
PRInt32 heightOfARow = scrolledAreaDesiredSize.maxElementSize->height;
|
2000-12-20 15:15:28 +00:00
|
|
|
heightOfARow -= aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom;
|
1999-03-22 21:32:12 +00:00
|
|
|
|
2000-03-21 15:22:53 +00:00
|
|
|
// Check to see if we have zero items
|
1999-08-06 14:14:38 +00:00
|
|
|
PRInt32 length = 0;
|
|
|
|
GetNumberOfOptions(&length);
|
|
|
|
|
2000-03-21 15:22:53 +00:00
|
|
|
// If there is only one option and that option's content is empty
|
|
|
|
// then heightOfARow is zero, so we need to go measure
|
|
|
|
// the height of the option as if it had some text.
|
|
|
|
if (heightOfARow == 0 && length > 0) {
|
|
|
|
nsIContent * option = GetOptionContent(0);
|
|
|
|
if (option != nsnull) {
|
|
|
|
nsIFrame * optFrame;
|
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
mPresContext->GetShell(getter_AddRefs(presShell));
|
|
|
|
nsresult result = presShell->GetPrimaryFrameFor(option, &optFrame);
|
|
|
|
if (NS_SUCCEEDED(result) && optFrame != nsnull) {
|
|
|
|
nsCOMPtr<nsIStyleContext> optStyle;
|
|
|
|
optFrame->GetStyleContext(getter_AddRefs(optStyle));
|
|
|
|
if (optStyle) {
|
|
|
|
const nsStyleFont* styleFont = (const nsStyleFont*)optStyle->GetStyleData(eStyleStruct_Font);
|
|
|
|
nsCOMPtr<nsIDeviceContext> deviceContext;
|
|
|
|
aPresContext->GetDeviceContext(getter_AddRefs(deviceContext));
|
|
|
|
NS_ASSERTION(deviceContext, "Couldn't get the device context");
|
|
|
|
nsIFontMetrics * fontMet;
|
|
|
|
result = deviceContext->GetMetricsFor(styleFont->mFont, fontMet);
|
|
|
|
if (NS_SUCCEEDED(result) && fontMet != nsnull) {
|
|
|
|
if (fontMet) {
|
|
|
|
fontMet->GetHeight(heightOfARow);
|
|
|
|
mMaxHeight = heightOfARow;
|
|
|
|
}
|
|
|
|
NS_RELEASE(fontMet);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-05-01 04:00:38 +00:00
|
|
|
NS_RELEASE(option);
|
2000-03-21 15:22:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check to see if we have no width and height
|
|
|
|
// The following code measures the width and height
|
|
|
|
// of a bogus string so the list actually displays
|
1999-05-07 20:30:16 +00:00
|
|
|
nscoord visibleHeight = 0;
|
1999-08-06 14:14:38 +00:00
|
|
|
if (isInDropDownMode) {
|
1999-07-20 22:32:41 +00:00
|
|
|
// Compute the visible height of the drop-down list
|
|
|
|
// The dropdown list height is the smaller of it's height setting or the height
|
|
|
|
// of the smallest box that can drawn around it's contents.
|
|
|
|
visibleHeight = scrolledAreaHeight;
|
1999-03-22 21:32:12 +00:00
|
|
|
|
2000-08-03 14:13:58 +00:00
|
|
|
mNumDisplayRows = kMaxDropDownRows;
|
|
|
|
if (visibleHeight > (mNumDisplayRows * heightOfARow)) {
|
|
|
|
visibleHeight = (mNumDisplayRows * heightOfARow);
|
2000-03-18 14:17:34 +00:00
|
|
|
// This is an adaptive algorithm for figuring out how many rows
|
|
|
|
// should be displayed in the drop down. The standard size is 20 rows,
|
|
|
|
// but on 640x480 it is typically too big.
|
|
|
|
// This takes the height of the screen divides it by two and then subtracts off
|
|
|
|
// an estimated height of the combobox. I estimate it by taking the max element size
|
|
|
|
// of the drop down and multiplying it by 2 (this is arbitrary) then subtract off
|
|
|
|
// the border and padding of the drop down (again rather arbitrary)
|
|
|
|
// This all breaks down if the font of the combobox is a lot larger then the option items
|
|
|
|
// or CSS style has set the height of the combobox to be rather large.
|
|
|
|
// We can fix these cases later if they actually happen.
|
|
|
|
if (isInDropDownMode) {
|
|
|
|
nscoord screenHeightInPixels = 0;
|
|
|
|
if (NS_SUCCEEDED(nsFormControlFrame::GetScreenHeight(aPresContext, screenHeightInPixels))) {
|
|
|
|
float p2t;
|
|
|
|
aPresContext->GetPixelsToTwips(&p2t);
|
|
|
|
nscoord screenHeight = NSIntPixelsToTwips(screenHeightInPixels, p2t);
|
|
|
|
|
|
|
|
nscoord availDropHgt = (screenHeight / 2) - (heightOfARow*2); // approx half screen minus combo size
|
2000-12-20 15:15:28 +00:00
|
|
|
availDropHgt -= aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom;
|
2000-03-18 14:17:34 +00:00
|
|
|
|
2000-12-20 15:15:28 +00:00
|
|
|
nscoord hgt = visibleHeight + aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom;
|
2000-08-29 13:24:38 +00:00
|
|
|
if (heightOfARow > 0) {
|
|
|
|
if (hgt > availDropHgt) {
|
|
|
|
visibleHeight = (availDropHgt / heightOfARow) * heightOfARow;
|
|
|
|
}
|
|
|
|
mNumDisplayRows = visibleHeight / heightOfARow;
|
|
|
|
} else {
|
|
|
|
// Hmmm, not sure what to do here. Punt, and make both of them one
|
|
|
|
visibleHeight = 1;
|
|
|
|
mNumDisplayRows = 1;
|
2000-03-18 14:17:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-07-20 22:32:41 +00:00
|
|
|
}
|
1999-05-07 20:30:16 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
// Calculate the visible height of the listbox
|
1999-07-20 03:41:03 +00:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != aReflowState.mComputedHeight) {
|
|
|
|
visibleHeight = aReflowState.mComputedHeight;
|
1999-05-07 20:30:16 +00:00
|
|
|
} else {
|
2000-08-03 14:13:58 +00:00
|
|
|
mNumDisplayRows = 1;
|
|
|
|
GetSizeAttribute(&mNumDisplayRows);
|
2000-02-12 16:21:37 +00:00
|
|
|
// because we are not a drop down
|
|
|
|
// we will always have 2 or more rows
|
2000-08-03 14:13:58 +00:00
|
|
|
if (mNumDisplayRows >= 1) {
|
|
|
|
visibleHeight = mNumDisplayRows * heightOfARow;
|
2000-03-03 04:28:59 +00:00
|
|
|
} else {
|
|
|
|
PRBool multipleSelections = PR_FALSE;
|
|
|
|
GetMultiple(&multipleSelections);
|
|
|
|
if (multipleSelections) {
|
|
|
|
visibleHeight = PR_MIN(length, kMaxDropDownRows) * heightOfARow;
|
|
|
|
} else {
|
|
|
|
visibleHeight = 2 * heightOfARow;
|
|
|
|
}
|
|
|
|
}
|
1999-04-16 19:28:12 +00:00
|
|
|
}
|
1999-03-22 21:32:12 +00:00
|
|
|
}
|
|
|
|
|
1999-08-06 14:14:38 +00:00
|
|
|
// There are no items in the list
|
|
|
|
// but we want to include space for the scrollbars
|
|
|
|
// So fake like we will need scrollbars also
|
|
|
|
if (!isInDropDownMode && 0 == length) {
|
|
|
|
scrolledAreaHeight = visibleHeight+1;
|
|
|
|
}
|
|
|
|
|
1999-05-07 20:30:16 +00:00
|
|
|
PRBool needsVerticalScrollbar = PR_FALSE;
|
|
|
|
if (visibleHeight < scrolledAreaHeight) {
|
|
|
|
needsVerticalScrollbar = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
2000-01-09 01:41:11 +00:00
|
|
|
if (needsVerticalScrollbar) {
|
1999-07-28 21:38:08 +00:00
|
|
|
mIsScrollbarVisible = PR_TRUE; // XXX temp code
|
|
|
|
} else {
|
|
|
|
mIsScrollbarVisible = PR_FALSE; // XXX temp code
|
1999-05-07 20:30:16 +00:00
|
|
|
}
|
|
|
|
|
1999-12-22 19:49:36 +00:00
|
|
|
// The visible height is zero, this could be a select with no options
|
|
|
|
// or a select with a single option that has no content or no label
|
|
|
|
//
|
|
|
|
// So this may not be the best solution, but we get the height of the font
|
|
|
|
// for the list frame and use that as the max/minimum size for the contents
|
|
|
|
if (visibleHeight == 0) {
|
|
|
|
nsCOMPtr<nsIFontMetrics> fontMet;
|
2000-03-28 15:11:16 +00:00
|
|
|
nsresult rvv = nsFormControlHelper::GetFrameFontFM(aPresContext, this, getter_AddRefs(fontMet));
|
|
|
|
if (NS_SUCCEEDED(rvv) && fontMet) {
|
1999-12-22 19:49:36 +00:00
|
|
|
aReflowState.rendContext->SetFont(fontMet);
|
|
|
|
fontMet->GetHeight(visibleHeight);
|
|
|
|
mMaxHeight = visibleHeight;
|
|
|
|
}
|
1999-09-09 19:37:23 +00:00
|
|
|
}
|
|
|
|
|
2000-01-09 01:41:11 +00:00
|
|
|
if (NS_UNCONSTRAINEDSIZE == aReflowState.mComputedWidth) {
|
2000-12-20 15:15:28 +00:00
|
|
|
visibleWidth += aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right;
|
|
|
|
}
|
|
|
|
|
|
|
|
// When in dropdown mode make sure we obey min/max-width and min/max-height
|
|
|
|
if (!isInDropDownMode) {
|
|
|
|
nscoord fullWidth = visibleWidth + aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right;
|
|
|
|
if (fullWidth > aReflowState.mComputedMaxWidth) {
|
|
|
|
visibleWidth = aReflowState.mComputedMaxWidth - aReflowState.mComputedBorderPadding.left - aReflowState.mComputedBorderPadding.right;
|
|
|
|
}
|
|
|
|
if (fullWidth < aReflowState.mComputedMinWidth) {
|
|
|
|
visibleWidth = aReflowState.mComputedMinWidth - aReflowState.mComputedBorderPadding.left - aReflowState.mComputedBorderPadding.right;
|
|
|
|
}
|
|
|
|
|
|
|
|
// calculate full height for comparison
|
|
|
|
// must add in Border & Padding twice because the scrolled area also inherits Border & Padding
|
|
|
|
nscoord fullHeight = visibleHeight + aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom;
|
|
|
|
// + aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom;
|
|
|
|
if (fullHeight > aReflowState.mComputedMaxHeight) {
|
|
|
|
visibleHeight = aReflowState.mComputedMaxHeight - aReflowState.mComputedBorderPadding.top - aReflowState.mComputedBorderPadding.bottom;
|
|
|
|
}
|
|
|
|
if (fullHeight < aReflowState.mComputedMinHeight) {
|
|
|
|
visibleHeight = aReflowState.mComputedMinHeight - aReflowState.mComputedBorderPadding.top - aReflowState.mComputedBorderPadding.bottom;
|
|
|
|
}
|
2000-01-09 01:41:11 +00:00
|
|
|
}
|
|
|
|
|
2001-03-19 23:20:21 +00:00
|
|
|
#ifdef IBMBIDI
|
|
|
|
nsRect parentRect, thisRect;
|
|
|
|
// Retrieve the scrollbar's width and height
|
|
|
|
float sbWidth = 0.0;
|
|
|
|
float sbHeight = 0.0;;
|
|
|
|
nsCOMPtr<nsIDeviceContext> dc;
|
|
|
|
aPresContext->GetDeviceContext(getter_AddRefs(dc));
|
|
|
|
dc->GetScrollBarDimensions(sbWidth, sbHeight);
|
|
|
|
// Convert to nscoord's by rounding
|
|
|
|
nscoord scrollbarWidth = NSToCoordRound(sbWidth);
|
|
|
|
|
|
|
|
const nsStyleDisplay* display;
|
|
|
|
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) display);
|
|
|
|
|
|
|
|
if (display->mDirection == NS_STYLE_DIRECTION_RTL)
|
|
|
|
{
|
|
|
|
nscoord bidiScrolledAreaWidth = scrolledAreaDesiredSize.maxElementSize->width;
|
|
|
|
firstPassState.reason = eReflowReason_StyleChange;
|
|
|
|
float p2t;
|
|
|
|
aPresContext->GetScaledPixelsToTwips(&p2t);
|
|
|
|
if (aReflowState.mComputedWidth == NS_UNCONSTRAINEDSIZE)
|
|
|
|
{
|
|
|
|
if (needsVerticalScrollbar) {
|
|
|
|
bidiScrolledAreaWidth -= scrollbarWidth;
|
|
|
|
} else {
|
|
|
|
bidiScrolledAreaWidth = aReflowState.mComputedWidth - scrollbarWidth + (6 * p2t);
|
|
|
|
if (needsVerticalScrollbar) bidiScrolledAreaWidth -= scrollbarWidth;
|
|
|
|
}
|
|
|
|
firstPassState.mComputedWidth = bidiScrolledAreaWidth;
|
|
|
|
firstPassState.availableWidth = bidiScrolledAreaWidth;
|
|
|
|
nsScrollFrame::Reflow(aPresContext, aDesiredSize, firstPassState, aStatus);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // IBMBIDI
|
|
|
|
|
1999-05-07 20:30:16 +00:00
|
|
|
// Do a second reflow with the adjusted width and height settings
|
|
|
|
// This sets up all of the frames with the correct width and height.
|
1999-10-07 21:39:50 +00:00
|
|
|
secondPassState.mComputedWidth = visibleWidth;
|
1999-07-20 03:41:03 +00:00
|
|
|
secondPassState.mComputedHeight = visibleHeight;
|
1999-05-07 20:30:16 +00:00
|
|
|
secondPassState.reason = eReflowReason_Resize;
|
2000-01-09 01:41:11 +00:00
|
|
|
|
2001-02-23 01:45:45 +00:00
|
|
|
if (mPassId == 0 || mPassId == 2) {
|
|
|
|
nsScrollFrame::Reflow(aPresContext, aDesiredSize, secondPassState, aStatus);
|
1999-03-22 21:32:12 +00:00
|
|
|
// Set the max element size to be the same as the desired element size.
|
2001-02-23 01:45:45 +00:00
|
|
|
} else {
|
|
|
|
aDesiredSize.width = visibleWidth;
|
|
|
|
aDesiredSize.height = visibleHeight;
|
|
|
|
aDesiredSize.ascent = aDesiredSize.height;
|
|
|
|
aDesiredSize.descent = 0;
|
|
|
|
}
|
|
|
|
|
1999-01-18 15:14:00 +00:00
|
|
|
if (nsnull != aDesiredSize.maxElementSize) {
|
|
|
|
aDesiredSize.maxElementSize->width = aDesiredSize.width;
|
|
|
|
aDesiredSize.maxElementSize->height = aDesiredSize.height;
|
|
|
|
}
|
|
|
|
|
1999-03-22 21:32:12 +00:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1999-10-07 21:39:50 +00:00
|
|
|
|
2001-02-23 01:45:45 +00:00
|
|
|
#ifdef DEBUG_rodsX
|
1999-10-07 21:39:50 +00:00
|
|
|
if (!isInDropDownMode) {
|
|
|
|
PRInt32 numRows = 1;
|
|
|
|
GetSizeAttribute(&numRows);
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("%d ", numRows);
|
1999-10-07 21:39:50 +00:00
|
|
|
if (numRows == 2) {
|
|
|
|
COMPARE_QUIRK_SIZE("nsListControlFrame", 56, 38)
|
2000-05-11 14:05:44 +00:00
|
|
|
} else if (numRows == 3) {
|
1999-10-07 21:39:50 +00:00
|
|
|
COMPARE_QUIRK_SIZE("nsListControlFrame", 56, 54)
|
2000-05-11 14:05:44 +00:00
|
|
|
} else if (numRows == 4) {
|
1999-10-07 21:39:50 +00:00
|
|
|
COMPARE_QUIRK_SIZE("nsListControlFrame", 56, 70)
|
2000-05-11 14:05:44 +00:00
|
|
|
} else {
|
|
|
|
COMPARE_QUIRK_SIZE("nsListControlFrame", 127, 118)
|
1999-10-07 21:39:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2000-03-18 14:17:34 +00:00
|
|
|
if (aReflowState.availableWidth != NS_UNCONSTRAINEDSIZE) {
|
2000-12-20 15:15:28 +00:00
|
|
|
mCachedAvailableSize.width = aDesiredSize.width - (aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right);
|
2000-03-18 14:17:34 +00:00
|
|
|
REFLOW_DEBUG_MSG2("** nsLCF Caching AW: %d\n", PX(mCachedAvailableSize.width));
|
|
|
|
}
|
|
|
|
if (aReflowState.availableHeight != NS_UNCONSTRAINEDSIZE) {
|
2000-12-20 15:15:28 +00:00
|
|
|
mCachedAvailableSize.height = aDesiredSize.height - (aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom);
|
2000-03-18 14:17:34 +00:00
|
|
|
REFLOW_DEBUG_MSG2("** nsLCF Caching AH: %d\n", PX(mCachedAvailableSize.height));
|
|
|
|
}
|
2000-03-03 04:28:59 +00:00
|
|
|
|
2000-03-18 14:17:34 +00:00
|
|
|
//REFLOW_DEBUG_MSG3("** nsLCF Caching AW: %d AH: %d\n", PX(mCachedAvailableSize.width), PX(mCachedAvailableSize.height));
|
2000-03-03 04:28:59 +00:00
|
|
|
|
2000-01-09 01:41:11 +00:00
|
|
|
nsFormControlFrame::SetupCachedSizes(mCacheSize, mCachedMaxElementSize, aDesiredSize);
|
|
|
|
|
2000-03-18 14:17:34 +00:00
|
|
|
REFLOW_DEBUG_MSG3("** Done nsLCF DW: %d DH: %d\n\n", PX(aDesiredSize.width), PX(aDesiredSize.height));
|
2000-03-03 04:28:59 +00:00
|
|
|
|
|
|
|
REFLOW_COUNTER();
|
|
|
|
|
|
|
|
#ifdef DO_REFLOW_COUNTER
|
|
|
|
if (gReflowControlCnt[mReflowId] > 50) {
|
|
|
|
REFLOW_DEBUG_MSG3("** Id: %d Cnt: %d ", mReflowId, gReflowControlCnt[mReflowId]);
|
|
|
|
REFLOW_DEBUG_MSG3("Done nsLCF DW: %d DH: %d\n", PX(aDesiredSize.width), PX(aDesiredSize.height));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2000-04-21 22:16:23 +00:00
|
|
|
NS_ASSERTION(aDesiredSize.width < 100000, "Width is still NS_UNCONSTRAINEDSIZE");
|
|
|
|
NS_ASSERTION(aDesiredSize.height < 100000, "Height is still NS_UNCONSTRAINEDSIZE");
|
1999-01-18 15:14:00 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 15:14:00 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::GetFormContent(nsIContent*& aContent) const
|
|
|
|
{
|
1999-02-10 00:42:56 +00:00
|
|
|
nsIContent* content;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = GetContent(&content);
|
|
|
|
aContent = content;
|
|
|
|
return rv;
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 15:14:00 +00:00
|
|
|
NS_IMETHODIMP
|
2000-01-31 23:36:50 +00:00
|
|
|
nsListControlFrame::GetFont(nsIPresContext* aPresContext,
|
|
|
|
const nsFont*& aFont)
|
1999-01-18 15:14:00 +00:00
|
|
|
{
|
2000-01-31 23:36:50 +00:00
|
|
|
return nsFormControlHelper::GetFont(this, aPresContext, mStyleContext, aFont);
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
|
1999-03-22 21:32:12 +00:00
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
PRBool
|
|
|
|
nsListControlFrame::IsOptionElement(nsIContent* aContent)
|
1999-05-13 23:45:40 +00:00
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
nsCOMPtr<nsIDOMHTMLOptionElement> optElem;
|
2000-02-02 22:24:56 +00:00
|
|
|
if (NS_SUCCEEDED(aContent->QueryInterface(NS_GET_IID(nsIDOMHTMLOptionElement),(void**) getter_AddRefs(optElem)))) {
|
1999-07-28 21:38:08 +00:00
|
|
|
if (optElem != nsnull) {
|
1999-05-13 23:45:40 +00:00
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
PRBool
|
|
|
|
nsListControlFrame::IsOptionElementFrame(nsIFrame *aFrame)
|
1999-05-13 23:45:40 +00:00
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
2000-02-12 16:21:37 +00:00
|
|
|
nsCOMPtr<nsIContent> content;
|
|
|
|
aFrame->GetContent(getter_AddRefs(content));
|
|
|
|
if (content) {
|
1999-05-13 23:45:40 +00:00
|
|
|
result = IsOptionElement(content);
|
|
|
|
}
|
2000-02-12 16:21:37 +00:00
|
|
|
return result;
|
1999-05-13 23:45:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-05-13 23:45:40 +00:00
|
|
|
// Go up the frame tree looking for the first ancestor that has content
|
|
|
|
// which is selectable
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
nsIFrame *
|
|
|
|
nsListControlFrame::GetSelectableFrame(nsIFrame *aFrame)
|
1999-05-13 23:45:40 +00:00
|
|
|
{
|
|
|
|
nsIFrame* selectedFrame = aFrame;
|
|
|
|
|
|
|
|
while ((nsnull != selectedFrame) &&
|
|
|
|
(PR_FALSE ==IsOptionElementFrame(selectedFrame))) {
|
|
|
|
selectedFrame->GetParent(&selectedFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(selectedFrame);
|
|
|
|
}
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
void
|
1999-10-26 04:44:41 +00:00
|
|
|
nsListControlFrame::ForceRedraw(nsIPresContext* aPresContext)
|
1999-05-07 20:30:16 +00:00
|
|
|
{
|
|
|
|
//XXX: Hack. This should not be needed. The problem is DisplaySelected
|
|
|
|
//and DisplayDeselected set and unset an attribute on generic HTML content
|
|
|
|
//which does not know that it should repaint as the result of the attribute
|
|
|
|
//being set. This should not be needed once the event state manager handles
|
|
|
|
//selection.
|
1999-10-26 04:44:41 +00:00
|
|
|
nsFormControlHelper::ForceDrawFrame(aPresContext, this);
|
1999-05-07 20:30:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-03-22 21:32:12 +00:00
|
|
|
// XXX: Here we introduce a new -moz-option-selected attribute so a attribute
|
|
|
|
// selecitor n the ua.css can change the style when the option is selected.
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
void
|
|
|
|
nsListControlFrame::DisplaySelected(nsIContent* aContent)
|
1999-01-18 15:14:00 +00:00
|
|
|
{
|
1999-04-12 22:14:31 +00:00
|
|
|
//XXX: This is temporary. It simulates psuedo states by using a attribute selector on
|
|
|
|
// -moz-option-selected in the ua.css style sheet. This will not be needed when
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
// The event state manager supports selected states. KMM
|
1999-05-07 20:30:16 +00:00
|
|
|
|
1999-11-12 15:00:30 +00:00
|
|
|
if (PR_TRUE == mIsAllFramesHere) {
|
2000-04-16 11:19:26 +00:00
|
|
|
aContent->SetAttribute(kNameSpaceID_None, nsLayoutAtoms::optionSelectedPseudo, nsAutoString(), PR_TRUE);
|
1999-09-30 11:37:58 +00:00
|
|
|
//ForceRedraw();
|
1999-05-27 21:17:10 +00:00
|
|
|
} else {
|
2000-04-16 11:19:26 +00:00
|
|
|
aContent->SetAttribute(kNameSpaceID_None, nsLayoutAtoms::optionSelectedPseudo, nsAutoString(), PR_FALSE);
|
1999-05-27 21:17:10 +00:00
|
|
|
}
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
void
|
|
|
|
nsListControlFrame::DisplayDeselected(nsIContent* aContent)
|
1999-03-22 21:32:12 +00:00
|
|
|
{
|
1999-04-12 22:14:31 +00:00
|
|
|
//XXX: This is temporary. It simulates psuedo states by using a attribute selector on
|
|
|
|
// -moz-option-selected in the ua.css style sheet. This will not be needed when
|
|
|
|
// The event state manager is functional. KMM
|
1999-11-12 15:00:30 +00:00
|
|
|
if (PR_TRUE == mIsAllFramesHere) {
|
1999-12-06 22:59:43 +00:00
|
|
|
aContent->UnsetAttribute(kNameSpaceID_None, nsLayoutAtoms::optionSelectedPseudo, PR_TRUE);
|
1999-09-30 11:37:58 +00:00
|
|
|
//ForceRedraw();
|
1999-05-27 21:17:10 +00:00
|
|
|
} else {
|
1999-12-06 22:59:43 +00:00
|
|
|
aContent->UnsetAttribute(kNameSpaceID_None, nsLayoutAtoms::optionSelectedPseudo, PR_FALSE);
|
1999-05-27 21:17:10 +00:00
|
|
|
}
|
1999-08-26 14:54:07 +00:00
|
|
|
|
|
|
|
}
|
1999-05-07 20:30:16 +00:00
|
|
|
|
1999-08-26 14:54:07 +00:00
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// Starts at the passed in content object and walks up the
|
|
|
|
// parent heierarchy looking for the nsIDOMHTMLOptionElement
|
|
|
|
//---------------------------------------------------------
|
|
|
|
nsIContent *
|
|
|
|
nsListControlFrame::GetOptionFromContent(nsIContent *aContent)
|
|
|
|
{
|
|
|
|
nsIContent * content = aContent;
|
2001-01-08 14:06:34 +00:00
|
|
|
NS_IF_ADDREF(content);
|
1999-08-26 14:54:07 +00:00
|
|
|
while (nsnull != content) {
|
|
|
|
if (IsOptionElement(content)) {
|
|
|
|
return content;
|
|
|
|
}
|
|
|
|
nsIContent * node = content;
|
|
|
|
node->GetParent(content); // this add refs
|
|
|
|
NS_RELEASE(node);
|
|
|
|
}
|
|
|
|
return nsnull;
|
1999-03-22 21:32:12 +00:00
|
|
|
}
|
|
|
|
|
1999-08-26 14:54:07 +00:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// Finds the index of the hit frame's content in the list
|
|
|
|
// of option elements
|
|
|
|
//---------------------------------------------------------
|
|
|
|
PRInt32
|
|
|
|
nsListControlFrame::GetSelectedIndexFromContent(nsIContent *aContent)
|
|
|
|
{
|
|
|
|
// Search the list of option elements looking for a match
|
|
|
|
// between the hit frame's content and the content of an option element
|
|
|
|
|
|
|
|
// get the collection of option items
|
2000-02-12 16:21:37 +00:00
|
|
|
nsCOMPtr<nsIDOMHTMLCollection> options = getter_AddRefs(GetOptions(mContent));
|
|
|
|
if (options) {
|
1999-08-26 14:54:07 +00:00
|
|
|
PRUint32 numOptions;
|
|
|
|
options->GetLength(&numOptions);
|
|
|
|
|
|
|
|
PRUint32 inx;
|
|
|
|
for (inx = 0; inx < numOptions; inx++) {
|
2000-02-12 17:49:11 +00:00
|
|
|
nsIContent * option = GetOptionAsContent(options, inx);
|
|
|
|
if (option != nsnull) {
|
|
|
|
if (option == aContent) {
|
|
|
|
NS_RELEASE(option);
|
1999-08-26 14:54:07 +00:00
|
|
|
return inx;
|
|
|
|
}
|
2000-02-12 17:49:11 +00:00
|
|
|
NS_RELEASE(option);
|
1999-08-26 14:54:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return kNothingSelected;
|
|
|
|
}
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
|
1999-08-26 14:54:07 +00:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// Finds the index of the hit frame's content in the list
|
|
|
|
// of option elements
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
PRInt32
|
1999-08-19 14:11:28 +00:00
|
|
|
nsListControlFrame::GetSelectedIndexFromFrame(nsIFrame *aHitFrame)
|
1999-01-18 15:14:00 +00:00
|
|
|
{
|
2000-02-12 16:21:37 +00:00
|
|
|
NS_ASSERTION(aHitFrame, "No frame for html <select> element\n");
|
|
|
|
|
1999-08-27 03:58:13 +00:00
|
|
|
PRInt32 indx = kNothingSelected;
|
1999-06-05 00:18:58 +00:00
|
|
|
// Get the content of the frame that was selected
|
|
|
|
if (aHitFrame) {
|
2000-02-12 16:21:37 +00:00
|
|
|
nsCOMPtr<nsIContent> selectedContent;
|
|
|
|
aHitFrame->GetContent(getter_AddRefs(selectedContent));
|
|
|
|
if (selectedContent) {
|
|
|
|
indx = GetSelectedIndexFromContent(selectedContent);
|
|
|
|
}
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
1999-08-27 03:58:13 +00:00
|
|
|
return indx;
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
void
|
|
|
|
nsListControlFrame::ClearSelection()
|
1999-01-18 15:14:00 +00:00
|
|
|
{
|
1999-07-20 22:32:41 +00:00
|
|
|
PRInt32 length = 0;
|
|
|
|
GetNumberOfOptions(&length);
|
|
|
|
for (PRInt32 i = 0; i < length; i++) {
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
if (i != mSelectedIndex) {
|
1999-08-26 14:54:07 +00:00
|
|
|
SetContentSelected(i, PR_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-14 22:00:24 +00:00
|
|
|
}
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
void
|
|
|
|
nsListControlFrame::ExtendedSelection(PRInt32 aStartIndex, PRInt32 aEndIndex, PRBool aDoInvert, PRBool aSetValue)
|
1999-01-18 15:14:00 +00:00
|
|
|
{
|
|
|
|
PRInt32 startInx;
|
|
|
|
PRInt32 endInx;
|
|
|
|
|
|
|
|
if (aStartIndex < aEndIndex) {
|
|
|
|
startInx = aStartIndex;
|
|
|
|
endInx = aEndIndex;
|
|
|
|
} else {
|
|
|
|
startInx = aEndIndex;
|
|
|
|
endInx = aStartIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32 i = 0;
|
|
|
|
PRBool startInverting = PR_FALSE;
|
1999-05-17 22:36:08 +00:00
|
|
|
|
1999-07-20 22:32:41 +00:00
|
|
|
PRInt32 length = 0;
|
|
|
|
GetNumberOfOptions(&length);
|
1999-05-17 22:36:08 +00:00
|
|
|
for (i = 0; i < length; i++) {
|
1999-01-18 15:14:00 +00:00
|
|
|
if (i == startInx) {
|
|
|
|
startInverting = PR_TRUE;
|
|
|
|
}
|
|
|
|
if (startInverting && ((i != mStartExtendedIndex && aDoInvert) || !aDoInvert)) {
|
|
|
|
if (aDoInvert) {
|
1999-08-26 14:54:07 +00:00
|
|
|
SetContentSelected(i, !IsContentSelectedByIndex(i));
|
1999-01-18 15:14:00 +00:00
|
|
|
} else {
|
1999-08-26 14:54:07 +00:00
|
|
|
SetContentSelected(i, aSetValue);
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i == endInx) {
|
|
|
|
startInverting = PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
void
|
|
|
|
nsListControlFrame::SingleSelection()
|
1999-01-18 15:14:00 +00:00
|
|
|
{
|
1999-08-26 14:54:07 +00:00
|
|
|
// Get Current selection
|
|
|
|
if (mSelectedIndex != kNothingSelected) {
|
|
|
|
if (mOldSelectedIndex != mSelectedIndex) {
|
|
|
|
// Deselect the previous selection if there is one
|
|
|
|
if (mOldSelectedIndex != kNothingSelected) {
|
|
|
|
SetContentSelected(mOldSelectedIndex, PR_FALSE);
|
1999-05-07 20:30:16 +00:00
|
|
|
}
|
1999-08-26 14:54:07 +00:00
|
|
|
// Display the new selection
|
|
|
|
SetContentSelected(mSelectedIndex, PR_TRUE);
|
|
|
|
} else {
|
|
|
|
// Selecting the currently selected item so do nothing.
|
1999-05-07 20:30:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-01-18 15:14:00 +00:00
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
void
|
|
|
|
nsListControlFrame::MultipleSelection(PRBool aIsShift, PRBool aIsControl)
|
1999-05-07 20:30:16 +00:00
|
|
|
{
|
|
|
|
if (kNothingSelected != mSelectedIndex) {
|
1999-08-27 14:42:27 +00:00
|
|
|
//if ((aIsShift) || (mButtonDown && (!aIsControl))) {
|
|
|
|
if (aIsShift) {
|
1999-08-26 14:54:07 +00:00
|
|
|
// Shift is held down
|
|
|
|
SetContentSelected(mSelectedIndex, PR_TRUE);
|
|
|
|
if (mEndExtendedIndex == kNothingSelected) {
|
2000-12-20 15:15:28 +00:00
|
|
|
if (mOldSelectedIndex == kNothingSelected) {
|
|
|
|
mStartExtendedIndex = mSelectedIndex;
|
|
|
|
mEndExtendedIndex = kNothingSelected;
|
|
|
|
} else {
|
|
|
|
if (mSelectedIndex == mOldSelectedIndex) {
|
|
|
|
mEndExtendedIndex = kNothingSelected;
|
|
|
|
} else {
|
|
|
|
mEndExtendedIndex = mSelectedIndex;
|
|
|
|
}
|
|
|
|
ExtendedSelection(mStartExtendedIndex, mEndExtendedIndex, PR_FALSE, PR_TRUE);
|
|
|
|
}
|
1999-08-26 14:54:07 +00:00
|
|
|
} else {
|
|
|
|
if (mStartExtendedIndex < mEndExtendedIndex) {
|
|
|
|
if (mSelectedIndex < mStartExtendedIndex) {
|
1999-08-27 14:42:27 +00:00
|
|
|
ExtendedSelection(mSelectedIndex+1, mEndExtendedIndex, PR_TRUE, PR_TRUE);
|
1999-08-26 14:54:07 +00:00
|
|
|
mEndExtendedIndex = mSelectedIndex;
|
|
|
|
} else if (mSelectedIndex > mEndExtendedIndex) {
|
|
|
|
ExtendedSelection(mEndExtendedIndex+1, mSelectedIndex, PR_FALSE, PR_TRUE);
|
|
|
|
mEndExtendedIndex = mSelectedIndex;
|
|
|
|
} else if (mSelectedIndex < mEndExtendedIndex) {
|
|
|
|
ExtendedSelection(mSelectedIndex+1, mEndExtendedIndex, PR_FALSE, PR_FALSE);
|
2000-12-20 15:15:28 +00:00
|
|
|
if (mSelectedIndex == mStartExtendedIndex) {
|
|
|
|
mEndExtendedIndex = kNothingSelected;
|
|
|
|
} else {
|
|
|
|
mEndExtendedIndex = mSelectedIndex;
|
|
|
|
}
|
1999-08-26 14:54:07 +00:00
|
|
|
}
|
|
|
|
} else if (mStartExtendedIndex > mEndExtendedIndex) {
|
|
|
|
if (mSelectedIndex > mStartExtendedIndex) {
|
1999-08-27 14:42:27 +00:00
|
|
|
ExtendedSelection(mEndExtendedIndex, mSelectedIndex-1, PR_TRUE, PR_TRUE);
|
1999-08-26 14:54:07 +00:00
|
|
|
mEndExtendedIndex = mSelectedIndex;
|
|
|
|
} else if (mSelectedIndex < mEndExtendedIndex) {
|
1999-08-27 14:42:27 +00:00
|
|
|
ExtendedSelection(mStartExtendedIndex, mEndExtendedIndex-1, PR_FALSE, PR_TRUE);
|
1999-08-26 14:54:07 +00:00
|
|
|
mEndExtendedIndex = mSelectedIndex;
|
|
|
|
} else if (mSelectedIndex > mEndExtendedIndex) {
|
|
|
|
ExtendedSelection(mEndExtendedIndex, mSelectedIndex-1, PR_FALSE, PR_FALSE);
|
2000-12-20 15:15:28 +00:00
|
|
|
if (mSelectedIndex == mStartExtendedIndex) {
|
|
|
|
mEndExtendedIndex = kNothingSelected;
|
|
|
|
} else {
|
|
|
|
mEndExtendedIndex = mSelectedIndex;
|
|
|
|
}
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
}
|
1999-08-26 14:54:07 +00:00
|
|
|
}
|
|
|
|
} else if (aIsControl) {
|
|
|
|
// Control is held down
|
|
|
|
if (IsContentSelectedByIndex(mSelectedIndex)) {
|
|
|
|
SetContentSelected(mSelectedIndex, PR_FALSE);
|
1999-05-17 22:36:08 +00:00
|
|
|
} else {
|
1999-08-26 14:54:07 +00:00
|
|
|
SetContentSelected(mSelectedIndex, PR_TRUE);
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
1999-08-26 14:54:07 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
// Neither control nor shift is held down
|
|
|
|
SetContentSelected(mSelectedIndex, PR_TRUE);
|
|
|
|
mStartExtendedIndex = mSelectedIndex;
|
|
|
|
mEndExtendedIndex = kNothingSelected;
|
|
|
|
ClearSelection();
|
|
|
|
}
|
|
|
|
}
|
2000-12-20 15:15:28 +00:00
|
|
|
#ifdef DEBUG_rods
|
|
|
|
printf("mSelectedIndex: %d\n", mSelectedIndex);
|
|
|
|
printf("mOldSelectedIndex: %d\n", mOldSelectedIndex);
|
|
|
|
printf("mStartExtendedIndex: %d\n", mStartExtendedIndex);
|
|
|
|
printf("mEndExtendedIndex: %d\n", mEndExtendedIndex);
|
|
|
|
#endif
|
1999-05-07 20:30:16 +00:00
|
|
|
}
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
void
|
1999-08-26 14:54:07 +00:00
|
|
|
nsListControlFrame::HandleListSelection(nsIDOMEvent* aEvent)
|
1999-05-28 21:12:09 +00:00
|
|
|
{
|
1999-08-26 14:54:07 +00:00
|
|
|
|
1999-07-20 22:32:41 +00:00
|
|
|
PRBool multipleSelections = PR_FALSE;
|
|
|
|
GetMultiple(&multipleSelections);
|
|
|
|
if (multipleSelections) {
|
1999-11-03 07:11:45 +00:00
|
|
|
nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aEvent);
|
1999-08-26 14:54:07 +00:00
|
|
|
PRBool isShift;
|
|
|
|
PRBool isControl;
|
2000-01-13 16:01:04 +00:00
|
|
|
#ifdef XP_MAC
|
|
|
|
mouseEvent->GetMetaKey(&isControl);
|
|
|
|
#else
|
1999-11-03 07:11:45 +00:00
|
|
|
mouseEvent->GetCtrlKey(&isControl);
|
2000-01-13 16:01:04 +00:00
|
|
|
#endif
|
1999-11-03 07:11:45 +00:00
|
|
|
mouseEvent->GetShiftKey(&isShift);
|
1999-08-26 14:54:07 +00:00
|
|
|
MultipleSelection(isShift, isControl);
|
1999-05-28 21:12:09 +00:00
|
|
|
} else {
|
|
|
|
SingleSelection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
PRBool
|
|
|
|
nsListControlFrame::HasSameContent(nsIFrame* aFrame1, nsIFrame* aFrame2)
|
1999-05-28 21:12:09 +00:00
|
|
|
{
|
|
|
|
// Quick check, if the frames are equal they must have
|
|
|
|
// the same content
|
|
|
|
if (aFrame1 == aFrame2)
|
|
|
|
return PR_TRUE;
|
|
|
|
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
nsIContent* content1 = nsnull;
|
|
|
|
nsIContent* content2 = nsnull;
|
|
|
|
aFrame1->GetContent(&content1);
|
|
|
|
aFrame2->GetContent(&content2);
|
|
|
|
if (aFrame1 == aFrame2) {
|
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IF_RELEASE(content1);
|
|
|
|
NS_IF_RELEASE(content2);
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-04-16 19:28:12 +00:00
|
|
|
NS_IMETHODIMP
|
1999-10-26 04:44:41 +00:00
|
|
|
nsListControlFrame::CaptureMouseEvents(nsIPresContext* aPresContext, PRBool aGrabMouseEvents)
|
1999-04-16 19:28:12 +00:00
|
|
|
{
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
|
1999-04-16 19:28:12 +00:00
|
|
|
// get its view
|
|
|
|
nsIView* view = nsnull;
|
1999-10-26 04:44:41 +00:00
|
|
|
GetView(aPresContext, &view);
|
1999-04-16 19:28:12 +00:00
|
|
|
nsCOMPtr<nsIViewManager> viewMan;
|
|
|
|
PRBool result;
|
|
|
|
|
|
|
|
if (view) {
|
|
|
|
view->GetViewManager(*getter_AddRefs(viewMan));
|
|
|
|
if (viewMan) {
|
|
|
|
if (aGrabMouseEvents) {
|
|
|
|
viewMan->GrabMouseEvents(view,result);
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
mIsCapturingMouseEvents = PR_TRUE;
|
1999-04-16 19:28:12 +00:00
|
|
|
} else {
|
|
|
|
viewMan->GrabMouseEvents(nsnull,result);
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
mIsCapturingMouseEvents = PR_FALSE;
|
1999-04-16 19:28:12 +00:00
|
|
|
}
|
1999-07-28 21:38:08 +00:00
|
|
|
// XXX this is temp code
|
1999-10-06 13:36:39 +00:00
|
|
|
#if 0
|
1999-07-28 21:38:08 +00:00
|
|
|
if (!mIsScrollbarVisible) {
|
|
|
|
nsIWidget * widget;
|
|
|
|
view->GetWidget(widget);
|
|
|
|
if (nsnull != widget) {
|
|
|
|
widget->CaptureMouse(aGrabMouseEvents);
|
|
|
|
NS_RELEASE(widget);
|
|
|
|
}
|
|
|
|
}
|
1999-10-06 13:36:39 +00:00
|
|
|
#endif
|
1999-04-16 19:28:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
nsIView*
|
|
|
|
nsListControlFrame::GetViewFor(nsIWidget* aWidget)
|
1999-06-21 20:41:56 +00:00
|
|
|
{
|
|
|
|
nsIView* view = nsnull;
|
|
|
|
void* clientData;
|
|
|
|
|
|
|
|
NS_PRECONDITION(nsnull != aWidget, "null widget ptr");
|
|
|
|
|
|
|
|
// The widget's client data points back to the owning view
|
|
|
|
if (aWidget && NS_SUCCEEDED(aWidget->GetClientData(clientData))) {
|
|
|
|
view = (nsIView*)clientData;
|
|
|
|
}
|
|
|
|
|
|
|
|
return view;
|
|
|
|
}
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-06-21 20:41:56 +00:00
|
|
|
// Determine if a view is an ancestor of another view.
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
PRBool
|
|
|
|
nsListControlFrame::IsAncestor(nsIView* aAncestor, nsIView* aChild)
|
1999-06-21 20:41:56 +00:00
|
|
|
{
|
|
|
|
nsIView* view = aChild;
|
|
|
|
while (nsnull != view) {
|
|
|
|
if (view == aAncestor)
|
|
|
|
// Is an ancestor
|
|
|
|
return(PR_TRUE);
|
|
|
|
else {
|
|
|
|
view->GetParent(view);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Not an ancestor
|
|
|
|
return(PR_FALSE);
|
|
|
|
}
|
1999-04-16 19:28:12 +00:00
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsListControlFrame::HandleEvent(nsIPresContext* aPresContext,
|
1999-01-18 15:14:00 +00:00
|
|
|
nsGUIEvent* aEvent,
|
1999-11-24 06:03:41 +00:00
|
|
|
nsEventStatus* aEventStatus)
|
1999-01-18 15:14:00 +00:00
|
|
|
{
|
1999-11-24 06:03:41 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aEventStatus);
|
1999-07-28 21:38:08 +00:00
|
|
|
|
|
|
|
/*const char * desc[] = {"NS_MOUSE_MOVE",
|
1999-01-18 15:14:00 +00:00
|
|
|
"NS_MOUSE_LEFT_BUTTON_UP",
|
|
|
|
"NS_MOUSE_LEFT_BUTTON_DOWN",
|
|
|
|
"<NA>","<NA>","<NA>","<NA>","<NA>","<NA>","<NA>",
|
|
|
|
"NS_MOUSE_MIDDLE_BUTTON_UP",
|
|
|
|
"NS_MOUSE_MIDDLE_BUTTON_DOWN",
|
|
|
|
"<NA>","<NA>","<NA>","<NA>","<NA>","<NA>","<NA>","<NA>",
|
|
|
|
"NS_MOUSE_RIGHT_BUTTON_UP",
|
|
|
|
"NS_MOUSE_RIGHT_BUTTON_DOWN",
|
2000-04-24 04:41:27 +00:00
|
|
|
"NS_MOUSE_ENTER_SYNTH",
|
|
|
|
"NS_MOUSE_EXIT_SYNTH",
|
1999-01-18 15:14:00 +00:00
|
|
|
"NS_MOUSE_LEFT_DOUBLECLICK",
|
|
|
|
"NS_MOUSE_MIDDLE_DOUBLECLICK",
|
|
|
|
"NS_MOUSE_RIGHT_DOUBLECLICK",
|
|
|
|
"NS_MOUSE_LEFT_CLICK",
|
|
|
|
"NS_MOUSE_MIDDLE_CLICK",
|
|
|
|
"NS_MOUSE_RIGHT_CLICK"};
|
|
|
|
int inx = aEvent->message-NS_MOUSE_MESSAGE_START;
|
|
|
|
if (inx >= 0 && inx <= (NS_MOUSE_RIGHT_CLICK-NS_MOUSE_MESSAGE_START)) {
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("Mouse in ListFrame %s [%d]\n", desc[inx], aEvent->message);
|
1999-01-18 15:14:00 +00:00
|
|
|
} else {
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("Mouse in ListFrame <UNKNOWN> [%d]\n", aEvent->message);
|
1999-07-28 21:38:08 +00:00
|
|
|
}*/
|
|
|
|
|
1999-11-24 06:03:41 +00:00
|
|
|
if (nsEventStatus_eConsumeNoDefault == *aEventStatus)
|
1999-01-18 15:14:00 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
2000-08-08 23:38:00 +00:00
|
|
|
// do we have style that affects how we are selected?
|
|
|
|
// do we have user-input style?
|
|
|
|
const nsStyleUserInterface* uiStyle;
|
2000-08-09 00:52:02 +00:00
|
|
|
GetStyleData(eStyleStruct_UserInterface, (const nsStyleStruct *&)uiStyle);
|
2000-08-08 23:38:00 +00:00
|
|
|
if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE || uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
|
|
|
|
return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
|
|
|
|
1999-08-27 14:42:27 +00:00
|
|
|
if (nsFormFrame::GetDisabled(this))
|
1999-08-10 19:22:51 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
1999-08-27 14:42:27 +00:00
|
|
|
switch(aEvent->message) {
|
|
|
|
case NS_KEY_PRESS:
|
|
|
|
if (NS_KEY_EVENT == aEvent->eventStructType) {
|
1999-11-23 03:26:56 +00:00
|
|
|
#ifdef DEBUG_rodsXXX
|
1999-08-27 14:42:27 +00:00
|
|
|
nsKeyEvent* keyEvent = (nsKeyEvent*)aEvent;
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("---> %d %c\n", keyEvent->keyCode, keyEvent->keyCode);
|
1999-11-23 03:26:56 +00:00
|
|
|
#endif
|
1999-08-27 14:42:27 +00:00
|
|
|
//if (NS_VK_SPACE == keyEvent->keyCode || NS_VK_RETURN == keyEvent->keyCode) {
|
1999-11-24 06:03:41 +00:00
|
|
|
// MouseClicked(aPresContext);
|
1999-08-27 14:42:27 +00:00
|
|
|
//}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
|
2000-08-08 23:38:00 +00:00
|
|
|
return nsScrollFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 15:14:00 +00:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsListControlFrame::SetInitialChildList(nsIPresContext* aPresContext,
|
1999-04-27 00:06:03 +00:00
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList)
|
1999-01-18 15:14:00 +00:00
|
|
|
{
|
1999-11-11 22:13:33 +00:00
|
|
|
// First check to see if all the content has been added
|
|
|
|
nsCOMPtr<nsISelectElement> element(do_QueryInterface(mContent));
|
|
|
|
if (element) {
|
|
|
|
element->IsDoneAddingContent(&mIsAllContentHere);
|
|
|
|
if (!mIsAllContentHere) {
|
|
|
|
mIsAllFramesHere = PR_FALSE;
|
|
|
|
mHasBeenInitialized = PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nsresult rv = nsScrollFrame::SetInitialChildList(aPresContext, aListName, aChildList);
|
|
|
|
|
|
|
|
// If all the content is here now check
|
|
|
|
// to see if all the frames have been created
|
1999-11-19 15:46:20 +00:00
|
|
|
/*if (mIsAllContentHere) {
|
1999-11-11 22:13:33 +00:00
|
|
|
// If all content and frames are here
|
|
|
|
// the reset/initialize
|
|
|
|
if (CheckIfAllFramesHere()) {
|
1999-11-24 06:03:41 +00:00
|
|
|
Reset(aPresContext);
|
1999-11-12 15:00:30 +00:00
|
|
|
mHasBeenInitialized = PR_TRUE;
|
1999-11-11 22:13:33 +00:00
|
|
|
}
|
1999-11-19 15:46:20 +00:00
|
|
|
}*/
|
1999-11-11 22:13:33 +00:00
|
|
|
|
|
|
|
return rv;
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-07-20 22:32:41 +00:00
|
|
|
nsresult
|
|
|
|
nsListControlFrame::GetSizeAttribute(PRInt32 *aSize) {
|
|
|
|
nsresult rv = NS_OK;
|
1999-07-28 21:38:08 +00:00
|
|
|
nsIDOMHTMLSelectElement* selectElement;
|
2000-02-02 22:24:56 +00:00
|
|
|
rv = mContent->QueryInterface(NS_GET_IID(nsIDOMHTMLSelectElement),(void**) &selectElement);
|
1999-07-28 21:38:08 +00:00
|
|
|
if (mContent && NS_SUCCEEDED(rv)) {
|
|
|
|
rv = selectElement->GetSize(aSize);
|
|
|
|
NS_RELEASE(selectElement);
|
1999-07-20 22:32:41 +00:00
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 15:14:00 +00:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsListControlFrame::Init(nsIPresContext* aPresContext,
|
1999-02-25 03:27:57 +00:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsIFrame* aPrevInFlow)
|
1999-01-18 15:14:00 +00:00
|
|
|
{
|
1999-11-24 06:03:41 +00:00
|
|
|
mPresContext = aPresContext;
|
1999-08-26 14:54:07 +00:00
|
|
|
NS_ADDREF(mPresContext);
|
1999-02-25 03:27:57 +00:00
|
|
|
nsresult result = nsScrollFrame::Init(aPresContext, aContent, aParent, aContext,
|
|
|
|
aPrevInFlow);
|
1999-08-26 14:54:07 +00:00
|
|
|
|
|
|
|
// get the reciever interface from the browser button's content node
|
|
|
|
nsCOMPtr<nsIDOMEventReceiver> reciever(do_QueryInterface(mContent));
|
|
|
|
|
|
|
|
// we shouldn't have to unregister this listener because when
|
|
|
|
// our frame goes away all these content node go away as well
|
|
|
|
// because our frame is the only one who references them.
|
2000-08-14 14:42:12 +00:00
|
|
|
// we need to hook up our listeners before the editor is initialized
|
|
|
|
result = NS_NewListEventListener(getter_AddRefs(mEventListener));
|
|
|
|
if (NS_FAILED(result)) { return result ; }
|
|
|
|
if (!mEventListener) { return NS_ERROR_NULL_POINTER; }
|
1999-08-26 14:54:07 +00:00
|
|
|
|
2000-08-14 14:42:12 +00:00
|
|
|
mEventListener->SetFrame(this);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMMouseListener> mouseListener = do_QueryInterface(mEventListener);
|
|
|
|
if (!mouseListener) { return NS_ERROR_NO_INTERFACE; }
|
|
|
|
reciever->AddEventListenerByIID(mouseListener, NS_GET_IID(nsIDOMMouseListener));
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMMouseMotionListener> mouseMotionListener = do_QueryInterface(mEventListener);
|
|
|
|
if (!mouseMotionListener) { return NS_ERROR_NO_INTERFACE; }
|
|
|
|
reciever->AddEventListenerByIID(mouseMotionListener, NS_GET_IID(nsIDOMMouseMotionListener));
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMKeyListener> keyListener = do_QueryInterface(mEventListener);
|
|
|
|
if (!keyListener) { return NS_ERROR_NO_INTERFACE; }
|
|
|
|
reciever->AddEventListenerByIID(keyListener, NS_GET_IID(nsIDOMKeyListener));
|
1999-09-10 22:56:23 +00:00
|
|
|
|
1999-01-18 15:14:00 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 15:14:00 +00:00
|
|
|
nscoord
|
1999-11-24 06:03:41 +00:00
|
|
|
nsListControlFrame::GetVerticalInsidePadding(nsIPresContext* aPresContext,
|
1999-09-30 11:37:58 +00:00
|
|
|
float aPixToTwip,
|
|
|
|
nscoord aInnerHeight) const
|
1999-01-18 15:14:00 +00:00
|
|
|
{
|
1999-03-22 21:32:12 +00:00
|
|
|
return NSIntPixelsToTwips(0, aPixToTwip);
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 15:14:00 +00:00
|
|
|
nscoord
|
1999-11-24 06:03:41 +00:00
|
|
|
nsListControlFrame::GetHorizontalInsidePadding(nsIPresContext* aPresContext,
|
1999-09-30 11:37:58 +00:00
|
|
|
float aPixToTwip,
|
|
|
|
nscoord aInnerWidth,
|
|
|
|
nscoord aCharWidth) const
|
1999-01-18 15:14:00 +00:00
|
|
|
{
|
1999-09-30 11:37:58 +00:00
|
|
|
return GetVerticalInsidePadding(aPresContext, aPixToTwip, aInnerWidth);
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-08-26 14:54:07 +00:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// Returns whether the nsIDOMHTMLSelectElement supports
|
|
|
|
// mulitple selection
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 15:14:00 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::GetMultiple(PRBool* aMultiple, nsIDOMHTMLSelectElement* aSelect)
|
|
|
|
{
|
|
|
|
if (!aSelect) {
|
1999-07-28 21:38:08 +00:00
|
|
|
nsIDOMHTMLSelectElement* selectElement = nsnull;
|
2000-02-02 22:24:56 +00:00
|
|
|
nsresult result = mContent->QueryInterface(NS_GET_IID(nsIDOMHTMLSelectElement),
|
1999-08-26 14:54:07 +00:00
|
|
|
(void**)&selectElement);
|
1999-07-28 21:38:08 +00:00
|
|
|
if (NS_SUCCEEDED(result) && selectElement) {
|
|
|
|
result = selectElement->GetMultiple(aMultiple);
|
|
|
|
NS_RELEASE(selectElement);
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
} else {
|
|
|
|
return aSelect->GetMultiple(aMultiple);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
|
1999-08-26 14:54:07 +00:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// for a given piece of content it returns nsIDOMHTMLSelectElement object
|
|
|
|
// or null
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 15:14:00 +00:00
|
|
|
nsIDOMHTMLSelectElement*
|
|
|
|
nsListControlFrame::GetSelect(nsIContent * aContent)
|
|
|
|
{
|
1999-07-28 21:38:08 +00:00
|
|
|
nsIDOMHTMLSelectElement* selectElement = nsnull;
|
2000-02-02 22:24:56 +00:00
|
|
|
nsresult result = aContent->QueryInterface(NS_GET_IID(nsIDOMHTMLSelectElement),
|
1999-08-26 14:54:07 +00:00
|
|
|
(void**)&selectElement);
|
1999-07-28 21:38:08 +00:00
|
|
|
if (NS_SUCCEEDED(result) && selectElement) {
|
|
|
|
return selectElement;
|
1999-01-18 15:14:00 +00:00
|
|
|
} else {
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
|
1999-08-26 14:54:07 +00:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// Returns the nsIContent object in the collection
|
2000-02-12 16:21:37 +00:00
|
|
|
// for a given index (AddRefs)
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-03-22 21:32:12 +00:00
|
|
|
nsIContent*
|
1999-08-27 14:42:27 +00:00
|
|
|
nsListControlFrame::GetOptionAsContent(nsIDOMHTMLCollection* aCollection, PRInt32 aIndex)
|
1999-03-22 21:32:12 +00:00
|
|
|
{
|
2000-02-12 16:21:37 +00:00
|
|
|
nsIContent * content = nsnull;
|
|
|
|
nsCOMPtr<nsIDOMHTMLOptionElement> optionElement = getter_AddRefs(GetOption(*aCollection, aIndex));
|
2000-08-25 13:12:59 +00:00
|
|
|
|
|
|
|
NS_ASSERTION(optionElement.get() != nsnull, "could get option element by index!");
|
|
|
|
|
2000-02-12 16:21:37 +00:00
|
|
|
if (optionElement) {
|
2000-02-02 22:24:56 +00:00
|
|
|
optionElement->QueryInterface(NS_GET_IID(nsIContent),(void**) &content);
|
1999-05-17 22:36:08 +00:00
|
|
|
}
|
1999-05-27 21:17:10 +00:00
|
|
|
|
1999-05-17 22:36:08 +00:00
|
|
|
return content;
|
|
|
|
}
|
1999-03-22 21:32:12 +00:00
|
|
|
|
1999-08-26 14:54:07 +00:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// for a given index it returns the nsIContent object
|
|
|
|
// from the select
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-05-17 22:36:08 +00:00
|
|
|
nsIContent*
|
1999-08-27 14:42:27 +00:00
|
|
|
nsListControlFrame::GetOptionContent(PRInt32 aIndex)
|
1999-05-17 22:36:08 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
nsIContent* content = nsnull;
|
2000-02-12 16:21:37 +00:00
|
|
|
nsCOMPtr<nsIDOMHTMLCollection> options = getter_AddRefs(GetOptions(mContent));
|
2000-08-25 13:12:59 +00:00
|
|
|
NS_ASSERTION(options.get() != nsnull, "Collection of options is null!");
|
|
|
|
|
2000-02-12 16:21:37 +00:00
|
|
|
if (options) {
|
1999-05-17 22:36:08 +00:00
|
|
|
content = GetOptionAsContent(options, aIndex);
|
2000-08-25 13:12:59 +00:00
|
|
|
}
|
1999-05-17 22:36:08 +00:00
|
|
|
return(content);
|
1999-03-22 21:32:12 +00:00
|
|
|
}
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-08-26 14:54:07 +00:00
|
|
|
// This returns the collection for nsIDOMHTMLSelectElement or
|
2000-02-12 16:21:37 +00:00
|
|
|
// the nsIContent object is the select is null (AddRefs)
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 15:14:00 +00:00
|
|
|
nsIDOMHTMLCollection*
|
|
|
|
nsListControlFrame::GetOptions(nsIContent * aContent, nsIDOMHTMLSelectElement* aSelect)
|
|
|
|
{
|
2000-02-24 00:08:00 +00:00
|
|
|
nsIDOMNSHTMLOptionCollection* optCol = nsnull;
|
1999-01-18 15:14:00 +00:00
|
|
|
nsIDOMHTMLCollection* options = nsnull;
|
|
|
|
if (!aSelect) {
|
2000-02-12 16:21:37 +00:00
|
|
|
nsCOMPtr<nsIDOMHTMLSelectElement> selectElement = getter_AddRefs(GetSelect(aContent));
|
1999-07-28 21:38:08 +00:00
|
|
|
if (selectElement) {
|
2000-02-24 00:08:00 +00:00
|
|
|
selectElement->GetOptions(&optCol); // AddRefs (1)
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
} else {
|
2000-02-24 00:08:00 +00:00
|
|
|
aSelect->GetOptions(&optCol); // AddRefs (1)
|
|
|
|
}
|
|
|
|
if (optCol) {
|
|
|
|
nsresult res = optCol->QueryInterface(NS_GET_IID(nsIDOMHTMLCollection), (void **)&options); // AddRefs (2)
|
|
|
|
NS_RELEASE(optCol); // Release (1)
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
2000-02-24 00:08:00 +00:00
|
|
|
return options;
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
|
1999-08-26 14:54:07 +00:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// Returns the nsIDOMHTMLOptionElement for a given index
|
|
|
|
// in the select's collection
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 15:14:00 +00:00
|
|
|
nsIDOMHTMLOptionElement*
|
1999-08-27 14:42:27 +00:00
|
|
|
nsListControlFrame::GetOption(nsIDOMHTMLCollection& aCollection, PRInt32 aIndex)
|
1999-01-18 15:14:00 +00:00
|
|
|
{
|
|
|
|
nsIDOMNode* node = nsnull;
|
1999-05-17 22:36:08 +00:00
|
|
|
if (NS_SUCCEEDED(aCollection.Item(aIndex, &node))) {
|
2000-08-25 13:12:59 +00:00
|
|
|
NS_ASSERTION(nsnull != node, "Item was succussful, but node from collection was null!");
|
1999-05-17 22:36:08 +00:00
|
|
|
if (nsnull != node) {
|
|
|
|
nsIDOMHTMLOptionElement* option = nsnull;
|
2000-02-02 22:24:56 +00:00
|
|
|
node->QueryInterface(NS_GET_IID(nsIDOMHTMLOptionElement), (void**)&option);
|
1999-05-17 22:36:08 +00:00
|
|
|
NS_RELEASE(node);
|
|
|
|
return option;
|
|
|
|
}
|
2000-08-25 13:12:59 +00:00
|
|
|
} else {
|
|
|
|
NS_ASSERTION(0, "Couldn't get option by index from collection!");
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
|
1999-08-26 14:54:07 +00:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// For a given index in the collection it sets the aValue
|
|
|
|
// parameter with the "value" ATTRIBUTE from the DOM element
|
|
|
|
// This method return PR_TRUE if successful
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 15:14:00 +00:00
|
|
|
PRBool
|
1999-08-26 14:54:07 +00:00
|
|
|
nsListControlFrame::GetOptionValue(nsIDOMHTMLCollection& aCollection,
|
1999-08-27 14:42:27 +00:00
|
|
|
PRInt32 aIndex,
|
1999-08-26 14:54:07 +00:00
|
|
|
nsString& aValue)
|
1999-01-18 15:14:00 +00:00
|
|
|
{
|
|
|
|
PRBool status = PR_FALSE;
|
1999-10-14 23:41:40 +00:00
|
|
|
nsresult result = NS_OK;
|
1999-01-18 15:14:00 +00:00
|
|
|
nsIDOMHTMLOptionElement* option = GetOption(aCollection, aIndex);
|
|
|
|
if (option) {
|
1999-10-14 23:41:40 +00:00
|
|
|
// Check for value attribute on the option element.
|
|
|
|
// Can not use the return value from option->GetValue() because it
|
|
|
|
// always returns NS_OK even when the value attribute does not
|
|
|
|
// exist.
|
|
|
|
nsCOMPtr<nsIHTMLContent> optionContent;
|
|
|
|
result = option->QueryInterface(kIHTMLContentIID, getter_AddRefs(optionContent));
|
|
|
|
if (NS_SUCCEEDED(result)) {
|
|
|
|
nsHTMLValue value;
|
|
|
|
result = optionContent->GetHTMLAttribute(nsHTMLAtoms::value, value);
|
|
|
|
|
|
|
|
if (NS_CONTENT_ATTR_NOT_THERE == result) {
|
|
|
|
result = option->GetText(aValue);
|
|
|
|
if (aValue.Length() > 0) {
|
|
|
|
status = PR_TRUE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Need to use the options GetValue to get the real value because
|
|
|
|
// it does extra processing on the return value. (i.e it trims it.)
|
|
|
|
result = option->GetValue(aValue);
|
|
|
|
status = PR_TRUE;
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_RELEASE(option);
|
|
|
|
}
|
1999-10-14 23:41:40 +00:00
|
|
|
|
1999-01-18 15:14:00 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
1999-08-26 14:54:07 +00:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// For a given piece of content, it determines whether the
|
|
|
|
// content (an option) is selected or not
|
|
|
|
// return PR_TRUE if it is, PR_FALSE if it is NOT
|
|
|
|
//---------------------------------------------------------
|
|
|
|
PRBool
|
|
|
|
nsListControlFrame::IsContentSelected(nsIContent* aContent)
|
|
|
|
{
|
|
|
|
nsString value;
|
1999-09-08 14:27:38 +00:00
|
|
|
//nsIAtom * selectedAtom = NS_NewAtom("selected");
|
1999-12-06 22:59:43 +00:00
|
|
|
nsresult result = aContent->GetAttribute(kNameSpaceID_None, nsLayoutAtoms::optionSelectedPseudo, value);
|
1999-08-26 14:54:07 +00:00
|
|
|
|
|
|
|
return (NS_CONTENT_ATTR_NOT_THERE == result ? PR_FALSE : PR_TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// For a given index is return whether the content is selected
|
|
|
|
//---------------------------------------------------------
|
|
|
|
PRBool
|
1999-08-27 14:42:27 +00:00
|
|
|
nsListControlFrame::IsContentSelectedByIndex(PRInt32 aIndex)
|
1999-08-26 14:54:07 +00:00
|
|
|
{
|
|
|
|
nsIContent* content = GetOptionContent(aIndex);
|
|
|
|
NS_ASSERTION(nsnull != content, "Failed to retrieve option content");
|
|
|
|
|
|
|
|
PRBool result = IsContentSelected(content);
|
|
|
|
NS_RELEASE(content);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// gets the content (an option) by index and then set it as
|
|
|
|
// being selected or not selected
|
|
|
|
//---------------------------------------------------------
|
|
|
|
void
|
1999-08-27 03:58:13 +00:00
|
|
|
nsListControlFrame::SetContentSelected(PRInt32 aIndex, PRBool aSelected)
|
1999-08-26 14:54:07 +00:00
|
|
|
{
|
|
|
|
if (aIndex == kNothingSelected) {
|
|
|
|
return;
|
|
|
|
}
|
2000-04-19 13:55:17 +00:00
|
|
|
|
2000-08-25 13:12:59 +00:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
PRInt32 numOptions = 0;
|
|
|
|
if (NS_SUCCEEDED(GetNumberOfOptions(&numOptions))) {
|
|
|
|
if (aIndex >= numOptions || aIndex < 0) {
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("Index: %d Range 0:%d (setting to %s)\n", aIndex, numOptions, aSelected?"TRUE":"FALSE");
|
2000-08-25 13:12:59 +00:00
|
|
|
NS_ASSERTION(0, "Bad Index has been passed into SetContentSelected!");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
NS_ASSERTION(0, "Couldn't get number of options for select!");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsIContent* content = GetOptionContent(aIndex);
|
|
|
|
NS_ASSERTION(content != nsnull, "Content should not be null!");
|
|
|
|
|
|
|
|
if (content != nsnull) {
|
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
mPresContext->GetShell(getter_AddRefs(presShell));
|
2000-12-20 15:15:28 +00:00
|
|
|
if (presShell) {
|
|
|
|
nsIFrame * childframe;
|
|
|
|
nsresult result = presShell->GetPrimaryFrameFor(content, &childframe);
|
|
|
|
if (NS_SUCCEEDED(result) && childframe != nsnull) {
|
|
|
|
if (aSelected) {
|
|
|
|
DisplaySelected(content);
|
|
|
|
// Now that it is selected scroll to it
|
|
|
|
ScrollToFrame(content);
|
|
|
|
} else {
|
|
|
|
DisplayDeselected(content);
|
|
|
|
}
|
2000-04-19 13:55:17 +00:00
|
|
|
} else {
|
2000-12-20 15:15:28 +00:00
|
|
|
mDelayedIndexSetting = aIndex;
|
|
|
|
mDelayedValueSetting = aSelected;
|
2000-04-19 13:55:17 +00:00
|
|
|
}
|
1999-09-30 11:37:58 +00:00
|
|
|
}
|
2000-08-25 13:12:59 +00:00
|
|
|
NS_RELEASE(content);
|
1999-08-26 14:54:07 +00:00
|
|
|
}
|
2000-04-19 13:55:17 +00:00
|
|
|
|
1999-08-26 14:54:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// Deselects all the content items in the select
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
nsresult
|
1999-01-18 15:14:00 +00:00
|
|
|
nsListControlFrame::Deselect()
|
|
|
|
{
|
|
|
|
PRInt32 i;
|
1999-07-20 22:32:41 +00:00
|
|
|
PRInt32 max = 0;
|
2000-01-31 23:36:50 +00:00
|
|
|
if (NS_SUCCEEDED(GetNumberOfOptions(&max))) {
|
|
|
|
for (i=0;i<max;i++) {
|
|
|
|
SetContentSelected(i, PR_FALSE);
|
|
|
|
}
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
mSelectedIndex = kNothingSelected;
|
|
|
|
|
1999-01-18 15:14:00 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 15:14:00 +00:00
|
|
|
PRIntn
|
|
|
|
nsListControlFrame::GetSkipSides() const
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
{
|
|
|
|
// Don't skip any sides during border rendering
|
1999-01-18 15:14:00 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 15:14:00 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::GetType(PRInt32* aType) const
|
|
|
|
{
|
|
|
|
*aType = NS_FORM_SELECT;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 15:14:00 +00:00
|
|
|
void
|
|
|
|
nsListControlFrame::SetFormFrame(nsFormFrame* aFormFrame)
|
|
|
|
{
|
|
|
|
mFormFrame = aFormFrame;
|
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 15:14:00 +00:00
|
|
|
PRBool
|
|
|
|
nsListControlFrame::IsSuccessful(nsIFormControlFrame* aSubmitter)
|
|
|
|
{
|
|
|
|
nsAutoString name;
|
2000-08-03 23:32:02 +00:00
|
|
|
PRBool disabled = PR_FALSE;
|
|
|
|
nsFormControlHelper::GetDisabled(mContent, &disabled);
|
|
|
|
return !disabled && (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name));
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 15:14:00 +00:00
|
|
|
void
|
|
|
|
nsListControlFrame::MouseClicked(nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
}
|
1999-03-22 21:32:12 +00:00
|
|
|
|
1999-07-20 22:32:41 +00:00
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 15:14:00 +00:00
|
|
|
PRInt32
|
|
|
|
nsListControlFrame::GetMaxNumValues()
|
|
|
|
{
|
|
|
|
PRBool multiple;
|
|
|
|
GetMultiple(&multiple);
|
|
|
|
if (multiple) {
|
|
|
|
PRUint32 length = 0;
|
|
|
|
nsIDOMHTMLCollection* options = GetOptions(mContent);
|
|
|
|
if (options) {
|
|
|
|
options->GetLength(&length);
|
1999-09-24 13:49:12 +00:00
|
|
|
NS_RELEASE(options);
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
return (PRInt32)length; // XXX fix return on GetMaxNumValues
|
|
|
|
} else {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-26 14:54:07 +00:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// Resets the select back to it's original default values;
|
|
|
|
// those values as determined by the original HTML
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 15:14:00 +00:00
|
|
|
void
|
1999-10-26 04:44:41 +00:00
|
|
|
nsListControlFrame::Reset(nsIPresContext* aPresContext)
|
1999-01-18 15:14:00 +00:00
|
|
|
{
|
2000-08-03 14:13:58 +00:00
|
|
|
REFLOW_DEBUG_MSG("LBX::Reset\n");
|
|
|
|
|
1999-11-11 22:13:33 +00:00
|
|
|
// if all the frames aren't here
|
|
|
|
// don't bother reseting
|
|
|
|
if (!mIsAllFramesHere) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMHTMLCollection> options = getter_AddRefs(GetOptions(mContent));
|
1999-01-18 15:14:00 +00:00
|
|
|
if (!options) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-03-03 04:28:59 +00:00
|
|
|
// Check here to see if this listbox has has its state restored
|
|
|
|
// Either by being a list or by being a dropdown.
|
|
|
|
// if we have been restored then we don't set any of the default selections
|
|
|
|
PRBool hasBeenRestored = mPresState != nsnull;
|
|
|
|
|
1999-01-18 15:14:00 +00:00
|
|
|
PRUint32 numOptions;
|
|
|
|
options->GetLength(&numOptions);
|
|
|
|
|
2000-01-18 23:33:22 +00:00
|
|
|
mSelectedIndex = kNothingSelected;
|
|
|
|
mStartExtendedIndex = kNothingSelected;
|
|
|
|
mEndExtendedIndex = kNothingSelected;
|
|
|
|
PRBool multiple;
|
|
|
|
GetMultiple(&multiple);
|
1999-11-01 15:41:17 +00:00
|
|
|
|
2000-03-03 04:28:59 +00:00
|
|
|
Deselect();
|
2000-02-15 15:04:38 +00:00
|
|
|
|
2000-03-03 04:28:59 +00:00
|
|
|
// Clear the cache and set the default selections
|
|
|
|
// if we havn't been restored
|
2000-02-15 15:04:38 +00:00
|
|
|
mSelectionCache->Clear();
|
|
|
|
mSelectionCacheLength = 0;
|
1999-08-26 14:54:07 +00:00
|
|
|
PRUint32 i;
|
|
|
|
for (i = 0; i < numOptions; i++) {
|
1999-11-11 22:13:33 +00:00
|
|
|
nsCOMPtr<nsIDOMHTMLOptionElement> option = getter_AddRefs(GetOption(*options, i));
|
1999-01-18 15:14:00 +00:00
|
|
|
if (option) {
|
|
|
|
PRBool selected = PR_FALSE;
|
2000-03-03 04:28:59 +00:00
|
|
|
if (!hasBeenRestored) {
|
|
|
|
option->GetDefaultSelected(&selected);
|
|
|
|
}
|
2000-02-15 15:04:38 +00:00
|
|
|
|
|
|
|
mSelectionCache->AppendElement((void*)selected);
|
|
|
|
mSelectionCacheLength++;
|
|
|
|
|
1999-01-18 15:14:00 +00:00
|
|
|
if (selected) {
|
2000-12-20 15:15:28 +00:00
|
|
|
if (mSelectedIndex == kNothingSelected ||
|
|
|
|
(mSelectedIndex != kNothingSelected && multiple)) {
|
|
|
|
mSelectedIndex = i;
|
|
|
|
SetContentSelected(i, PR_TRUE);
|
|
|
|
if (multiple) {
|
|
|
|
mStartExtendedIndex = i;
|
|
|
|
if (mEndExtendedIndex == kNothingSelected) {
|
|
|
|
mEndExtendedIndex = i;
|
|
|
|
}
|
2000-01-18 23:33:22 +00:00
|
|
|
}
|
2000-12-20 15:15:28 +00:00
|
|
|
} else {
|
|
|
|
SetContentSelected(mSelectedIndex, PR_FALSE);
|
|
|
|
mSelectionCache->ReplaceElementAt((void*)PR_FALSE, mSelectedIndex);
|
|
|
|
mSelectedIndex = i;
|
|
|
|
SetContentSelected(i, PR_TRUE);
|
1999-11-11 22:13:33 +00:00
|
|
|
}
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-10-05 23:43:06 +00:00
|
|
|
|
2000-03-03 04:28:59 +00:00
|
|
|
// Ok, so we were restored, now set the last known selections from the restore state.
|
|
|
|
if (hasBeenRestored) {
|
|
|
|
nsCOMPtr<nsISupports> supp;
|
2001-02-06 01:59:59 +00:00
|
|
|
mPresState->GetStatePropertyAsSupports(NS_LITERAL_STRING("selecteditems"), getter_AddRefs(supp));
|
2000-03-03 04:28:59 +00:00
|
|
|
|
|
|
|
nsresult res = NS_ERROR_NULL_POINTER;
|
|
|
|
if (!supp)
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsCOMPtr<nsISupportsArray> value = do_QueryInterface(supp);
|
|
|
|
if (!value)
|
|
|
|
return;
|
|
|
|
|
|
|
|
PRUint32 count = 0;
|
|
|
|
value->Count(&count);
|
2000-02-15 15:04:38 +00:00
|
|
|
|
2000-03-03 04:28:59 +00:00
|
|
|
nsCOMPtr<nsISupportsPRInt32> thisVal;
|
|
|
|
PRInt32 j=0;
|
2000-03-28 15:11:16 +00:00
|
|
|
for (i=0; i<count; i++) {
|
2000-03-03 04:28:59 +00:00
|
|
|
nsCOMPtr<nsISupports> suppval = getter_AddRefs(value->ElementAt(i));
|
|
|
|
thisVal = do_QueryInterface(suppval);
|
|
|
|
if (thisVal) {
|
|
|
|
res = thisVal->GetData(&j);
|
|
|
|
if (NS_SUCCEEDED(res)) {
|
|
|
|
mSelectedIndex = j;
|
|
|
|
SetContentSelected(j, PR_TRUE);// might want to use ToggleSelection
|
|
|
|
mSelectionCache->ReplaceElementAt((void*)PR_TRUE, j);
|
|
|
|
if (multiple) {
|
|
|
|
mStartExtendedIndex = j;
|
|
|
|
if (mEndExtendedIndex == kNothingSelected) {
|
|
|
|
mEndExtendedIndex = j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
res = NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
if (!NS_SUCCEEDED(res)) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-02-15 15:04:38 +00:00
|
|
|
if (mComboboxFrame != nsnull) {
|
|
|
|
if (mSelectedIndex == kNothingSelected) {
|
|
|
|
mComboboxFrame->MakeSureSomethingIsSelected(mPresContext);
|
|
|
|
} else {
|
|
|
|
mComboboxFrame->UpdateSelection(PR_FALSE, PR_TRUE, mSelectedIndex); // don't dispatch event
|
|
|
|
}
|
1999-11-16 22:47:23 +00:00
|
|
|
}
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 15:14:00 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::GetName(nsString* aResult)
|
|
|
|
{
|
|
|
|
nsresult result = NS_FORM_NOTOK;
|
|
|
|
if (mContent) {
|
|
|
|
nsIHTMLContent* formControl = nsnull;
|
2000-02-02 22:24:56 +00:00
|
|
|
result = mContent->QueryInterface(NS_GET_IID(nsIHTMLContent),(void**)&formControl);
|
1999-07-28 21:38:08 +00:00
|
|
|
if (NS_SUCCEEDED(result) && formControl) {
|
1999-01-18 15:14:00 +00:00
|
|
|
nsHTMLValue value;
|
|
|
|
result = formControl->GetHTMLAttribute(nsHTMLAtoms::name, value);
|
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == result) {
|
|
|
|
if (eHTMLUnit_String == value.GetUnit()) {
|
|
|
|
value.GetStringValue(*aResult);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_RELEASE(formControl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-07-20 22:32:41 +00:00
|
|
|
PRInt32
|
|
|
|
nsListControlFrame::GetNumberOfSelections()
|
|
|
|
{
|
|
|
|
PRInt32 count = 0;
|
|
|
|
PRInt32 length = 0;
|
|
|
|
GetNumberOfOptions(&length);
|
|
|
|
PRInt32 i = 0;
|
|
|
|
for (i = 0; i < length; i++) {
|
1999-08-26 14:54:07 +00:00
|
|
|
if (IsContentSelectedByIndex(i)) {
|
1999-07-20 22:32:41 +00:00
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(count);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 15:14:00 +00:00
|
|
|
PRBool
|
|
|
|
nsListControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
|
|
|
nsString* aValues, nsString* aNames)
|
|
|
|
{
|
|
|
|
aNumValues = 0;
|
|
|
|
nsAutoString name;
|
|
|
|
nsresult result = GetName(&name);
|
|
|
|
if ((aMaxNumValues <= 0) || (NS_CONTENT_ATTR_NOT_THERE == result)) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2000-02-12 16:21:37 +00:00
|
|
|
nsCOMPtr<nsIDOMHTMLCollection> options = getter_AddRefs(GetOptions(mContent));
|
1999-01-18 15:14:00 +00:00
|
|
|
if (!options) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
1999-07-20 22:32:41 +00:00
|
|
|
PRBool status = PR_FALSE;
|
|
|
|
PRBool multiple;
|
|
|
|
GetMultiple(&multiple);
|
|
|
|
if (!multiple) {
|
|
|
|
if (mSelectedIndex >= 0) {
|
|
|
|
nsAutoString value;
|
|
|
|
GetOptionValue(*options, mSelectedIndex, value);
|
1999-12-14 14:16:09 +00:00
|
|
|
value.CompressWhitespace();
|
1999-07-20 22:32:41 +00:00
|
|
|
aNumValues = 1;
|
|
|
|
aNames[0] = name;
|
|
|
|
aValues[0] = value;
|
|
|
|
status = PR_TRUE;
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
1999-07-20 22:32:41 +00:00
|
|
|
}
|
|
|
|
else {
|
1999-01-18 15:14:00 +00:00
|
|
|
aNumValues = 0;
|
1999-07-20 22:32:41 +00:00
|
|
|
PRInt32 length = 0;
|
|
|
|
GetNumberOfOptions(&length);
|
|
|
|
for (int i = 0; i < length; i++) {
|
1999-08-26 14:54:07 +00:00
|
|
|
if (PR_TRUE == IsContentSelectedByIndex(i)) {
|
1999-07-20 22:32:41 +00:00
|
|
|
nsAutoString value;
|
|
|
|
GetOptionValue(*options, i, value);
|
|
|
|
aNames[aNumValues] = name;
|
|
|
|
aValues[aNumValues] = value;
|
|
|
|
aNumValues++;
|
|
|
|
}
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
status = PR_TRUE;
|
1999-07-20 22:32:41 +00:00
|
|
|
}
|
1999-01-18 15:14:00 +00:00
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 15:14:00 +00:00
|
|
|
void
|
|
|
|
nsListControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
|
|
|
|
{
|
1999-05-17 22:36:08 +00:00
|
|
|
// XXX:TODO Make set focus work
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
|
1999-08-21 00:09:24 +00:00
|
|
|
//---------------------------------------------------------
|
|
|
|
void
|
|
|
|
nsListControlFrame::ScrollIntoView(nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
if (aPresContext) {
|
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
aPresContext->GetShell(getter_AddRefs(presShell));
|
2000-09-08 05:53:28 +00:00
|
|
|
if (presShell) {
|
|
|
|
presShell->ScrollFrameIntoView(this,
|
2000-01-25 22:19:39 +00:00
|
|
|
NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE);
|
2000-09-08 05:53:28 +00:00
|
|
|
}
|
1999-08-21 00:09:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 15:14:00 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::SetComboboxFrame(nsIFrame* aComboboxFrame)
|
|
|
|
{
|
1999-05-27 21:17:10 +00:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
if (nsnull != aComboboxFrame) {
|
2000-02-02 22:24:56 +00:00
|
|
|
rv = aComboboxFrame->QueryInterface(NS_GET_IID(nsIComboboxControlFrame),(void**) &mComboboxFrame);
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
1999-05-27 21:17:10 +00:00
|
|
|
return rv;
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
|
1999-08-26 14:54:07 +00:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// Gets the text of the currently selected item
|
|
|
|
// if the there are zero items then an empty string is returned
|
|
|
|
// if there is nothing selected, then the 0th item's text is returned
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 15:14:00 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::GetSelectedItem(nsString & aStr)
|
|
|
|
{
|
2000-04-16 11:19:26 +00:00
|
|
|
aStr.SetLength(0);
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
2000-02-12 16:21:37 +00:00
|
|
|
nsCOMPtr<nsIDOMHTMLCollection> options = getter_AddRefs(GetOptions(mContent));
|
1999-08-26 14:54:07 +00:00
|
|
|
|
2000-02-12 16:21:37 +00:00
|
|
|
if (options) {
|
1999-08-26 14:54:07 +00:00
|
|
|
PRUint32 numOptions;
|
|
|
|
options->GetLength(&numOptions);
|
|
|
|
|
|
|
|
if (numOptions == 0) {
|
|
|
|
rv = NS_OK;
|
|
|
|
} else {
|
2000-02-12 16:21:37 +00:00
|
|
|
nsCOMPtr<nsIDOMHTMLOptionElement> optionElement = getter_AddRefs(GetOption(*options, mSelectedIndex));
|
|
|
|
if (optionElement) {
|
2000-06-15 13:00:23 +00:00
|
|
|
#if 0 // This is for turning off labels Bug 4050
|
1999-08-26 14:54:07 +00:00
|
|
|
nsAutoString text;
|
1999-09-10 22:56:23 +00:00
|
|
|
rv = optionElement->GetLabel(text);
|
2000-02-12 16:21:37 +00:00
|
|
|
// the return value is always NS_OK from DOMElements
|
|
|
|
// it is meaningless to check for it
|
|
|
|
if (text.Length() > 0) {
|
|
|
|
nsAutoString compressText = text;
|
|
|
|
compressText.CompressWhitespace(PR_TRUE, PR_TRUE);
|
|
|
|
if (compressText.Length() != 0) {
|
|
|
|
text = compressText;
|
1999-09-10 22:56:23 +00:00
|
|
|
}
|
2000-02-12 16:21:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (0 == text.Length()) {
|
|
|
|
// the return value is always NS_OK from DOMElements
|
|
|
|
// it is meaningless to check for it
|
|
|
|
optionElement->GetText(text);
|
1999-09-10 22:56:23 +00:00
|
|
|
}
|
2000-02-12 16:21:37 +00:00
|
|
|
aStr = text;
|
2000-06-15 13:00:23 +00:00
|
|
|
#else
|
|
|
|
optionElement->GetText(aStr);
|
|
|
|
#endif
|
2000-02-12 16:21:37 +00:00
|
|
|
rv = NS_OK;
|
1999-05-27 21:17:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-08-19 14:11:28 +00:00
|
|
|
//---------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::GetSelectedIndex(PRInt32 * aIndex)
|
|
|
|
{
|
|
|
|
*aIndex = mSelectedIndex;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-26 14:54:07 +00:00
|
|
|
//---------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::GetSelectedIndexFromDOM(PRInt32 * aIndex)
|
|
|
|
{
|
|
|
|
// figure out which item is selected by looking at which
|
|
|
|
// option are selected
|
|
|
|
*aIndex = kNothingSelected;
|
2000-02-12 16:21:37 +00:00
|
|
|
nsCOMPtr<nsIDOMHTMLCollection> options = getter_AddRefs(GetOptions(mContent));
|
1999-08-26 14:54:07 +00:00
|
|
|
if (options) {
|
|
|
|
PRUint32 numOptions;
|
|
|
|
options->GetLength(&numOptions);
|
|
|
|
|
|
|
|
PRUint32 inx;
|
|
|
|
for (inx = 0; inx < numOptions && (*aIndex == kNothingSelected); inx++) {
|
2000-02-12 16:21:37 +00:00
|
|
|
nsCOMPtr<nsIContent> content = getter_AddRefs(GetOptionAsContent(options, inx));
|
1999-08-26 14:54:07 +00:00
|
|
|
if (nsnull != content) {
|
|
|
|
if (IsContentSelected(content)) {
|
|
|
|
*aIndex = (PRInt32)inx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
|
|
|
PRBool
|
|
|
|
nsListControlFrame::IsInDropDownMode()
|
1999-05-27 21:17:10 +00:00
|
|
|
{
|
|
|
|
return((nsnull == mComboboxFrame) ? PR_FALSE : PR_TRUE);
|
1999-01-18 15:14:00 +00:00
|
|
|
}
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
|
|
|
nsresult
|
|
|
|
nsListControlFrame::RequiresWidget(PRBool& aRequiresWidget)
|
1999-01-25 22:16:27 +00:00
|
|
|
{
|
1999-04-12 22:14:31 +00:00
|
|
|
aRequiresWidget = PR_FALSE;
|
1999-01-25 22:16:27 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-07-20 22:32:41 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::GetNumberOfOptions(PRInt32* aNumOptions)
|
1999-04-12 22:14:31 +00:00
|
|
|
{
|
2000-01-31 23:36:50 +00:00
|
|
|
if (mContent != nsnull) {
|
2000-02-12 16:21:37 +00:00
|
|
|
nsCOMPtr<nsIDOMHTMLCollection> options = getter_AddRefs(GetOptions(mContent));
|
2000-01-31 23:36:50 +00:00
|
|
|
if (nsnull == options) {
|
|
|
|
*aNumOptions = 0;
|
|
|
|
} else {
|
|
|
|
PRUint32 length = 0;
|
|
|
|
options->GetLength(&length);
|
|
|
|
*aNumOptions = (PRInt32)length;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
1999-04-12 22:14:31 +00:00
|
|
|
}
|
2000-01-31 23:36:50 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
1999-04-12 22:14:31 +00:00
|
|
|
}
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-05-07 20:30:16 +00:00
|
|
|
// Select the specified item in the listbox using control logic.
|
|
|
|
// If it a single selection listbox the previous selection will be
|
|
|
|
// de-selected.
|
|
|
|
void
|
1999-05-27 21:17:10 +00:00
|
|
|
nsListControlFrame::ToggleSelected(PRInt32 aIndex)
|
1999-05-07 20:30:16 +00:00
|
|
|
{
|
|
|
|
PRBool multiple;
|
|
|
|
GetMultiple(&multiple);
|
|
|
|
|
|
|
|
if (PR_TRUE == multiple) {
|
1999-08-26 14:54:07 +00:00
|
|
|
SetContentSelected(aIndex, PR_TRUE);
|
1999-05-07 20:30:16 +00:00
|
|
|
} else {
|
1999-08-26 14:54:07 +00:00
|
|
|
SetContentSelected(mSelectedIndex, PR_FALSE);
|
|
|
|
SetContentSelected(aIndex, PR_TRUE);
|
1999-05-27 21:17:10 +00:00
|
|
|
mSelectedIndex = aIndex;
|
1999-05-07 20:30:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-26 14:54:07 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISelectControlFrame
|
|
|
|
//----------------------------------------------------------------------
|
1999-11-11 22:13:33 +00:00
|
|
|
PRBool nsListControlFrame::CheckIfAllFramesHere()
|
|
|
|
{
|
|
|
|
// Get the number of optgroups and options
|
1999-12-28 19:41:57 +00:00
|
|
|
//PRInt32 numContentItems = 0;
|
1999-11-11 22:13:33 +00:00
|
|
|
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(mContent));
|
|
|
|
if (node) {
|
1999-12-08 00:08:41 +00:00
|
|
|
// XXX Need to find a fail proff way to determine that
|
|
|
|
// all the frames are there
|
|
|
|
mIsAllFramesHere = PR_TRUE;//NS_OK == CountAllChild(node, numContentItems);
|
1999-11-11 22:13:33 +00:00
|
|
|
}
|
|
|
|
// now make sure we have a frame each piece of content
|
|
|
|
|
|
|
|
return mIsAllFramesHere;
|
|
|
|
}
|
|
|
|
|
2000-02-15 15:04:38 +00:00
|
|
|
//-------------------------------------------------------------------
|
1999-11-11 22:13:33 +00:00
|
|
|
NS_IMETHODIMP
|
1999-11-19 15:46:20 +00:00
|
|
|
nsListControlFrame::DoneAddingContent(PRBool aIsDone)
|
1999-11-11 22:13:33 +00:00
|
|
|
{
|
1999-11-19 15:46:20 +00:00
|
|
|
mIsAllContentHere = aIsDone;
|
|
|
|
if (mIsAllContentHere) {
|
|
|
|
// Here we check to see if all the frames have been created
|
|
|
|
// for all the content.
|
|
|
|
// If so, then we can initialize;
|
|
|
|
if (mIsAllFramesHere == PR_FALSE) {
|
|
|
|
// if all the frames are now present we can initalize
|
|
|
|
if (CheckIfAllFramesHere() && mPresContext) {
|
|
|
|
mHasBeenInitialized = PR_TRUE;
|
|
|
|
Reset(mPresContext);
|
|
|
|
}
|
1999-11-11 22:13:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-02-15 15:04:38 +00:00
|
|
|
//-------------------------------------------------------------------
|
1999-08-26 14:54:07 +00:00
|
|
|
NS_IMETHODIMP
|
1999-10-26 04:44:41 +00:00
|
|
|
nsListControlFrame::AddOption(nsIPresContext* aPresContext, PRInt32 aIndex)
|
1999-08-26 14:54:07 +00:00
|
|
|
{
|
2000-03-03 04:28:59 +00:00
|
|
|
#ifdef DO_REFLOW_DEBUG
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("---- Id: %d nsLCF %p Added Option %d\n", mReflowId, this, aIndex);
|
2000-03-03 04:28:59 +00:00
|
|
|
#endif
|
|
|
|
|
1999-11-11 22:13:33 +00:00
|
|
|
if (!mIsAllContentHere) {
|
|
|
|
nsCOMPtr<nsISelectElement> element(do_QueryInterface(mContent));
|
|
|
|
if (element) {
|
|
|
|
element->IsDoneAddingContent(&mIsAllContentHere);
|
|
|
|
if (!mIsAllContentHere) {
|
|
|
|
mIsAllFramesHere = PR_FALSE;
|
|
|
|
mHasBeenInitialized = PR_FALSE;
|
|
|
|
} else {
|
|
|
|
PRInt32 numOptions;
|
|
|
|
GetNumberOfOptions(&numOptions);
|
|
|
|
mIsAllFramesHere = aIndex == numOptions-1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-11-12 15:00:30 +00:00
|
|
|
|
1999-11-11 22:13:33 +00:00
|
|
|
if (!mHasBeenInitialized) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-01 15:41:17 +00:00
|
|
|
PRInt32 oldSelection = mSelectedIndex;
|
1999-08-26 14:54:07 +00:00
|
|
|
|
1999-10-12 08:47:29 +00:00
|
|
|
// Adding an option to the select can cause a change in selection
|
|
|
|
// if the new option has it's selected attribute set.
|
1999-11-01 15:41:17 +00:00
|
|
|
// this code checks to see if it does
|
|
|
|
// if so then it resets the entire selection of listbox
|
|
|
|
PRBool wasReset = PR_FALSE;
|
1999-11-09 13:41:27 +00:00
|
|
|
nsCOMPtr<nsIDOMHTMLCollection> options = getter_AddRefs(GetOptions(mContent));
|
1999-11-01 15:41:17 +00:00
|
|
|
if (options) {
|
1999-11-09 13:41:27 +00:00
|
|
|
nsCOMPtr<nsIDOMHTMLOptionElement> option = getter_AddRefs(GetOption(*options, aIndex));
|
1999-11-01 15:41:17 +00:00
|
|
|
if (option) {
|
|
|
|
PRBool selected = PR_FALSE;
|
|
|
|
option->GetDefaultSelected(&selected);
|
2000-02-15 15:04:38 +00:00
|
|
|
|
|
|
|
mSelectionCache->InsertElementAt((void*)selected, aIndex);
|
|
|
|
mSelectionCacheLength++;
|
|
|
|
|
1999-11-01 15:41:17 +00:00
|
|
|
if (selected) {
|
2000-02-15 15:04:38 +00:00
|
|
|
Reset(aPresContext); // this sets mSelectedIndex to the defaulted selection
|
1999-11-01 15:41:17 +00:00
|
|
|
wasReset = PR_TRUE;
|
|
|
|
}
|
2000-02-09 19:34:39 +00:00
|
|
|
|
2000-08-03 14:13:58 +00:00
|
|
|
#ifdef DEBUG_rods
|
2000-02-09 19:34:39 +00:00
|
|
|
{
|
2000-08-03 14:13:58 +00:00
|
|
|
nsAutoString text;
|
|
|
|
text.AssignWithConversion("No Value");
|
2000-02-09 19:34:39 +00:00
|
|
|
nsresult rv = option->GetLabel(text);
|
|
|
|
if (NS_CONTENT_ATTR_NOT_THERE == rv || 0 == text.Length()) {
|
|
|
|
option->GetText(text);
|
|
|
|
}
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("|||||this %p Index: %d [%s] CB: %p\n", this, aIndex, text.ToNewCString(), mComboboxFrame); //leaks
|
2000-02-09 19:34:39 +00:00
|
|
|
}
|
|
|
|
#endif
|
1999-11-01 15:41:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!wasReset) {
|
|
|
|
GetSelectedIndexFromDOM(&mSelectedIndex); // comes from the DOM
|
|
|
|
}
|
|
|
|
|
|
|
|
// if selection changed because of the new option being added
|
|
|
|
// notify the combox if necessary
|
2000-02-15 15:04:38 +00:00
|
|
|
if (mComboboxFrame != nsnull) {
|
|
|
|
if (mSelectedIndex == kNothingSelected) {
|
|
|
|
mComboboxFrame->MakeSureSomethingIsSelected(mPresContext);
|
|
|
|
} else if (oldSelection != mSelectedIndex) {
|
|
|
|
mComboboxFrame->UpdateSelection(PR_FALSE, PR_TRUE, mSelectedIndex); // don't dispatch event
|
|
|
|
}
|
1999-11-01 15:41:17 +00:00
|
|
|
}
|
|
|
|
|
1999-08-26 14:54:07 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-02-15 15:04:38 +00:00
|
|
|
//-------------------------------------------------------------------
|
1999-08-26 14:54:07 +00:00
|
|
|
NS_IMETHODIMP
|
1999-10-26 04:44:41 +00:00
|
|
|
nsListControlFrame::RemoveOption(nsIPresContext* aPresContext, PRInt32 aIndex)
|
1999-08-26 14:54:07 +00:00
|
|
|
{
|
|
|
|
PRInt32 numOptions;
|
|
|
|
GetNumberOfOptions(&numOptions);
|
|
|
|
|
1999-10-12 08:47:29 +00:00
|
|
|
// PRInt32 oldSelectedIndex = mSelectedIndex;
|
|
|
|
GetSelectedIndexFromDOM(&mSelectedIndex); // comes from the DOM
|
1999-08-26 14:54:07 +00:00
|
|
|
|
1999-10-12 08:47:29 +00:00
|
|
|
// Select the new selectedIndex
|
|
|
|
// Don't need to deselect option as it is being removed anyway.
|
|
|
|
if (mSelectedIndex >= 0) {
|
|
|
|
SetContentSelected(mSelectedIndex, PR_TRUE);
|
1999-08-26 14:54:07 +00:00
|
|
|
}
|
|
|
|
|
2000-02-15 15:04:38 +00:00
|
|
|
mSelectionCache->RemoveElementAt(aIndex);
|
|
|
|
mSelectionCacheLength--;
|
1999-10-12 08:47:29 +00:00
|
|
|
|
1999-08-26 14:54:07 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-08-27 03:58:13 +00:00
|
|
|
|
2000-12-20 15:15:28 +00:00
|
|
|
#ifdef FIX_FOR_BUG_50376
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
nsresult nsListControlFrame::GetPresStateAndValueArray(nsISupportsArray ** aSuppArray)
|
|
|
|
{
|
|
|
|
// Basically we need to check for and/or create
|
|
|
|
// both the PresState and the Supports Array
|
|
|
|
// There may already be a no PresState and no Supports Array
|
|
|
|
// or there may be PresState and no Supports Array
|
|
|
|
// or there may be both
|
|
|
|
|
|
|
|
// So assume we need to create the supports array and
|
|
|
|
//flip it off if we don't
|
|
|
|
PRBool createSupportsArray = PR_TRUE;
|
|
|
|
|
|
|
|
nsresult res = NS_ERROR_FAILURE;
|
|
|
|
if (mPresState) {
|
|
|
|
nsCOMPtr<nsISupports> supp;
|
2001-02-06 01:59:59 +00:00
|
|
|
mPresState->GetStatePropertyAsSupports(NS_LITERAL_STRING("selecteditems"), getter_AddRefs(supp));
|
2000-12-20 15:15:28 +00:00
|
|
|
if (supp) {
|
|
|
|
res = supp->QueryInterface(NS_GET_IID(nsISupportsArray), (void**)aSuppArray);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
createSupportsArray = PR_FALSE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
NS_NewPresState(getter_AddRefs(mPresState));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (createSupportsArray) {
|
|
|
|
res = NS_NewISupportsArray(aSuppArray);
|
|
|
|
if (NS_SUCCEEDED(res)) {
|
2001-02-06 01:59:59 +00:00
|
|
|
res = mPresState->SetStatePropertyAsSupports(NS_LITERAL_STRING("selecteditems"), *aSuppArray);
|
2000-12-20 15:15:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
nsresult nsListControlFrame::SetSelectionInPresState(PRInt32 aIndex, PRBool aValue)
|
|
|
|
{
|
|
|
|
// if there is no PresState and we ned to remove it
|
|
|
|
// from the PresState, then there is nothing to do
|
|
|
|
if (!mPresState && !aValue) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsISupportsArray> suppArray;
|
|
|
|
nsresult res = GetPresStateAndValueArray(getter_AddRefs(suppArray));
|
|
|
|
|
|
|
|
if (NS_FAILED(res) || !suppArray)
|
|
|
|
return res;
|
|
|
|
|
|
|
|
if (aValue) {
|
|
|
|
PRUint32 count;
|
|
|
|
suppArray->Count(&count);
|
|
|
|
return SetOptionIntoPresState(suppArray, aIndex, count);
|
|
|
|
} else {
|
|
|
|
return RemoveOptionFromPresState(suppArray, aIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
nsresult nsListControlFrame::RemoveOptionFromPresState(nsISupportsArray * aSuppArray,
|
|
|
|
PRInt32 aIndex)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aSuppArray);
|
|
|
|
nsresult res = NS_ERROR_FAILURE;
|
|
|
|
PRUint32 count;
|
|
|
|
aSuppArray->Count(&count);
|
|
|
|
nsCOMPtr<nsISupportsPRInt32> thisVal;
|
|
|
|
for (PRUint32 i=0; i<count; i++) {
|
|
|
|
nsCOMPtr<nsISupports> suppval = getter_AddRefs(aSuppArray->ElementAt(i));
|
|
|
|
thisVal = do_QueryInterface(suppval);
|
|
|
|
if (thisVal) {
|
|
|
|
PRInt32 optIndex;
|
|
|
|
res = thisVal->GetData(&optIndex);
|
|
|
|
if (NS_SUCCEEDED(res)) {
|
|
|
|
if (optIndex == aIndex) {
|
|
|
|
aSuppArray->RemoveElementAt(i);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
res = NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
if (NS_FAILED(res)) break;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
nsresult nsListControlFrame::SetOptionIntoPresState(nsISupportsArray * aSuppArray,
|
|
|
|
PRInt32 aIndex,
|
|
|
|
PRInt32 anItemNum)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aSuppArray);
|
|
|
|
nsCOMPtr<nsISupportsPRInt32> thisVal;
|
|
|
|
nsresult res = nsComponentManager::CreateInstance(NS_SUPPORTS_PRINT32_CONTRACTID,
|
|
|
|
nsnull, NS_GET_IID(nsISupportsPRInt32), (void**)getter_AddRefs(thisVal));
|
|
|
|
if (NS_SUCCEEDED(res) && thisVal) {
|
|
|
|
res = thisVal->SetData(aIndex);
|
|
|
|
if (NS_SUCCEEDED(res)) {
|
|
|
|
PRBool okay = aSuppArray->InsertElementAt((nsISupports *)thisVal, anItemNum);
|
|
|
|
if (!okay) res = NS_ERROR_OUT_OF_MEMORY; // Most likely cause;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // FIX_FOR_BUG_50376
|
|
|
|
|
1999-08-27 03:58:13 +00:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// Select the specified item in the listbox using control logic.
|
|
|
|
// If it a single selection listbox the previous selection will be
|
|
|
|
// de-selected.
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::SetOptionSelected(PRInt32 aIndex, PRBool aValue)
|
|
|
|
{
|
2000-12-20 15:15:28 +00:00
|
|
|
#ifdef FIX_FOR_BUG_50376
|
|
|
|
if (!mIsAllFramesHere && !mHasBeenInitialized) {
|
|
|
|
return SetSelectionInPresState(aIndex, aValue);
|
|
|
|
}
|
|
|
|
#endif // FIX_FOR_BUG_50376
|
|
|
|
|
1999-08-27 03:58:13 +00:00
|
|
|
PRBool multiple;
|
1999-09-16 22:36:29 +00:00
|
|
|
nsresult rv = GetMultiple(&multiple);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
1999-08-27 03:58:13 +00:00
|
|
|
if (aValue) {
|
1999-09-16 22:36:29 +00:00
|
|
|
ToggleSelected(aIndex); // sets mSelectedIndex
|
1999-08-27 03:58:13 +00:00
|
|
|
} else {
|
1999-09-16 22:36:29 +00:00
|
|
|
SetContentSelected(aIndex, aValue);
|
|
|
|
if (!multiple) {
|
|
|
|
// Get the new selIndex from the DOM (may have changed)
|
|
|
|
PRInt32 selectedIndex;
|
|
|
|
GetSelectedIndexFromDOM(&selectedIndex);
|
|
|
|
if (mSelectedIndex != selectedIndex) {
|
|
|
|
ToggleSelected(selectedIndex); // sets mSelectedIndex
|
|
|
|
}
|
1999-08-27 03:58:13 +00:00
|
|
|
}
|
|
|
|
}
|
1999-10-05 23:43:06 +00:00
|
|
|
// Should we send an event here or not?
|
1999-11-11 22:13:33 +00:00
|
|
|
if (nsnull != mComboboxFrame && mIsAllFramesHere) {
|
1999-09-16 22:36:29 +00:00
|
|
|
rv = mComboboxFrame->UpdateSelection(PR_FALSE, PR_TRUE, aIndex); // don't dispatch event
|
1999-10-05 23:43:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Compare content state with local cache of last known state
|
|
|
|
// If there was a change, call SelectionChanged()
|
|
|
|
NS_IMETHODIMP
|
1999-10-12 08:47:29 +00:00
|
|
|
nsListControlFrame::UpdateSelection(PRBool aDoDispatchEvent, PRBool aForceUpdate, nsIContent* aContent)
|
1999-10-05 23:43:06 +00:00
|
|
|
{
|
1999-11-11 22:13:33 +00:00
|
|
|
if (!mIsAllFramesHere || !mIsAllContentHere) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-10-05 23:43:06 +00:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
PRBool changed = PR_FALSE;
|
|
|
|
|
|
|
|
// Paranoia: check if cache is up to date with content
|
|
|
|
PRInt32 length = 0;
|
|
|
|
GetNumberOfOptions(&length);
|
|
|
|
if (mSelectionCacheLength != length) {
|
2000-05-11 14:05:44 +00:00
|
|
|
//NS_ASSERTION(0,"nsListControlFrame: Cache sync'd with content!\n");
|
1999-10-05 23:43:06 +00:00
|
|
|
changed = PR_TRUE; // Assume the worst, there was a change.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Step through content looking for change in selection
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
if (!changed) {
|
|
|
|
PRBool selected;
|
2000-05-11 14:05:44 +00:00
|
|
|
// the content array of options is actually
|
|
|
|
// out of sync with the array
|
|
|
|
// so until bug 38825 is fixed.
|
|
|
|
if (mSelectionCacheLength != length) { // this shouldn't happend
|
|
|
|
for (PRInt32 i = 0; i < length; i++) {
|
|
|
|
selected = IsContentSelectedByIndex(i);
|
|
|
|
if (selected != (PRBool)mSelectionCache->ElementAt(i)) {
|
|
|
|
mSelectionCache->ReplaceElementAt((void*)selected, i);
|
|
|
|
changed = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
mSelectionCache->Clear();
|
|
|
|
for (PRInt32 i = 0; i < length; i++) {
|
|
|
|
selected = IsContentSelectedByIndex(i);
|
|
|
|
mSelectionCache->InsertElementAt((void*)selected, i);
|
1999-10-05 23:43:06 +00:00
|
|
|
changed = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-08-03 14:13:58 +00:00
|
|
|
PRBool isDroppedDown = PR_FALSE;
|
|
|
|
if (mComboboxFrame != nsnull) {
|
|
|
|
mComboboxFrame->IsDroppedDown(&isDroppedDown);
|
1999-10-12 08:47:29 +00:00
|
|
|
}
|
2000-08-03 14:13:58 +00:00
|
|
|
if (changed && aDoDispatchEvent && !isDroppedDown) {
|
|
|
|
rv = SelectionChanged(aContent); // Dispatch event
|
1999-09-16 22:36:29 +00:00
|
|
|
}
|
1999-08-27 03:58:13 +00:00
|
|
|
}
|
2000-08-03 14:13:58 +00:00
|
|
|
|
|
|
|
if ((changed || aForceUpdate) && mComboboxFrame) {
|
|
|
|
rv = mComboboxFrame->SelectionChanged(); // Update view
|
|
|
|
}
|
1999-09-16 22:36:29 +00:00
|
|
|
return rv;
|
1999-08-27 03:58:13 +00:00
|
|
|
}
|
|
|
|
|
2000-03-18 14:17:34 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::GetOptionsContainer(nsIPresContext* aPresContext, nsIFrame** aFrame)
|
|
|
|
{
|
|
|
|
return FirstChild(aPresContext, nsnull, aFrame);
|
|
|
|
}
|
|
|
|
|
2000-04-28 23:24:59 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::OptionDisabled(nsIContent * aContent)
|
|
|
|
{
|
|
|
|
if (IsContentSelected(aContent)) {
|
|
|
|
PRInt32 inx = GetSelectedIndexFromContent(aContent);
|
|
|
|
SetOptionSelected(inx, PR_FALSE);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-10-05 23:43:06 +00:00
|
|
|
// Send out an onchange notification.
|
|
|
|
nsresult
|
|
|
|
nsListControlFrame::SelectionChanged(nsIContent* aContent)
|
|
|
|
{
|
2000-05-16 21:58:37 +00:00
|
|
|
nsresult ret = NS_ERROR_FAILURE;
|
|
|
|
|
1999-10-05 23:43:06 +00:00
|
|
|
// Dispatch the NS_FORM_CHANGE event
|
|
|
|
nsEventStatus status = nsEventStatus_eIgnore;
|
2000-09-19 21:47:04 +00:00
|
|
|
nsEvent event;
|
|
|
|
event.eventStructType = NS_EVENT;
|
1999-10-05 23:43:06 +00:00
|
|
|
event.message = NS_FORM_CHANGE;
|
|
|
|
|
2000-05-16 21:58:37 +00:00
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
mPresContext->GetShell(getter_AddRefs(presShell));
|
|
|
|
if (presShell) {
|
2000-09-19 21:47:04 +00:00
|
|
|
ret = presShell->HandleEventWithTarget(&event, this, nsnull, NS_EVENT_FLAG_INIT, &status);
|
1999-10-05 23:43:06 +00:00
|
|
|
}
|
2000-05-16 21:58:37 +00:00
|
|
|
return ret;
|
1999-10-05 23:43:06 +00:00
|
|
|
}
|
|
|
|
|
1999-09-15 05:31:31 +00:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// Determine if the specified item in the listbox is selected.
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::GetOptionSelected(PRInt32 aIndex, PRBool* aValue)
|
|
|
|
{
|
|
|
|
*aValue = IsContentSelectedByIndex(aIndex);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-26 14:54:07 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// End nsISelectControlFrame
|
|
|
|
//----------------------------------------------------------------------
|
1999-05-07 20:30:16 +00:00
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-05-07 20:30:16 +00:00
|
|
|
NS_IMETHODIMP
|
2000-08-23 17:27:06 +00:00
|
|
|
nsListControlFrame::SetProperty(nsIPresContext* aPresContext, nsIAtom* aName,
|
|
|
|
const nsAReadableString& aValue)
|
1999-01-25 22:16:27 +00:00
|
|
|
{
|
1999-04-12 22:14:31 +00:00
|
|
|
if (nsHTMLAtoms::selected == aName) {
|
|
|
|
return NS_ERROR_INVALID_ARG; // Selected is readonly according to spec.
|
2000-02-12 16:21:37 +00:00
|
|
|
|
1999-04-12 22:14:31 +00:00
|
|
|
} else if (nsHTMLAtoms::selectedindex == aName) {
|
|
|
|
PRInt32 error = 0;
|
2000-08-23 17:27:06 +00:00
|
|
|
nsAutoString str(aValue);
|
|
|
|
PRInt32 selectedIndex = str.ToInteger(&error, 10); // Get index from aValue
|
1999-04-12 22:14:31 +00:00
|
|
|
if (error) {
|
|
|
|
return NS_ERROR_INVALID_ARG; // Couldn't convert to integer
|
|
|
|
} else {
|
2000-02-12 16:21:37 +00:00
|
|
|
// Start by getting the num of options
|
|
|
|
// to make sure the new index is within the bounds
|
2000-03-20 23:43:07 +00:00
|
|
|
// if selectedIndex is -1, deselect all (bug 28143)
|
2000-02-12 16:21:37 +00:00
|
|
|
PRInt32 numOptions = 0;
|
|
|
|
GetNumberOfOptions(&numOptions);
|
2000-03-20 23:43:07 +00:00
|
|
|
if (selectedIndex < -1 || selectedIndex >= numOptions) {
|
2000-02-12 16:21:37 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2000-03-20 23:43:07 +00:00
|
|
|
if (selectedIndex == -1) {
|
|
|
|
Deselect();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Get the DOM interface for the select
|
|
|
|
// we will use this to see if it is a "multiple" select
|
|
|
|
nsCOMPtr<nsIDOMHTMLSelectElement> selectElement = getter_AddRefs(GetSelect(mContent));
|
|
|
|
if (selectElement) {
|
|
|
|
// check to see if it is a mulitple select
|
|
|
|
PRBool multiple = PR_FALSE;
|
|
|
|
if (NS_FAILED(GetMultiple(&multiple, selectElement))) {
|
|
|
|
multiple = PR_FALSE;
|
|
|
|
}
|
|
|
|
// if it is a multiple, select the new item
|
|
|
|
if (multiple) {
|
|
|
|
SetOptionSelected(selectedIndex, PR_TRUE);
|
|
|
|
} else {
|
|
|
|
// if it is a single select,
|
|
|
|
// check to see if it is the currect selection
|
|
|
|
// if it is, then do nothing
|
|
|
|
if (mSelectedIndex != selectedIndex) {
|
|
|
|
ToggleSelected(selectedIndex); // sets mSelectedIndex
|
|
|
|
if (nsnull != mComboboxFrame && mIsAllFramesHere) {
|
|
|
|
mComboboxFrame->UpdateSelection(PR_FALSE, PR_TRUE, selectedIndex); // don't dispatch event
|
|
|
|
}
|
|
|
|
}
|
2000-02-12 16:21:37 +00:00
|
|
|
}
|
|
|
|
}
|
1999-08-26 14:54:07 +00:00
|
|
|
}
|
1999-04-12 22:14:31 +00:00
|
|
|
}
|
|
|
|
}
|
2000-03-20 23:43:07 +00:00
|
|
|
|
1999-01-25 22:16:27 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-05-07 20:30:16 +00:00
|
|
|
NS_IMETHODIMP
|
2000-08-23 17:27:06 +00:00
|
|
|
nsListControlFrame::GetProperty(nsIAtom* aName, nsAWritableString& aValue)
|
1999-03-06 19:43:13 +00:00
|
|
|
{
|
1999-04-12 22:14:31 +00:00
|
|
|
// Get the selected value of option from local cache (optimization vs. widget)
|
|
|
|
if (nsHTMLAtoms::selected == aName) {
|
2000-08-23 17:27:06 +00:00
|
|
|
nsAutoString val(aValue);
|
1999-04-12 22:14:31 +00:00
|
|
|
PRInt32 error = 0;
|
|
|
|
PRBool selected = PR_FALSE;
|
2000-08-23 17:27:06 +00:00
|
|
|
PRInt32 indx = val.ToInteger(&error, 10); // Get index from aValue
|
1999-04-12 22:14:31 +00:00
|
|
|
if (error == 0)
|
1999-08-27 03:58:13 +00:00
|
|
|
selected = IsContentSelectedByIndex(indx);
|
1999-04-12 22:14:31 +00:00
|
|
|
|
|
|
|
nsFormControlHelper::GetBoolString(selected, aValue);
|
|
|
|
|
|
|
|
// For selectedIndex, get the value from the widget
|
|
|
|
} else if (nsHTMLAtoms::selectedindex == aName) {
|
1999-08-26 14:54:07 +00:00
|
|
|
// figures out the first selected item from the content
|
|
|
|
PRInt32 selectedIndex;
|
|
|
|
GetSelectedIndexFromDOM(&selectedIndex);
|
1999-09-17 07:22:23 +00:00
|
|
|
if ((kNothingSelected == selectedIndex) && (mComboboxFrame)) {
|
|
|
|
selectedIndex = 0;
|
|
|
|
}
|
2000-08-23 17:27:06 +00:00
|
|
|
nsAutoString str; str.AppendInt(selectedIndex, 10);
|
|
|
|
aValue.Append(str);
|
1999-04-12 22:14:31 +00:00
|
|
|
}
|
|
|
|
|
1999-03-06 19:43:13 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-05-28 21:12:09 +00:00
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-05-27 21:17:10 +00:00
|
|
|
// Create a Borderless top level widget for drop-down lists.
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
nsresult
|
|
|
|
nsListControlFrame::CreateScrollingViewWidget(nsIView* aView, const nsStylePosition* aPosition)
|
1999-05-27 21:17:10 +00:00
|
|
|
{
|
|
|
|
if (IsInDropDownMode() == PR_TRUE) {
|
|
|
|
nsWidgetInitData widgetData;
|
2000-01-25 01:53:34 +00:00
|
|
|
aView->SetFloating(PR_TRUE);
|
1999-07-28 21:38:08 +00:00
|
|
|
widgetData.mWindowType = eWindowType_popup;
|
1999-07-27 04:27:17 +00:00
|
|
|
widgetData.mBorderStyle = eBorderStyle_default;
|
1999-09-14 21:29:58 +00:00
|
|
|
|
|
|
|
#ifdef XP_MAC
|
|
|
|
static NS_DEFINE_IID(kCPopUpCID, NS_POPUP_CID);
|
|
|
|
aView->CreateWidget(kCPopUpCID, &widgetData, nsnull);
|
|
|
|
#else
|
|
|
|
static NS_DEFINE_IID(kCChildCID, NS_CHILD_CID);
|
|
|
|
aView->CreateWidget(kCChildCID, &widgetData, nsnull);
|
|
|
|
#endif
|
1999-05-27 21:17:10 +00:00
|
|
|
return NS_OK;
|
|
|
|
} else {
|
|
|
|
return nsScrollFrame::CreateScrollingViewWidget(aView, aPosition);
|
|
|
|
}
|
|
|
|
}
|
1999-06-21 20:41:56 +00:00
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-06-21 20:41:56 +00:00
|
|
|
void
|
|
|
|
nsListControlFrame::GetViewOffset(nsIViewManager* aManager, nsIView* aView,
|
|
|
|
nsPoint& aPoint)
|
|
|
|
{
|
|
|
|
aPoint.x = 0;
|
|
|
|
aPoint.y = 0;
|
1999-05-27 21:17:10 +00:00
|
|
|
|
1999-06-21 20:41:56 +00:00
|
|
|
nsIView *parent;
|
|
|
|
nsRect bounds;
|
|
|
|
|
|
|
|
parent = aView;
|
|
|
|
while (nsnull != parent) {
|
|
|
|
parent->GetBounds(bounds);
|
|
|
|
aPoint.x += bounds.x;
|
|
|
|
aPoint.y += bounds.y;
|
|
|
|
parent->GetParent(parent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-08-31 13:22:50 +00:00
|
|
|
NS_IMETHODIMP
|
1999-10-26 04:44:41 +00:00
|
|
|
nsListControlFrame::SyncViewWithFrame(nsIPresContext* aPresContext)
|
1999-06-21 20:41:56 +00:00
|
|
|
{
|
|
|
|
// Resync the view's position with the frame.
|
|
|
|
// The problem is the dropdown's view is attached directly under
|
|
|
|
// the root view. This means it's view needs to have it's coordinates calculated
|
|
|
|
// as if it were in it's normal position in the view hierarchy.
|
1999-08-31 13:22:50 +00:00
|
|
|
mComboboxFrame->AbsolutelyPositionDropDown();
|
1999-06-21 20:41:56 +00:00
|
|
|
|
|
|
|
nsPoint parentPos;
|
|
|
|
nsCOMPtr<nsIViewManager> viewManager;
|
|
|
|
|
|
|
|
//Get parent frame
|
|
|
|
nsIFrame* parent;
|
1999-10-26 04:44:41 +00:00
|
|
|
GetParentWithView(aPresContext, &parent);
|
1999-06-21 20:41:56 +00:00
|
|
|
NS_ASSERTION(parent, "GetParentWithView failed");
|
|
|
|
|
|
|
|
// Get parent view
|
|
|
|
nsIView* parentView = nsnull;
|
1999-10-26 04:44:41 +00:00
|
|
|
parent->GetView(aPresContext, &parentView);
|
1999-06-21 20:41:56 +00:00
|
|
|
|
|
|
|
parentView->GetViewManager(*getter_AddRefs(viewManager));
|
|
|
|
GetViewOffset(viewManager, parentView, parentPos);
|
|
|
|
nsIView* view = nsnull;
|
1999-10-26 04:44:41 +00:00
|
|
|
GetView(aPresContext, &view);
|
1999-06-21 20:41:56 +00:00
|
|
|
|
|
|
|
nsIView* containingView = nsnull;
|
|
|
|
nsPoint offset;
|
1999-10-26 04:44:41 +00:00
|
|
|
GetOffsetFromView(aPresContext, offset, &containingView);
|
1999-08-31 13:22:50 +00:00
|
|
|
//nsSize size;
|
|
|
|
//GetSize(size);
|
1999-06-21 20:41:56 +00:00
|
|
|
|
1999-08-31 13:22:50 +00:00
|
|
|
nscoord width;
|
|
|
|
nscoord height;
|
|
|
|
view->GetDimensions(&width, &height);
|
1999-07-28 21:38:08 +00:00
|
|
|
|
1999-08-31 13:22:50 +00:00
|
|
|
if (width != mRect.width || height != mRect.height) {
|
2000-05-26 23:31:25 +00:00
|
|
|
//viewManager->ResizeView(view, mRect.width, mRect.height);
|
1999-08-31 13:22:50 +00:00
|
|
|
}
|
|
|
|
nscoord x;
|
|
|
|
nscoord y;
|
|
|
|
view->GetPosition(&x, &y);
|
1999-07-28 21:38:08 +00:00
|
|
|
|
1999-08-31 13:22:50 +00:00
|
|
|
nscoord newX = parentPos.x + offset.x;
|
|
|
|
nscoord newY = parentPos.y + offset.y;
|
1999-07-28 21:38:08 +00:00
|
|
|
|
1999-08-31 13:22:50 +00:00
|
|
|
//if (newX != x || newY != y) {
|
|
|
|
viewManager->MoveViewTo(view, newX, newY);
|
|
|
|
//}
|
|
|
|
|
|
|
|
nsViewVisibility visibility;
|
|
|
|
|
|
|
|
view->GetVisibility(visibility);
|
|
|
|
const nsStyleDisplay* disp;
|
|
|
|
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) disp);
|
|
|
|
|
|
|
|
if (visibility != disp->mVisible) {
|
1999-12-14 14:16:09 +00:00
|
|
|
//view->SetVisibility(NS_STYLE_VISIBILITY_VISIBLE == disp->mVisible ?nsViewVisibility_kShow:nsViewVisibility_kHide);
|
1999-08-31 13:22:50 +00:00
|
|
|
}
|
1999-07-28 21:38:08 +00:00
|
|
|
|
1999-06-21 20:41:56 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-09-08 14:27:38 +00:00
|
|
|
//---------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::AboutToDropDown()
|
|
|
|
{
|
|
|
|
mSelectedIndexWhenPoppedDown = mSelectedIndex;
|
1999-11-12 15:00:30 +00:00
|
|
|
if (mIsAllContentHere && mIsAllFramesHere && mHasBeenInitialized) {
|
|
|
|
if (mSelectedIndex != kNothingSelected) {
|
|
|
|
// make sure we scroll to the correct item before it drops down
|
|
|
|
nsCOMPtr<nsIContent> content = getter_AddRefs(GetOptionContent(mSelectedIndex));
|
|
|
|
if (content) {
|
|
|
|
ScrollToFrame(content);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ScrollToFrame(nsnull); // this means it scrolls to 0,0
|
1999-11-11 22:13:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-08 14:27:38 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-10-01 14:30:33 +00:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// We are about to be rolledup from the outside (ComboboxFrame)
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::AboutToRollup()
|
|
|
|
{
|
2000-12-20 23:25:40 +00:00
|
|
|
// XXX To have clicking outside the combobox ALWAYS reset the contents to the
|
|
|
|
// state before it was dropped, remove the all the code in the "if" below and replace it
|
|
|
|
// with just the call to ResetSelectedItem()
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// When the dropdown is dropped down via a mouse click and the user moves the mouse
|
|
|
|
// up and down without clicking, the currently selected item is being tracking inside
|
|
|
|
// the dropdown, but the combobox is not being updated. When the user selects items
|
|
|
|
// with the arrow keys, the combobox is being updated. So when the user clicks outside
|
|
|
|
// the dropdown and it needs to roll up it has to decide whether to keep the current
|
|
|
|
// selection or not. The GetIndexOfDisplayArea method is used to get the current index
|
|
|
|
// in the combobox to compare it to the current index in the dropdown to see if the combox
|
|
|
|
// has been updated and that way it knows whether to "cancel" the the current selection
|
|
|
|
// residing in the dropdown. Or whether to leave the selection alone.
|
|
|
|
if (IsInDropDownMode() == PR_TRUE) {
|
|
|
|
PRInt32 index;
|
|
|
|
mComboboxFrame->GetIndexOfDisplayArea(&index);
|
|
|
|
// if the indexes do NOT match then the selection in the combobox
|
|
|
|
// was never updated, and therefore we should reset the the selection back to
|
|
|
|
// whatever it was before it was dropped down.
|
|
|
|
if (index != mSelectedIndex) {
|
|
|
|
ResetSelectedItem();
|
|
|
|
}
|
|
|
|
}
|
1999-10-01 14:30:33 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-06-21 20:41:56 +00:00
|
|
|
nsresult
|
1999-10-26 04:44:41 +00:00
|
|
|
nsListControlFrame::GetScrollingParentView(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIView** aParentView)
|
1999-06-21 20:41:56 +00:00
|
|
|
{
|
|
|
|
if (IsInDropDownMode() == PR_TRUE) {
|
|
|
|
// Use the parent frame to get the view manager
|
|
|
|
nsIView* parentView = nsnull;
|
1999-10-26 04:44:41 +00:00
|
|
|
nsresult rv = aParent->GetView(aPresContext, &parentView);
|
1999-06-21 20:41:56 +00:00
|
|
|
NS_ASSERTION(parentView, "GetView failed");
|
|
|
|
nsCOMPtr<nsIViewManager> viewManager;
|
|
|
|
parentView->GetViewManager(*getter_AddRefs(viewManager));
|
|
|
|
NS_ASSERTION(viewManager, "GetViewManager failed");
|
|
|
|
|
|
|
|
// Ask the view manager for the root view and
|
|
|
|
// use it as the parent for popup scrolling lists.
|
|
|
|
// Using the normal view as the parent causes the
|
|
|
|
// drop-down list to be clipped to a parent view.
|
|
|
|
// Using the root view as the parent
|
|
|
|
// prevents this from happening.
|
|
|
|
viewManager->GetRootView(*aParentView);
|
2000-01-31 23:36:50 +00:00
|
|
|
NS_ASSERTION(aParentView, "GetRootView failed");
|
1999-06-21 20:41:56 +00:00
|
|
|
return rv;
|
|
|
|
} else {
|
1999-10-26 04:44:41 +00:00
|
|
|
return nsScrollFrame::GetScrollingParentView(aPresContext, aParent, aParentView);
|
1999-06-21 20:41:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
1999-06-21 20:41:56 +00:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsListControlFrame::DidReflow(nsIPresContext* aPresContext,
|
1999-07-28 21:38:08 +00:00
|
|
|
nsDidReflowStatus aStatus)
|
1999-06-21 20:41:56 +00:00
|
|
|
{
|
|
|
|
if (PR_TRUE == IsInDropDownMode())
|
|
|
|
{
|
1999-08-31 13:22:50 +00:00
|
|
|
//SyncViewWithFrame();
|
|
|
|
mState &= ~NS_FRAME_SYNC_FRAME_AND_VIEW;
|
1999-06-21 20:41:56 +00:00
|
|
|
nsresult rv = nsScrollFrame::DidReflow(aPresContext, aStatus);
|
1999-08-31 13:22:50 +00:00
|
|
|
mState |= NS_FRAME_SYNC_FRAME_AND_VIEW;
|
1999-11-24 06:03:41 +00:00
|
|
|
SyncViewWithFrame(aPresContext);
|
1999-06-21 20:41:56 +00:00
|
|
|
return rv;
|
|
|
|
} else {
|
2001-03-09 03:21:51 +00:00
|
|
|
nsresult rv = nsScrollFrame::DidReflow(aPresContext, aStatus);
|
|
|
|
if (!mDoneWithInitialReflow && mSelectedIndex != kNothingSelected) {
|
|
|
|
nsCOMPtr<nsIContent> content = getter_AddRefs(GetOptionContent(mSelectedIndex));
|
|
|
|
if (content) {
|
|
|
|
ScrollToFrame(content);
|
|
|
|
}
|
|
|
|
mDoneWithInitialReflow = PR_TRUE;
|
|
|
|
}
|
|
|
|
return rv;
|
1999-06-21 20:41:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-10-26 04:44:41 +00:00
|
|
|
NS_IMETHODIMP nsListControlFrame::MoveTo(nsIPresContext* aPresContext, nscoord aX, nscoord aY)
|
1999-08-31 13:22:50 +00:00
|
|
|
{
|
|
|
|
if (PR_TRUE == IsInDropDownMode())
|
|
|
|
{
|
|
|
|
//SyncViewWithFrame();
|
|
|
|
mState &= ~NS_FRAME_SYNC_FRAME_AND_VIEW;
|
1999-10-26 04:44:41 +00:00
|
|
|
nsresult rv = nsScrollFrame::MoveTo(aPresContext, aX, aY);
|
1999-08-31 13:22:50 +00:00
|
|
|
mState |= NS_FRAME_SYNC_FRAME_AND_VIEW;
|
|
|
|
//SyncViewWithFrame();
|
|
|
|
return rv;
|
|
|
|
} else {
|
1999-10-26 04:44:41 +00:00
|
|
|
return nsScrollFrame::MoveTo(aPresContext, aX, aY);
|
1999-08-31 13:22:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-19 23:20:21 +00:00
|
|
|
#ifdef IBMBIDI
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::GetFrameType(nsIAtom** aType) const
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aType, "null OUT parameter pointer");
|
|
|
|
*aType = nsLayoutAtoms::listControlFrame;
|
|
|
|
NS_ADDREF(*aType);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
#endif // IBMBIDI
|
1999-08-31 13:22:50 +00:00
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::GetMaximumSize(nsSize &aSize)
|
|
|
|
{
|
1999-07-28 21:38:08 +00:00
|
|
|
aSize.width = mMaxWidth;
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
aSize.height = mMaxHeight;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-05-27 21:17:10 +00:00
|
|
|
|
1999-03-06 19:43:13 +00:00
|
|
|
|
1999-07-28 21:38:08 +00:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::SetSuggestedSize(nscoord aWidth, nscoord aHeight)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-03-28 22:22:54 +00:00
|
|
|
|
1999-09-08 14:27:38 +00:00
|
|
|
//---------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::IsTargetOptionDisabled(PRBool &aIsDisabled)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
|
|
|
aIsDisabled = PR_FALSE;
|
|
|
|
|
2000-02-12 16:21:37 +00:00
|
|
|
nsCOMPtr<nsIEventStateManager> stateManager;
|
|
|
|
rv = mPresContext->GetEventStateManager(getter_AddRefs(stateManager));
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
nsCOMPtr<nsIContent> content;
|
|
|
|
rv = stateManager->GetEventTargetContent(nsnull, getter_AddRefs(content));
|
|
|
|
if (NS_SUCCEEDED(rv) && content) {
|
1999-09-08 14:27:38 +00:00
|
|
|
if (IsOptionElement(content)) {
|
|
|
|
aIsDisabled = nsFormFrame::GetDisabled(this, content);
|
|
|
|
} else {
|
|
|
|
rv = NS_ERROR_FAILURE; // return error when it is not an option
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2000-08-17 21:38:15 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::IsOptionDisabled(PRInt32 anIndex, PRBool &aIsDisabled)
|
|
|
|
{
|
|
|
|
PRBool isOptDisabled = PR_FALSE;
|
|
|
|
nsCOMPtr<nsIDOMHTMLCollection> options = getter_AddRefs(GetOptions(mContent));
|
|
|
|
nsCOMPtr<nsIDOMHTMLOptionElement> optionElement;
|
|
|
|
if (options) {
|
|
|
|
optionElement = getter_AddRefs(GetOption(*options, anIndex));
|
|
|
|
nsCOMPtr<nsIContent> content = do_QueryInterface(optionElement);
|
|
|
|
if (content) {
|
|
|
|
aIsDisabled = nsFormFrame::GetDisabled(nsnull, content);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
1999-10-01 14:30:33 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// This is used to reset the the list and it's selection because the
|
|
|
|
// selection was cancelled and the list rolled up.
|
|
|
|
void nsListControlFrame::ResetSelectedItem()
|
1999-11-11 22:13:33 +00:00
|
|
|
{
|
|
|
|
if (mIsAllFramesHere) {
|
|
|
|
ToggleSelected(mSelectedIndexWhenPoppedDown);
|
2000-12-20 15:15:28 +00:00
|
|
|
if (IsInDropDownMode() == PR_TRUE) {
|
|
|
|
mComboboxFrame->ListWasSelected(mPresContext, PR_TRUE);
|
|
|
|
}
|
1999-11-11 22:13:33 +00:00
|
|
|
}
|
1999-10-01 14:30:33 +00:00
|
|
|
}
|
|
|
|
|
2000-02-09 19:34:39 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// helper
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
PRBool
|
|
|
|
nsListControlFrame::IsLeftButton(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
|
|
|
// only allow selection with the left button
|
|
|
|
nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aMouseEvent);
|
|
|
|
if (mouseEvent) {
|
|
|
|
PRUint16 whichButton;
|
|
|
|
if (NS_SUCCEEDED(mouseEvent->GetButton(&whichButton))) {
|
2001-03-02 18:39:22 +00:00
|
|
|
return whichButton != 0?PR_FALSE:PR_TRUE;
|
2000-02-09 19:34:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
1999-08-26 14:54:07 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIDOMMouseListener
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
nsresult
|
|
|
|
nsListControlFrame::MouseUp(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
2000-03-07 15:54:31 +00:00
|
|
|
NS_ASSERTION(aMouseEvent != nsnull, "aMouseEvent is null.");
|
|
|
|
|
|
|
|
REFLOW_DEBUG_MSG("--------------------------- MouseUp ----------------------------\n");
|
1999-08-26 14:54:07 +00:00
|
|
|
|
|
|
|
if (nsFormFrame::GetDisabled(this)) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-02-09 19:34:39 +00:00
|
|
|
// only allow selection with the left button
|
2000-08-03 14:13:58 +00:00
|
|
|
// if a right button click is on the combobox itself
|
|
|
|
// or on the select when in listbox mode, then let the click through
|
2000-02-09 19:34:39 +00:00
|
|
|
if (!IsLeftButton(aMouseEvent)) {
|
2000-12-20 15:15:28 +00:00
|
|
|
if (IsInDropDownMode() == PR_TRUE) {
|
2000-08-03 14:13:58 +00:00
|
|
|
if (!IsClickingInCombobox(aMouseEvent)) {
|
|
|
|
aMouseEvent->PreventDefault();
|
|
|
|
aMouseEvent->PreventCapture();
|
|
|
|
aMouseEvent->PreventBubble();
|
|
|
|
} else {
|
2000-08-17 21:38:15 +00:00
|
|
|
mButtonDown = PR_FALSE;
|
|
|
|
CaptureMouseEvents(mPresContext, PR_FALSE);
|
2000-08-03 14:13:58 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-08-17 21:38:15 +00:00
|
|
|
mButtonDown = PR_FALSE;
|
|
|
|
CaptureMouseEvents(mPresContext, PR_FALSE);
|
2000-08-03 14:13:58 +00:00
|
|
|
return NS_ERROR_FAILURE; // means consume event
|
|
|
|
} else {
|
2000-08-17 21:38:15 +00:00
|
|
|
mButtonDown = PR_FALSE;
|
|
|
|
CaptureMouseEvents(mPresContext, PR_FALSE);
|
2000-08-03 14:13:58 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-02-09 19:34:39 +00:00
|
|
|
}
|
|
|
|
|
1999-09-08 14:27:38 +00:00
|
|
|
// Check to see if the disabled option was clicked on
|
|
|
|
// NS_ERROR_FAILURE is returned is it isn't over an option
|
|
|
|
PRBool optionIsDisabled;
|
|
|
|
if (NS_OK == IsTargetOptionDisabled(optionIsDisabled)) {
|
|
|
|
if (optionIsDisabled) {
|
2000-12-20 15:15:28 +00:00
|
|
|
if (IsInDropDownMode() == PR_TRUE) {
|
1999-10-01 14:30:33 +00:00
|
|
|
ResetSelectedItem();
|
2000-12-20 15:15:28 +00:00
|
|
|
} else {
|
|
|
|
SetContentSelected(mSelectedIndex, PR_FALSE);
|
|
|
|
mSelectedIndex = kNothingSelected;
|
|
|
|
}
|
2000-05-11 14:05:44 +00:00
|
|
|
REFLOW_DEBUG_MSG(">>>>>> Option is disabled");
|
2000-08-17 21:38:15 +00:00
|
|
|
mButtonDown = PR_FALSE;
|
|
|
|
CaptureMouseEvents(mPresContext, PR_FALSE);
|
1999-09-08 14:27:38 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-26 14:54:07 +00:00
|
|
|
const nsStyleDisplay* disp = (const nsStyleDisplay*)mStyleContext->GetStyleData(eStyleStruct_Display);
|
2000-03-17 10:15:13 +00:00
|
|
|
if (!disp->IsVisible()) {
|
2000-05-11 14:05:44 +00:00
|
|
|
REFLOW_DEBUG_MSG(">>>>>> Select is NOT visible");
|
1999-08-26 14:54:07 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsInDropDownMode() == PR_TRUE) {
|
2000-05-26 23:31:25 +00:00
|
|
|
// XXX This is a bit of a hack, but.....
|
|
|
|
// But the idea here is to make sure you get an "onclick" event when you mouse
|
|
|
|
// down on the select and the drag over an option and let go
|
|
|
|
// And then NOT get an "onclick" event when when you click down on the select
|
|
|
|
// and then up outside of the select
|
|
|
|
// the EventStateManager tracks the content of the mouse down and the mouse up
|
|
|
|
// to make sure they are the same, and the onclick is sent in the PostHandleEvent
|
|
|
|
// depeneding on whether the clickCount is non-zero.
|
|
|
|
// So we cheat here by either setting or unsetting the clcikCount in the native event
|
|
|
|
// so the right thing happens for the onclick event
|
|
|
|
nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(aMouseEvent));
|
|
|
|
nsMouseEvent * mouseEvent;
|
|
|
|
privateEvent->GetInternalNSEvent((nsEvent**)&mouseEvent);
|
|
|
|
|
1999-08-27 14:42:27 +00:00
|
|
|
if (NS_SUCCEEDED(GetIndexFromDOMEvent(aMouseEvent, mOldSelectedIndex, mSelectedIndex))) {
|
2000-05-11 14:05:44 +00:00
|
|
|
REFLOW_DEBUG_MSG2(">>>>>> Found Index: %d", mSelectedIndex);
|
1999-08-26 14:54:07 +00:00
|
|
|
if (kNothingSelected != mSelectedIndex) {
|
|
|
|
SetContentSelected(mSelectedIndex, PR_TRUE);
|
|
|
|
}
|
|
|
|
if (mComboboxFrame) {
|
2000-08-03 14:13:58 +00:00
|
|
|
mComboboxFrame->ListWasSelected(mPresContext, PR_FALSE);
|
1999-08-26 14:54:07 +00:00
|
|
|
}
|
2000-05-26 23:31:25 +00:00
|
|
|
mouseEvent->clickCount = 1;
|
|
|
|
} else {
|
|
|
|
// the click was out side of the select or its dropdown
|
2000-07-07 01:35:23 +00:00
|
|
|
mouseEvent->clickCount = IsClickingInCombobox(aMouseEvent)?1:0;
|
1999-08-26 14:54:07 +00:00
|
|
|
}
|
|
|
|
} else {
|
2000-05-11 14:05:44 +00:00
|
|
|
REFLOW_DEBUG_MSG(">>>>>> Didn't find");
|
1999-08-26 14:54:07 +00:00
|
|
|
mButtonDown = PR_FALSE;
|
1999-10-26 04:44:41 +00:00
|
|
|
CaptureMouseEvents(mPresContext, PR_FALSE);
|
2000-08-03 14:13:58 +00:00
|
|
|
if (mSelectedIndex != mOldSelectedIndex) {
|
|
|
|
UpdateSelection(PR_TRUE, PR_FALSE, mContent);
|
|
|
|
}
|
2000-03-07 15:54:31 +00:00
|
|
|
#if 0 // XXX - this is a partial fix for Bug 29990
|
|
|
|
if (mSelectedIndex != mStartExtendedIndex) {
|
|
|
|
mEndExtendedIndex = mSelectedIndex;
|
|
|
|
}
|
|
|
|
#endif
|
1999-08-26 14:54:07 +00:00
|
|
|
}
|
|
|
|
|
2000-03-07 15:54:31 +00:00
|
|
|
return NS_OK;
|
1999-08-26 14:54:07 +00:00
|
|
|
}
|
|
|
|
|
2000-01-11 20:36:37 +00:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// helper method
|
|
|
|
PRBool nsListControlFrame::IsClickingInCombobox(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
|
|
|
// Cheesey way to figure out if we clicking in the ListBox portion
|
|
|
|
// or the Combobox portion
|
|
|
|
// Return TRUE if we are clicking in the combobox frame
|
|
|
|
if (mComboboxFrame) {
|
|
|
|
nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(aMouseEvent));
|
|
|
|
PRInt32 scrX;
|
|
|
|
PRInt32 scrY;
|
|
|
|
mouseEvent->GetScreenX(&scrX);
|
|
|
|
mouseEvent->GetScreenY(&scrY);
|
|
|
|
nsRect rect;
|
|
|
|
mComboboxFrame->GetAbsoluteRect(&rect);
|
|
|
|
if (rect.Contains(scrX, scrY)) {
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
1999-08-26 14:54:07 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Sets the mSelectedIndex and mOldSelectedIndex from figuring out what
|
|
|
|
// item was selected using content
|
|
|
|
// Returns NS_OK if it successfully found the selection
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
nsresult
|
1999-08-27 14:42:27 +00:00
|
|
|
nsListControlFrame::GetIndexFromDOMEvent(nsIDOMEvent* aMouseEvent,
|
|
|
|
PRInt32& aOldIndex,
|
|
|
|
PRInt32& aCurIndex)
|
1999-08-26 14:54:07 +00:00
|
|
|
{
|
2000-01-11 20:36:37 +00:00
|
|
|
if (IsClickingInCombobox(aMouseEvent)) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2000-08-03 14:13:58 +00:00
|
|
|
#ifdef DEBUG_rodsX
|
|
|
|
nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(aMouseEvent));
|
2000-03-28 15:11:16 +00:00
|
|
|
nsCOMPtr<nsIDOMNode> node;
|
|
|
|
mouseEvent->GetTarget(getter_AddRefs(node));
|
|
|
|
nsCOMPtr<nsIContent> content = do_QueryInterface(node);
|
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
mPresContext->GetShell(getter_AddRefs(presShell));
|
|
|
|
nsIFrame * frame;
|
|
|
|
nsresult result = presShell->GetPrimaryFrameFor(content, &frame);
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("Target Frame: %p this: %p\n", frame, this);
|
|
|
|
printf("-->\n");
|
2000-08-03 14:13:58 +00:00
|
|
|
#endif
|
|
|
|
|
1999-08-26 14:54:07 +00:00
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
2000-02-12 16:21:37 +00:00
|
|
|
nsCOMPtr<nsIEventStateManager> stateManager;
|
|
|
|
if (NS_SUCCEEDED(mPresContext->GetEventStateManager(getter_AddRefs(stateManager)))) {
|
|
|
|
nsCOMPtr<nsIContent> content;
|
|
|
|
stateManager->GetEventTargetContent(nsnull, getter_AddRefs(content));
|
1999-11-11 22:13:33 +00:00
|
|
|
|
2000-02-12 16:21:37 +00:00
|
|
|
nsCOMPtr<nsIContent> optionContent = getter_AddRefs(GetOptionFromContent(content));
|
|
|
|
if (optionContent) {
|
1999-08-27 14:42:27 +00:00
|
|
|
aOldIndex = aCurIndex;
|
|
|
|
aCurIndex = GetSelectedIndexFromContent(optionContent);
|
2000-10-28 22:17:53 +00:00
|
|
|
//printf("--> Old: %d New: %d\n", aOldIndex, aCurIndex);
|
1999-08-26 14:54:07 +00:00
|
|
|
rv = NS_OK;
|
|
|
|
}
|
|
|
|
}
|
2000-10-28 22:17:53 +00:00
|
|
|
//printf("--> bailing\n");
|
1999-08-26 14:54:07 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2000-03-15 15:55:30 +00:00
|
|
|
void
|
|
|
|
nsListControlFrame::GetScrollableView(nsIScrollableView*& aScrollableView)
|
|
|
|
{
|
|
|
|
aScrollableView = nsnull;
|
|
|
|
|
|
|
|
nsIView * scrollView;
|
|
|
|
GetView(mPresContext, &scrollView);
|
2000-03-18 14:17:34 +00:00
|
|
|
nsresult rv = scrollView->QueryInterface(NS_GET_IID(nsIScrollableView), (void**)&aScrollableView);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv) && aScrollableView, "We must be able to get a ScrollableView");
|
2000-03-15 15:55:30 +00:00
|
|
|
}
|
|
|
|
|
1999-08-26 14:54:07 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
nsresult
|
|
|
|
nsListControlFrame::MouseDown(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
2000-03-07 15:54:31 +00:00
|
|
|
NS_ASSERTION(aMouseEvent != nsnull, "aMouseEvent is null.");
|
|
|
|
|
|
|
|
REFLOW_DEBUG_MSG("--------------------------- MouseDown ----------------------------\n");
|
|
|
|
|
1999-08-26 14:54:07 +00:00
|
|
|
if (nsFormFrame::GetDisabled(this)) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-09-08 14:27:38 +00:00
|
|
|
|
2000-02-09 19:34:39 +00:00
|
|
|
// only allow selection with the left button
|
2000-08-03 14:13:58 +00:00
|
|
|
// if a right button click is on the combobox itself
|
|
|
|
// or on the select when in listbox mode, then let the click through
|
2000-02-09 19:34:39 +00:00
|
|
|
if (!IsLeftButton(aMouseEvent)) {
|
2000-08-03 14:13:58 +00:00
|
|
|
if (IsInDropDownMode()) {
|
|
|
|
if (!IsClickingInCombobox(aMouseEvent)) {
|
|
|
|
aMouseEvent->PreventDefault();
|
|
|
|
aMouseEvent->PreventCapture();
|
|
|
|
aMouseEvent->PreventBubble();
|
|
|
|
} else {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE; // means consume event
|
|
|
|
} else {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-02-09 19:34:39 +00:00
|
|
|
}
|
|
|
|
|
1999-09-08 14:27:38 +00:00
|
|
|
// Check to see if the disabled option was clicked on
|
|
|
|
// NS_ERROR_FAILURE is returned is it isn't over an option
|
|
|
|
PRBool optionIsDisabled;
|
|
|
|
if (NS_OK == IsTargetOptionDisabled(optionIsDisabled)) {
|
1999-09-08 19:54:30 +00:00
|
|
|
if (optionIsDisabled) {
|
|
|
|
if (IsInDropDownMode() == PR_TRUE) {
|
1999-10-01 14:30:33 +00:00
|
|
|
ResetSelectedItem();
|
1999-09-08 19:54:30 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-09-08 14:27:38 +00:00
|
|
|
}
|
|
|
|
|
1999-08-27 14:42:27 +00:00
|
|
|
PRInt32 oldIndex;
|
|
|
|
PRInt32 curIndex = mSelectedIndex;
|
1999-08-26 14:54:07 +00:00
|
|
|
|
1999-08-27 14:42:27 +00:00
|
|
|
if (NS_SUCCEEDED(GetIndexFromDOMEvent(aMouseEvent, oldIndex, curIndex))) {
|
1999-08-26 14:54:07 +00:00
|
|
|
if (IsInDropDownMode() == PR_TRUE) {
|
2000-08-29 13:24:38 +00:00
|
|
|
#if 0 // Fix for Bug 50024
|
1999-09-30 11:37:58 +00:00
|
|
|
// the pop up stole focus away from the webshell
|
|
|
|
// now I am giving it back
|
|
|
|
nsIFrame * parentFrame;
|
1999-10-26 04:44:41 +00:00
|
|
|
GetParentWithView(mPresContext, &parentFrame);
|
1999-09-30 11:37:58 +00:00
|
|
|
if (nsnull != parentFrame) {
|
|
|
|
nsIView * pView;
|
1999-10-26 04:44:41 +00:00
|
|
|
parentFrame->GetView(mPresContext, &pView);
|
1999-09-30 11:37:58 +00:00
|
|
|
if (nsnull != pView) {
|
|
|
|
nsIWidget *window = nsnull;
|
|
|
|
|
|
|
|
nsIView *ancestor = pView;
|
|
|
|
while (nsnull != ancestor) {
|
|
|
|
ancestor->GetWidget(window); // addrefs
|
|
|
|
if (nsnull != window) {
|
|
|
|
window->SetFocus();
|
|
|
|
NS_IF_RELEASE(window);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ancestor->GetParent(ancestor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// turn back on focus events
|
2000-02-12 16:21:37 +00:00
|
|
|
nsCOMPtr<nsIEventStateManager> stateManager;
|
|
|
|
if (NS_SUCCEEDED(mPresContext->GetEventStateManager(getter_AddRefs(stateManager)))) {
|
1999-09-30 11:37:58 +00:00
|
|
|
stateManager->ConsumeFocusEvents(PR_TRUE);
|
|
|
|
}
|
2000-08-29 13:24:38 +00:00
|
|
|
#endif
|
1999-08-26 14:54:07 +00:00
|
|
|
} else {
|
1999-08-27 14:42:27 +00:00
|
|
|
mSelectedIndex = curIndex;
|
|
|
|
mOldSelectedIndex = oldIndex;
|
1999-08-26 14:54:07 +00:00
|
|
|
// Handle Like List
|
|
|
|
mButtonDown = PR_TRUE;
|
1999-10-26 04:44:41 +00:00
|
|
|
CaptureMouseEvents(mPresContext, PR_TRUE);
|
1999-08-26 14:54:07 +00:00
|
|
|
HandleListSelection(aMouseEvent);
|
|
|
|
}
|
|
|
|
} else {
|
1999-09-08 14:27:38 +00:00
|
|
|
// NOTE: the combo box is responsible for dropping it down
|
1999-08-26 14:54:07 +00:00
|
|
|
if (mComboboxFrame) {
|
2000-02-12 16:21:37 +00:00
|
|
|
nsCOMPtr<nsIEventStateManager> stateManager;
|
|
|
|
if (NS_SUCCEEDED(mPresContext->GetEventStateManager(getter_AddRefs(stateManager)))) {
|
1999-09-13 18:29:00 +00:00
|
|
|
nsIFrame * frame;
|
|
|
|
stateManager->GetEventTarget(&frame);
|
|
|
|
nsCOMPtr<nsIListControlFrame> listFrame(do_QueryInterface(frame));
|
|
|
|
if (listFrame) {
|
2000-01-11 20:36:37 +00:00
|
|
|
if (!IsClickingInCombobox(aMouseEvent)) {
|
1999-09-13 23:20:50 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-01-18 23:33:22 +00:00
|
|
|
} else {
|
2001-02-01 22:45:32 +00:00
|
|
|
if (!IsClickingInCombobox(aMouseEvent)) {
|
|
|
|
return NS_OK;
|
2000-01-18 23:33:22 +00:00
|
|
|
}
|
1999-09-13 18:29:00 +00:00
|
|
|
}
|
1999-09-30 11:37:58 +00:00
|
|
|
// This will consume the focus event we get from the clicking on the dropdown
|
|
|
|
//stateManager->ConsumeFocusEvents(PR_TRUE);
|
|
|
|
|
|
|
|
PRBool isDroppedDown;
|
|
|
|
mComboboxFrame->IsDroppedDown(&isDroppedDown);
|
|
|
|
mComboboxFrame->ShowDropDown(!isDroppedDown);
|
|
|
|
// Reset focus on main webshell here
|
|
|
|
//stateManager->SetContentState(mContent, NS_EVENT_STATE_FOCUS);
|
1999-09-13 18:29:00 +00:00
|
|
|
|
1999-09-30 11:37:58 +00:00
|
|
|
if (isDroppedDown) {
|
1999-10-26 04:44:41 +00:00
|
|
|
CaptureMouseEvents(mPresContext, PR_FALSE);
|
1999-09-30 11:37:58 +00:00
|
|
|
}
|
2000-03-28 15:11:16 +00:00
|
|
|
return NS_OK;
|
1999-08-26 14:54:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-03-03 04:28:59 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
1999-08-26 14:54:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIDOMMouseMotionListener
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
nsresult
|
|
|
|
nsListControlFrame::MouseMove(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
2000-03-07 15:54:31 +00:00
|
|
|
NS_ASSERTION(aMouseEvent != nsnull, "aMouseEvent is null.");
|
2000-05-11 14:05:44 +00:00
|
|
|
//REFLOW_DEBUG_MSG("MouseMove\n");
|
2000-03-07 15:54:31 +00:00
|
|
|
|
2000-12-20 15:15:28 +00:00
|
|
|
if (IsInDropDownMode() == PR_TRUE) {
|
1999-09-19 09:48:04 +00:00
|
|
|
PRBool isDroppedDown = PR_FALSE;
|
|
|
|
mComboboxFrame->IsDroppedDown(&isDroppedDown);
|
|
|
|
if (isDroppedDown) {
|
|
|
|
PRInt32 oldIndex;
|
|
|
|
PRInt32 curIndex = mSelectedIndex;
|
|
|
|
if (NS_SUCCEEDED(GetIndexFromDOMEvent(aMouseEvent, oldIndex, curIndex))) {
|
2001-03-20 11:48:27 +00:00
|
|
|
PRBool optionIsDisabled = PR_FALSE;
|
|
|
|
if (NS_SUCCEEDED(IsTargetOptionDisabled(optionIsDisabled)) && !optionIsDisabled) {
|
|
|
|
mSelectedIndex = curIndex;
|
|
|
|
mOldSelectedIndex = oldIndex;
|
|
|
|
if (kNothingSelected != mSelectedIndex) {
|
|
|
|
if (mOldSelectedIndex != mSelectedIndex) {
|
|
|
|
if (mOldSelectedIndex != kNothingSelected) {
|
|
|
|
SetContentSelected(mOldSelectedIndex, PR_FALSE);
|
|
|
|
}
|
|
|
|
SetContentSelected(mSelectedIndex, PR_TRUE);
|
1999-09-19 09:48:04 +00:00
|
|
|
}
|
1999-08-26 14:54:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-03-15 15:55:30 +00:00
|
|
|
} else {// XXX - temporary until we get drag events
|
2000-03-07 15:54:31 +00:00
|
|
|
if (mButtonDown) {
|
2000-03-15 15:55:30 +00:00
|
|
|
return DragMove(aMouseEvent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsListControlFrame::DragMove(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aMouseEvent != nsnull, "aMouseEvent is null.");
|
2000-05-11 14:05:44 +00:00
|
|
|
//REFLOW_DEBUG_MSG("DragMove\n");
|
2000-03-15 15:55:30 +00:00
|
|
|
|
2000-12-20 15:15:28 +00:00
|
|
|
if (IsInDropDownMode() == PR_FALSE) {
|
2000-03-15 15:55:30 +00:00
|
|
|
// check to make sure we are a mulitple select list
|
2000-03-07 15:54:31 +00:00
|
|
|
PRBool multipleSelections = PR_FALSE;
|
|
|
|
GetMultiple(&multipleSelections);
|
|
|
|
if (multipleSelections) {
|
2000-03-15 15:55:30 +00:00
|
|
|
// get the currently moused over item
|
2000-03-07 15:54:31 +00:00
|
|
|
PRInt32 oldIndex;
|
|
|
|
PRInt32 curIndex = mSelectedIndex;
|
|
|
|
if (NS_SUCCEEDED(GetIndexFromDOMEvent(aMouseEvent, oldIndex, curIndex))) {
|
2000-03-15 15:55:30 +00:00
|
|
|
if (curIndex != oldIndex) {
|
|
|
|
// select down the list
|
|
|
|
if (curIndex > oldIndex) {
|
|
|
|
PRInt32 startInx = oldIndex > mStartExtendedIndex?oldIndex+1:oldIndex;
|
|
|
|
PRInt32 endInx = curIndex > mStartExtendedIndex?curIndex+1:curIndex;
|
|
|
|
PRInt32 i;
|
|
|
|
for (i=startInx;i<endInx;i++) {
|
|
|
|
if (i != mStartExtendedIndex) { // skip the starting clicked on node
|
|
|
|
PRBool optionIsDisabled;
|
|
|
|
if (NS_OK == IsTargetOptionDisabled(optionIsDisabled)) {
|
|
|
|
if (!optionIsDisabled) {
|
|
|
|
mSelectedIndex = i;
|
|
|
|
SetContentSelected(mSelectedIndex, i > mStartExtendedIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mSelectedIndex = curIndex;
|
|
|
|
} else {
|
|
|
|
// select up the list
|
|
|
|
PRInt32 startInx = oldIndex >= mStartExtendedIndex?oldIndex:oldIndex-1;
|
|
|
|
PRInt32 endInx = curIndex >= mStartExtendedIndex?curIndex:curIndex-1;
|
|
|
|
PRInt32 i;
|
|
|
|
for (i=startInx;i>endInx;i--) {
|
|
|
|
if (i != mStartExtendedIndex) { // skip the starting clicked on node
|
|
|
|
PRBool optionIsDisabled;
|
|
|
|
if (NS_OK == IsTargetOptionDisabled(optionIsDisabled)) {
|
|
|
|
if (!optionIsDisabled) {
|
|
|
|
mSelectedIndex = i;
|
|
|
|
SetContentSelected(mSelectedIndex, i < mStartExtendedIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-03-07 15:54:31 +00:00
|
|
|
mSelectedIndex = curIndex;
|
|
|
|
}
|
2000-03-15 15:55:30 +00:00
|
|
|
} else {
|
|
|
|
//mOldSelectedIndex = oldIndex;
|
|
|
|
mSelectedIndex = curIndex;
|
2000-03-07 15:54:31 +00:00
|
|
|
}
|
|
|
|
}
|
2000-08-03 14:13:58 +00:00
|
|
|
} else { // Fix Bug 44454
|
|
|
|
// get the currently moused over item
|
|
|
|
PRInt32 oldIndex;
|
|
|
|
PRInt32 curIndex = mSelectedIndex;
|
|
|
|
if (NS_SUCCEEDED(GetIndexFromDOMEvent(aMouseEvent, oldIndex, curIndex))) {
|
|
|
|
if (curIndex != oldIndex) { // select down the list
|
|
|
|
SetContentSelected(mSelectedIndex, PR_FALSE);
|
|
|
|
mSelectedIndex = curIndex;
|
|
|
|
SetContentSelected(mSelectedIndex, PR_TRUE);
|
|
|
|
mStartExtendedIndex = mSelectedIndex;
|
|
|
|
mEndExtendedIndex = kNothingSelected;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // Fix Bug 44454
|
1999-08-26 14:54:07 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-27 14:42:27 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIDOMKeyListener
|
|
|
|
//----------------------------------------------------------------------
|
1999-09-30 11:37:58 +00:00
|
|
|
nsresult
|
2000-05-03 22:01:47 +00:00
|
|
|
nsListControlFrame::KeyDown(nsIDOMEvent* aKeyEvent)
|
1999-09-30 11:37:58 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-08-03 14:13:58 +00:00
|
|
|
//----------------------------------------------------------------------
|
1999-11-11 22:13:33 +00:00
|
|
|
nsresult
|
|
|
|
nsListControlFrame::ScrollToFrame(nsIContent* aOptElement)
|
|
|
|
{
|
2000-03-15 15:55:30 +00:00
|
|
|
nsIScrollableView * scrollableView;
|
|
|
|
GetScrollableView(scrollableView);
|
1999-11-12 15:00:30 +00:00
|
|
|
|
2000-03-15 15:55:30 +00:00
|
|
|
if (scrollableView) {
|
|
|
|
// if null is passed in we scroll to 0,0
|
|
|
|
if (nsnull == aOptElement) {
|
1999-11-12 15:00:30 +00:00
|
|
|
scrollableView->ScrollTo(0, 0, PR_TRUE);
|
2000-03-15 15:55:30 +00:00
|
|
|
return NS_OK;
|
1999-11-12 15:00:30 +00:00
|
|
|
}
|
|
|
|
|
2000-03-15 15:55:30 +00:00
|
|
|
// otherwise we find the content's frame and scroll to it
|
2000-08-03 14:13:58 +00:00
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
mPresContext->GetShell(getter_AddRefs(presShell));
|
2000-03-15 15:55:30 +00:00
|
|
|
nsIFrame * childframe;
|
|
|
|
nsresult result;
|
|
|
|
if (aOptElement) {
|
|
|
|
result = presShell->GetPrimaryFrameFor(aOptElement, &childframe);
|
|
|
|
} else {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2000-08-03 14:13:58 +00:00
|
|
|
if (NS_SUCCEEDED(result) && childframe) {
|
2000-03-15 15:55:30 +00:00
|
|
|
if (NS_SUCCEEDED(result) && scrollableView) {
|
|
|
|
const nsIView * clippedView;
|
|
|
|
scrollableView->GetClipView(&clippedView);
|
|
|
|
nscoord x;
|
|
|
|
nscoord y;
|
|
|
|
scrollableView->GetScrollPosition(x,y);
|
|
|
|
// get the clipped rect
|
|
|
|
nsRect rect;
|
|
|
|
clippedView->GetBounds(rect);
|
|
|
|
// now move it by the offset of the scroll position
|
|
|
|
rect.x = 0;
|
|
|
|
rect.y = 0;
|
|
|
|
rect.MoveBy(x,y);
|
|
|
|
|
|
|
|
// get the child
|
|
|
|
nsRect fRect;
|
|
|
|
childframe->GetRect(fRect);
|
|
|
|
nsPoint pnt;
|
|
|
|
nsIView * view;
|
|
|
|
childframe->GetOffsetFromView(mPresContext, pnt, &view);
|
|
|
|
|
2000-08-03 14:13:58 +00:00
|
|
|
// This change for 33421 (remove this comment later)
|
|
|
|
|
|
|
|
// options can be a child of an optgroup
|
|
|
|
// this checks to see the parent is an optgroup
|
|
|
|
// and then adds in the parent's y coord
|
|
|
|
// XXX this assume only one level of nesting of optgroups
|
|
|
|
// which is all the spec specifies at the moment.
|
|
|
|
nsCOMPtr<nsIContent> parentContent;
|
|
|
|
aOptElement->GetParent(*getter_AddRefs(parentContent));
|
|
|
|
nsCOMPtr<nsIDOMHTMLOptGroupElement> optGroup(do_QueryInterface(parentContent));
|
|
|
|
nsRect optRect(0,0,0,0);
|
|
|
|
if (optGroup) {
|
|
|
|
nsIFrame * optFrame;
|
|
|
|
result = presShell->GetPrimaryFrameFor(parentContent, &optFrame);
|
|
|
|
if (NS_SUCCEEDED(result) && optFrame) {
|
|
|
|
optFrame->GetRect(optRect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fRect.y += optRect.y;
|
|
|
|
|
2000-03-15 15:55:30 +00:00
|
|
|
// see if the selected frame is inside the scrolled area
|
|
|
|
if (!rect.Contains(fRect)) {
|
|
|
|
// figure out which direction we are going
|
|
|
|
if (fRect.y+fRect.height >= rect.y+rect.height) {
|
|
|
|
y = fRect.y-(rect.height-fRect.height);
|
|
|
|
} else {
|
|
|
|
y = fRect.y;
|
|
|
|
}
|
|
|
|
scrollableView->ScrollTo(pnt.x, y, PR_TRUE);
|
1999-11-11 22:13:33 +00:00
|
|
|
}
|
|
|
|
|
2000-03-15 15:55:30 +00:00
|
|
|
}
|
1999-11-11 22:13:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-08-17 21:38:15 +00:00
|
|
|
//---------------------------------------------------------------------
|
|
|
|
// Ok, the entire idea of this routine is to move to the next item that
|
|
|
|
// is suppose to be selected. If the item is disabled then we search in
|
|
|
|
// the same direction looking for the next item to select. If we run off
|
|
|
|
// the end of the list then we start at the end of the list and search
|
|
|
|
// backwards until we get back to the original item or an enabled option
|
|
|
|
//
|
|
|
|
// anNewIndex - will get set to the new index if it finds one
|
|
|
|
// anOldIndex - gets sets to the old index if a new index is found
|
|
|
|
// aDoSetNewIndex - indicates that a new item was found and it can be selected
|
|
|
|
// aWasDisabled - means it found a new item but it was disabled
|
|
|
|
// aNumOptions - the total number of options in the list
|
|
|
|
// aDoAdjustInc - the initial increment 1-n
|
|
|
|
// aDoAdjustIncNext - the increment used to search for the next enabled option
|
|
|
|
void
|
|
|
|
nsListControlFrame::AdjustIndexForDisabledOpt(PRInt32 &anNewIndex, PRInt32 &anOldIndex,
|
|
|
|
PRBool &aDoSetNewIndex, PRBool &aWasDisabled,
|
|
|
|
PRInt32 aNumOptions, PRInt32 aDoAdjustInc,
|
|
|
|
PRInt32 aDoAdjustIncNext)
|
|
|
|
{
|
|
|
|
// the aDoAdjustInc could be a "1" for a single item or
|
|
|
|
// any number greater representing a page of items
|
|
|
|
//
|
|
|
|
PRInt32 newIndex = anNewIndex + aDoAdjustInc;
|
|
|
|
PRBool doingReverse = PR_FALSE; // means we reached the end of the list and now we are searching backwards
|
|
|
|
PRInt32 bottom = 0; // lowest index in the search range
|
|
|
|
PRInt32 top = aNumOptions;// highest index in the search range
|
|
|
|
|
|
|
|
// make sure we start off in the range
|
|
|
|
if (newIndex < bottom) {
|
|
|
|
newIndex = 0;
|
|
|
|
} else if (newIndex >= top) {
|
2000-08-29 13:24:38 +00:00
|
|
|
newIndex = aNumOptions-1;
|
2000-08-17 21:38:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
aWasDisabled = PR_FALSE;
|
|
|
|
while (1) {
|
|
|
|
// Special Debug Code
|
2000-10-28 22:17:53 +00:00
|
|
|
//printf("T:%d B:%d I:%d R:%d IM:%d I:%d\n", top, bottom, newIndex, aDoAdjustInc, aDoAdjustIncNext, doingReverse);
|
2000-08-17 21:38:15 +00:00
|
|
|
//if (newIndex < -30 || newIndex > 30) {
|
2000-10-28 22:17:53 +00:00
|
|
|
// printf("********************************* Stopped!\n");
|
2000-08-17 21:38:15 +00:00
|
|
|
// return;
|
|
|
|
//}
|
|
|
|
// if the newIndex isn't disabled, we are golden, bail out
|
|
|
|
if (NS_OK == IsOptionDisabled(newIndex, aWasDisabled) && !aWasDisabled) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// it WAS disabled, so sart looking ahead for the next enabled option
|
|
|
|
newIndex += aDoAdjustIncNext;
|
|
|
|
|
|
|
|
// well, if we reach end reverse the search
|
|
|
|
if (newIndex < bottom) {
|
|
|
|
if (doingReverse) {
|
|
|
|
return; // if we are in reverse mode and reach the end bail out
|
|
|
|
} else {
|
|
|
|
// reset the newIndex to the end of the list we hit
|
|
|
|
// reverse the incrementer
|
|
|
|
// set the other end of the list to our original starting index
|
|
|
|
newIndex = bottom;
|
|
|
|
aDoAdjustIncNext = -aDoAdjustIncNext;
|
|
|
|
doingReverse = PR_TRUE;
|
|
|
|
top = anNewIndex;
|
|
|
|
}
|
|
|
|
} else if (newIndex >= top) {
|
|
|
|
if (doingReverse) {
|
|
|
|
return; // if we are in reverse mode and reach the end bail out
|
|
|
|
} else {
|
|
|
|
// reset the newIndex to the end of the list we hit
|
|
|
|
// reverse the incrementer
|
|
|
|
// set the other end of the list to our original starting index
|
|
|
|
newIndex = top - 1;
|
|
|
|
aDoAdjustIncNext = -aDoAdjustIncNext;
|
|
|
|
doingReverse = PR_TRUE;
|
|
|
|
bottom = anNewIndex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Looks like we found one
|
|
|
|
anOldIndex = anNewIndex;
|
|
|
|
anNewIndex = newIndex;
|
|
|
|
aDoSetNewIndex = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
1999-08-27 14:42:27 +00:00
|
|
|
nsresult
|
2000-05-03 22:01:47 +00:00
|
|
|
nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent)
|
1999-08-27 14:42:27 +00:00
|
|
|
{
|
2000-03-07 15:54:31 +00:00
|
|
|
NS_ASSERTION(aKeyEvent != nsnull, "keyEvent is null.");
|
|
|
|
|
1999-11-12 15:08:28 +00:00
|
|
|
if (nsFormFrame::GetDisabled(this))
|
|
|
|
return NS_OK;
|
|
|
|
|
2000-08-03 14:13:58 +00:00
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
|
|
|
PRUint32 code = 0;
|
|
|
|
PRUint32 numOptions = 0;
|
|
|
|
PRBool isShift = PR_FALSE;
|
|
|
|
nsCOMPtr<nsIDOMHTMLCollection> options;
|
|
|
|
|
|
|
|
// Start by making sure we can query for a key event
|
1999-11-03 07:11:45 +00:00
|
|
|
nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aKeyEvent);
|
|
|
|
if (keyEvent) {
|
1999-10-01 14:30:33 +00:00
|
|
|
//uiEvent->GetCharCode(&code);
|
2000-03-07 15:54:31 +00:00
|
|
|
//REFLOW_DEBUG_MSG3("%c %d ", code, code);
|
1999-11-03 07:11:45 +00:00
|
|
|
keyEvent->GetKeyCode(&code);
|
2000-05-08 22:18:38 +00:00
|
|
|
if (code == 0) {
|
|
|
|
keyEvent->GetCharCode(&code);
|
|
|
|
}
|
2000-03-15 15:55:30 +00:00
|
|
|
#ifdef DO_REFLOW_DEBUG
|
|
|
|
if (code >= 32) {
|
|
|
|
REFLOW_DEBUG_MSG3("KeyCode: %c %d\n", code, code);
|
|
|
|
}
|
|
|
|
#endif
|
2000-08-29 13:24:38 +00:00
|
|
|
PRBool isControl = PR_FALSE;
|
|
|
|
PRBool isAlt = PR_FALSE;
|
|
|
|
PRBool isMeta = PR_FALSE;
|
|
|
|
keyEvent->GetCtrlKey(&isControl);
|
2000-10-12 14:20:02 +00:00
|
|
|
keyEvent->GetMetaKey(&isMeta);
|
2000-12-20 15:15:28 +00:00
|
|
|
if (isControl || isMeta) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
keyEvent->GetAltKey(&isAlt);
|
|
|
|
// Fix for Bug 62425
|
|
|
|
if (isAlt) {
|
|
|
|
#ifdef FIX_FOR_BUG_62425
|
|
|
|
if (code == nsIDOMKeyEvent::DOM_VK_UP || code == nsIDOMKeyEvent::DOM_VK_DOWN) {
|
|
|
|
if (IsInDropDownMode() == PR_TRUE) {
|
|
|
|
PRBool isDroppedDown;
|
|
|
|
mComboboxFrame->IsDroppedDown(&isDroppedDown);
|
|
|
|
mComboboxFrame->ShowDropDown(!isDroppedDown);
|
|
|
|
aKeyEvent->PreventDefault();
|
|
|
|
aKeyEvent->PreventCapture();
|
|
|
|
aKeyEvent->PreventBubble();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2000-08-29 13:24:38 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-03-15 15:55:30 +00:00
|
|
|
|
|
|
|
keyEvent->GetShiftKey(&isShift);
|
1999-09-30 11:37:58 +00:00
|
|
|
|
2000-08-03 14:13:58 +00:00
|
|
|
// now make sure there are options or we are wasting our time
|
|
|
|
options = getter_AddRefs(GetOptions(mContent));
|
1999-08-27 14:42:27 +00:00
|
|
|
|
2000-02-12 16:21:37 +00:00
|
|
|
if (options) {
|
1999-09-30 11:37:58 +00:00
|
|
|
options->GetLength(&numOptions);
|
1999-08-27 14:42:27 +00:00
|
|
|
|
1999-09-30 11:37:58 +00:00
|
|
|
if (numOptions == 0) {
|
2000-08-03 14:13:58 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
} else{
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We are handling this so don't let it bubble up
|
|
|
|
aKeyEvent->PreventBubble();
|
|
|
|
|
|
|
|
// this tells us whether we need to process the new index that was set
|
|
|
|
// DOM_VK_RETURN & DOM_VK_ESCAPE will leave this false
|
|
|
|
PRBool doSetNewIndex = PR_FALSE;
|
|
|
|
|
|
|
|
// set up the old and new selected index and process it
|
|
|
|
// DOM_VK_RETURN selects the item
|
|
|
|
// DOM_VK_ESCAPE cancels the selection
|
|
|
|
// default processing checks to see if the pressed the first
|
|
|
|
// letter of an item in the list and advances to it
|
|
|
|
|
|
|
|
switch (code) {
|
|
|
|
|
|
|
|
case nsIDOMKeyEvent::DOM_VK_UP:
|
|
|
|
case nsIDOMKeyEvent::DOM_VK_LEFT: {
|
|
|
|
REFLOW_DEBUG_MSG2("DOM_VK_UP mSelectedIndex: %d ", mSelectedIndex);
|
|
|
|
if (mSelectedIndex > 0) {
|
2000-08-17 21:38:15 +00:00
|
|
|
PRBool wasDisabled;
|
|
|
|
AdjustIndexForDisabledOpt(mSelectedIndex, mOldSelectedIndex,
|
|
|
|
doSetNewIndex, wasDisabled,
|
|
|
|
(PRInt32)numOptions, -1, -1);
|
2000-08-03 14:13:58 +00:00
|
|
|
}
|
|
|
|
REFLOW_DEBUG_MSG2(" After: %d\n", mSelectedIndex);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case nsIDOMKeyEvent::DOM_VK_DOWN:
|
|
|
|
case nsIDOMKeyEvent::DOM_VK_RIGHT: {
|
|
|
|
REFLOW_DEBUG_MSG2("DOM_VK_DOWN mSelectedIndex: %d ", mSelectedIndex);
|
2000-08-17 21:38:15 +00:00
|
|
|
|
2000-08-29 13:24:38 +00:00
|
|
|
if (mSelectedIndex < (PRInt32)(numOptions-1)) {
|
2000-08-17 21:38:15 +00:00
|
|
|
PRBool wasDisabled;
|
|
|
|
AdjustIndexForDisabledOpt(mSelectedIndex, mOldSelectedIndex,
|
|
|
|
doSetNewIndex, wasDisabled,
|
|
|
|
(PRInt32)numOptions, 1, 1);
|
2000-08-03 14:13:58 +00:00
|
|
|
}
|
|
|
|
REFLOW_DEBUG_MSG2(" After: %d\n", mSelectedIndex);
|
|
|
|
} break;
|
1999-11-12 15:08:28 +00:00
|
|
|
|
2000-08-03 14:13:58 +00:00
|
|
|
case nsIDOMKeyEvent::DOM_VK_RETURN: {
|
2000-08-17 21:38:15 +00:00
|
|
|
if (mComboboxFrame != nsnull) {
|
2000-12-20 15:15:28 +00:00
|
|
|
if (IsInDropDownMode() == PR_TRUE) {
|
|
|
|
PRBool isDroppedDown;
|
|
|
|
mComboboxFrame->IsDroppedDown(&isDroppedDown);
|
2000-08-17 21:38:15 +00:00
|
|
|
mComboboxFrame->ListWasSelected(mPresContext, isDroppedDown);
|
|
|
|
} else {
|
|
|
|
UpdateSelection(PR_TRUE, PR_FALSE, mContent);
|
|
|
|
}
|
|
|
|
}
|
2000-08-03 14:13:58 +00:00
|
|
|
} break;
|
2000-05-03 22:01:47 +00:00
|
|
|
|
2000-08-03 14:13:58 +00:00
|
|
|
case nsIDOMKeyEvent::DOM_VK_ESCAPE: {
|
2000-12-20 15:15:28 +00:00
|
|
|
if (IsInDropDownMode() == PR_TRUE) {
|
2000-08-03 14:13:58 +00:00
|
|
|
ResetSelectedItem();
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case nsIDOMKeyEvent::DOM_VK_PAGE_UP: {
|
|
|
|
if (mSelectedIndex > 0) {
|
2000-08-17 21:38:15 +00:00
|
|
|
PRBool wasDisabled;
|
|
|
|
AdjustIndexForDisabledOpt(mSelectedIndex, mOldSelectedIndex,
|
|
|
|
doSetNewIndex, wasDisabled,
|
|
|
|
(PRInt32)numOptions, -(mNumDisplayRows-1), -1);
|
2000-08-03 14:13:58 +00:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case nsIDOMKeyEvent::DOM_VK_PAGE_DOWN: {
|
2000-08-29 13:24:38 +00:00
|
|
|
if (mSelectedIndex < (PRInt32)(numOptions-1)) {
|
2000-08-17 21:38:15 +00:00
|
|
|
PRBool wasDisabled;
|
|
|
|
AdjustIndexForDisabledOpt(mSelectedIndex, mOldSelectedIndex,
|
|
|
|
doSetNewIndex, wasDisabled,
|
|
|
|
(PRInt32)numOptions, (mNumDisplayRows-1), 1);
|
2000-08-03 14:13:58 +00:00
|
|
|
}
|
|
|
|
} break;
|
2000-03-07 15:54:31 +00:00
|
|
|
|
2000-08-03 14:13:58 +00:00
|
|
|
case nsIDOMKeyEvent::DOM_VK_HOME: {
|
|
|
|
if (mSelectedIndex > 0) {
|
|
|
|
mOldSelectedIndex = mSelectedIndex;
|
|
|
|
mSelectedIndex = 0;
|
|
|
|
doSetNewIndex = PR_TRUE;
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case nsIDOMKeyEvent::DOM_VK_END: {
|
|
|
|
if ((mSelectedIndex+1) < (PRInt32)numOptions) {
|
|
|
|
mOldSelectedIndex = mSelectedIndex;
|
|
|
|
mSelectedIndex = (PRInt32)numOptions-1;
|
|
|
|
if (mSelectedIndex > (PRInt32)numOptions) {
|
|
|
|
mSelectedIndex = (PRInt32)numOptions-1;
|
|
|
|
}
|
|
|
|
doSetNewIndex = PR_TRUE;
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
|
|
|
|
default: { // Select option with this as the first character
|
|
|
|
// XXX Not I18N compliant
|
2000-12-20 15:15:28 +00:00
|
|
|
code = (PRUint32)nsCRT::ToLower((PRUnichar)code);
|
2000-08-03 14:13:58 +00:00
|
|
|
PRInt32 selectedIndex = (mSelectedIndex == kNothingSelected ? 0 : mSelectedIndex+1) % numOptions;
|
|
|
|
PRInt32 startedAtIndex = selectedIndex;
|
|
|
|
PRBool loopedAround = PR_FALSE;
|
|
|
|
while ((selectedIndex < startedAtIndex && loopedAround) || !loopedAround) {
|
|
|
|
nsCOMPtr<nsIDOMHTMLOptionElement>optionElement = getter_AddRefs(GetOption(*options, selectedIndex));
|
|
|
|
if (optionElement) {
|
2001-03-08 02:29:21 +00:00
|
|
|
PRBool isDisabled = PR_FALSE;
|
|
|
|
optionElement->GetDisabled(&isDisabled);
|
|
|
|
if (!isDisabled) {
|
|
|
|
nsAutoString text;
|
|
|
|
if (NS_OK == optionElement->GetText(text)) {
|
|
|
|
text.ToLowerCase();
|
|
|
|
PRUnichar firstChar = text.CharAt(0);
|
|
|
|
if (firstChar == (PRUnichar)code) {
|
|
|
|
mOldSelectedIndex = mSelectedIndex;
|
|
|
|
mSelectedIndex = selectedIndex;
|
|
|
|
SingleSelection();
|
|
|
|
if (nsnull != mComboboxFrame && mIsAllFramesHere) {
|
|
|
|
mComboboxFrame->UpdateSelection(PR_TRUE, PR_TRUE, mSelectedIndex); // dispatch event
|
|
|
|
} else {
|
|
|
|
UpdateSelection(PR_TRUE, PR_FALSE, GetOptionContent(mSelectedIndex)); // dispatch event
|
|
|
|
}
|
|
|
|
break;
|
2000-03-18 14:17:34 +00:00
|
|
|
}
|
1999-09-30 11:37:58 +00:00
|
|
|
}
|
2000-08-03 14:13:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
selectedIndex++;
|
|
|
|
if (selectedIndex == (PRInt32)numOptions) {
|
|
|
|
selectedIndex = 0;
|
|
|
|
loopedAround = PR_TRUE;
|
|
|
|
}
|
2000-03-15 15:55:30 +00:00
|
|
|
|
2000-08-03 14:13:58 +00:00
|
|
|
} // while
|
|
|
|
} break;//case
|
|
|
|
} // switch
|
2000-03-15 15:55:30 +00:00
|
|
|
|
2000-08-03 14:13:58 +00:00
|
|
|
// actually process the new index and let the selection code
|
|
|
|
// the scrolling for us
|
|
|
|
if (doSetNewIndex) {
|
|
|
|
PRBool multipleSelections = PR_FALSE;
|
|
|
|
GetMultiple(&multipleSelections);
|
|
|
|
if (multipleSelections && isShift) {
|
|
|
|
REFLOW_DEBUG_MSG2("mStartExtendedIndex: %d\n", mStartExtendedIndex);
|
1999-10-01 14:30:33 +00:00
|
|
|
|
2000-08-29 13:24:38 +00:00
|
|
|
// determine the direct it is moving and this if the select should be added to or not
|
|
|
|
PRBool appendSel = ((code == nsIDOMKeyEvent::DOM_VK_UP || code == nsIDOMKeyEvent::DOM_VK_LEFT) &&
|
|
|
|
mSelectedIndex < mStartExtendedIndex) ||
|
|
|
|
((code == nsIDOMKeyEvent::DOM_VK_DOWN || code == nsIDOMKeyEvent::DOM_VK_RIGHT) &&
|
|
|
|
mSelectedIndex > mStartExtendedIndex);
|
|
|
|
if (appendSel) {
|
2000-08-03 14:13:58 +00:00
|
|
|
SetContentSelected(mSelectedIndex, PR_TRUE);
|
|
|
|
} else {
|
|
|
|
SetContentSelected(mSelectedIndex, PR_TRUE);
|
|
|
|
SetContentSelected(mOldSelectedIndex, PR_FALSE);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
SingleSelection();
|
|
|
|
if (nsnull != mComboboxFrame && mIsAllFramesHere) {
|
|
|
|
mComboboxFrame->UpdateSelection(PR_TRUE, PR_TRUE, mSelectedIndex); // dispatch event
|
|
|
|
} else {
|
|
|
|
UpdateSelection(PR_TRUE, PR_FALSE, GetOptionContent(mSelectedIndex)); // dispatch event
|
|
|
|
}
|
|
|
|
mStartExtendedIndex = mSelectedIndex;
|
|
|
|
mEndExtendedIndex = kNothingSelected;
|
1999-08-27 14:42:27 +00:00
|
|
|
}
|
2000-08-03 14:13:58 +00:00
|
|
|
// XXX - Are we cover up a problem here???
|
|
|
|
// Why aren't they getting flushed each time?
|
|
|
|
// because this isn't needed for Gfx
|
2000-12-20 15:15:28 +00:00
|
|
|
if (IsInDropDownMode() == PR_TRUE) {
|
2000-08-03 14:13:58 +00:00
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
mPresContext->GetShell(getter_AddRefs(presShell));
|
|
|
|
presShell->FlushPendingNotifications();
|
|
|
|
}
|
|
|
|
REFLOW_DEBUG_MSG2(" After: %d\n", mSelectedIndex);
|
|
|
|
} else {
|
|
|
|
REFLOW_DEBUG_MSG(" After: SKIPPED it\n");
|
1999-08-27 14:42:27 +00:00
|
|
|
}
|
2000-08-03 14:13:58 +00:00
|
|
|
|
1999-08-27 14:42:27 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-08-06 14:14:38 +00:00
|
|
|
|
1999-09-15 05:31:31 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIStatefulFrame
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
1999-10-26 04:44:41 +00:00
|
|
|
nsListControlFrame::GetStateType(nsIPresContext* aPresContext,
|
|
|
|
nsIStatefulFrame::StateType* aStateType)
|
1999-09-15 05:31:31 +00:00
|
|
|
{
|
|
|
|
*aStateType = nsIStatefulFrame::eSelectType;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-03-03 04:28:59 +00:00
|
|
|
//----------------------------------------------------------------------
|
1999-09-15 05:31:31 +00:00
|
|
|
NS_IMETHODIMP
|
2000-03-03 04:28:59 +00:00
|
|
|
nsListControlFrame::SaveStateInternal(nsIPresContext* aPresContext, nsIPresState** aState)
|
1999-09-15 05:31:31 +00:00
|
|
|
{
|
2001-02-06 01:59:59 +00:00
|
|
|
PRBool saveState = PR_FALSE;
|
|
|
|
nsresult res = NS_OK;
|
|
|
|
|
|
|
|
// Determine if we need to save state (non-default options selected)
|
|
|
|
PRInt32 i, numOptions = 0;
|
|
|
|
GetNumberOfOptions(&numOptions);
|
|
|
|
for (i = 0; i < numOptions; i++) {
|
|
|
|
nsCOMPtr<nsIContent> content = dont_AddRef(GetOptionContent(i));
|
|
|
|
nsCOMPtr<nsIDOMHTMLOptionElement> option(do_QueryInterface(content));
|
|
|
|
if (option) {
|
|
|
|
PRBool stateBool = IsContentSelected(content);
|
|
|
|
PRBool defaultStateBool = PR_FALSE;
|
|
|
|
res = option->GetDefaultSelected(&defaultStateBool);
|
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
|
|
|
|
|
|
|
if (stateBool != defaultStateBool) {
|
|
|
|
saveState = PR_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (saveState) {
|
|
|
|
nsCOMPtr<nsISupportsArray> value;
|
|
|
|
nsresult res = NS_NewISupportsArray(getter_AddRefs(value));
|
|
|
|
NS_ENSURE_TRUE(value, res);
|
|
|
|
|
|
|
|
PRInt32 j = 0;
|
|
|
|
for (i = 0; i < numOptions; i++) {
|
|
|
|
if (IsContentSelectedByIndex(i)) {
|
2000-12-20 15:15:28 +00:00
|
|
|
#ifdef FIX_FOR_BUG_50376
|
|
|
|
res = SetOptionIntoPresState(value, i, j++);
|
|
|
|
#else
|
2001-02-06 01:59:59 +00:00
|
|
|
nsCOMPtr<nsISupportsPRInt32> thisVal(do_CreateInstance(NS_SUPPORTS_PRINT32_CONTRACTID));
|
|
|
|
NS_ENSURE_TRUE(thisVal, res);
|
|
|
|
|
|
|
|
res = thisVal->SetData(i);
|
|
|
|
NS_ENSURE_SUCCEEDED(res, res);
|
|
|
|
|
|
|
|
PRBool okay = value->InsertElementAt((nsISupports *)thisVal, j++);
|
|
|
|
NS_ENSURE_TRUE(okay, NS_ERROR_OUT_OF_MEMORY);
|
2000-12-20 15:15:28 +00:00
|
|
|
#endif
|
1999-09-15 05:31:31 +00:00
|
|
|
}
|
|
|
|
}
|
2001-02-06 01:59:59 +00:00
|
|
|
|
|
|
|
res = NS_NewPresState(aState);
|
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
|
|
|
res = (*aState)->SetStatePropertyAsSupports(NS_LITERAL_STRING("selecteditems"), value);
|
1999-09-15 05:31:31 +00:00
|
|
|
}
|
2000-01-14 09:28:54 +00:00
|
|
|
|
1999-09-15 05:31:31 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2000-03-03 04:28:59 +00:00
|
|
|
//----------------------------------------------------------------------
|
1999-09-15 05:31:31 +00:00
|
|
|
NS_IMETHODIMP
|
2000-03-03 04:28:59 +00:00
|
|
|
nsListControlFrame::SaveState(nsIPresContext* aPresContext,
|
|
|
|
nsIPresState** aState)
|
1999-09-15 05:31:31 +00:00
|
|
|
{
|
2001-02-06 01:59:59 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aState);
|
|
|
|
|
2000-03-03 04:28:59 +00:00
|
|
|
if (mComboboxFrame == nsnull) {
|
2001-02-06 01:59:59 +00:00
|
|
|
return SaveStateInternal(aPresContext, aState);
|
2000-03-03 04:28:59 +00:00
|
|
|
}
|
2000-01-14 09:28:54 +00:00
|
|
|
|
2000-03-03 04:28:59 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2000-02-15 15:04:38 +00:00
|
|
|
|
2000-03-03 04:28:59 +00:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::RestoreStateInternal(nsIPresContext* aPresContext,
|
|
|
|
nsIPresState* aState)
|
|
|
|
{
|
|
|
|
mPresState = aState;
|
2001-02-06 01:59:59 +00:00
|
|
|
|
|
|
|
if (mHasBeenInitialized) { // Already called Reset, call again to update selection
|
|
|
|
Reset(aPresContext);
|
|
|
|
}
|
2000-03-03 04:28:59 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-02-15 15:04:38 +00:00
|
|
|
|
2000-03-03 04:28:59 +00:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::RestoreState(nsIPresContext* aPresContext,
|
|
|
|
nsIPresState* aState)
|
|
|
|
{
|
2001-02-06 01:59:59 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aState);
|
2000-03-03 04:28:59 +00:00
|
|
|
// ignore requests for saving state that are made directly
|
|
|
|
// to the list frame by the system
|
|
|
|
// The combobox frame will call RestoreStateInternal
|
|
|
|
// to have its state saved.
|
|
|
|
//
|
|
|
|
// mComboboxFrame is null when it is a stand-alone listbox
|
|
|
|
if (mComboboxFrame == nsnull) {
|
|
|
|
return RestoreStateInternal(aPresContext, aState);
|
1999-09-15 05:31:31 +00:00
|
|
|
}
|
2000-03-03 04:28:59 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
1999-09-15 05:31:31 +00:00
|
|
|
}
|
2000-08-14 14:42:12 +00:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* nsListEventListener
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
NS_NewListEventListener(nsIListEventListener ** aInstancePtr)
|
|
|
|
{
|
|
|
|
nsListEventListener* it = new nsListEventListener();
|
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
return it->QueryInterface(NS_GET_IID(nsIListEventListener), (void **) aInstancePtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF(nsListEventListener)
|
|
|
|
|
|
|
|
NS_IMPL_RELEASE(nsListEventListener)
|
|
|
|
|
|
|
|
|
|
|
|
nsListEventListener::nsListEventListener()
|
|
|
|
{
|
|
|
|
NS_INIT_REFCNT();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsListEventListener::~nsListEventListener()
|
|
|
|
{
|
|
|
|
// all refcounted objects are held as nsCOMPtrs, clear themselves
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListEventListener::SetFrame(nsListControlFrame *aFrame)
|
|
|
|
{
|
|
|
|
mFrame.SetReference(aFrame->WeakReferent());
|
|
|
|
if (aFrame)
|
|
|
|
{
|
|
|
|
aFrame->GetContent(getter_AddRefs(mContent));
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsListEventListener::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|
|
|
{
|
|
|
|
if (nsnull == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
if (aIID.Equals(NS_GET_IID(nsISupports))) {
|
|
|
|
nsIDOMKeyListener *tmp = this;
|
|
|
|
nsISupports *tmp2 = tmp;
|
|
|
|
*aInstancePtr = (void*) tmp2;
|
|
|
|
NS_ADDREF_THIS();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aIID.Equals(NS_GET_IID(nsIDOMEventListener))) {
|
|
|
|
nsIDOMKeyListener *kl = (nsIDOMKeyListener*)this;
|
|
|
|
nsIDOMEventListener *temp = kl;
|
|
|
|
*aInstancePtr = (void*)temp;
|
|
|
|
NS_ADDREF_THIS();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aIID.Equals(NS_GET_IID(nsIDOMMouseMotionListener))) {
|
|
|
|
*aInstancePtr = (void*)(nsIDOMMouseMotionListener*) this;
|
|
|
|
NS_ADDREF_THIS();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
if (aIID.Equals(NS_GET_IID(nsIDOMKeyListener))) {
|
|
|
|
*aInstancePtr = (void*)(nsIDOMKeyListener*)this;
|
|
|
|
NS_ADDREF_THIS();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
if (aIID.Equals(NS_GET_IID(nsIDOMMouseListener))) {
|
|
|
|
*aInstancePtr = (void*)(nsIDOMMouseListener*)this;
|
|
|
|
NS_ADDREF_THIS();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
if (aIID.Equals(NS_GET_IID(nsIListEventListener))) {
|
|
|
|
*aInstancePtr = (void*)(nsIListEventListener*)this;
|
|
|
|
NS_ADDREF_THIS();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsListEventListener::HandleEvent(nsIDOMEvent* aEvent)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*================== nsIKeyListener =========================*/
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsListEventListener::KeyDown(nsIDOMEvent* aKeyEvent)
|
|
|
|
{
|
|
|
|
nsListControlFrame *gfxFrame = mFrame.Reference();
|
|
|
|
if (gfxFrame && mContent)
|
|
|
|
{
|
|
|
|
return gfxFrame->KeyDown(aKeyEvent);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsListEventListener::KeyUp(nsIDOMEvent* aKeyEvent)
|
|
|
|
{
|
|
|
|
nsListControlFrame *gfxFrame = mFrame.Reference();
|
|
|
|
if (gfxFrame && mContent)
|
|
|
|
{
|
|
|
|
return gfxFrame->KeyUp(aKeyEvent);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsListEventListener::KeyPress(nsIDOMEvent* aKeyEvent)
|
|
|
|
{
|
|
|
|
nsListControlFrame *gfxFrame = mFrame.Reference();
|
|
|
|
if (gfxFrame && mContent)
|
|
|
|
{
|
|
|
|
return gfxFrame->KeyPress(aKeyEvent);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*=============== nsIMouseListener ======================*/
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsListEventListener::MouseDown(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
|
|
|
nsListControlFrame *gfxFrame = mFrame.Reference();
|
|
|
|
if (gfxFrame && mContent)
|
|
|
|
{
|
|
|
|
return gfxFrame->MouseDown(aMouseEvent);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsListEventListener::MouseUp(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
|
|
|
nsListControlFrame *gfxFrame = mFrame.Reference();
|
|
|
|
if (gfxFrame && mContent)
|
|
|
|
{
|
|
|
|
return gfxFrame->MouseUp(aMouseEvent);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsListEventListener::MouseClick(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
|
|
|
nsListControlFrame *gfxFrame = mFrame.Reference();
|
|
|
|
if (gfxFrame && mContent)
|
|
|
|
{
|
|
|
|
return gfxFrame->MouseClick(aMouseEvent);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsListEventListener::MouseDblClick(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
|
|
|
nsListControlFrame *gfxFrame = mFrame.Reference();
|
|
|
|
if (gfxFrame && mContent)
|
|
|
|
{
|
|
|
|
return gfxFrame->MouseDblClick(aMouseEvent);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsListEventListener::MouseOver(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
|
|
|
nsListControlFrame *gfxFrame = mFrame.Reference();
|
|
|
|
if (gfxFrame && mContent)
|
|
|
|
{
|
|
|
|
return gfxFrame->MouseOver(aMouseEvent);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsListEventListener::MouseOut(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
|
|
|
nsListControlFrame *gfxFrame = mFrame.Reference();
|
|
|
|
if (gfxFrame && mContent)
|
|
|
|
{
|
|
|
|
return gfxFrame->MouseOut(aMouseEvent);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*=============== nsIDOMMouseMotionListener ======================*/
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsListEventListener::MouseMove(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
|
|
|
nsListControlFrame *gfxFrame = mFrame.Reference();
|
|
|
|
if (gfxFrame && mContent)
|
|
|
|
{
|
|
|
|
return gfxFrame->MouseMove(aMouseEvent);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsListEventListener::DragMove(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
nsListControlFrame *gfxFrame = mFrame.Reference();
|
|
|
|
if (gfxFrame && mContent)
|
|
|
|
{
|
|
|
|
return gfxFrame->DragMove(aMouseEvent);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|