Bug 1294102 - Use the original height that is not affected by the top to decide the button style on OSX. r=mstange

This commit is contained in:
Tooru Fujisawa 2016-08-13 15:34:57 +09:00
parent f829bffa9d
commit b9da2b39b7
5 changed files with 29 additions and 5 deletions

View File

@ -0,0 +1,6 @@
<!DOCTYPE html>
<html>
<body>
<input type="button" style="position: absolute; top: 10.1px; left: 10px; width: 90px; height: 26.3px;" value="M">
</body>
</html>

View File

@ -0,0 +1,6 @@
<!DOCTYPE html>
<html>
<body>
<input type="button" style="position: absolute; top: 10.3px; left: 10px; width: 90px; height: 26.3px;" value="M">
</body>
</html>

View File

@ -1962,6 +1962,11 @@ random-if(!winWidget) == 1273154-2.html 1273154-2-ref.html # depends on Windows
!= 1276161-1b.html 1276161-1-notref.html
!= 1276161-1a.html 1276161-1b.html
== 1275411-1.html 1275411-1-ref.html
# Buttons in 2 pages have different position and the rendering result can be
# different, but they should use the same button style and the background color
# should be same. |fuzzy()| here allows the difference in border, but not
# background color.
skip-if(!cocoaWidget) fuzzy(255,1000) == 1294102-1.html 1294102-1-ref.html
HTTP == 652991-1a.html 652991-1-ref.html
HTTP == 652991-1b.html 652991-1-ref.html

View File

@ -123,7 +123,7 @@ protected:
nsIFrame* aFrame, mozilla::EventStates inState);
void DrawPushButton(CGContextRef cgContext, const HIRect& inBoxRect,
mozilla::EventStates inState, uint8_t aWidgetType,
nsIFrame* aFrame);
nsIFrame* aFrame, float aOriginalHeight);
void DrawMenuIcon(CGContextRef cgContext, const CGRect& aRect,
mozilla::EventStates inState, nsIFrame* aFrame,
const NSSize& aIconSize, NSString* aImageName,

View File

@ -1195,7 +1195,7 @@ static const CellRenderSettings pushButtonSettings = {
void
nsNativeThemeCocoa::DrawPushButton(CGContextRef cgContext, const HIRect& inBoxRect,
EventStates inState, uint8_t aWidgetType,
nsIFrame* aFrame)
nsIFrame* aFrame, float aOriginalHeight)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
@ -1225,7 +1225,10 @@ nsNativeThemeCocoa::DrawPushButton(CGContextRef cgContext, const HIRect& inBoxRe
// If the button is tall enough, draw the square button style so that
// buttons with non-standard content look good. Otherwise draw normal
// rounded aqua buttons.
if (inBoxRect.size.height > DO_SQUARE_BUTTON_HEIGHT) {
// This comparison is done based on the height that is calculated without
// the top, because the snapped height can be affected by the top of the
// rect and that may result in different height depending on the top value.
if (aOriginalHeight > DO_SQUARE_BUTTON_HEIGHT) {
[cell setBezelStyle:NSShadowlessSquareBezelStyle];
DrawCellWithScaling(cell, cgContext, inBoxRect, NSRegularControlSize,
NSZeroSize, NSMakeSize(14, 0), NULL, mCellDrawView,
@ -2284,6 +2287,7 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsRenderingContext* aContext,
gfx::Rect nativeDirtyRect = NSRectToRect(aDirtyRect, p2a);
gfxRect nativeWidgetRect(aRect.x, aRect.y, aRect.width, aRect.height);
nativeWidgetRect.ScaleInverse(gfxFloat(p2a));
float nativeWidgetHeight = round(nativeWidgetRect.Height());
nativeWidgetRect.Round();
if (nativeWidgetRect.IsEmpty())
return NS_OK; // Don't attempt to draw invisible widgets.
@ -2294,6 +2298,7 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsRenderingContext* aContext,
if (hidpi) {
// Use high-resolution drawing.
nativeWidgetRect.Scale(0.5f);
nativeWidgetHeight *= 0.5f;
nativeDirtyRect.Scale(0.5f);
aDrawTarget.SetTransform(aDrawTarget.GetTransform().PreScale(2.0f, 2.0f));
}
@ -2472,7 +2477,8 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsRenderingContext* aContext,
} else if (IsButtonTypeMenu(aFrame)) {
DrawDropdown(cgContext, macRect, eventState, aWidgetType, aFrame);
} else {
DrawPushButton(cgContext, macRect, eventState, aWidgetType, aFrame);
DrawPushButton(cgContext, macRect, eventState, aWidgetType, aFrame,
nativeWidgetHeight);
}
break;
@ -2483,7 +2489,8 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsRenderingContext* aContext,
case NS_THEME_MAC_HELP_BUTTON:
case NS_THEME_MAC_DISCLOSURE_BUTTON_OPEN:
case NS_THEME_MAC_DISCLOSURE_BUTTON_CLOSED:
DrawPushButton(cgContext, macRect, eventState, aWidgetType, aFrame);
DrawPushButton(cgContext, macRect, eventState, aWidgetType, aFrame,
nativeWidgetHeight);
break;
case NS_THEME_BUTTON_BEVEL: