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(fieldset, "fieldset")
HTML_ATOM(fieldsetContentPseudo, ":fieldset-content")
HTML_ATOM(fileButtonStylePseudo, ":-moz-file-button")
HTML_ATOM(fileTextStylePseudo, ":-moz-file-text")
HTML_ATOM(firstLetterPseudo, ":first-letter")
HTML_ATOM(firstLinePseudo, ":first-line")
HTML_ATOM(font, "font")

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

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

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

@ -2410,8 +2410,11 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresContext* aPresContex
PRInt32 size = 1;
nsresult result = aContent->QueryInterface(kIDOMHTMLSelectElementIID, (void**)&select);
if (NS_SUCCEEDED(result)) {
result = select->GetSize(&size);
if ((1 == size) || (kNoSizeSpecified == size)) {
select->GetSize(&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.
// 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.
@ -2521,6 +2524,7 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresContext* aPresContex
}
nsresult
nsCSSFrameConstructor::ConstructFrameByTag(nsIPresContext* aPresContext,
nsFrameConstructorState& aState,

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

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

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

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

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

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

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

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

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

@ -69,7 +69,8 @@ nsPresContext::nsPresContext()
nsLayoutAtoms::AddRefAtoms();
mCompatibilityMode = eCompatibility_Standard;
mCompatibilityLocked = PR_FALSE;
mWidgetRenderingMode = eWidgetRendering_Native; // to be changed to _Gfx soon!
mWidgetRenderingMode = eWidgetRendering_Native; // Soon to be set to PartialGfx
#ifdef _WIN32
// 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
if ((NS_OK == result) && (nsnull != fcFrame)) {
// 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);
// Find out if there are any options in the list to select
PRInt32 length = 0;
mListControlFrame->GetNumberOfOptions(&length);
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;
}
/*XXX-REMOVE
PRBool
nsComboboxControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
nsString* aValues, nsString* aNames)
@ -739,6 +745,21 @@ nsComboboxControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValue
nsresult status = PR_TRUE;
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

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

@ -249,7 +249,7 @@ nsFormControlFrame::Reflow(nsIPresContext& aPresContext,
nsWidgetRendering 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
if (PR_TRUE == requiresWidget) {
RequiresWidget(requiresWidget);

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

@ -305,7 +305,7 @@ nsFormControlHelper::CalculateSize (nsIPresContext* aPresContext,
PRInt32 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)
{
if (!aWidthExplicit) {

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

@ -69,6 +69,12 @@ public:
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
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 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
// -moz-option-selected in the ua.css style sheet. This will not be needed when
@ -75,8 +77,6 @@ nsListControlFrame::nsListControlFrame()
{
mHitFrame = nsnull;
mSelectedIndex = kNothingSelected;
mNumRows = 0;
mNumSelections = 0;
mComboboxFrame = nsnull;
mFormFrame = nsnull;
mDisplayed = PR_FALSE;
@ -268,7 +268,7 @@ nsListControlFrame::Reflow(nsIPresContext& aPresContext,
//longest element in the list
nsHTMLReflowState secondPassState(aReflowState);
nsHTMLReflowState firstPassState(aReflowState);
// Get the size of option elements inside 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.availableWidth = NS_UNCONSTRAINEDSIZE;
firstPassState.availableHeight = NS_UNCONSTRAINEDSIZE;
nsSize scrolledAreaSize(0,0);
nsHTMLReflowMetrics scrolledAreaDesiredSize(&scrolledAreaSize);
if (eReflowReason_Incremental == firstPassState.reason) {
// When incremental, Reflow everything
nsIFrame* targetFrame;
firstPassState.reflowCommand->GetTarget(targetFrame);
if (this == targetFrame) {
@ -370,20 +368,28 @@ nsListControlFrame::Reflow(nsIPresContext& aPresContext,
nscoord visibleHeight = 0;
if (IsInDropDownMode() == PR_TRUE) {
// 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;
// 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;
if (visibleHeight > (kMaxDropDownRows * heightOfARow))
visibleHeight = (kMaxDropDownRows * heightOfARow);
if (visibleHeight > (kMaxDropDownRows * heightOfARow)) {
visibleHeight = (kMaxDropDownRows * heightOfARow);
}
} else {
// Calculate the visible height of the listbox
if (NS_UNCONSTRAINEDSIZE != aReflowState.mComputedHeight) {
visibleHeight = aReflowState.mComputedHeight;
} 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
PRUint32 length;
length = GetNumberOfOptions();
PRInt32 length = 0;
GetNumberOfOptions(&length);
nsIDOMHTMLCollection* options = GetOptions(mContent);
if (nsnull != options) {
PRUint32 numOptions;
@ -575,8 +581,9 @@ nsListControlFrame::GetSelectedIndex(nsIFrame *aHitFrame)
void
nsListControlFrame::ClearSelection()
{
PRUint32 length = GetNumberOfOptions();
for (PRInt32 i = 0; i < (PRInt32)length; i++) {
PRInt32 length = 0;
GetNumberOfOptions(&length);
for (PRInt32 i = 0; i < length; i++) {
if (i != mSelectedIndex) {
SetFrameSelected(i, PR_FALSE);
}
@ -600,7 +607,8 @@ nsListControlFrame::ExtendedSelection(PRInt32 aStartIndex, PRInt32 aEndIndex, PR
PRInt32 i = 0;
PRBool startInverting = PR_FALSE;
PRInt32 length = GetNumberOfOptions();
PRInt32 length = 0;
GetNumberOfOptions(&length);
for (i = 0; i < length; i++) {
if (i == startInx) {
startInverting = PR_TRUE;
@ -703,7 +711,9 @@ nsListControlFrame::HandleListSelection(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus)
{
if (mMultipleSelections) {
PRBool multipleSelections = PR_FALSE;
GetMultiple(&multipleSelections);
if (multipleSelections) {
MultipleSelection(((nsMouseEvent *)aEvent)->isShift, ((nsMouseEvent *)aEvent)->isControl);
} else {
SingleSelection();
@ -738,19 +748,23 @@ nsListControlFrame::HandleLikeListEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus)
{
if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) {
HandleListSelection(aPresContext, aEvent, aEventStatus);
mButtonDown = PR_TRUE;
CaptureMouseEvents(PR_TRUE);
mLastFrame = mHitFrame;
} else if (aEvent->message == NS_MOUSE_MOVE) {
if ((PR_TRUE == mButtonDown) && (! HasSameContent(mLastFrame, mHitFrame))) {
if (nsnull != mHitFrame) {
if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) {
HandleListSelection(aPresContext, aEvent, aEventStatus);
mButtonDown = PR_TRUE;
CaptureMouseEvents(PR_TRUE);
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;
@ -951,6 +965,18 @@ nsListControlFrame::SetInitialChildList(nsIPresContext& aPresContext,
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
nsListControlFrame::Init(nsIPresContext& aPresContext,
@ -961,14 +987,6 @@ nsListControlFrame::Init(nsIPresContext& aPresContext,
{
nsresult result = nsScrollFrame::Init(aPresContext, aContent, aParent, aContext,
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
// the listbox items from the content. This is done here because
@ -1108,11 +1126,12 @@ nsListControlFrame::SetFrameSelected(PRUint32 aIndex, PRBool aSelected)
void
nsListControlFrame::InitializeFromContent()
{
PRUint32 length = GetNumberOfOptions();
PRInt32 length = 0;
GetNumberOfOptions(&length);
nsIDOMHTMLCollection* options = GetOptions(mContent);
nsresult result = NS_OK;
if (nsnull != options) {
for (PRUint32 i = 0; i < length; i++) {
for (PRInt32 i = 0; i < length; i++) {
nsIDOMHTMLOptionElement* optionElement = nsnull;
optionElement = GetOption(*options, i);
if (nsnull != optionElement) {
@ -1190,11 +1209,11 @@ nsresult
nsListControlFrame::Deselect()
{
PRInt32 i;
PRInt32 max = GetNumberOfOptions();
PRInt32 max = 0;
GetNumberOfOptions(&max);
for (i=0;i<max;i++) {
SetFrameSelected(i, PR_FALSE);
}
mNumSelections = 0;
mSelectedIndex = kNothingSelected;
return NS_OK;
@ -1234,6 +1253,7 @@ nsListControlFrame::MouseClicked(nsIPresContext* aPresContext)
{
}
PRInt32
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
nsListControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
nsString* aValues, nsString* aNames)
{
PRBool status = PR_FALSE;
aNumValues = 0;
nsAutoString name;
nsresult result = GetName(&name);
@ -1318,28 +1352,34 @@ nsListControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
return PR_FALSE;
}
NS_ASSERTION(aMaxNumValues >= mNumSelections, "invalid max num values");
if (mNumSelections >= 0) {
PRInt32* selections = new PRInt32[mNumSelections];
PRInt32 i = 0;
PRInt32 inx;
for (inx=0;i<mNumSelections;i++) {
if (IsFrameSelected(inx)) {
selections[i++] = inx;
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;
}
}
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;
}
}
NS_RELEASE(options);
return status;
@ -1398,16 +1438,20 @@ nsresult nsListControlFrame::RequiresWidget(PRBool& aRequiresWidget)
return NS_OK;
}
PRInt32 nsListControlFrame::GetNumberOfOptions()
NS_IMETHODIMP
nsListControlFrame::GetNumberOfOptions(PRInt32* aNumOptions)
{
nsIDOMHTMLCollection* options = GetOptions(mContent);
if (!options) {
return 0;
if (nsnull == options) {
*aNumOptions = 0;
} else {
PRUint32 length = 0;
options->GetLength(&length);
*aNumOptions = (PRInt32)length;
NS_RELEASE(options);
}
PRUint32 numOptions;
options->GetLength(&numOptions);
NS_RELEASE(options);
return(numOptions);
return NS_OK;
}
// Select the specified item in the listbox using control logic.

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

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

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

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

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

@ -710,19 +710,6 @@ button:focus:-moz-focus-inner {
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] {
border: 2px inset rgb(204, 204, 204);
background-color: white;
@ -763,6 +750,16 @@ select[size] {
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"] {
vertical-align: bottom;
border: none;
@ -833,6 +830,17 @@ select[size="1"] option[-moz-option-selected] {
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 {
border: 1px dotted white;
background-color: rgb(0,0,128);

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

@ -69,6 +69,12 @@ public:
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;
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
if (!mFormFrame && (eReflowReason_Initial == aReflowState.reason)) {
nsFormFrame::AddFormControlFrame(aPresContext, *this);

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

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

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

@ -176,10 +176,15 @@ nsComboboxControlFrame::InitTextStr(PRBool aUpdate)
// No selection so use the first item in the list box
if ((NS_OK == result) && (nsnull != fcFrame)) {
// 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);
// Find out if there are any options in the list to select
PRInt32 length = 0;
mListControlFrame->GetNumberOfOptions(&length);
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;
}
/*XXX-REMOVE
PRBool
nsComboboxControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
nsString* aValues, nsString* aNames)
@ -739,6 +745,21 @@ nsComboboxControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValue
nsresult status = PR_TRUE;
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

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

@ -249,7 +249,7 @@ nsFormControlFrame::Reflow(nsIPresContext& aPresContext,
nsWidgetRendering 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
if (PR_TRUE == requiresWidget) {
RequiresWidget(requiresWidget);

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

@ -305,7 +305,7 @@ nsFormControlHelper::CalculateSize (nsIPresContext* aPresContext,
PRInt32 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)
{
if (!aWidthExplicit) {

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

@ -38,8 +38,10 @@
// Constants
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 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
// -moz-option-selected in the ua.css style sheet. This will not be needed when
@ -75,8 +77,6 @@ nsListControlFrame::nsListControlFrame()
{
mHitFrame = nsnull;
mSelectedIndex = kNothingSelected;
mNumRows = 0;
mNumSelections = 0;
mComboboxFrame = nsnull;
mFormFrame = nsnull;
mDisplayed = PR_FALSE;
@ -268,7 +268,7 @@ nsListControlFrame::Reflow(nsIPresContext& aPresContext,
//longest element in the list
nsHTMLReflowState secondPassState(aReflowState);
nsHTMLReflowState firstPassState(aReflowState);
// Get the size of option elements inside 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.availableWidth = NS_UNCONSTRAINEDSIZE;
firstPassState.availableHeight = NS_UNCONSTRAINEDSIZE;
nsSize scrolledAreaSize(0,0);
nsHTMLReflowMetrics scrolledAreaDesiredSize(&scrolledAreaSize);
if (eReflowReason_Incremental == firstPassState.reason) {
// When incremental, Reflow everything
nsIFrame* targetFrame;
firstPassState.reflowCommand->GetTarget(targetFrame);
if (this == targetFrame) {
@ -370,20 +368,28 @@ nsListControlFrame::Reflow(nsIPresContext& aPresContext,
nscoord visibleHeight = 0;
if (IsInDropDownMode() == PR_TRUE) {
// 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;
// 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;
if (visibleHeight > (kMaxDropDownRows * heightOfARow))
visibleHeight = (kMaxDropDownRows * heightOfARow);
if (visibleHeight > (kMaxDropDownRows * heightOfARow)) {
visibleHeight = (kMaxDropDownRows * heightOfARow);
}
} else {
// Calculate the visible height of the listbox
if (NS_UNCONSTRAINEDSIZE != aReflowState.mComputedHeight) {
visibleHeight = aReflowState.mComputedHeight;
} 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
PRUint32 length;
length = GetNumberOfOptions();
PRInt32 length = 0;
GetNumberOfOptions(&length);
nsIDOMHTMLCollection* options = GetOptions(mContent);
if (nsnull != options) {
PRUint32 numOptions;
@ -575,8 +581,9 @@ nsListControlFrame::GetSelectedIndex(nsIFrame *aHitFrame)
void
nsListControlFrame::ClearSelection()
{
PRUint32 length = GetNumberOfOptions();
for (PRInt32 i = 0; i < (PRInt32)length; i++) {
PRInt32 length = 0;
GetNumberOfOptions(&length);
for (PRInt32 i = 0; i < length; i++) {
if (i != mSelectedIndex) {
SetFrameSelected(i, PR_FALSE);
}
@ -600,7 +607,8 @@ nsListControlFrame::ExtendedSelection(PRInt32 aStartIndex, PRInt32 aEndIndex, PR
PRInt32 i = 0;
PRBool startInverting = PR_FALSE;
PRInt32 length = GetNumberOfOptions();
PRInt32 length = 0;
GetNumberOfOptions(&length);
for (i = 0; i < length; i++) {
if (i == startInx) {
startInverting = PR_TRUE;
@ -703,7 +711,9 @@ nsListControlFrame::HandleListSelection(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus)
{
if (mMultipleSelections) {
PRBool multipleSelections = PR_FALSE;
GetMultiple(&multipleSelections);
if (multipleSelections) {
MultipleSelection(((nsMouseEvent *)aEvent)->isShift, ((nsMouseEvent *)aEvent)->isControl);
} else {
SingleSelection();
@ -738,19 +748,23 @@ nsListControlFrame::HandleLikeListEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus)
{
if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) {
HandleListSelection(aPresContext, aEvent, aEventStatus);
mButtonDown = PR_TRUE;
CaptureMouseEvents(PR_TRUE);
mLastFrame = mHitFrame;
} else if (aEvent->message == NS_MOUSE_MOVE) {
if ((PR_TRUE == mButtonDown) && (! HasSameContent(mLastFrame, mHitFrame))) {
if (nsnull != mHitFrame) {
if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) {
HandleListSelection(aPresContext, aEvent, aEventStatus);
mButtonDown = PR_TRUE;
CaptureMouseEvents(PR_TRUE);
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;
@ -951,6 +965,18 @@ nsListControlFrame::SetInitialChildList(nsIPresContext& aPresContext,
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
nsListControlFrame::Init(nsIPresContext& aPresContext,
@ -961,14 +987,6 @@ nsListControlFrame::Init(nsIPresContext& aPresContext,
{
nsresult result = nsScrollFrame::Init(aPresContext, aContent, aParent, aContext,
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
// the listbox items from the content. This is done here because
@ -1108,11 +1126,12 @@ nsListControlFrame::SetFrameSelected(PRUint32 aIndex, PRBool aSelected)
void
nsListControlFrame::InitializeFromContent()
{
PRUint32 length = GetNumberOfOptions();
PRInt32 length = 0;
GetNumberOfOptions(&length);
nsIDOMHTMLCollection* options = GetOptions(mContent);
nsresult result = NS_OK;
if (nsnull != options) {
for (PRUint32 i = 0; i < length; i++) {
for (PRInt32 i = 0; i < length; i++) {
nsIDOMHTMLOptionElement* optionElement = nsnull;
optionElement = GetOption(*options, i);
if (nsnull != optionElement) {
@ -1190,11 +1209,11 @@ nsresult
nsListControlFrame::Deselect()
{
PRInt32 i;
PRInt32 max = GetNumberOfOptions();
PRInt32 max = 0;
GetNumberOfOptions(&max);
for (i=0;i<max;i++) {
SetFrameSelected(i, PR_FALSE);
}
mNumSelections = 0;
mSelectedIndex = kNothingSelected;
return NS_OK;
@ -1234,6 +1253,7 @@ nsListControlFrame::MouseClicked(nsIPresContext* aPresContext)
{
}
PRInt32
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
nsListControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
nsString* aValues, nsString* aNames)
{
PRBool status = PR_FALSE;
aNumValues = 0;
nsAutoString name;
nsresult result = GetName(&name);
@ -1318,28 +1352,34 @@ nsListControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
return PR_FALSE;
}
NS_ASSERTION(aMaxNumValues >= mNumSelections, "invalid max num values");
if (mNumSelections >= 0) {
PRInt32* selections = new PRInt32[mNumSelections];
PRInt32 i = 0;
PRInt32 inx;
for (inx=0;i<mNumSelections;i++) {
if (IsFrameSelected(inx)) {
selections[i++] = inx;
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;
}
}
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;
}
}
NS_RELEASE(options);
return status;
@ -1398,16 +1438,20 @@ nsresult nsListControlFrame::RequiresWidget(PRBool& aRequiresWidget)
return NS_OK;
}
PRInt32 nsListControlFrame::GetNumberOfOptions()
NS_IMETHODIMP
nsListControlFrame::GetNumberOfOptions(PRInt32* aNumOptions)
{
nsIDOMHTMLCollection* options = GetOptions(mContent);
if (!options) {
return 0;
if (nsnull == options) {
*aNumOptions = 0;
} else {
PRUint32 length = 0;
options->GetLength(&length);
*aNumOptions = (PRInt32)length;
NS_RELEASE(options);
}
PRUint32 numOptions;
options->GetLength(&numOptions);
NS_RELEASE(options);
return(numOptions);
return NS_OK;
}
// Select the specified item in the listbox using control logic.

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

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

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

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

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

@ -2410,8 +2410,11 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresContext* aPresContex
PRInt32 size = 1;
nsresult result = aContent->QueryInterface(kIDOMHTMLSelectElementIID, (void**)&select);
if (NS_SUCCEEDED(result)) {
result = select->GetSize(&size);
if ((1 == size) || (kNoSizeSpecified == size)) {
select->GetSize(&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.
// 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.
@ -2521,6 +2524,7 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresContext* aPresContex
}
nsresult
nsCSSFrameConstructor::ConstructFrameByTag(nsIPresContext* aPresContext,
nsFrameConstructorState& aState,

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

@ -710,19 +710,6 @@ button:focus:-moz-focus-inner {
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] {
border: 2px inset rgb(204, 204, 204);
background-color: white;
@ -763,6 +750,16 @@ select[size] {
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"] {
vertical-align: bottom;
border: none;
@ -833,6 +830,17 @@ select[size="1"] option[-moz-option-selected] {
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 {
border: 1px dotted white;
background-color: rgb(0,0,128);