Bug 658829 part 3 - move GetProgress*Value to nsNativeTheme r=jimm

--HG--
extra : rebase_source : 562107a9a653f352900073b096bce0b85aa423f4
This commit is contained in:
Neil Rashbrook 2013-02-25 00:26:07 +00:00
parent ab07dc4549
commit 9980a170e6
4 changed files with 47 additions and 43 deletions

View File

@ -68,10 +68,6 @@ protected:
CGRect SeparatorAdjustedRect(CGRect aRect, nsIFrame* aLeft,
nsIFrame* aCurrent, nsIFrame* aRight);
// Helpers for progressbar.
double GetProgressValue(nsIFrame* aFrame);
double GetProgressMaxValue(nsIFrame* aFrame);
// HITheme drawing routines
void DrawFrame(CGContextRef context, HIThemeFrameKind inKind,
const HIRect& inBoxRect, bool inReadOnly,

View File

@ -23,7 +23,6 @@
#include "nsCocoaWindow.h"
#include "nsNativeThemeColors.h"
#include "nsIScrollableFrame.h"
#include "nsIDOMHTMLProgressElement.h"
#include "nsIDOMHTMLMeterElement.h"
#include "mozilla/dom/Element.h"
@ -2994,39 +2993,3 @@ nsNativeThemeCocoa::GetWidgetTransparency(nsIFrame* aFrame, uint8_t 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, nsGkAtoms::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)std::max(CheckIntAttr(aFrame, nsGkAtoms::max, 100), 1);
}

View File

@ -14,6 +14,7 @@
#include "nsString.h"
#include "nsINameSpaceManager.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsIDOMHTMLProgressElement.h"
#include "nsIDOMXULMenuListElement.h"
#include "nsThemeConstants.h"
#include "nsIComponentManager.h"
@ -101,6 +102,7 @@ nsNativeTheme::GetContentState(nsIFrame* aFrame, uint8_t aWidgetType)
return flags;
}
/* static */
bool
nsNativeTheme::CheckBooleanAttr(nsIFrame* aFrame, nsIAtom* aAtom)
{
@ -121,6 +123,7 @@ nsNativeTheme::CheckBooleanAttr(nsIFrame* aFrame, nsIAtom* aAtom)
NS_LITERAL_STRING("true"), eCaseMatters);
}
/* static */
int32_t
nsNativeTheme::CheckIntAttr(nsIFrame* aFrame, nsIAtom* aAtom, int32_t defaultValue)
{
@ -137,6 +140,44 @@ nsNativeTheme::CheckIntAttr(nsIFrame* aFrame, nsIAtom* aAtom, int32_t defaultVal
return value;
}
/* static */
double
nsNativeTheme::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)nsNativeTheme::CheckIntAttr(aFrame, nsGkAtoms::value, 0);
}
/* static */
double
nsNativeTheme::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)std::max(nsNativeTheme::CheckIntAttr(aFrame, nsGkAtoms::max, 100), 1);
}
bool
nsNativeTheme::GetCheckedOrSelected(nsIFrame* aFrame, bool aCheckSelected)
{

View File

@ -155,8 +155,12 @@ class nsNativeTheme : public nsITimerCallback
bool IsMenuListEditable(nsIFrame *aFrame);
nsIPresShell *GetPresShell(nsIFrame* aFrame);
int32_t CheckIntAttr(nsIFrame* aFrame, nsIAtom* aAtom, int32_t defaultValue);
bool CheckBooleanAttr(nsIFrame* aFrame, nsIAtom* aAtom);
static bool CheckBooleanAttr(nsIFrame* aFrame, nsIAtom* aAtom);
static int32_t CheckIntAttr(nsIFrame* aFrame, nsIAtom* aAtom, int32_t defaultValue);
// Helpers for progressbar.
static double GetProgressValue(nsIFrame* aFrame);
static double GetProgressMaxValue(nsIFrame* aFrame);
bool GetCheckedOrSelected(nsIFrame* aFrame, bool aCheckSelected);
bool GetIndeterminate(nsIFrame* aFrame);