From 2b63edc0c21106ba5b9d1c257d778a5ab529dc82 Mon Sep 17 00:00:00 2001 From: "joshmoz@gmail.com" Date: Wed, 26 Mar 2008 22:36:20 -0700 Subject: [PATCH] Scrollbar thumb is drawn with wrong size for custom scrollbars. b=424074 r=josh sr=vlad --- layout/reftests/bugs/424074-1-ref.xul | 11 +++++++++++ layout/reftests/bugs/424074-1-ref2.xul | 11 +++++++++++ layout/reftests/bugs/424074-1-ref3.xul | 11 +++++++++++ layout/reftests/bugs/424074-1.xul | 7 +++++++ layout/reftests/bugs/reftest.list | 3 +++ widget/src/cocoa/nsNativeThemeCocoa.mm | 17 +++++++++-------- widget/src/gtk2/nsNativeThemeGTK.cpp | 8 ++++---- widget/src/xpwidgets/nsNativeTheme.cpp | 8 ++++---- widget/src/xpwidgets/nsNativeTheme.h | 5 ++--- widget/src/xpwidgets/nsWidgetAtomList.h | 1 + 10 files changed, 63 insertions(+), 19 deletions(-) create mode 100644 layout/reftests/bugs/424074-1-ref.xul create mode 100644 layout/reftests/bugs/424074-1-ref2.xul create mode 100644 layout/reftests/bugs/424074-1-ref3.xul create mode 100644 layout/reftests/bugs/424074-1.xul diff --git a/layout/reftests/bugs/424074-1-ref.xul b/layout/reftests/bugs/424074-1-ref.xul new file mode 100644 index 00000000000..5e08d2a8b12 --- /dev/null +++ b/layout/reftests/bugs/424074-1-ref.xul @@ -0,0 +1,11 @@ + + + + + + + diff --git a/layout/reftests/bugs/424074-1-ref2.xul b/layout/reftests/bugs/424074-1-ref2.xul new file mode 100644 index 00000000000..8b538a33f3d --- /dev/null +++ b/layout/reftests/bugs/424074-1-ref2.xul @@ -0,0 +1,11 @@ + + + + + + + diff --git a/layout/reftests/bugs/424074-1-ref3.xul b/layout/reftests/bugs/424074-1-ref3.xul new file mode 100644 index 00000000000..42edc44e0ba --- /dev/null +++ b/layout/reftests/bugs/424074-1-ref3.xul @@ -0,0 +1,11 @@ + + + + + + + diff --git a/layout/reftests/bugs/424074-1.xul b/layout/reftests/bugs/424074-1.xul new file mode 100644 index 00000000000..315faf51781 --- /dev/null +++ b/layout/reftests/bugs/424074-1.xul @@ -0,0 +1,7 @@ + + + + + + + diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list index e37abfe8541..8c8a2194d1a 100644 --- a/layout/reftests/bugs/reftest.list +++ b/layout/reftests/bugs/reftest.list @@ -779,3 +779,6 @@ fails == 413027-3.html 413027-3-ref.html == 423385-1.html 423385-1-ref.html == 423599-1.html 423599-1-ref.html == 423676-1.html 423676-1-ref.html +== 424074-1.xul 424074-1-ref.xul +!= 424074-1.xul 424074-1-ref2.xul +== 424074-1-ref2.xul 424074-1-ref3.xul diff --git a/widget/src/cocoa/nsNativeThemeCocoa.mm b/widget/src/cocoa/nsNativeThemeCocoa.mm index eb797296df6..d533d3bb5bb 100644 --- a/widget/src/cocoa/nsNativeThemeCocoa.mm +++ b/widget/src/cocoa/nsNativeThemeCocoa.mm @@ -837,9 +837,10 @@ nsNativeThemeCocoa::GetScrollbarDrawInfo(HIThemeTrackDrawInfo& aTdi, nsIFrame *a { NS_OBJC_BEGIN_TRY_ABORT_BLOCK; - PRInt32 curpos = CheckIntAttr(aFrame, nsWidgetAtoms::curpos); - PRInt32 minpos = CheckIntAttr(aFrame, nsWidgetAtoms::minpos); - PRInt32 maxpos = CheckIntAttr(aFrame, nsWidgetAtoms::maxpos); + PRInt32 curpos = CheckIntAttr(aFrame, nsWidgetAtoms::curpos, 0); + PRInt32 minpos = CheckIntAttr(aFrame, nsWidgetAtoms::minpos, 0); + PRInt32 maxpos = CheckIntAttr(aFrame, nsWidgetAtoms::maxpos, 100); + PRInt32 thumbSize = CheckIntAttr(aFrame, nsWidgetAtoms::pageincrement, 10); PRBool isHorizontal = aFrame->GetContent()->AttrValueIs(kNameSpaceID_None, nsWidgetAtoms::orient, nsWidgetAtoms::horizontal, eCaseMatters); @@ -856,12 +857,12 @@ nsNativeThemeCocoa::GetScrollbarDrawInfo(HIThemeTrackDrawInfo& aTdi, nsIFrame *a if (isHorizontal) aTdi.attributes |= kThemeTrackHorizontal; - PRInt32 longSideLength = (PRInt32)(isHorizontal ? (aRect.size.width) : (aRect.size.height)); - aTdi.trackInfo.scrollbar.viewsize = (SInt32)longSideLength; + aTdi.trackInfo.scrollbar.viewsize = (SInt32)thumbSize; /* Only display features if we have enough room for them. * Gecko still maintains the scrollbar info; this is just a visual issue (bug 380185). */ + PRInt32 longSideLength = (PRInt32)(isHorizontal ? (aRect.size.width) : (aRect.size.height)); if (longSideLength >= (isSmall ? MIN_SMALL_SCROLLBAR_SIZE_WITH_THUMB : MIN_SCROLLBAR_SIZE_WITH_THUMB)) { aTdi.attributes |= kThemeTrackShowThumb; } @@ -1240,9 +1241,9 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame case NS_THEME_SCALE_HORIZONTAL: case NS_THEME_SCALE_VERTICAL: { - PRInt32 curpos = CheckIntAttr(aFrame, nsWidgetAtoms::curpos); - PRInt32 minpos = CheckIntAttr(aFrame, nsWidgetAtoms::minpos); - PRInt32 maxpos = CheckIntAttr(aFrame, nsWidgetAtoms::maxpos); + PRInt32 curpos = CheckIntAttr(aFrame, nsWidgetAtoms::curpos, 0); + PRInt32 minpos = CheckIntAttr(aFrame, nsWidgetAtoms::minpos, 0); + PRInt32 maxpos = CheckIntAttr(aFrame, nsWidgetAtoms::maxpos, 100); if (!maxpos) maxpos = 100; diff --git a/widget/src/gtk2/nsNativeThemeGTK.cpp b/widget/src/gtk2/nsNativeThemeGTK.cpp index 18ca6260c49..dc43da53eb4 100644 --- a/widget/src/gtk2/nsNativeThemeGTK.cpp +++ b/widget/src/gtk2/nsNativeThemeGTK.cpp @@ -267,8 +267,8 @@ nsNativeThemeGTK::GetGtkWidgetAndState(PRUint8 aWidgetType, nsIFrame* aFrame, // the slider to the actual scrollbar object nsIFrame *tmpFrame = aFrame->GetParent()->GetParent(); - aState->curpos = CheckIntAttr(tmpFrame, nsWidgetAtoms::curpos); - aState->maxpos = CheckIntAttr(tmpFrame, nsWidgetAtoms::maxpos); + aState->curpos = CheckIntAttr(tmpFrame, nsWidgetAtoms::curpos, 0); + aState->maxpos = CheckIntAttr(tmpFrame, nsWidgetAtoms::maxpos, 100); } if (aWidgetType == NS_THEME_SCROLLBAR_BUTTON_UP || @@ -277,8 +277,8 @@ nsNativeThemeGTK::GetGtkWidgetAndState(PRUint8 aWidgetType, nsIFrame* aFrame, aWidgetType == NS_THEME_SCROLLBAR_BUTTON_RIGHT) { // set the state to disabled when the scrollbar is scrolled to // the beginning or the end, depending on the button type. - PRInt32 curpos = CheckIntAttr(aFrame, nsWidgetAtoms::curpos); - PRInt32 maxpos = CheckIntAttr(aFrame, nsWidgetAtoms::maxpos); + PRInt32 curpos = CheckIntAttr(aFrame, nsWidgetAtoms::curpos, 0); + PRInt32 maxpos = CheckIntAttr(aFrame, nsWidgetAtoms::maxpos, 100); if ((curpos == 0 && (aWidgetType == NS_THEME_SCROLLBAR_BUTTON_UP || aWidgetType == NS_THEME_SCROLLBAR_BUTTON_LEFT)) || (curpos == maxpos && diff --git a/widget/src/xpwidgets/nsNativeTheme.cpp b/widget/src/xpwidgets/nsNativeTheme.cpp index 259e063f3da..c5767d492dd 100644 --- a/widget/src/xpwidgets/nsNativeTheme.cpp +++ b/widget/src/xpwidgets/nsNativeTheme.cpp @@ -114,16 +114,16 @@ nsNativeTheme::CheckBooleanAttr(nsIFrame* aFrame, nsIAtom* aAtom) } PRInt32 -nsNativeTheme::CheckIntAttr(nsIFrame* aFrame, nsIAtom* aAtom) +nsNativeTheme::CheckIntAttr(nsIFrame* aFrame, nsIAtom* aAtom, PRInt32 defaultValue) { if (!aFrame) - return 0; + return defaultValue; nsAutoString attr; aFrame->GetContent()->GetAttr(kNameSpaceID_None, aAtom, attr); PRInt32 err, value = attr.ToInteger(&err); - if (NS_FAILED(err)) - return 0; + if (attr.IsEmpty() || NS_FAILED(err)) + return defaultValue; return value; } diff --git a/widget/src/xpwidgets/nsNativeTheme.h b/widget/src/xpwidgets/nsNativeTheme.h index caf07b852d4..7ac02e53966 100644 --- a/widget/src/xpwidgets/nsNativeTheme.h +++ b/widget/src/xpwidgets/nsNativeTheme.h @@ -131,7 +131,7 @@ class nsNativeTheme PRBool IsIndeterminateProgress(nsIFrame* aFrame); PRInt32 GetProgressValue(nsIFrame* aFrame) { - return CheckIntAttr(aFrame, nsWidgetAtoms::value); + return CheckIntAttr(aFrame, nsWidgetAtoms::value, 0); } // textfield: @@ -139,9 +139,8 @@ class nsNativeTheme return CheckBooleanAttr(aFrame, nsWidgetAtoms::readonly); } - // These are used by nsNativeThemeGtk nsIPresShell *GetPresShell(nsIFrame* aFrame); - PRInt32 CheckIntAttr(nsIFrame* aFrame, nsIAtom* aAtom); + PRInt32 CheckIntAttr(nsIFrame* aFrame, nsIAtom* aAtom, PRInt32 defaultValue); PRBool CheckBooleanAttr(nsIFrame* aFrame, nsIAtom* aAtom); PRBool GetCheckedOrSelected(nsIFrame* aFrame, PRBool aCheckSelected); diff --git a/widget/src/xpwidgets/nsWidgetAtomList.h b/widget/src/xpwidgets/nsWidgetAtomList.h index 75a35a8d468..27f677e749e 100644 --- a/widget/src/xpwidgets/nsWidgetAtomList.h +++ b/widget/src/xpwidgets/nsWidgetAtomList.h @@ -99,6 +99,7 @@ WIDGET_ATOM(name, "name") WIDGET_ATOM(onAppCommand, "onAppCommand") WIDGET_ATOM(open, "open") // Whether or not a menu, tree, etc. is open WIDGET_ATOM(orient, "orient") +WIDGET_ATOM(pageincrement, "pageincrement") WIDGET_ATOM(parentfocused, "parentfocused") WIDGET_ATOM(radio, "radio") WIDGET_ATOM(readonly, "readonly")