1999-01-18 18:14:00 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (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/
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape Communications
|
|
|
|
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
|
|
|
* Netscape Communications Corporation. All Rights Reserved.
|
|
|
|
*/
|
1999-02-12 20:45:58 +03:00
|
|
|
#include "nsCOMPtr.h"
|
1999-01-18 18:14:00 +03:00
|
|
|
#include "nsListControlFrame.h"
|
1999-10-08 01:39:50 +04:00
|
|
|
#include "nsFormControlFrame.h" // for COMPARE macro
|
1999-01-18 18:14:00 +03:00
|
|
|
#include "nsFormControlHelper.h"
|
|
|
|
#include "nsHTMLIIDs.h"
|
|
|
|
#include "nsHTMLAtoms.h"
|
|
|
|
#include "nsIHTMLContent.h"
|
|
|
|
#include "nsIFormControl.h"
|
|
|
|
#include "nsINameSpaceManager.h"
|
1999-03-23 00:32:12 +03:00
|
|
|
#include "nsIDeviceContext.h"
|
|
|
|
#include "nsIDOMHTMLCollection.h"
|
|
|
|
#include "nsIDOMHTMLSelectElement.h"
|
|
|
|
#include "nsIDOMHTMLOptionElement.h"
|
1999-01-18 18:14:00 +03:00
|
|
|
#include "nsIComboboxControlFrame.h"
|
|
|
|
#include "nsIViewManager.h"
|
|
|
|
#include "nsFormFrame.h"
|
1999-03-23 00:32:12 +03:00
|
|
|
#include "nsIScrollableView.h"
|
1999-05-08 00:30:16 +04:00
|
|
|
#include "nsIDOMHTMLOptGroupElement.h"
|
1999-05-28 01:17:10 +04:00
|
|
|
#include "nsWidgetsCID.h"
|
|
|
|
#include "nsIReflowCommand.h"
|
1999-08-06 18:14:38 +04:00
|
|
|
#include "nsIPresShell.h"
|
1999-08-26 18:54:07 +04:00
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsIDOMEventReceiver.h"
|
|
|
|
#include "nsIEventStateManager.h"
|
|
|
|
#include "nsIDOMUIEvent.h"
|
1999-10-06 03:43:06 +04:00
|
|
|
#include "nsIPrivateDOMEvent.h"
|
1999-09-15 09:31:31 +04:00
|
|
|
#include "nsIStatefulFrame.h"
|
|
|
|
#include "nsISupportsArray.h"
|
|
|
|
#include "nsISupportsPrimitives.h"
|
|
|
|
#include "nsIComponentManager.h"
|
1999-10-08 01:39:50 +04:00
|
|
|
#include "nsILookAndFeel.h"
|
1999-08-26 18:54:07 +04:00
|
|
|
|
|
|
|
static NS_DEFINE_IID(kIDOMMouseListenerIID, NS_IDOMMOUSELISTENER_IID);
|
|
|
|
static NS_DEFINE_IID(kIDOMMouseMotionListenerIID, NS_IDOMMOUSEMOTIONLISTENER_IID);
|
1999-08-27 18:42:27 +04:00
|
|
|
static NS_DEFINE_IID(kIDOMKeyListenerIID, NS_IDOMKEYLISTENER_IID);
|
1999-10-06 03:43:06 +04:00
|
|
|
static NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID);
|
|
|
|
static NS_DEFINE_IID(kIFrameIID, NS_IFRAME_IID);
|
|
|
|
static NS_DEFINE_IID(kIPrivateDOMEventIID, NS_IPRIVATEDOMEVENT_IID);
|
1999-05-08 00:30:16 +04:00
|
|
|
|
1999-01-18 18:14:00 +03:00
|
|
|
// Constants
|
1999-07-29 01:38:08 +04:00
|
|
|
const nscoord kMaxDropDownRows = 20; // This matches the setting for 4.x browsers
|
1999-07-21 02:32:41 +04:00
|
|
|
const PRInt32 kDefaultMultiselectHeight = 4; // This is compatible with 4.x browsers
|
1999-07-29 01:38:08 +04: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-08 00:30:16 +04:00
|
|
|
|
1999-04-13 02:14:31 +04: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-03-03 01:43:26 +03:00
|
|
|
const char * kMozSelected = "-moz-option-selected";
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 18:14:00 +03:00
|
|
|
nsresult
|
1999-05-12 02:03:29 +04:00
|
|
|
NS_NewListControlFrame(nsIFrame** aNewFrame)
|
1999-01-18 18:14:00 +03:00
|
|
|
{
|
1999-05-12 02:03:29 +04:00
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-01-18 18:14:00 +03:00
|
|
|
nsListControlFrame* it = new nsListControlFrame;
|
1999-05-12 02:03:29 +04:00
|
|
|
if (!it) {
|
1999-01-18 18:14:00 +03:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-05-12 02:03:29 +04:00
|
|
|
*aNewFrame = it;
|
1999-01-18 18:14:00 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 18:14:00 +03:00
|
|
|
nsListControlFrame::nsListControlFrame()
|
|
|
|
{
|
1999-08-26 18:54:07 +04:00
|
|
|
mHitFrame = nsnull;
|
|
|
|
mSelectedIndex = kNothingSelected;
|
|
|
|
mComboboxFrame = nsnull;
|
|
|
|
mFormFrame = nsnull;
|
|
|
|
mDisplayed = PR_FALSE;
|
|
|
|
mButtonDown = PR_FALSE;
|
|
|
|
mLastFrame = nsnull;
|
|
|
|
mMaxWidth = 0;
|
|
|
|
mMaxHeight = 0;
|
|
|
|
mPresContext = nsnull;
|
|
|
|
mEndExtendedIndex = kNothingSelected;
|
|
|
|
mStartExtendedIndex = kNothingSelected;
|
|
|
|
mIgnoreMouseUp = 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-15 02:00:24 +04:00
|
|
|
mIsCapturingMouseEvents = PR_FALSE;
|
1999-10-06 03:43:06 +04:00
|
|
|
mSelectionCache = nsnull;
|
|
|
|
mSelectionCacheLength = -1;
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 18:14:00 +03:00
|
|
|
nsListControlFrame::~nsListControlFrame()
|
|
|
|
{
|
1999-10-21 01:59:04 +04:00
|
|
|
// if list is dropped down
|
|
|
|
// make sure it gets rolled up
|
|
|
|
if (IsInDropDownMode()) {
|
|
|
|
PRBool isDown;
|
|
|
|
mComboboxFrame->IsDroppedDown(&isDown);
|
|
|
|
if (isDown) {
|
|
|
|
mComboboxFrame->ShowDropDown(PR_FALSE);
|
|
|
|
}
|
|
|
|
}
|
1999-08-31 17:22:50 +04:00
|
|
|
|
|
|
|
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.
|
|
|
|
reciever->RemoveEventListenerByIID((nsIDOMMouseListener *)this, kIDOMMouseListenerIID);
|
|
|
|
reciever->RemoveEventListenerByIID((nsIDOMMouseMotionListener *)this, kIDOMMouseMotionListenerIID);
|
|
|
|
reciever->RemoveEventListenerByIID((nsIDOMKeyListener *)this, kIDOMKeyListenerIID);
|
|
|
|
|
1999-05-08 00:30:16 +04:00
|
|
|
mComboboxFrame = nsnull;
|
1999-04-27 04:06:03 +04:00
|
|
|
mFormFrame = nsnull;
|
1999-08-26 18:54:07 +04:00
|
|
|
NS_IF_RELEASE(mPresContext);
|
1999-10-06 03:43:06 +04:00
|
|
|
if (mSelectionCache) {
|
|
|
|
delete[] mSelectionCache;
|
|
|
|
}
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-08-31 17:22:50 +04:00
|
|
|
//NS_IMPL_ADDREF(nsListControlFrame)
|
|
|
|
//NS_IMPL_RELEASE(nsListControlFrame)
|
1999-01-18 18:14:00 +03:00
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 18:14:00 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|
|
|
{
|
|
|
|
if (NULL == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-07-29 01:38:08 +04:00
|
|
|
if (aIID.Equals(nsCOMTypeInfo<nsIFormControlFrame>::GetIID())) {
|
1999-01-18 18:14:00 +03:00
|
|
|
*aInstancePtr = (void*) ((nsIFormControlFrame*) this);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-07-29 01:38:08 +04:00
|
|
|
if (aIID.Equals(nsCOMTypeInfo<nsIListControlFrame>::GetIID())) {
|
1999-01-18 18:14:00 +03:00
|
|
|
*aInstancePtr = (void *)((nsIListControlFrame*)this);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-08-26 18:54:07 +04:00
|
|
|
if (aIID.Equals(nsCOMTypeInfo<nsISelectControlFrame>::GetIID())) {
|
|
|
|
*aInstancePtr = (void *)((nsISelectControlFrame*)this);
|
1999-01-18 18:14:00 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-08-26 18:54:07 +04:00
|
|
|
if (aIID.Equals(kIDOMMouseListenerIID)) {
|
|
|
|
*aInstancePtr = (void*)(nsIDOMMouseListener*) this;
|
|
|
|
NS_ADDREF_THIS();
|
|
|
|
return NS_OK;
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
1999-08-26 18:54:07 +04:00
|
|
|
if (aIID.Equals(kIDOMMouseMotionListenerIID)) {
|
|
|
|
*aInstancePtr = (void*)(nsIDOMMouseMotionListener*) this;
|
|
|
|
NS_ADDREF_THIS();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-08-27 18:42:27 +04:00
|
|
|
if (aIID.Equals(kIDOMKeyListenerIID)) {
|
|
|
|
*aInstancePtr = (void*)(nsIDOMKeyListener*) this;
|
|
|
|
NS_ADDREF_THIS();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-09-15 09:31:31 +04:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
|
|
|
|
*aInstancePtr = (void*)(nsIStatefulFrame*) this;
|
|
|
|
NS_ADDREF_THIS();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-08-26 18:54:07 +04:00
|
|
|
return nsScrollFrame::QueryInterface(aIID, aInstancePtr);
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-03-23 00:32:12 +03:00
|
|
|
// Reflow is overriden to constrain the listbox height to the number of rows and columns
|
|
|
|
// specified.
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
|
1999-01-18 18:14:00 +03:00
|
|
|
NS_IMETHODIMP
|
1999-07-29 01:38:08 +04:00
|
|
|
nsListControlFrame::Reflow(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1999-01-18 18:14:00 +03:00
|
|
|
{
|
1999-10-08 01:39:50 +04:00
|
|
|
#ifdef DEBUG_rods
|
1999-08-31 17:22:50 +04:00
|
|
|
printf("nsListControlFrame::Reflow Reason: ");
|
|
|
|
switch (aReflowState.reason) {
|
|
|
|
case eReflowReason_Initial:printf("eReflowReason_Initial\n");break;
|
|
|
|
case eReflowReason_Incremental:printf("eReflowReason_Incremental\n");break;
|
|
|
|
case eReflowReason_Resize:printf("eReflowReason_Resize\n");break;
|
|
|
|
case eReflowReason_StyleChange:printf("eReflowReason_StyleChange\n");break;
|
|
|
|
}
|
1999-09-09 04:23:40 +04:00
|
|
|
#endif // DEBUG_rods
|
|
|
|
|
1999-03-23 00:32:12 +03: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 18:14:00 +03:00
|
|
|
aDesiredSize.width = 0;
|
|
|
|
aDesiredSize.height = 0;
|
|
|
|
|
1999-08-10 23:22:51 +04:00
|
|
|
// Add the list frame as a child of the form
|
|
|
|
if (IsInDropDownMode() == PR_FALSE && !mFormFrame && (eReflowReason_Initial == aReflowState.reason)) {
|
|
|
|
nsFormFrame::AddFormControlFrame(aPresContext, *this);
|
|
|
|
}
|
|
|
|
|
1999-03-23 00:32:12 +03:00
|
|
|
//--Calculate a width just big enough for the scrollframe to shrink around the
|
|
|
|
//longest element in the list
|
1999-05-08 00:30:16 +04:00
|
|
|
nsHTMLReflowState secondPassState(aReflowState);
|
|
|
|
nsHTMLReflowState firstPassState(aReflowState);
|
1999-09-08 18:27:38 +04:00
|
|
|
//nsHTMLReflowState firstPassState(aPresContext, nsnull,
|
|
|
|
// this, aDesiredSize);
|
1999-07-21 02:32:41 +04:00
|
|
|
|
1999-05-08 00:30:16 +04:00
|
|
|
// Get the size of option elements inside the listbox
|
1999-03-23 00:32:12 +03:00
|
|
|
// Compute the width based on the longest line in the listbox.
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
firstPassState.mComputedWidth = NS_UNCONSTRAINEDSIZE;
|
1999-07-20 07:41:03 +04:00
|
|
|
firstPassState.mComputedHeight = NS_UNCONSTRAINEDSIZE;
|
1999-07-29 01:38:08 +04:00
|
|
|
firstPassState.availableWidth = NS_UNCONSTRAINEDSIZE;
|
1999-05-08 00:30:16 +04:00
|
|
|
firstPassState.availableHeight = NS_UNCONSTRAINEDSIZE;
|
1999-07-21 02:32:41 +04:00
|
|
|
|
1999-05-08 00:30:16 +04:00
|
|
|
nsSize scrolledAreaSize(0,0);
|
|
|
|
nsHTMLReflowMetrics scrolledAreaDesiredSize(&scrolledAreaSize);
|
1999-05-28 01:17:10 +04:00
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
|
1999-05-28 01:17:10 +04:00
|
|
|
if (eReflowReason_Incremental == firstPassState.reason) {
|
|
|
|
nsIFrame* targetFrame;
|
|
|
|
firstPassState.reflowCommand->GetTarget(targetFrame);
|
|
|
|
if (this == targetFrame) {
|
|
|
|
nsIReflowCommand::ReflowType type;
|
|
|
|
aReflowState.reflowCommand->GetType(type);
|
|
|
|
firstPassState.reason = eReflowReason_StyleChange;
|
|
|
|
firstPassState.reflowCommand = nsnull;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-05-08 00:30:16 +04:00
|
|
|
nsScrollFrame::Reflow(aPresContext,
|
1999-07-29 01:38:08 +04:00
|
|
|
scrolledAreaDesiredSize,
|
|
|
|
firstPassState,
|
|
|
|
aStatus);
|
1999-05-08 00:30:16 +04:00
|
|
|
|
1999-10-08 01:39:50 +04: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
|
|
|
|
nscoord scrolledAreaWidth = scrolledAreaDesiredSize.maxElementSize->width;
|
1999-05-08 00:30:16 +04:00
|
|
|
nscoord scrolledAreaHeight = scrolledAreaDesiredSize.height;
|
1999-10-08 01:39:50 +04:00
|
|
|
|
|
|
|
// Keep the oringal values
|
|
|
|
mMaxWidth = scrolledAreaWidth;
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
mMaxHeight = scrolledAreaDesiredSize.maxElementSize->height;
|
1999-05-08 00:30:16 +04:00
|
|
|
|
1999-10-08 01:39:50 +04:00
|
|
|
// The first reflow produces a box with the scrollbar width and borders
|
|
|
|
// added in so we need to subtract them out.
|
1999-05-08 00:30:16 +04:00
|
|
|
|
1999-10-08 01:39:50 +04:00
|
|
|
// Retrieve the scrollbar's width and height
|
1999-09-09 23:37:23 +04:00
|
|
|
float sbWidth = 0.0;
|
1999-03-23 00:32:12 +03:00
|
|
|
float sbHeight = 0.0;;
|
|
|
|
nsCOMPtr<nsIDeviceContext> dc;
|
|
|
|
aPresContext.GetDeviceContext(getter_AddRefs(dc));
|
|
|
|
dc->GetScrollBarDimensions(sbWidth, sbHeight);
|
1999-09-09 23:37:23 +04:00
|
|
|
// Convert to nscoord's by rounding
|
1999-10-08 01:39:50 +04:00
|
|
|
nscoord scrollbarWidth = NSToCoordRound(sbWidth);
|
1999-09-09 23:37:23 +04:00
|
|
|
nscoord scrollbarHeight = NSToCoordRound(sbHeight);
|
1999-03-23 00:32:12 +03:00
|
|
|
|
1999-05-08 00:30:16 +04:00
|
|
|
// Subtract out the scrollbar width
|
|
|
|
scrolledAreaWidth -= scrollbarWidth;
|
1999-04-13 02:14:31 +04:00
|
|
|
|
1999-05-08 00:30:16 +04:00
|
|
|
// Subtract out the borders
|
|
|
|
nsMargin border;
|
|
|
|
if (!aReflowState.mStyleSpacing->GetBorder(border)) {
|
1999-07-28 08:48:34 +04:00
|
|
|
NS_NOTYETIMPLEMENTED("percentage border");
|
1999-05-08 00:30:16 +04:00
|
|
|
border.SizeTo(0, 0, 0, 0);
|
|
|
|
}
|
1999-07-29 01:38:08 +04:00
|
|
|
|
1999-09-08 18:27:38 +04:00
|
|
|
nsMargin padding;
|
|
|
|
if (!aReflowState.mStyleSpacing->GetPadding(padding)) {
|
|
|
|
NS_NOTYETIMPLEMENTED("percentage padding");
|
|
|
|
padding.SizeTo(0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
1999-05-08 00:30:16 +04:00
|
|
|
mBorderOffsetY = border.top;
|
1999-03-23 00:32:12 +03:00
|
|
|
|
1999-10-22 02:22:32 +04:00
|
|
|
scrolledAreaWidth -= (border.left + border.right + padding.left + padding.right);
|
1999-05-08 00:30:16 +04:00
|
|
|
scrolledAreaHeight -= (border.top + border.bottom);
|
1999-03-23 00:32:12 +03:00
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
// Now the scrolledAreaWidth and scrolledAreaHeight are exactly
|
|
|
|
// wide and high enough to enclose their contents
|
1999-04-16 23:28:12 +04:00
|
|
|
|
1999-08-06 18:14:38 +04:00
|
|
|
PRBool isInDropDownMode = IsInDropDownMode();
|
|
|
|
|
1999-05-08 00:30:16 +04:00
|
|
|
nscoord visibleWidth = 0;
|
1999-08-06 18:14:38 +04:00
|
|
|
if (isInDropDownMode) {
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
// Calculate visible width for dropdown
|
1999-07-20 07:41:03 +04: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-15 02:00:24 +04:00
|
|
|
visibleWidth = scrolledAreaWidth;
|
|
|
|
} else {
|
1999-07-20 07:41:03 +04:00
|
|
|
visibleWidth = aReflowState.mComputedWidth - (border.left + border.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-15 02:00:24 +04:00
|
|
|
}
|
1999-05-08 00:30:16 +04:00
|
|
|
} else {
|
1999-07-20 07:41:03 +04:00
|
|
|
if (NS_UNCONSTRAINEDSIZE == aReflowState.mComputedWidth) {
|
1999-05-08 00:30:16 +04:00
|
|
|
visibleWidth = scrolledAreaWidth;
|
|
|
|
} else {
|
1999-10-29 00:31:23 +04:00
|
|
|
visibleWidth = aReflowState.mComputedWidth - scrollbarWidth;
|
|
|
|
visibleWidth -= (border.left + border.right + padding.left + padding.right);
|
1999-04-16 23:28:12 +04:00
|
|
|
}
|
|
|
|
}
|
1999-05-08 00:30:16 +04:00
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
// 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-08 00:30:16 +04:00
|
|
|
|
1999-05-18 02:36:08 +04: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;
|
1999-10-08 01:39:50 +04:00
|
|
|
heightOfARow -= (border.top + border.bottom + padding.top + padding.bottom);
|
1999-03-23 00:32:12 +03:00
|
|
|
|
1999-08-06 18:14:38 +04:00
|
|
|
// Check to see if we have zero item and
|
|
|
|
// whether we have no width and height
|
|
|
|
// The following code measures the width and height
|
|
|
|
// of a bogus string so the list actually displays
|
|
|
|
PRInt32 length = 0;
|
|
|
|
GetNumberOfOptions(&length);
|
|
|
|
|
1999-05-08 00:30:16 +04:00
|
|
|
nscoord visibleHeight = 0;
|
1999-08-06 18:14:38 +04:00
|
|
|
if (isInDropDownMode) {
|
1999-07-21 02:32:41 +04: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-23 00:32:12 +03:00
|
|
|
|
1999-07-21 02:32:41 +04:00
|
|
|
if (visibleHeight > (kMaxDropDownRows * heightOfARow)) {
|
|
|
|
visibleHeight = (kMaxDropDownRows * heightOfARow);
|
|
|
|
}
|
1999-05-08 00:30:16 +04:00
|
|
|
|
|
|
|
} else {
|
|
|
|
// Calculate the visible height of the listbox
|
1999-07-20 07:41:03 +04:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != aReflowState.mComputedHeight) {
|
|
|
|
visibleHeight = aReflowState.mComputedHeight;
|
1999-10-29 00:31:23 +04:00
|
|
|
visibleHeight -= (border.top + border.bottom + padding.top + padding.bottom);
|
1999-05-08 00:30:16 +04:00
|
|
|
} else {
|
1999-07-21 02:32:41 +04:00
|
|
|
PRInt32 numRows = 1;
|
|
|
|
GetSizeAttribute(&numRows);
|
|
|
|
if (numRows == kNoSizeSpecified) {
|
|
|
|
visibleHeight = aReflowState.mComputedHeight;
|
1999-10-29 00:31:23 +04:00
|
|
|
visibleHeight -= (border.top + border.bottom + padding.top + padding.bottom);
|
1999-10-08 01:39:50 +04:00
|
|
|
} else {
|
1999-07-21 02:32:41 +04:00
|
|
|
visibleHeight = numRows * heightOfARow;
|
|
|
|
}
|
1999-04-16 23:28:12 +04:00
|
|
|
}
|
1999-03-23 00:32:12 +03:00
|
|
|
}
|
|
|
|
|
1999-08-06 18:14:38 +04: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-08 00:30:16 +04:00
|
|
|
PRBool needsVerticalScrollbar = PR_FALSE;
|
|
|
|
if (visibleHeight < scrolledAreaHeight) {
|
|
|
|
needsVerticalScrollbar = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
1999-08-06 18:14:38 +04:00
|
|
|
if (needsVerticalScrollbar && !isInDropDownMode) {
|
1999-05-08 00:30:16 +04:00
|
|
|
visibleWidth += scrollbarWidth;
|
1999-07-29 01:38:08 +04:00
|
|
|
mIsScrollbarVisible = PR_TRUE; // XXX temp code
|
|
|
|
} else {
|
1999-10-08 01:39:50 +04:00
|
|
|
if (!isInDropDownMode) {
|
|
|
|
visibleWidth += scrollbarWidth;
|
|
|
|
}
|
1999-07-29 01:38:08 +04:00
|
|
|
mIsScrollbarVisible = PR_FALSE; // XXX temp code
|
1999-05-08 00:30:16 +04:00
|
|
|
}
|
|
|
|
|
1999-09-09 23:37:23 +04:00
|
|
|
if (visibleHeight < scrollbarHeight) {
|
|
|
|
visibleHeight = scrollbarHeight;
|
|
|
|
mMaxHeight = scrollbarHeight;
|
|
|
|
}
|
|
|
|
|
1999-05-08 00:30:16 +04: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-08 01:39:50 +04:00
|
|
|
secondPassState.mComputedWidth = visibleWidth;
|
1999-07-20 07:41:03 +04:00
|
|
|
secondPassState.mComputedHeight = visibleHeight;
|
1999-05-08 00:30:16 +04:00
|
|
|
secondPassState.reason = eReflowReason_Resize;
|
1999-10-08 01:39:50 +04:00
|
|
|
//printf("List: visible %d %d\n", visibleWidth, visibleHeight);
|
1999-08-06 18:14:38 +04:00
|
|
|
nsScrollFrame::Reflow(aPresContext, aDesiredSize, secondPassState, aStatus);
|
1999-05-08 00:30:16 +04:00
|
|
|
|
1999-03-23 00:32:12 +03:00
|
|
|
// Set the max element size to be the same as the desired element size.
|
1999-01-18 18:14:00 +03:00
|
|
|
if (nsnull != aDesiredSize.maxElementSize) {
|
|
|
|
aDesiredSize.maxElementSize->width = aDesiredSize.width;
|
|
|
|
aDesiredSize.maxElementSize->height = aDesiredSize.height;
|
|
|
|
}
|
1999-10-08 01:39:50 +04:00
|
|
|
//printf("List: aDesiredSize %d %d\n", aDesiredSize.width, aDesiredSize.height);
|
1999-01-18 18:14:00 +03:00
|
|
|
|
1999-03-23 00:32:12 +03:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1999-05-28 01:17:10 +04:00
|
|
|
mDisplayed = PR_TRUE;
|
1999-10-08 01:39:50 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG_rods
|
|
|
|
if (!isInDropDownMode) {
|
|
|
|
PRInt32 numRows = 1;
|
|
|
|
GetSizeAttribute(&numRows);
|
|
|
|
printf("%d ", numRows);
|
|
|
|
if (numRows == 2) {
|
|
|
|
COMPARE_QUIRK_SIZE("nsListControlFrame", 56, 38)
|
|
|
|
} if (numRows == 3) {
|
|
|
|
COMPARE_QUIRK_SIZE("nsListControlFrame", 56, 54)
|
|
|
|
} if (numRows == 4) {
|
|
|
|
COMPARE_QUIRK_SIZE("nsListControlFrame", 56, 70)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1999-01-18 18:14:00 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 18:14:00 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::GetFormContent(nsIContent*& aContent) const
|
|
|
|
{
|
1999-02-10 03:42:56 +03:00
|
|
|
nsIContent* content;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = GetContent(&content);
|
|
|
|
aContent = content;
|
|
|
|
return rv;
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 18:14:00 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::GetFont(nsIPresContext* aPresContext,
|
|
|
|
nsFont& aFont)
|
|
|
|
{
|
|
|
|
nsFormControlHelper::GetFont(this, aPresContext, mStyleContext, aFont);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-03-23 00:32:12 +03:00
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
PRBool
|
|
|
|
nsListControlFrame::IsOptionElement(nsIContent* aContent)
|
1999-05-14 03:45:40 +04:00
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
nsCOMPtr<nsIDOMHTMLOptionElement> optElem;
|
|
|
|
if (NS_SUCCEEDED(aContent->QueryInterface(nsCOMTypeInfo<nsIDOMHTMLOptionElement>::GetIID(),(void**) getter_AddRefs(optElem)))) {
|
|
|
|
if (optElem != nsnull) {
|
1999-05-14 03:45:40 +04:00
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
PRBool
|
|
|
|
nsListControlFrame::IsOptionElementFrame(nsIFrame *aFrame)
|
1999-05-14 03:45:40 +04:00
|
|
|
{
|
|
|
|
nsIContent *content = nsnull;
|
|
|
|
aFrame->GetContent(&content);
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
if (nsnull != content) {
|
|
|
|
result = IsOptionElement(content);
|
|
|
|
NS_RELEASE(content);
|
|
|
|
}
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-05-14 03:45:40 +04: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-15 02:00:24 +04:00
|
|
|
nsIFrame *
|
|
|
|
nsListControlFrame::GetSelectableFrame(nsIFrame *aFrame)
|
1999-05-14 03:45:40 +04:00
|
|
|
{
|
|
|
|
nsIFrame* selectedFrame = aFrame;
|
|
|
|
|
|
|
|
while ((nsnull != selectedFrame) &&
|
|
|
|
(PR_FALSE ==IsOptionElementFrame(selectedFrame))) {
|
|
|
|
selectedFrame->GetParent(&selectedFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(selectedFrame);
|
|
|
|
}
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
void
|
1999-10-26 08:44:41 +04:00
|
|
|
nsListControlFrame::ForceRedraw(nsIPresContext* aPresContext)
|
1999-05-08 00:30:16 +04: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 08:44:41 +04:00
|
|
|
nsFormControlHelper::ForceDrawFrame(aPresContext, this);
|
1999-05-08 00:30:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-03-23 00:32:12 +03: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-15 02:00:24 +04:00
|
|
|
void
|
|
|
|
nsListControlFrame::DisplaySelected(nsIContent* aContent)
|
1999-01-18 18:14:00 +03:00
|
|
|
{
|
1999-04-13 02:14:31 +04: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-15 02:00:24 +04:00
|
|
|
// The event state manager supports selected states. KMM
|
1999-05-08 00:30:16 +04:00
|
|
|
|
1999-08-26 18:54:07 +04:00
|
|
|
nsIAtom * selectedAtom = NS_NewAtom(kMozSelected);
|
1999-05-28 01:17:10 +04:00
|
|
|
if (PR_TRUE == mDisplayed) {
|
|
|
|
aContent->SetAttribute(kNameSpaceID_None, selectedAtom, "", PR_TRUE);
|
1999-09-30 15:37:58 +04:00
|
|
|
//ForceRedraw();
|
1999-05-28 01:17:10 +04:00
|
|
|
} else {
|
|
|
|
aContent->SetAttribute(kNameSpaceID_None, selectedAtom, "", PR_FALSE);
|
|
|
|
}
|
1999-08-26 18:54:07 +04:00
|
|
|
NS_RELEASE(selectedAtom);
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
void
|
|
|
|
nsListControlFrame::DisplayDeselected(nsIContent* aContent)
|
1999-03-23 00:32:12 +03:00
|
|
|
{
|
1999-04-13 02:14:31 +04: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-05-28 01:17:10 +04:00
|
|
|
|
1999-08-26 18:54:07 +04:00
|
|
|
nsIAtom * selectedAtom = NS_NewAtom(kMozSelected);
|
1999-05-28 01:17:10 +04:00
|
|
|
if (PR_TRUE == mDisplayed) {
|
|
|
|
aContent->UnsetAttribute(kNameSpaceID_None, selectedAtom, PR_TRUE);
|
1999-09-30 15:37:58 +04:00
|
|
|
//ForceRedraw();
|
1999-05-28 01:17:10 +04:00
|
|
|
} else {
|
|
|
|
aContent->UnsetAttribute(kNameSpaceID_None, selectedAtom, PR_FALSE);
|
|
|
|
}
|
1999-08-26 18:54:07 +04:00
|
|
|
NS_RELEASE(selectedAtom);
|
|
|
|
|
|
|
|
}
|
1999-05-08 00:30:16 +04:00
|
|
|
|
1999-08-26 18:54:07 +04: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;
|
|
|
|
NS_ADDREF(content);
|
|
|
|
while (nsnull != content) {
|
|
|
|
if (IsOptionElement(content)) {
|
|
|
|
return content;
|
|
|
|
}
|
|
|
|
nsIContent * node = content;
|
|
|
|
node->GetParent(content); // this add refs
|
|
|
|
NS_RELEASE(node);
|
|
|
|
}
|
|
|
|
return nsnull;
|
1999-03-23 00:32:12 +03:00
|
|
|
}
|
|
|
|
|
1999-08-26 18:54:07 +04: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
|
|
|
|
nsIDOMHTMLCollection* options = GetOptions(mContent);
|
|
|
|
if (nsnull != options) {
|
|
|
|
PRUint32 numOptions;
|
|
|
|
options->GetLength(&numOptions);
|
|
|
|
|
|
|
|
PRUint32 inx;
|
|
|
|
for (inx = 0; inx < numOptions; inx++) {
|
|
|
|
nsIContent* option = nsnull;
|
|
|
|
option = GetOptionAsContent(options, inx);
|
|
|
|
if (nsnull != option) {
|
|
|
|
if (option == aContent) {
|
|
|
|
NS_RELEASE(option);
|
|
|
|
NS_RELEASE(options);
|
|
|
|
return inx;
|
|
|
|
}
|
1999-09-30 15:37:58 +04:00
|
|
|
NS_RELEASE(option);
|
1999-08-26 18:54:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_RELEASE(options);
|
|
|
|
}
|
|
|
|
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-15 02:00:24 +04:00
|
|
|
|
1999-08-26 18:54:07 +04:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// Finds the index of the hit frame's content in the list
|
|
|
|
// of option elements
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
PRInt32
|
1999-08-19 18:11:28 +04:00
|
|
|
nsListControlFrame::GetSelectedIndexFromFrame(nsIFrame *aHitFrame)
|
1999-01-18 18:14:00 +03:00
|
|
|
{
|
1999-08-27 07:58:13 +04:00
|
|
|
PRInt32 indx = kNothingSelected;
|
1999-06-05 04:18:58 +04:00
|
|
|
// Get the content of the frame that was selected
|
1999-05-18 02:36:08 +04:00
|
|
|
nsIContent* selectedContent = nsnull;
|
1999-06-05 04:18:58 +04:00
|
|
|
NS_ASSERTION(aHitFrame, "No frame for html <select> element\n");
|
|
|
|
if (aHitFrame) {
|
|
|
|
aHitFrame->GetContent(&selectedContent);
|
1999-08-27 07:58:13 +04:00
|
|
|
indx = GetSelectedIndexFromContent(selectedContent);
|
1999-08-26 18:54:07 +04:00
|
|
|
NS_RELEASE(selectedContent);
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
1999-08-27 07:58:13 +04:00
|
|
|
return indx;
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
void
|
|
|
|
nsListControlFrame::ClearSelection()
|
1999-01-18 18:14:00 +03:00
|
|
|
{
|
1999-07-21 02:32:41 +04: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-15 02:00:24 +04:00
|
|
|
if (i != mSelectedIndex) {
|
1999-08-26 18:54:07 +04: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-15 02:00:24 +04:00
|
|
|
}
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
void
|
|
|
|
nsListControlFrame::ExtendedSelection(PRInt32 aStartIndex, PRInt32 aEndIndex, PRBool aDoInvert, PRBool aSetValue)
|
1999-01-18 18:14:00 +03: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-18 02:36:08 +04:00
|
|
|
|
1999-07-21 02:32:41 +04:00
|
|
|
PRInt32 length = 0;
|
|
|
|
GetNumberOfOptions(&length);
|
1999-05-18 02:36:08 +04:00
|
|
|
for (i = 0; i < length; i++) {
|
1999-01-18 18:14:00 +03:00
|
|
|
if (i == startInx) {
|
|
|
|
startInverting = PR_TRUE;
|
|
|
|
}
|
|
|
|
if (startInverting && ((i != mStartExtendedIndex && aDoInvert) || !aDoInvert)) {
|
|
|
|
if (aDoInvert) {
|
1999-08-26 18:54:07 +04:00
|
|
|
SetContentSelected(i, !IsContentSelectedByIndex(i));
|
1999-01-18 18:14:00 +03:00
|
|
|
} else {
|
1999-08-26 18:54:07 +04:00
|
|
|
SetContentSelected(i, aSetValue);
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i == endInx) {
|
|
|
|
startInverting = PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
void
|
|
|
|
nsListControlFrame::SingleSelection()
|
1999-01-18 18:14:00 +03:00
|
|
|
{
|
1999-08-26 18:54:07 +04: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-08 00:30:16 +04:00
|
|
|
}
|
1999-08-26 18:54:07 +04:00
|
|
|
// Display the new selection
|
|
|
|
SetContentSelected(mSelectedIndex, PR_TRUE);
|
|
|
|
} else {
|
|
|
|
// Selecting the currently selected item so do nothing.
|
1999-05-08 00:30:16 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-01-18 18:14:00 +03:00
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
void
|
|
|
|
nsListControlFrame::MultipleSelection(PRBool aIsShift, PRBool aIsControl)
|
1999-05-08 00:30:16 +04:00
|
|
|
{
|
|
|
|
if (kNothingSelected != mSelectedIndex) {
|
1999-08-27 18:42:27 +04:00
|
|
|
//if ((aIsShift) || (mButtonDown && (!aIsControl))) {
|
|
|
|
if (aIsShift) {
|
1999-08-26 18:54:07 +04:00
|
|
|
// Shift is held down
|
|
|
|
SetContentSelected(mSelectedIndex, PR_TRUE);
|
|
|
|
if (mEndExtendedIndex == kNothingSelected) {
|
|
|
|
mEndExtendedIndex = mSelectedIndex;
|
|
|
|
ExtendedSelection(mStartExtendedIndex, mEndExtendedIndex, PR_FALSE, PR_TRUE);
|
|
|
|
} else {
|
|
|
|
if (mStartExtendedIndex < mEndExtendedIndex) {
|
|
|
|
if (mSelectedIndex < mStartExtendedIndex) {
|
1999-08-27 18:42:27 +04:00
|
|
|
ExtendedSelection(mSelectedIndex+1, mEndExtendedIndex, PR_TRUE, PR_TRUE);
|
1999-08-26 18:54:07 +04: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);
|
|
|
|
mEndExtendedIndex = mSelectedIndex;
|
|
|
|
}
|
|
|
|
} else if (mStartExtendedIndex > mEndExtendedIndex) {
|
|
|
|
if (mSelectedIndex > mStartExtendedIndex) {
|
1999-08-27 18:42:27 +04:00
|
|
|
ExtendedSelection(mEndExtendedIndex, mSelectedIndex-1, PR_TRUE, PR_TRUE);
|
1999-08-26 18:54:07 +04:00
|
|
|
mEndExtendedIndex = mSelectedIndex;
|
|
|
|
} else if (mSelectedIndex < mEndExtendedIndex) {
|
1999-08-27 18:42:27 +04:00
|
|
|
ExtendedSelection(mStartExtendedIndex, mEndExtendedIndex-1, PR_FALSE, PR_TRUE);
|
1999-08-26 18:54:07 +04:00
|
|
|
mEndExtendedIndex = mSelectedIndex;
|
|
|
|
} else if (mSelectedIndex > mEndExtendedIndex) {
|
|
|
|
ExtendedSelection(mEndExtendedIndex, mSelectedIndex-1, PR_FALSE, PR_FALSE);
|
|
|
|
mEndExtendedIndex = mSelectedIndex;
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
}
|
1999-08-26 18:54:07 +04:00
|
|
|
}
|
|
|
|
} else if (aIsControl) {
|
|
|
|
// Control is held down
|
|
|
|
if (IsContentSelectedByIndex(mSelectedIndex)) {
|
|
|
|
SetContentSelected(mSelectedIndex, PR_FALSE);
|
1999-05-18 02:36:08 +04:00
|
|
|
} else {
|
1999-08-26 18:54:07 +04:00
|
|
|
SetContentSelected(mSelectedIndex, PR_TRUE);
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
1999-08-26 18:54:07 +04:00
|
|
|
|
|
|
|
} else {
|
|
|
|
// Neither control nor shift is held down
|
|
|
|
SetContentSelected(mSelectedIndex, PR_TRUE);
|
|
|
|
mStartExtendedIndex = mSelectedIndex;
|
|
|
|
mEndExtendedIndex = kNothingSelected;
|
|
|
|
ClearSelection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-05-08 00:30:16 +04:00
|
|
|
}
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
void
|
1999-08-26 18:54:07 +04:00
|
|
|
nsListControlFrame::HandleListSelection(nsIDOMEvent* aEvent)
|
1999-05-29 01:12:09 +04:00
|
|
|
{
|
1999-08-26 18:54:07 +04:00
|
|
|
|
1999-07-21 02:32:41 +04:00
|
|
|
PRBool multipleSelections = PR_FALSE;
|
|
|
|
GetMultiple(&multipleSelections);
|
|
|
|
if (multipleSelections) {
|
1999-08-26 18:54:07 +04:00
|
|
|
nsCOMPtr<nsIDOMUIEvent> uiEvent = do_QueryInterface(aEvent);
|
|
|
|
PRBool isShift;
|
|
|
|
PRBool isControl;
|
|
|
|
uiEvent->GetCtrlKey(&isControl);
|
|
|
|
uiEvent->GetShiftKey(&isShift);
|
|
|
|
MultipleSelection(isShift, isControl);
|
1999-05-29 01:12:09 +04:00
|
|
|
} else {
|
|
|
|
SingleSelection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
PRBool
|
|
|
|
nsListControlFrame::HasSameContent(nsIFrame* aFrame1, nsIFrame* aFrame2)
|
1999-05-29 01:12:09 +04: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-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-04-16 23:28:12 +04:00
|
|
|
NS_IMETHODIMP
|
1999-10-26 08:44:41 +04:00
|
|
|
nsListControlFrame::CaptureMouseEvents(nsIPresContext* aPresContext, PRBool aGrabMouseEvents)
|
1999-04-16 23:28:12 +04:00
|
|
|
{
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
|
1999-04-16 23:28:12 +04:00
|
|
|
// get its view
|
|
|
|
nsIView* view = nsnull;
|
1999-10-26 08:44:41 +04:00
|
|
|
GetView(aPresContext, &view);
|
1999-04-16 23:28:12 +04: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-15 02:00:24 +04:00
|
|
|
mIsCapturingMouseEvents = PR_TRUE;
|
1999-04-16 23:28:12 +04: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-15 02:00:24 +04:00
|
|
|
mIsCapturingMouseEvents = PR_FALSE;
|
1999-04-16 23:28:12 +04:00
|
|
|
}
|
1999-07-29 01:38:08 +04:00
|
|
|
// XXX this is temp code
|
1999-10-06 17:36:39 +04:00
|
|
|
#if 0
|
1999-07-29 01:38:08 +04:00
|
|
|
if (!mIsScrollbarVisible) {
|
|
|
|
nsIWidget * widget;
|
|
|
|
view->GetWidget(widget);
|
|
|
|
if (nsnull != widget) {
|
|
|
|
widget->CaptureMouse(aGrabMouseEvents);
|
|
|
|
NS_RELEASE(widget);
|
|
|
|
}
|
|
|
|
}
|
1999-10-06 17:36:39 +04:00
|
|
|
#endif
|
1999-04-16 23:28:12 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
nsIView*
|
|
|
|
nsListControlFrame::GetViewFor(nsIWidget* aWidget)
|
1999-06-22 00:41:56 +04: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-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-06-22 00:41:56 +04: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-15 02:00:24 +04:00
|
|
|
PRBool
|
|
|
|
nsListControlFrame::IsAncestor(nsIView* aAncestor, nsIView* aChild)
|
1999-06-22 00:41:56 +04: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 23:28:12 +04:00
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::HandleEvent(nsIPresContext& aPresContext,
|
1999-01-18 18:14:00 +03:00
|
|
|
nsGUIEvent* aEvent,
|
|
|
|
nsEventStatus& aEventStatus)
|
|
|
|
{
|
1999-07-29 01:38:08 +04:00
|
|
|
|
|
|
|
/*const char * desc[] = {"NS_MOUSE_MOVE",
|
1999-01-18 18:14:00 +03: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",
|
|
|
|
"NS_MOUSE_ENTER",
|
|
|
|
"NS_MOUSE_EXIT",
|
|
|
|
"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)) {
|
|
|
|
printf("Mouse in ListFrame %s [%d]\n", desc[inx], aEvent->message);
|
|
|
|
} else {
|
|
|
|
printf("Mouse in ListFrame <UNKNOWN> [%d]\n", aEvent->message);
|
1999-07-29 01:38:08 +04:00
|
|
|
}*/
|
|
|
|
|
1999-08-27 18:42:27 +04:00
|
|
|
if (nsEventStatus_eConsumeNoDefault == aEventStatus)
|
1999-01-18 18:14:00 +03:00
|
|
|
return NS_OK;
|
|
|
|
|
1999-08-27 18:42:27 +04:00
|
|
|
if (nsFormFrame::GetDisabled(this))
|
1999-08-10 23:22:51 +04:00
|
|
|
return NS_OK;
|
|
|
|
|
1999-08-27 18:42:27 +04:00
|
|
|
switch(aEvent->message) {
|
|
|
|
case NS_KEY_PRESS:
|
|
|
|
if (NS_KEY_EVENT == aEvent->eventStructType) {
|
|
|
|
nsKeyEvent* keyEvent = (nsKeyEvent*)aEvent;
|
|
|
|
printf("---> %d %c\n", keyEvent->keyCode, keyEvent->keyCode);
|
|
|
|
//if (NS_VK_SPACE == keyEvent->keyCode || NS_VK_RETURN == keyEvent->keyCode) {
|
|
|
|
// MouseClicked(&aPresContext);
|
|
|
|
//}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
1999-08-27 18:42:27 +04:00
|
|
|
return(nsScrollFrame::HandleEvent(aPresContext, aEvent, aEventStatus));
|
1999-07-29 01:38:08 +04:00
|
|
|
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 18:14:00 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::SetInitialChildList(nsIPresContext& aPresContext,
|
1999-04-27 04:06:03 +04:00
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList)
|
1999-01-18 18:14:00 +03:00
|
|
|
{
|
|
|
|
mContentFrame = aChildList;
|
|
|
|
return nsScrollFrame::SetInitialChildList(aPresContext, aListName, aChildList);
|
|
|
|
}
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-07-21 02:32:41 +04:00
|
|
|
nsresult
|
|
|
|
nsListControlFrame::GetSizeAttribute(PRInt32 *aSize) {
|
|
|
|
nsresult rv = NS_OK;
|
1999-07-29 01:38:08 +04:00
|
|
|
nsIDOMHTMLSelectElement* selectElement;
|
|
|
|
rv = mContent->QueryInterface(nsCOMTypeInfo<nsIDOMHTMLSelectElement>::GetIID(),(void**) &selectElement);
|
|
|
|
if (mContent && NS_SUCCEEDED(rv)) {
|
|
|
|
rv = selectElement->GetSize(aSize);
|
|
|
|
NS_RELEASE(selectElement);
|
1999-07-21 02:32:41 +04: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-15 02:00:24 +04:00
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 18:14:00 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::Init(nsIPresContext& aPresContext,
|
1999-02-25 06:27:57 +03:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsIFrame* aPrevInFlow)
|
1999-01-18 18:14:00 +03:00
|
|
|
{
|
1999-08-26 18:54:07 +04:00
|
|
|
mPresContext = &aPresContext;
|
|
|
|
NS_ADDREF(mPresContext);
|
1999-02-25 06:27:57 +03:00
|
|
|
nsresult result = nsScrollFrame::Init(aPresContext, aContent, aParent, aContext,
|
|
|
|
aPrevInFlow);
|
1999-05-28 01:17:10 +04:00
|
|
|
// Initialize the current selected and not selected state's for
|
|
|
|
// the listbox items from the content. This is done here because
|
|
|
|
// The selected content sets an attribute that must be on the content
|
|
|
|
// before the option element's frames are constructed so the frames will
|
|
|
|
// get the proper style based on attribute selectors which refer to the
|
|
|
|
// selected attribute.
|
|
|
|
if (!mIsInitializedFromContent) {
|
1999-10-26 08:44:41 +04:00
|
|
|
Reset(&aPresContext);
|
1999-10-06 03:43:06 +04:00
|
|
|
} else {
|
|
|
|
InitSelectionCache(-1);
|
1999-05-28 01:17:10 +04:00
|
|
|
}
|
1999-08-26 18:54:07 +04: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.
|
|
|
|
reciever->AddEventListenerByIID((nsIDOMMouseListener *)this, kIDOMMouseListenerIID);
|
|
|
|
reciever->AddEventListenerByIID((nsIDOMMouseMotionListener *)this, kIDOMMouseMotionListenerIID);
|
1999-08-27 18:42:27 +04:00
|
|
|
reciever->AddEventListenerByIID((nsIDOMKeyListener *)this, kIDOMKeyListenerIID);
|
1999-08-26 18:54:07 +04:00
|
|
|
|
1999-09-11 02:56:23 +04:00
|
|
|
#if 0
|
|
|
|
nsIFrame* parent;
|
|
|
|
GetParentWithView(&parent);
|
|
|
|
NS_ASSERTION(parent, "GetParentWithView failed");
|
|
|
|
|
|
|
|
// Get parent view
|
|
|
|
nsIView* parentView = nsnull;
|
|
|
|
while (1) {
|
|
|
|
parent->GetView(&parentView);
|
|
|
|
}
|
|
|
|
#endif
|
1999-01-18 18:14:00 +03: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-15 02:00:24 +04:00
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 18:14:00 +03:00
|
|
|
nscoord
|
1999-09-30 15:37:58 +04:00
|
|
|
nsListControlFrame::GetVerticalInsidePadding(nsIPresContext& aPresContext,
|
|
|
|
float aPixToTwip,
|
|
|
|
nscoord aInnerHeight) const
|
1999-01-18 18:14:00 +03:00
|
|
|
{
|
1999-03-23 00:32:12 +03:00
|
|
|
return NSIntPixelsToTwips(0, aPixToTwip);
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 18:14:00 +03:00
|
|
|
nscoord
|
|
|
|
nsListControlFrame::GetHorizontalInsidePadding(nsIPresContext& aPresContext,
|
1999-09-30 15:37:58 +04:00
|
|
|
float aPixToTwip,
|
|
|
|
nscoord aInnerWidth,
|
|
|
|
nscoord aCharWidth) const
|
1999-01-18 18:14:00 +03:00
|
|
|
{
|
1999-09-30 15:37:58 +04:00
|
|
|
return GetVerticalInsidePadding(aPresContext, aPixToTwip, aInnerWidth);
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-08-26 18:54:07 +04:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// Returns whether the nsIDOMHTMLSelectElement supports
|
|
|
|
// mulitple selection
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 18:14:00 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::GetMultiple(PRBool* aMultiple, nsIDOMHTMLSelectElement* aSelect)
|
|
|
|
{
|
|
|
|
if (!aSelect) {
|
1999-07-29 01:38:08 +04:00
|
|
|
nsIDOMHTMLSelectElement* selectElement = nsnull;
|
1999-08-26 18:54:07 +04:00
|
|
|
nsresult result = mContent->QueryInterface(nsCOMTypeInfo<nsIDOMHTMLSelectElement>::GetIID(),
|
|
|
|
(void**)&selectElement);
|
1999-07-29 01:38:08 +04:00
|
|
|
if (NS_SUCCEEDED(result) && selectElement) {
|
|
|
|
result = selectElement->GetMultiple(aMultiple);
|
|
|
|
NS_RELEASE(selectElement);
|
1999-01-18 18:14:00 +03: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-15 02:00:24 +04:00
|
|
|
|
1999-08-26 18:54:07 +04:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// for a given piece of content it returns nsIDOMHTMLSelectElement object
|
|
|
|
// or null
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 18:14:00 +03:00
|
|
|
nsIDOMHTMLSelectElement*
|
|
|
|
nsListControlFrame::GetSelect(nsIContent * aContent)
|
|
|
|
{
|
1999-07-29 01:38:08 +04:00
|
|
|
nsIDOMHTMLSelectElement* selectElement = nsnull;
|
1999-08-26 18:54:07 +04:00
|
|
|
nsresult result = aContent->QueryInterface(nsCOMTypeInfo<nsIDOMHTMLSelectElement>::GetIID(),
|
|
|
|
(void**)&selectElement);
|
1999-07-29 01:38:08 +04:00
|
|
|
if (NS_SUCCEEDED(result) && selectElement) {
|
|
|
|
return selectElement;
|
1999-01-18 18:14:00 +03: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-15 02:00:24 +04:00
|
|
|
|
1999-08-26 18:54:07 +04:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// Returns the nsIContent object in the collection
|
|
|
|
// for a given index
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-03-23 00:32:12 +03:00
|
|
|
nsIContent*
|
1999-08-27 18:42:27 +04:00
|
|
|
nsListControlFrame::GetOptionAsContent(nsIDOMHTMLCollection* aCollection, PRInt32 aIndex)
|
1999-03-23 00:32:12 +03:00
|
|
|
{
|
1999-08-26 18:54:07 +04:00
|
|
|
nsIContent * content = nsnull;
|
1999-05-18 02:36:08 +04:00
|
|
|
nsIDOMHTMLOptionElement* optionElement = GetOption(*aCollection, aIndex);
|
|
|
|
if (nsnull != optionElement) {
|
1999-08-19 18:11:28 +04:00
|
|
|
optionElement->QueryInterface(nsCOMTypeInfo<nsIContent>::GetIID(),(void**) &content);
|
1999-05-28 01:17:10 +04:00
|
|
|
NS_RELEASE(optionElement);
|
1999-05-18 02:36:08 +04:00
|
|
|
}
|
1999-05-28 01:17:10 +04:00
|
|
|
|
1999-05-18 02:36:08 +04:00
|
|
|
return content;
|
|
|
|
}
|
1999-03-23 00:32:12 +03:00
|
|
|
|
1999-08-26 18:54:07 +04:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// for a given index it returns the nsIContent object
|
|
|
|
// from the select
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-05-18 02:36:08 +04:00
|
|
|
nsIContent*
|
1999-08-27 18:42:27 +04:00
|
|
|
nsListControlFrame::GetOptionContent(PRInt32 aIndex)
|
1999-05-18 02:36:08 +04:00
|
|
|
|
|
|
|
{
|
|
|
|
nsIContent* content = nsnull;
|
|
|
|
nsIDOMHTMLCollection* options = GetOptions(mContent);
|
|
|
|
if (nsnull != options) {
|
|
|
|
content = GetOptionAsContent(options, aIndex);
|
|
|
|
NS_RELEASE(options);
|
1999-03-23 00:32:12 +03:00
|
|
|
}
|
1999-05-18 02:36:08 +04:00
|
|
|
return(content);
|
1999-03-23 00:32:12 +03:00
|
|
|
}
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-08-26 18:54:07 +04:00
|
|
|
// This returns the collection for nsIDOMHTMLSelectElement or
|
|
|
|
// the nsIContent object is the select is null
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 18:14:00 +03:00
|
|
|
nsIDOMHTMLCollection*
|
|
|
|
nsListControlFrame::GetOptions(nsIContent * aContent, nsIDOMHTMLSelectElement* aSelect)
|
|
|
|
{
|
|
|
|
nsIDOMHTMLCollection* options = nsnull;
|
|
|
|
if (!aSelect) {
|
1999-07-29 01:38:08 +04:00
|
|
|
nsIDOMHTMLSelectElement* selectElement = GetSelect(aContent);
|
|
|
|
if (selectElement) {
|
|
|
|
selectElement->GetOptions(&options);
|
|
|
|
NS_RELEASE(selectElement);
|
1999-01-18 18:14:00 +03:00
|
|
|
return options;
|
|
|
|
} else {
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
aSelect->GetOptions(&options);
|
|
|
|
return options;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-26 18:54:07 +04:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// Returns the nsIDOMHTMLOptionElement for a given index
|
|
|
|
// in the select's collection
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 18:14:00 +03:00
|
|
|
nsIDOMHTMLOptionElement*
|
1999-08-27 18:42:27 +04:00
|
|
|
nsListControlFrame::GetOption(nsIDOMHTMLCollection& aCollection, PRInt32 aIndex)
|
1999-01-18 18:14:00 +03:00
|
|
|
{
|
|
|
|
nsIDOMNode* node = nsnull;
|
1999-05-18 02:36:08 +04:00
|
|
|
if (NS_SUCCEEDED(aCollection.Item(aIndex, &node))) {
|
|
|
|
if (nsnull != node) {
|
|
|
|
nsIDOMHTMLOptionElement* option = nsnull;
|
1999-08-26 18:54:07 +04:00
|
|
|
node->QueryInterface(nsCOMTypeInfo<nsIDOMHTMLOptionElement>::GetIID(), (void**)&option);
|
1999-05-18 02:36:08 +04:00
|
|
|
NS_RELEASE(node);
|
|
|
|
return option;
|
|
|
|
}
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
|
1999-08-26 18:54:07 +04: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-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 18:14:00 +03:00
|
|
|
PRBool
|
1999-08-26 18:54:07 +04:00
|
|
|
nsListControlFrame::GetOptionValue(nsIDOMHTMLCollection& aCollection,
|
1999-08-27 18:42:27 +04:00
|
|
|
PRInt32 aIndex,
|
1999-08-26 18:54:07 +04:00
|
|
|
nsString& aValue)
|
1999-01-18 18:14:00 +03:00
|
|
|
{
|
|
|
|
PRBool status = PR_FALSE;
|
1999-10-15 03:41:40 +04:00
|
|
|
nsresult result = NS_OK;
|
1999-01-18 18:14:00 +03:00
|
|
|
nsIDOMHTMLOptionElement* option = GetOption(aCollection, aIndex);
|
|
|
|
if (option) {
|
1999-10-15 03:41:40 +04: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 18:14:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_RELEASE(option);
|
|
|
|
}
|
1999-10-15 03:41:40 +04:00
|
|
|
|
1999-01-18 18:14:00 +03:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
1999-08-26 18:54:07 +04: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;
|
|
|
|
nsIAtom * selectedAtom = NS_NewAtom(kMozSelected);
|
1999-09-08 18:27:38 +04:00
|
|
|
//nsIAtom * selectedAtom = NS_NewAtom("selected");
|
1999-08-26 18:54:07 +04:00
|
|
|
nsresult result = aContent->GetAttribute(kNameSpaceID_None, selectedAtom, value);
|
|
|
|
NS_RELEASE(selectedAtom);
|
|
|
|
|
|
|
|
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 18:42:27 +04:00
|
|
|
nsListControlFrame::IsContentSelectedByIndex(PRInt32 aIndex)
|
1999-08-26 18:54:07 +04: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 07:58:13 +04:00
|
|
|
nsListControlFrame::SetContentSelected(PRInt32 aIndex, PRBool aSelected)
|
1999-08-26 18:54:07 +04:00
|
|
|
{
|
|
|
|
if (aIndex == kNothingSelected) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
nsIContent* content = GetOptionContent(aIndex);
|
1999-09-30 15:37:58 +04:00
|
|
|
//NS_ASSERTION(nsnull != content && aIndex == 0, "Failed to retrieve option content");
|
|
|
|
if (nsnull != content) {
|
|
|
|
if (aSelected) {
|
|
|
|
DisplaySelected(content);
|
|
|
|
} else {
|
|
|
|
DisplayDeselected(content);
|
|
|
|
}
|
|
|
|
NS_RELEASE(content);
|
1999-08-26 18:54:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// Deselects all the content items in the select
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
nsresult
|
1999-01-18 18:14:00 +03:00
|
|
|
nsListControlFrame::Deselect()
|
|
|
|
{
|
|
|
|
PRInt32 i;
|
1999-07-21 02:32:41 +04:00
|
|
|
PRInt32 max = 0;
|
|
|
|
GetNumberOfOptions(&max);
|
1999-05-28 01:17:10 +04:00
|
|
|
for (i=0;i<max;i++) {
|
1999-08-26 18:54:07 +04:00
|
|
|
SetContentSelected(i, PR_FALSE);
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
mSelectedIndex = kNothingSelected;
|
|
|
|
|
1999-01-18 18:14:00 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 18:14:00 +03: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-15 02:00:24 +04:00
|
|
|
{
|
|
|
|
// Don't skip any sides during border rendering
|
1999-01-18 18:14:00 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 18:14:00 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::GetType(PRInt32* aType) const
|
|
|
|
{
|
|
|
|
*aType = NS_FORM_SELECT;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 18:14:00 +03: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-15 02:00:24 +04:00
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 18:14:00 +03:00
|
|
|
PRBool
|
|
|
|
nsListControlFrame::IsSuccessful(nsIFormControlFrame* aSubmitter)
|
|
|
|
{
|
|
|
|
nsAutoString name;
|
|
|
|
return (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name));
|
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 18:14:00 +03:00
|
|
|
void
|
|
|
|
nsListControlFrame::MouseClicked(nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
}
|
1999-03-23 00:32:12 +03:00
|
|
|
|
1999-07-21 02:32:41 +04:00
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 18:14:00 +03: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 17:49:12 +04:00
|
|
|
NS_RELEASE(options);
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
return (PRInt32)length; // XXX fix return on GetMaxNumValues
|
|
|
|
} else {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
|
1999-08-26 18:54:07 +04:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// Resets the select back to it's original default values;
|
|
|
|
// those values as determined by the original HTML
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 18:14:00 +03:00
|
|
|
void
|
1999-10-26 08:44:41 +04:00
|
|
|
nsListControlFrame::Reset(nsIPresContext* aPresContext)
|
1999-01-18 18:14:00 +03:00
|
|
|
{
|
|
|
|
nsIDOMHTMLCollection* options = GetOptions(mContent);
|
|
|
|
if (!options) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint32 numOptions;
|
|
|
|
options->GetLength(&numOptions);
|
|
|
|
|
|
|
|
Deselect();
|
1999-08-26 18:54:07 +04:00
|
|
|
PRUint32 i;
|
|
|
|
for (i = 0; i < numOptions; i++) {
|
1999-01-18 18:14:00 +03:00
|
|
|
nsIDOMHTMLOptionElement* option = GetOption(*options, i);
|
|
|
|
if (option) {
|
|
|
|
PRBool selected = PR_FALSE;
|
1999-08-10 23:22:51 +04:00
|
|
|
option->GetDefaultSelected(&selected);
|
1999-01-18 18:14:00 +03:00
|
|
|
if (selected) {
|
1999-08-10 23:22:51 +04:00
|
|
|
mSelectedIndex = i;
|
1999-08-26 18:54:07 +04:00
|
|
|
SetContentSelected(i, PR_TRUE);
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
NS_RELEASE(option);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_RELEASE(options);
|
1999-10-06 03:43:06 +04:00
|
|
|
|
|
|
|
InitSelectionCache(numOptions);
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 18:14:00 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::GetName(nsString* aResult)
|
|
|
|
{
|
|
|
|
nsresult result = NS_FORM_NOTOK;
|
|
|
|
if (mContent) {
|
|
|
|
nsIHTMLContent* formControl = nsnull;
|
1999-07-29 01:38:08 +04:00
|
|
|
result = mContent->QueryInterface(nsCOMTypeInfo<nsIHTMLContent>::GetIID(),(void**)&formControl);
|
|
|
|
if (NS_SUCCEEDED(result) && formControl) {
|
1999-01-18 18:14:00 +03: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-15 02:00:24 +04:00
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-07-21 02:32:41 +04:00
|
|
|
PRInt32
|
|
|
|
nsListControlFrame::GetNumberOfSelections()
|
|
|
|
{
|
|
|
|
PRInt32 count = 0;
|
|
|
|
PRInt32 length = 0;
|
|
|
|
GetNumberOfOptions(&length);
|
|
|
|
PRInt32 i = 0;
|
|
|
|
for (i = 0; i < length; i++) {
|
1999-08-26 18:54:07 +04:00
|
|
|
if (IsContentSelectedByIndex(i)) {
|
1999-07-21 02:32:41 +04:00
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(count);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 18:14:00 +03: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;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIDOMHTMLCollection* options = GetOptions(mContent);
|
|
|
|
if (!options) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
1999-07-21 02:32:41 +04:00
|
|
|
PRBool status = PR_FALSE;
|
|
|
|
PRBool multiple;
|
|
|
|
GetMultiple(&multiple);
|
|
|
|
if (!multiple) {
|
|
|
|
if (mSelectedIndex >= 0) {
|
|
|
|
nsAutoString value;
|
|
|
|
GetOptionValue(*options, mSelectedIndex, value);
|
|
|
|
aNumValues = 1;
|
|
|
|
aNames[0] = name;
|
|
|
|
aValues[0] = value;
|
|
|
|
status = PR_TRUE;
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
1999-07-21 02:32:41 +04:00
|
|
|
}
|
|
|
|
else {
|
1999-01-18 18:14:00 +03:00
|
|
|
aNumValues = 0;
|
1999-07-21 02:32:41 +04:00
|
|
|
PRInt32 length = 0;
|
|
|
|
GetNumberOfOptions(&length);
|
|
|
|
for (int i = 0; i < length; i++) {
|
1999-08-26 18:54:07 +04:00
|
|
|
if (PR_TRUE == IsContentSelectedByIndex(i)) {
|
1999-07-21 02:32:41 +04:00
|
|
|
nsAutoString value;
|
|
|
|
GetOptionValue(*options, i, value);
|
|
|
|
aNames[aNumValues] = name;
|
|
|
|
aValues[aNumValues] = value;
|
|
|
|
aNumValues++;
|
|
|
|
}
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
status = PR_TRUE;
|
1999-07-21 02:32:41 +04:00
|
|
|
}
|
1999-01-18 18:14:00 +03:00
|
|
|
NS_RELEASE(options);
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 18:14:00 +03:00
|
|
|
void
|
|
|
|
nsListControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
|
|
|
|
{
|
1999-05-18 02:36:08 +04:00
|
|
|
// XXX:TODO Make set focus work
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
1999-08-21 04:09:24 +04:00
|
|
|
//---------------------------------------------------------
|
|
|
|
void
|
|
|
|
nsListControlFrame::ScrollIntoView(nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
if (aPresContext) {
|
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
aPresContext->GetShell(getter_AddRefs(presShell));
|
|
|
|
presShell->ScrollFrameIntoView(this,
|
|
|
|
NS_PRESSHELL_SCROLL_ANYWHERE,NS_PRESSHELL_SCROLL_ANYWHERE);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 18:14:00 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::SetComboboxFrame(nsIFrame* aComboboxFrame)
|
|
|
|
{
|
1999-05-28 01:17:10 +04:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
if (nsnull != aComboboxFrame) {
|
1999-07-29 01:38:08 +04:00
|
|
|
rv = aComboboxFrame->QueryInterface(nsCOMTypeInfo<nsIComboboxControlFrame>::GetIID(),(void**) &mComboboxFrame);
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
1999-05-28 01:17:10 +04:00
|
|
|
return rv;
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
|
1999-08-26 18:54:07 +04: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-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-01-18 18:14:00 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::GetSelectedItem(nsString & aStr)
|
|
|
|
{
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
aStr = "";
|
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
1999-05-28 01:17:10 +04:00
|
|
|
nsIDOMHTMLCollection* options = GetOptions(mContent);
|
1999-08-26 18:54:07 +04:00
|
|
|
|
1999-05-28 01:17:10 +04:00
|
|
|
if (nsnull != options) {
|
1999-08-26 18:54:07 +04:00
|
|
|
PRUint32 numOptions;
|
|
|
|
options->GetLength(&numOptions);
|
|
|
|
|
|
|
|
if (numOptions == 0) {
|
|
|
|
rv = NS_OK;
|
|
|
|
} else {
|
1999-10-12 12:47:29 +04:00
|
|
|
nsIDOMHTMLOptionElement* optionElement = GetOption(*options, mSelectedIndex);
|
1999-08-26 18:54:07 +04:00
|
|
|
if (nsnull != optionElement) {
|
|
|
|
nsAutoString text;
|
1999-09-11 02:56:23 +04:00
|
|
|
rv = optionElement->GetLabel(text);
|
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE != rv || 0 == text.Length()) {
|
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == optionElement->GetText(text)) {
|
|
|
|
aStr = text;
|
|
|
|
rv = NS_OK;
|
|
|
|
}
|
|
|
|
} else {
|
1999-08-26 18:54:07 +04:00
|
|
|
aStr = text;
|
|
|
|
rv = NS_OK;
|
1999-09-11 02:56:23 +04:00
|
|
|
}
|
1999-08-26 18:54:07 +04:00
|
|
|
NS_RELEASE(optionElement);
|
1999-05-28 01:17:10 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_RELEASE(options);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-08-19 18:11:28 +04:00
|
|
|
//---------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::GetSelectedIndex(PRInt32 * aIndex)
|
|
|
|
{
|
|
|
|
*aIndex = mSelectedIndex;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-26 18:54:07 +04:00
|
|
|
//---------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::GetSelectedIndexFromDOM(PRInt32 * aIndex)
|
|
|
|
{
|
|
|
|
// figure out which item is selected by looking at which
|
|
|
|
// option are selected
|
|
|
|
*aIndex = kNothingSelected;
|
|
|
|
nsIDOMHTMLCollection* options = GetOptions(mContent);
|
|
|
|
if (options) {
|
|
|
|
PRUint32 numOptions;
|
|
|
|
options->GetLength(&numOptions);
|
|
|
|
|
|
|
|
PRUint32 inx;
|
|
|
|
for (inx = 0; inx < numOptions && (*aIndex == kNothingSelected); inx++) {
|
|
|
|
nsIContent* content = GetOptionAsContent(options, inx);
|
|
|
|
if (nsnull != content) {
|
|
|
|
if (IsContentSelected(content)) {
|
|
|
|
*aIndex = (PRInt32)inx;
|
|
|
|
}
|
|
|
|
NS_RELEASE(content);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_RELEASE(options);
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
|
|
|
PRBool
|
|
|
|
nsListControlFrame::IsInDropDownMode()
|
1999-05-28 01:17:10 +04:00
|
|
|
{
|
|
|
|
return((nsnull == mComboboxFrame) ? PR_FALSE : PR_TRUE);
|
1999-01-18 18:14:00 +03:00
|
|
|
}
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
|
|
|
nsresult
|
|
|
|
nsListControlFrame::RequiresWidget(PRBool& aRequiresWidget)
|
1999-01-26 01:16:27 +03:00
|
|
|
{
|
1999-04-13 02:14:31 +04:00
|
|
|
aRequiresWidget = PR_FALSE;
|
1999-01-26 01:16:27 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-07-21 02:32:41 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::GetNumberOfOptions(PRInt32* aNumOptions)
|
1999-04-13 02:14:31 +04:00
|
|
|
{
|
|
|
|
nsIDOMHTMLCollection* options = GetOptions(mContent);
|
1999-07-21 02:32:41 +04:00
|
|
|
if (nsnull == options) {
|
|
|
|
*aNumOptions = 0;
|
|
|
|
} else {
|
|
|
|
PRUint32 length = 0;
|
|
|
|
options->GetLength(&length);
|
|
|
|
*aNumOptions = (PRInt32)length;
|
|
|
|
NS_RELEASE(options);
|
1999-04-13 02:14:31 +04:00
|
|
|
}
|
1999-07-21 02:32:41 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
1999-04-13 02:14:31 +04:00
|
|
|
}
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-05-08 00:30:16 +04: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-28 01:17:10 +04:00
|
|
|
nsListControlFrame::ToggleSelected(PRInt32 aIndex)
|
1999-05-08 00:30:16 +04:00
|
|
|
{
|
|
|
|
PRBool multiple;
|
|
|
|
GetMultiple(&multiple);
|
|
|
|
|
|
|
|
if (PR_TRUE == multiple) {
|
1999-08-26 18:54:07 +04:00
|
|
|
SetContentSelected(aIndex, PR_TRUE);
|
1999-05-08 00:30:16 +04:00
|
|
|
} else {
|
1999-08-26 18:54:07 +04:00
|
|
|
SetContentSelected(mSelectedIndex, PR_FALSE);
|
|
|
|
SetContentSelected(aIndex, PR_TRUE);
|
1999-05-28 01:17:10 +04:00
|
|
|
mSelectedIndex = aIndex;
|
1999-05-08 00:30:16 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-26 18:54:07 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISelectControlFrame
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
1999-10-26 08:44:41 +04:00
|
|
|
nsListControlFrame::AddOption(nsIPresContext* aPresContext, PRInt32 aIndex)
|
1999-08-26 18:54:07 +04:00
|
|
|
{
|
|
|
|
PRInt32 numOptions;
|
|
|
|
GetNumberOfOptions(&numOptions);
|
|
|
|
|
1999-10-12 12:47:29 +04:00
|
|
|
// PRInt32 oldSelectedIndex = mSelectedIndex;
|
|
|
|
GetSelectedIndexFromDOM(&mSelectedIndex); // comes from the DOM
|
1999-08-26 18:54:07 +04:00
|
|
|
|
1999-10-12 12:47:29 +04:00
|
|
|
// Adding an option to the select can cause a change in selection
|
|
|
|
// if the new option has it's selected attribute set.
|
|
|
|
// selectionChanged = (1 == numOptions ||
|
|
|
|
// kNothingSelected == oldSelectedIndex || mSelectedIndex != oldSelectedIndex)
|
|
|
|
|
|
|
|
// For now, we don't care because we're not dispatching an event:
|
|
|
|
InitSelectionCache(-1); // Reset sel cache so as not to send event
|
1999-08-26 18:54:07 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-10-26 08:44:41 +04:00
|
|
|
nsListControlFrame::RemoveOption(nsIPresContext* aPresContext, PRInt32 aIndex)
|
1999-08-26 18:54:07 +04:00
|
|
|
{
|
|
|
|
PRInt32 numOptions;
|
|
|
|
GetNumberOfOptions(&numOptions);
|
|
|
|
|
1999-10-12 12:47:29 +04:00
|
|
|
// PRInt32 oldSelectedIndex = mSelectedIndex;
|
|
|
|
GetSelectedIndexFromDOM(&mSelectedIndex); // comes from the DOM
|
1999-08-26 18:54:07 +04:00
|
|
|
|
1999-10-12 12:47:29 +04: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 18:54:07 +04:00
|
|
|
}
|
|
|
|
|
1999-10-12 12:47:29 +04:00
|
|
|
// Only if aIndex != -1 can we determine if there was a change in selection
|
|
|
|
// selectionChanged = (aIndex == mSelectedIndex) || (mSelectedIndex ==
|
|
|
|
// oldSelectedIndex - (oldSelectedIndex > aIndex)?1:0);
|
|
|
|
// Call SelectionChanged to dispatch an event if so!
|
|
|
|
|
|
|
|
// For now, we don't care because we're not dispatching an event:
|
|
|
|
InitSelectionCache(-1); // Reset cache to not send event
|
1999-08-26 18:54:07 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-08-27 07:58:13 +04: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)
|
|
|
|
{
|
|
|
|
PRBool multiple;
|
1999-09-17 02:36:29 +04:00
|
|
|
nsresult rv = GetMultiple(&multiple);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
1999-08-27 07:58:13 +04:00
|
|
|
if (aValue) {
|
1999-09-17 02:36:29 +04:00
|
|
|
ToggleSelected(aIndex); // sets mSelectedIndex
|
1999-08-27 07:58:13 +04:00
|
|
|
} else {
|
1999-09-17 02:36:29 +04: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 07:58:13 +04:00
|
|
|
}
|
|
|
|
}
|
1999-10-06 03:43:06 +04:00
|
|
|
// Should we send an event here or not?
|
1999-09-17 02:36:29 +04:00
|
|
|
if (nsnull != mComboboxFrame) {
|
|
|
|
rv = mComboboxFrame->UpdateSelection(PR_FALSE, PR_TRUE, aIndex); // don't dispatch event
|
1999-10-06 03:43:06 +04:00
|
|
|
} else {
|
|
|
|
InitSelectionCache(-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initialize selection cache from content state;
|
|
|
|
nsresult
|
|
|
|
nsListControlFrame::InitSelectionCache(PRInt32 aLength)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
// Get number of options from content if needed
|
|
|
|
if (0 > aLength) {
|
|
|
|
rv = GetNumberOfOptions(&aLength);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Allocate a new array or realloc if the length has changed
|
|
|
|
if (NS_SUCCEEDED(rv) && (mSelectionCacheLength != aLength)) {
|
|
|
|
if (mSelectionCache) {
|
|
|
|
delete[] mSelectionCache;
|
|
|
|
mSelectionCacheLength = 0;
|
|
|
|
}
|
|
|
|
mSelectionCache = new PRBool[aLength];
|
|
|
|
if (!mSelectionCache) return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
mSelectionCacheLength = aLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sync the cache to the content
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
for (PRInt32 i = 0; i < mSelectionCacheLength; i++) {
|
|
|
|
mSelectionCache[i] = IsContentSelectedByIndex(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Compare content state with local cache of last known state
|
|
|
|
// If there was a change, call SelectionChanged()
|
|
|
|
NS_IMETHODIMP
|
1999-10-12 12:47:29 +04:00
|
|
|
nsListControlFrame::UpdateSelection(PRBool aDoDispatchEvent, PRBool aForceUpdate, nsIContent* aContent)
|
1999-10-06 03:43:06 +04: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) {
|
|
|
|
NS_ASSERTION(0,"nsListControlFrame: Cache sync'd with content!\n");
|
|
|
|
rv = InitSelectionCache(length);
|
|
|
|
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;
|
|
|
|
for (PRInt32 i = 0; i < length; i++) {
|
|
|
|
selected = IsContentSelectedByIndex(i);
|
|
|
|
if (selected != mSelectionCache[i]) {
|
|
|
|
mSelectionCache[i] = selected;
|
|
|
|
changed = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-10-12 12:47:29 +04:00
|
|
|
if (changed && aDoDispatchEvent) {
|
|
|
|
rv = SelectionChanged(aContent); // Dispatch event
|
|
|
|
}
|
|
|
|
if ((changed || aForceUpdate) && mComboboxFrame) {
|
|
|
|
rv = mComboboxFrame->SelectionChanged(); // Update view
|
1999-09-17 02:36:29 +04:00
|
|
|
}
|
1999-08-27 07:58:13 +04:00
|
|
|
}
|
1999-09-17 02:36:29 +04:00
|
|
|
return rv;
|
1999-08-27 07:58:13 +04:00
|
|
|
}
|
|
|
|
|
1999-10-06 03:43:06 +04:00
|
|
|
// Send out an onchange notification.
|
|
|
|
nsresult
|
|
|
|
nsListControlFrame::SelectionChanged(nsIContent* aContent)
|
|
|
|
{
|
|
|
|
// Dispatch the NS_FORM_CHANGE event
|
|
|
|
nsEventStatus status = nsEventStatus_eIgnore;
|
|
|
|
nsGUIEvent event;
|
|
|
|
event.eventStructType = NS_GUI_EVENT;
|
|
|
|
event.widget = nsnull;
|
|
|
|
event.message = NS_FORM_CHANGE;
|
|
|
|
event.flags = NS_EVENT_FLAG_NONE;
|
|
|
|
|
|
|
|
// Here we create our own DOM event and set the target to the Select
|
|
|
|
// We'll pass this DOM event in, in hopes that the target is used.
|
|
|
|
nsIDOMEvent* DOMEvent = nsnull;
|
|
|
|
nsresult res = NS_NewDOMUIEvent(&DOMEvent, *mPresContext, &event);
|
|
|
|
if (NS_SUCCEEDED(res) && DOMEvent && mContent) {
|
|
|
|
nsIDOMNode* node = nsnull;
|
|
|
|
res = mContent->QueryInterface(kIDOMNodeIID, (void**)&node);
|
|
|
|
if (NS_SUCCEEDED(res) && node) {
|
|
|
|
nsIPrivateDOMEvent* pDOMEvent = nsnull;
|
|
|
|
res = DOMEvent->QueryInterface(kIPrivateDOMEventIID, (void**)&pDOMEvent);
|
|
|
|
if (NS_SUCCEEDED(res) && pDOMEvent) {
|
|
|
|
res = pDOMEvent->SetTarget(node);
|
|
|
|
if (NS_SUCCEEDED(res)) {
|
|
|
|
// Have the content handle the event.
|
|
|
|
res = mContent->HandleDOMEvent(*mPresContext, &event, &DOMEvent, NS_EVENT_FLAG_BUBBLE, status);
|
|
|
|
}
|
|
|
|
NS_RELEASE(pDOMEvent);
|
|
|
|
}
|
|
|
|
NS_RELEASE(node);
|
|
|
|
}
|
|
|
|
NS_RELEASE(DOMEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now have the frame handle the event
|
|
|
|
if (NS_SUCCEEDED(res)) {
|
|
|
|
if (this) {
|
|
|
|
nsIFrame* frame = nsnull;
|
|
|
|
res = this->QueryInterface(kIFrameIID, (void**)&frame);
|
|
|
|
if ((NS_SUCCEEDED(res)) && (nsnull != frame)) {
|
|
|
|
res = frame->HandleEvent(*mPresContext, &event, status);
|
|
|
|
// NS_RELEASE(frame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
1999-09-15 09:31:31 +04: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 18:54:07 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// End nsISelectControlFrame
|
|
|
|
//----------------------------------------------------------------------
|
1999-05-08 00:30:16 +04:00
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-05-08 00:30:16 +04:00
|
|
|
NS_IMETHODIMP
|
1999-10-26 08:44:41 +04:00
|
|
|
nsListControlFrame::SetProperty(nsIPresContext* aPresContext, nsIAtom* aName, const nsString& aValue)
|
1999-01-26 01:16:27 +03:00
|
|
|
{
|
1999-04-13 02:14:31 +04:00
|
|
|
if (nsHTMLAtoms::selected == aName) {
|
|
|
|
return NS_ERROR_INVALID_ARG; // Selected is readonly according to spec.
|
|
|
|
} else if (nsHTMLAtoms::selectedindex == aName) {
|
|
|
|
PRInt32 error = 0;
|
|
|
|
PRInt32 selectedIndex = aValue.ToInteger(&error, 10); // Get index from aValue
|
|
|
|
if (error) {
|
|
|
|
return NS_ERROR_INVALID_ARG; // Couldn't convert to integer
|
|
|
|
} else {
|
1999-05-08 00:30:16 +04:00
|
|
|
// Select the specified item in the list box.
|
1999-08-26 18:54:07 +04:00
|
|
|
if (mSelectedIndex != selectedIndex) {
|
|
|
|
ToggleSelected(selectedIndex);// sets mSelectedIndex
|
1999-10-06 03:43:06 +04:00
|
|
|
// Should we send an event here?
|
1999-08-26 18:54:07 +04:00
|
|
|
if (nsnull != mComboboxFrame) {
|
|
|
|
mComboboxFrame->UpdateSelection(PR_FALSE, PR_TRUE, selectedIndex); // don't dispatch event
|
1999-10-06 03:43:06 +04:00
|
|
|
} else {
|
|
|
|
InitSelectionCache(-1);
|
|
|
|
}
|
1999-08-26 18:54:07 +04:00
|
|
|
}
|
1999-04-13 02:14:31 +04:00
|
|
|
}
|
|
|
|
}
|
1999-05-28 01:17:10 +04:00
|
|
|
|
1999-01-26 01:16:27 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-05-08 00:30:16 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::GetProperty(nsIAtom* aName, nsString& aValue)
|
1999-03-06 22:43:13 +03:00
|
|
|
{
|
1999-04-13 02:14:31 +04:00
|
|
|
// Get the selected value of option from local cache (optimization vs. widget)
|
|
|
|
if (nsHTMLAtoms::selected == aName) {
|
|
|
|
PRInt32 error = 0;
|
|
|
|
PRBool selected = PR_FALSE;
|
1999-08-27 07:58:13 +04:00
|
|
|
PRInt32 indx = aValue.ToInteger(&error, 10); // Get index from aValue
|
1999-04-13 02:14:31 +04:00
|
|
|
if (error == 0)
|
1999-08-27 07:58:13 +04:00
|
|
|
selected = IsContentSelectedByIndex(indx);
|
1999-04-13 02:14:31 +04:00
|
|
|
|
|
|
|
nsFormControlHelper::GetBoolString(selected, aValue);
|
|
|
|
|
|
|
|
// For selectedIndex, get the value from the widget
|
|
|
|
} else if (nsHTMLAtoms::selectedindex == aName) {
|
1999-08-26 18:54:07 +04:00
|
|
|
// figures out the first selected item from the content
|
|
|
|
PRInt32 selectedIndex;
|
|
|
|
GetSelectedIndexFromDOM(&selectedIndex);
|
1999-09-17 11:22:23 +04:00
|
|
|
if ((kNothingSelected == selectedIndex) && (mComboboxFrame)) {
|
|
|
|
selectedIndex = 0;
|
|
|
|
}
|
1999-08-26 18:54:07 +04:00
|
|
|
aValue.Append(selectedIndex, 10);
|
|
|
|
//aValue.Append(mSelectedIndex, 10);
|
|
|
|
|
1999-04-13 02:14:31 +04:00
|
|
|
}
|
|
|
|
|
1999-03-06 22:43:13 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-05-29 01:12:09 +04:00
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-05-28 01:17:10 +04: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-15 02:00:24 +04:00
|
|
|
nsresult
|
|
|
|
nsListControlFrame::CreateScrollingViewWidget(nsIView* aView, const nsStylePosition* aPosition)
|
1999-05-28 01:17:10 +04:00
|
|
|
{
|
|
|
|
if (IsInDropDownMode() == PR_TRUE) {
|
|
|
|
nsWidgetInitData widgetData;
|
|
|
|
aView->SetZIndex(kMaxZ);
|
1999-07-29 01:38:08 +04:00
|
|
|
widgetData.mWindowType = eWindowType_popup;
|
1999-07-27 08:27:17 +04:00
|
|
|
widgetData.mBorderStyle = eBorderStyle_default;
|
1999-09-15 01:29:58 +04: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-28 01:17:10 +04:00
|
|
|
return NS_OK;
|
|
|
|
} else {
|
|
|
|
return nsScrollFrame::CreateScrollingViewWidget(aView, aPosition);
|
|
|
|
}
|
|
|
|
}
|
1999-06-22 00:41:56 +04:00
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-06-22 00:41:56 +04:00
|
|
|
void
|
|
|
|
nsListControlFrame::GetViewOffset(nsIViewManager* aManager, nsIView* aView,
|
|
|
|
nsPoint& aPoint)
|
|
|
|
{
|
|
|
|
aPoint.x = 0;
|
|
|
|
aPoint.y = 0;
|
1999-05-28 01:17:10 +04:00
|
|
|
|
1999-06-22 00:41:56 +04: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-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-08-31 17:22:50 +04:00
|
|
|
NS_IMETHODIMP
|
1999-10-26 08:44:41 +04:00
|
|
|
nsListControlFrame::SyncViewWithFrame(nsIPresContext* aPresContext)
|
1999-06-22 00:41:56 +04: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 17:22:50 +04:00
|
|
|
mComboboxFrame->AbsolutelyPositionDropDown();
|
1999-06-22 00:41:56 +04:00
|
|
|
|
|
|
|
nsPoint parentPos;
|
|
|
|
nsCOMPtr<nsIViewManager> viewManager;
|
|
|
|
|
|
|
|
//Get parent frame
|
|
|
|
nsIFrame* parent;
|
1999-10-26 08:44:41 +04:00
|
|
|
GetParentWithView(aPresContext, &parent);
|
1999-06-22 00:41:56 +04:00
|
|
|
NS_ASSERTION(parent, "GetParentWithView failed");
|
|
|
|
|
|
|
|
// Get parent view
|
|
|
|
nsIView* parentView = nsnull;
|
1999-10-26 08:44:41 +04:00
|
|
|
parent->GetView(aPresContext, &parentView);
|
1999-06-22 00:41:56 +04:00
|
|
|
|
|
|
|
parentView->GetViewManager(*getter_AddRefs(viewManager));
|
|
|
|
GetViewOffset(viewManager, parentView, parentPos);
|
|
|
|
nsIView* view = nsnull;
|
1999-10-26 08:44:41 +04:00
|
|
|
GetView(aPresContext, &view);
|
1999-06-22 00:41:56 +04:00
|
|
|
|
|
|
|
nsIView* containingView = nsnull;
|
|
|
|
nsPoint offset;
|
1999-10-26 08:44:41 +04:00
|
|
|
GetOffsetFromView(aPresContext, offset, &containingView);
|
1999-08-31 17:22:50 +04:00
|
|
|
//nsSize size;
|
|
|
|
//GetSize(size);
|
1999-06-22 00:41:56 +04:00
|
|
|
|
1999-08-31 17:22:50 +04:00
|
|
|
nscoord width;
|
|
|
|
nscoord height;
|
|
|
|
view->GetDimensions(&width, &height);
|
1999-07-29 01:38:08 +04:00
|
|
|
|
1999-08-31 17:22:50 +04:00
|
|
|
if (width != mRect.width || height != mRect.height) {
|
|
|
|
viewManager->ResizeView(view, mRect.width, mRect.height);
|
|
|
|
}
|
|
|
|
nscoord x;
|
|
|
|
nscoord y;
|
|
|
|
view->GetPosition(&x, &y);
|
1999-07-29 01:38:08 +04:00
|
|
|
|
1999-08-31 17:22:50 +04:00
|
|
|
nscoord newX = parentPos.x + offset.x;
|
|
|
|
nscoord newY = parentPos.y + offset.y;
|
1999-07-29 01:38:08 +04:00
|
|
|
|
1999-08-31 17:22:50 +04: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-09-29 07:36:16 +04:00
|
|
|
view->SetVisibility(NS_STYLE_VISIBILITY_VISIBLE == disp->mVisible ?nsViewVisibility_kShow:nsViewVisibility_kHide);
|
1999-08-31 17:22:50 +04:00
|
|
|
}
|
1999-07-29 01:38:08 +04:00
|
|
|
|
1999-06-22 00:41:56 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-09-08 18:27:38 +04:00
|
|
|
//---------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::AboutToDropDown()
|
|
|
|
{
|
|
|
|
mSelectedIndexWhenPoppedDown = mSelectedIndex;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-10-01 18:30:33 +04:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// We are about to be rolledup from the outside (ComboboxFrame)
|
|
|
|
// this is a "cancelled" action not a selected action
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::AboutToRollup()
|
|
|
|
{
|
|
|
|
ResetSelectedItem();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-06-22 00:41:56 +04:00
|
|
|
nsresult
|
1999-10-26 08:44:41 +04:00
|
|
|
nsListControlFrame::GetScrollingParentView(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIView** aParentView)
|
1999-06-22 00:41:56 +04:00
|
|
|
{
|
|
|
|
if (IsInDropDownMode() == PR_TRUE) {
|
|
|
|
// Use the parent frame to get the view manager
|
|
|
|
nsIView* parentView = nsnull;
|
1999-10-26 08:44:41 +04:00
|
|
|
nsresult rv = aParent->GetView(aPresContext, &parentView);
|
1999-06-22 00:41:56 +04: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);
|
|
|
|
NS_ASSERTION(aParentView, "GetRootView failed");
|
|
|
|
return rv;
|
|
|
|
} else {
|
1999-10-26 08:44:41 +04:00
|
|
|
return nsScrollFrame::GetScrollingParentView(aPresContext, aParent, aParentView);
|
1999-06-22 00:41:56 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
1999-06-22 00:41:56 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::DidReflow(nsIPresContext& aPresContext,
|
1999-07-29 01:38:08 +04:00
|
|
|
nsDidReflowStatus aStatus)
|
1999-06-22 00:41:56 +04:00
|
|
|
{
|
|
|
|
if (PR_TRUE == IsInDropDownMode())
|
|
|
|
{
|
1999-08-31 17:22:50 +04:00
|
|
|
//SyncViewWithFrame();
|
|
|
|
mState &= ~NS_FRAME_SYNC_FRAME_AND_VIEW;
|
1999-06-22 00:41:56 +04:00
|
|
|
nsresult rv = nsScrollFrame::DidReflow(aPresContext, aStatus);
|
1999-08-31 17:22:50 +04:00
|
|
|
mState |= NS_FRAME_SYNC_FRAME_AND_VIEW;
|
1999-10-26 08:44:41 +04:00
|
|
|
SyncViewWithFrame(&aPresContext);
|
1999-06-22 00:41:56 +04:00
|
|
|
return rv;
|
|
|
|
} else {
|
|
|
|
return nsScrollFrame::DidReflow(aPresContext, aStatus);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-10-26 08:44:41 +04:00
|
|
|
NS_IMETHODIMP nsListControlFrame::MoveTo(nsIPresContext* aPresContext, nscoord aX, nscoord aY)
|
1999-08-31 17:22:50 +04:00
|
|
|
{
|
|
|
|
if (PR_TRUE == IsInDropDownMode())
|
|
|
|
{
|
|
|
|
//SyncViewWithFrame();
|
|
|
|
mState &= ~NS_FRAME_SYNC_FRAME_AND_VIEW;
|
1999-10-26 08:44:41 +04:00
|
|
|
nsresult rv = nsScrollFrame::MoveTo(aPresContext, aX, aY);
|
1999-08-31 17:22:50 +04:00
|
|
|
mState |= NS_FRAME_SYNC_FRAME_AND_VIEW;
|
|
|
|
//SyncViewWithFrame();
|
|
|
|
return rv;
|
|
|
|
} else {
|
1999-10-26 08:44:41 +04:00
|
|
|
return nsScrollFrame::MoveTo(aPresContext, aX, aY);
|
1999-08-31 17:22:50 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::GetMaximumSize(nsSize &aSize)
|
|
|
|
{
|
1999-07-29 01:38:08 +04: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-15 02:00:24 +04:00
|
|
|
aSize.height = mMaxHeight;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-05-28 01:17:10 +04:00
|
|
|
|
1999-03-06 22:43:13 +03:00
|
|
|
|
1999-07-29 01:38:08 +04:00
|
|
|
//---------------------------------------------------------
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::SetSuggestedSize(nscoord aWidth, nscoord aHeight)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-03-29 02:22:54 +04:00
|
|
|
|
1999-09-08 18:27:38 +04:00
|
|
|
//---------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsListControlFrame::IsTargetOptionDisabled(PRBool &aIsDisabled)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
|
|
|
aIsDisabled = PR_FALSE;
|
|
|
|
|
|
|
|
nsIEventStateManager *stateManager;
|
|
|
|
rv = mPresContext->GetEventStateManager(&stateManager);
|
|
|
|
if (NS_OK == rv) {
|
|
|
|
nsIContent * content;
|
|
|
|
rv = stateManager->GetEventTargetContent(&content);
|
|
|
|
if (NS_OK == rv && nsnull != content) {
|
|
|
|
if (IsOptionElement(content)) {
|
|
|
|
aIsDisabled = nsFormFrame::GetDisabled(this, content);
|
|
|
|
} else {
|
|
|
|
rv = NS_ERROR_FAILURE; // return error when it is not an option
|
|
|
|
}
|
|
|
|
NS_RELEASE(content);
|
|
|
|
}
|
|
|
|
NS_RELEASE(stateManager);
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-10-01 18:30:33 +04: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()
|
|
|
|
{
|
|
|
|
ToggleSelected(mSelectedIndexWhenPoppedDown);
|
|
|
|
}
|
|
|
|
|
1999-08-26 18:54:07 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIDOMMouseListener
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
nsresult
|
|
|
|
nsListControlFrame::MouseUp(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (nsFormFrame::GetDisabled(this)) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-09-08 18:27:38 +04: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) {
|
|
|
|
if (IsInDropDownMode() == PR_TRUE && mComboboxFrame) {
|
1999-10-01 18:30:33 +04:00
|
|
|
ResetSelectedItem();
|
1999-09-08 18:27:38 +04:00
|
|
|
mComboboxFrame->ListWasSelected(mPresContext);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-26 18:54:07 +04:00
|
|
|
const nsStyleDisplay* disp = (const nsStyleDisplay*)mStyleContext->GetStyleData(eStyleStruct_Display);
|
|
|
|
if (!disp->mVisible) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsInDropDownMode() == PR_TRUE) {
|
1999-08-27 18:42:27 +04:00
|
|
|
if (NS_SUCCEEDED(GetIndexFromDOMEvent(aMouseEvent, mOldSelectedIndex, mSelectedIndex))) {
|
1999-08-26 18:54:07 +04:00
|
|
|
if (kNothingSelected != mSelectedIndex) {
|
|
|
|
SetContentSelected(mSelectedIndex, PR_TRUE);
|
|
|
|
}
|
|
|
|
if (mComboboxFrame) {
|
|
|
|
mComboboxFrame->ListWasSelected(mPresContext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
mButtonDown = PR_FALSE;
|
1999-10-26 08:44:41 +04:00
|
|
|
CaptureMouseEvents(mPresContext, PR_FALSE);
|
1999-10-12 12:47:29 +04:00
|
|
|
UpdateSelection(PR_TRUE, PR_FALSE, mContent);
|
1999-08-26 18:54:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// 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 18:42:27 +04:00
|
|
|
nsListControlFrame::GetIndexFromDOMEvent(nsIDOMEvent* aMouseEvent,
|
|
|
|
PRInt32& aOldIndex,
|
|
|
|
PRInt32& aCurIndex)
|
1999-08-26 18:54:07 +04:00
|
|
|
{
|
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
|
|
|
nsIEventStateManager *stateManager;
|
|
|
|
if (NS_OK == mPresContext->GetEventStateManager(&stateManager)) {
|
|
|
|
nsIContent * content;
|
|
|
|
stateManager->GetEventTargetContent(&content);
|
1999-10-01 18:30:33 +04:00
|
|
|
#ifdef DEBUG_rodsXXX
|
1999-08-31 17:22:50 +04:00
|
|
|
///////////////////
|
1999-09-09 04:23:40 +04:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMHTMLOptionElement> optElem;
|
|
|
|
if (NS_SUCCEEDED(content->QueryInterface(nsCOMTypeInfo<nsIDOMHTMLOptionElement>::GetIID(),(void**) getter_AddRefs(optElem)))) {
|
|
|
|
nsAutoString val;
|
|
|
|
optElem->GetValue(val);
|
|
|
|
printf("val [%s]\n", val.ToNewCString());
|
|
|
|
}
|
1999-08-31 17:22:50 +04:00
|
|
|
}
|
|
|
|
///////////////////
|
1999-09-30 15:37:58 +04:00
|
|
|
#endif
|
1999-08-26 18:54:07 +04:00
|
|
|
nsIContent * optionContent = GetOptionFromContent(content);
|
|
|
|
NS_RELEASE(content);
|
|
|
|
if (nsnull != optionContent) {
|
1999-08-27 18:42:27 +04:00
|
|
|
aOldIndex = aCurIndex;
|
|
|
|
aCurIndex = GetSelectedIndexFromContent(optionContent);
|
1999-08-26 18:54:07 +04:00
|
|
|
NS_RELEASE(optionContent);
|
|
|
|
rv = NS_OK;
|
|
|
|
}
|
|
|
|
NS_RELEASE(stateManager);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
nsresult
|
|
|
|
nsListControlFrame::MouseDown(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
|
|
|
if (nsFormFrame::GetDisabled(this)) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-09-08 18:27:38 +04: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 23:54:30 +04:00
|
|
|
if (optionIsDisabled) {
|
|
|
|
if (IsInDropDownMode() == PR_TRUE) {
|
1999-10-01 18:30:33 +04:00
|
|
|
ResetSelectedItem();
|
1999-09-08 23:54:30 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-09-08 18:27:38 +04:00
|
|
|
}
|
|
|
|
|
1999-08-27 18:42:27 +04:00
|
|
|
PRInt32 oldIndex;
|
|
|
|
PRInt32 curIndex = mSelectedIndex;
|
1999-08-26 18:54:07 +04:00
|
|
|
|
1999-08-27 18:42:27 +04:00
|
|
|
if (NS_SUCCEEDED(GetIndexFromDOMEvent(aMouseEvent, oldIndex, curIndex))) {
|
1999-08-26 18:54:07 +04:00
|
|
|
if (IsInDropDownMode() == PR_TRUE) {
|
1999-09-30 15:37:58 +04:00
|
|
|
// the pop up stole focus away from the webshell
|
|
|
|
// now I am giving it back
|
|
|
|
nsIFrame * parentFrame;
|
1999-10-26 08:44:41 +04:00
|
|
|
GetParentWithView(mPresContext, &parentFrame);
|
1999-09-30 15:37:58 +04:00
|
|
|
if (nsnull != parentFrame) {
|
|
|
|
nsIView * pView;
|
1999-10-26 08:44:41 +04:00
|
|
|
parentFrame->GetView(mPresContext, &pView);
|
1999-09-30 15:37:58 +04: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
|
|
|
|
nsIEventStateManager *stateManager;
|
|
|
|
if (NS_OK == mPresContext->GetEventStateManager(&stateManager)) {
|
|
|
|
stateManager->ConsumeFocusEvents(PR_TRUE);
|
|
|
|
NS_RELEASE(stateManager);
|
|
|
|
}
|
1999-08-26 18:54:07 +04:00
|
|
|
} else {
|
1999-08-27 18:42:27 +04:00
|
|
|
mSelectedIndex = curIndex;
|
|
|
|
mOldSelectedIndex = oldIndex;
|
1999-08-26 18:54:07 +04:00
|
|
|
// Handle Like List
|
|
|
|
mButtonDown = PR_TRUE;
|
1999-10-26 08:44:41 +04:00
|
|
|
CaptureMouseEvents(mPresContext, PR_TRUE);
|
1999-08-26 18:54:07 +04:00
|
|
|
HandleListSelection(aMouseEvent);
|
|
|
|
}
|
|
|
|
} else {
|
1999-09-08 18:27:38 +04:00
|
|
|
// NOTE: the combo box is responsible for dropping it down
|
1999-08-26 18:54:07 +04:00
|
|
|
if (mComboboxFrame) {
|
1999-09-13 22:29:00 +04:00
|
|
|
nsIEventStateManager *stateManager;
|
|
|
|
if (NS_OK == mPresContext->GetEventStateManager(&stateManager)) {
|
|
|
|
nsIFrame * frame;
|
|
|
|
stateManager->GetEventTarget(&frame);
|
|
|
|
nsCOMPtr<nsIListControlFrame> listFrame(do_QueryInterface(frame));
|
|
|
|
if (listFrame) {
|
1999-09-14 03:20:50 +04:00
|
|
|
nsCOMPtr<nsIDOMUIEvent> uiEvent(do_QueryInterface(aMouseEvent));
|
|
|
|
PRInt32 scrX;
|
|
|
|
PRInt32 scrY;
|
|
|
|
uiEvent->GetScreenX(&scrX);
|
|
|
|
uiEvent->GetScreenY(&scrY);
|
|
|
|
nsRect rect;
|
|
|
|
mComboboxFrame->GetAbsoluteRect(&rect);
|
|
|
|
if (!rect.Contains(scrX, scrY)) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-09-13 22:29:00 +04:00
|
|
|
}
|
1999-09-30 15:37:58 +04: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 22:29:00 +04:00
|
|
|
|
1999-09-30 15:37:58 +04:00
|
|
|
if (isDroppedDown) {
|
1999-10-26 08:44:41 +04:00
|
|
|
CaptureMouseEvents(mPresContext, PR_FALSE);
|
1999-09-30 15:37:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_RELEASE(stateManager);
|
1999-08-26 18:54:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIDOMMouseMotionListener
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
nsresult
|
|
|
|
nsListControlFrame::MouseMove(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
1999-09-19 13:48:04 +04:00
|
|
|
if (mComboboxFrame) { // Synonym for IsInDropDownMode()
|
|
|
|
PRBool isDroppedDown = PR_FALSE;
|
|
|
|
mComboboxFrame->IsDroppedDown(&isDroppedDown);
|
|
|
|
if (isDroppedDown) {
|
|
|
|
PRInt32 oldIndex;
|
|
|
|
PRInt32 curIndex = mSelectedIndex;
|
|
|
|
if (NS_SUCCEEDED(GetIndexFromDOMEvent(aMouseEvent, oldIndex, curIndex))) {
|
|
|
|
mSelectedIndex = curIndex;
|
|
|
|
mOldSelectedIndex = oldIndex;
|
|
|
|
if (kNothingSelected != mSelectedIndex) {
|
|
|
|
if (mOldSelectedIndex != mSelectedIndex) {
|
|
|
|
if (mOldSelectedIndex != kNothingSelected) {
|
|
|
|
SetContentSelected(mOldSelectedIndex, PR_FALSE);
|
|
|
|
}
|
|
|
|
SetContentSelected(mSelectedIndex, PR_TRUE);
|
1999-08-26 18:54:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-27 18:42:27 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIDOMKeyListener
|
|
|
|
//----------------------------------------------------------------------
|
1999-09-30 15:37:58 +04:00
|
|
|
nsresult
|
|
|
|
nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-27 18:42:27 +04:00
|
|
|
nsresult
|
|
|
|
nsListControlFrame::KeyDown(nsIDOMEvent* aKeyEvent)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMUIEvent> uiEvent = do_QueryInterface(aKeyEvent);
|
1999-09-30 15:37:58 +04:00
|
|
|
if (uiEvent) {
|
|
|
|
PRUint32 code;
|
1999-10-01 18:30:33 +04:00
|
|
|
//uiEvent->GetCharCode(&code);
|
1999-09-30 15:37:58 +04:00
|
|
|
//printf("%c %d ", code, code);
|
|
|
|
uiEvent->GetKeyCode(&code);
|
|
|
|
//printf("%c %d\n", code, code);
|
|
|
|
|
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
|
|
|
nsIDOMHTMLCollection* options = GetOptions(mContent);
|
1999-08-27 18:42:27 +04:00
|
|
|
|
1999-09-30 15:37:58 +04:00
|
|
|
if (nsnull != options) {
|
|
|
|
PRUint32 numOptions;
|
|
|
|
options->GetLength(&numOptions);
|
1999-08-27 18:42:27 +04:00
|
|
|
|
1999-09-30 15:37:58 +04:00
|
|
|
if (numOptions == 0) {
|
|
|
|
rv = NS_OK;
|
|
|
|
} else {
|
|
|
|
if (code == nsIDOMUIEvent::DOM_VK_UP) {
|
|
|
|
printf("DOM_VK_UP mSelectedIndex: %d ", mSelectedIndex);
|
|
|
|
if (mSelectedIndex > 0) {
|
|
|
|
mOldSelectedIndex = mSelectedIndex;
|
|
|
|
mSelectedIndex--;
|
|
|
|
SingleSelection();
|
|
|
|
if (nsnull != mComboboxFrame) {
|
|
|
|
mComboboxFrame->UpdateSelection(PR_FALSE, PR_TRUE, mSelectedIndex); // don't dispatch event
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf(" After: %d\n", mSelectedIndex);
|
|
|
|
} if (code == nsIDOMUIEvent::DOM_VK_DOWN) {
|
|
|
|
printf("DOM_VK_DOWN mSelectedIndex: %d ", mSelectedIndex);
|
|
|
|
if ((mSelectedIndex+1) < (PRInt32)numOptions) {
|
|
|
|
mOldSelectedIndex = mSelectedIndex;
|
|
|
|
mSelectedIndex++;
|
|
|
|
SingleSelection();
|
|
|
|
if (nsnull != mComboboxFrame) {
|
|
|
|
mComboboxFrame->UpdateSelection(PR_FALSE, PR_TRUE, mSelectedIndex); // don't dispatch event
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf(" After: %d\n", mSelectedIndex);
|
|
|
|
} if (code == nsIDOMUIEvent::DOM_VK_RETURN) {
|
|
|
|
if (IsInDropDownMode() == PR_TRUE && mComboboxFrame) {
|
1999-10-06 03:43:06 +04:00
|
|
|
mComboboxFrame->ListWasSelected(mPresContext);
|
|
|
|
} else {
|
1999-10-29 00:31:23 +04:00
|
|
|
UpdateSelection(PR_TRUE, PR_FALSE, mContent);
|
|
|
|
}
|
1999-09-30 15:37:58 +04:00
|
|
|
} if (code == nsIDOMUIEvent::DOM_VK_ESCAPE) {
|
|
|
|
if (IsInDropDownMode() == PR_TRUE && mComboboxFrame) {
|
1999-10-01 18:30:33 +04:00
|
|
|
ResetSelectedItem();
|
1999-09-30 15:37:58 +04:00
|
|
|
mComboboxFrame->ListWasSelected(mPresContext);
|
|
|
|
}
|
1999-10-06 03:43:06 +04:00
|
|
|
} else { // Select option with this as the first character
|
1999-10-29 00:31:23 +04:00
|
|
|
// XXX Not I18N compliant
|
1999-10-06 03:43:06 +04:00
|
|
|
PRInt32 selectedIndex = (mSelectedIndex == kNothingSelected ? 0 : mSelectedIndex+1) % numOptions;
|
1999-10-01 18:30:33 +04:00
|
|
|
PRInt32 startedAtIndex = selectedIndex;
|
|
|
|
PRBool loopedAround = PR_FALSE;
|
|
|
|
while ((selectedIndex < startedAtIndex && loopedAround) || !loopedAround) {
|
|
|
|
nsIDOMHTMLOptionElement* optionElement = GetOption(*options, selectedIndex);
|
1999-09-30 15:37:58 +04:00
|
|
|
if (nsnull != optionElement) {
|
|
|
|
nsAutoString text;
|
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == optionElement->GetText(text)) {
|
|
|
|
char * buf = text.ToNewCString();
|
|
|
|
char c = buf[0];
|
|
|
|
delete [] buf;
|
|
|
|
if (c == (char)code) {
|
|
|
|
mOldSelectedIndex = mSelectedIndex;
|
1999-10-01 18:30:33 +04:00
|
|
|
mSelectedIndex = selectedIndex;
|
1999-09-30 15:37:58 +04:00
|
|
|
SingleSelection();
|
|
|
|
if (nsnull != mComboboxFrame) {
|
|
|
|
mComboboxFrame->UpdateSelection(PR_FALSE, PR_TRUE, mSelectedIndex); // don't dispatch event
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
1999-08-27 18:42:27 +04:00
|
|
|
}
|
1999-09-30 15:37:58 +04:00
|
|
|
NS_RELEASE(optionElement);
|
1999-08-27 18:42:27 +04:00
|
|
|
}
|
1999-10-01 18:30:33 +04:00
|
|
|
selectedIndex++;
|
|
|
|
if (selectedIndex == (PRInt32)numOptions) {
|
|
|
|
selectedIndex = 0;
|
|
|
|
loopedAround = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // while
|
1999-08-27 18:42:27 +04:00
|
|
|
}
|
|
|
|
}
|
1999-09-30 15:37:58 +04:00
|
|
|
NS_RELEASE(options);
|
1999-08-27 18:42:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-08-06 18:14:38 +04:00
|
|
|
|
1999-09-15 09:31:31 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIStatefulFrame
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
1999-10-26 08:44:41 +04:00
|
|
|
nsListControlFrame::GetStateType(nsIPresContext* aPresContext,
|
|
|
|
nsIStatefulFrame::StateType* aStateType)
|
1999-09-15 09:31:31 +04:00
|
|
|
{
|
|
|
|
*aStateType = nsIStatefulFrame::eSelectType;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-10-26 08:44:41 +04:00
|
|
|
nsListControlFrame::SaveState(nsIPresContext* aPresContext,
|
|
|
|
nsISupports** aState)
|
1999-09-15 09:31:31 +04:00
|
|
|
{
|
|
|
|
nsISupportsArray* value = nsnull;
|
|
|
|
nsresult res = NS_NewISupportsArray(&value);
|
|
|
|
if (NS_SUCCEEDED(res) && value) {
|
|
|
|
PRInt32 j=0;
|
|
|
|
PRInt32 length = 0;
|
|
|
|
GetNumberOfOptions(&length);
|
|
|
|
PRInt32 i;
|
|
|
|
for (i=0; i<length; i++) {
|
|
|
|
PRBool selected = PR_FALSE;
|
|
|
|
res = GetOptionSelected(i, &selected);
|
|
|
|
if (NS_SUCCEEDED(res) && selected) {
|
|
|
|
nsISupportsPRInt32* thisVal = nsnull;
|
|
|
|
res = nsComponentManager::CreateInstance(NS_SUPPORTS_PRINT32_PROGID,
|
|
|
|
nsnull, NS_GET_IID(nsISupportsPRInt32), (void**)&thisVal);
|
|
|
|
if (NS_SUCCEEDED(res) && thisVal) {
|
|
|
|
res = thisVal->SetData(i);
|
|
|
|
if (NS_SUCCEEDED(res)) {
|
|
|
|
PRBool okay = value->InsertElementAt((nsISupports *)thisVal, j++);
|
|
|
|
if (!okay) res = NS_ERROR_OUT_OF_MEMORY; // Most likely cause;
|
|
|
|
}
|
|
|
|
if (!NS_SUCCEEDED(res)) NS_RELEASE(thisVal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!NS_SUCCEEDED(res)) break;
|
|
|
|
}
|
|
|
|
if (i<length)
|
|
|
|
NS_RELEASE(value);
|
|
|
|
}
|
|
|
|
*aState = (nsISupports*)value; // Set to null if not successful
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-10-26 08:44:41 +04:00
|
|
|
nsListControlFrame::RestoreState(nsIPresContext* aPresContext,
|
|
|
|
nsISupports* aState)
|
1999-09-15 09:31:31 +04:00
|
|
|
{
|
|
|
|
nsISupportsArray* value = (nsISupportsArray *)aState;
|
|
|
|
nsresult res = NS_ERROR_NULL_POINTER;
|
|
|
|
if (value) {
|
|
|
|
res = Deselect();
|
|
|
|
if (NS_SUCCEEDED(res)) {
|
|
|
|
PRUint32 count = 0;
|
|
|
|
res = value->Count(&count);
|
|
|
|
if (NS_SUCCEEDED(res)) {
|
|
|
|
nsISupportsPRInt32* thisVal = nsnull;
|
|
|
|
PRInt32 j=0;
|
|
|
|
for (PRUint32 i=0; i<count; i++) {
|
|
|
|
thisVal = (nsISupportsPRInt32*) value->ElementAt(i);
|
|
|
|
if (thisVal) {
|
|
|
|
res = thisVal->GetData(&j);
|
|
|
|
if (NS_SUCCEEDED(res)) {
|
|
|
|
res = SetOptionSelected(j, PR_TRUE);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
res = NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
if (!NS_SUCCEEDED(res)) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|