2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04: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 11:11:59 +04:00
|
|
|
|
2006-03-25 08:47:31 +03:00
|
|
|
/* DOM object representing lists of values in DOM computed style */
|
|
|
|
|
2002-07-08 11:11:59 +04:00
|
|
|
#include "nsDOMCSSValueList.h"
|
2012-10-01 20:49:41 +04:00
|
|
|
#include "mozilla/dom/CSSValueListBinding.h"
|
2015-12-24 03:25:43 +03:00
|
|
|
#include "mozilla/Move.h"
|
2012-10-01 20:49:41 +04:00
|
|
|
|
|
|
|
using namespace mozilla;
|
2002-07-08 11:11:59 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
nsDOMCSSValueList::nsDOMCSSValueList(bool aCommaDelimited, bool aReadonly)
|
2012-10-01 20:49:41 +04:00
|
|
|
: CSSValue(), mCommaDelimited(aCommaDelimited), mReadonly(aReadonly)
|
2002-07-08 11:11:59 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsDOMCSSValueList::~nsDOMCSSValueList()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-10-01 20:49:41 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMCSSValueList)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMCSSValueList)
|
2010-01-12 16:08:43 +03:00
|
|
|
|
2002-07-08 11:11:59 +04:00
|
|
|
// QueryInterface implementation for nsDOMCSSValueList
|
2012-10-01 20:49:41 +04:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMCSSValueList)
|
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
2002-07-08 11:11:59 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSValue)
|
2013-01-14 21:29:27 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSValueList)
|
2012-10-01 20:49:41 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, CSSValue)
|
2002-07-08 11:11:59 +04:00
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2014-04-29 12:57:00 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsDOMCSSValueList, mCSSValues)
|
2002-07-08 11:11:59 +04:00
|
|
|
|
2012-10-01 20:49:41 +04:00
|
|
|
JSObject*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
nsDOMCSSValueList::WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto)
|
2002-07-08 11:11:59 +04:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
return dom::CSSValueListBinding::Wrap(cx, this, aGivenProto);
|
2002-07-08 11:11:59 +04:00
|
|
|
}
|
|
|
|
|
2012-10-01 20:49:41 +04:00
|
|
|
void
|
2015-12-24 03:25:43 +03:00
|
|
|
nsDOMCSSValueList::AppendCSSValue(already_AddRefed<CSSValue> aValue)
|
2002-07-08 11:11:59 +04:00
|
|
|
{
|
2015-12-24 03:25:43 +03:00
|
|
|
RefPtr<CSSValue> val = aValue;
|
|
|
|
mCSSValues.AppendElement(Move(val));
|
2002-07-08 11:11:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// nsIDOMCSSValue
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMCSSValueList::GetCssText(nsAString& aCssText)
|
|
|
|
{
|
|
|
|
aCssText.Truncate();
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t count = mCSSValues.Length();
|
2002-07-08 11:11:59 +04:00
|
|
|
|
|
|
|
nsAutoString separator;
|
|
|
|
if (mCommaDelimited) {
|
2004-06-17 04:13:25 +04:00
|
|
|
separator.AssignLiteral(", ");
|
2002-07-08 11:11:59 +04:00
|
|
|
}
|
|
|
|
else {
|
2014-01-04 19:02:17 +04:00
|
|
|
separator.Assign(char16_t(' '));
|
2002-07-08 11:11:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoString tmpStr;
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < count; ++i) {
|
2012-10-01 20:49:41 +04:00
|
|
|
CSSValue *cssValue = mCSSValues[i];
|
2002-07-08 11:11:59 +04:00
|
|
|
NS_ASSERTION(cssValue, "Eek! Someone filled the value list with null CSSValues!");
|
2012-10-01 20:49:41 +04:00
|
|
|
ErrorResult dummy;
|
2002-07-08 11:11:59 +04:00
|
|
|
if (cssValue) {
|
2012-10-01 20:49:41 +04:00
|
|
|
cssValue->GetCssText(tmpStr, dummy);
|
2002-07-08 11:11:59 +04: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-21 01:05:24 +03:00
|
|
|
// it's ok to append a separator.
|
2002-07-08 11:11:59 +04:00
|
|
|
if (!aCssText.IsEmpty()) {
|
|
|
|
aCssText.Append(separator);
|
|
|
|
}
|
|
|
|
aCssText.Append(tmpStr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-10-01 20:49:41 +04:00
|
|
|
void
|
|
|
|
nsDOMCSSValueList::GetCssText(nsString& aText, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
aRv = GetCssText(aText);
|
|
|
|
}
|
|
|
|
|
2002-07-08 11:11:59 +04: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 20:49:41 +04:00
|
|
|
void
|
|
|
|
nsDOMCSSValueList::SetCssText(const nsAString& aText, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
aRv = SetCssText(aText);
|
|
|
|
}
|
2002-07-08 11:11:59 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsDOMCSSValueList::GetCssValueType(uint16_t* aValueType)
|
2002-07-08 11:11:59 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aValueType);
|
|
|
|
*aValueType = nsIDOMCSSValue::CSS_VALUE_LIST;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-10-01 20:49:41 +04:00
|
|
|
uint16_t
|
|
|
|
nsDOMCSSValueList::CssValueType() const
|
|
|
|
{
|
|
|
|
return nsIDOMCSSValue::CSS_VALUE_LIST;
|
|
|
|
}
|