Bug 838750 - Convert HTMLMeterElement to WebIDL. r=Ms2ger

This commit is contained in:
Andrea Marchesini 2013-02-07 10:00:39 -05:00
Родитель 133ab1bf92
Коммит cc3b4f4aa3
5 изменённых файлов: 120 добавлений и 43 удалений

Просмотреть файл

@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "HTMLMeterElement.h"
#include "mozilla/dom/HTMLMeterElementBinding.h"
NS_IMPL_NS_NEW_HTML_ELEMENT(Meter)
DOMCI_NODE_DATA(HTMLMeterElement, mozilla::dom::HTMLMeterElement)
@ -20,6 +21,7 @@ const double HTMLMeterElement::kDefaultMax = 1.0;
HTMLMeterElement::HTMLMeterElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsGenericHTMLElement(aNodeInfo)
{
SetIsDOMBinding();
}
HTMLMeterElement::~HTMLMeterElement()
@ -72,7 +74,7 @@ HTMLMeterElement::ParseAttribute(int32_t aNamespaceID, nsIAtom* aAttribute,
*/
double
HTMLMeterElement::GetMin() const
HTMLMeterElement::Min() const
{
/**
* If the attribute min is defined, the minimum is this value.
@ -86,7 +88,7 @@ HTMLMeterElement::GetMin() const
}
double
HTMLMeterElement::GetMax() const
HTMLMeterElement::Max() const
{
/**
* If the attribute max is defined, the maximum is this value.
@ -103,11 +105,11 @@ HTMLMeterElement::GetMax() const
max = kDefaultMax;
}
return std::max(max, GetMin());
return std::max(max, Min());
}
double
HTMLMeterElement::GetValue() const
HTMLMeterElement::Value() const
{
/**
* If the attribute value is defined, the actual value is this value.
@ -126,17 +128,17 @@ HTMLMeterElement::GetValue() const
value = kDefaultValue;
}
double min = GetMin();
double min = Min();
if (value <= min) {
return min;
}
return std::min(value, GetMax());
return std::min(value, Max());
}
double
HTMLMeterElement::GetLow() const
HTMLMeterElement::Low() const
{
/**
* If the low value is defined, the low value is this value.
@ -147,7 +149,7 @@ HTMLMeterElement::GetLow() const
* the low value is the same as the maximum value.
*/
double min = GetMin();
double min = Min();
const nsAttrValue* attrLow = mAttrsAndChildren.GetAttr(nsGkAtoms::low);
if (!attrLow || attrLow->Type() != nsAttrValue::eDoubleValue) {
@ -160,11 +162,11 @@ HTMLMeterElement::GetLow() const
return min;
}
return std::min(low, GetMax());
return std::min(low, Max());
}
double
HTMLMeterElement::GetHigh() const
HTMLMeterElement::High() const
{
/**
* If the high value is defined, the high value is this value.
@ -175,7 +177,7 @@ HTMLMeterElement::GetHigh() const
* the high value is the same as the maximum value.
*/
double max = GetMax();
double max = Max();
const nsAttrValue* attrHigh = mAttrsAndChildren.GetAttr(nsGkAtoms::high);
if (!attrHigh || attrHigh->Type() != nsAttrValue::eDoubleValue) {
@ -188,11 +190,11 @@ HTMLMeterElement::GetHigh() const
return max;
}
return std::max(high, GetLow());
return std::max(high, Low());
}
double
HTMLMeterElement::GetOptimum() const
HTMLMeterElement::Optimum() const
{
/**
* If the optimum value is defined, the optimum value is this value.
@ -205,9 +207,9 @@ HTMLMeterElement::GetOptimum() const
* the optimum value is the same as the maximum value.
*/
double max = GetMax();
double max = Max();
double min = GetMin();
double min = Min();
const nsAttrValue* attrOptimum =
mAttrsAndChildren.GetAttr(nsGkAtoms::optimum);
@ -231,7 +233,7 @@ HTMLMeterElement::GetOptimum() const
NS_IMETHODIMP
HTMLMeterElement::GetMin(double* aValue)
{
*aValue = GetMin();
*aValue = Min();
return NS_OK;
}
@ -244,7 +246,7 @@ HTMLMeterElement::SetMin(double aValue)
NS_IMETHODIMP
HTMLMeterElement::GetMax(double* aValue)
{
*aValue = GetMax();
*aValue = Max();
return NS_OK;
}
@ -257,7 +259,7 @@ HTMLMeterElement::SetMax(double aValue)
NS_IMETHODIMP
HTMLMeterElement::GetValue(double* aValue)
{
*aValue = GetValue();
*aValue = Value();
return NS_OK;
}
@ -270,7 +272,7 @@ HTMLMeterElement::SetValue(double aValue)
NS_IMETHODIMP
HTMLMeterElement::GetLow(double* aValue)
{
*aValue = GetLow();
*aValue = Low();
return NS_OK;
}
@ -283,7 +285,7 @@ HTMLMeterElement::SetLow(double aValue)
NS_IMETHODIMP
HTMLMeterElement::GetHigh(double* aValue)
{
*aValue = GetHigh();
*aValue = High();
return NS_OK;
}
@ -296,7 +298,7 @@ HTMLMeterElement::SetHigh(double aValue)
NS_IMETHODIMP
HTMLMeterElement::GetOptimum(double* aValue)
{
*aValue = GetOptimum();
*aValue = Optimum();
return NS_OK;
}
@ -319,10 +321,10 @@ HTMLMeterElement::GetOptimumState() const
* If the optimum value is in ]high, maximum],
* return if the value is in optimal, suboptimal or sub-suboptimal region
*/
double value = GetValue();
double low = GetLow();
double high = GetHigh();
double optimum = GetOptimum();
double value = Value();
double low = Low();
double high = High();
double optimum = Optimum();
if (optimum < low) {
if (value < low) {
@ -349,5 +351,12 @@ HTMLMeterElement::GetOptimumState() const
return NS_EVENT_STATE_SUB_OPTIMUM;
}
JSObject*
HTMLMeterElement::WrapNode(JSContext* aCx, JSObject* aScope,
bool* aTriedToWrap)
{
return HTMLMeterElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -50,6 +50,54 @@ public:
virtual nsIDOMNode* AsDOMNode() { return this; }
// WebIDL
/* @return the value */
double Value() const;
void SetValue(double aValue, ErrorResult& aRv)
{
aRv = SetValue(aValue);
}
/* @return the minimum value */
double Min() const;
void SetMin(double aValue, ErrorResult& aRv)
{
aRv = SetMin(aValue);
}
/* @return the maximum value */
double Max() const;
void SetMax(double aValue, ErrorResult& aRv)
{
aRv = SetMax(aValue);
}
/* @return the low value */
double Low() const;
void SetLow(double aValue, ErrorResult& aRv)
{
aRv = SetLow(aValue);
}
/* @return the high value */
double High() const;
void SetHigh(double aValue, ErrorResult& aRv)
{
aRv = SetHigh(aValue);
}
/* @return the optimum value */
double Optimum() const;
void SetOptimum(double aValue, ErrorResult& aRv)
{
aRv = SetOptimum(aValue);
}
protected:
virtual JSObject* WrapNode(JSContext* aCx, JSObject* aScope,
bool* aTriedToWrap) MOZ_OVERRIDE;
private:
static const double kDefaultValue;
@ -65,24 +113,6 @@ private:
* @return the optimum state of the element.
*/
nsEventStates GetOptimumState() const;
/* @return the minimum value */
double GetMin() const;
/* @return the maximum value */
double GetMax() const;
/* @return the actual value */
double GetValue() const;
/* @return the low value */
double GetLow() const;
/* @return the high value */
double GetHigh() const;
/* @return the optimum value */
double GetOptimum() const;
};
} // namespace dom

