2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* DOM object representing lists of values in DOM computed style */
|
|
|
|
|
|
|
|
#include "nsDOMCSSValueList.h"
|
2012-10-01 09:49:41 -07:00
|
|
|
#include "mozilla/dom/CSSValueListBinding.h"
|
2013-03-17 00:55:08 -07:00
|
|
|
#include "nsAutoPtr.h"
|
2012-10-01 09:49:41 -07:00
|
|
|
|
|
|
|
using namespace mozilla;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
nsDOMCSSValueList::nsDOMCSSValueList(bool aCommaDelimited, bool aReadonly)
|
2012-10-01 09:49:41 -07:00
|
|
|
: CSSValue(), mCommaDelimited(aCommaDelimited), mReadonly(aReadonly)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsDOMCSSValueList::~nsDOMCSSValueList()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-10-01 09:49:41 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMCSSValueList)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMCSSValueList)
|
2010-01-12 05:08:43 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// QueryInterface implementation for nsDOMCSSValueList
|
2012-10-01 09:49:41 -07:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMCSSValueList)
|
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSValue)
|
2013-01-14 09:29:27 -08:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSValueList)
|
2012-10-01 09:49:41 -07:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, CSSValue)
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2014-04-29 01:57:00 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsDOMCSSValueList, mCSSValues)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-10-01 09:49:41 -07:00
|
|
|
JSObject*
|
2014-04-08 15:27:18 -07:00
|
|
|
nsDOMCSSValueList::WrapObject(JSContext *cx)
|
2007-03-22 10:30:00 -07: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 15:27:17 -07:00
|
|
|
return dom::CSSValueListBinding::Wrap(cx, this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-10-01 09:49:41 -07:00
|
|
|
void
|
|
|
|
nsDOMCSSValueList::AppendCSSValue(CSSValue* aValue)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-10-01 09:49:41 -07:00
|
|
|
mCSSValues.AppendElement(aValue);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// nsIDOMCSSValue
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMCSSValueList::GetCssText(nsAString& aCssText)
|
|
|
|
{
|
|
|
|
aCssText.Truncate();
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t count = mCSSValues.Length();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsAutoString separator;
|
|
|
|
if (mCommaDelimited) {
|
|
|
|
separator.AssignLiteral(", ");
|
|
|
|
}
|
|
|
|
else {
|
2014-01-04 07:02:17 -08:00
|
|
|
separator.Assign(char16_t(' '));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoString tmpStr;
|
2012-08-22 08:56:38 -07:00
|
|
|
for (uint32_t i = 0; i < count; ++i) {
|
2012-10-01 09:49:41 -07:00
|
|
|
CSSValue *cssValue = mCSSValues[i];
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ASSERTION(cssValue, "Eek! Someone filled the value list with null CSSValues!");
|
2012-10-01 09:49:41 -07:00
|
|
|
ErrorResult dummy;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (cssValue) {
|
2012-10-01 09:49:41 -07:00
|
|
|
cssValue->GetCssText(tmpStr, dummy);
|
2007-03-22 10:30:00 -07: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
|
|
|
|
// it's ok to append a separator.
|
|
|
|
if (!aCssText.IsEmpty()) {
|
|
|
|
aCssText.Append(separator);
|
|
|
|
}
|
|
|
|
aCssText.Append(tmpStr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-10-01 09:49:41 -07:00
|
|
|
void
|
|
|
|
nsDOMCSSValueList::GetCssText(nsString& aText, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
aRv = GetCssText(aText);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07: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 09:49:41 -07:00
|
|
|
void
|
|
|
|
nsDOMCSSValueList::SetCssText(const nsAString& aText, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
aRv = SetCssText(aText);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsDOMCSSValueList::GetCssValueType(uint16_t* aValueType)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aValueType);
|
|
|
|
*aValueType = nsIDOMCSSValue::CSS_VALUE_LIST;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-10-01 09:49:41 -07:00
|
|
|
uint16_t
|
|
|
|
nsDOMCSSValueList::CssValueType() const
|
|
|
|
{
|
|
|
|
return nsIDOMCSSValue::CSS_VALUE_LIST;
|
|
|
|
}
|