2015-05-03 22:32:37 +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/. */
|
2011-10-11 09:50:08 +04:00
|
|
|
|
2013-01-04 21:02:14 +04:00
|
|
|
#include "mozilla/dom/HTMLSharedListElement.h"
|
2013-01-04 21:02:14 +04:00
|
|
|
#include "mozilla/dom/HTMLDListElementBinding.h"
|
|
|
|
#include "mozilla/dom/HTMLOListElementBinding.h"
|
|
|
|
#include "mozilla/dom/HTMLUListElementBinding.h"
|
2011-10-11 09:50:08 +04:00
|
|
|
|
2018-06-22 19:48:42 +03:00
|
|
|
#include "mozilla/MappedDeclarations.h"
|
1998-09-03 03:53:16 +04:00
|
|
|
#include "nsGenericHTMLElement.h"
|
2012-09-30 20:40:24 +04:00
|
|
|
#include "nsAttrValueInlines.h"
|
2006-12-26 20:47:52 +03:00
|
|
|
#include "nsGkAtoms.h"
|
1998-09-02 04:56:01 +04:00
|
|
|
#include "nsStyleConsts.h"
|
2004-01-26 22:22:05 +03:00
|
|
|
#include "nsMappedAttributes.h"
|
1998-09-02 04:56:01 +04:00
|
|
|
|
2013-02-08 16:20:11 +04:00
|
|
|
NS_IMPL_NS_NEW_HTML_ELEMENT(SharedList)
|
1998-09-02 04:56:01 +04:00
|
|
|
|
2013-01-04 21:02:14 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
1999-10-07 04:35:04 +04:00
|
|
|
|
2013-01-04 21:02:14 +04:00
|
|
|
HTMLSharedListElement::~HTMLSharedListElement() {}
|
1998-09-02 04:56:01 +04:00
|
|
|
|
2017-10-03 02:42:09 +03:00
|
|
|
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(HTMLSharedListElement,
|
|
|
|
nsGenericHTMLElement)
|
2004-05-19 00:58:12 +04:00
|
|
|
|
2013-02-08 16:20:11 +04:00
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLSharedListElement)
|
1998-09-02 04:56:01 +04:00
|
|
|
|
2011-06-30 01:39:21 +04:00
|
|
|
// Shared with nsHTMLSharedElement.cpp
|
2005-01-25 03:02:58 +03:00
|
|
|
nsAttrValue::EnumTable kListTypeTable[] = {
|
1998-09-04 02:21:32 +04:00
|
|
|
{"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},
|
2016-09-07 05:20:17 +03:00
|
|
|
{nullptr, 0}};
|
1998-09-30 02:34:30 +04:00
|
|
|
|
2011-06-30 01:39:21 +04: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},
|
2016-09-07 05:20:17 +03:00
|
|
|
{nullptr, 0}};
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2013-01-04 21:02:14 +04:00
|
|
|
bool HTMLSharedListElement::ParseAttribute(
|
|
|
|
int32_t aNamespaceID, nsAtom* aAttribute, const nsAString& aValue,
|
2017-11-02 06:35:52 +03:00
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal, nsAttrValue& aResult) {
|
2005-11-29 19:37:15 +03:00
|
|
|
if (aNamespaceID == kNameSpaceID_None) {
|
2006-12-26 20:47:52 +03:00
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::ol) || mNodeInfo->Equals(nsGkAtoms::ul)) {
|
|
|
|
if (aAttribute == nsGkAtoms::type) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return aResult.ParseEnumValue(aValue, kListTypeTable, false) ||
|
|
|
|
aResult.ParseEnumValue(aValue, kOldListTypeTable, true);
|
2005-11-29 19:37:15 +03:00
|
|
|
}
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::start) {
|
2005-11-29 19:37:15 +03:00
|
|
|
return aResult.ParseIntValue(aValue);
|
|
|
|
}
|
2004-04-13 02:25:17 +04:00
|
|
|
}
|
1998-09-04 02:21:32 +04:00
|
|
|
}
|
2000-12-23 13:56:31 +03:00
|
|
|
|
2005-11-29 19:37:15 +03:00
|
|
|
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
2017-11-02 06:35:52 +03:00
|
|
|
aMaybeScriptedPrincipal, aResult);
|
1998-09-02 04:56:01 +04:00
|
|
|
}
|
|
|
|
|
2013-11-19 23:21:29 +04:00
|
|
|
void HTMLSharedListElement::MapAttributesIntoRule(
|
|
|
|
const nsMappedAttributes* aAttributes, MappedDeclarations& aDecls) {
|
2018-06-22 19:48:42 +03:00
|
|
|
if (!aDecls.PropertyIsSet(eCSSProperty_list_style_type)) {
|
2018-03-29 04:39:07 +03:00
|
|
|
// type: enum
|
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::type);
|
|
|
|
if (value && value->Type() == nsAttrValue::eEnum) {
|
2018-06-22 19:48:42 +03:00
|
|
|
aDecls.SetKeywordValue(eCSSProperty_list_style_type,
|
|
|
|
value->GetEnumValue());
|
1998-09-04 02:21:32 +04:00
|
|
|
}
|
|
|
|
}
|
2000-12-23 13:56:31 +03:00
|
|
|
|
2018-06-22 19:48:42 +03:00
|
|
|
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aDecls);
|
1998-09-05 08:00:06 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP_(bool)
|
2017-10-03 01:05:19 +03:00
|
|
|
HTMLSharedListElement::IsAttributeMapped(const nsAtom* aAttribute) const {
|
2006-12-26 20:47:52 +03:00
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::ol) || mNodeInfo->Equals(nsGkAtoms::ul)) {
|
2004-04-13 02:25:17 +04:00
|
|
|
static const MappedAttributeEntry attributes[] = {{nsGkAtoms::type},
|
2012-07-30 18:20:58 +04:00
|
|
|
{nullptr}};
|
2004-04-13 02:25:17 +04:00
|
|
|
|
|
|
|
static const MappedAttributeEntry* const map[] = {
|
|
|
|
attributes,
|
|
|
|
sCommonAttributeMap,
|
|
|
|
};
|
|
|
|
|
2011-12-18 14:09:27 +04:00
|
|
|
return FindAttributeDependence(aAttribute, map);
|
2004-04-13 02:25:17 +04:00
|
|
|
}
|
2003-04-17 00:54:20 +04:00
|
|
|
|
2004-04-13 02:25:17 +04:00
|
|
|
return nsGenericHTMLElement::IsAttributeMapped(aAttribute);
|
1999-07-07 05:24:40 +04:00
|
|
|
}
|
|
|
|
|
2013-01-04 21:02:14 +04:00
|
|
|
nsMapRuleToAttributesFunc HTMLSharedListElement::GetAttributeMappingFunction()
|
|
|
|
const {
|
2006-12-26 20:47:52 +03:00
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::ol) || mNodeInfo->Equals(nsGkAtoms::ul)) {
|
2005-01-12 22:45:38 +03:00
|
|
|
return &MapAttributesIntoRule;
|
2004-04-13 02:25:17 +04:00
|
|
|
}
|
2005-01-12 22:45:38 +03:00
|
|
|
|
|
|
|
return nsGenericHTMLElement::GetAttributeMappingFunction();
|
1998-09-02 04:56:01 +04:00
|
|
|
}
|
2013-01-04 21:02:14 +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
|
|
|
JSObject* HTMLSharedListElement::WrapNode(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) {
|
2013-02-08 16:20:11 +04:00
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::ol)) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return HTMLOListElement_Binding::Wrap(aCx, this, aGivenProto);
|
2013-02-08 16:20:11 +04:00
|
|
|
}
|
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::dl)) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return HTMLDListElement_Binding::Wrap(aCx, this, aGivenProto);
|
2013-02-08 16:20:11 +04:00
|
|
|
}
|
|
|
|
MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::ul));
|
2018-06-26 00:20:54 +03:00
|
|
|
return HTMLUListElement_Binding::Wrap(aCx, this, aGivenProto);
|
2013-01-04 21:02:14 +04:00
|
|
|
}
|
|
|
|
|
2013-01-04 21:02:14 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|