зеркало из https://github.com/mozilla/gecko-dev.git
Bug 634549 - Cocoa's progress bar widget should use HTML progress element's values. r=mstange,roc
This commit is contained in:
Родитель
7d26270904
Коммит
0dca09f5ff
|
@ -96,13 +96,17 @@ protected:
|
|||
nsresult GetSystemColor(PRUint8 aWidgetType, nsILookAndFeel::nsColorID& aColorID);
|
||||
nsIntMargin RTLAwareMargin(const nsIntMargin& aMargin, nsIFrame* aFrame);
|
||||
|
||||
// Helpers for progressbar.
|
||||
double GetProgressValue(nsIFrame* aFrame);
|
||||
double GetProgressMaxValue(nsIFrame* aFrame);
|
||||
|
||||
// HITheme drawing routines
|
||||
void DrawFrame(CGContextRef context, HIThemeFrameKind inKind,
|
||||
const HIRect& inBoxRect, PRBool inReadOnly,
|
||||
nsEventStates inState);
|
||||
void DrawProgress(CGContextRef context, const HIRect& inBoxRect,
|
||||
PRBool inIsIndeterminate, PRBool inIsHorizontal,
|
||||
PRInt32 inValue, PRInt32 inMaxValue, nsIFrame* aFrame);
|
||||
double inValue, double inMaxValue, nsIFrame* aFrame);
|
||||
void DrawTab(CGContextRef context, HIRect inBoxRect, nsEventStates inState,
|
||||
nsIFrame* aFrame);
|
||||
void DrawTabPanel(CGContextRef context, const HIRect& inBoxRect, nsIFrame* aFrame);
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
#include "nsCocoaWindow.h"
|
||||
#include "nsNativeThemeColors.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "nsIDOMHTMLProgressElement.h"
|
||||
|
||||
#include "gfxContext.h"
|
||||
#include "gfxQuartzSurface.h"
|
||||
|
@ -1042,7 +1043,7 @@ RenderProgress(CGContextRef cgContext, const HIRect& aRenderRect, void* aData)
|
|||
void
|
||||
nsNativeThemeCocoa::DrawProgress(CGContextRef cgContext, const HIRect& inBoxRect,
|
||||
PRBool inIsIndeterminate, PRBool inIsHorizontal,
|
||||
PRInt32 inValue, PRInt32 inMaxValue,
|
||||
double inValue, double inMaxValue,
|
||||
nsIFrame* aFrame)
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||
|
@ -1056,8 +1057,8 @@ nsNativeThemeCocoa::DrawProgress(CGContextRef cgContext, const HIRect& inBoxRect
|
|||
tdi.kind = inIsIndeterminate ? kThemeMediumIndeterminateBar: kThemeMediumProgressBar;
|
||||
tdi.bounds = inBoxRect;
|
||||
tdi.min = 0;
|
||||
tdi.max = inMaxValue;
|
||||
tdi.value = inValue;
|
||||
tdi.max = PR_INT32_MAX;
|
||||
tdi.value = PR_INT32_MAX * (inValue / inMaxValue);
|
||||
tdi.attributes = inIsHorizontal ? kThemeTrackHorizontal : 0;
|
||||
tdi.enableState = FrameIsInActiveWindow(aFrame) ? kThemeTrackActive : kThemeTrackInactive;
|
||||
tdi.trackInfo.progress.phase = PR_IntervalToMilliseconds(PR_IntervalNow()) /
|
||||
|
@ -2527,3 +2528,39 @@ nsNativeThemeCocoa::GetWidgetTransparency(nsIFrame* aFrame, PRUint8 aWidgetType)
|
|||
return eUnknownTransparency;
|
||||
}
|
||||
}
|
||||
|
||||
double
|
||||
nsNativeThemeCocoa::GetProgressValue(nsIFrame* aFrame)
|
||||
{
|
||||
// When we are using the HTML progress element,
|
||||
// we can get the value from the IDL property.
|
||||
if (aFrame) {
|
||||
nsCOMPtr<nsIDOMHTMLProgressElement> progress =
|
||||
do_QueryInterface(aFrame->GetContent());
|
||||
if (progress) {
|
||||
double value;
|
||||
progress->GetValue(&value);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
return (double)CheckIntAttr(aFrame, nsWidgetAtoms::value, 0);
|
||||
}
|
||||
|
||||
double
|
||||
nsNativeThemeCocoa::GetProgressMaxValue(nsIFrame* aFrame)
|
||||
{
|
||||
// When we are using the HTML progress element,
|
||||
// we can get the max from the IDL property.
|
||||
if (aFrame) {
|
||||
nsCOMPtr<nsIDOMHTMLProgressElement> progress =
|
||||
do_QueryInterface(aFrame->GetContent());
|
||||
if (progress) {
|
||||
double max;
|
||||
progress->GetMax(&max);
|
||||
return max;
|
||||
}
|
||||
}
|
||||
|
||||
return (double)PR_MAX(CheckIntAttr(aFrame, nsWidgetAtoms::max, 100), 1);
|
||||
}
|
||||
|
|
|
@ -162,14 +162,6 @@ class nsNativeTheme : public nsITimerCallback
|
|||
// progressbar:
|
||||
PRBool IsIndeterminateProgress(nsIFrame* aFrame, nsEventStates aEventStates);
|
||||
|
||||
PRInt32 GetProgressValue(nsIFrame* aFrame) {
|
||||
return CheckIntAttr(aFrame, nsWidgetAtoms::value, 0);
|
||||
}
|
||||
|
||||
PRInt32 GetProgressMaxValue(nsIFrame* aFrame) {
|
||||
return PR_MAX(CheckIntAttr(aFrame, nsWidgetAtoms::max, 100), 1);
|
||||
}
|
||||
|
||||
// textfield:
|
||||
PRBool IsReadOnly(nsIFrame* aFrame) {
|
||||
return CheckBooleanAttr(aFrame, nsWidgetAtoms::readonly);
|
||||
|
|
Загрузка…
Ссылка в новой задаче