зеркало из https://github.com/mozilla/gecko-dev.git
Bug 839033 - HTMLProgressElement cleanup. r=mounir
This commit is contained in:
Родитель
71bb4d183e
Коммит
31b6ebad7c
|
@ -72,66 +72,72 @@ HTMLProgressElement::ParseAttribute(int32_t aNamespaceID, nsIAtom* aAttribute,
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
HTMLProgressElement::GetValue(double* aValue)
|
HTMLProgressElement::GetValue(double* aValue)
|
||||||
|
{
|
||||||
|
*aValue = Value();
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
HTMLProgressElement::Value() const
|
||||||
{
|
{
|
||||||
const nsAttrValue* attrValue = mAttrsAndChildren.GetAttr(nsGkAtoms::value);
|
const nsAttrValue* attrValue = mAttrsAndChildren.GetAttr(nsGkAtoms::value);
|
||||||
if (!attrValue || attrValue->Type() != nsAttrValue::eDoubleValue ||
|
if (!attrValue || attrValue->Type() != nsAttrValue::eDoubleValue ||
|
||||||
attrValue->GetDoubleValue() < 0.0) {
|
attrValue->GetDoubleValue() < 0.0) {
|
||||||
*aValue = kDefaultValue;
|
return kDefaultValue;
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*aValue = attrValue->GetDoubleValue();
|
return std::min(attrValue->GetDoubleValue(), Max());
|
||||||
|
|
||||||
double max;
|
|
||||||
GetMax(&max);
|
|
||||||
|
|
||||||
*aValue = std::min(*aValue, max);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
HTMLProgressElement::SetValue(double aValue)
|
HTMLProgressElement::SetValue(double aValue)
|
||||||
{
|
{
|
||||||
return SetDoubleAttr(nsGkAtoms::value, aValue);
|
ErrorResult rv;
|
||||||
|
SetValue(aValue, rv);
|
||||||
|
return rv.ErrorCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
HTMLProgressElement::GetMax(double* aValue)
|
HTMLProgressElement::GetMax(double* aValue)
|
||||||
|
{
|
||||||
|
*aValue = Max();
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
HTMLProgressElement::Max() const
|
||||||
{
|
{
|
||||||
const nsAttrValue* attrMax = mAttrsAndChildren.GetAttr(nsGkAtoms::max);
|
const nsAttrValue* attrMax = mAttrsAndChildren.GetAttr(nsGkAtoms::max);
|
||||||
if (attrMax && attrMax->Type() == nsAttrValue::eDoubleValue &&
|
if (!attrMax || attrMax->Type() != nsAttrValue::eDoubleValue ||
|
||||||
attrMax->GetDoubleValue() > 0.0) {
|
attrMax->GetDoubleValue() <= 0.0) {
|
||||||
*aValue = attrMax->GetDoubleValue();
|
return kDefaultMax;
|
||||||
} else {
|
|
||||||
*aValue = kDefaultMax;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return attrMax->GetDoubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
HTMLProgressElement::SetMax(double aValue)
|
HTMLProgressElement::SetMax(double aValue)
|
||||||
{
|
{
|
||||||
return SetDoubleAttr(nsGkAtoms::max, aValue);
|
ErrorResult rv;
|
||||||
|
SetMax(aValue, rv);
|
||||||
|
return rv.ErrorCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
HTMLProgressElement::GetPosition(double* aPosition)
|
HTMLProgressElement::GetPosition(double* aPosition)
|
||||||
|
{
|
||||||
|
*aPosition = Position();
|
||||||
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
HTMLProgressElement::Position() const
|
||||||
{
|
{
|
||||||
if (IsIndeterminate()) {
|
if (IsIndeterminate()) {
|
||||||
*aPosition = kIndeterminatePosition;
|
return kIndeterminatePosition;
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double value;
|
return Value() / Max();
|
||||||
double max;
|
|
||||||
GetValue(&value);
|
|
||||||
GetMax(&max);
|
|
||||||
|
|
||||||
*aPosition = value / max;
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
@ -50,36 +50,17 @@ public:
|
||||||
virtual nsIDOMNode* AsDOMNode() { return this; }
|
virtual nsIDOMNode* AsDOMNode() { return this; }
|
||||||
|
|
||||||
// WebIDL
|
// WebIDL
|
||||||
double Value()
|
double Value() const;
|
||||||
{
|
|
||||||
double ret;
|
|
||||||
GetValue(&ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetValue(double aValue, ErrorResult& aRv)
|
void SetValue(double aValue, ErrorResult& aRv)
|
||||||
{
|
{
|
||||||
aRv = SetDoubleAttr(nsGkAtoms::value, aValue);
|
aRv = SetDoubleAttr(nsGkAtoms::value, aValue);
|
||||||
}
|
}
|
||||||
|
double Max() const;
|
||||||
double Max()
|
|
||||||
{
|
|
||||||
double ret;
|
|
||||||
GetMax(&ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetMax(double aValue, ErrorResult& aRv)
|
void SetMax(double aValue, ErrorResult& aRv)
|
||||||
{
|
{
|
||||||
aRv = SetDoubleAttr(nsGkAtoms::max, aValue);
|
aRv = SetDoubleAttr(nsGkAtoms::max, aValue);
|
||||||
}
|
}
|
||||||
|
double Position() const;
|
||||||
double Position()
|
|
||||||
{
|
|
||||||
double ret;
|
|
||||||
GetPosition(&ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual JSObject* WrapNode(JSContext* aCx, JSObject* aScope,
|
virtual JSObject* WrapNode(JSContext* aCx, JSObject* aScope,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче