Scrollbar thumb is drawn with wrong size for custom scrollbars. b=424074 r=josh sr=vlad

This commit is contained in:
joshmoz@gmail.com 2008-03-26 22:36:20 -07:00
parent 615699b20b
commit 2b63edc0c2
10 changed files with 63 additions and 19 deletions

View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window orient="horizontal" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<vbox width="500">
<scrollbar
orient="horizontal"
curpos="0"
maxpos="100"
pageincrement="10"/>
</vbox>
</window>

View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window orient="horizontal" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<vbox width="500">
<scrollbar
orient="horizontal"
curpos="0"
maxpos="100"
pageincrement="40"/>
</vbox>
</window>

View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window orient="horizontal" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<vbox width="500">
<scrollbar
orient="horizontal"
curpos="0"
maxpos="1000"
pageincrement="400"/>
</vbox>
</window>

View File

@ -0,0 +1,7 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window orient="horizontal" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<vbox width="500">
<scrollbar orient="horizontal"/>
</vbox>
</window>

View File

@ -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

View File

@ -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;

View File

@ -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 &&

View File

@ -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;
}

View File

@ -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);

View File

@ -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")