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"
|
2012-10-01 16:49:41 +00:00
|
|
|
#include "mozilla/dom/CSSValueListBinding.h"
|
2013-03-17 07:55:08 +00:00
|
|
|
#include "nsAutoPtr.h"
|
2012-10-01 16:49:41 +00:00
|
|
|
|
|
|
|
using namespace mozilla;
|
2002-07-08 07:11:59 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
nsDOMCSSValueList::nsDOMCSSValueList(bool aCommaDelimited, bool aReadonly)
|
2012-10-01 16:49:41 +00:00
|
|
|
: CSSValue(), mCommaDelimited(aCommaDelimited), mReadonly(aReadonly)
|
2002-07-08 07:11:59 +00:00
|
|
|
{
|
2012-10-01 16:49:41 +00:00
|
|
|
SetIsDOMBinding();
|
2002-07-08 07:11:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsDOMCSSValueList::~nsDOMCSSValueList()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-10-01 16:49:41 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMCSSValueList)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMCSSValueList)
|
2010-01-12 13:08:43 +00:00
|
|
|
|
2002-07-08 07:11:59 +00:00
|
|
|
// QueryInterface implementation for nsDOMCSSValueList
|
2012-10-01 16:49:41 +00:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMCSSValueList)
|
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
2002-07-08 07:11:59 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSValue)
|
2013-01-14 17:29:27 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSValueList)
|
2012-10-01 16:49:41 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, CSSValue)
|
2002-07-08 07:11:59 +00:00
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2014-04-29 08:57:00 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsDOMCSSValueList, mCSSValues)
|
2002-07-08 07:11:59 +00:00
|
|
|
|
2012-10-01 16:49:41 +00:00
|
|
|
JSObject*
|
2014-04-08 22:27:18 +00:00
|
|
|
nsDOMCSSValueList::WrapObject(JSContext *cx)
|
2002-07-08 07:11:59 +00:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-08 22:27:17 +00:00
|
|
|
return dom::CSSValueListBinding::Wrap(cx, this);
|
2002-07-08 07:11:59 +00:00
|
|
|
}
|
|
|
|
|
2012-10-01 16:49:41 +00:00
|
|
|
void
|
|
|
|
nsDOMCSSValueList::AppendCSSValue(CSSValue* aValue)
|
2002-07-08 07:11:59 +00:00
|
|
|
{
|
2012-10-01 16:49:41 +00:00
|
|
|
mCSSValues.AppendElement(aValue);
|
2002-07-08 07:11:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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 {
|
2014-01-04 15:02:17 +00:00
|
|
|
separator.Assign(char16_t(' '));
|
2002-07-08 07:11:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoString tmpStr;
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < count; ++i) {
|
2012-10-01 16:49:41 +00:00
|
|
|
CSSValue *cssValue = mCSSValues[i];
|
2002-07-08 07:11:59 +00:00
|
|
|
NS_ASSERTION(cssValue, "Eek! Someone filled the value list with null CSSValues!");
|
2012-10-01 16:49:41 +00:00
|
|
|
ErrorResult dummy;
|
2002-07-08 07:11:59 +00:00
|
|
|
if (cssValue) {
|
2012-10-01 16:49:41 +00:00
|
|
|
cssValue->GetCssText(tmpStr, dummy);
|
2002-07-08 07:11:59 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-10-01 16:49:41 +00:00
|
|
|
void
|
|
|
|
nsDOMCSSValueList::GetCssText(nsString& aText, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
aRv = GetCssText(aText);
|
|
|
|
}
|
|
|
|
|
2002-07-08 07:11:59 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-10-01 16:49:41 +00:00
|
|
|
void
|
|
|
|
nsDOMCSSValueList::SetCssText(const nsAString& aText, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
aRv = SetCssText(aText);
|
|
|
|
}
|
2002-07-08 07:11:59 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-10-01 16:49:41 +00:00
|
|
|
uint16_t
|
|
|
|
nsDOMCSSValueList::CssValueType() const
|
|
|
|
{
|
|
|
|
return nsIDOMCSSValue::CSS_VALUE_LIST;
|
|
|
|
}
|