2015-05-03 12:32:37 -07: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 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/. */
|
2011-10-10 22:50:08 -07:00
|
|
|
|
2013-01-04 09:02:14 -08:00
|
|
|
#include "mozilla/dom/HTMLSharedListElement.h"
|
2013-01-04 09:02:14 -08:00
|
|
|
#include "mozilla/dom/HTMLDListElementBinding.h"
|
|
|
|
#include "mozilla/dom/HTMLOListElementBinding.h"
|
|
|
|
#include "mozilla/dom/HTMLUListElementBinding.h"
|
2011-10-10 22:50:08 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsGenericHTMLElement.h"
|
2012-09-30 09:40:24 -07:00
|
|
|
#include "nsAttrValueInlines.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsGkAtoms.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsMappedAttributes.h"
|
|
|
|
#include "nsRuleData.h"
|
|
|
|
|
2013-02-08 04:20:11 -08:00
|
|
|
NS_IMPL_NS_NEW_HTML_ELEMENT(SharedList)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-01-04 09:02:14 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-01-04 09:02:14 -08:00
|
|
|
HTMLSharedListElement::~HTMLSharedListElement()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-01-04 09:02:14 -08:00
|
|
|
NS_IMPL_ADDREF_INHERITED(HTMLSharedListElement, Element)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(HTMLSharedListElement, Element)
|
2010-01-12 05:08:43 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// QueryInterface implementation for nsHTMLSharedListElement
|
2013-05-21 06:38:15 -07:00
|
|
|
NS_INTERFACE_MAP_BEGIN(HTMLSharedListElement)
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMHTMLOListElement, ol)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMHTMLUListElement, ul)
|
2013-08-07 13:23:08 -07:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(nsGenericHTMLElement)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
|
2013-02-08 04:20:11 -08:00
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLSharedListElement)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
|
2013-01-04 09:02:14 -08:00
|
|
|
NS_IMPL_BOOL_ATTR(HTMLSharedListElement, Compact, compact)
|
|
|
|
NS_IMPL_INT_ATTR_DEFAULT_VALUE(HTMLSharedListElement, Start, start, 1)
|
|
|
|
NS_IMPL_STRING_ATTR(HTMLSharedListElement, Type, type)
|
|
|
|
NS_IMPL_BOOL_ATTR(HTMLSharedListElement, Reversed, reversed)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-06-29 14:39:21 -07:00
|
|
|
// Shared with nsHTMLSharedElement.cpp
|
2007-03-22 10:30:00 -07:00
|
|
|
nsAttrValue::EnumTable kListTypeTable[] = {
|
|
|
|
{ "none", NS_STYLE_LIST_STYLE_NONE },
|
|
|
|
{ "disc", NS_STYLE_LIST_STYLE_DISC },
|
|
|
|
{ "circle", NS_STYLE_LIST_STYLE_CIRCLE },
|
|
|
|
{ "round", NS_STYLE_LIST_STYLE_CIRCLE },
|
|
|
|
{ "square", NS_STYLE_LIST_STYLE_SQUARE },
|
|
|
|
{ "decimal", NS_STYLE_LIST_STYLE_DECIMAL },
|
|
|
|
{ "lower-roman", NS_STYLE_LIST_STYLE_LOWER_ROMAN },
|
|
|
|
{ "upper-roman", NS_STYLE_LIST_STYLE_UPPER_ROMAN },
|
|
|
|
{ "lower-alpha", NS_STYLE_LIST_STYLE_LOWER_ALPHA },
|
|
|
|
{ "upper-alpha", NS_STYLE_LIST_STYLE_UPPER_ALPHA },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
2011-06-29 14:39:21 -07:00
|
|
|
static const nsAttrValue::EnumTable kOldListTypeTable[] = {
|
|
|
|
{ "1", NS_STYLE_LIST_STYLE_DECIMAL },
|
|
|
|
{ "A", NS_STYLE_LIST_STYLE_UPPER_ALPHA },
|
|
|
|
{ "a", NS_STYLE_LIST_STYLE_LOWER_ALPHA },
|
|
|
|
{ "I", NS_STYLE_LIST_STYLE_UPPER_ROMAN },
|
|
|
|
{ "i", NS_STYLE_LIST_STYLE_LOWER_ROMAN },
|
2007-03-22 10:30:00 -07:00
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2013-01-04 09:02:14 -08:00
|
|
|
HTMLSharedListElement::ParseAttribute(int32_t aNamespaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
|
|
|
nsAttrValue& aResult)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (aNamespaceID == kNameSpaceID_None) {
|
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::ol) ||
|
|
|
|
mNodeInfo->Equals(nsGkAtoms::ul)) {
|
|
|
|
if (aAttribute == nsGkAtoms::type) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return aResult.ParseEnumValue(aValue, kListTypeTable, false) ||
|
|
|
|
aResult.ParseEnumValue(aValue, kOldListTypeTable, true);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
if (aAttribute == nsGkAtoms::start) {
|
|
|
|
return aResult.ParseIntValue(aValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
|
|
|
aResult);
|
|
|
|
}
|
|
|
|
|
2013-11-19 11:21:29 -08:00
|
|
|
void
|
|
|
|
HTMLSharedListElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|
|
|
nsRuleData* aData)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2007-10-08 14:58:22 -07:00
|
|
|
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(List)) {
|
2011-03-17 20:14:31 -07:00
|
|
|
nsCSSValue* listStyleType = aData->ValueForListStyleType();
|
|
|
|
if (listStyleType->GetUnit() == eCSSUnit_Null) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// type: enum
|
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::type);
|
|
|
|
if (value) {
|
|
|
|
if (value->Type() == nsAttrValue::eEnum)
|
2011-03-17 20:14:31 -07:00
|
|
|
listStyleType->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
2007-03-22 10:30:00 -07:00
|
|
|
else
|
2011-03-17 20:14:31 -07:00
|
|
|
listStyleType->SetIntValue(NS_STYLE_LIST_STYLE_DECIMAL, eCSSUnit_Enumerated);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHODIMP_(bool)
|
2013-01-04 09:02:14 -08:00
|
|
|
HTMLSharedListElement::IsAttributeMapped(const nsIAtom* aAttribute) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::ol) ||
|
|
|
|
mNodeInfo->Equals(nsGkAtoms::ul)) {
|
|
|
|
static const MappedAttributeEntry attributes[] = {
|
|
|
|
{ &nsGkAtoms::type },
|
2012-07-30 07:20:58 -07:00
|
|
|
{ nullptr }
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static const MappedAttributeEntry* const map[] = {
|
|
|
|
attributes,
|
|
|
|
sCommonAttributeMap,
|
|
|
|
};
|
|
|
|
|
2011-12-18 02:09:27 -08:00
|
|
|
return FindAttributeDependence(aAttribute, map);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return nsGenericHTMLElement::IsAttributeMapped(aAttribute);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsMapRuleToAttributesFunc
|
2013-01-04 09:02:14 -08:00
|
|
|
HTMLSharedListElement::GetAttributeMappingFunction() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::ol) ||
|
|
|
|
mNodeInfo->Equals(nsGkAtoms::ul)) {
|
|
|
|
return &MapAttributesIntoRule;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsGenericHTMLElement::GetAttributeMappingFunction();
|
|
|
|
}
|
2013-01-04 09:02:14 -08:00
|
|
|
|
2013-01-04 09:02:14 -08: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 07:13:33 -07:00
|
|
|
HTMLSharedListElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-01-04 09:02:14 -08:00
|
|
|
{
|
2013-02-08 04:20:11 -08:00
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::ol)) {
|
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 07:13:33 -07:00
|
|
|
return HTMLOListElementBinding::Wrap(aCx, this, aGivenProto);
|
2013-02-08 04:20:11 -08:00
|
|
|
}
|
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::dl)) {
|
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 07:13:33 -07:00
|
|
|
return HTMLDListElementBinding::Wrap(aCx, this, aGivenProto);
|
2013-02-08 04:20:11 -08:00
|
|
|
}
|
|
|
|
MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::ul));
|
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 07:13:33 -07:00
|
|
|
return HTMLUListElementBinding::Wrap(aCx, this, aGivenProto);
|
2013-01-04 09:02:14 -08:00
|
|
|
}
|
|
|
|
|
2013-01-04 09:02:14 -08:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|