2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
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/HTMLLIElement.h"
|
2013-01-04 09:02:14 -08:00
|
|
|
#include "mozilla/dom/HTMLLIElementBinding.h"
|
2011-10-10 22:50:08 -07:00
|
|
|
|
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"
|
|
|
|
|
|
|
|
NS_IMPL_NS_NEW_HTML_ELEMENT(LI)
|
|
|
|
|
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
|
|
|
HTMLLIElement::~HTMLLIElement()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-04-27 00:06:00 -07:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED(HTMLLIElement, nsGenericHTMLElement,
|
|
|
|
nsIDOMHTMLLIElement)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-01-04 09:02:14 -08:00
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLLIElement)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-01-04 09:02:14 -08:00
|
|
|
NS_IMPL_STRING_ATTR(HTMLLIElement, Type, type)
|
|
|
|
NS_IMPL_INT_ATTR(HTMLLIElement, Value, value)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-06-29 14:39:21 -07:00
|
|
|
// values that are handled case-insensitively
|
2007-03-22 10:30:00 -07:00
|
|
|
static const nsAttrValue::EnumTable kUnorderedListItemTypeTable[] = {
|
|
|
|
{ "disc", NS_STYLE_LIST_STYLE_DISC },
|
|
|
|
{ "circle", NS_STYLE_LIST_STYLE_CIRCLE },
|
|
|
|
{ "round", NS_STYLE_LIST_STYLE_CIRCLE },
|
|
|
|
{ "square", NS_STYLE_LIST_STYLE_SQUARE },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
2011-06-29 14:39:21 -07:00
|
|
|
// values that are handled case-sensitively
|
2007-03-22 10:30:00 -07:00
|
|
|
static const nsAttrValue::EnumTable kOrderedListItemTypeTable[] = {
|
2011-06-29 14:39:21 -07: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 },
|
2007-03-22 10:30:00 -07:00
|
|
|
{ "1", NS_STYLE_LIST_STYLE_DECIMAL },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2013-01-04 09:02:14 -08:00
|
|
|
HTMLLIElement::ParseAttribute(int32_t aNamespaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
|
|
|
nsAttrValue& aResult)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (aNamespaceID == kNameSpaceID_None) {
|
|
|
|
if (aAttribute == nsGkAtoms::type) {
|
|
|
|
return aResult.ParseEnumValue(aValue, kOrderedListItemTypeTable,
|
2011-10-17 07:59:28 -07:00
|
|
|
true) ||
|
|
|
|
aResult.ParseEnumValue(aValue, kUnorderedListItemTypeTable, false);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
if (aAttribute == nsGkAtoms::value) {
|
2011-08-31 03:34:07 -07:00
|
|
|
return aResult.ParseIntValue(aValue);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
|
|
|
aResult);
|
|
|
|
}
|
|
|
|
|
2013-11-19 11:21:29 -08:00
|
|
|
void
|
|
|
|
HTMLLIElement::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 && 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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHODIMP_(bool)
|
2013-01-04 09:02:14 -08:00
|
|
|
HTMLLIElement::IsAttributeMapped(const nsIAtom* aAttribute) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
nsMapRuleToAttributesFunc
|
2013-01-04 09:02:14 -08:00
|
|
|
HTMLLIElement::GetAttributeMappingFunction() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return &MapAttributesIntoRule;
|
|
|
|
}
|
2013-01-04 09:02:14 -08:00
|
|
|
|
2013-01-04 09:02:14 -08:00
|
|
|
JSObject*
|
2014-04-08 15:27:17 -07:00
|
|
|
HTMLLIElement::WrapNode(JSContext *aCx)
|
2013-01-04 09:02:14 -08: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 HTMLLIElementBinding::Wrap(aCx, this);
|
2013-01-04 09:02:14 -08:00
|
|
|
}
|
|
|
|
|
2013-01-04 09:02:14 -08:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|