2015-05-03 19:32:37 +00: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 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/. */
|
2011-10-11 05:50:08 +00:00
|
|
|
|
2013-01-04 17:02:14 +00:00
|
|
|
#include "mozilla/dom/HTMLLIElement.h"
|
2013-01-04 17:02:14 +00:00
|
|
|
#include "mozilla/dom/HTMLLIElementBinding.h"
|
2011-10-11 05:50:08 +00:00
|
|
|
|
2018-06-22 16:48:42 +00:00
|
|
|
#include "mozilla/MappedDeclarations.h"
|
2012-09-30 16:40:24 +00:00
|
|
|
#include "nsAttrValueInlines.h"
|
2006-12-26 17:47:52 +00:00
|
|
|
#include "nsGkAtoms.h"
|
1998-09-02 00:56:01 +00:00
|
|
|
#include "nsStyleConsts.h"
|
2004-01-26 19:22:05 +00:00
|
|
|
#include "nsMappedAttributes.h"
|
1998-09-02 00:56:01 +00:00
|
|
|
|
2004-05-18 20:58:12 +00:00
|
|
|
NS_IMPL_NS_NEW_HTML_ELEMENT(LI)
|
2000-12-23 10:56:31 +00:00
|
|
|
|
2013-01-04 17:02:14 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2000-12-23 10:56:31 +00:00
|
|
|
|
2013-01-04 17:02:14 +00:00
|
|
|
HTMLLIElement::~HTMLLIElement()
|
1998-09-02 00:56:01 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-01-04 17:02:14 +00:00
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLLIElement)
|
1998-09-02 00:56:01 +00:00
|
|
|
|
2011-06-29 21:39:21 +00:00
|
|
|
// values that are handled case-insensitively
|
2005-01-25 00:02:58 +00:00
|
|
|
static const nsAttrValue::EnumTable kUnorderedListItemTypeTable[] = {
|
1999-03-31 20:49:25 +00:00
|
|
|
{ "disc", NS_STYLE_LIST_STYLE_DISC },
|
1998-09-03 22:21:32 +00:00
|
|
|
{ "circle", NS_STYLE_LIST_STYLE_CIRCLE },
|
|
|
|
{ "round", NS_STYLE_LIST_STYLE_CIRCLE },
|
|
|
|
{ "square", NS_STYLE_LIST_STYLE_SQUARE },
|
2016-09-07 02:20:17 +00:00
|
|
|
{ nullptr, 0 }
|
2002-02-08 00:05:17 +00:00
|
|
|
};
|
|
|
|
|
2011-06-29 21:39:21 +00:00
|
|
|
// values that are handled case-sensitively
|
2005-01-25 00:02:58 +00:00
|
|
|
static const nsAttrValue::EnumTable kOrderedListItemTypeTable[] = {
|
2011-06-29 21:39:21 +00:00
|
|
|
{ "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 },
|
1999-03-20 01:32:48 +00:00
|
|
|
{ "1", NS_STYLE_LIST_STYLE_DECIMAL },
|
2016-09-07 02:20:17 +00:00
|
|
|
{ nullptr, 0 }
|
1998-09-03 22:21:32 +00:00
|
|
|
};
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2013-01-04 17:02:14 +00:00
|
|
|
HTMLLIElement::ParseAttribute(int32_t aNamespaceID,
|
2017-10-02 22:05:19 +00:00
|
|
|
nsAtom* aAttribute,
|
2013-01-04 17:02:14 +00:00
|
|
|
const nsAString& aValue,
|
2017-11-02 03:35:52 +00:00
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
2013-01-04 17:02:14 +00:00
|
|
|
nsAttrValue& aResult)
|
1998-09-02 00:56:01 +00:00
|
|
|
{
|
2005-11-29 16:37:15 +00:00
|
|
|
if (aNamespaceID == kNameSpaceID_None) {
|
2006-12-26 17:47:52 +00:00
|
|
|
if (aAttribute == nsGkAtoms::type) {
|
2005-11-29 16:37:15 +00:00
|
|
|
return aResult.ParseEnumValue(aValue, kOrderedListItemTypeTable,
|
2011-10-17 14:59:28 +00:00
|
|
|
true) ||
|
|
|
|
aResult.ParseEnumValue(aValue, kUnorderedListItemTypeTable, false);
|
2005-11-29 16:37:15 +00:00
|
|
|
}
|
2006-12-26 17:47:52 +00:00
|
|
|
if (aAttribute == nsGkAtoms::value) {
|
2011-08-31 10:34:07 +00:00
|
|
|
return aResult.ParseIntValue(aValue);
|
2005-11-29 16:37:15 +00:00
|
|
|
}
|
1998-09-03 22:21:32 +00:00
|
|
|
}
|
2000-12-23 10:56:31 +00:00
|
|
|
|
2005-11-29 16:37:15 +00:00
|
|
|
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
2017-11-02 03:35:52 +00:00
|
|
|
aMaybeScriptedPrincipal, aResult);
|
1998-09-02 00:56:01 +00:00
|
|
|
}
|
|
|
|
|
2013-11-19 19:21:29 +00:00
|
|
|
void
|
|
|
|
HTMLLIElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
2018-06-22 16:48:42 +00:00
|
|
|
MappedDeclarations& aDecls)
|
1998-09-02 00:56:01 +00:00
|
|
|
{
|
2018-06-22 16:48:42 +00:00
|
|
|
if (!aDecls.PropertyIsSet(eCSSProperty_list_style_type)) {
|
2018-03-29 01:39:07 +00:00
|
|
|
// type: enum
|
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::type);
|
|
|
|
if (value && value->Type() == nsAttrValue::eEnum)
|
2018-06-22 16:48:42 +00:00
|
|
|
aDecls.SetKeywordValue(eCSSProperty_list_style_type, value->GetEnumValue());
|
1998-09-03 22:21:32 +00:00
|
|
|
}
|
2001-05-31 22:19:43 +00:00
|
|
|
|
2018-06-22 16:48:42 +00:00
|
|
|
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aDecls);
|
1998-09-05 04:00:06 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHODIMP_(bool)
|
2017-10-02 22:05:19 +00:00
|
|
|
HTMLLIElement::IsAttributeMapped(const nsAtom* aAttribute) const
|
1999-07-07 01:24:40 +00:00
|
|
|
{
|
2004-02-25 21:04:50 +00:00
|
|
|
static const MappedAttributeEntry attributes[] = {
|
2018-04-11 08:22:05 +00:00
|
|
|
{ &nsGkAtoms::type },
|
2012-07-30 14:20:58 +00:00
|
|
|
{ nullptr },
|
2003-04-16 20:54:20 +00:00
|
|
|
};
|
|
|
|
|
2004-02-25 21:04:50 +00:00
|
|
|
static const MappedAttributeEntry* const map[] = {
|
2003-04-16 20:54:20 +00:00
|
|
|
attributes,
|
|
|
|
sCommonAttributeMap,
|
|
|
|
};
|
|
|
|
|
2011-12-18 10:09:27 +00:00
|
|
|
return FindAttributeDependence(aAttribute, map);
|
1999-07-07 01:24:40 +00:00
|
|
|
}
|
|
|
|
|
2005-01-12 19:45:38 +00:00
|
|
|
nsMapRuleToAttributesFunc
|
2013-01-04 17:02:14 +00:00
|
|
|
HTMLLIElement::GetAttributeMappingFunction() const
|
1998-09-05 04:00:06 +00:00
|
|
|
{
|
2005-01-12 19:45:38 +00:00
|
|
|
return &MapAttributesIntoRule;
|
1998-09-02 00:56:01 +00:00
|
|
|
}
|
2013-01-04 17:02:14 +00:00
|
|
|
|
2013-01-04 17:02:14 +00: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 14:13:33 +00:00
|
|
|
HTMLLIElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-01-04 17:02:14 +00:00
|
|
|
{
|
2018-06-25 21:20:54 +00:00
|
|
|
return HTMLLIElement_Binding::Wrap(aCx, this, aGivenProto);
|
2013-01-04 17:02:14 +00:00
|
|
|
}
|
|
|
|
|
2013-01-04 17:02:14 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|