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/. */
|
2002-07-08 07:11:59 +00:00
|
|
|
|
2006-03-25 05:47:31 +00:00
|
|
|
/* DOM object representing lists of values in DOM computed style */
|
|
|
|
|
2002-07-08 07:11:59 +00:00
|
|
|
#include "nsDOMCSSValueList.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2012-07-27 14:03:27 +00:00
|
|
|
#include "nsError.h"
|
2002-07-08 07:11:59 +00:00
|
|
|
#include "prtypes.h"
|
|
|
|
#include "nsContentUtils.h"
|
2012-07-20 16:42:08 +00:00
|
|
|
#include "nsDOMClassInfoID.h"
|
2002-07-08 07:11:59 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
nsDOMCSSValueList::nsDOMCSSValueList(bool aCommaDelimited, bool aReadonly)
|
2002-07-08 07:11:59 +00:00
|
|
|
: mCommaDelimited(aCommaDelimited), mReadonly(aReadonly)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsDOMCSSValueList::~nsDOMCSSValueList()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2003-09-07 21:50:21 +00:00
|
|
|
NS_IMPL_ADDREF(nsDOMCSSValueList)
|
|
|
|
NS_IMPL_RELEASE(nsDOMCSSValueList)
|
2002-07-08 07:11:59 +00:00
|
|
|
|
2010-01-12 13:08:43 +00:00
|
|
|
DOMCI_DATA(CSSValueList, nsDOMCSSValueList)
|
|
|
|
|
2002-07-08 07:11:59 +00:00
|
|
|
// QueryInterface implementation for nsDOMCSSValueList
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsDOMCSSValueList)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSValueList)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSValue)
|
2006-02-23 22:31:34 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
2010-03-17 15:09:05 +00:00
|
|
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSValueList)
|
2002-07-08 07:11:59 +00:00
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2011-03-04 17:28:57 +00:00
|
|
|
void
|
2002-07-08 07:11:59 +00:00
|
|
|
nsDOMCSSValueList::AppendCSSValue(nsIDOMCSSValue* aValue)
|
|
|
|
{
|
2011-03-04 17:28:57 +00:00
|
|
|
mCSSValues.AppendElement(aValue);
|
2002-07-08 07:11:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// nsIDOMCSSValueList
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsDOMCSSValueList::GetLength(uint32_t* aLength)
|
2002-07-08 07:11:59 +00:00
|
|
|
{
|
2011-03-04 17:28:57 +00:00
|
|
|
*aLength = mCSSValues.Length();
|
2002-07-08 07:11:59 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsDOMCSSValueList::Item(uint32_t aIndex, nsIDOMCSSValue **aReturn)
|
2002-07-08 07:11:59 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aReturn);
|
|
|
|
|
2008-10-22 14:31:14 +00:00
|
|
|
NS_IF_ADDREF(*aReturn = GetItemAt(aIndex));
|
2002-07-08 07:11:59 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// nsIDOMCSSValue
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMCSSValueList::GetCssText(nsAString& aCssText)
|
|
|
|
{
|
|
|
|
aCssText.Truncate();
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t count = mCSSValues.Length();
|
2002-07-08 07:11:59 +00:00
|
|
|
|
|
|
|
nsAutoString separator;
|
|
|
|
if (mCommaDelimited) {
|
2004-06-17 00:13:25 +00:00
|
|
|
separator.AssignLiteral(", ");
|
2002-07-08 07:11:59 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
separator.Assign(PRUnichar(' '));
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMCSSValue> cssValue;
|
|
|
|
nsAutoString tmpStr;
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < count; ++i) {
|
2003-01-11 10:28:37 +00:00
|
|
|
cssValue = mCSSValues[i];
|
2002-07-08 07:11:59 +00:00
|
|
|
NS_ASSERTION(cssValue, "Eek! Someone filled the value list with null CSSValues!");
|
|
|
|
if (cssValue) {
|
|
|
|
cssValue->GetCssText(tmpStr);
|
|
|
|
|
|
|
|
if (tmpStr.IsEmpty()) {
|
|
|
|
|
|
|
|
#ifdef DEBUG_caillon
|
|
|
|
NS_ERROR("Eek! An empty CSSValue! Bad!");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If this isn't the first item in the list, then
|
2005-11-20 22:05:24 +00:00
|
|
|
// it's ok to append a separator.
|
2002-07-08 07:11:59 +00:00
|
|
|
if (!aCssText.IsEmpty()) {
|
|
|
|
aCssText.Append(separator);
|
|
|
|
}
|
|
|
|
aCssText.Append(tmpStr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMCSSValueList::SetCssText(const nsAString& aCssText)
|
|
|
|
{
|
|
|
|
if (mReadonly) {
|
|
|
|
return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_NOTYETIMPLEMENTED("Can't SetCssText yet: please write me!");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsDOMCSSValueList::GetCssValueType(uint16_t* aValueType)
|
2002-07-08 07:11:59 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aValueType);
|
|
|
|
*aValueType = nsIDOMCSSValue::CSS_VALUE_LIST;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|