2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
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 "CSSValue.h"
|
|
|
|
#include "nsCoord.h"
|
2020-02-24 16:30:48 +03:00
|
|
|
#include "nsString.h"
|
2000-05-15 05:58:26 +04:00
|
|
|
|
2010-06-04 00:11:34 +04:00
|
|
|
class nsIURI;
|
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.
|
|
|
|
*/
|
2018-01-11 11:17:57 +03:00
|
|
|
class nsROCSSPrimitiveValue final : public mozilla::dom::CSSValue {
|
2000-05-15 05:58:26 +04:00
|
|
|
public:
|
2018-05-08 10:20:43 +03:00
|
|
|
enum : uint16_t {
|
|
|
|
CSS_UNKNOWN,
|
|
|
|
CSS_NUMBER,
|
|
|
|
CSS_PERCENTAGE,
|
|
|
|
CSS_EMS,
|
|
|
|
CSS_EXS,
|
|
|
|
CSS_PX,
|
|
|
|
CSS_CM,
|
|
|
|
CSS_MM,
|
|
|
|
CSS_IN,
|
|
|
|
CSS_PT,
|
|
|
|
CSS_PC,
|
|
|
|
CSS_DEG,
|
|
|
|
CSS_MS,
|
|
|
|
CSS_S,
|
|
|
|
CSS_HZ,
|
|
|
|
CSS_KHZ,
|
|
|
|
CSS_DIMENSION,
|
|
|
|
CSS_STRING,
|
|
|
|
CSS_URI,
|
|
|
|
CSS_RGBCOLOR,
|
|
|
|
CSS_NUMBER_INT32,
|
|
|
|
CSS_NUMBER_UINT32,
|
|
|
|
};
|
2000-05-15 05:58:26 +04:00
|
|
|
|
2012-10-01 20:49:41 +04:00
|
|
|
// CSSValue
|
2018-02-09 08:22:43 +03:00
|
|
|
void GetCssText(nsString& aText, mozilla::ErrorResult& aRv) final;
|
|
|
|
uint16_t CssValueType() const final;
|
2012-10-01 20:49:41 +04:00
|
|
|
|
|
|
|
// CSSPrimitiveValue
|
2018-01-11 11:17:57 +03:00
|
|
|
uint16_t PrimitiveType();
|
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);
|
2020-06-18 03:42:47 +03:00
|
|
|
void SetPixels(float aValue);
|
2010-06-04 00:11:34 +04:00
|
|
|
void SetAppUnits(nscoord aValue);
|
|
|
|
void SetAppUnits(float aValue);
|
2020-02-24 16:30:48 +03:00
|
|
|
void SetString(const nsACString& aString);
|
|
|
|
void SetString(const nsAString& aString);
|
|
|
|
|
|
|
|
template <size_t N>
|
|
|
|
void SetString(const char (&aString)[N]) {
|
|
|
|
SetString(nsLiteralCString(aString));
|
|
|
|
}
|
|
|
|
|
2010-06-04 00:11:34 +04:00
|
|
|
void SetURI(nsIURI* aURI);
|
|
|
|
void SetTime(float aValue);
|
|
|
|
void Reset();
|
2002-03-08 22:04:15 +03:00
|
|
|
|
2018-05-08 10:20:43 +03:00
|
|
|
virtual ~nsROCSSPrimitiveValue();
|
2014-06-26 20:29:05 +04:00
|
|
|
|
2018-05-08 10:20:43 +03:00
|
|
|
protected:
|
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 {
|
2002-03-22 23:18:42 +03:00
|
|
|
float mFloat;
|
2014-03-29 20:29:30 +04:00
|
|
|
int32_t mInt32;
|
|
|
|
uint32_t mUint32;
|
2014-01-04 19:02:17 +04:00
|
|
|
char16_t* mString;
|
2015-04-19 22:05:57 +03:00
|
|
|
nsIURI* MOZ_OWNING_REF mURI;
|
2002-03-08 22:04:15 +03:00
|
|
|
} mValue;
|
2000-05-15 05:58:26 +04:00
|
|
|
};
|
|
|
|
|
2018-01-11 11:17:57 +03:00
|
|
|
inline nsROCSSPrimitiveValue* mozilla::dom::CSSValue::AsPrimitiveValue() {
|
2018-05-08 10:20:43 +03:00
|
|
|
return CssValueType() == mozilla::dom::CSSValue::CSS_PRIMITIVE_VALUE
|
|
|
|
? static_cast<nsROCSSPrimitiveValue*>(this)
|
|
|
|
: nullptr;
|
2012-10-25 03:38:52 +04:00
|
|
|
}
|
|
|
|
|
2000-05-15 05:58:26 +04:00
|
|
|
#endif /* nsROCSSPrimitiveValue_h___ */
|