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
|
|
|
|
2011-09-08 15:15:00 +04:00
|
|
|
/**
|
|
|
|
* Read-only CSS primitive value - a DOM object representing values in DOM
|
|
|
|
* computed style.
|
|
|
|
*/
|
2012-10-01 20:49:41 +04:00
|
|
|
class nsROCSSPrimitiveValue MOZ_FINAL : public mozilla::dom::CSSValue,
|
|
|
|
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
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
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();
|
2012-10-01 20:49:41 +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);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-04-25 20:29:54 +04:00
|
|
|
virtual JSObject *WrapObject(JSContext *cx,
|
|
|
|
JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
|
2012-10-01 20:49:41 +04:00
|
|
|
|
2000-05-15 05:58:26 +04:00
|
|
|
private:
|
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;
|
2007-01-25 05:03:02 +03:00
|
|
|
nsDOMCSSRGBColor* mColor;
|
2012-12-26 07:01:06 +04:00
|
|
|
nsDOMCSSRect* mRect;
|
2002-03-22 23:18:42 +03:00
|
|
|
PRUnichar* mString;
|
2003-10-02 02:53:56 +04:00
|
|
|
nsIURI* 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___ */
|
|
|
|
|