nsPresContext.cpp,.h - Added eWidgetRendering_PartialGfx as a rendering mode to PresContext.

ua.css - Added select[multiple] rule for multi-select listboxes without a size
Fixed form submission for gfx checkboxes,radiobuttons, and select by rewriting GetNamesValues.
Added nsListControlFrame::GetSizeAttribute and nsListControlFrame::GetNumberOfRows
Added logic to nsCSSFrameConstructor::ConstructSelectFrame and nsListControlFrame::Reflow
to handle the case of a multiselect select without a size specified.
This commit is contained in:
kmcclusk%netscape.com 1999-07-20 22:32:41 +00:00
Родитель 6f9b8db4dd
Коммит 41ed34acb6
27 изменённых файлов: 395 добавлений и 222 удалений

Просмотреть файл

@ -112,9 +112,6 @@ HTML_ATOM(enctype, "enctype")
HTML_ATOM(face, "face") HTML_ATOM(face, "face")
HTML_ATOM(fieldset, "fieldset") HTML_ATOM(fieldset, "fieldset")
HTML_ATOM(fieldsetContentPseudo, ":fieldset-content") HTML_ATOM(fieldsetContentPseudo, ":fieldset-content")
HTML_ATOM(fileButtonStylePseudo, ":-moz-file-button")
HTML_ATOM(fileTextStylePseudo, ":-moz-file-text")
HTML_ATOM(firstLetterPseudo, ":first-letter") HTML_ATOM(firstLetterPseudo, ":first-letter")
HTML_ATOM(firstLinePseudo, ":first-line") HTML_ATOM(firstLinePseudo, ":first-line")
HTML_ATOM(font, "font") HTML_ATOM(font, "font")

Просмотреть файл

@ -112,9 +112,6 @@ HTML_ATOM(enctype, "enctype")
HTML_ATOM(face, "face") HTML_ATOM(face, "face")
HTML_ATOM(fieldset, "fieldset") HTML_ATOM(fieldset, "fieldset")
HTML_ATOM(fieldsetContentPseudo, ":fieldset-content") HTML_ATOM(fieldsetContentPseudo, ":fieldset-content")
HTML_ATOM(fileButtonStylePseudo, ":-moz-file-button")
HTML_ATOM(fileTextStylePseudo, ":-moz-file-text")
HTML_ATOM(firstLetterPseudo, ":first-letter") HTML_ATOM(firstLetterPseudo, ":first-letter")
HTML_ATOM(firstLinePseudo, ":first-line") HTML_ATOM(firstLinePseudo, ":first-line")
HTML_ATOM(font, "font") HTML_ATOM(font, "font")

Просмотреть файл

