diff --git a/widget/src/xpwidgets/nsNativeTheme.cpp b/widget/src/xpwidgets/nsNativeTheme.cpp index 737928074337..b38c8a80b6cd 100644 --- a/widget/src/xpwidgets/nsNativeTheme.cpp +++ b/widget/src/xpwidgets/nsNativeTheme.cpp @@ -185,13 +185,14 @@ nsNativeTheme::GetCheckedOrSelected(nsIFrame* aFrame, PRBool aCheckSelected) } static void -ConvertMarginToAppUnits(const nsMargin &aSource, nsMargin &aDest) +ConvertBorderToAppUnits(nsPresContext* aPresContext, const nsMargin &aSource, nsMargin &aDest) { - PRInt32 p2a = nsPresContext::AppUnitsPerCSSPixel(); - aDest.top = NSIntPixelsToAppUnits(aSource.top, p2a); - aDest.left = NSIntPixelsToAppUnits(aSource.left, p2a); - aDest.bottom = NSIntPixelsToAppUnits(aSource.bottom, p2a); - aDest.right = NSIntPixelsToAppUnits(aSource.right, p2a); + PRInt32 cp2a = nsPresContext::AppUnitsPerCSSPixel(); + PRInt32 dp2a = aPresContext->AppUnitsPerDevPixel(); + aDest.top = NS_ROUND_BORDER_TO_PIXELS(NSIntPixelsToAppUnits(aSource.top, cp2a), dp2a); + aDest.left = NS_ROUND_BORDER_TO_PIXELS(NSIntPixelsToAppUnits(aSource.left, cp2a), dp2a); + aDest.bottom = NS_ROUND_BORDER_TO_PIXELS(NSIntPixelsToAppUnits(aSource.bottom, cp2a), dp2a); + aDest.right = NS_ROUND_BORDER_TO_PIXELS(NSIntPixelsToAppUnits(aSource.right, cp2a), dp2a);; } PRBool @@ -216,7 +217,7 @@ nsNativeTheme::IsWidgetStyled(nsPresContext* aPresContext, nsIFrame* aFrame, switch (aWidgetType) { case NS_THEME_BUTTON: if (IsDisabled(aFrame)) { - ConvertMarginToAppUnits(sButtonDisabledBorderSize, defaultBorderSize); + ConvertBorderToAppUnits(aPresContext, sButtonDisabledBorderSize, defaultBorderSize); defaultBorderStyle = sButtonInactiveBorderStyle; lookAndFeel->GetColor(sButtonDisabledBorderColorID, defaultBorderColor); @@ -224,7 +225,7 @@ nsNativeTheme::IsWidgetStyled(nsPresContext* aPresContext, nsIFrame* aFrame, defaultBGColor); } else { PRInt32 contentState = GetContentState(aFrame, aWidgetType); - ConvertMarginToAppUnits(sButtonBorderSize, defaultBorderSize); + ConvertBorderToAppUnits(aPresContext, sButtonBorderSize, defaultBorderSize); if (contentState & NS_EVENT_STATE_HOVER && contentState & NS_EVENT_STATE_ACTIVE) defaultBorderStyle = sButtonActiveBorderStyle; @@ -240,7 +241,7 @@ nsNativeTheme::IsWidgetStyled(nsPresContext* aPresContext, nsIFrame* aFrame, case NS_THEME_TEXTFIELD: case NS_THEME_TEXTFIELD_MULTILINE: defaultBorderStyle = sTextfieldBorderStyle; - ConvertMarginToAppUnits(sTextfieldBorderSize, defaultBorderSize); + ConvertBorderToAppUnits(aPresContext, sTextfieldBorderSize, defaultBorderSize); lookAndFeel->GetColor(sTextfieldBorderColorID, defaultBorderColor); defaultBGTransparent = sTextfieldBGTransparent; if (!defaultBGTransparent) { @@ -253,7 +254,7 @@ nsNativeTheme::IsWidgetStyled(nsPresContext* aPresContext, nsIFrame* aFrame, case NS_THEME_LISTBOX: defaultBorderStyle = sListboxBorderStyle; - ConvertMarginToAppUnits(sListboxBorderSize, defaultBorderSize); + ConvertBorderToAppUnits(aPresContext, sListboxBorderSize, defaultBorderSize); lookAndFeel->GetColor(sListboxBorderColorID, defaultBorderColor); defaultBGTransparent = sListboxBGTransparent; if (!defaultBGTransparent) { @@ -266,7 +267,7 @@ nsNativeTheme::IsWidgetStyled(nsPresContext* aPresContext, nsIFrame* aFrame, case NS_THEME_DROPDOWN: defaultBorderStyle = sComboboxBorderStyle; - ConvertMarginToAppUnits(sComboboxBorderSize, defaultBorderSize); + ConvertBorderToAppUnits(aPresContext, sComboboxBorderSize, defaultBorderSize); lookAndFeel->GetColor(sComboboxBorderColorID, defaultBorderColor); defaultBGTransparent = sComboboxBGTransparent; if (!defaultBGTransparent) {