2001-09-25 05:32:19 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 01:52:36 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
2000-05-15 05:58:26 +04:00
|
|
|
*
|
2004-04-18 01:52:36 +04:00
|
|
|
* The contents of this file are subject to the Mozilla 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/MPL/
|
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.
|
|
|
|
*
|
2004-04-18 01:52:36 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-25 05:32:19 +04:00
|
|
|
* 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
|
2004-04-18 01:52:36 +04:00
|
|
|
* either of 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"),
|
2001-09-25 05:32:19 +04:00
|
|
|
* 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
|
2004-04-18 01:52:36 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-25 05:32:19 +04:00
|
|
|
* 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
|
2004-04-18 01:52:36 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-25 05:32:19 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
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
|
|
|
#include "nsROCSSPrimitiveValue.h"
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsDOMError.h"
|
2000-06-14 04:06:36 +04:00
|
|
|
#include "prprf.h"
|
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
|
|
|
#include "nsContentUtils.h"
|
2002-03-27 10:39:54 +03:00
|
|
|
#include "nsXPIDLString.h"
|
2002-05-15 22:55:21 +04:00
|
|
|
#include "nsCRT.h"
|
2007-02-07 10:46:44 +03:00
|
|
|
#include "nsPresContext.h"
|
2000-05-15 05:58:26 +04:00
|
|
|
|
2007-02-07 10:46:44 +03:00
|
|
|
nsROCSSPrimitiveValue::nsROCSSPrimitiveValue(PRInt32 aAppUnitsPerInch)
|
|
|
|
: mType(CSS_PX), mAppUnitsPerInch(aAppUnitsPerInch)
|
2000-05-15 05:58:26 +04:00
|
|
|
{
|
2007-02-07 10:46:44 +03:00
|
|
|
mValue.mAppUnits = 0;
|
2000-05-15 05:58:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nsROCSSPrimitiveValue::~nsROCSSPrimitiveValue()
|
|
|
|
{
|
2002-03-08 22:04:15 +03:00
|
|
|
Reset();
|
2000-05-15 05:58:26 +04:00
|
|
|
}
|
|
|
|
|
2002-03-27 10:39:54 +03:00
|
|
|
void
|
2003-10-02 02:53:56 +04:00
|
|
|
nsROCSSPrimitiveValue::GetEscapedURI(nsIURI *aURI, PRUnichar **aReturn)
|
2002-03-27 10:39:54 +03:00
|
|
|
{
|
2003-10-02 02:53:56 +04:00
|
|
|
nsCAutoString specUTF8;
|
|
|
|
aURI->GetSpec(specUTF8);
|
2006-02-03 17:18:39 +03:00
|
|
|
NS_ConvertUTF8toUTF16 spec(specUTF8);
|
2003-10-02 02:53:56 +04:00
|
|
|
|
|
|
|
PRUint16 length = spec.Length();
|
2002-03-27 10:39:54 +03:00
|
|
|
PRUnichar *escaped = (PRUnichar *)nsMemory::Alloc(length * 2 * sizeof(PRUnichar) + sizeof(PRUnichar('\0')));
|
|
|
|
|
|
|
|
if (escaped) {
|
|
|
|
PRUnichar *ptr = escaped;
|
|
|
|
|
|
|
|
for (PRUint16 i = 0; i < length; ++i) {
|
2003-10-02 02:53:56 +04:00
|
|
|
switch (spec[i]) {
|
2002-03-27 10:39:54 +03:00
|
|
|
case ' ' : // space
|
|
|
|
case '\t': // tab
|
|
|
|
case '(' : // opening parenthesis
|
|
|
|
case ')' : // closing parenthesis
|
|
|
|
case '\'': // single quote
|
|
|
|
case '"' : // double quote
|
|
|
|
case ',' : // comma
|
|
|
|
case '\\': // backslash
|
|
|
|
// We have one of the above special characters.
|
|
|
|
// Prepend it with a backslash.
|
|
|
|
*ptr++ = '\\';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2003-10-02 02:53:56 +04:00
|
|
|
*ptr++ = spec[i];
|
2002-03-27 10:39:54 +03:00
|
|
|
}
|
|
|
|
*ptr = 0;
|
|
|
|
}
|
|
|
|
*aReturn = escaped;
|
|
|
|
}
|
|
|
|
|
2000-05-15 05:58:26 +04:00
|
|
|
|
2003-09-08 01:50:21 +04:00
|
|
|
NS_IMPL_ADDREF(nsROCSSPrimitiveValue)
|
|
|
|
NS_IMPL_RELEASE(nsROCSSPrimitiveValue)
|
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
|
|
|
// QueryInterface implementation for nsROCSSPrimitiveValue
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsROCSSPrimitiveValue)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSPrimitiveValue)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSValue)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMCSSPrimitiveValue)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(ROCSSPrimitiveValue)
|
|
|
|
NS_INTERFACE_MAP_END
|
2000-05-15 05:58:26 +04:00
|
|
|
|
|
|
|
|
|
|
|
// nsIDOMCSSValue
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2002-03-24 01:56:05 +03:00
|
|
|
nsROCSSPrimitiveValue::GetCssText(nsAString& aCssText)
|
2000-05-15 05:58:26 +04:00
|
|
|
{
|
2000-08-23 21:27:06 +04:00
|
|
|
nsAutoString tmpStr;
|
2000-05-15 05:58:26 +04:00
|
|
|
aCssText.Truncate();
|
2002-01-11 03:15:55 +03:00
|
|
|
nsresult result = NS_OK;
|
2000-06-14 04:06:36 +04:00
|
|
|
|
|
|
|
switch (mType) {
|
|
|
|
case CSS_PX :
|
|
|
|
{
|
2007-02-07 10:46:44 +03:00
|
|
|
float val = nsPresContext::AppUnitsToFloatCSSPixels(mValue.mAppUnits);
|
2002-01-11 03:15:55 +03:00
|
|
|
tmpStr.AppendFloat(val);
|
2004-06-17 04:13:25 +04:00
|
|
|
tmpStr.AppendLiteral("px");
|
2000-06-14 04:06:36 +04:00
|
|
|
break;
|
|
|
|
}
|
2002-03-22 23:18:42 +03:00
|
|
|
case CSS_IDENT :
|
2004-01-18 05:42:27 +03:00
|
|
|
{
|
|
|
|
const char *atomValue;
|
|
|
|
mValue.mAtom->GetUTF8String(&atomValue);
|
|
|
|
AppendUTF8toUTF16(atomValue, tmpStr);
|
|
|
|
break;
|
|
|
|
}
|
2000-06-14 04:06:36 +04:00
|
|
|
case CSS_STRING :
|
2007-07-22 21:58:37 +04:00
|
|
|
case CSS_COUNTER : /* FIXME: COUNTER should use an object */
|
2000-06-14 04:06:36 +04:00
|
|
|
{
|
2002-03-08 22:04:15 +03:00
|
|
|
tmpStr.Append(mValue.mString);
|
2000-06-14 04:06:36 +04:00
|
|
|
break;
|
|
|
|
}
|
2002-03-13 00:16:22 +03:00
|
|
|
case CSS_URI :
|
|
|
|
{
|
2002-03-27 10:39:54 +03:00
|
|
|
nsXPIDLString uri;
|
2003-10-02 02:53:56 +04:00
|
|
|
if (mValue.mURI) {
|
|
|
|
GetEscapedURI(mValue.mURI, getter_Copies(uri));
|
|
|
|
tmpStr.Assign(NS_LITERAL_STRING("url(") +
|
|
|
|
uri +
|
|
|
|
NS_LITERAL_STRING(")"));
|
|
|
|
} else {
|
|
|
|
// XXXldb Any better ideas? It's good to have something that
|
|
|
|
// doesn't parse so that things round-trip "correctly".
|
|
|
|
tmpStr.Assign(NS_LITERAL_STRING("url(invalid-url:)"));
|
|
|
|
}
|
2002-03-13 00:16:22 +03:00
|
|
|
break;
|
|
|
|
}
|
2007-07-22 21:58:37 +04:00
|
|
|
case CSS_ATTR :
|
|
|
|
{
|
|
|
|
tmpStr.AppendLiteral("attr(");
|
|
|
|
tmpStr.Append(mValue.mString);
|
|
|
|
tmpStr.Append(PRUnichar(')'));
|
|
|
|
break;
|
|
|
|
}
|
2001-12-07 00:15:54 +03:00
|
|
|
case CSS_PERCENTAGE :
|
|
|
|
{
|
2002-03-08 22:04:15 +03:00
|
|
|
tmpStr.AppendFloat(mValue.mFloat * 100);
|
2001-12-07 00:15:54 +03:00
|
|
|
tmpStr.Append(PRUnichar('%'));
|
|
|
|
break;
|
|
|
|
}
|
2002-03-08 22:04:15 +03:00
|
|
|
case CSS_NUMBER :
|
|
|
|
{
|
|
|
|
tmpStr.AppendFloat(mValue.mFloat);
|
|
|
|
break;
|
|
|
|
}
|
2002-01-11 03:15:55 +03:00
|
|
|
case CSS_RECT :
|
|
|
|
{
|
2002-03-08 22:04:15 +03:00
|
|
|
NS_ASSERTION(mValue.mRect, "mValue.mRect should never be null");
|
2002-01-11 03:15:55 +03:00
|
|
|
NS_NAMED_LITERAL_STRING(comma, ", ");
|
|
|
|
nsCOMPtr<nsIDOMCSSPrimitiveValue> sideCSSValue;
|
|
|
|
nsAutoString sideValue;
|
2004-06-17 04:13:25 +04:00
|
|
|
tmpStr.AssignLiteral("rect(");
|
2002-01-11 03:15:55 +03:00
|
|
|
// get the top
|
2002-03-08 22:04:15 +03:00
|
|
|
result = mValue.mRect->GetTop(getter_AddRefs(sideCSSValue));
|
2002-01-11 03:15:55 +03:00
|
|
|
if (NS_FAILED(result))
|
|
|
|
break;
|
|
|
|
result = sideCSSValue->GetCssText(sideValue);
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
break;
|
|
|
|
tmpStr.Append(sideValue + comma);
|
|
|
|
// get the right
|
2002-03-08 22:04:15 +03:00
|
|
|
result = mValue.mRect->GetRight(getter_AddRefs(sideCSSValue));
|
2002-01-11 03:15:55 +03:00
|
|
|
if (NS_FAILED(result))
|
|
|
|
break;
|
|
|
|
result = sideCSSValue->GetCssText(sideValue);
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
break;
|
|
|
|
tmpStr.Append(sideValue + comma);
|
|
|
|
// get the bottom
|
2002-03-08 22:04:15 +03:00
|
|
|
result = mValue.mRect->GetBottom(getter_AddRefs(sideCSSValue));
|
2002-01-11 03:15:55 +03:00
|
|
|
if (NS_FAILED(result))
|
|
|
|
break;
|
|
|
|
result = sideCSSValue->GetCssText(sideValue);
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
break;
|
|
|
|
tmpStr.Append(sideValue + comma);
|
|
|
|
// get the left
|
2002-03-08 22:04:15 +03:00
|
|
|
result = mValue.mRect->GetLeft(getter_AddRefs(sideCSSValue));
|
2002-01-11 03:15:55 +03:00
|
|
|
if (NS_FAILED(result))
|
|
|
|
break;
|
|
|
|
result = sideCSSValue->GetCssText(sideValue);
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
break;
|
|
|
|
tmpStr.Append(sideValue + NS_LITERAL_STRING(")"));
|
2002-03-22 23:18:42 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CSS_RGBCOLOR :
|
|
|
|
{
|
|
|
|
NS_ASSERTION(mValue.mColor, "mValue.mColor should never be null");
|
|
|
|
NS_NAMED_LITERAL_STRING(comma, ", ");
|
|
|
|
nsCOMPtr<nsIDOMCSSPrimitiveValue> colorCSSValue;
|
|
|
|
nsAutoString colorValue;
|
2007-01-25 05:03:02 +03:00
|
|
|
if (mValue.mColor->HasAlpha())
|
|
|
|
tmpStr.AssignLiteral("rgba(");
|
|
|
|
else
|
|
|
|
tmpStr.AssignLiteral("rgb(");
|
2002-03-22 23:18:42 +03:00
|
|
|
|
|
|
|
// get the red component
|
|
|
|
result = mValue.mColor->GetRed(getter_AddRefs(colorCSSValue));
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
break;
|
|
|
|
result = colorCSSValue->GetCssText(colorValue);
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
break;
|
|
|
|
tmpStr.Append(colorValue + comma);
|
|
|
|
|
|
|
|
// get the green component
|
|
|
|
result = mValue.mColor->GetGreen(getter_AddRefs(colorCSSValue));
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
break;
|
|
|
|
result = colorCSSValue->GetCssText(colorValue);
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
break;
|
|
|
|
tmpStr.Append(colorValue + comma);
|
|
|
|
|
|
|
|
// get the blue component
|
|
|
|
result = mValue.mColor->GetBlue(getter_AddRefs(colorCSSValue));
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
break;
|
|
|
|
result = colorCSSValue->GetCssText(colorValue);
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
break;
|
2007-01-25 05:03:02 +03:00
|
|
|
tmpStr.Append(colorValue);
|
|
|
|
|
|
|
|
if (mValue.mColor->HasAlpha()) {
|
|
|
|
// get the alpha component
|
|
|
|
result = mValue.mColor->GetAlpha(getter_AddRefs(colorCSSValue));
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
break;
|
|
|
|
result = colorCSSValue->GetCssText(colorValue);
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
break;
|
|
|
|
tmpStr.Append(comma + colorValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
tmpStr.Append(NS_LITERAL_STRING(")"));
|
2002-03-22 23:18:42 +03:00
|
|
|
|
2002-01-11 03:15:55 +03:00
|
|
|
break;
|
|
|
|
}
|
2007-02-07 10:46:44 +03:00
|
|
|
case CSS_CM :
|
|
|
|
case CSS_MM :
|
|
|
|
case CSS_IN :
|
|
|
|
case CSS_PT :
|
2000-06-14 04:06:36 +04:00
|
|
|
case CSS_PC :
|
|
|
|
case CSS_UNKNOWN :
|
|
|
|
case CSS_EMS :
|
|
|
|
case CSS_EXS :
|
|
|
|
case CSS_DEG :
|
|
|
|
case CSS_RAD :
|
|
|
|
case CSS_GRAD :
|
|
|
|
case CSS_MS :
|
|
|
|
case CSS_S :
|
|
|
|
case CSS_HZ :
|
|
|
|
case CSS_KHZ :
|
|
|
|
case CSS_DIMENSION :
|
2002-03-08 22:04:15 +03:00
|
|
|
NS_ERROR("We have a bogus value set. This should not happen");
|
2000-06-14 04:06:36 +04:00
|
|
|
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
|
|
|
}
|
|
|
|
|
2002-01-11 03:15:55 +03:00
|
|
|
if (NS_SUCCEEDED(result)) {
|
|
|
|
aCssText.Assign(tmpStr);
|
|
|
|
}
|
2000-08-23 21:27:06 +04:00
|
|
|
|
2000-06-14 04:06:36 +04:00
|
|
|
return NS_OK;
|
2000-05-15 05:58:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2002-03-24 01:56:05 +03:00
|
|
|
nsROCSSPrimitiveValue::SetCssText(const nsAString& aCssText)
|
2000-05-15 05:58:26 +04:00
|
|
|
{
|
|
|
|
return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2000-09-19 09:37:23 +04:00
|
|
|
nsROCSSPrimitiveValue::GetCssValueType(PRUint16* aValueType)
|
2000-05-15 05:58:26 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aValueType);
|
|
|
|
*aValueType = nsIDOMCSSValue::CSS_PRIMITIVE_VALUE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// nsIDOMCSSPrimitiveValue
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsROCSSPrimitiveValue::GetPrimitiveType(PRUint16* aPrimitiveType)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aPrimitiveType);
|
|
|
|
*aPrimitiveType = mType;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsROCSSPrimitiveValue::SetFloatValue(PRUint16 aUnitType, float aFloatValue)
|
|
|
|
{
|
|
|
|
return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsROCSSPrimitiveValue::GetFloatValue(PRUint16 aUnitType, float* aReturn)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aReturn);
|
|
|
|
*aReturn = 0;
|
|
|
|
|
|
|
|
switch(aUnitType) {
|
|
|
|
case CSS_PX :
|
2002-03-08 22:04:15 +03:00
|
|
|
if (mType != CSS_PX)
|
|
|
|
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
2007-02-07 10:46:44 +03:00
|
|
|
*aReturn = nsPresContext::AppUnitsToFloatCSSPixels(mValue.mAppUnits);
|
2000-05-15 05:58:26 +04:00
|
|
|
break;
|
|
|
|
case CSS_CM :
|
2002-03-08 22:04:15 +03:00
|
|
|
if (mType != CSS_PX)
|
|
|
|
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
2007-02-07 10:46:44 +03:00
|
|
|
*aReturn = mValue.mAppUnits * 2.54f / float(mAppUnitsPerInch);
|
2000-05-15 05:58:26 +04:00
|
|
|
break;
|
|
|
|
case CSS_MM :
|
2002-03-08 22:04:15 +03:00
|
|
|
if (mType != CSS_PX)
|
|
|
|
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
2007-02-07 10:46:44 +03:00
|
|
|
*aReturn = mValue.mAppUnits * 25.4f / float(mAppUnitsPerInch);
|
2000-05-15 05:58:26 +04:00
|
|
|
break;
|
|
|
|
case CSS_IN :
|
2002-03-08 22:04:15 +03:00
|
|
|
if (mType != CSS_PX)
|
|
|
|
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
2007-02-07 10:46:44 +03:00
|
|
|
*aReturn = mValue.mAppUnits / float(mAppUnitsPerInch);
|
2000-05-15 05:58:26 +04:00
|
|
|
break;
|
|
|
|
case CSS_PT :
|
2002-03-08 22:04:15 +03:00
|
|
|
if (mType != CSS_PX)
|
|
|
|
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
2008-04-08 04:27:10 +04:00
|
|
|
*aReturn = mValue.mAppUnits * POINTS_PER_INCH_FLOAT /
|
|
|
|
float(mAppUnitsPerInch);
|
2000-05-15 05:58:26 +04:00
|
|
|
break;
|
2002-03-22 23:18:42 +03:00
|
|
|
case CSS_PC :
|
|
|
|
if (mType != CSS_PX)
|
|
|
|
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
2007-02-07 10:46:44 +03:00
|
|
|
*aReturn = mValue.mAppUnits * 6.0f / float(mAppUnitsPerInch);
|
2002-03-22 23:18:42 +03:00
|
|
|
break;
|
2002-01-11 03:15:55 +03:00
|
|
|
case CSS_PERCENTAGE :
|
2002-03-08 22:04:15 +03:00
|
|
|
if (mType != CSS_PERCENTAGE)
|
|
|
|
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
|
|
|
*aReturn = mValue.mFloat * 100;
|
|
|
|
break;
|
|
|
|
case CSS_NUMBER :
|
|
|
|
if (mType != CSS_NUMBER)
|
|
|
|
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
|
|
|
*aReturn = mValue.mFloat;
|
2002-01-11 03:15:55 +03:00
|
|
|
break;
|
2000-05-15 05:58:26 +04:00
|
|
|
case CSS_UNKNOWN :
|
|
|
|
case CSS_EMS :
|
|
|
|
case CSS_EXS :
|
|
|
|
case CSS_DEG :
|
|
|
|
case CSS_RAD :
|
|
|
|
case CSS_GRAD :
|
|
|
|
case CSS_MS :
|
|
|
|
case CSS_S :
|
|
|
|
case CSS_HZ :
|
|
|
|
case CSS_KHZ :
|
|
|
|
case CSS_DIMENSION :
|
|
|
|
case CSS_STRING :
|
|
|
|
case CSS_URI :
|
|
|
|
case CSS_IDENT :
|
|
|
|
case CSS_ATTR :
|
|
|
|
case CSS_COUNTER :
|
|
|
|
case CSS_RECT :
|
|
|
|
case CSS_RGBCOLOR :
|
|
|
|
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsROCSSPrimitiveValue::SetStringValue(PRUint16 aStringType,
|
2002-03-24 01:56:05 +03:00
|
|
|
const nsAString& aStringValue)
|
2000-05-15 05:58:26 +04:00
|
|
|
{
|
|
|
|
return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2002-03-24 01:56:05 +03:00
|
|
|
nsROCSSPrimitiveValue::GetStringValue(nsAString& aReturn)
|
2000-05-15 05:58:26 +04:00
|
|
|
{
|
2002-03-13 00:16:22 +03:00
|
|
|
switch (mType) {
|
2002-03-22 23:18:42 +03:00
|
|
|
case CSS_IDENT:
|
2004-01-18 05:42:27 +03:00
|
|
|
mValue.mAtom->ToString(aReturn);
|
|
|
|
break;
|
2002-03-13 00:16:22 +03:00
|
|
|
case CSS_STRING:
|
2007-07-22 21:58:37 +04:00
|
|
|
case CSS_ATTR:
|
2002-03-27 10:39:54 +03:00
|
|
|
aReturn.Assign(mValue.mString);
|
2002-03-13 00:16:22 +03:00
|
|
|
break;
|
2003-10-02 02:53:56 +04:00
|
|
|
case CSS_URI: {
|
|
|
|
nsCAutoString spec;
|
|
|
|
if (mValue.mURI)
|
|
|
|
mValue.mURI->GetSpec(spec);
|
|
|
|
CopyUTF8toUTF16(spec, aReturn);
|
|
|
|
} break;
|
2002-03-13 00:16:22 +03:00
|
|
|
default:
|
|
|
|
aReturn.Truncate();
|
|
|
|
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
2002-01-11 03:15:55 +03:00
|
|
|
}
|
2000-05-15 05:58:26 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsROCSSPrimitiveValue::GetCounterValue(nsIDOMCounter** aReturn)
|
|
|
|
{
|
|
|
|
return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsROCSSPrimitiveValue::GetRectValue(nsIDOMRect** aReturn)
|
|
|
|
{
|
2002-03-08 22:04:15 +03:00
|
|
|
if (mType != CSS_RECT) {
|
2002-01-11 03:15:55 +03:00
|
|
|
*aReturn = nsnull;
|
|
|
|
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
|
|
|
}
|
2002-03-08 22:04:15 +03:00
|
|
|
NS_ASSERTION(mValue.mRect, "mValue.mRect should never be null");
|
|
|
|
return CallQueryInterface(mValue.mRect, aReturn);
|
2000-05-15 05:58:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsROCSSPrimitiveValue::GetRGBColorValue(nsIDOMRGBColor** aReturn)
|
|
|
|
{
|
2002-03-22 23:18:42 +03:00
|
|
|
if (mType != CSS_RGBCOLOR) {
|
|
|
|
*aReturn = nsnull;
|
|
|
|
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
|
|
|
}
|
|
|
|
NS_ASSERTION(mValue.mColor, "mValue.mColor should never be null");
|
|
|
|
return CallQueryInterface(mValue.mColor, aReturn);
|
2000-05-15 05:58:26 +04:00
|
|
|
}
|
|
|
|
|