mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changesets, cf285bf3c6fc, e8b847157094, and dd86a8178cec (bug 839033) for bustage.
--HG-- rename : content/html/content/src/HTMLProgressElement.h => content/html/content/src/nsHTMLProgressElement.cpp
This commit is contained in:
parent
484d075fce
commit
4cbf80f0ff
@ -1,158 +0,0 @@
|
||||
/* -*- Mode: C++; 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/. */
|
||||
|
||||
#include "mozilla/dom/HTMLProgressElement.h"
|
||||
#include "mozilla/dom/HTMLProgressElementBinding.h"
|
||||
|
||||
NS_IMPL_NS_NEW_HTML_ELEMENT(Progress)
|
||||
DOMCI_NODE_DATA(HTMLProgressElement, mozilla::dom::HTMLProgressElement)
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
const double HTMLProgressElement::kIndeterminatePosition = -1.0;
|
||||
const double HTMLProgressElement::kDefaultValue = 0.0;
|
||||
const double HTMLProgressElement::kDefaultMax = 1.0;
|
||||
|
||||
|
||||
HTMLProgressElement::HTMLProgressElement(already_AddRefed<nsINodeInfo> aNodeInfo)
|
||||
: nsGenericHTMLElement(aNodeInfo)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
|
||||
// We start out indeterminate
|
||||
AddStatesSilently(NS_EVENT_STATE_INDETERMINATE);
|
||||
}
|
||||
|
||||
HTMLProgressElement::~HTMLProgressElement()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(HTMLProgressElement, Element)
|
||||
NS_IMPL_RELEASE_INHERITED(HTMLProgressElement, Element)
|
||||
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(HTMLProgressElement)
|
||||
NS_HTML_CONTENT_INTERFACE_TABLE1(HTMLProgressElement,
|
||||
nsIDOMHTMLProgressElement)
|
||||
NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(HTMLProgressElement,
|
||||
nsGenericHTMLElement)
|
||||
NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLProgressElement)
|
||||
|
||||
NS_IMPL_ELEMENT_CLONE(HTMLProgressElement)
|
||||
|
||||
|
||||
nsEventStates
|
||||
HTMLProgressElement::IntrinsicState() const
|
||||
{
|
||||
nsEventStates state = nsGenericHTMLElement::IntrinsicState();
|
||||
|
||||
if (IsIndeterminate()) {
|
||||
state |= NS_EVENT_STATE_INDETERMINATE;
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLProgressElement::ParseAttribute(int32_t aNamespaceID, nsIAtom* aAttribute,
|
||||
const nsAString& aValue, nsAttrValue& aResult)
|
||||
{
|
||||
if (aNamespaceID == kNameSpaceID_None) {
|
||||
if (aAttribute == nsGkAtoms::value || aAttribute == nsGkAtoms::max) {
|
||||
return aResult.ParseDoubleValue(aValue);
|
||||
}
|
||||
}
|
||||
|
||||
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute,
|
||||
aValue, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLProgressElement::GetValue(double* aValue)
|
||||
{
|
||||
*aValue = Value();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
double
|
||||
HTMLProgressElement::Value() const
|
||||
{
|
||||
const nsAttrValue* attrValue = mAttrsAndChildren.GetAttr(nsGkAtoms::value);
|
||||
if (!attrValue || attrValue->Type() != nsAttrValue::eDoubleValue ||
|
||||
attrValue->GetDoubleValue() < 0.0) {
|
||||
return kDefaultValue;
|
||||
}
|
||||
|
||||
return std::min(attrValue->GetDoubleValue(), Max());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLProgressElement::SetValue(double aValue)
|
||||
{
|
||||
ErrorResult rv;
|
||||
SetValue(aValue, rv);
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLProgressElement::GetMax(double* aValue)
|
||||
{
|
||||
*aValue = Max();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
double
|
||||
HTMLProgressElement::Max() const
|
||||
{
|
||||
const nsAttrValue* attrMax = mAttrsAndChildren.GetAttr(nsGkAtoms::max);
|
||||
if (!attrMax || attrMax->Type() != nsAttrValue::eDoubleValue ||
|
||||
attrMax->GetDoubleValue() <= 0.0) {
|
||||
return kDefaultMax;
|
||||
}
|
||||
|
||||
return attrMax->GetDoubleValue();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLProgressElement::SetMax(double aValue)
|
||||
{
|
||||
ErrorResult rv;
|
||||
SetMax(aValue, rv);
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLProgressElement::GetPosition(double* aPosition)
|
||||
{
|
||||
*aPosition = Position();
|
||||
}
|
||||
|
||||
double
|
||||
HTMLProgressElement::Position() const
|
||||
{
|
||||
if (IsIndeterminate()) {
|
||||
return kIndeterminatePosition;
|
||||
}
|
||||
|
||||
return Value() / Max();
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLProgressElement::IsIndeterminate() const
|
||||
{
|
||||
const nsAttrValue* attrValue = mAttrsAndChildren.GetAttr(nsGkAtoms::value);
|
||||
return !attrValue || attrValue->Type() != nsAttrValue::eDoubleValue;
|
||||
}
|
||||
|
||||
JSObject*
|
||||
HTMLProgressElement::WrapNode(JSContext* aCx, JSObject* aScope,
|
||||
bool* aTriedToWrap)
|
||||
{
|
||||
return HTMLProgressElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
@ -1,87 +0,0 @@
|
||||
/* -*- Mode: C++; 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/. */
|
||||
|
||||
#ifndef mozilla_dom_HTMLProgressElement_h
|
||||
#define mozilla_dom_HTMLProgressElement_h
|
||||
|
||||
#include "nsIDOMHTMLProgressElement.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsAttrValue.h"
|
||||
#include "nsAttrValueInlines.h"
|
||||
#include "nsEventStateManager.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class HTMLProgressElement : public nsGenericHTMLElement,
|
||||
public nsIDOMHTMLProgressElement
|
||||
{
|
||||
public:
|
||||
HTMLProgressElement(already_AddRefed<nsINodeInfo> aNodeInfo);
|
||||
virtual ~HTMLProgressElement();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIDOMNode
|
||||
NS_FORWARD_NSIDOMNODE_TO_NSINODE
|
||||
|
||||
// nsIDOMElement
|
||||
NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
|
||||
|
||||
// nsIDOMHTMLElement
|
||||
NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
|
||||
|
||||
// nsIDOMHTMLProgressElement
|
||||
NS_DECL_NSIDOMHTMLPROGRESSELEMENT
|
||||
|
||||
nsEventStates IntrinsicState() const;
|
||||
|
||||
nsresult Clone(nsINodeInfo* aNodeInfo, nsINode** aResult) const;
|
||||
|
||||
bool ParseAttribute(int32_t aNamespaceID, nsIAtom* aAttribute,
|
||||
const nsAString& aValue, nsAttrValue& aResult);
|
||||
|
||||
virtual nsXPCClassInfo* GetClassInfo();
|
||||
|
||||
virtual nsIDOMNode* AsDOMNode() { return this; }
|
||||
|
||||
// WebIDL
|
||||
double Value() const;
|
||||
void SetValue(double aValue, ErrorResult& aRv)
|
||||
{
|
||||
aRv = SetDoubleAttr(nsGkAtoms::value, aValue);
|
||||
}
|
||||
double Max() const;
|
||||
void SetMax(double aValue, ErrorResult& aRv)
|
||||
{
|
||||
aRv = SetDoubleAttr(nsGkAtoms::max, aValue);
|
||||
}
|
||||
double Position() const;
|
||||
|
||||
protected:
|
||||
virtual JSObject* WrapNode(JSContext* aCx, JSObject* aScope,
|
||||
bool* aTriedToWrap) MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Returns whethem the progress element is in the indeterminate state.
|
||||
* A progress element is in the indeterminate state if its value is ommited
|
||||
* or is not a floating point number..
|
||||
*
|
||||
* @return whether the progress element is in the indeterminate state.
|
||||
*/
|
||||
bool IsIndeterminate() const;
|
||||
|
||||
static const double kIndeterminatePosition;
|
||||
static const double kDefaultValue;
|
||||
static const double kDefaultMax;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_HTMLProgressElement_h
|
@ -53,7 +53,6 @@ EXPORTS_mozilla/dom = \
|
||||
HTMLOptGroupElement.h \
|
||||
HTMLParagraphElement.h \
|
||||
HTMLPreElement.h \
|
||||
HTMLProgressElement.h \
|
||||
HTMLScriptElement.h \
|
||||
HTMLSharedElement.h \
|
||||
HTMLSharedListElement.h \
|
||||
@ -115,7 +114,7 @@ CPPSRCS = \
|
||||
nsHTMLOutputElement.cpp \
|
||||
HTMLParagraphElement.cpp \
|
||||
HTMLPreElement.cpp \
|
||||
HTMLProgressElement.cpp \
|
||||
nsHTMLProgressElement.cpp \
|
||||
HTMLScriptElement.cpp \
|
||||
nsHTMLSelectElement.cpp \
|
||||
HTMLSharedElement.cpp \
|
||||
|
192
content/html/content/src/nsHTMLProgressElement.cpp
Normal file
192
content/html/content/src/nsHTMLProgressElement.cpp
Normal file
@ -0,0 +1,192 @@
|
||||
/* -*- Mode: C++; 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/. */
|
||||
|
||||
#include "nsIDOMHTMLProgressElement.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsAttrValue.h"
|
||||
#include "nsAttrValueInlines.h"
|
||||
#include "nsEventStateManager.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
||||
class nsHTMLProgressElement : public nsGenericHTMLElement,
|
||||
public nsIDOMHTMLProgressElement
|
||||
{
|
||||
public:
|
||||
nsHTMLProgressElement(already_AddRefed<nsINodeInfo> aNodeInfo);
|
||||
virtual ~nsHTMLProgressElement();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIDOMNode
|
||||
NS_FORWARD_NSIDOMNODE_TO_NSINODE
|
||||
|
||||
// nsIDOMElement
|
||||
NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
|
||||
|
||||
// nsIDOMHTMLElement
|
||||
NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
|
||||
|
||||
// nsIDOMHTMLProgressElement
|
||||
NS_DECL_NSIDOMHTMLPROGRESSELEMENT
|
||||
|
||||
nsEventStates IntrinsicState() const;
|
||||
|
||||
nsresult Clone(nsINodeInfo* aNodeInfo, nsINode** aResult) const;
|
||||
|
||||
bool ParseAttribute(int32_t aNamespaceID, nsIAtom* aAttribute,
|
||||
const nsAString& aValue, nsAttrValue& aResult);
|
||||
|
||||
virtual nsXPCClassInfo* GetClassInfo();
|
||||
|
||||
virtual nsIDOMNode* AsDOMNode() { return this; }
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Returns whethem the progress element is in the indeterminate state.
|
||||
* A progress element is in the indeterminate state if its value is ommited
|
||||
* or is not a floating point number..
|
||||
*
|
||||
* @return whether the progress element is in the indeterminate state.
|
||||
*/
|
||||
bool IsIndeterminate() const;
|
||||
|
||||
static const double kIndeterminatePosition;
|
||||
static const double kDefaultValue;
|
||||
static const double kDefaultMax;
|
||||
};
|
||||
|
||||
const double nsHTMLProgressElement::kIndeterminatePosition = -1.0;
|
||||
const double nsHTMLProgressElement::kDefaultValue = 0.0;
|
||||
const double nsHTMLProgressElement::kDefaultMax = 1.0;
|
||||
|
||||
NS_IMPL_NS_NEW_HTML_ELEMENT(Progress)
|
||||
|
||||
|
||||
nsHTMLProgressElement::nsHTMLProgressElement(already_AddRefed<nsINodeInfo> aNodeInfo)
|
||||
: nsGenericHTMLElement(aNodeInfo)
|
||||
{
|
||||
// We start out indeterminate
|
||||
AddStatesSilently(NS_EVENT_STATE_INDETERMINATE);
|
||||
}
|
||||
|
||||
nsHTMLProgressElement::~nsHTMLProgressElement()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsHTMLProgressElement, Element)
|
||||
NS_IMPL_RELEASE_INHERITED(nsHTMLProgressElement, Element)
|
||||
|
||||
DOMCI_NODE_DATA(HTMLProgressElement, nsHTMLProgressElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsHTMLProgressElement)
|
||||
NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLProgressElement,
|
||||
nsIDOMHTMLProgressElement)
|
||||
NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLProgressElement,
|
||||
nsGenericHTMLElement)
|
||||
NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLProgressElement)
|
||||
|
||||
NS_IMPL_ELEMENT_CLONE(nsHTMLProgressElement)
|
||||
|
||||
|
||||
nsEventStates
|
||||
nsHTMLProgressElement::IntrinsicState() const
|
||||
{
|
||||
nsEventStates state = nsGenericHTMLElement::IntrinsicState();
|
||||
|
||||
if (IsIndeterminate()) {
|
||||
state |= NS_EVENT_STATE_INDETERMINATE;
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
bool
|
||||
nsHTMLProgressElement::ParseAttribute(int32_t aNamespaceID, nsIAtom* aAttribute,
|
||||
const nsAString& aValue, nsAttrValue& aResult)
|
||||
{
|
||||
if (aNamespaceID == kNameSpaceID_None) {
|
||||
if (aAttribute == nsGkAtoms::value || aAttribute == nsGkAtoms::max) {
|
||||
return aResult.ParseDoubleValue(aValue);
|
||||
}
|
||||
}
|
||||
|
||||
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute,
|
||||
aValue, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLProgressElement::GetValue(double* aValue)
|
||||
{
|
||||
const nsAttrValue* attrValue = mAttrsAndChildren.GetAttr(nsGkAtoms::value);
|
||||
if (!attrValue || attrValue->Type() != nsAttrValue::eDoubleValue ||
|
||||
attrValue->GetDoubleValue() < 0.0) {
|
||||
*aValue = kDefaultValue;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*aValue = attrValue->GetDoubleValue();
|
||||
|
||||
double max;
|
||||
GetMax(&max);
|
||||
|
||||
*aValue = std::min(*aValue, max);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLProgressElement::SetValue(double aValue)
|
||||
{
|
||||
return SetDoubleAttr(nsGkAtoms::value, aValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLProgressElement::GetMax(double* aValue)
|
||||
{
|
||||
const nsAttrValue* attrMax = mAttrsAndChildren.GetAttr(nsGkAtoms::max);
|
||||
if (attrMax && attrMax->Type() == nsAttrValue::eDoubleValue &&
|
||||
attrMax->GetDoubleValue() > 0.0) {
|
||||
*aValue = attrMax->GetDoubleValue();
|
||||
} else {
|
||||
*aValue = kDefaultMax;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLProgressElement::SetMax(double aValue)
|
||||
{
|
||||
return SetDoubleAttr(nsGkAtoms::max, aValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLProgressElement::GetPosition(double* aPosition)
|
||||
{
|
||||
if (IsIndeterminate()) {
|
||||
*aPosition = kIndeterminatePosition;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
double value;
|
||||
double max;
|
||||
GetValue(&value);
|
||||
GetMax(&max);
|
||||
|
||||
*aPosition = value / max;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
nsHTMLProgressElement::IsIndeterminate() const
|
||||
{
|
||||
const nsAttrValue* attrValue = mAttrsAndChildren.GetAttr(nsGkAtoms::value);
|
||||
return !attrValue || attrValue->Type() != nsAttrValue::eDoubleValue;
|
||||
}
|
||||
|
@ -506,10 +506,6 @@ DOMInterfaces = {
|
||||
'hasInstanceInterface': 'nsIDOMHTMLPreElement',
|
||||
},
|
||||
|
||||
'HTMLProgressElement': {
|
||||
'hasInstanceInterface': 'nsIDOMHTMLProgressElement',
|
||||
},
|
||||
|
||||
'HTMLPropertiesCollection': {
|
||||
'headerFile': 'HTMLPropertiesCollection.h',
|
||||
'resultNotAddRefed': [ 'item', 'namedItem', 'names' ]
|
||||
|
@ -1,25 +0,0 @@
|
||||
/* -*- 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-progress-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.
|
||||
*/
|
||||
|
||||
interface HTMLProgressElement : HTMLElement {
|
||||
[SetterThrows]
|
||||
attribute double value;
|
||||
[SetterThrows]
|
||||
attribute double max;
|
||||
readonly attribute double position;
|
||||
|
||||
/**
|
||||
* The labels attribute will be done with bug 567740.
|
||||
*/
|
||||
//readonly attribute NodeList labels;
|
||||
};
|
@ -90,7 +90,6 @@ webidl_files = \
|
||||
HTMLParagraphElement.webidl \
|
||||
HTMLParamElement.webidl \
|
||||
HTMLPreElement.webidl \
|
||||
HTMLProgressElement.webidl \
|
||||
HTMLPropertiesCollection.webidl \
|
||||
HTMLQuoteElement.webidl \
|
||||
HTMLScriptElement.webidl \
|
||||
|
Loading…
Reference in New Issue
Block a user