зеркало из https://github.com/mozilla/pjs.git
Changed GetVerticalInsidePading to take the PresContext to the method can use the cached LookAndFeel object
and it now uses the cached L&F obj
This commit is contained in:
Родитель
32eed904b7
Коммит
b8d329d0cf
|
@ -78,8 +78,6 @@ static NS_DEFINE_IID(kITextWidgetIID, NS_ITEXTWIDGET_IID);
|
|||
static NS_DEFINE_IID(kITextAreaWidgetIID, NS_ITEXTAREAWIDGET_IID);
|
||||
static NS_DEFINE_IID(kIDOMHTMLTextAreaElementIID, NS_IDOMHTMLTEXTAREAELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMHTMLInputElementIID, NS_IDOMHTMLINPUTELEMENT_IID);
|
||||
static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
||||
static NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID);
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIWebShellContainerIID, NS_IWEB_SHELL_CONTAINER_IID);
|
||||
|
@ -607,11 +605,10 @@ nsGfxTextControlFrame::PaintTextControl(nsIPresContext& aPresContext,
|
|||
nsRect rect(0, 0, mRect.width, mRect.height);
|
||||
if (eCompatibility_NavQuirks == mode) {
|
||||
nscoord borderTwips = 0;
|
||||
nsILookAndFeel * lookAndFeel;
|
||||
if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) {
|
||||
nsCOMPtr<nsILookAndFeel> lookAndFeel;
|
||||
if (NS_SUCCEEDED(aPresContext.GetLookAndFeel(getter_AddRefs(lookAndFeel)))) {
|
||||
PRInt32 tfBorder;
|
||||
lookAndFeel->GetMetric(nsILookAndFeel::eMetric_TextFieldBorder, tfBorder);
|
||||
NS_RELEASE(lookAndFeel);
|
||||
float p2t;
|
||||
aPresContext.GetScaledPixelsToTwips(&p2t);
|
||||
borderTwips = NSIntPixelsToTwips(tfBorder, p2t);
|
||||
|
@ -933,12 +930,25 @@ nsGfxTextControlFrame::Reflow(nsIPresContext& aPresContext,
|
|||
// Quirks mode will NOT obey CSS border and padding
|
||||
// GetDesiredSize calculates the size without CSS borders
|
||||
// the nsLeafFrame::Reflow will add in the borders
|
||||
if (eCompatibility_NavQuirks == mode) {
|
||||
GetDesiredSize(&aPresContext, aReflowState, aMetrics);
|
||||
aStatus = NS_FRAME_COMPLETE;
|
||||
if (NS_UNCONSTRAINEDSIZE != aReflowState.mComputedWidth &&
|
||||
NS_UNCONSTRAINEDSIZE != aReflowState.mComputedWidth) {
|
||||
aMetrics.width = aReflowState.mComputedWidth;
|
||||
aMetrics.height = aReflowState.mComputedHeight;
|
||||
} else {
|
||||
rv = nsLeafFrame::Reflow(aPresContext, aMetrics, aReflowState, aStatus);
|
||||
if (eCompatibility_NavQuirks == mode) {
|
||||
GetDesiredSize(&aPresContext, aReflowState, aMetrics);
|
||||
} else {
|
||||
rv = nsLeafFrame::Reflow(aPresContext, aMetrics, aReflowState, aStatus);
|
||||
}
|
||||
|
||||
if (NS_UNCONSTRAINEDSIZE != aReflowState.mComputedWidth) {
|
||||
aMetrics.width = aReflowState.mComputedWidth;
|
||||
}
|
||||
if (NS_UNCONSTRAINEDSIZE != aReflowState.mComputedWidth) {
|
||||
aMetrics.height = aReflowState.mComputedHeight;
|
||||
}
|
||||
}
|
||||
aStatus = NS_FRAME_COMPLETE;
|
||||
// Now resize the widget if there is one, in this case it is
|
||||
// the webshell for the editor
|
||||
if (!mDidInit) {
|
||||
|
@ -965,15 +975,14 @@ nsGfxTextControlFrame::Reflow(nsIPresContext& aPresContext,
|
|||
// otherwise it comes from style
|
||||
nsMargin border;
|
||||
if (eCompatibility_NavQuirks == mode) {
|
||||
nsILookAndFeel * lookAndFeel;
|
||||
if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) {
|
||||
nsCOMPtr<nsILookAndFeel> lookAndFeel;
|
||||
if (NS_SUCCEEDED(aPresContext.GetLookAndFeel(getter_AddRefs(lookAndFeel)))) {
|
||||
float p2t;
|
||||
aPresContext.GetPixelsToTwips(&p2t);
|
||||
PRInt32 borderSize;
|
||||
lookAndFeel->GetMetric(nsILookAndFeel::eMetric_TextFieldBorder, borderSize);
|
||||
nscoord borderTwips = NSIntPixelsToTwips(borderSize, p2t);
|
||||
border.SizeTo(borderTwips, borderTwips, borderTwips, borderTwips);
|
||||
NS_RELEASE(lookAndFeel);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -986,6 +995,11 @@ nsGfxTextControlFrame::Reflow(nsIPresContext& aPresContext,
|
|||
float t2p;
|
||||
aPresContext.GetTwipsToPixels(&t2p);
|
||||
|
||||
#ifdef DEBUG_rods
|
||||
printf ("nsGfxTextControlFrame::Reflow: size=%d,%d %d,%d\n\n",
|
||||
aMetrics.width, aMetrics.height, NSToCoordRound(aMetrics.width * t2p), NSToCoordRound(aMetrics.height * t2p));
|
||||
#endif
|
||||
|
||||
nsRect subBounds;
|
||||
|
||||
// XXX: the point here is to make a single-line edit field as wide as it wants to be,
|
||||
|
|
|
@ -27,11 +27,10 @@
|
|||
#include "nsWidgetsCID.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsStyleUtil.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIRadioIID, NS_IRADIOBUTTON_IID);
|
||||
static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
||||
static NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID);
|
||||
|
||||
#define NS_DEFAULT_RADIOBOX_SIZE 12
|
||||
|
||||
|
@ -54,13 +53,12 @@ NS_NewNativeRadioControlFrame(nsIFrame** aNewFrame)
|
|||
|
||||
|
||||
nscoord
|
||||
nsNativeRadioControlFrame::GetRadioboxSize(float aPixToTwip) const
|
||||
nsNativeRadioControlFrame::GetRadioboxSize(nsIPresContext* aPresContext, float aPixToTwip) const
|
||||
{
|
||||
nsILookAndFeel * lookAndFeel;
|
||||
PRInt32 radioboxSize = 0;
|
||||
if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) {
|
||||
nsCOMPtr<nsILookAndFeel> lookAndFeel;
|
||||
if (NS_SUCCEEDED(aPresContext->GetLookAndFeel(getter_AddRefs(lookAndFeel)))) {
|
||||
lookAndFeel->GetMetric(nsILookAndFeel::eMetric_RadioboxSize, radioboxSize);
|
||||
NS_RELEASE(lookAndFeel);
|
||||
}
|
||||
if (radioboxSize == 0)
|
||||
radioboxSize = NS_DEFAULT_RADIOBOX_SIZE;
|
||||
|
@ -69,9 +67,9 @@ nsNativeRadioControlFrame::GetRadioboxSize(float aPixToTwip) const
|
|||
|
||||
void
|
||||
nsNativeRadioControlFrame::GetDesiredSize(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsHTMLReflowMetrics& aDesiredLayoutSize,
|
||||
nsSize& aDesiredWidgetSize)
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsHTMLReflowMetrics& aDesiredLayoutSize,
|
||||
nsSize& aDesiredWidgetSize)
|
||||
{
|
||||
|
||||
nsWidgetRendering mode;
|
||||
|
@ -82,7 +80,7 @@ nsNativeRadioControlFrame::GetDesiredSize(nsIPresContext* aPresContext,
|
|||
} else {
|
||||
float p2t;
|
||||
aPresContext->GetScaledPixelsToTwips(&p2t);
|
||||
aDesiredWidgetSize.width = GetRadioboxSize(p2t);
|
||||
aDesiredWidgetSize.width = GetRadioboxSize(aPresContext, p2t);
|
||||
aDesiredWidgetSize.height = aDesiredWidgetSize.width;
|
||||
|
||||
aDesiredLayoutSize.width = aDesiredWidgetSize.width;
|
||||
|
|
|
@ -49,7 +49,7 @@ protected:
|
|||
virtual PRBool GetRadioState();
|
||||
virtual void SetRadioState(PRBool aValue);
|
||||
|
||||
virtual nscoord GetRadioboxSize(float aPixToTwip) const;
|
||||
virtual nscoord GetRadioboxSize(nsIPresContext* aPresContext, float aPixToTwip) const;
|
||||
virtual void GetDesiredSize(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsHTMLReflowMetrics& aDesiredLayoutSize,
|
||||
|
|
|
@ -64,8 +64,6 @@ static NS_DEFINE_IID(kComboBoxIID, NS_ICOMBOBOX_IID);
|
|||
static NS_DEFINE_IID(kListBoxIID, NS_ILISTBOX_IID);
|
||||
static NS_DEFINE_IID(kComboCID, NS_COMBOBOX_CID);
|
||||
static NS_DEFINE_IID(kListCID, NS_LISTBOX_CID);
|
||||
static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
||||
static NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID);
|
||||
static NS_DEFINE_IID(kISelectControlFrameIID, NS_ISELECTCONTROLFRAME_IID);
|
||||
|
||||
class nsOption;
|
||||
|
@ -95,7 +93,8 @@ public:
|
|||
|
||||
virtual nscoord GetVerticalBorderWidth(float aPixToTwip) const;
|
||||
virtual nscoord GetHorizontalBorderWidth(float aPixToTwip) const;
|
||||
virtual nscoord GetVerticalInsidePadding(float aPixToTwip,
|
||||
virtual nscoord GetVerticalInsidePadding(nsIPresContext& aPresContext,
|
||||
float aPixToTwip,
|
||||
nscoord aInnerHeight) const;
|
||||
virtual nscoord GetHorizontalInsidePadding(nsIPresContext& aPresContext,
|
||||
float aPixToTwip,
|
||||
|
@ -265,8 +264,9 @@ nsNativeSelectControlFrame::GetHorizontalBorderWidth(float aPixToTwip) const
|
|||
}
|
||||
|
||||
nscoord
|
||||
nsNativeSelectControlFrame::GetVerticalInsidePadding(float aPixToTwip,
|
||||
nscoord aInnerHeight) const
|
||||
nsNativeSelectControlFrame::GetVerticalInsidePadding(nsIPresContext& aPresContext,
|
||||
float aPixToTwip,
|
||||
nscoord aInnerHeight) const
|
||||
{
|
||||
// XXX NOTE: the enums eMetric_ListVerticalInsidePadding and eMetric_ListShouldUseVerticalInsidePadding
|
||||
// are ONLY needed because GTK is not using the "float" padding values and wants to only use an
|
||||
|
@ -281,13 +281,12 @@ nsNativeSelectControlFrame::GetVerticalInsidePadding(float aPixToTwip,
|
|||
float pad;
|
||||
PRInt32 padInside;
|
||||
PRInt32 shouldUsePadInside;
|
||||
nsILookAndFeel * lookAndFeel;
|
||||
if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) {
|
||||
nsCOMPtr<nsILookAndFeel> lookAndFeel;
|
||||
if (NS_SUCCEEDED(aPresContext.GetLookAndFeel(getter_AddRefs(lookAndFeel)))) {
|
||||
lookAndFeel->GetMetric(nsILookAndFeel::eMetricFloat_ListVerticalInsidePadding, pad);
|
||||
// These two (below) are really only needed for GTK
|
||||
lookAndFeel->GetMetric(nsILookAndFeel::eMetric_ListVerticalInsidePadding, padInside);
|
||||
lookAndFeel->GetMetric(nsILookAndFeel::eMetric_ListShouldUseVerticalInsidePadding, shouldUsePadInside);
|
||||
NS_RELEASE(lookAndFeel);
|
||||
}
|
||||
|
||||
if (1 == shouldUsePadInside) {
|
||||
|
@ -316,13 +315,12 @@ nsNativeSelectControlFrame::GetHorizontalInsidePadding(nsIPresContext& aPresCont
|
|||
float pad;
|
||||
PRInt32 padMin;
|
||||
PRInt32 shouldUsePadMin;
|
||||
nsILookAndFeel * lookAndFeel;
|
||||
if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) {
|
||||
nsCOMPtr<nsILookAndFeel> lookAndFeel;
|
||||
if (NS_SUCCEEDED(aPresContext.GetLookAndFeel(getter_AddRefs(lookAndFeel)))) {
|
||||
lookAndFeel->GetMetric(nsILookAndFeel::eMetricFloat_ListHorizontalInsidePadding, pad);
|
||||
lookAndFeel->GetMetric(nsILookAndFeel::eMetric_ListHorizontalInsideMinimumPadding, padMin);
|
||||
// This one (below) is really only needed for GTK
|
||||
lookAndFeel->GetMetric(nsILookAndFeel::eMetric_ListShouldUseHorizontalInsideMinimumPadding, shouldUsePadMin);
|
||||
NS_RELEASE(lookAndFeel);
|
||||
}
|
||||
|
||||
if (1 == shouldUsePadMin) {
|
||||
|
@ -360,9 +358,9 @@ nsNativeSelectControlFrame::GetCID()
|
|||
|
||||
void
|
||||
nsNativeSelectControlFrame::GetDesiredSize(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsHTMLReflowMetrics& aDesiredLayoutSize,
|
||||
nsSize& aDesiredWidgetSize)
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsHTMLReflowMetrics& aDesiredLayoutSize,
|
||||
nsSize& aDesiredWidgetSize)
|
||||
{
|
||||
nsIDOMHTMLCollection* options = GetOptions();
|
||||
if (!options)
|
||||
|
@ -458,11 +456,11 @@ nsNativeSelectControlFrame::GetDesiredSize(nsIPresContext* aPresContext
|
|||
|
||||
// XXX put this in widget library, combo boxes are fixed height (visible part)
|
||||
aDesiredLayoutSize.height = (mIsComboBox)
|
||||
? rowHeight + (2 * GetVerticalInsidePadding(p2t, rowHeight))
|
||||
? rowHeight + (2 * GetVerticalInsidePadding(*aPresContext, p2t, rowHeight))
|
||||
: desiredSize.height;
|
||||
if (aDesiredLayoutSize.maxElementSize) {
|
||||
aDesiredLayoutSize.maxElementSize->height = (mIsComboBox)
|
||||
? rowHeight + (2 * GetVerticalInsidePadding(p2t, rowHeight))
|
||||
? rowHeight + (2 * GetVerticalInsidePadding(*aPresContext, p2t, rowHeight))
|
||||
: minSize.height;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,8 +59,6 @@ static NS_DEFINE_IID(kComboBoxIID, NS_ICOMBOBOX_IID);
|
|||
static NS_DEFINE_IID(kListBoxIID, NS_ILISTBOX_IID);
|
||||
static NS_DEFINE_IID(kComboCID, NS_COMBOBOX_CID);
|
||||
static NS_DEFINE_IID(kListCID, NS_LISTBOX_CID);
|
||||
static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
||||
static NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID);
|
||||
|
||||
|
||||
class nsOption;
|
||||
|
@ -85,7 +83,8 @@ public:
|
|||
|
||||
virtual nscoord GetVerticalBorderWidth(float aPixToTwip) const;
|
||||
virtual nscoord GetHorizontalBorderWidth(float aPixToTwip) const;
|
||||
virtual nscoord GetVerticalInsidePadding(float aPixToTwip,
|
||||
virtual nscoord GetVerticalInsidePadding(nsIPresContext& aPresContext,
|
||||
float aPixToTwip,
|
||||
nscoord aInnerHeight) const;
|
||||
virtual nscoord GetHorizontalInsidePadding(nsIPresContext& aPresContext,
|
||||
float aPixToTwip,
|
||||
|
@ -208,7 +207,8 @@ nsSelectControlFrame::GetHorizontalBorderWidth(float aPixToTwip) const
|
|||
}
|
||||
|
||||
nscoord
|
||||
nsSelectControlFrame::GetVerticalInsidePadding(float aPixToTwip,
|
||||
nsSelectControlFrame::GetVerticalInsidePadding(nsIPresContext& aPresContext,
|
||||
float aPixToTwip,
|
||||
nscoord aInnerHeight) const
|
||||
{
|
||||
// XXX NOTE: the enums eMetric_ListVerticalInsidePadding and eMetric_ListShouldUseVerticalInsidePadding
|
||||
|
@ -224,8 +224,8 @@ nsSelectControlFrame::GetVerticalInsidePadding(float aPixToTwip,
|
|||
float pad;
|
||||
PRInt32 padInside;
|
||||
PRInt32 shouldUsePadInside;
|
||||
nsILookAndFeel * lookAndFeel;
|
||||
if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) {
|
||||
nsCOMPtr<nsILookAndFeel> lookAndFeel;
|
||||
if (NS_SUCCEEDED(aPresContext.GetLookAndFeel(getter_AddRefs(lookAndFeel)))) {
|
||||
lookAndFeel->GetMetric(nsILookAndFeel::eMetricFloat_ListVerticalInsidePadding, pad);
|
||||
// These two (below) are really only needed for GTK
|
||||
lookAndFeel->GetMetric(nsILookAndFeel::eMetric_ListVerticalInsidePadding, padInside);
|
||||
|
@ -259,8 +259,8 @@ nsSelectControlFrame::GetHorizontalInsidePadding(nsIPresContext& aPresContext,
|
|||
float pad;
|
||||
PRInt32 padMin;
|
||||
PRInt32 shouldUsePadMin;
|
||||
nsILookAndFeel * lookAndFeel;
|
||||
if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) {
|
||||
nsCOMPtr<nsILookAndFeel> lookAndFeel;
|
||||
if (NS_SUCCEEDED(aPresContext.GetLookAndFeel(getter_AddRefs(lookAndFeel)))) {
|
||||
lookAndFeel->GetMetric(nsILookAndFeel::eMetricFloat_ListHorizontalInsidePadding, pad);
|
||||
lookAndFeel->GetMetric(nsILookAndFeel::eMetric_ListHorizontalInsideMinimumPadding, padMin);
|
||||
// This one (below) is really only needed for GTK
|
||||
|
@ -403,11 +403,11 @@ nsSelectControlFrame::GetDesiredSize(nsIPresContext* aPresContext,
|
|||
|
||||
// XXX put this in widget library, combo boxes are fixed height (visible part)
|
||||
aDesiredLayoutSize.height = (mIsComboBox)
|
||||
? rowHeight + (2 * GetVerticalInsidePadding(p2t, rowHeight))
|
||||
? rowHeight + (2 * GetVerticalInsidePadding(*aPresContext, p2t, rowHeight))
|
||||
: desiredSize.height;
|
||||
if (aDesiredLayoutSize.maxElementSize) {
|
||||
aDesiredLayoutSize.maxElementSize->height = (mIsComboBox)
|
||||
? rowHeight + (2 * GetVerticalInsidePadding(p2t, rowHeight))
|
||||
? rowHeight + (2 * GetVerticalInsidePadding(*aPresContext, p2t, rowHeight))
|
||||
: minSize.height;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче