2001-09-25 01:32:19 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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 01:58:26 +00:00
|
|
|
|
2006-03-25 05:47:31 +00:00
|
|
|
/* DOM object representing values in DOM computed style */
|
|
|
|
|
2000-05-15 01:58:26 +00:00
|
|
|
#ifndef nsROCSSPrimitiveValue_h___
|
|
|
|
#define nsROCSSPrimitiveValue_h___
|
|
|
|
|
2012-10-01 16:49:41 +00:00
|
|
|
#include "nsIDOMCSSValue.h"
|
2000-05-15 01:58:26 +00:00
|
|
|
#include "nsIDOMCSSPrimitiveValue.h"
|
2007-07-22 17:58:37 +00:00
|
|
|
#include "nsCSSKeywords.h"
|
2012-10-01 16:49:41 +00:00
|
|
|
#include "CSSValue.h"
|
2013-03-03 00:31:48 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2012-10-01 16:49:41 +00:00
|
|
|
#include "nsCoord.h"
|
2000-05-15 01:58:26 +00:00
|
|
|
|
2010-06-03 20:11:34 +00:00
|
|
|
class nsIURI;
|
2012-12-26 03:01:06 +00:00
|
|
|
class nsDOMCSSRect;
|
2010-06-03 20:11:34 +00:00
|
|
|
class nsDOMCSSRGBColor;
|
2000-05-15 01:58:26 +00:00
|
|
|
|
2014-03-29 16:29:30 +00: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 11:15:00 +00:00
|
|
|
/**
|
|
|
|
* Read-only CSS primitive value - a DOM object representing values in DOM
|
|
|
|
* computed style.
|
|
|
|
*/
|
2012-10-01 16:49:41 +00:00
|
|
|
class nsROCSSPrimitiveValue MOZ_FINAL : public mozilla::dom::CSSValue,
|
|
|
|
public nsIDOMCSSPrimitiveValue
|
2000-05-15 01:58:26 +00:00
|
|
|
{
|
|
|
|
public:
|
2012-10-01 16:49:41 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsROCSSPrimitiveValue, mozilla::dom::CSSValue)
|
2000-05-15 01:58:26 +00: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 16:46:42 +00:00
|
|
|
NS_DECL_NSIDOMCSSPRIMITIVEVALUE
|
2000-05-15 01:58:26 +00: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 16:46:42 +00:00
|
|
|
NS_DECL_NSIDOMCSSVALUE
|
2000-05-15 01:58:26 +00:00
|
|
|
|
2012-10-01 16:49:41 +00:00
|
|
|
// CSSValue
|
|
|
|
virtual void GetCssText(nsString& aText, mozilla::ErrorResult& aRv) MOZ_OVERRIDE MOZ_FINAL;
|
|
|
|
virtual void SetCssText(const nsAString& aText, mozilla::ErrorResult& aRv) MOZ_OVERRIDE MOZ_FINAL;
|
|
|
|
virtual uint16_t CssValueType() const MOZ_OVERRIDE MOZ_FINAL;
|
|
|
|
|
|
|
|
// CSSPrimitiveValue
|
|
|
|
uint16_t PrimitiveType()
|
|
|
|
{
|
2013-07-26 06:02:33 +00: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 16:29:30 +00:00
|
|
|
if (mType == CSS_NUMBER_INT32 || mType == CSS_NUMBER_UINT32) {
|
|
|
|
return CSS_NUMBER;
|
|
|
|
}
|
2013-07-26 06:02:33 +00:00
|
|
|
return CSS_UNKNOWN;
|
|
|
|
}
|
2012-10-01 16:49:41 +00: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 17:02:37 +00:00
|
|
|
nsDOMCSSRect* GetRectValue(mozilla::ErrorResult& aRv);
|
2012-10-25 00:43:56 +00:00
|
|
|
nsDOMCSSRGBColor *GetRGBColorValue(mozilla::ErrorResult& aRv);
|
2012-10-01 16:49:41 +00:00
|
|
|
|
2000-05-15 01:58:26 +00:00
|
|
|
// nsROCSSPrimitiveValue
|
2010-08-13 09:58:04 +00:00
|
|
|
nsROCSSPrimitiveValue();
|
2000-05-15 01:58:26 +00:00
|
|
|
|
2010-06-03 20:11:34 +00:00
|
|
|
void SetNumber(float aValue);
|
2012-08-22 15:56:38 +00:00
|
|
|
void SetNumber(int32_t aValue);
|
|
|
|
void SetNumber(uint32_t aValue);
|
2010-06-03 20:11:34 +00:00
|
|
|
void SetPercent(float aValue);
|
2013-07-26 06:02:33 +00:00
|
|
|
void SetDegree(float aValue);
|
|
|
|
void SetGrad(float aValue);
|
|
|
|
void SetRadian(float aValue);
|
|
|
|
void SetTurn(float aValue);
|
2010-06-03 20:11:34 +00:00
|
|
|
void SetAppUnits(nscoord aValue);
|
|
|
|
void SetAppUnits(float aValue);
|
|
|
|
void SetIdent(nsCSSKeyword aKeyword);
|
2007-07-22 17:58:37 +00:00
|
|
|
// FIXME: CSS_STRING should imply a string with "" and a need for escaping.
|
2012-08-22 15:56:38 +00:00
|
|
|
void SetString(const nsACString& aString, uint16_t aType = CSS_STRING);
|
2007-07-22 17:58:37 +00:00
|
|
|
// FIXME: CSS_STRING should imply a string with "" and a need for escaping.
|
2012-08-22 15:56:38 +00:00
|
|
|
void SetString(const nsAString& aString, uint16_t aType = CSS_STRING);
|
2010-06-03 20:11:34 +00:00
|
|
|
void SetURI(nsIURI *aURI);
|
|
|
|
void SetColor(nsDOMCSSRGBColor* aColor);
|
2012-12-26 03:01:06 +00:00
|
|
|
void SetRect(nsDOMCSSRect* aRect);
|
2010-06-03 20:11:34 +00:00
|
|
|
void SetTime(float aValue);
|
|
|
|
void Reset();
|
2002-03-08 19:04:15 +00:00
|
|
|
|
2012-10-01 16:49:41 +00:00
|
|
|
nsISupports* GetParentObject() const
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-04-08 22:27:18 +00:00
|
|
|
virtual JSObject *WrapObject(JSContext *cx) MOZ_OVERRIDE;
|
2012-10-01 16:49:41 +00:00
|
|
|
|
2000-05-15 01:58:26 +00:00
|
|
|
private:
|
2014-06-26 16:29:05 +00:00
|
|
|
~nsROCSSPrimitiveValue();
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint16_t mType;
|
2000-05-15 01:58:26 +00:00
|
|
|
|
2002-03-08 19:04:15 +00:00
|
|
|
union {
|
2007-02-07 07:46:44 +00:00
|
|
|
nscoord mAppUnits;
|
2002-03-22 20:18:42 +00:00
|
|
|
float mFloat;
|
2014-03-29 16:29:30 +00:00
|
|
|
int32_t mInt32;
|
|
|
|
uint32_t mUint32;
|
2007-01-25 02:03:02 +00:00
|
|
|
nsDOMCSSRGBColor* mColor;
|
2012-12-26 03:01:06 +00:00
|
|
|
nsDOMCSSRect* mRect;
|
2014-01-04 15:02:17 +00:00
|
|
|
char16_t* mString;
|
2003-10-01 22:53:56 +00:00
|
|
|
nsIURI* mURI;
|
2009-01-23 01:28:14 +00:00
|
|
|
nsCSSKeyword mKeyword;
|
2002-03-08 19:04:15 +00:00
|
|
|
} mValue;
|
2000-05-15 01:58:26 +00:00
|
|
|
};
|
|
|
|
|
2012-10-24 23:38:52 +00:00
|
|
|
inline nsROCSSPrimitiveValue *mozilla::dom::CSSValue::AsPrimitiveValue()
|
|
|
|
{
|
|
|
|
return CssValueType() == nsIDOMCSSValue::CSS_PRIMITIVE_VALUE ?
|
|
|
|
static_cast<nsROCSSPrimitiveValue*>(this) : nullptr;
|
|
|
|
}
|
|
|
|
|
2000-05-15 01:58:26 +00:00
|
|
|
#endif /* nsROCSSPrimitiveValue_h___ */
|
|
|
|
|