Various modifications/fixes/cleanup for frame-based listboxes.

Set display type to block for option elements in ua.css.
Enable frame-based listboxes when widget render mode is gfx.
This commit is contained in:
kmcclusk@netscape.com
1999-03-22 21:32:12 +00:00
parent 927e96ad3e
commit 6fe29f4620
12 changed files with 801 additions and 1386 deletions

View File

@@ -1721,18 +1721,21 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresContext* aPresContext,
PRBool aIsFixedPositioned,
nsAbsoluteItems& aFixedItems)
{
#define NS_FRAME_BASED_COMBO_WORKS 0
nsresult rv = NS_OK;
nsWidgetRendering mode;
aPresContext->GetWidgetRenderingMode(&mode);
//XXX: When frame-based rendering works uncomment this and remove the line below
// if (eWidgetRendering_Gfx == mode) {
if (0) {
if (eWidgetRendering_Gfx == mode) {
nsIDOMHTMLSelectElement* select = nsnull;
PRInt32 size = 1;
nsresult result = aContent->QueryInterface(kIDOMHTMLSelectElementIID, (void**)&select);
if (NS_OK == result) {
result = select->GetSize(&size);
if (1 == size) {
if (! NS_FRAME_BASED_COMBO_WORKS) {
rv = NS_NewSelectControlFrame(aNewFrame);
} else {
nsIFrame * comboboxFrame;
rv = NS_NewComboboxControlFrame(comboboxFrame);
nsIComboboxControlFrame* comboBox;
@@ -1798,6 +1801,7 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresContext* aPresContext,
aStyleContext, PR_TRUE);
aNewFrame = comboboxFrame;
}
}
} else {
nsIFrame * listFrame;

View File

@@ -377,9 +377,11 @@ NS_IMETHODIMP nsComboboxControlFrame::Reflow(nsIPresContext& aPresConte
aPresContext.GetScaledPixelsToTwips(&sp2t);
nscoord onePixel = NSIntPixelsToTwips(1, sp2t);
#if 0
nscoord scrollbarWidth = 0;
nscoord scrollbarHeight = 0;
nsListControlFrame::GetScrollBarDimensions(aPresContext, scrollbarWidth, scrollbarHeight);
#endif
nscoord extra = desiredSize.height - (rowHeight * numRows);

File diff suppressed because it is too large Load Diff

View File

@@ -23,11 +23,9 @@
#include "nsIDOMFocusListener.h"
#include "nsIPresContext.h"
#include "nsIFormControlFrame.h"
#ifdef PLUGGABLE_EVENTS
#include "nsIPluggableEventListener.h"
#endif
#include "nsIListControlFrame.h"
class nsIDOMHTMLSelectElement;
class nsIDOMHTMLCollection;
class nsIDOMHTMLOptionElement;
@@ -35,33 +33,7 @@ class nsFormFrame;
class nsScrollFrame;
class nsIComboboxControlFrame;
#if 0
struct nsInputDimSpec
{
nsIAtom* mColSizeAttr; // attribute used to determine width
PRBool mColSizeAttrInPixels; // is attribute value in pixels (otherwise num chars)
nsIAtom* mColValueAttr; // attribute used to get value to determine size
// if not determined above
nsString* mColDefaultValue; // default value if not determined above
nscoord mColDefaultSize; // default width if not determined above
PRBool mColDefaultSizeInPixels; // is default width in pixels (otherswise num chars)
nsIAtom* mRowSizeAttr; // attribute used to determine height
nscoord mRowDefaultSize; // default height if not determined above
nsInputDimSpec(nsIAtom* aColSizeAttr, PRBool aColSizeAttrInPixels,
nsIAtom* aColValueAttr, nsString* aColDefaultValue,
nscoord aColDefaultSize, PRBool aColDefaultSizeInPixels,
nsIAtom* aRowSizeAttr, nscoord aRowDefaultSize)
: mColSizeAttr(aColSizeAttr), mColSizeAttrInPixels(aColSizeAttrInPixels),
mColValueAttr(aColValueAttr),
mColDefaultValue(aColDefaultValue), mColDefaultSize(aColDefaultSize),
mColDefaultSizeInPixels(aColDefaultSizeInPixels),
mRowSizeAttr(aRowSizeAttr), mRowDefaultSize(aRowDefaultSize)
{
}
};
#endif
/**
* The block frame has two additional named child lists:
* - "Floater-list" which contains the floated frames
@@ -73,9 +45,6 @@ struct nsInputDimSpec
class nsListControlFrame : public nsScrollFrame,
public nsIFormControlFrame,
public nsIListControlFrame
#ifdef PLUGGABLE_EVENTS
public nsIPluggableEventListener
#endif
{
public:
friend nsresult NS_NewListControlFrame(nsIFrame*& aNewFrame);
@@ -101,20 +70,6 @@ public:
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
//
/* virtual nsresult AppendNewFrames(nsIPresContext& aPresContext, nsIFrame*);
virtual nsresult InsertNewFrame(nsIPresContext& aPresContext,
nsBaseIBFrame* aParentFrame,
nsIFrame* aNewFrame,
nsIFrame* aPrevSibling);
virtual nsresult DoRemoveFrame(nsBlockReflowState& aState,
nsBaseIBFrame* aParentFrame,
nsIFrame* aDeletedFrame,
nsIFrame* aPrevSibling);
*/
NS_IMETHOD Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
@@ -127,24 +82,10 @@ public:
NS_IMETHOD SetProperty(nsIAtom* aName, const nsString& aValue);
NS_IMETHOD GetProperty(nsIAtom* aName, nsString& aValue);
#if 0
virtual void GetStyleSize(nsIPresContext& aContext,
const nsHTMLReflowState& aReflowState,
nsSize& aSize);
#endif
virtual void GetDesiredSize(nsIPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsHTMLReflowMetrics& aDesiredLayoutSize,
nsSize& aDesiredWidgetSize);
#if 0
nscoord CalculateSize (nsIPresContext* aPresContext, nsListControlFrame* aFrame,
const nsSize& aCSSSize, nsInputDimSpec& aDimensionSpec,
nsSize& aBounds, PRBool& aWidthExplicit,
PRBool& aHeightExplicit, nscoord& aRowSize,
nsIRenderingContext *aRendContext);
#endif
/*virtual nsresult Focus(nsIDOMEvent* aEvent);
virtual nsresult Blur(nsIDOMEvent* aEvent);
@@ -156,21 +97,9 @@ public:
NS_METHOD GetMultiple(PRBool* aResult, nsIDOMHTMLSelectElement* aSelect = nsnull);
///XXX: End o the temporary methods
#if 0
nscoord GetTextSize(nsIPresContext& aContext, nsListControlFrame* aFrame,
const nsString& aString, nsSize& aSize,
nsIRenderingContext *aRendContext);
nscoord GetTextSize(nsIPresContext& aContext, nsListControlFrame* aFrame,
PRInt32 aNumChars, nsSize& aSize,
nsIRenderingContext *aRendContext);
#endif
virtual nsresult GetSizeFromContent(PRInt32* aSize) const;
NS_IMETHOD GetMaxLength(PRInt32* aSize);
static void GetScrollBarDimensions(nsIPresContext& aPresContext,
nscoord &aWidth, nscoord &aHeight);
virtual nscoord GetVerticalBorderWidth(float aPixToTwip) const;
virtual nscoord GetHorizontalBorderWidth(float aPixToTwip) const;
virtual nscoord GetVerticalInsidePadding(float aPixToTwip,
@@ -219,26 +148,21 @@ public:
virtual void SetFormFrame(nsFormFrame* aFrame);
// nsIPluggableEventListener
NS_IMETHOD PluggableEventHandler(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus);
NS_IMETHOD PluggableGetFrameForPoint(const nsPoint& aPoint,
nsIFrame** aFrame);
// nsIListControlFrame
NS_IMETHOD SetComboboxFrame(nsIFrame* aComboboxFrame);
NS_IMETHOD GetSelectedItem(nsString & aStr);
NS_IMETHOD AboutToDropDown();
// Static Methods
static nsIDOMHTMLSelectElement* GetSelect(nsIContent * aContent);
static nsIDOMHTMLCollection* GetOptions(nsIContent * aContent, nsIDOMHTMLSelectElement* aSelect = nsnull);
static nsIDOMHTMLOptionElement* GetOption(nsIDOMHTMLCollection& aOptions, PRUint32 aIndex);
static PRBool GetOptionValue(nsIDOMHTMLCollection& aCollecton, PRUint32 aIndex, nsString& aValue);
nsIContent* GetOptionContent(PRUint32 aIndex);
PRBool IsFrameSelected(PRUint32 aIndex);
void SetFrameSelected(PRUint32 aIndex, PRBool aSelected);
protected:
nsListControlFrame();
virtual ~nsListControlFrame();
@@ -249,11 +173,13 @@ protected:
nsIAtom* aList,
nsIFrame** aFrame);
// Utility methods
void DisplaySelected(nsIContent* aContent);
void DisplayDeselected(nsIContent* aContent);
void UpdateItem(nsIContent* aContent, PRBool aSelected);
// nsHTMLContainerFrame overrides
virtual void PaintChildren(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
void ClearSelection();
void InitializeFromContent(PRBool aDoDisplay = PR_FALSE);
@@ -272,31 +198,22 @@ protected:
// Data Members
nsFormFrame* mFormFrame;
PRInt32 mNumRows;
PRBool mIsFrameSelected[64];
//XXX: TODO: This should not be hardcoded to 64
//ZZZ PRBool mIsFrameSelected[64];
PRInt32 mNumSelections;
PRInt32 mMaxNumSelections;
PRBool mMultipleSelections;
//nsIContent * mSelectedContent;
PRInt32 mSelectedIndex;
PRInt32 mStartExtendedIndex;
PRInt32 mEndExtendedIndex;
nsIFrame * mHitFrame;
nsIContent * mHitContent;
nsIFrame * mCurrentHitFrame;
nsIContent * mCurrentHitContent;
nsIFrame * mSelectedFrame;
nsIContent * mSelectedContent;
PRBool mIsInitializedFromContent;
nsIFrame * mContentFrame;
PRBool mInDropDownMode;
nsIComboboxControlFrame * mComboboxFrame;

View File

@@ -664,6 +664,7 @@ select {
color:black;
}
option {
display:block;
}
option.selected {
@@ -673,8 +674,8 @@ option.selected {
}
option[-moz-option-selected] {
color:blue;
background-color:green;
color:white;
background-color: rgb(0,0,128);
}
option.selectedfocus {

View File

@@ -377,9 +377,11 @@ NS_IMETHODIMP nsComboboxControlFrame::Reflow(nsIPresContext& aPresConte
aPresContext.GetScaledPixelsToTwips(&sp2t);
nscoord onePixel = NSIntPixelsToTwips(1, sp2t);
#if 0
nscoord scrollbarWidth = 0;
nscoord scrollbarHeight = 0;
nsListControlFrame::GetScrollBarDimensions(aPresContext, scrollbarWidth, scrollbarHeight);
#endif
nscoord extra = desiredSize.height - (rowHeight * numRows);

File diff suppressed because it is too large Load Diff

View File

@@ -23,11 +23,9 @@
#include "nsIDOMFocusListener.h"
#include "nsIPresContext.h"
#include "nsIFormControlFrame.h"
#ifdef PLUGGABLE_EVENTS
#include "nsIPluggableEventListener.h"
#endif
#include "nsIListControlFrame.h"
class nsIDOMHTMLSelectElement;
class nsIDOMHTMLCollection;
class nsIDOMHTMLOptionElement;
@@ -35,33 +33,7 @@ class nsFormFrame;
class nsScrollFrame;
class nsIComboboxControlFrame;
#if 0
struct nsInputDimSpec
{
nsIAtom* mColSizeAttr; // attribute used to determine width
PRBool mColSizeAttrInPixels; // is attribute value in pixels (otherwise num chars)
nsIAtom* mColValueAttr; // attribute used to get value to determine size
// if not determined above
nsString* mColDefaultValue; // default value if not determined above
nscoord mColDefaultSize; // default width if not determined above
PRBool mColDefaultSizeInPixels; // is default width in pixels (otherswise num chars)
nsIAtom* mRowSizeAttr; // attribute used to determine height
nscoord mRowDefaultSize; // default height if not determined above
nsInputDimSpec(nsIAtom* aColSizeAttr, PRBool aColSizeAttrInPixels,
nsIAtom* aColValueAttr, nsString* aColDefaultValue,
nscoord aColDefaultSize, PRBool aColDefaultSizeInPixels,
nsIAtom* aRowSizeAttr, nscoord aRowDefaultSize)
: mColSizeAttr(aColSizeAttr), mColSizeAttrInPixels(aColSizeAttrInPixels),
mColValueAttr(aColValueAttr),
mColDefaultValue(aColDefaultValue), mColDefaultSize(aColDefaultSize),
mColDefaultSizeInPixels(aColDefaultSizeInPixels),
mRowSizeAttr(aRowSizeAttr), mRowDefaultSize(aRowDefaultSize)
{
}
};
#endif
/**
* The block frame has two additional named child lists:
* - "Floater-list" which contains the floated frames
@@ -73,9 +45,6 @@ struct nsInputDimSpec
class nsListControlFrame : public nsScrollFrame,
public nsIFormControlFrame,
public nsIListControlFrame
#ifdef PLUGGABLE_EVENTS
public nsIPluggableEventListener
#endif
{
public:
friend nsresult NS_NewListControlFrame(nsIFrame*& aNewFrame);
@@ -101,20 +70,6 @@ public:
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
//
/* virtual nsresult AppendNewFrames(nsIPresContext& aPresContext, nsIFrame*);
virtual nsresult InsertNewFrame(nsIPresContext& aPresContext,
nsBaseIBFrame* aParentFrame,
nsIFrame* aNewFrame,
nsIFrame* aPrevSibling);
virtual nsresult DoRemoveFrame(nsBlockReflowState& aState,
nsBaseIBFrame* aParentFrame,
nsIFrame* aDeletedFrame,
nsIFrame* aPrevSibling);
*/
NS_IMETHOD Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
@@ -127,24 +82,10 @@ public:
NS_IMETHOD SetProperty(nsIAtom* aName, const nsString& aValue);
NS_IMETHOD GetProperty(nsIAtom* aName, nsString& aValue);
#if 0
virtual void GetStyleSize(nsIPresContext& aContext,
const nsHTMLReflowState& aReflowState,
nsSize& aSize);
#endif
virtual void GetDesiredSize(nsIPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsHTMLReflowMetrics& aDesiredLayoutSize,
nsSize& aDesiredWidgetSize);
#if 0
nscoord CalculateSize (nsIPresContext* aPresContext, nsListControlFrame* aFrame,
const nsSize& aCSSSize, nsInputDimSpec& aDimensionSpec,
nsSize& aBounds, PRBool& aWidthExplicit,
PRBool& aHeightExplicit, nscoord& aRowSize,
nsIRenderingContext *aRendContext);
#endif
/*virtual nsresult Focus(nsIDOMEvent* aEvent);
virtual nsresult Blur(nsIDOMEvent* aEvent);
@@ -156,21 +97,9 @@ public:
NS_METHOD GetMultiple(PRBool* aResult, nsIDOMHTMLSelectElement* aSelect = nsnull);
///XXX: End o the temporary methods
#if 0
nscoord GetTextSize(nsIPresContext& aContext, nsListControlFrame* aFrame,
const nsString& aString, nsSize& aSize,
nsIRenderingContext *aRendContext);
nscoord GetTextSize(nsIPresContext& aContext, nsListControlFrame* aFrame,
PRInt32 aNumChars, nsSize& aSize,
nsIRenderingContext *aRendContext);
#endif
virtual nsresult GetSizeFromContent(PRInt32* aSize) const;
NS_IMETHOD GetMaxLength(PRInt32* aSize);
static void GetScrollBarDimensions(nsIPresContext& aPresContext,
nscoord &aWidth, nscoord &aHeight);
virtual nscoord GetVerticalBorderWidth(float aPixToTwip) const;
virtual nscoord GetHorizontalBorderWidth(float aPixToTwip) const;
virtual nscoord GetVerticalInsidePadding(float aPixToTwip,
@@ -219,26 +148,21 @@ public:
virtual void SetFormFrame(nsFormFrame* aFrame);
// nsIPluggableEventListener
NS_IMETHOD PluggableEventHandler(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus);
NS_IMETHOD PluggableGetFrameForPoint(const nsPoint& aPoint,
nsIFrame** aFrame);
// nsIListControlFrame
NS_IMETHOD SetComboboxFrame(nsIFrame* aComboboxFrame);
NS_IMETHOD GetSelectedItem(nsString & aStr);
NS_IMETHOD AboutToDropDown();
// Static Methods
static nsIDOMHTMLSelectElement* GetSelect(nsIContent * aContent);
static nsIDOMHTMLCollection* GetOptions(nsIContent * aContent, nsIDOMHTMLSelectElement* aSelect = nsnull);
static nsIDOMHTMLOptionElement* GetOption(nsIDOMHTMLCollection& aOptions, PRUint32 aIndex);
static PRBool GetOptionValue(nsIDOMHTMLCollection& aCollecton, PRUint32 aIndex, nsString& aValue);
nsIContent* GetOptionContent(PRUint32 aIndex);
PRBool IsFrameSelected(PRUint32 aIndex);
void SetFrameSelected(PRUint32 aIndex, PRBool aSelected);
protected:
nsListControlFrame();
virtual ~nsListControlFrame();
@@ -249,11 +173,13 @@ protected:
nsIAtom* aList,
nsIFrame** aFrame);
// Utility methods
void DisplaySelected(nsIContent* aContent);
void DisplayDeselected(nsIContent* aContent);
void UpdateItem(nsIContent* aContent, PRBool aSelected);
// nsHTMLContainerFrame overrides
virtual void PaintChildren(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
void ClearSelection();
void InitializeFromContent(PRBool aDoDisplay = PR_FALSE);
@@ -272,31 +198,22 @@ protected:
// Data Members
nsFormFrame* mFormFrame;
PRInt32 mNumRows;
PRBool mIsFrameSelected[64];
//XXX: TODO: This should not be hardcoded to 64
//ZZZ PRBool mIsFrameSelected[64];
PRInt32 mNumSelections;
PRInt32 mMaxNumSelections;
PRBool mMultipleSelections;
//nsIContent * mSelectedContent;
PRInt32 mSelectedIndex;
PRInt32 mStartExtendedIndex;
PRInt32 mEndExtendedIndex;
nsIFrame * mHitFrame;
nsIContent * mHitContent;
nsIFrame * mCurrentHitFrame;
nsIContent * mCurrentHitContent;
nsIFrame * mSelectedFrame;
nsIContent * mSelectedContent;
PRBool mIsInitializedFromContent;
nsIFrame * mContentFrame;
PRBool mInDropDownMode;
nsIComboboxControlFrame * mComboboxFrame;

View File

@@ -1721,18 +1721,21 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresContext* aPresContext,
PRBool aIsFixedPositioned,
nsAbsoluteItems& aFixedItems)
{
#define NS_FRAME_BASED_COMBO_WORKS 0
nsresult rv = NS_OK;
nsWidgetRendering mode;
aPresContext->GetWidgetRenderingMode(&mode);
//XXX: When frame-based rendering works uncomment this and remove the line below
// if (eWidgetRendering_Gfx == mode) {
if (0) {
if (eWidgetRendering_Gfx == mode) {
nsIDOMHTMLSelectElement* select = nsnull;
PRInt32 size = 1;
nsresult result = aContent->QueryInterface(kIDOMHTMLSelectElementIID, (void**)&select);
if (NS_OK == result) {
result = select->GetSize(&size);
if (1 == size) {
if (! NS_FRAME_BASED_COMBO_WORKS) {
rv = NS_NewSelectControlFrame(aNewFrame);
} else {
nsIFrame * comboboxFrame;
rv = NS_NewComboboxControlFrame(comboboxFrame);
nsIComboboxControlFrame* comboBox;
@@ -1798,6 +1801,7 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresContext* aPresContext,
aStyleContext, PR_TRUE);
aNewFrame = comboboxFrame;
}
}
} else {
nsIFrame * listFrame;

View File

@@ -664,6 +664,7 @@ select {
color:black;
}
option {
display:block;
}
option.selected {
@@ -673,8 +674,8 @@ option.selected {
}
option[-moz-option-selected] {
color:blue;
background-color:green;
color:white;
background-color: rgb(0,0,128);
}
option.selectedfocus {

View File

@@ -151,6 +151,7 @@ install:: $(PROGRAM)
$(MAKE_INSTALL) samples\test13.html $(DIST)\bin\res\samples
$(MAKE_INSTALL) samples\test_pr.html $(DIST)\bin\res\samples
$(MAKE_INSTALL) samples\test_gfx.html $(DIST)\bin\res\samples
$(MAKE_INSTALL) samples\test_lbox.html $(DIST)\bin\res\samples
$(MAKE_INSTALL) samples\toolbarTest1.xul $(DIST)\bin\res\samples
$(MAKE_INSTALL) samples\treeTest1.xul $(DIST)\bin\res\samples
$(MAKE_INSTALL) samples\xulTest.css $(DIST)\bin\res\samples
@@ -202,6 +203,7 @@ clobber::
rm -f $(DIST)\bin\res\samples\test12.html
rm -f $(DIST)\bin\res\samples\test_pr.html
rm -f $(DIST)\bin\res\samples\test_gfx.html
rm -f $(DIST)\bin\res\samples\test_lbox.html
rm -f $(DIST)\bin\res\throbber\anim.gif
rm -f $(DIST)\bin\res\throbber\anims00.gif
rm -f $(DIST)\bin\res\throbber\anims01.gif

View File

@@ -0,0 +1,63 @@
<html>
<body>
<form>
<P> Side by Side listboxes <P> (left - single select, right - multiselect)
<BR>
<select name=select1 size=2>
<option>option 1</option>
<option>option 2</option>
<option selected>option 3</option>
<option>option 4</option>
<option>option 5</option>
<option>option 6</option>
<option>option 7</option>
<option>option 8</option>
</select>
<select name=select2 size=4 multiple>
<option>option 1</option>
<option>option 2</option>
<option>option 3</option>
<option>option 4</option>
<option>option 5</option>
</select>
<br>
<P> This listbox should be on a new line with now scrollbars
<BR>
<select name=select3 size=4 multiple>
<option>option 1</option>
<option>option 2</option>
</select>
<BR>
<P> This listbox has a specified width of 500px
<BR>
<select name=select4 style="width:500px;" size=2 multiple>
<option>option 1</option>
<option>option 2</option>
<option>option 3</option>
</select>
<BR>
<P> This listbox has a specified height of 100px
<BR>
<select name=select4 style="height:100px;" size=2 multiple>
<option>option 1</option>
<option>option 2</option>
<option>option 3</option>
</select>
<BR>
<P> This listbox should have 5pixel red inset borders
<P> the first option has orange text.
<P> the second option has yellow text.
<BR>
<select name=select5 style="border: 5px inset red;" size=3 multiple>
<option style="color:orange;">option 2</option>
<option style="color:yellow;">option 1</option>
<option>option 3</option>
<option>option 4</option>
</select>
<BR>
</body>
</body>
</html>