@ -2410,8 +2410,11 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresContext* aPresContex
PRInt32 size = 1; PRInt32 size = 1;
nsresult result = aContent->QueryInterface(kIDOMHTMLSelectElementIID, (void**)&select); nsresult result = aContent->QueryInterface(kIDOMHTMLSelectElementIID, (void**)&select);
if (NS_SUCCEEDED(result)) { if (NS_SUCCEEDED(result)) {
result = select->GetSize(&size); select->GetSize(&size);
if ((1 == size) || (kNoSizeSpecified == size)) { PRBool multipleSelect = PR_FALSE;
select->GetMultiple(&multipleSelect);
// Construct a combobox if size=1 or no size is specified and its multiple select
if (((1 == size) || (kNoSizeSpecified == size)) && (PR_FALSE == multipleSelect)) {
// Construct a frame-based combo box. // Construct a frame-based combo box.
// The frame-based combo box is built out of tree parts. A display area, a button and // The frame-based combo box is built out of tree parts. A display area, a button and
// a dropdown list. The display area and button are created through anonymous content. // a dropdown list. The display area and button are created through anonymous content.
@ -2521,6 +2524,7 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresContext* aPresContex
} }
nsresult nsresult
nsCSSFrameConstructor::ConstructFrameByTag(nsIPresContext* aPresContext, nsCSSFrameConstructor::ConstructFrameByTag(nsIPresContext* aPresContext,
nsFrameConstructorState& aState, nsFrameConstructorState& aState,

Просмотреть файл

@ -69,7 +69,8 @@ nsPresContext::nsPresContext()
nsLayoutAtoms::AddRefAtoms(); nsLayoutAtoms::AddRefAtoms();
mCompatibilityMode = eCompatibility_Standard; mCompatibilityMode = eCompatibility_Standard;
mCompatibilityLocked = PR_FALSE; mCompatibilityLocked = PR_FALSE;
mWidgetRenderingMode = eWidgetRendering_Native; // to be changed to _Gfx soon! mWidgetRenderingMode = eWidgetRendering_Native; // Soon to be set to PartialGfx
#ifdef _WIN32 #ifdef _WIN32
// XXX This needs to be elsewhere, e.g., part of nsIDeviceContext // XXX This needs to be elsewhere, e.g., part of nsIDeviceContext

Просмотреть файл

@ -53,7 +53,8 @@ enum nsCompatibility {
enum nsWidgetRendering { enum nsWidgetRendering {
eWidgetRendering_Native = 1, eWidgetRendering_Native = 1,
eWidgetRendering_Gfx = 2 eWidgetRendering_Gfx = 2,
eWidgetRendering_PartialGfx = 3
}; };
// An interface for presentation contexts. Presentation contexts are // An interface for presentation contexts. Presentation contexts are

Просмотреть файл

@ -53,7 +53,8 @@ enum nsCompatibility {
enum nsWidgetRendering { enum nsWidgetRendering {
eWidgetRendering_Native = 1, eWidgetRendering_Native = 1,
eWidgetRendering_Gfx = 2 eWidgetRendering_Gfx = 2,
eWidgetRendering_PartialGfx = 3
}; };
// An interface for presentation contexts. Presentation contexts are // An interface for presentation contexts. Presentation contexts are

Просмотреть файл

@ -53,7 +53,8 @@ enum nsCompatibility {
enum nsWidgetRendering { enum nsWidgetRendering {
eWidgetRendering_Native = 1, eWidgetRendering_Native = 1,
eWidgetRendering_Gfx = 2 eWidgetRendering_Gfx = 2,
eWidgetRendering_PartialGfx = 3
}; };
// An interface for presentation contexts. Presentation contexts are // An interface for presentation contexts. Presentation contexts are

Просмотреть файл

@ -69,7 +69,8 @@ nsPresContext::nsPresContext()
nsLayoutAtoms::AddRefAtoms(); nsLayoutAtoms::AddRefAtoms();
mCompatibilityMode = eCompatibility_Standard; mCompatibilityMode = eCompatibility_Standard;
mCompatibilityLocked = PR_FALSE; mCompatibilityLocked = PR_FALSE;
mWidgetRenderingMode = eWidgetRendering_Native; // to be changed to _Gfx soon! mWidgetRenderingMode = eWidgetRendering_Native; // Soon to be set to PartialGfx
#ifdef _WIN32 #ifdef _WIN32
// XXX This needs to be elsewhere, e.g., part of nsIDeviceContext // XXX This needs to be elsewhere, e.g., part of nsIDeviceContext

Просмотреть файл

@ -176,10 +176,15 @@ nsComboboxControlFrame::InitTextStr(PRBool aUpdate)
// No selection so use the first item in the list box // No selection so use the first item in the list box
if ((NS_OK == result) && (nsnull != fcFrame)) { if ((NS_OK == result) && (nsnull != fcFrame)) {
// Set listbox selection to first item in the list box // Find out if there are any options in the list to select
fcFrame->SetProperty(nsHTMLAtoms::selectedindex, "0"); PRInt32 length = 0;
// Get the listbox selection as a string mListControlFrame->GetNumberOfOptions(&length);
mListControlFrame->GetSelectedItem(mTextStr); if (length > 0) {
// Set listbox selection to first item in the list box
fcFrame->SetProperty(nsHTMLAtoms::selectedindex, "0");
// Get the listbox selection as a string
mListControlFrame->GetSelectedItem(mTextStr);
}
} }
} }
@ -722,6 +727,7 @@ nsComboboxControlFrame::GetMaxNumValues()
return 1; return 1;
} }
/*XXX-REMOVE
PRBool PRBool
nsComboboxControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues, nsComboboxControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
nsString* aValues, nsString* aNames) nsString* aValues, nsString* aNames)
@ -739,6 +745,21 @@ nsComboboxControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValue
nsresult status = PR_TRUE; nsresult status = PR_TRUE;
return status; return status;
} }
*/
PRBool
nsComboboxControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
nsString* aValues, nsString* aNames)
{
nsIFormControlFrame* fcFrame = nsnull;
nsIFrame* dropdownFrame = GetDropdownFrame();
nsresult result = dropdownFrame->QueryInterface(kIFormControlFrameIID, (void**)&fcFrame);
if ((NS_SUCCEEDED(result)) && (nsnull != fcFrame)) {
return fcFrame->GetNamesValues(aMaxNumValues, aNumValues, aValues, aNames);
}
return PR_FALSE;
}
//-------------------------------------------------------------- //--------------------------------------------------------------
NS_IMETHODIMP NS_IMETHODIMP

Просмотреть файл

@ -249,7 +249,7 @@ nsFormControlFrame::Reflow(nsIPresContext& aPresContext,
nsWidgetRendering mode; nsWidgetRendering mode;
aPresContext.GetWidgetRenderingMode(&mode); aPresContext.GetWidgetRenderingMode(&mode);
if (eWidgetRendering_Gfx == mode) { if ((eWidgetRendering_Gfx == mode) || (eWidgetRendering_PartialGfx == mode)) {
// Check with the frame to see if requires a widget to render // Check with the frame to see if requires a widget to render
if (PR_TRUE == requiresWidget) { if (PR_TRUE == requiresWidget) {
RequiresWidget(requiresWidget); RequiresWidget(requiresWidget);

Просмотреть файл

@ -305,7 +305,7 @@ nsFormControlHelper::CalculateSize (nsIPresContext* aPresContext,
PRInt32 type; PRInt32 type;
aFrame->GetType(&type); aFrame->GetType(&type);
if (PR_TRUE == requiresWidget || eWidgetRendering_Gfx != mode || if (PR_TRUE == requiresWidget || eWidgetRendering_Native == mode ||
type==NS_FORM_INPUT_TEXT || type==NS_FORM_TEXTAREA || type==NS_FORM_INPUT_PASSWORD) type==NS_FORM_INPUT_TEXT || type==NS_FORM_TEXTAREA || type==NS_FORM_INPUT_PASSWORD)
{ {
if (!aWidthExplicit) { if (!aWidthExplicit) {

Просмотреть файл

@ -69,6 +69,12 @@ public:
NS_IMETHOD GetMaximumSize(nsSize &aSize) = 0; NS_IMETHOD GetMaximumSize(nsSize &aSize) = 0;
/**
* Returns the number of options in the listbox
*/
NS_IMETHOD GetNumberOfOptions(PRInt32* aNumOptions) = 0;
}; };

Просмотреть файл

@ -38,8 +38,10 @@
// Constants // Constants
const nscoord kMaxDropDownRows = 20; // This matches the setting for 4.x browsers const nscoord kMaxDropDownRows = 20; // This matches the setting for 4.x browsers
const PRInt32 kDefaultMultiselectHeight = 4; // This is compatible with 4.x browsers
const PRInt32 kNothingSelected = -1; const PRInt32 kNothingSelected = -1;
const PRInt32 kMaxZ= 0x7fffffff; //XXX: Shouldn't there be a define somewhere for MaxInt for PRInt32 const PRInt32 kMaxZ= 0x7fffffff; //XXX: Shouldn't there be a define somewhere for MaxInt for PRInt32
const PRInt32 kNoSizeSpecified = -1;
//XXX: This is temporary. It simulates psuedo states by using a attribute selector on //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 // -moz-option-selected in the ua.css style sheet. This will not be needed when
@ -75,8 +77,6 @@ nsListControlFrame::nsListControlFrame()
{ {
mHitFrame = nsnull; mHitFrame = nsnull;
mSelectedIndex = kNothingSelected; mSelectedIndex = kNothingSelected;
mNumRows = 0;
mNumSelections = 0;
mComboboxFrame = nsnull; mComboboxFrame = nsnull;
mFormFrame = nsnull; mFormFrame = nsnull;
mDisplayed = PR_FALSE; mDisplayed = PR_FALSE;
@ -268,7 +268,7 @@ nsListControlFrame::Reflow(nsIPresContext& aPresContext,
//longest element in the list //longest element in the list
nsHTMLReflowState secondPassState(aReflowState); nsHTMLReflowState secondPassState(aReflowState);
nsHTMLReflowState firstPassState(aReflowState); nsHTMLReflowState firstPassState(aReflowState);
// Get the size of option elements inside the listbox // Get the size of option elements inside the listbox
// Compute the width based on the longest line in the listbox. // Compute the width based on the longest line in the listbox.
@ -276,14 +276,12 @@ nsListControlFrame::Reflow(nsIPresContext& aPresContext,
firstPassState.mComputedHeight = NS_UNCONSTRAINEDSIZE; firstPassState.mComputedHeight = NS_UNCONSTRAINEDSIZE;
firstPassState.availableWidth = NS_UNCONSTRAINEDSIZE; firstPassState.availableWidth = NS_UNCONSTRAINEDSIZE;
firstPassState.availableHeight = NS_UNCONSTRAINEDSIZE; firstPassState.availableHeight = NS_UNCONSTRAINEDSIZE;
nsSize scrolledAreaSize(0,0); nsSize scrolledAreaSize(0,0);
nsHTMLReflowMetrics scrolledAreaDesiredSize(&scrolledAreaSize); nsHTMLReflowMetrics scrolledAreaDesiredSize(&scrolledAreaSize);
if (eReflowReason_Incremental == firstPassState.reason) { if (eReflowReason_Incremental == firstPassState.reason) {
// When incremental, Reflow everything
nsIFrame* targetFrame; nsIFrame* targetFrame;
firstPassState.reflowCommand->GetTarget(targetFrame); firstPassState.reflowCommand->GetTarget(targetFrame);
if (this == targetFrame) { if (this == targetFrame) {
@ -370,20 +368,28 @@ nsListControlFrame::Reflow(nsIPresContext& aPresContext,
nscoord visibleHeight = 0; nscoord visibleHeight = 0;
if (IsInDropDownMode() == PR_TRUE) { if (IsInDropDownMode() == PR_TRUE) {
// Compute the visible height of the drop-down list // Compute the visible height of the drop-down list
// The dropdown list height is the smaller of it's height setting or the height // 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. // of the smallest box that can drawn around it's contents.
visibleHeight = scrolledAreaHeight; visibleHeight = scrolledAreaHeight;
if (visibleHeight > (kMaxDropDownRows * heightOfARow)) if (visibleHeight > (kMaxDropDownRows * heightOfARow)) {
visibleHeight = (kMaxDropDownRows * heightOfARow); visibleHeight = (kMaxDropDownRows * heightOfARow);
}
} else { } else {
// Calculate the visible height of the listbox // Calculate the visible height of the listbox
if (NS_UNCONSTRAINEDSIZE != aReflowState.mComputedHeight) { if (NS_UNCONSTRAINEDSIZE != aReflowState.mComputedHeight) {
visibleHeight = aReflowState.mComputedHeight; visibleHeight = aReflowState.mComputedHeight;
} else { } else {
visibleHeight = mNumRows * heightOfARow; PRInt32 numRows = 1;
GetSizeAttribute(&numRows);
if (numRows == kNoSizeSpecified) {
visibleHeight = aReflowState.mComputedHeight;
}
else {
visibleHeight = numRows * heightOfARow;
}
} }
} }
@ -548,8 +554,8 @@ nsListControlFrame::GetSelectedIndex(nsIFrame *aHitFrame)
// Search the list of option elements looking for a match // Search the list of option elements looking for a match
PRUint32 length; PRInt32 length = 0;
length = GetNumberOfOptions(); GetNumberOfOptions(&length);
nsIDOMHTMLCollection* options = GetOptions(mContent); nsIDOMHTMLCollection* options = GetOptions(mContent);
if (nsnull != options) { if (nsnull != options) {
PRUint32 numOptions; PRUint32 numOptions;
@ -575,8 +581,9 @@ nsListControlFrame::GetSelectedIndex(nsIFrame *aHitFrame)
void void
nsListControlFrame::ClearSelection() nsListControlFrame::ClearSelection()
{ {
PRUint32 length = GetNumberOfOptions(); PRInt32 length = 0;
for (PRInt32 i = 0; i < (PRInt32)length; i++) { GetNumberOfOptions(&length);
for (PRInt32 i = 0; i < length; i++) {
if (i != mSelectedIndex) { if (i != mSelectedIndex) {
SetFrameSelected(i, PR_FALSE); SetFrameSelected(i, PR_FALSE);
} }
@ -600,7 +607,8 @@ nsListControlFrame::ExtendedSelection(PRInt32 aStartIndex, PRInt32 aEndIndex, PR
PRInt32 i = 0; PRInt32 i = 0;
PRBool startInverting = PR_FALSE; PRBool startInverting = PR_FALSE;
PRInt32 length = GetNumberOfOptions(); PRInt32 length = 0;
GetNumberOfOptions(&length);
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
if (i == startInx) { if (i == startInx) {
startInverting = PR_TRUE; startInverting = PR_TRUE;
@ -703,7 +711,9 @@ nsListControlFrame::HandleListSelection(nsIPresContext& aPresContext,
nsGUIEvent* aEvent, nsGUIEvent* aEvent,
nsEventStatus& aEventStatus) nsEventStatus& aEventStatus)
{ {
if (mMultipleSelections) { PRBool multipleSelections = PR_FALSE;
GetMultiple(&multipleSelections);
if (multipleSelections) {
MultipleSelection(((nsMouseEvent *)aEvent)->isShift, ((nsMouseEvent *)aEvent)->isControl); MultipleSelection(((nsMouseEvent *)aEvent)->isShift, ((nsMouseEvent *)aEvent)->isControl);
} else { } else {
SingleSelection(); SingleSelection();
@ -738,19 +748,23 @@ nsListControlFrame::HandleLikeListEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent, nsGUIEvent* aEvent,
nsEventStatus& aEventStatus) nsEventStatus& aEventStatus)
{ {
if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) { if (nsnull != mHitFrame) {
HandleListSelection(aPresContext, aEvent, aEventStatus);
mButtonDown = PR_TRUE; if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) {
CaptureMouseEvents(PR_TRUE);
mLastFrame = mHitFrame;
} else if (aEvent->message == NS_MOUSE_MOVE) {
if ((PR_TRUE == mButtonDown) && (! HasSameContent(mLastFrame, mHitFrame))) {
HandleListSelection(aPresContext, aEvent, aEventStatus); HandleListSelection(aPresContext, aEvent, aEventStatus);
mButtonDown = PR_TRUE;
CaptureMouseEvents(PR_TRUE);
mLastFrame = mHitFrame; mLastFrame = mHitFrame;
} else if (aEvent->message == NS_MOUSE_MOVE) {
if ((PR_TRUE == mButtonDown) && (! HasSameContent(mLastFrame, mHitFrame))) {
HandleListSelection(aPresContext, aEvent, aEventStatus);
mLastFrame = mHitFrame;
}
} else if (aEvent->message == NS_MOUSE_LEFT_BUTTON_UP) {
mButtonDown = PR_FALSE;
CaptureMouseEvents(PR_FALSE);
} }
} else if (aEvent->message == NS_MOUSE_LEFT_BUTTON_UP) {
mButtonDown = PR_FALSE;
CaptureMouseEvents(PR_FALSE);
} }
aEventStatus = nsEventStatus_eConsumeNoDefault; aEventStatus = nsEventStatus_eConsumeNoDefault;
@ -951,6 +965,18 @@ nsListControlFrame::SetInitialChildList(nsIPresContext& aPresContext,
return nsScrollFrame::SetInitialChildList(aPresContext, aListName, aChildList); return nsScrollFrame::SetInitialChildList(aPresContext, aListName, aChildList);
} }
nsresult
nsListControlFrame::GetSizeAttribute(PRInt32 *aSize) {
nsresult rv = NS_OK;
nsIDOMHTMLSelectElement* select;
rv = mContent->QueryInterface(kIDOMHTMLSelectElementIID, (void**) &select);
if (mContent && (NS_SUCCEEDED(rv))) {
rv = select->GetSize(aSize);
NS_RELEASE(select);
}
return rv;
}
NS_IMETHODIMP NS_IMETHODIMP
nsListControlFrame::Init(nsIPresContext& aPresContext, nsListControlFrame::Init(nsIPresContext& aPresContext,
@ -961,14 +987,6 @@ nsListControlFrame::Init(nsIPresContext& aPresContext,
{ {
nsresult result = nsScrollFrame::Init(aPresContext, aContent, aParent, aContext, nsresult result = nsScrollFrame::Init(aPresContext, aContent, aParent, aContext,
aPrevInFlow); aPrevInFlow);
if (NS_OK == result) {
nsIDOMHTMLSelectElement* select;
if (mContent && (NS_OK == mContent->QueryInterface(kIDOMHTMLSelectElementIID, (void**) &select))) {
select->GetMultiple(&mMultipleSelections);
select->GetSize(&mNumRows);
NS_RELEASE(select);
}
}
// Initialize the current selected and not selected state's for // Initialize the current selected and not selected state's for
// the listbox items from the content. This is done here because // the listbox items from the content. This is done here because
@ -1108,11 +1126,12 @@ nsListControlFrame::SetFrameSelected(PRUint32 aIndex, PRBool aSelected)
void void
nsListControlFrame::InitializeFromContent() nsListControlFrame::InitializeFromContent()
{ {
PRUint32 length = GetNumberOfOptions(); PRInt32 length = 0;
GetNumberOfOptions(&length);
nsIDOMHTMLCollection* options = GetOptions(mContent); nsIDOMHTMLCollection* options = GetOptions(mContent);
nsresult result = NS_OK; nsresult result = NS_OK;
if (nsnull != options) { if (nsnull != options) {
for (PRUint32 i = 0; i < length; i++) { for (PRInt32 i = 0; i < length; i++) {
nsIDOMHTMLOptionElement* optionElement = nsnull; nsIDOMHTMLOptionElement* optionElement = nsnull;
optionElement = GetOption(*options, i); optionElement = GetOption(*options, i);
if (nsnull != optionElement) { if (nsnull != optionElement) {
@ -1190,11 +1209,11 @@ nsresult
nsListControlFrame::Deselect() nsListControlFrame::Deselect()
{ {
PRInt32 i; PRInt32 i;
PRInt32 max = GetNumberOfOptions(); PRInt32 max = 0;
GetNumberOfOptions(&max);
for (i=0;i<max;i++) { for (i=0;i<max;i++) {
SetFrameSelected(i, PR_FALSE); SetFrameSelected(i, PR_FALSE);
} }
mNumSelections = 0;
mSelectedIndex = kNothingSelected; mSelectedIndex = kNothingSelected;
return NS_OK; return NS_OK;
@ -1234,6 +1253,7 @@ nsListControlFrame::MouseClicked(nsIPresContext* aPresContext)
{ {
} }
PRInt32 PRInt32
nsListControlFrame::GetMaxNumValues() nsListControlFrame::GetMaxNumValues()
{ {
@ -1300,12 +1320,26 @@ nsListControlFrame::GetName(nsString* aResult)
} }
PRInt32
nsListControlFrame::GetNumberOfSelections()
{
PRInt32 count = 0;
PRInt32 length = 0;
GetNumberOfOptions(&length);
PRInt32 i = 0;
for (i = 0; i < length; i++) {
if (IsFrameSelected(i)) {
count++;
}
}
return(count);
}
PRBool PRBool
nsListControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues, nsListControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
nsString* aValues, nsString* aNames) nsString* aValues, nsString* aNames)
{ {
PRBool status = PR_FALSE;
aNumValues = 0; aNumValues = 0;
nsAutoString name; nsAutoString name;
nsresult result = GetName(&name); nsresult result = GetName(&name);
@ -1318,28 +1352,34 @@ nsListControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
return PR_FALSE; return PR_FALSE;
} }
NS_ASSERTION(aMaxNumValues >= mNumSelections, "invalid max num values"); PRBool status = PR_FALSE;
if (mNumSelections >= 0) { PRBool multiple;
PRInt32* selections = new PRInt32[mNumSelections]; GetMultiple(&multiple);
PRInt32 i = 0; if (!multiple) {
PRInt32 inx; if (mSelectedIndex >= 0) {
for (inx=0;i<mNumSelections;i++) { nsAutoString value;
if (IsFrameSelected(inx)) { GetOptionValue(*options, mSelectedIndex, value);
selections[i++] = inx; aNumValues = 1;
aNames[0] = name;
aValues[0] = value;
status = PR_TRUE;
}
}
else {
aNumValues = 0;
PRInt32 length = 0;
GetNumberOfOptions(&length);
for (int i = 0; i < length; i++) {
if (PR_TRUE == IsFrameSelected(i)) {
nsAutoString value;
GetOptionValue(*options, i, value);
aNames[aNumValues] = name;
aValues[aNumValues] = value;
aNumValues++;
} }
} }
aNumValues = 0;
for (i = 0; i < mNumSelections; i++) {
nsAutoString value;
GetOptionValue(*options, selections[i], value);
aNames[i] = name;
aValues[i] = value;
aNumValues++;
}
delete[] selections;
status = PR_TRUE; status = PR_TRUE;
} }
NS_RELEASE(options); NS_RELEASE(options);
return status; return status;
@ -1398,16 +1438,20 @@ nsresult nsListControlFrame::RequiresWidget(PRBool& aRequiresWidget)
return NS_OK; return NS_OK;
} }
PRInt32 nsListControlFrame::GetNumberOfOptions() NS_IMETHODIMP
nsListControlFrame::GetNumberOfOptions(PRInt32* aNumOptions)
{ {
nsIDOMHTMLCollection* options = GetOptions(mContent); nsIDOMHTMLCollection* options = GetOptions(mContent);
if (!options) { if (nsnull == options) {
return 0; *aNumOptions = 0;
} else {
PRUint32 length = 0;
options->GetLength(&length);
*aNumOptions = (PRInt32)length;
NS_RELEASE(options);
} }
PRUint32 numOptions;
options->GetLength(&numOptions); return NS_OK;
NS_RELEASE(options);
return(numOptions);
} }
// Select the specified item in the listbox using control logic. // Select the specified item in the listbox using control logic.

Просмотреть файл

@ -103,6 +103,7 @@ public:
NS_IMETHOD CaptureMouseEvents(PRBool aGrabMouseEvents); NS_IMETHOD CaptureMouseEvents(PRBool aGrabMouseEvents);
NS_IMETHOD GetMaximumSize(nsSize &aSize); NS_IMETHOD GetMaximumSize(nsSize &aSize);
NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight); NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight);
NS_IMETHOD GetNumberOfOptions(PRInt32* aNumOptions);
// Static Methods // Static Methods
static nsIDOMHTMLSelectElement* GetSelect(nsIContent * aContent); static nsIDOMHTMLSelectElement* GetSelect(nsIContent * aContent);
@ -124,6 +125,8 @@ protected:
PRInt32 GetNumberOfOptions(); PRInt32 GetNumberOfOptions();
// Utility methods // Utility methods
nsresult GetSizeAttribute(PRInt32 *aSize);
PRInt32 GetNumberOfSelections();
nsIContent* GetOptionContent(PRUint32 aIndex); nsIContent* GetOptionContent(PRUint32 aIndex);
PRBool IsContentSelected(nsIContent* aContent); PRBool IsContentSelected(nsIContent* aContent);
PRBool IsFrameSelected(PRUint32 aIndex); PRBool IsFrameSelected(PRUint32 aIndex);
@ -168,9 +171,6 @@ protected:
// Data Members // Data Members
nscoord mBorderOffsetY; nscoord mBorderOffsetY;
nsFormFrame* mFormFrame; nsFormFrame* mFormFrame;
PRInt32 mNumRows;
PRInt32 mNumSelections;
PRBool mMultipleSelections;
PRInt32 mSelectedIndex; PRInt32 mSelectedIndex;
PRInt32 mStartExtendedIndex; PRInt32 mStartExtendedIndex;
PRInt32 mEndExtendedIndex; PRInt32 mEndExtendedIndex;

Просмотреть файл

@ -112,9 +112,6 @@ HTML_ATOM(enctype, "enctype")
HTML_ATOM(face, "face") HTML_ATOM(face, "face")
HTML_ATOM(fieldset, "fieldset") HTML_ATOM(fieldset, "fieldset")
HTML_ATOM(fieldsetContentPseudo, ":fieldset-content") HTML_ATOM(fieldsetContentPseudo, ":fieldset-content")
HTML_ATOM(fileButtonStylePseudo, ":-moz-file-button")
HTML_ATOM(fileTextStylePseudo, ":-moz-file-text")
HTML_ATOM(firstLetterPseudo, ":first-letter") HTML_ATOM(firstLetterPseudo, ":first-letter")
HTML_ATOM(firstLinePseudo, ":first-line") HTML_ATOM(firstLinePseudo, ":first-line")
HTML_ATOM(font, "font") HTML_ATOM(font, "font")

Просмотреть файл

@ -710,19 +710,6 @@ button:focus:-moz-focus-inner {
border : 1px dotted black; border : 1px dotted black;
} }
:-moz-file-button {
border: 2px outset rgb(204, 204, 204);
color:black;
background-color: rgb(204, 204, 204);
}
:-moz-file-text {
border: 2px inset rgb(204, 204, 204);
margin-right: 10px;
background-color: white;
color: black;
}
input[type=text] { input[type=text] {
border: 2px inset rgb(204, 204, 204); border: 2px inset rgb(204, 204, 204);
background-color: white; background-color: white;
@ -763,6 +750,16 @@ select[size] {
border: 1px inset rgb(153, 153, 153); border: 1px inset rgb(153, 153, 153);
} }
select[multiple] {
background-color: white;
border: 1px inset rgb(153, 153, 153);
}
select[multiple][size="1"] {
background-color: white;
border: 1px inset rgb(153, 153, 153);
}
select[size="1"] { select[size="1"] {
vertical-align: bottom; vertical-align: bottom;
border: none; border: none;
@ -833,6 +830,17 @@ select[size="1"] option[-moz-option-selected] {
background-color:white; background-color:white;
} }
select[multiple] option[-moz-option-selected] {
color:white;
background-color:rgb(51,51,102);
}
select[multiple][size="1"] option[-moz-option-selected] {
color:white;
background-color:rgb(51,51,102);
}
option.selectedfocus { option.selectedfocus {
border: 1px dotted white; border: 1px dotted white;
background-color: rgb(0,0,128); background-color: rgb(0,0,128);

Просмотреть файл

@ -69,6 +69,12 @@ public:
NS_IMETHOD GetMaximumSize(nsSize &aSize) = 0; NS_IMETHOD GetMaximumSize(nsSize &aSize) = 0;
/**
* Returns the number of options in the listbox
*/
NS_IMETHOD GetNumberOfOptions(PRInt32* aNumOptions) = 0;
}; };

Просмотреть файл

@ -381,7 +381,7 @@ nsButtonControlFrame::Reflow(nsIPresContext& aPresContext,
nsWidgetRendering mode; nsWidgetRendering mode;
aPresContext.GetWidgetRenderingMode(&mode); aPresContext.GetWidgetRenderingMode(&mode);
if (eWidgetRendering_Gfx == mode || NS_FORM_INPUT_IMAGE == type) { if (eWidgetRendering_Gfx == mode || eWidgetRendering_PartialGfx == mode || NS_FORM_INPUT_IMAGE == type) {
// add ourself as an nsIFormControlFrame // add ourself as an nsIFormControlFrame
if (!mFormFrame && (eReflowReason_Initial == aReflowState.reason)) { if (!mFormFrame && (eReflowReason_Initial == aReflowState.reason)) {
nsFormFrame::AddFormControlFrame(aPresContext, *this); nsFormFrame::AddFormControlFrame(aPresContext, *this);

Просмотреть файл

@ -275,29 +275,35 @@ nsCheckboxControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValue
} }
PRBool result = PR_TRUE; PRBool result = PR_TRUE;
PRBool state = PR_FALSE;
nsAutoString value; nsAutoString value;
nsresult valueResult = GetValue(&value); nsresult valueResult = GetValue(&value);
nsICheckButton* checkBox = nsnull; nsICheckButton* checkBox = nsnull;
if ((nsnull != mWidget) && if (nsnull != mWidget) {
(NS_OK == mWidget->QueryInterface(kICheckButtonIID,(void**)&checkBox))) { // native-widget
PRBool state = PR_FALSE; if (NS_SUCCEEDED(mWidget->QueryInterface(kICheckButtonIID,(void**)&checkBox))) {
checkBox->GetState(state); checkBox->GetState(state);
if (PR_TRUE != state) { NS_RELEASE(checkBox);
result = PR_FALSE;
} else {
if (NS_CONTENT_ATTR_HAS_VALUE != valueResult) {
aValues[0] = "on";
} else {
aValues[0] = value;
} }
aNames[0] = name; } else {
aNumValues = 1; // gfx-rendered
} state = mChecked;
NS_RELEASE(checkBox);
} }
if (PR_TRUE != state) {
result = PR_FALSE;
} else {
if (NS_CONTENT_ATTR_HAS_VALUE != valueResult) {
aValues[0] = "on";
} else {
aValues[0] = value;
}
aNames[0] = name;
aNumValues = 1;
}
return result; return result;
} }

Просмотреть файл

@ -176,10 +176,15 @@ nsComboboxControlFrame::InitTextStr(PRBool aUpdate)
// No selection so use the first item in the list box // No selection so use the first item in the list box
if ((NS_OK == result) && (nsnull != fcFrame)) { if ((NS_OK == result) && (nsnull != fcFrame)) {
// Set listbox selection to first item in the list box // Find out if there are any options in the list to select
fcFrame->SetProperty(nsHTMLAtoms::selectedindex, "0"); PRInt32 length = 0;
// Get the listbox selection as a string mListControlFrame->GetNumberOfOptions(&length);
mListControlFrame->GetSelectedItem(mTextStr); if (length > 0) {
// Set listbox selection to first item in the list box
fcFrame->SetProperty(nsHTMLAtoms::selectedindex, "0");
// Get the listbox selection as a string
mListControlFrame->GetSelectedItem(mTextStr);
}
} }
} }
@ -722,6 +727,7 @@ nsComboboxControlFrame::GetMaxNumValues()
return 1; return 1;
} }
/*XXX-REMOVE
PRBool PRBool
nsComboboxControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues, nsComboboxControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
nsString* aValues, nsString* aNames) nsString* aValues, nsString* aNames)
@ -739,6 +745,21 @@ nsComboboxControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValue
nsresult status = PR_TRUE; nsresult status = PR_TRUE;
return status; return status;
} }
*/
PRBool
nsComboboxControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
nsString* aValues, nsString* aNames)
{
nsIFormControlFrame* fcFrame = nsnull;
nsIFrame* dropdownFrame = GetDropdownFrame();
nsresult result = dropdownFrame->QueryInterface(kIFormControlFrameIID, (void**)&fcFrame);
if ((NS_SUCCEEDED(result)) && (nsnull != fcFrame)) {
return fcFrame->GetNamesValues(aMaxNumValues, aNumValues, aValues, aNames);
}
return PR_FALSE;
}
//-------------------------------------------------------------- //--------------------------------------------------------------
NS_IMETHODIMP NS_IMETHODIMP

Просмотреть файл

@ -249,7 +249,7 @@ nsFormControlFrame::Reflow(nsIPresContext& aPresContext,
nsWidgetRendering mode; nsWidgetRendering mode;
aPresContext.GetWidgetRenderingMode(&mode); aPresContext.GetWidgetRenderingMode(&mode);
if (eWidgetRendering_Gfx == mode) { if ((eWidgetRendering_Gfx == mode) || (eWidgetRendering_PartialGfx == mode)) {
// Check with the frame to see if requires a widget to render // Check with the frame to see if requires a widget to render
if (PR_TRUE == requiresWidget) { if (PR_TRUE == requiresWidget) {
RequiresWidget(requiresWidget); RequiresWidget(requiresWidget);

Просмотреть файл

@ -305,7 +305,7 @@ nsFormControlHelper::CalculateSize (nsIPresContext* aPresContext,
PRInt32 type; PRInt32 type;
aFrame->GetType(&type); aFrame->GetType(&type);
if (PR_TRUE == requiresWidget || eWidgetRendering_Gfx != mode || if (PR_TRUE == requiresWidget || eWidgetRendering_Native == mode ||
type==NS_FORM_INPUT_TEXT || type==NS_FORM_TEXTAREA || type==NS_FORM_INPUT_PASSWORD) type==NS_FORM_INPUT_TEXT || type==NS_FORM_TEXTAREA || type==NS_FORM_INPUT_PASSWORD)
{ {
if (!aWidthExplicit) { if (!aWidthExplicit) {

Просмотреть файл

@ -38,8 +38,10 @@
// Constants // Constants
const nscoord kMaxDropDownRows = 20; // This matches the setting for 4.x browsers const nscoord kMaxDropDownRows = 20; // This matches the setting for 4.x browsers
const PRInt32 kDefaultMultiselectHeight = 4; // This is compatible with 4.x browsers
const PRInt32 kNothingSelected = -1; const PRInt32 kNothingSelected = -1;
const PRInt32 kMaxZ= 0x7fffffff; //XXX: Shouldn't there be a define somewhere for MaxInt for PRInt32 const PRInt32 kMaxZ= 0x7fffffff; //XXX: Shouldn't there be a define somewhere for MaxInt for PRInt32
const PRInt32 kNoSizeSpecified = -1;
//XXX: This is temporary. It simulates psuedo states by using a attribute selector on //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 // -moz-option-selected in the ua.css style sheet. This will not be needed when
@ -75,8 +77,6 @@ nsListControlFrame::nsListControlFrame()
{ {
mHitFrame = nsnull; mHitFrame = nsnull;
mSelectedIndex = kNothingSelected; mSelectedIndex = kNothingSelected;
mNumRows = 0;
mNumSelections = 0;
mComboboxFrame = nsnull; mComboboxFrame = nsnull;
mFormFrame = nsnull; mFormFrame = nsnull;
mDisplayed = PR_FALSE; mDisplayed = PR_FALSE;
@ -268,7 +268,7 @@ nsListControlFrame::Reflow(nsIPresContext& aPresContext,
//longest element in the list //longest element in the list
nsHTMLReflowState secondPassState(aReflowState); nsHTMLReflowState secondPassState(aReflowState);
nsHTMLReflowState firstPassState(aReflowState); nsHTMLReflowState firstPassState(aReflowState);
// Get the size of option elements inside the listbox // Get the size of option elements inside the listbox
// Compute the width based on the longest line in the listbox. // Compute the width based on the longest line in the listbox.
@ -276,14 +276,12 @@ nsListControlFrame::Reflow(nsIPresContext& aPresContext,
firstPassState.mComputedHeight = NS_UNCONSTRAINEDSIZE; firstPassState.mComputedHeight = NS_UNCONSTRAINEDSIZE;
firstPassState.availableWidth = NS_UNCONSTRAINEDSIZE; firstPassState.availableWidth = NS_UNCONSTRAINEDSIZE;
firstPassState.availableHeight = NS_UNCONSTRAINEDSIZE; firstPassState.availableHeight = NS_UNCONSTRAINEDSIZE;
nsSize scrolledAreaSize(0,0); nsSize scrolledAreaSize(0,0);
nsHTMLReflowMetrics scrolledAreaDesiredSize(&scrolledAreaSize); nsHTMLReflowMetrics scrolledAreaDesiredSize(&scrolledAreaSize);
if (eReflowReason_Incremental == firstPassState.reason) { if (eReflowReason_Incremental == firstPassState.reason) {
// When incremental, Reflow everything
nsIFrame* targetFrame; nsIFrame* targetFrame;
firstPassState.reflowCommand->GetTarget(targetFrame); firstPassState.reflowCommand->GetTarget(targetFrame);
if (this == targetFrame) { if (this == targetFrame) {
@ -370,20 +368,28 @@ nsListControlFrame::Reflow(nsIPresContext& aPresContext,
nscoord visibleHeight = 0; nscoord visibleHeight = 0;
if (IsInDropDownMode() == PR_TRUE) { if (IsInDropDownMode() == PR_TRUE) {
// Compute the visible height of the drop-down list // Compute the visible height of the drop-down list
// The dropdown list height is the smaller of it's height setting or the height // 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. // of the smallest box that can drawn around it's contents.
visibleHeight = scrolledAreaHeight; visibleHeight = scrolledAreaHeight;
if (visibleHeight > (kMaxDropDownRows * heightOfARow)) if (visibleHeight > (kMaxDropDownRows * heightOfARow)) {
visibleHeight = (kMaxDropDownRows * heightOfARow); visibleHeight = (kMaxDropDownRows * heightOfARow);
}
} else { } else {
// Calculate the visible height of the listbox // Calculate the visible height of the listbox
if (NS_UNCONSTRAINEDSIZE != aReflowState.mComputedHeight) { if (NS_UNCONSTRAINEDSIZE != aReflowState.mComputedHeight) {
visibleHeight = aReflowState.mComputedHeight; visibleHeight = aReflowState.mComputedHeight;
} else { } else {
visibleHeight = mNumRows * heightOfARow; PRInt32 numRows = 1;
GetSizeAttribute(&numRows);
if (numRows == kNoSizeSpecified) {
visibleHeight = aReflowState.mComputedHeight;
}
else {
visibleHeight = numRows * heightOfARow;
}
} }
} }
@ -548,8 +554,8 @@ nsListControlFrame::GetSelectedIndex(nsIFrame *aHitFrame)
// Search the list of option elements looking for a match // Search the list of option elements looking for a match
PRUint32 length; PRInt32 length = 0;
length = GetNumberOfOptions(); GetNumberOfOptions(&length);
nsIDOMHTMLCollection* options = GetOptions(mContent); nsIDOMHTMLCollection* options = GetOptions(mContent);
if (nsnull != options) { if (nsnull != options) {
PRUint32 numOptions; PRUint32 numOptions;
@ -575,8 +581,9 @@ nsListControlFrame::GetSelectedIndex(nsIFrame *aHitFrame)
void void
nsListControlFrame::ClearSelection() nsListControlFrame::ClearSelection()
{ {
PRUint32 length = GetNumberOfOptions(); PRInt32 length = 0;
for (PRInt32 i = 0; i < (PRInt32)length; i++) { GetNumberOfOptions(&length);
for (PRInt32 i = 0; i < length; i++) {
if (i != mSelectedIndex) { if (i != mSelectedIndex) {
SetFrameSelected(i, PR_FALSE); SetFrameSelected(i, PR_FALSE);
} }
@ -600,7 +607,8 @@ nsListControlFrame::ExtendedSelection(PRInt32 aStartIndex, PRInt32 aEndIndex, PR
PRInt32 i = 0; PRInt32 i = 0;
PRBool startInverting = PR_FALSE; PRBool startInverting = PR_FALSE;
PRInt32 length = GetNumberOfOptions(); PRInt32 length = 0;
GetNumberOfOptions(&length);
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
if (i == startInx) { if (i == startInx) {
startInverting = PR_TRUE; startInverting = PR_TRUE;
@ -703,7 +711,9 @@ nsListControlFrame::HandleListSelection(nsIPresContext& aPresContext,
nsGUIEvent* aEvent, nsGUIEvent* aEvent,
nsEventStatus& aEventStatus) nsEventStatus& aEventStatus)
{ {
if (mMultipleSelections) { PRBool multipleSelections = PR_FALSE;
GetMultiple(&multipleSelections);
if (multipleSelections) {
MultipleSelection(((nsMouseEvent *)aEvent)->isShift, ((nsMouseEvent *)aEvent)->isControl); MultipleSelection(((nsMouseEvent *)aEvent)->isShift, ((nsMouseEvent *)aEvent)->isControl);
} else { } else {
SingleSelection(); SingleSelection();
@ -738,19 +748,23 @@ nsListControlFrame::HandleLikeListEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent, nsGUIEvent* aEvent,
nsEventStatus& aEventStatus) nsEventStatus& aEventStatus)
{ {
if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) { if (nsnull != mHitFrame) {
HandleListSelection(aPresContext, aEvent, aEventStatus);
mButtonDown = PR_TRUE; if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) {
CaptureMouseEvents(PR_TRUE);
mLastFrame = mHitFrame;
} else if (aEvent->message == NS_MOUSE_MOVE) {
if ((PR_TRUE == mButtonDown) && (! HasSameContent(mLastFrame, mHitFrame))) {
HandleListSelection(aPresContext, aEvent, aEventStatus); HandleListSelection(aPresContext, aEvent, aEventStatus);
mButtonDown = PR_TRUE;
CaptureMouseEvents(PR_TRUE);
mLastFrame = mHitFrame; mLastFrame = mHitFrame;
} else if (aEvent->message == NS_MOUSE_MOVE) {
if ((PR_TRUE == mButtonDown) && (! HasSameContent(mLastFrame, mHitFrame))) {
HandleListSelection(aPresContext, aEvent, aEventStatus);
mLastFrame = mHitFrame;
}
} else if (aEvent->message == NS_MOUSE_LEFT_BUTTON_UP) {
mButtonDown = PR_FALSE;
CaptureMouseEvents(PR_FALSE);
} }
} else if (aEvent->message == NS_MOUSE_LEFT_BUTTON_UP) {
mButtonDown = PR_FALSE;
CaptureMouseEvents(PR_FALSE);
} }
aEventStatus = nsEventStatus_eConsumeNoDefault; aEventStatus = nsEventStatus_eConsumeNoDefault;
@ -951,6 +965,18 @@ nsListControlFrame::SetInitialChildList(nsIPresContext& aPresContext,
return nsScrollFrame::SetInitialChildList(aPresContext, aListName, aChildList); return nsScrollFrame::SetInitialChildList(aPresContext, aListName, aChildList);
} }
nsresult
nsListControlFrame::GetSizeAttribute(PRInt32 *aSize) {
nsresult rv = NS_OK;
nsIDOMHTMLSelectElement* select;
rv = mContent->QueryInterface(kIDOMHTMLSelectElementIID, (void**) &select);
if (mContent && (NS_SUCCEEDED(rv))) {
rv = select->GetSize(aSize);
NS_RELEASE(select);
}
return rv;
}
NS_IMETHODIMP NS_IMETHODIMP
nsListControlFrame::Init(nsIPresContext& aPresContext, nsListControlFrame::Init(nsIPresContext& aPresContext,
@ -961,14 +987,6 @@ nsListControlFrame::Init(nsIPresContext& aPresContext,
{ {
nsresult result = nsScrollFrame::Init(aPresContext, aContent, aParent, aContext, nsresult result = nsScrollFrame::Init(aPresContext, aContent, aParent, aContext,
aPrevInFlow); aPrevInFlow);
if (NS_OK == result) {
nsIDOMHTMLSelectElement* select;
if (mContent && (NS_OK == mContent->QueryInterface(kIDOMHTMLSelectElementIID, (void**) &select))) {
select->GetMultiple(&mMultipleSelections);
select->GetSize(&mNumRows);
NS_RELEASE(select);
}
}
// Initialize the current selected and not selected state's for // Initialize the current selected and not selected state's for
// the listbox items from the content. This is done here because // the listbox items from the content. This is done here because
@ -1108,11 +1126,12 @@ nsListControlFrame::SetFrameSelected(PRUint32 aIndex, PRBool aSelected)
void void
nsListControlFrame::InitializeFromContent() nsListControlFrame::InitializeFromContent()
{ {
PRUint32 length = GetNumberOfOptions(); PRInt32 length = 0;
GetNumberOfOptions(&length);
nsIDOMHTMLCollection* options = GetOptions(mContent); nsIDOMHTMLCollection* options = GetOptions(mContent);
nsresult result = NS_OK; nsresult result = NS_OK;
if (nsnull != options) { if (nsnull != options) {
for (PRUint32 i = 0; i < length; i++) { for (PRInt32 i = 0; i < length; i++) {
nsIDOMHTMLOptionElement* optionElement = nsnull; nsIDOMHTMLOptionElement* optionElement = nsnull;
optionElement = GetOption(*options, i); optionElement = GetOption(*options, i);
if (nsnull != optionElement) { if (nsnull != optionElement) {
@ -1190,11 +1209,11 @@ nsresult
nsListControlFrame::Deselect() nsListControlFrame::Deselect()
{ {
PRInt32 i; PRInt32 i;
PRInt32 max = GetNumberOfOptions(); PRInt32 max = 0;
GetNumberOfOptions(&max);
for (i=0;i<max;i++) { for (i=0;i<max;i++) {
SetFrameSelected(i, PR_FALSE); SetFrameSelected(i, PR_FALSE);
} }
mNumSelections = 0;
mSelectedIndex = kNothingSelected; mSelectedIndex = kNothingSelected;
return NS_OK; return NS_OK;
@ -1234,6 +1253,7 @@ nsListControlFrame::MouseClicked(nsIPresContext* aPresContext)
{ {
} }
PRInt32 PRInt32
nsListControlFrame::GetMaxNumValues() nsListControlFrame::GetMaxNumValues()
{ {
@ -1300,12 +1320,26 @@ nsListControlFrame::GetName(nsString* aResult)
} }
PRInt32
nsListControlFrame::GetNumberOfSelections()
{
PRInt32 count = 0;
PRInt32 length = 0;
GetNumberOfOptions(&length);
PRInt32 i = 0;
for (i = 0; i < length; i++) {
if (IsFrameSelected(i)) {
count++;
}
}
return(count);
}
PRBool PRBool
nsListControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues, nsListControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
nsString* aValues, nsString* aNames) nsString* aValues, nsString* aNames)
{ {
PRBool status = PR_FALSE;
aNumValues = 0; aNumValues = 0;
nsAutoString name; nsAutoString name;
nsresult result = GetName(&name); nsresult result = GetName(&name);
@ -1318,28 +1352,34 @@ nsListControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
return PR_FALSE; return PR_FALSE;
} }
NS_ASSERTION(aMaxNumValues >= mNumSelections, "invalid max num values"); PRBool status = PR_FALSE;
if (mNumSelections >= 0) { PRBool multiple;
PRInt32* selections = new PRInt32[mNumSelections]; GetMultiple(&multiple);
PRInt32 i = 0; if (!multiple) {
PRInt32 inx; if (mSelectedIndex >= 0) {
for (inx=0;i<mNumSelections;i++) { nsAutoString value;
if (IsFrameSelected(inx)) { GetOptionValue(*options, mSelectedIndex, value);
selections[i++] = inx; aNumValues = 1;
aNames[0] = name;
aValues[0] = value;
status = PR_TRUE;
}
}
else {
aNumValues = 0;
PRInt32 length = 0;
GetNumberOfOptions(&length);
for (int i = 0; i < length; i++) {
if (PR_TRUE == IsFrameSelected(i)) {
nsAutoString value;
GetOptionValue(*options, i, value);
aNames[aNumValues] = name;
aValues[aNumValues] = value;
aNumValues++;
} }
} }
aNumValues = 0;
for (i = 0; i < mNumSelections; i++) {
nsAutoString value;
GetOptionValue(*options, selections[i], value);
aNames[i] = name;
aValues[i] = value;
aNumValues++;
}
delete[] selections;
status = PR_TRUE; status = PR_TRUE;
} }
NS_RELEASE(options); NS_RELEASE(options);
return status; return status;
@ -1398,16 +1438,20 @@ nsresult nsListControlFrame::RequiresWidget(PRBool& aRequiresWidget)
return NS_OK; return NS_OK;
} }
PRInt32 nsListControlFrame::GetNumberOfOptions() NS_IMETHODIMP
nsListControlFrame::GetNumberOfOptions(PRInt32* aNumOptions)
{ {
nsIDOMHTMLCollection* options = GetOptions(mContent); nsIDOMHTMLCollection* options = GetOptions(mContent);
if (!options) { if (nsnull == options) {
return 0; *aNumOptions = 0;
} else {
PRUint32 length = 0;
options->GetLength(&length);
*aNumOptions = (PRInt32)length;
NS_RELEASE(options);
} }
PRUint32 numOptions;
options->GetLength(&numOptions); return NS_OK;
NS_RELEASE(options);
return(numOptions);
} }
// Select the specified item in the listbox using control logic. // Select the specified item in the listbox using control logic.

Просмотреть файл

@ -103,6 +103,7 @@ public:
NS_IMETHOD CaptureMouseEvents(PRBool aGrabMouseEvents); NS_IMETHOD CaptureMouseEvents(PRBool aGrabMouseEvents);
NS_IMETHOD GetMaximumSize(nsSize &aSize); NS_IMETHOD GetMaximumSize(nsSize &aSize);
NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight); NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight);
NS_IMETHOD GetNumberOfOptions(PRInt32* aNumOptions);
// Static Methods // Static Methods
static nsIDOMHTMLSelectElement* GetSelect(nsIContent * aContent); static nsIDOMHTMLSelectElement* GetSelect(nsIContent * aContent);
@ -124,6 +125,8 @@ protected:
PRInt32 GetNumberOfOptions(); PRInt32 GetNumberOfOptions();
// Utility methods // Utility methods
nsresult GetSizeAttribute(PRInt32 *aSize);
PRInt32 GetNumberOfSelections();
nsIContent* GetOptionContent(PRUint32 aIndex); nsIContent* GetOptionContent(PRUint32 aIndex);
PRBool IsContentSelected(nsIContent* aContent); PRBool IsContentSelected(nsIContent* aContent);
PRBool IsFrameSelected(PRUint32 aIndex); PRBool IsFrameSelected(PRUint32 aIndex);
@ -168,9 +171,6 @@ protected:
// Data Members // Data Members
nscoord mBorderOffsetY; nscoord mBorderOffsetY;
nsFormFrame* mFormFrame; nsFormFrame* mFormFrame;
PRInt32 mNumRows;
PRInt32 mNumSelections;
PRBool mMultipleSelections;
PRInt32 mSelectedIndex; PRInt32 mSelectedIndex;
PRInt32 mStartExtendedIndex; PRInt32 mStartExtendedIndex;
PRInt32 mEndExtendedIndex; PRInt32 mEndExtendedIndex;

Просмотреть файл

@ -169,7 +169,7 @@ nsRadioControlFrame::GetDesiredSize(nsIPresContext* aPresContext,
nsWidgetRendering mode; nsWidgetRendering mode;
aPresContext->GetWidgetRenderingMode(&mode); aPresContext->GetWidgetRenderingMode(&mode);
if (eWidgetRendering_Gfx == mode) { if ((eWidgetRendering_Gfx == mode) || (eWidgetRendering_PartialGfx == mode)) {
nsFormControlFrame::GetDesiredSize(aPresContext,aReflowState,aDesiredLayoutSize, nsFormControlFrame::GetDesiredSize(aPresContext,aReflowState,aDesiredLayoutSize,
aDesiredWidgetSize); aDesiredWidgetSize);
} else { } else {
@ -306,11 +306,16 @@ nsRadioControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
PRBool state = PR_FALSE; PRBool state = PR_FALSE;
nsIRadioButton* radio = nsnull; if (nsnull == mWidget) {
if (mWidget && (NS_OK == mWidget->QueryInterface(kIRadioIID,(void**)&radio))) { state = mChecked;
radio->GetState(state); } else {
NS_RELEASE(radio); nsIRadioButton* radio = nsnull;
if (mWidget && (NS_OK == mWidget->QueryInterface(kIRadioIID,(void**)&radio))) {
radio->GetState(state);
NS_RELEASE(radio);
}
} }
if(PR_TRUE != state) { if(PR_TRUE != state) {
return PR_FALSE; return PR_FALSE;
} }

Просмотреть файл

@ -2410,8 +2410,11 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresContext* aPresContex
PRInt32 size = 1; PRInt32 size = 1;
nsresult result = aContent->QueryInterface(kIDOMHTMLSelectElementIID, (void**)&select); nsresult result = aContent->QueryInterface(kIDOMHTMLSelectElementIID, (void**)&select);
if (NS_SUCCEEDED(result)) { if (NS_SUCCEEDED(result)) {
result = select->GetSize(&size); select->GetSize(&size);
if ((1 == size) || (kNoSizeSpecified == size)) { PRBool multipleSelect = PR_FALSE;
select->GetMultiple(&multipleSelect);
// Construct a combobox if size=1 or no size is specified and its multiple select
if (((1 == size) || (kNoSizeSpecified == size)) && (PR_FALSE == multipleSelect)) {
// Construct a frame-based combo box. // Construct a frame-based combo box.
// The frame-based combo box is built out of tree parts. A display area, a button and // The frame-based combo box is built out of tree parts. A display area, a button and
// a dropdown list. The display area and button are created through anonymous content. // a dropdown list. The display area and button are created through anonymous content.
@ -2521,6 +2524,7 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresContext* aPresContex
} }
nsresult nsresult
nsCSSFrameConstructor::ConstructFrameByTag(nsIPresContext* aPresContext, nsCSSFrameConstructor::ConstructFrameByTag(nsIPresContext* aPresContext,
nsFrameConstructorState& aState, nsFrameConstructorState& aState,

Просмотреть файл

@ -710,19 +710,6 @@ button:focus:-moz-focus-inner {
border : 1px dotted black; border : 1px dotted black;
} }
:-moz-file-button {
border: 2px outset rgb(204, 204, 204);
color:black;
background-color: rgb(204, 204, 204);
}
:-moz-file-text {
border: 2px inset rgb(204, 204, 204);
margin-right: 10px;
background-color: white;
color: black;
}
input[type=text] { input[type=text] {
border: 2px inset rgb(204, 204, 204); border: 2px inset rgb(204, 204, 204);
background-color: white; background-color: white;
@ -763,6 +750,16 @@ select[size] {
border: 1px inset rgb(153, 153, 153); border: 1px inset rgb(153, 153, 153);
} }
select[multiple] {
background-color: white;
border: 1px inset rgb(153, 153, 153);
}
select[multiple][size="1"] {
background-color: white;
border: 1px inset rgb(153, 153, 153);
}
select[size="1"] { select[size="1"] {
vertical-align: bottom; vertical-align: bottom;
border: none; border: none;
@ -833,6 +830,17 @@ select[size="1"] option[-moz-option-selected] {
background-color:white; background-color:white;
} }
select[multiple] option[-moz-option-selected] {
color:white;
background-color:rgb(51,51,102);
}
select[multiple][size="1"] option[-moz-option-selected] {
color:white;
background-color:rgb(51,51,102);
}
option.selectedfocus { option.selectedfocus {
border: 1px dotted white; border: 1px dotted white;
background-color: rgb(0,0,128); background-color: rgb(0,0,128);