2001-09-25 05:32:19 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
2000-05-15 05:58:26 +04:00
|
|
|
*
|
2001-09-25 05:32:19 +04:00
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.1 (the "License"); you may not use this file except in
|
|
|
|
* compliance with the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/NPL/
|
2000-05-15 05:58:26 +04:00
|
|
|
*
|
2001-09-25 05:32:19 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
2000-05-15 05:58:26 +04:00
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2001-09-25 05:32:19 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
2000-05-15 05:58:26 +04:00
|
|
|
*
|
2001-09-25 05:32:19 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the NPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2000-05-15 05:58:26 +04:00
|
|
|
|
|
|
|
#ifndef nsROCSSPrimitiveValue_h___
|
|
|
|
#define nsROCSSPrimitiveValue_h___
|
|
|
|
|
|
|
|
#include "nsIDOMCSSPrimitiveValue.h"
|
2001-05-21 07:14:39 +04:00
|
|
|
#include "nsString.h"
|
2000-05-15 05:58:26 +04:00
|
|
|
#include "nsCoord.h"
|
|
|
|
#include "nsUnitConversion.h"
|
2002-01-11 03:15:55 +03:00
|
|
|
#include "nsReadableUtils.h"
|
2000-05-15 05:58:26 +04:00
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsDOMError.h"
|
2002-01-11 03:15:55 +03:00
|
|
|
#include "nsDOMCSSRect.h"
|
2000-05-15 05:58:26 +04:00
|
|
|
|
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
|
|
|
class nsROCSSPrimitiveValue : public nsIDOMCSSPrimitiveValue
|
2000-05-15 05:58:26 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
// nsROCSSPrimitiveValue
|
|
|
|
nsROCSSPrimitiveValue(nsISupports *aOwner, float aP2T);
|
|
|
|
virtual ~nsROCSSPrimitiveValue();
|
|
|
|
|
2002-03-08 22:04:15 +03:00
|
|
|
void SetNumber(float aValue)
|
|
|
|
{
|
|
|
|
Reset();
|
|
|
|
mValue.mFloat = aValue;
|
|
|
|
mType = CSS_NUMBER;
|
|
|
|
}
|
|
|
|
|
2001-12-07 00:15:54 +03:00
|
|
|
void SetPercent(float aValue)
|
|
|
|
{
|
2002-03-08 22:04:15 +03:00
|
|
|
Reset();
|
|
|
|
mValue.mFloat = aValue;
|
2001-12-07 00:15:54 +03:00
|
|
|
mType = CSS_PERCENTAGE;
|
|
|
|
}
|
|
|
|
|
2000-05-15 05:58:26 +04:00
|
|
|
void SetTwips(nscoord aValue)
|
|
|
|
{
|
2002-03-08 22:04:15 +03:00
|
|
|
Reset();
|
|
|
|
mValue.mTwips = aValue;
|
|
|
|
mType = CSS_PX;
|
2000-05-15 05:58:26 +04:00
|
|
|
}
|
|
|
|
|
2002-01-11 03:15:55 +03:00
|
|
|
void SetString(const nsACString& aString)
|
2000-05-15 05:58:26 +04:00
|
|
|
{
|
2002-03-08 22:04:15 +03:00
|
|
|
Reset();
|
|
|
|
mValue.mString = ToNewUnicode(aString);
|
2000-05-15 05:58:26 +04:00
|
|
|
mType = CSS_STRING;
|
|
|
|
}
|
|
|
|
|
2001-09-07 06:28:10 +04:00
|
|
|
void SetString(const nsAString& aString)
|
2000-06-14 04:06:36 +04:00
|
|
|
{
|
2002-03-08 22:04:15 +03:00
|
|
|
Reset();
|
|
|
|
mValue.mString = ToNewUnicode(aString);
|
2000-06-14 04:06:36 +04:00
|
|
|
mType = CSS_STRING;
|
|
|
|
}
|
|
|
|
|
2002-03-13 00:16:22 +03:00
|
|
|
void SetURI(const nsACString& aString)
|
|
|
|
{
|
|
|
|
Reset();
|
|
|
|
mValue.mString = ToNewUnicode(aString);
|
|
|
|
mType = CSS_URI;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetURI(const nsAString& aString)
|
|
|
|
{
|
|
|
|
Reset();
|
|
|
|
mValue.mString = ToNewUnicode(aString);
|
|
|
|
mType = CSS_URI;
|
|
|
|
}
|
|
|
|
|
2002-01-11 03:15:55 +03:00
|
|
|
void SetRect(nsIDOMRect* aRect)
|
|
|
|
{
|
2002-03-08 22:04:15 +03:00
|
|
|
NS_PRECONDITION(aRect, "Null rect being set!");
|
|
|
|
Reset();
|
|
|
|
mValue.mRect = aRect;
|
|
|
|
NS_ADDREF(mValue.mRect);
|
2002-01-11 03:15:55 +03:00
|
|
|
mType = CSS_RECT;
|
|
|
|
}
|
|
|
|
|
2002-03-08 22:04:15 +03:00
|
|
|
void Reset(void)
|
|
|
|
{
|
2002-03-13 00:16:22 +03:00
|
|
|
if (mType == CSS_STRING || mType == CSS_URI) {
|
2002-03-08 22:04:15 +03:00
|
|
|
NS_ASSERTION(mValue.mString, "Null string should never happen");
|
|
|
|
nsMemory::Free(mValue.mString);
|
|
|
|
mValue.mString = nsnull;
|
|
|
|
}
|
|
|
|
else if (mType == CSS_RECT) {
|
|
|
|
NS_ASSERTION(mValue.mRect, "Null Rect should never happen");
|
|
|
|
NS_RELEASE(mValue.mRect);
|
|
|
|
mValue.mRect = nsnull;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-05-15 05:58:26 +04:00
|
|
|
private:
|
|
|
|
PRUint16 mType;
|
|
|
|
|
2002-03-08 22:04:15 +03:00
|
|
|
union {
|
|
|
|
nscoord mTwips;
|
|
|
|
float mFloat;
|
|
|
|
nsIDOMRect* mRect;
|
|
|
|
PRUnichar* mString;
|
|
|
|
} mValue;
|
|
|
|
|
2000-05-15 05:58:26 +04:00
|
|
|
nsISupports *mOwner;
|
|
|
|
|
|
|
|
float mT2P;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsROCSSPrimitiveValue_h___ */
|
|
|
|
|