gfx vs native widget rendering can now be specified in the viewer at run-time.
Added methods to GetWidgetRenderingMode and SetWidgetRenderingMode in nsPresContext Removed NS_GFX_RENDER_FORM_ELEMENTS define, now it uses the GetWidgetRenderingMode method on the rendering context. Resurrected Rod's listbox frame-based widget code. Added -moz-option-selected pseudo attribute to control the appearance of selected items for the listbox frame-based widget. Added a style rule with attribute selector for -moz-option-selected to the ua.css style sheet. Modifed nsView::SetVFlags to do a bitwise or instead of bitwise and to set flags. Modified nsView::HandleEvent to compare mVFlags with NS_VIEW_FLAG_DONT_CHECK_CHILDREN git-svn-id: svn://10.0.0.236/trunk@22614 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
8525928774
commit
4bd141876c
@ -198,7 +198,8 @@ NS_IMETHODIMP
|
||||
nsHTMLOptionElement::GetSelected(PRBool* aValue)
|
||||
{
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
if (NS_OK == GetPrimaryFrame(formControlFrame)) {
|
||||
nsresult rv = GetPrimaryFrame(formControlFrame);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PRInt32 index;
|
||||
if (NS_OK == GetIndex(&index)) {
|
||||
nsString value;
|
||||
@ -211,7 +212,7 @@ nsHTMLOptionElement::GetSelected(PRBool* aValue)
|
||||
}
|
||||
NS_RELEASE(formControlFrame);
|
||||
}
|
||||
return NS_OK;
|
||||
return rv;
|
||||
}
|
||||
|
||||
//NS_IMPL_BOOL_ATTR(nsHTMLOptionElement, DefaultSelected, defaultselected)
|
||||
|
||||
@ -74,8 +74,6 @@ NS_NewTitledButtonFrame ( nsIFrame*& aNewFrame );
|
||||
*/
|
||||
#endif
|
||||
|
||||
//#define FRAMEBASED_COMPONENTS 1 // This is temporary please leave in for now - rods
|
||||
|
||||
//static NS_DEFINE_IID(kIStyleRuleIID, NS_ISTYLE_RULE_IID);
|
||||
static NS_DEFINE_IID(kIStyleFrameConstructionIID, NS_ISTYLE_FRAME_CONSTRUCTION_IID);
|
||||
static NS_DEFINE_IID(kIHTMLTableCellElementIID, NS_IHTMLTABLECELLELEMENT_IID);
|
||||
@ -1719,89 +1717,118 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresContext* aPresContext,
|
||||
nsAbsoluteItems& aAbsoluteItems,
|
||||
nsIFrame*& aNewFrame,
|
||||
PRBool & aProcessChildren,
|
||||
PRBool & aIsAbsolutelyPositioned,
|
||||
PRBool & aFrameHasBeenInitialized)
|
||||
PRBool aIsAbsolutelyPositioned,
|
||||
PRBool & aFrameHasBeenInitialized,
|
||||
PRBool aIsFixedPositioned,
|
||||
nsAbsoluteItems& aFixedItems)
|
||||
{
|
||||
#ifdef FRAMEBASED_COMPONENTS
|
||||
nsresult rv = NS_OK;
|
||||
nsIDOMHTMLSelectElement* select = nsnull;
|
||||
PRBool multiple = PR_FALSE;
|
||||
nsresult result = aContent->QueryInterface(kIDOMHTMLSelectElementIID, (void**)&select);
|
||||
if (NS_OK == result) {
|
||||
result = select->GetMultiple(&multiple); // XXX This is wrong!
|
||||
if (!multiple) {
|
||||
nsIFrame * comboboxFrame;
|
||||
rv = NS_NewComboboxControlFrame(comboboxFrame);
|
||||
nsIComboboxControlFrame* comboBox;
|
||||
if (NS_OK == comboboxFrame->QueryInterface(kIComboboxControlFrameIID, (void**)&comboBox)) {
|
||||
nsWidgetRendering mode;
|
||||
aPresContext->GetWidgetRenderingMode(&mode);
|
||||
//XXX: When frame-based rendering works uncomment this and remove the line below
|
||||
// if (eWidgetRendering_Gfx == mode) {
|
||||
if (0) {
|
||||
nsIDOMHTMLSelectElement* select = nsnull;
|
||||
PRBool multiple = PR_FALSE;
|
||||
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)) {
|
||||
|
||||
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, PR_TRUE, PR_TRUE);
|
||||
} else {
|
||||
nsIFrame * listFrame;
|
||||
rv = NS_NewListControlFrame(listFrame);
|
||||
aNewFrame = listFrame;
|
||||
InitializeScrollFrame(listFrame, aPresContext, aContent, aParentFrame, aStyleContext,
|
||||
aAbsoluteItems, aNewFrame, aFixedItems, aIsAbsolutelyPositioned, PR_FALSE, 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
|
||||
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
|
||||
nsIStyleContext* visiblePseudoStyle = aPresContext->ResolvePseudoStyleContextFor
|
||||
(aContent, nsHTMLAtoms::dropDownVisible, aStyleContext);
|
||||
nsIStyleContext* hiddenPseudoStyle = aPresContext->ResolvePseudoStyleContextFor
|
||||
(aContent, nsHTMLAtoms::dropDownHidden, aStyleContext);
|
||||
nsIStyleContext* outPseudoStyle = aPresContext->ResolvePseudoStyleContextFor
|
||||
(aContent, nsHTMLAtoms::dropDownBtnOut, aStyleContext);
|
||||
nsIStyleContext* pressPseudoStyle = aPresContext->ResolvePseudoStyleContextFor
|
||||
(aContent, nsHTMLAtoms::dropDownBtnPressed, aStyleContext);
|
||||
|
||||
comboBox->SetDropDownStyleContexts(visiblePseudoStyle, hiddenPseudoStyle);
|
||||
comboBox->SetButtonStyleContexts(outPseudoStyle, pressPseudoStyle);
|
||||
|
||||
aProcessChildren = PR_FALSE;
|
||||
nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, listFrame,
|
||||
aStyleContext, PR_TRUE);
|
||||
aNewFrame = comboboxFrame;
|
||||
// Set flag so the events go to the listFrame not child frames.
|
||||
nsIView *listView;
|
||||
listFrame->GetView(&listView);
|
||||
NS_ASSERTION(nsnull != listView,"ListFrame's view is nsnull");
|
||||
listView->SetViewFlags(NS_VIEW_FLAG_DONT_CHECK_CHILDREN);
|
||||
aFrameHasBeenInitialized = PR_TRUE;
|
||||
}
|
||||
|
||||
NS_RELEASE(select);
|
||||
} else {
|
||||
nsIFrame * listFrame;
|
||||
rv = NS_NewListControlFrame(listFrame);
|
||||
aNewFrame = listFrame;
|
||||
InitializeScrollFrame(listFrame, aPresContext, aContent, aParentFrame, aStyleContext,
|
||||
aAbsoluteItems, aNewFrame, aIsAbsolutelyPositioned, PR_TRUE);
|
||||
aFrameHasBeenInitialized = PR_TRUE;
|
||||
rv = NS_NewSelectControlFrame(aNewFrame);
|
||||
}
|
||||
NS_RELEASE(select);
|
||||
} else {
|
||||
rv = NS_NewSelectControlFrame(aNewFrame);
|
||||
}
|
||||
else {
|
||||
// Not frame based. Use a frame which creates a native widget instead.
|
||||
rv = NS_NewSelectControlFrame(aNewFrame);
|
||||
}
|
||||
|
||||
#else
|
||||
nsresult rv = NS_NewSelectControlFrame(aNewFrame);
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsCSSFrameConstructor::ConstructFrameByTag(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent,
|
||||
@ -1881,7 +1908,8 @@ nsCSSFrameConstructor::ConstructFrameByTag(nsIPresContext* aPresContext,
|
||||
aTag, aStyleContext, aAbsoluteItems,
|
||||
newFrame, processChildren,
|
||||
isAbsolutelyPositioned,
|
||||
frameHasBeenInitialized);
|
||||
frameHasBeenInitialized,
|
||||
isFixedPositioned, aFixedItems);
|
||||
}
|
||||
else if (nsHTMLAtoms::applet == aTag) {
|
||||
isReplaced = PR_TRUE;
|
||||
|
||||
@ -303,8 +303,10 @@ protected:
|
||||
nsAbsoluteItems& aAbsoluteItems,
|
||||
nsIFrame*& aNewFrame,
|
||||
PRBool & aProcessChildren,
|
||||
PRBool & aIsAbsolutelyPositioned,
|
||||
PRBool & aFrameHasBeenInitialized);
|
||||
PRBool aIsAbsolutelyPositioned,
|
||||
PRBool & aFrameHasBeenInitialized,
|
||||
PRBool aIsFixedPositioned,
|
||||
nsAbsoluteItems& aFixedItems);
|
||||
|
||||
nsresult ConstructFrameByTag(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent,
|
||||
|
||||
@ -194,6 +194,10 @@ nsPresContext::GetUserPreferences()
|
||||
mCompatibilityMode = (enum nsCompatibility)prefInt; // bad cast
|
||||
}
|
||||
|
||||
if (NS_OK == mPrefs->GetIntPref("nglayout.widget.mode", &prefInt)) {
|
||||
mWidgetRenderingMode = (enum nsWidgetRendering)prefInt; // bad cast
|
||||
}
|
||||
|
||||
PRBool usePrefColors = PR_TRUE;
|
||||
#ifdef _WIN32
|
||||
XP_Bool boolPref;
|
||||
@ -319,6 +323,7 @@ nsPresContext::GetCompatibilityMode(nsCompatibility* aResult)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::SetCompatibilityMode(nsCompatibility aMode)
|
||||
{
|
||||
@ -326,6 +331,27 @@ nsPresContext::SetCompatibilityMode(nsCompatibility aMode)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::GetWidgetRenderingMode(nsWidgetRendering* aResult)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aResult, "null ptr");
|
||||
if (nsnull == aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*aResult = mWidgetRenderingMode;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::SetWidgetRenderingMode(nsWidgetRendering aMode)
|
||||
{
|
||||
mWidgetRenderingMode = aMode;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::GetBaseURL(nsIURL** aResult)
|
||||
{
|
||||
|
||||
@ -50,6 +50,11 @@ enum nsCompatibility {
|
||||
eCompatibility_NavQuirks = 2
|
||||
};
|
||||
|
||||
enum nsWidgetRendering {
|
||||
eWidgetRendering_Native = 1,
|
||||
eWidgetRendering_Gfx = 2
|
||||
};
|
||||
|
||||
// An interface for presentation contexts. Presentation contexts are
|
||||
// objects that provide an outer context for a presentation shell.
|
||||
class nsIPresContext : public nsISupports {
|
||||
@ -86,6 +91,12 @@ public:
|
||||
NS_IMETHOD GetCompatibilityMode(nsCompatibility* aModeResult) = 0;
|
||||
NS_IMETHOD SetCompatibilityMode(nsCompatibility aMode) = 0;
|
||||
|
||||
/**
|
||||
* Access the widget rendering mode for this context
|
||||
*/
|
||||
NS_IMETHOD GetWidgetRenderingMode(nsWidgetRendering* aModeResult) = 0;
|
||||
NS_IMETHOD SetWidgetRenderingMode(nsWidgetRendering aMode) = 0;
|
||||
|
||||
/**
|
||||
* Get base url for presentation
|
||||
*/
|
||||
|
||||
@ -50,6 +50,11 @@ enum nsCompatibility {
|
||||
eCompatibility_NavQuirks = 2
|
||||
};
|
||||
|
||||
enum nsWidgetRendering {
|
||||
eWidgetRendering_Native = 1,
|
||||
eWidgetRendering_Gfx = 2
|
||||
};
|
||||
|
||||
// An interface for presentation contexts. Presentation contexts are
|
||||
// objects that provide an outer context for a presentation shell.
|
||||
class nsIPresContext : public nsISupports {
|
||||
@ -86,6 +91,12 @@ public:
|
||||
NS_IMETHOD GetCompatibilityMode(nsCompatibility* aModeResult) = 0;
|
||||
NS_IMETHOD SetCompatibilityMode(nsCompatibility aMode) = 0;
|
||||
|
||||
/**
|
||||
* Access the widget rendering mode for this context
|
||||
*/
|
||||
NS_IMETHOD GetWidgetRenderingMode(nsWidgetRendering* aModeResult) = 0;
|
||||
NS_IMETHOD SetWidgetRenderingMode(nsWidgetRendering aMode) = 0;
|
||||
|
||||
/**
|
||||
* Get base url for presentation
|
||||
*/
|
||||
|
||||
@ -50,6 +50,11 @@ enum nsCompatibility {
|
||||
eCompatibility_NavQuirks = 2
|
||||
};
|
||||
|
||||
enum nsWidgetRendering {
|
||||
eWidgetRendering_Native = 1,
|
||||
eWidgetRendering_Gfx = 2
|
||||
};
|
||||
|
||||
// An interface for presentation contexts. Presentation contexts are
|
||||
// objects that provide an outer context for a presentation shell.
|
||||
class nsIPresContext : public nsISupports {
|
||||
@ -86,6 +91,12 @@ public:
|
||||
NS_IMETHOD GetCompatibilityMode(nsCompatibility* aModeResult) = 0;
|
||||
NS_IMETHOD SetCompatibilityMode(nsCompatibility aMode) = 0;
|
||||
|
||||
/**
|
||||
* Access the widget rendering mode for this context
|
||||
*/
|
||||
NS_IMETHOD GetWidgetRenderingMode(nsWidgetRendering* aModeResult) = 0;
|
||||
NS_IMETHOD SetWidgetRenderingMode(nsWidgetRendering aMode) = 0;
|
||||
|
||||
/**
|
||||
* Get base url for presentation
|
||||
*/
|
||||
|
||||
@ -194,6 +194,10 @@ nsPresContext::GetUserPreferences()
|
||||
mCompatibilityMode = (enum nsCompatibility)prefInt; // bad cast
|
||||
}
|
||||
|
||||
if (NS_OK == mPrefs->GetIntPref("nglayout.widget.mode", &prefInt)) {
|
||||
mWidgetRenderingMode = (enum nsWidgetRendering)prefInt; // bad cast
|
||||
}
|
||||
|
||||
PRBool usePrefColors = PR_TRUE;
|
||||
#ifdef _WIN32
|
||||
XP_Bool boolPref;
|
||||
@ -319,6 +323,7 @@ nsPresContext::GetCompatibilityMode(nsCompatibility* aResult)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::SetCompatibilityMode(nsCompatibility aMode)
|
||||
{
|
||||
@ -326,6 +331,27 @@ nsPresContext::SetCompatibilityMode(nsCompatibility aMode)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::GetWidgetRenderingMode(nsWidgetRendering* aResult)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aResult, "null ptr");
|
||||
if (nsnull == aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*aResult = mWidgetRenderingMode;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::SetWidgetRenderingMode(nsWidgetRendering aMode)
|
||||
{
|
||||
mWidgetRenderingMode = aMode;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::GetBaseURL(nsIURL** aResult)
|
||||
{
|
||||
|
||||
@ -41,6 +41,8 @@ public:
|
||||
NS_IMETHOD GetPrefs(nsIPref** aPrefsResult);
|
||||
NS_IMETHOD GetCompatibilityMode(nsCompatibility* aModeResult);
|
||||
NS_IMETHOD SetCompatibilityMode(nsCompatibility aMode);
|
||||
NS_IMETHOD GetWidgetRenderingMode(nsWidgetRendering* aModeResult);
|
||||
NS_IMETHOD SetWidgetRenderingMode(nsWidgetRendering aMode);
|
||||
NS_IMETHOD GetBaseURL(nsIURL** aURLResult);
|
||||
NS_IMETHOD GetMedium(nsIAtom** aMediumResult) = 0;
|
||||
NS_IMETHOD ResolveStyleContextFor(nsIContent* aContent,
|
||||
@ -112,6 +114,7 @@ protected:
|
||||
nsVoidArray mImageLoaders;
|
||||
nsIEventStateManager* mEventManager;
|
||||
nsCompatibility mCompatibilityMode;
|
||||
nsWidgetRendering mWidgetRenderingMode;
|
||||
nsIURL* mBaseURL;
|
||||
PRBool mStopped;
|
||||
|
||||
|
||||
@ -61,7 +61,6 @@ static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
|
||||
static NS_DEFINE_IID(kIViewIID, NS_IVIEW_IID);
|
||||
static NS_DEFINE_IID(kIDOMHTMLInputElementIID, NS_IDOMHTMLINPUTELEMENT_IID);
|
||||
|
||||
|
||||
nsFormControlFrame::nsFormControlFrame()
|
||||
: nsLeafFrame()
|
||||
{
|
||||
@ -234,12 +233,14 @@ nsFormControlFrame::Reflow(nsIPresContext& aPresContext,
|
||||
dx->SupportsNativeWidgets(requiresWidget);
|
||||
}
|
||||
|
||||
#ifdef NS_GFX_RENDER_FORM_ELEMENTS
|
||||
// Check with the frame to see if requires a widget to render
|
||||
if (PR_TRUE == requiresWidget) {
|
||||
RequiresWidget(requiresWidget);
|
||||
nsWidgetRendering mode;
|
||||
aPresContext.GetWidgetRenderingMode(&mode);
|
||||
if (eWidgetRendering_Gfx == mode) {
|
||||
// Check with the frame to see if requires a widget to render
|
||||
if (PR_TRUE == requiresWidget) {
|
||||
RequiresWidget(requiresWidget);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
GetDesiredSize(&aPresContext, aReflowState, aDesiredSize, mWidgetSize);
|
||||
|
||||
|
||||
@ -36,12 +36,6 @@ class nsFormFrame;
|
||||
#define CSS_NOTSET -1
|
||||
#define ATTR_NOTSET -1
|
||||
|
||||
// Defining this causes some of the form elements to be rendered
|
||||
// using GFX calls, rather than creating a widget. Undefining it
|
||||
// causes widgets to be used for form elements. @see RequiresWidget method
|
||||
// to see which widgets will obey this directive.
|
||||
//#define NS_GFX_RENDER_FORM_ELEMENTS
|
||||
|
||||
/**
|
||||
* nsFormControlFrame is the base class for frames of form controls. It
|
||||
* provides a uniform way of creating widgets, resizing, and painting.
|
||||
|
||||
@ -74,6 +74,8 @@ const char * kNormal = "";
|
||||
const char * kSelected = "SELECTED";
|
||||
const char * kSelectedFocus = "SELECTEDFOCUS";
|
||||
|
||||
const char * kMozSelected = "-moz-option-selected";
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
|
||||
static NS_DEFINE_IID(kIFormControlFrameIID, NS_IFORMCONTROLFRAME_IID);
|
||||
@ -437,7 +439,8 @@ PRInt32 nsListControlFrame::SetContentSelected(nsIFrame * aHitFrame,
|
||||
nsIContent* content;
|
||||
kid->GetContent(&content);
|
||||
aHitContent = content;
|
||||
aHitContent->SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::kClass, (aIsSelected?kSelectedFocus:kNormal), PR_TRUE);
|
||||
nsCOMPtr<nsIAtom> selectedAtom ( dont_QueryInterface(NS_NewAtom(kMozSelected)) );
|
||||
aHitContent->SetAttribute(kNameSpaceID_None, selectedAtom, "", PR_TRUE);
|
||||
return index;
|
||||
}
|
||||
kid->GetNextSibling(&kid);
|
||||
@ -569,12 +572,14 @@ NS_IMETHODIMP nsListControlFrame::HandleLikeListEvent(nsIPresContext& aPresConte
|
||||
}
|
||||
} else {
|
||||
if (nsnull != mSelectedContent) {
|
||||
mSelectedContent->SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::kClass, kNormal, PR_TRUE);
|
||||
nsCOMPtr<nsIAtom> selectedAtom ( dont_QueryInterface(NS_NewAtom(kMozSelected)) );
|
||||
mSelectedContent->UnsetAttribute(kNameSpaceID_None, selectedAtom, PR_TRUE);
|
||||
//XXX: This needs to a set a psuedo attribute instead mSelectedContent->SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::kClass, kNormal, PR_TRUE);
|
||||
NS_RELEASE(mSelectedContent);
|
||||
}
|
||||
}
|
||||
mIsFrameSelected[mSelectedIndex] = selected;
|
||||
//mHitContent->SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::kClass, (selected?kSelectedFocus:kNormal), PR_TRUE);
|
||||
//XXX mHitContent->SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::kClass, (selected?kSelectedFocus:kNormal), PR_TRUE);
|
||||
mSelectedContent = mHitContent;
|
||||
mSelectedFrame = mHitFrame;
|
||||
aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
@ -694,6 +699,7 @@ NS_IMETHODIMP nsListControlFrame::HandleEvent(nsIPresContext& aPresContext,
|
||||
} else {
|
||||
printf("Mouse in ListFrame <UNKNOWN> [%d]\n", aEvent->message);
|
||||
}*/
|
||||
|
||||
if (nsEventStatus_eConsumeNoDefault == aEventStatus) {
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1086,7 +1092,7 @@ nsListControlFrame::InitializeFromContent(PRBool aDoDisplay)
|
||||
if (result == NS_OK) {
|
||||
PRBool selected;
|
||||
option->GetDefaultSelected(&selected);
|
||||
option->GetSelected(&selected);
|
||||
//XXX: Remove, why is selected queried twice here? option->GetSelected(&selected);
|
||||
mIsFrameSelected[i] = selected;
|
||||
|
||||
if (mInDropDownMode) {
|
||||
@ -1103,7 +1109,10 @@ nsListControlFrame::InitializeFromContent(PRBool aDoDisplay)
|
||||
}
|
||||
} else {
|
||||
if (selected && aDoDisplay) {
|
||||
content->SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::kClass, (selected?kSelected:kNormal), PR_TRUE);
|
||||
// XXX: Here we introduce a new -moz-option-selected attribute so a attribute
|
||||
// selecitor n the ua.css can change the style when the option is selected.
|
||||
nsCOMPtr<nsIAtom> selectedAtom ( dont_QueryInterface(NS_NewAtom(kMozSelected)));
|
||||
content->SetAttribute(kNameSpaceID_None, selectedAtom, "", PR_TRUE);
|
||||
}
|
||||
}
|
||||
NS_RELEASE(option);
|
||||
|
||||
@ -198,7 +198,8 @@ NS_IMETHODIMP
|
||||
nsHTMLOptionElement::GetSelected(PRBool* aValue)
|
||||
{
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
if (NS_OK == GetPrimaryFrame(formControlFrame)) {
|
||||
nsresult rv = GetPrimaryFrame(formControlFrame);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PRInt32 index;
|
||||
if (NS_OK == GetIndex(&index)) {
|
||||
nsString value;
|
||||
@ -211,7 +212,7 @@ nsHTMLOptionElement::GetSelected(PRBool* aValue)
|
||||
}
|
||||
NS_RELEASE(formControlFrame);
|
||||
}
|
||||
return NS_OK;
|
||||
return rv;
|
||||
}
|
||||
|
||||
//NS_IMPL_BOOL_ATTR(nsHTMLOptionElement, DefaultSelected, defaultselected)
|
||||
|
||||
@ -576,11 +576,18 @@ select {
|
||||
}
|
||||
option {
|
||||
}
|
||||
|
||||
option.selected {
|
||||
border: 1px solid rgb(0,0,128);
|
||||
background-color: rgb(0,0,128);
|
||||
color: rgb(255,255,255);
|
||||
}
|
||||
|
||||
option[-moz-option-selected] {
|
||||
color:blue;
|
||||
background-color:green;
|
||||
}
|
||||
|
||||
option.selectedfocus {
|
||||
border: 1px dotted white;
|
||||
background-color: rgb(0,0,128);
|
||||
|
||||
@ -319,21 +319,23 @@ nsButtonControlFrame::GetDesiredSize(nsIPresContext* aPresContext,
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
|
||||
nsWidgetRendering mode;
|
||||
aPresContext->GetWidgetRenderingMode(&mode);
|
||||
|
||||
if (NS_FORM_INPUT_HIDDEN == type) { // there is no physical rep
|
||||
aDesiredLayoutSize.width = 0;
|
||||
aDesiredLayoutSize.height = 0;
|
||||
aDesiredLayoutSize.ascent = 0;
|
||||
aDesiredLayoutSize.descent = 0;
|
||||
} else {
|
||||
#ifdef NS_GFX_RENDER_FORM_ELEMENTS
|
||||
nsCOMPtr<nsIStyleContext> outlineStyle( dont_QueryInterface(mStyleContext) );
|
||||
nsCOMPtr<nsIAtom> sbAtom ( dont_QueryInterface(NS_NewAtom(":button-outline")) );
|
||||
aPresContext->ProbePseudoStyleContextFor(mContent, sbAtom, mStyleContext, PR_FALSE, getter_AddRefs(outlineStyle));
|
||||
|
||||
const nsStyleSpacing* outline = (const nsStyleSpacing*)outlineStyle->GetStyleData(eStyleStruct_Spacing);
|
||||
nsMargin outlineBorder;
|
||||
outline->CalcBorderFor(this, outlineBorder);
|
||||
#endif
|
||||
nsMargin outlineBorder;
|
||||
if (eWidgetRendering_Gfx == mode) {
|
||||
nsCOMPtr<nsIStyleContext> outlineStyle( dont_QueryInterface(mStyleContext));
|
||||
nsCOMPtr<nsIAtom> sbAtom ( dont_QueryInterface(NS_NewAtom(":button-outline")) );
|
||||
aPresContext->ProbePseudoStyleContextFor(mContent, sbAtom, mStyleContext, PR_FALSE, getter_AddRefs(outlineStyle));
|
||||
const nsStyleSpacing* outline = (const nsStyleSpacing*)outlineStyle->GetStyleData(eStyleStruct_Spacing);
|
||||
outline->CalcBorderFor(this, outlineBorder);
|
||||
}
|
||||
nsSize styleSize;
|
||||
GetStyleSize(*aPresContext, aReflowState, styleSize);
|
||||
// a browse button shares its style context with its parent nsInputFile
|
||||
@ -359,16 +361,16 @@ nsButtonControlFrame::GetDesiredSize(nsIPresContext* aPresContext,
|
||||
aDesiredLayoutSize.maxElementSize->width = minSize.width;
|
||||
aDesiredLayoutSize.maxElementSize->height = minSize.height;
|
||||
}
|
||||
#ifdef NS_GFX_RENDER_FORM_ELEMENTS
|
||||
nscoord horOutline = outlineBorder.left + outlineBorder.right;
|
||||
nscoord verOutline = outlineBorder.top + outlineBorder.bottom;
|
||||
aDesiredLayoutSize.width += horOutline;
|
||||
aDesiredLayoutSize.height += verOutline;
|
||||
if (aDesiredLayoutSize.maxElementSize) {
|
||||
aDesiredLayoutSize.maxElementSize->width += horOutline;
|
||||
aDesiredLayoutSize.maxElementSize->height += verOutline;
|
||||
if (eWidgetRendering_Gfx == mode) {
|
||||
nscoord horOutline = outlineBorder.left + outlineBorder.right;
|
||||
nscoord verOutline = outlineBorder.top + outlineBorder.bottom;
|
||||
aDesiredLayoutSize.width += horOutline;
|
||||
aDesiredLayoutSize.height += verOutline;
|
||||
if (aDesiredLayoutSize.maxElementSize) {
|
||||
aDesiredLayoutSize.maxElementSize->width += horOutline;
|
||||
aDesiredLayoutSize.maxElementSize->height += verOutline;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
aDesiredWidgetSize.width = aDesiredLayoutSize.width;
|
||||
@ -468,10 +470,12 @@ nsButtonControlFrame::HandleEvent(nsIPresContext& aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus& aEventStatus)
|
||||
{
|
||||
|
||||
#ifndef NS_GFX_RENDER_FORM_ELEMENTS
|
||||
return nsFormControlFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
#else
|
||||
nsWidgetRendering mode;
|
||||
aPresContext.GetWidgetRenderingMode(&mode);
|
||||
|
||||
if (eWidgetRendering_Native == mode) {
|
||||
return nsFormControlFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
}
|
||||
|
||||
// if disabled do nothing
|
||||
if (nsFormFrame::GetDisabled(this)) {
|
||||
@ -501,8 +505,7 @@ nsButtonControlFrame::HandleEvent(nsIPresContext& aPresContext,
|
||||
if (mPressed)
|
||||
mContent->SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::kClass, "PRESSED", PR_TRUE);
|
||||
else
|
||||
mContent->SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::kClass, "ROLLOVER", PR_TRUE);
|
||||
|
||||
mContent->SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::kClass, "ROLLOVER", PR_TRUE);
|
||||
break;
|
||||
case NS_MOUSE_LEFT_BUTTON_DOWN:
|
||||
mGotFocus = PR_TRUE;
|
||||
@ -541,7 +544,6 @@ nsButtonControlFrame::HandleEvent(nsIPresContext& aPresContext,
|
||||
|
||||
return NS_OK;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@ -165,32 +165,31 @@ nsCheckboxControlFrame::GetCheckboxSize(float aPixToTwip) const
|
||||
}
|
||||
|
||||
void
|
||||
nsCheckboxControlFrame::GetDesiredSize(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsHTMLReflowMetrics& aDesiredLayoutSize,
|
||||
nsSize& aDesiredWidgetSize)
|
||||
nsCheckboxControlFrame::GetDesiredSize(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsHTMLReflowMetrics& aDesiredLayoutSize,
|
||||
nsSize& aDesiredWidgetSize)
|
||||
{
|
||||
float p2t;
|
||||
aPresContext->GetScaledPixelsToTwips(&p2t);
|
||||
#ifndef NS_GFX_RENDER_FORM_ELEMENTS
|
||||
aDesiredWidgetSize.width = GetCheckboxSize(p2t);
|
||||
aDesiredWidgetSize.height = aDesiredWidgetSize.width;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef NS_GFX_RENDER_FORM_ELEMENTS
|
||||
nsFormControlFrame::GetDesiredSize(aPresContext, aReflowState,
|
||||
aDesiredLayoutSize, aDesiredWidgetSize);
|
||||
#else
|
||||
aDesiredLayoutSize.width = aDesiredWidgetSize.width;
|
||||
aDesiredLayoutSize.height = aDesiredWidgetSize.height;
|
||||
aDesiredLayoutSize.ascent = aDesiredLayoutSize.height;
|
||||
aDesiredLayoutSize.descent = 0;
|
||||
if (aDesiredLayoutSize.maxElementSize) {
|
||||
aDesiredLayoutSize.maxElementSize->width = aDesiredLayoutSize.width;
|
||||
aDesiredLayoutSize.maxElementSize->height = aDesiredLayoutSize.height;
|
||||
nsWidgetRendering mode;
|
||||
aPresContext->GetWidgetRenderingMode(&mode);
|
||||
if (eWidgetRendering_Gfx == mode) {
|
||||
nsFormControlFrame::GetDesiredSize(aPresContext, aReflowState,
|
||||
aDesiredLayoutSize, aDesiredWidgetSize);
|
||||
} else {
|
||||
aDesiredWidgetSize.width = GetCheckboxSize(p2t);
|
||||
aDesiredWidgetSize.height = aDesiredWidgetSize.width;
|
||||
aDesiredLayoutSize.width = aDesiredWidgetSize.width;
|
||||
aDesiredLayoutSize.height = aDesiredWidgetSize.height;
|
||||
aDesiredLayoutSize.ascent = aDesiredLayoutSize.height;
|
||||
aDesiredLayoutSize.descent = 0;
|
||||
if (aDesiredLayoutSize.maxElementSize) {
|
||||
aDesiredLayoutSize.maxElementSize->width = aDesiredLayoutSize.width;
|
||||
aDesiredLayoutSize.maxElementSize->height = aDesiredLayoutSize.height;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -61,7 +61,6 @@ static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
|
||||
static NS_DEFINE_IID(kIViewIID, NS_IVIEW_IID);
|
||||
static NS_DEFINE_IID(kIDOMHTMLInputElementIID, NS_IDOMHTMLINPUTELEMENT_IID);
|
||||
|
||||
|
||||
nsFormControlFrame::nsFormControlFrame()
|
||||
: nsLeafFrame()
|
||||
{
|
||||
@ -234,12 +233,14 @@ nsFormControlFrame::Reflow(nsIPresContext& aPresContext,
|
||||
dx->SupportsNativeWidgets(requiresWidget);
|
||||
}
|
||||
|
||||
#ifdef NS_GFX_RENDER_FORM_ELEMENTS
|
||||
// Check with the frame to see if requires a widget to render
|
||||
if (PR_TRUE == requiresWidget) {
|
||||
RequiresWidget(requiresWidget);
|
||||
nsWidgetRendering mode;
|
||||
aPresContext.GetWidgetRenderingMode(&mode);
|
||||
if (eWidgetRendering_Gfx == mode) {
|
||||
// Check with the frame to see if requires a widget to render
|
||||
if (PR_TRUE == requiresWidget) {
|
||||
RequiresWidget(requiresWidget);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
GetDesiredSize(&aPresContext, aReflowState, aDesiredSize, mWidgetSize);
|
||||
|
||||
|
||||
@ -36,12 +36,6 @@ class nsFormFrame;
|
||||
#define CSS_NOTSET -1
|
||||
#define ATTR_NOTSET -1
|
||||
|
||||
// Defining this causes some of the form elements to be rendered
|
||||
// using GFX calls, rather than creating a widget. Undefining it
|
||||
// causes widgets to be used for form elements. @see RequiresWidget method
|
||||
// to see which widgets will obey this directive.
|
||||
//#define NS_GFX_RENDER_FORM_ELEMENTS
|
||||
|
||||
/**
|
||||
* nsFormControlFrame is the base class for frames of form controls. It
|
||||
* provides a uniform way of creating widgets, resizing, and painting.
|
||||
|
||||
@ -74,6 +74,8 @@ const char * kNormal = "";
|
||||
const char * kSelected = "SELECTED";
|
||||
const char * kSelectedFocus = "SELECTEDFOCUS";
|
||||
|
||||
const char * kMozSelected = "-moz-option-selected";
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
|
||||
static NS_DEFINE_IID(kIFormControlFrameIID, NS_IFORMCONTROLFRAME_IID);
|
||||
@ -437,7 +439,8 @@ PRInt32 nsListControlFrame::SetContentSelected(nsIFrame * aHitFrame,
|
||||
nsIContent* content;
|
||||
kid->GetContent(&content);
|
||||
aHitContent = content;
|
||||
aHitContent->SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::kClass, (aIsSelected?kSelectedFocus:kNormal), PR_TRUE);
|
||||
nsCOMPtr<nsIAtom> selectedAtom ( dont_QueryInterface(NS_NewAtom(kMozSelected)) );
|
||||
aHitContent->SetAttribute(kNameSpaceID_None, selectedAtom, "", PR_TRUE);
|
||||
return index;
|
||||
}
|
||||
kid->GetNextSibling(&kid);
|
||||
@ -569,12 +572,14 @@ NS_IMETHODIMP nsListControlFrame::HandleLikeListEvent(nsIPresContext& aPresConte
|
||||
}
|
||||
} else {
|
||||
if (nsnull != mSelectedContent) {
|
||||
mSelectedContent->SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::kClass, kNormal, PR_TRUE);
|
||||
nsCOMPtr<nsIAtom> selectedAtom ( dont_QueryInterface(NS_NewAtom(kMozSelected)) );
|
||||
mSelectedContent->UnsetAttribute(kNameSpaceID_None, selectedAtom, PR_TRUE);
|
||||
//XXX: This needs to a set a psuedo attribute instead mSelectedContent->SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::kClass, kNormal, PR_TRUE);
|
||||
NS_RELEASE(mSelectedContent);
|
||||
}
|
||||
}
|
||||
mIsFrameSelected[mSelectedIndex] = selected;
|
||||
//mHitContent->SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::kClass, (selected?kSelectedFocus:kNormal), PR_TRUE);
|
||||
//XXX mHitContent->SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::kClass, (selected?kSelectedFocus:kNormal), PR_TRUE);
|
||||
mSelectedContent = mHitContent;
|
||||
mSelectedFrame = mHitFrame;
|
||||
aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
@ -694,6 +699,7 @@ NS_IMETHODIMP nsListControlFrame::HandleEvent(nsIPresContext& aPresContext,
|
||||
} else {
|
||||
printf("Mouse in ListFrame <UNKNOWN> [%d]\n", aEvent->message);
|
||||
}*/
|
||||
|
||||
if (nsEventStatus_eConsumeNoDefault == aEventStatus) {
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1086,7 +1092,7 @@ nsListControlFrame::InitializeFromContent(PRBool aDoDisplay)
|
||||
if (result == NS_OK) {
|
||||
PRBool selected;
|
||||
option->GetDefaultSelected(&selected);
|
||||
option->GetSelected(&selected);
|
||||
//XXX: Remove, why is selected queried twice here? option->GetSelected(&selected);
|
||||
mIsFrameSelected[i] = selected;
|
||||
|
||||
if (mInDropDownMode) {
|
||||
@ -1103,7 +1109,10 @@ nsListControlFrame::InitializeFromContent(PRBool aDoDisplay)
|
||||
}
|
||||
} else {
|
||||
if (selected && aDoDisplay) {
|
||||
content->SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::kClass, (selected?kSelected:kNormal), PR_TRUE);
|
||||
// XXX: Here we introduce a new -moz-option-selected attribute so a attribute
|
||||
// selecitor n the ua.css can change the style when the option is selected.
|
||||
nsCOMPtr<nsIAtom> selectedAtom ( dont_QueryInterface(NS_NewAtom(kMozSelected)));
|
||||
content->SetAttribute(kNameSpaceID_None, selectedAtom, "", PR_TRUE);
|
||||
}
|
||||
}
|
||||
NS_RELEASE(option);
|
||||
|
||||
@ -102,24 +102,27 @@ nsRadioControlFrame::GetDesiredSize(nsIPresContext* aPresContext,
|
||||
nsHTMLReflowMetrics& aDesiredLayoutSize,
|
||||
nsSize& aDesiredWidgetSize)
|
||||
{
|
||||
#ifndef NS_GFX_RENDER_FORM_ELEMENTS
|
||||
float p2t;
|
||||
aPresContext->GetScaledPixelsToTwips(&p2t);
|
||||
aDesiredWidgetSize.width = GetRadioboxSize(p2t);
|
||||
aDesiredWidgetSize.height = aDesiredWidgetSize.width;
|
||||
|
||||
aDesiredLayoutSize.width = aDesiredWidgetSize.width;
|
||||
aDesiredLayoutSize.height = aDesiredWidgetSize.height;
|
||||
aDesiredLayoutSize.ascent = aDesiredLayoutSize.height;
|
||||
aDesiredLayoutSize.descent = 0;
|
||||
if (aDesiredLayoutSize.maxElementSize) {
|
||||
aDesiredLayoutSize.maxElementSize->width = aDesiredLayoutSize.width;
|
||||
aDesiredLayoutSize.maxElementSize->height = aDesiredLayoutSize.height;
|
||||
nsWidgetRendering mode;
|
||||
aPresContext->GetWidgetRenderingMode(&mode);
|
||||
if (eWidgetRendering_Native == mode) {
|
||||
float p2t;
|
||||
aPresContext->GetScaledPixelsToTwips(&p2t);
|
||||
aDesiredWidgetSize.width = GetRadioboxSize(p2t);
|
||||
aDesiredWidgetSize.height = aDesiredWidgetSize.width;
|
||||
|
||||
aDesiredLayoutSize.width = aDesiredWidgetSize.width;
|
||||
aDesiredLayoutSize.height = aDesiredWidgetSize.height;
|
||||
aDesiredLayoutSize.ascent = aDesiredLayoutSize.height;
|
||||
aDesiredLayoutSize.descent = 0;
|
||||
if (aDesiredLayoutSize.maxElementSize) {
|
||||
aDesiredLayoutSize.maxElementSize->width = aDesiredLayoutSize.width;
|
||||
aDesiredLayoutSize.maxElementSize->height = aDesiredLayoutSize.height;
|
||||
}
|
||||
} else {
|
||||
nsFormControlFrame::GetDesiredSize(aPresContext,aReflowState,aDesiredLayoutSize,
|
||||
aDesiredWidgetSize);
|
||||
}
|
||||
#else
|
||||
nsFormControlFrame::GetDesiredSize(aPresContext,aReflowState,aDesiredLayoutSize,
|
||||
aDesiredWidgetSize);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@ -74,8 +74,6 @@ NS_NewTitledButtonFrame ( nsIFrame*& aNewFrame );
|
||||
*/
|
||||
#endif
|
||||
|
||||
//#define FRAMEBASED_COMPONENTS 1 // This is temporary please leave in for now - rods
|
||||
|
||||
//static NS_DEFINE_IID(kIStyleRuleIID, NS_ISTYLE_RULE_IID);
|
||||
static NS_DEFINE_IID(kIStyleFrameConstructionIID, NS_ISTYLE_FRAME_CONSTRUCTION_IID);
|
||||
static NS_DEFINE_IID(kIHTMLTableCellElementIID, NS_IHTMLTABLECELLELEMENT_IID);
|
||||
@ -1719,89 +1717,118 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresContext* aPresContext,
|
||||
nsAbsoluteItems& aAbsoluteItems,
|
||||
nsIFrame*& aNewFrame,
|
||||
PRBool & aProcessChildren,
|
||||
PRBool & aIsAbsolutelyPositioned,
|
||||
PRBool & aFrameHasBeenInitialized)
|
||||
PRBool aIsAbsolutelyPositioned,
|
||||
PRBool & aFrameHasBeenInitialized,
|
||||
PRBool aIsFixedPositioned,
|
||||
nsAbsoluteItems& aFixedItems)
|
||||
{
|
||||
#ifdef FRAMEBASED_COMPONENTS
|
||||
nsresult rv = NS_OK;
|
||||
nsIDOMHTMLSelectElement* select = nsnull;
|
||||
PRBool multiple = PR_FALSE;
|
||||
nsresult result = aContent->QueryInterface(kIDOMHTMLSelectElementIID, (void**)&select);
|
||||
if (NS_OK == result) {
|
||||
result = select->GetMultiple(&multiple); // XXX This is wrong!
|
||||
if (!multiple) {
|
||||
nsIFrame * comboboxFrame;
|
||||
rv = NS_NewComboboxControlFrame(comboboxFrame);
|
||||
nsIComboboxControlFrame* comboBox;
|
||||
if (NS_OK == comboboxFrame->QueryInterface(kIComboboxControlFrameIID, (void**)&comboBox)) {
|
||||
nsWidgetRendering mode;
|
||||
aPresContext->GetWidgetRenderingMode(&mode);
|
||||
//XXX: When frame-based rendering works uncomment this and remove the line below
|
||||
// if (eWidgetRendering_Gfx == mode) {
|
||||
if (0) {
|
||||
nsIDOMHTMLSelectElement* select = nsnull;
|
||||
PRBool multiple = PR_FALSE;
|
||||
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)) {
|
||||
|
||||
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, PR_TRUE, PR_TRUE);
|
||||
} else {
|
||||
nsIFrame * listFrame;
|
||||
rv = NS_NewListControlFrame(listFrame);
|
||||
aNewFrame = listFrame;
|
||||
InitializeScrollFrame(listFrame, aPresContext, aContent, aParentFrame, aStyleContext,
|
||||
aAbsoluteItems, aNewFrame, aFixedItems, aIsAbsolutelyPositioned, PR_FALSE, 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
|
||||
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
|
||||
nsIStyleContext* visiblePseudoStyle = aPresContext->ResolvePseudoStyleContextFor
|
||||
(aContent, nsHTMLAtoms::dropDownVisible, aStyleContext);
|
||||
nsIStyleContext* hiddenPseudoStyle = aPresContext->ResolvePseudoStyleContextFor
|
||||
(aContent, nsHTMLAtoms::dropDownHidden, aStyleContext);
|
||||
nsIStyleContext* outPseudoStyle = aPresContext->ResolvePseudoStyleContextFor
|
||||
(aContent, nsHTMLAtoms::dropDownBtnOut, aStyleContext);
|
||||
nsIStyleContext* pressPseudoStyle = aPresContext->ResolvePseudoStyleContextFor
|
||||
(aContent, nsHTMLAtoms::dropDownBtnPressed, aStyleContext);
|
||||
|
||||
comboBox->SetDropDownStyleContexts(visiblePseudoStyle, hiddenPseudoStyle);
|
||||
comboBox->SetButtonStyleContexts(outPseudoStyle, pressPseudoStyle);
|
||||
|
||||
aProcessChildren = PR_FALSE;
|
||||
nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, listFrame,
|
||||
aStyleContext, PR_TRUE);
|
||||
aNewFrame = comboboxFrame;
|
||||
// Set flag so the events go to the listFrame not child frames.
|
||||
nsIView *listView;
|
||||
listFrame->GetView(&listView);
|
||||
NS_ASSERTION(nsnull != listView,"ListFrame's view is nsnull");
|
||||
listView->SetViewFlags(NS_VIEW_FLAG_DONT_CHECK_CHILDREN);
|
||||
aFrameHasBeenInitialized = PR_TRUE;
|
||||
}
|
||||
|
||||
NS_RELEASE(select);
|
||||
} else {
|
||||
nsIFrame * listFrame;
|
||||
rv = NS_NewListControlFrame(listFrame);
|
||||
aNewFrame = listFrame;
|
||||
InitializeScrollFrame(listFrame, aPresContext, aContent, aParentFrame, aStyleContext,
|
||||
aAbsoluteItems, aNewFrame, aIsAbsolutelyPositioned, PR_TRUE);
|
||||
aFrameHasBeenInitialized = PR_TRUE;
|
||||
rv = NS_NewSelectControlFrame(aNewFrame);
|
||||
}
|
||||
NS_RELEASE(select);
|
||||
} else {
|
||||
rv = NS_NewSelectControlFrame(aNewFrame);
|
||||
}
|
||||
else {
|
||||
// Not frame based. Use a frame which creates a native widget instead.
|
||||
rv = NS_NewSelectControlFrame(aNewFrame);
|
||||
}
|
||||
|
||||
#else
|
||||
nsresult rv = NS_NewSelectControlFrame(aNewFrame);
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsCSSFrameConstructor::ConstructFrameByTag(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent,
|
||||
@ -1881,7 +1908,8 @@ nsCSSFrameConstructor::ConstructFrameByTag(nsIPresContext* aPresContext,
|
||||
aTag, aStyleContext, aAbsoluteItems,
|
||||
newFrame, processChildren,
|
||||
isAbsolutelyPositioned,
|
||||
frameHasBeenInitialized);
|
||||
frameHasBeenInitialized,
|
||||
isFixedPositioned, aFixedItems);
|
||||
}
|
||||
else if (nsHTMLAtoms::applet == aTag) {
|
||||
isReplaced = PR_TRUE;
|
||||
|
||||
@ -303,8 +303,10 @@ protected:
|
||||
nsAbsoluteItems& aAbsoluteItems,
|
||||
nsIFrame*& aNewFrame,
|
||||
PRBool & aProcessChildren,
|
||||
PRBool & aIsAbsolutelyPositioned,
|
||||
PRBool & aFrameHasBeenInitialized);
|
||||
PRBool aIsAbsolutelyPositioned,
|
||||
PRBool & aFrameHasBeenInitialized,
|
||||
PRBool aIsFixedPositioned,
|
||||
nsAbsoluteItems& aFixedItems);
|
||||
|
||||
nsresult ConstructFrameByTag(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent,
|
||||
|
||||
@ -576,11 +576,18 @@ select {
|
||||
}
|
||||
option {
|
||||
}
|
||||
|
||||
option.selected {
|
||||
border: 1px solid rgb(0,0,128);
|
||||
background-color: rgb(0,0,128);
|
||||
color: rgb(255,255,255);
|
||||
}
|
||||
|
||||
option[-moz-option-selected] {
|
||||
color:blue;
|
||||
background-color:green;
|
||||
}
|
||||
|
||||
option.selectedfocus {
|
||||
border: 1px dotted white;
|
||||
background-color: rgb(0,0,128);
|
||||
|
||||
@ -777,7 +777,7 @@ NS_IMETHODIMP nsView :: HandleEvent(nsGUIEvent *event, PRUint32 aEventFlags,
|
||||
PRBool handledByChild = PR_FALSE;
|
||||
|
||||
//see if any of this view's children can process the event
|
||||
if (aStatus == nsEventStatus_eIgnore && !(mEventFlags & NS_VIEW_FLAG_DONT_CHECK_CHILDREN)) {
|
||||
if (aStatus == nsEventStatus_eIgnore && !(mVFlags & NS_VIEW_FLAG_DONT_CHECK_CHILDREN)) {
|
||||
PRInt32 numkids;
|
||||
nsRect trect;
|
||||
nscoord x, y;
|
||||
@ -1292,7 +1292,7 @@ void nsView :: List(FILE* out, PRInt32 aIndent) const
|
||||
|
||||
NS_IMETHODIMP nsView :: SetViewFlags(PRInt32 aFlags)
|
||||
{
|
||||
mVFlags &= aFlags;
|
||||
mVFlags |= aFlags;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -2872,6 +2872,15 @@ nsBrowserWindow::SetCompatibilityMode(PRBool aIsStandard)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsBrowserWindow::SetWidgetRenderingMode(PRBool aIsNative)
|
||||
{
|
||||
if (nsnull != mPrefs) {
|
||||
int32 prefInt = (aIsNative) ? eWidgetRendering_Native : eWidgetRendering_Gfx;
|
||||
mPrefs->SetIntPref("nglayout.widget.mode", prefInt);
|
||||
mPrefs->SavePrefFile();
|
||||
}
|
||||
}
|
||||
|
||||
nsEventStatus
|
||||
nsBrowserWindow::DispatchStyleMenu(PRInt32 aID)
|
||||
@ -2966,6 +2975,13 @@ nsBrowserWindow::DispatchStyleMenu(PRInt32 aID)
|
||||
SetCompatibilityMode(VIEWER_STANDARD_MODE == aID);
|
||||
result = nsEventStatus_eConsumeNoDefault;
|
||||
break;
|
||||
|
||||
case VIEWER_NATIVE_WIDGET_MODE:
|
||||
case VIEWER_GFX_WIDGET_MODE:
|
||||
SetWidgetRenderingMode(VIEWER_NATIVE_WIDGET_MODE == aID);
|
||||
result = nsEventStatus_eConsumeNoDefault;
|
||||
break;
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -176,6 +176,7 @@ public:
|
||||
#endif
|
||||
nsEventStatus DispatchStyleMenu(PRInt32 aID);
|
||||
void SetCompatibilityMode(PRBool aIsStandard);
|
||||
void SetWidgetRenderingMode(PRBool aIsNative);
|
||||
|
||||
nsEventStatus ProcessDialogEvent(nsGUIEvent *aEvent);
|
||||
|
||||
|
||||
@ -47,6 +47,7 @@
|
||||
#include "nsColor.h"
|
||||
#include "nsWidgetSupport.h"
|
||||
|
||||
|
||||
// XXX For font setting below
|
||||
#include "nsFont.h"
|
||||
#include "nsUnitConversion.h"
|
||||
|
||||
@ -111,6 +111,11 @@ VIEWER MENU DISCARDABLE
|
||||
MENUITEM "Nav Quirks", VIEWER_NAV_QUIRKS_MODE
|
||||
MENUITEM "Standard", VIEWER_STANDARD_MODE
|
||||
}
|
||||
POPUP "&Widget Rendering Mode Pref"
|
||||
{
|
||||
MENUITEM "Native", VIEWER_NATIVE_WIDGET_MODE
|
||||
MENUITEM "Gfx", VIEWER_GFX_WIDGET_MODE
|
||||
}
|
||||
}
|
||||
POPUP "&Tools"
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user