Просмотреть файл

@ -431,6 +431,10 @@ DOMInterfaces = {
'hasInstanceInterface': 'nsIDOMHTMLMetaElement',
},
'HTMLMeterElement': {
'hasInstanceInterface': 'nsIDOMHTMLMeterElement',
},
'HTMLModElement': {
'hasInstanceInterface': 'nsIDOMHTMLModElement',
},

Просмотреть файл

@ -0,0 +1,33 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* http://www.whatwg.org/specs/web-apps/current-work/#the-meter-element
*
* © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
* Opera Software ASA. You are granted a license to use, reproduce
* and create derivative works of this document.
*/
// http://www.whatwg.org/specs/web-apps/current-work/#the-meter-element
interface HTMLMeterElement : HTMLElement {
[SetterThrows]
attribute double value;
[SetterThrows]
attribute double min;
[SetterThrows]
attribute double max;
[SetterThrows]
attribute double low;
[SetterThrows]
attribute double high;
[SetterThrows]
attribute double optimum;
/**
* The labels attribute will be done with bug 556743.
*/
//readonly attribute NodeList labels;
};

Просмотреть файл

@ -74,6 +74,7 @@ webidl_files = \
HTMLLIElement.webidl \
HTMLMapElement.webidl \
HTMLMetaElement.webidl \
HTMLMeterElement.webidl \
HTMLModElement.webidl \
HTMLOListElement.webidl \
HTMLOptionsCollection.webidl \