/* 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 LAYOUT_STYLE_TYPEDOM_CSSNUMERICVALUE_H_ #define LAYOUT_STYLE_TYPEDOM_CSSNUMERICVALUE_H_ #include "js/TypeDecls.h" #include "mozilla/dom/CSSMathSumBindingFwd.h" #include "mozilla/dom/CSSNumericValueBindingFwd.h" #include "mozilla/dom/CSSStyleValue.h" #include "mozilla/dom/CSSUnitValueBindingFwd.h" #include "nsStringFwd.h" template struct already_AddRefed; template class nsCOMPtr; class nsISupports; namespace mozilla { struct CSSPropertyId; class ErrorResult; struct StyleNumericValue; struct StyleNumericValueResult; namespace dom { class GlobalObject; template class Sequence; class CSSNumericValue : public CSSStyleValue { public: enum class NumericValueType { Uninitialized, // TODO: Remove once the implementation is complete. UnitValue, MathSum, }; explicit CSSNumericValue(nsCOMPtr aParent); CSSNumericValue(nsCOMPtr aParent, NumericValueType aNumericValueType); static RefPtr Create(nsCOMPtr aParent, const StyleNumericValue& aNumericValue); JSObject* WrapObject(JSContext* aCx, JS::Handle aGivenProto) override; // start of CSSNumbericValue Web IDL declarations already_AddRefed Add( const Sequence& aValues, ErrorResult& aRv); already_AddRefed Sub( const Sequence& aValues, ErrorResult& aRv); already_AddRefed Mul( const Sequence& aValues, ErrorResult& aRv); already_AddRefed Div( const Sequence& aValues, ErrorResult& aRv); already_AddRefed Min( const Sequence& aValues, ErrorResult& aRv); already_AddRefed Max( const Sequence& aValues, ErrorResult& aRv); bool Equals(const Sequence& aValue); // https://drafts.css-houdini.org/css-typed-om-1/#dom-cssnumericvalue-to already_AddRefed To(const nsACString& aUnit, ErrorResult& aRv); already_AddRefed ToSum(const Sequence& aUnits, ErrorResult& aRv); void Type(CSSNumericType& aRetVal); // https://drafts.css-houdini.org/css-typed-om-1/#dom-cssnumericvalue-parse static already_AddRefed Parse(const GlobalObject& aGlobal, const nsACString& aCssText, ErrorResult& aRv); // end of CSSNumbericValue Web IDL declarations NumericValueType GetNumericValueType() const { return mNumericValueType; } bool IsCSSUnitValue() const; // Defined in CSSUnitValue.cpp const CSSUnitValue& GetAsCSSUnitValue() const; // Defined in CSSUnitValue.cpp CSSUnitValue& GetAsCSSUnitValue(); bool IsCSSMathSum() const; // Defined in CSSMathSum.cpp const CSSMathSum& GetAsCSSMathSum() const; // Defined in CSSMathSum.cpp CSSMathSum& GetAsCSSMathSum(); void ToCssTextWithProperty(const CSSPropertyId& aPropertyId, nsACString& aDest) const; // TODO: This can be changed to return StyleNumericValue directly once the // Unitialized type is removed. StyleNumericValueResult ToStyleNumericValue() const; protected: virtual ~CSSNumericValue() = default; const NumericValueType mNumericValueType; }; } // namespace dom } // namespace mozilla #endif // LAYOUT_STYLE_TYPEDOM_CSSNUMERICVALUE_H_