2001-09-25 05:32:19 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2000-05-15 05:58:26 +04:00
|
|
|
|
2006-03-25 08:47:31 +03:00
|
|
|
/* DOM object representing values in DOM computed style */
|
|
|
|
|
2000-05-15 05:58:26 +04:00
|
|
|
#ifndef nsROCSSPrimitiveValue_h___
|
|
|
|
#define nsROCSSPrimitiveValue_h___
|
|
|
|
|
2012-10-01 20:49:41 +04:00
|
|
|
#include "nsIDOMCSSValue.h"
|
2000-05-15 05:58:26 +04:00
|
|
|
#include "nsIDOMCSSPrimitiveValue.h"
|
2007-07-22 21:58:37 +04:00
|
|
|
#include "nsCSSKeywords.h"
|
2012-10-01 20:49:41 +04:00
|
|
|
#include "CSSValue.h"
|
2013-03-03 04:31:48 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2012-10-01 20:49:41 +04:00
|
|
|
#include "nsCoord.h"
|
2000-05-15 05:58:26 +04:00
|
|
|
|
2010-06-04 00:11:34 +04:00
|
|
|
class nsIURI;
|
2012-12-26 07:01:06 +04:00
|
|
|
class nsDOMCSSRect;
|
2010-06-04 00:11:34 +04:00
|
|
|
class nsDOMCSSRGBColor;
|
2000-05-15 05:58:26 +04:00
|
|
|
|
2014-03-29 20:29:30 +04:00
|
|
|
// There is no CSS_TURN constant on the CSSPrimitiveValue interface,
|
|
|
|
// since that unit is newer than DOM Level 2 Style, and CSS OM will
|
|
|
|
// probably expose CSS values in some other way in the future. We
|
|
|
|
// use this value in mType for "turn"-unit angles, but we define it
|
|
|
|
// here to avoid exposing it to content.
|
|
|
|
#define CSS_TURN 30U
|
|
|
|
// Likewise we have some internal aliases for CSS_NUMBER that we don't
|
|
|
|
// want to expose.
|
|
|
|
#define CSS_NUMBER_INT32 31U
|
|
|
|
#define CSS_NUMBER_UINT32 32U
|
|
|
|
|
2011-09-08 15:15:00 +04:00
|
|
|
/**
|
|
|
|
* Read-only CSS primitive value - a DOM object representing values in DOM
|
|
|
|
* computed style.
|
|
|
|
*/
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsROCSSPrimitiveValue final : public mozilla::dom::CSSValue,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsIDOMCSSPrimitiveValue
|
2000-05-15 05:58:26 +04:00
|
|
|
{
|
|
|
|
public:
|
2012-10-01 20:49:41 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsROCSSPrimitiveValue, mozilla::dom::CSSValue)
|
2000-05-15 05:58:26 +04:00
|
|
|
|
|
|
|
// nsIDOMCSSPrimitiveValue
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
NS_DECL_NSIDOMCSSPRIMITIVEVALUE
|
2000-05-15 05:58:26 +04:00
|
|
|
|
|
|
|
// nsIDOMCSSValue
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
NS_DECL_NSIDOMCSSVALUE
|
2000-05-15 05:58:26 +04:00
|
|
|
|
2012-10-01 20:49:41 +04:00
|
|
|
// CSSValue
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void GetCssText(nsString& aText, mozilla::ErrorResult& aRv) override final;
|
|
|
|
virtual void SetCssText(const nsAString& aText, mozilla::ErrorResult& aRv) override final;
|
|
|
|
virtual uint16_t CssValueType() const override final;
|
2012-10-01 20:49:41 +04:00
|
|
|
|
|
|
|
// CSSPrimitiveValue
|
|
|
|
uint16_t PrimitiveType()
|
|
|
|
{
|
2013-07-26 10:02:33 +04:00
|
|
|
// New value types were introduced but not added to CSS OM.
|
|
|
|
// Return CSS_UNKNOWN to avoid exposing CSS_TURN to content.
|
|
|
|
if (mType > CSS_RGBCOLOR) {
|
2014-03-29 20:29:30 +04:00
|
|
|
if (mType == CSS_NUMBER_INT32 || mType == CSS_NUMBER_UINT32) {
|
|
|
|
return CSS_NUMBER;
|
|
|
|
}
|
2013-07-26 10:02:33 +04:00
|
|
|
return CSS_UNKNOWN;
|
|
|
|
}
|
2012-10-01 20:49:41 +04:00
|
|
|
return mType;
|
|
|
|
}
|
|
|
|
void SetFloatValue(uint16_t aUnitType, float aValue,
|
|
|
|
mozilla::ErrorResult& aRv);
|
|
|
|
float GetFloatValue(uint16_t aUnitType, mozilla::ErrorResult& aRv);
|
|
|
|
void GetStringValue(nsString& aString, mozilla::ErrorResult& aRv);
|
|
|
|
void SetStringValue(uint16_t aUnitType, const nsAString& aString,
|
|
|
|
mozilla::ErrorResult& aRv);
|
|
|
|
already_AddRefed<nsIDOMCounter> GetCounterValue(mozilla::ErrorResult& aRv);
|
2012-12-26 21:02:37 +04:00
|
|
|
nsDOMCSSRect* GetRectValue(mozilla::ErrorResult& aRv);
|
2012-10-25 04:43:56 +04:00
|
|
|
nsDOMCSSRGBColor *GetRGBColorValue(mozilla::ErrorResult& aRv);
|
2012-10-01 20:49:41 +04:00
|
|
|
|
2000-05-15 05:58:26 +04:00
|
|
|
// nsROCSSPrimitiveValue
|
2010-08-13 13:58:04 +04:00
|
|
|
nsROCSSPrimitiveValue();
|
2000-05-15 05:58:26 +04:00
|
|
|
|
2010-06-04 00:11:34 +04:00
|
|
|
void SetNumber(float aValue);
|
2012-08-22 19:56:38 +04:00
|
|
|
void SetNumber(int32_t aValue);
|
|
|
|
void SetNumber(uint32_t aValue);
|
2010-06-04 00:11:34 +04:00
|
|
|
void SetPercent(float aValue);
|
2013-07-26 10:02:33 +04:00
|
|
|
void SetDegree(float aValue);
|
|
|
|
void SetGrad(float aValue);
|
|
|
|
void SetRadian(float aValue);
|
|
|
|
void SetTurn(float aValue);
|
2010-06-04 00:11:34 +04:00
|
|
|
void SetAppUnits(nscoord aValue);
|
|
|
|
void SetAppUnits(float aValue);
|
|
|
|
void SetIdent(nsCSSKeyword aKeyword);
|
2007-07-22 21:58:37 +04:00
|
|
|
// FIXME: CSS_STRING should imply a string with "" and a need for escaping.
|
2012-08-22 19:56:38 +04:00
|
|
|
void SetString(const nsACString& aString, uint16_t aType = CSS_STRING);
|
2007-07-22 21:58:37 +04:00
|
|
|
// FIXME: CSS_STRING should imply a string with "" and a need for escaping.
|
2012-08-22 19:56:38 +04:00
|
|
|
void SetString(const nsAString& aString, uint16_t aType = CSS_STRING);
|
2010-06-04 00:11:34 +04:00
|
|
|
void SetURI(nsIURI *aURI);
|
|
|
|
void SetColor(nsDOMCSSRGBColor* aColor);
|
2012-12-26 07:01:06 +04:00
|
|
|
void SetRect(nsDOMCSSRect* aRect);
|
2010-06-04 00:11:34 +04:00
|
|
|
void SetTime(float aValue);
|
|
|
|
void Reset();
|
2002-03-08 22:04:15 +03:00
|
|
|
|
2012-10-01 20:49:41 +04:00
|
|
|
nsISupports* GetParentObject() const
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject *WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
|
2012-10-01 20:49:41 +04:00
|
|
|
|
2000-05-15 05:58:26 +04:00
|
|
|
private:
|
2014-06-26 20:29:05 +04:00
|
|
|
~nsROCSSPrimitiveValue();
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t mType;
|
2000-05-15 05:58:26 +04:00
|
|
|
|
2002-03-08 22:04:15 +03:00
|
|
|
union {
|
2007-02-07 10:46:44 +03:00
|
|
|
nscoord mAppUnits;
|
2002-03-22 23:18:42 +03:00
|
|
|
float mFloat;
|
2014-03-29 20:29:30 +04:00
|
|
|
int32_t mInt32;
|
|
|
|
uint32_t mUint32;
|
2015-04-19 22:05:57 +03:00
|
|
|
// These can't be nsCOMPtr/nsRefPtr's because they are used inside a union.
|
2015-04-19 21:46:47 +03:00
|
|
|
nsDOMCSSRGBColor* MOZ_OWNING_REF mColor;
|
|
|
|
nsDOMCSSRect* MOZ_OWNING_REF mRect;
|
2014-01-04 19:02:17 +04:00
|
|
|
char16_t* mString;
|
2015-04-19 22:05:57 +03:00
|
|
|
nsIURI* MOZ_OWNING_REF mURI;
|
2009-01-23 04:28:14 +03:00
|
|
|
nsCSSKeyword mKeyword;
|
2002-03-08 22:04:15 +03:00
|
|
|
} mValue;
|
2000-05-15 05:58:26 +04:00
|
|
|
};
|
|
|
|
|
2012-10-25 03:38:52 +04:00
|
|
|
inline nsROCSSPrimitiveValue *mozilla::dom::CSSValue::AsPrimitiveValue()
|
|
|
|
{
|
|
|
|
return CssValueType() == nsIDOMCSSValue::CSS_PRIMITIVE_VALUE ?
|
|
|
|
static_cast<nsROCSSPrimitiveValue*>(this) : nullptr;
|
|
|
|
}
|
|
|
|
|
2000-05-15 05:58:26 +04:00
|
|
|
#endif /* nsROCSSPrimitiveValue_h___ */
|
|
|
|
|