зеркало из https://github.com/mozilla/pjs.git
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:
Родитель
cb9e34b3fc
Коммит
3ecd16ef89
|
@ -1721,82 +1721,86 @@ 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) {
|
||||
nsIFrame * comboboxFrame;
|
||||
rv = NS_NewComboboxControlFrame(comboboxFrame);
|
||||
nsIComboboxControlFrame* comboBox;
|
||||
if (NS_OK == comboboxFrame->QueryInterface(kIComboboxControlFrameIID, (void**)&comboBox)) {
|
||||
if (! NS_FRAME_BASED_COMBO_WORKS) {
|
||||
rv = NS_NewSelectControlFrame(aNewFrame);
|
||||
} else {
|
||||
nsIFrame * comboboxFrame;
|
||||
rv = NS_NewComboboxControlFrame(comboboxFrame);
|
||||
nsIComboboxControlFrame* comboBox;
|
||||
if (NS_OK == comboboxFrame->QueryInterface(kIComboboxControlFrameIID, (void**)&comboBox)) {
|
||||
|
||||
nsIFrame * listFrame;
|
||||
rv = NS_NewListControlFrame(listFrame);
|
||||
nsIFrame * listFrame;
|
||||
rv = NS_NewListControlFrame(listFrame);
|
||||
|
||||
// This is important to do before it is initialized
|
||||
// it tells it that it is in "DropDown Mode"
|
||||
nsIListControlFrame * listControlFrame;
|
||||
if (NS_OK == listFrame->QueryInterface(kIListControlFrameIID, (void**)&listControlFrame)) {
|
||||
listControlFrame->SetComboboxFrame(comboboxFrame);
|
||||
// This is important to do before it is initialized
|
||||
// it tells it that it is in "DropDown Mode"
|
||||
nsIListControlFrame * listControlFrame;
|
||||
if (NS_OK == listFrame->QueryInterface(kIListControlFrameIID, (void**)&listControlFrame)) {
|
||||
listControlFrame->SetComboboxFrame(comboboxFrame);
|
||||
}
|
||||
|
||||
InitializeScrollFrame(listFrame, aPresContext, aContent, comboboxFrame, aStyleContext,
|
||||
aAbsoluteItems, aNewFrame, aFixedItems, aIsAbsolutelyPositioned,
|
||||
aIsFixedPositioned, PR_TRUE);
|
||||
|
||||
nsIFrame* placeholderFrame;
|
||||
|
||||
CreatePlaceholderFrameFor(aPresContext, aContent, aNewFrame, aStyleContext,
|
||||
aParentFrame, placeholderFrame);
|
||||
|
||||
// Add the absolutely positioned frame to its containing block's list
|
||||
// of child frames
|
||||
if (aIsAbsolutelyPositioned)
|
||||
aAbsoluteItems.AddChild(aNewFrame);
|
||||
|
||||
listFrame = aNewFrame;
|
||||
|
||||
// This needs to be done "after" the ListFrame has it's ChildList set
|
||||
// because the SetInitChildList intializes the ListBox selection state
|
||||
// and this method initializes the ComboBox's selection state
|
||||
comboBox->SetDropDown(placeholderFrame, listFrame);
|
||||
|
||||
// Set up the Pseudo Style contents
|
||||
//XXX: What should happend if resolving the pseudo style fails?
|
||||
nsCOMPtr<nsIStyleContext> visiblePseudoStyle;
|
||||
aPresContext->ResolvePseudoStyleContextFor
|
||||
(aContent, nsHTMLAtoms::dropDownVisible, aStyleContext, PR_FALSE,
|
||||
getter_AddRefs(visiblePseudoStyle));
|
||||
|
||||
nsCOMPtr<nsIStyleContext> hiddenPseudoStyle;
|
||||
aPresContext->ResolvePseudoStyleContextFor
|
||||
(aContent, nsHTMLAtoms::dropDownHidden, aStyleContext, PR_FALSE,
|
||||
getter_AddRefs(hiddenPseudoStyle));
|
||||
|
||||
nsCOMPtr<nsIStyleContext> outPseudoStyle;
|
||||
aPresContext->ResolvePseudoStyleContextFor
|
||||
(aContent, nsHTMLAtoms::dropDownBtnOut, aStyleContext, PR_FALSE,
|
||||
getter_AddRefs(outPseudoStyle));
|
||||
|
||||
nsCOMPtr<nsIStyleContext> pressPseudoStyle;
|
||||
aPresContext->ResolvePseudoStyleContextFor(aContent, nsHTMLAtoms::dropDownBtnPressed,
|
||||
aStyleContext, PR_FALSE, getter_AddRefs(pressPseudoStyle));
|
||||
|
||||
comboBox->SetDropDownStyleContexts(visiblePseudoStyle, hiddenPseudoStyle);
|
||||
comboBox->SetButtonStyleContexts(outPseudoStyle, pressPseudoStyle);
|
||||
|
||||
aProcessChildren = PR_FALSE;
|
||||
nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, listFrame,
|
||||
aStyleContext, PR_TRUE);
|
||||
aNewFrame = comboboxFrame;
|
||||
}
|
||||
|
||||
InitializeScrollFrame(listFrame, aPresContext, aContent, comboboxFrame, aStyleContext,
|
||||
aAbsoluteItems, aNewFrame, aFixedItems, aIsAbsolutelyPositioned,
|
||||
aIsFixedPositioned, PR_TRUE);
|
||||
|
||||
nsIFrame* placeholderFrame;
|
||||
|
||||
CreatePlaceholderFrameFor(aPresContext, aContent, aNewFrame, aStyleContext,
|
||||
aParentFrame, placeholderFrame);
|
||||
|
||||
// Add the absolutely positioned frame to its containing block's list
|
||||
// of child frames
|
||||
if (aIsAbsolutelyPositioned)
|
||||
aAbsoluteItems.AddChild(aNewFrame);
|
||||
|
||||
listFrame = aNewFrame;
|
||||
|
||||
// This needs to be done "after" the ListFrame has it's ChildList set
|
||||
// because the SetInitChildList intializes the ListBox selection state
|
||||
// and this method initializes the ComboBox's selection state
|
||||
comboBox->SetDropDown(placeholderFrame, listFrame);
|
||||
|
||||
// Set up the Pseudo Style contents
|
||||
//XXX: What should happend if resolving the pseudo style fails?
|
||||
nsCOMPtr<nsIStyleContext> visiblePseudoStyle;
|
||||
aPresContext->ResolvePseudoStyleContextFor
|
||||
(aContent, nsHTMLAtoms::dropDownVisible, aStyleContext, PR_FALSE,
|
||||
getter_AddRefs(visiblePseudoStyle));
|
||||
|
||||
nsCOMPtr<nsIStyleContext> hiddenPseudoStyle;
|
||||
aPresContext->ResolvePseudoStyleContextFor
|
||||
(aContent, nsHTMLAtoms::dropDownHidden, aStyleContext, PR_FALSE,
|
||||
getter_AddRefs(hiddenPseudoStyle));
|
||||
|
||||
nsCOMPtr<nsIStyleContext> outPseudoStyle;
|
||||
aPresContext->ResolvePseudoStyleContextFor
|
||||
(aContent, nsHTMLAtoms::dropDownBtnOut, aStyleContext, PR_FALSE,
|
||||
getter_AddRefs(outPseudoStyle));
|
||||
|
||||
nsCOMPtr<nsIStyleContext> pressPseudoStyle;
|
||||
aPresContext->ResolvePseudoStyleContextFor(aContent, nsHTMLAtoms::dropDownBtnPressed,
|
||||
aStyleContext, PR_FALSE, getter_AddRefs(pressPseudoStyle));
|
||||
|
||||
comboBox->SetDropDownStyleContexts(visiblePseudoStyle, hiddenPseudoStyle);
|
||||
comboBox->SetButtonStyleContexts(outPseudoStyle, pressPseudoStyle);
|
||||
|
||||
aProcessChildren = PR_FALSE;
|
||||
nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, listFrame,
|
||||
aStyleContext, PR_TRUE);
|
||||
aNewFrame = comboboxFrame;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -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
|
||||
|
@ -71,11 +43,8 @@ struct nsInputDimSpec
|
|||
* @see nsLayoutAtoms::floaterList
|
||||
*/
|
||||
class nsListControlFrame : public nsScrollFrame,
|
||||
public nsIFormControlFrame,
|
||||
public nsIListControlFrame
|
||||
#ifdef PLUGGABLE_EVENTS
|
||||
public nsIPluggableEventListener
|
||||
#endif
|
||||
public nsIFormControlFrame,
|
||||
public nsIListControlFrame
|
||||
{
|
||||
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,
|
||||
|
@ -205,7 +134,7 @@ public:
|
|||
NS_IMETHOD GetName(nsString* aName);
|
||||
|
||||
virtual void SetFocus(PRBool aOn = PR_TRUE, PRBool aRepaint = PR_FALSE);
|
||||
|
||||
|
||||
virtual void MouseClicked(nsIPresContext* aPresContext);
|
||||
|
||||
virtual void Reset();
|
||||
|
@ -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,12 +173,14 @@ protected:
|
|||
nsIAtom* aList,
|
||||
nsIFrame** aFrame);
|
||||
|
||||
// nsHTMLContainerFrame overrides
|
||||
virtual void PaintChildren(nsIPresContext& aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer);
|
||||
// Utility methods
|
||||
|
||||
void DisplaySelected(nsIContent* aContent);
|
||||
void DisplayDeselected(nsIContent* aContent);
|
||||
void UpdateItem(nsIContent* aContent, PRBool aSelected);
|
||||
|
||||
// nsHTMLContainerFrame overrides
|
||||
|
||||
void ClearSelection();
|
||||
void InitializeFromContent(PRBool aDoDisplay = PR_FALSE);
|
||||
|
||||
|
@ -272,35 +198,26 @@ 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;
|
||||
nsIFrame * mHitFrame;
|
||||
nsIContent * mHitContent;
|
||||
|
||||
nsIFrame * mCurrentHitFrame;
|
||||
nsIFrame * mCurrentHitFrame;
|
||||
nsIContent * mCurrentHitContent;
|
||||
|
||||
nsIFrame * mSelectedFrame;
|
||||
nsIFrame * mSelectedFrame;
|
||||
nsIContent * mSelectedContent;
|
||||
|
||||
PRBool mIsInitializedFromContent;
|
||||
|
||||
nsIFrame * mContentFrame;
|
||||
PRBool mInDropDownMode;
|
||||
nsIFrame * mContentFrame;
|
||||
PRBool mInDropDownMode;
|
||||
nsIComboboxControlFrame * mComboboxFrame;
|
||||
nsString mSelectionStr;
|
||||
nsString mSelectionStr;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -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
|
||||
|
@ -71,11 +43,8 @@ struct nsInputDimSpec
|
|||
* @see nsLayoutAtoms::floaterList
|
||||
*/
|
||||
class nsListControlFrame : public nsScrollFrame,
|
||||
public nsIFormControlFrame,
|
||||
public nsIListControlFrame
|
||||
#ifdef PLUGGABLE_EVENTS
|
||||
public nsIPluggableEventListener
|
||||
#endif
|
||||
public nsIFormControlFrame,
|
||||
public nsIListControlFrame
|
||||
{
|
||||
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,
|
||||
|
@ -205,7 +134,7 @@ public:
|
|||
NS_IMETHOD GetName(nsString* aName);
|
||||
|
||||
virtual void SetFocus(PRBool aOn = PR_TRUE, PRBool aRepaint = PR_FALSE);
|
||||
|
||||
|
||||
virtual void MouseClicked(nsIPresContext* aPresContext);
|
||||
|
||||
virtual void Reset();
|
||||
|
@ -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,12 +173,14 @@ protected:
|
|||
nsIAtom* aList,
|
||||
nsIFrame** aFrame);
|
||||
|
||||
// nsHTMLContainerFrame overrides
|
||||
virtual void PaintChildren(nsIPresContext& aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer);
|
||||
// Utility methods
|
||||
|
||||
void DisplaySelected(nsIContent* aContent);
|
||||
void DisplayDeselected(nsIContent* aContent);
|
||||
void UpdateItem(nsIContent* aContent, PRBool aSelected);
|
||||
|
||||
// nsHTMLContainerFrame overrides
|
||||
|
||||
void ClearSelection();
|
||||
void InitializeFromContent(PRBool aDoDisplay = PR_FALSE);
|
||||
|
||||
|
@ -272,35 +198,26 @@ 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;
|
||||
nsIFrame * mHitFrame;
|
||||
nsIContent * mHitContent;
|
||||
|
||||
nsIFrame * mCurrentHitFrame;
|
||||
nsIFrame * mCurrentHitFrame;
|
||||
nsIContent * mCurrentHitContent;
|
||||
|
||||
nsIFrame * mSelectedFrame;
|
||||
nsIFrame * mSelectedFrame;
|
||||
nsIContent * mSelectedContent;
|
||||
|
||||
PRBool mIsInitializedFromContent;
|
||||
|
||||
nsIFrame * mContentFrame;
|
||||
PRBool mInDropDownMode;
|
||||
nsIFrame * mContentFrame;
|
||||
PRBool mInDropDownMode;
|
||||
nsIComboboxControlFrame * mComboboxFrame;
|
||||
nsString mSelectionStr;
|
||||
nsString mSelectionStr;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -1721,82 +1721,86 @@ 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) {
|
||||
nsIFrame * comboboxFrame;
|
||||
rv = NS_NewComboboxControlFrame(comboboxFrame);
|
||||
nsIComboboxControlFrame* comboBox;
|
||||
if (NS_OK == comboboxFrame->QueryInterface(kIComboboxControlFrameIID, (void**)&comboBox)) {
|
||||
if (! NS_FRAME_BASED_COMBO_WORKS) {
|
||||
rv = NS_NewSelectControlFrame(aNewFrame);
|
||||
} else {
|
||||
nsIFrame * comboboxFrame;
|
||||
rv = NS_NewComboboxControlFrame(comboboxFrame);
|
||||
nsIComboboxControlFrame* comboBox;
|
||||
if (NS_OK == comboboxFrame->QueryInterface(kIComboboxControlFrameIID, (void**)&comboBox)) {
|
||||
|
||||
nsIFrame * listFrame;
|
||||
rv = NS_NewListControlFrame(listFrame);
|
||||
nsIFrame * listFrame;
|
||||
rv = NS_NewListControlFrame(listFrame);
|
||||
|
||||
// This is important to do before it is initialized
|
||||
// it tells it that it is in "DropDown Mode"
|
||||
nsIListControlFrame * listControlFrame;
|
||||
if (NS_OK == listFrame->QueryInterface(kIListControlFrameIID, (void**)&listControlFrame)) {
|
||||
listControlFrame->SetComboboxFrame(comboboxFrame);
|
||||
// This is important to do before it is initialized
|
||||
// it tells it that it is in "DropDown Mode"
|
||||
nsIListControlFrame * listControlFrame;
|
||||
if (NS_OK == listFrame->QueryInterface(kIListControlFrameIID, (void**)&listControlFrame)) {
|
||||
listControlFrame->SetComboboxFrame(comboboxFrame);
|
||||
}
|
||||
|
||||
InitializeScrollFrame(listFrame, aPresContext, aContent, comboboxFrame, aStyleContext,
|
||||
aAbsoluteItems, aNewFrame, aFixedItems, aIsAbsolutelyPositioned,
|
||||
aIsFixedPositioned, PR_TRUE);
|
||||
|
||||
nsIFrame* placeholderFrame;
|
||||
|
||||
CreatePlaceholderFrameFor(aPresContext, aContent, aNewFrame, aStyleContext,
|
||||
aParentFrame, placeholderFrame);
|
||||
|
||||
// Add the absolutely positioned frame to its containing block's list
|
||||
// of child frames
|
||||
if (aIsAbsolutelyPositioned)
|
||||
aAbsoluteItems.AddChild(aNewFrame);
|
||||
|
||||
listFrame = aNewFrame;
|
||||
|
||||
// This needs to be done "after" the ListFrame has it's ChildList set
|
||||
// because the SetInitChildList intializes the ListBox selection state
|
||||
// and this method initializes the ComboBox's selection state
|
||||
comboBox->SetDropDown(placeholderFrame, listFrame);
|
||||
|
||||
// Set up the Pseudo Style contents
|
||||
//XXX: What should happend if resolving the pseudo style fails?
|
||||
nsCOMPtr<nsIStyleContext> visiblePseudoStyle;
|
||||
aPresContext->ResolvePseudoStyleContextFor
|
||||
(aContent, nsHTMLAtoms::dropDownVisible, aStyleContext, PR_FALSE,
|
||||
getter_AddRefs(visiblePseudoStyle));
|
||||
|
||||
nsCOMPtr<nsIStyleContext> hiddenPseudoStyle;
|
||||
aPresContext->ResolvePseudoStyleContextFor
|
||||
(aContent, nsHTMLAtoms::dropDownHidden, aStyleContext, PR_FALSE,
|
||||
getter_AddRefs(hiddenPseudoStyle));
|
||||
|
||||
nsCOMPtr<nsIStyleContext> outPseudoStyle;
|
||||
aPresContext->ResolvePseudoStyleContextFor
|
||||
(aContent, nsHTMLAtoms::dropDownBtnOut, aStyleContext, PR_FALSE,
|
||||
getter_AddRefs(outPseudoStyle));
|
||||
|
||||
nsCOMPtr<nsIStyleContext> pressPseudoStyle;
|
||||
aPresContext->ResolvePseudoStyleContextFor(aContent, nsHTMLAtoms::dropDownBtnPressed,
|
||||
aStyleContext, PR_FALSE, getter_AddRefs(pressPseudoStyle));
|
||||
|
||||
comboBox->SetDropDownStyleContexts(visiblePseudoStyle, hiddenPseudoStyle);
|
||||
comboBox->SetButtonStyleContexts(outPseudoStyle, pressPseudoStyle);
|
||||
|
||||
aProcessChildren = PR_FALSE;
|
||||
nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, listFrame,
|
||||
aStyleContext, PR_TRUE);
|
||||
aNewFrame = comboboxFrame;
|
||||
}
|
||||
|
||||
InitializeScrollFrame(listFrame, aPresContext, aContent, comboboxFrame, aStyleContext,
|
||||
aAbsoluteItems, aNewFrame, aFixedItems, aIsAbsolutelyPositioned,
|
||||
aIsFixedPositioned, PR_TRUE);
|
||||
|
||||
nsIFrame* placeholderFrame;
|
||||
|
||||
CreatePlaceholderFrameFor(aPresContext, aContent, aNewFrame, aStyleContext,
|
||||
aParentFrame, placeholderFrame);
|
||||
|
||||
// Add the absolutely positioned frame to its containing block's list
|
||||
// of child frames
|
||||
if (aIsAbsolutelyPositioned)
|
||||
aAbsoluteItems.AddChild(aNewFrame);
|
||||
|
||||
listFrame = aNewFrame;
|
||||
|
||||
// This needs to be done "after" the ListFrame has it's ChildList set
|
||||
// because the SetInitChildList intializes the ListBox selection state
|
||||
// and this method initializes the ComboBox's selection state
|
||||
comboBox->SetDropDown(placeholderFrame, listFrame);
|
||||
|
||||
// Set up the Pseudo Style contents
|
||||
//XXX: What should happend if resolving the pseudo style fails?
|
||||
nsCOMPtr<nsIStyleContext> visiblePseudoStyle;
|
||||
aPresContext->ResolvePseudoStyleContextFor
|
||||
(aContent, nsHTMLAtoms::dropDownVisible, aStyleContext, PR_FALSE,
|
||||
getter_AddRefs(visiblePseudoStyle));
|
||||
|
||||
nsCOMPtr<nsIStyleContext> hiddenPseudoStyle;
|
||||
aPresContext->ResolvePseudoStyleContextFor
|
||||
(aContent, nsHTMLAtoms::dropDownHidden, aStyleContext, PR_FALSE,
|
||||
getter_AddRefs(hiddenPseudoStyle));
|
||||
|
||||
nsCOMPtr<nsIStyleContext> outPseudoStyle;
|
||||
aPresContext->ResolvePseudoStyleContextFor
|
||||
(aContent, nsHTMLAtoms::dropDownBtnOut, aStyleContext, PR_FALSE,
|
||||
getter_AddRefs(outPseudoStyle));
|
||||
|
||||
nsCOMPtr<nsIStyleContext> pressPseudoStyle;
|
||||
aPresContext->ResolvePseudoStyleContextFor(aContent, nsHTMLAtoms::dropDownBtnPressed,
|
||||
aStyleContext, PR_FALSE, getter_AddRefs(pressPseudoStyle));
|
||||
|
||||
comboBox->SetDropDownStyleContexts(visiblePseudoStyle, hiddenPseudoStyle);
|
||||
comboBox->SetButtonStyleContexts(outPseudoStyle, pressPseudoStyle);
|
||||
|
||||
aProcessChildren = PR_FALSE;
|
||||
nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, listFrame,
|
||||
aStyleContext, PR_TRUE);
|
||||
aNewFrame = comboboxFrame;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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>
|
Загрузка…
Ссылка в новой задаче