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
|
|
|
|
2012-12-21 14:06:50 +00:00
|
|
|
#include "HTMLDivElement.h"
|
2008-02-21 20:39:20 +00:00
|
|
|
#include "nsGenericHTMLElement.h"
|
1998-09-01 19:07:50 +00:00
|
|
|
#include "nsStyleConsts.h"
|
2004-01-26 19:22:05 +00:00
|
|
|
#include "nsMappedAttributes.h"
|
2012-11-22 11:09:57 +00:00
|
|
|
#include "mozilla/dom/HTMLDivElementBinding.h"
|
1998-09-01 19:07:50 +00:00
|
|
|
|
2004-05-18 20:58:12 +00:00
|
|
|
NS_IMPL_NS_NEW_HTML_ELEMENT(Div)
|
2000-12-23 10:56:31 +00:00
|
|
|
|
2012-12-21 14:06:50 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2000-12-23 10:56:31 +00:00
|
|
|
|
2012-12-21 14:06:50 +00:00
|
|
|
HTMLDivElement::~HTMLDivElement()
|
1998-09-01 19:07:50 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-12-21 14:06:50 +00:00
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLDivElement)
|
1998-09-01 19:07:50 +00:00
|
|
|
|
2012-11-22 11:09:57 +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
|
|
|
HTMLDivElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
2012-11-22 11:09:57 +00: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 14:13:33 +00:00
|
|
|
return dom::HTMLDivElementBinding::Wrap(aCx, this, aGivenProto);
|
2012-11-22 11:09:57 +00:00
|
|
|
}
|
2000-12-23 10:56:31 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2012-12-21 14:06:50 +00:00
|
|
|
HTMLDivElement::ParseAttribute(int32_t aNamespaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
|
|
|
nsAttrValue& aResult)
|
1998-09-01 19:07:50 +00:00
|
|
|
{
|
2005-11-29 16:37:15 +00:00
|
|
|
if (aNamespaceID == kNameSpaceID_None) {
|
2006-12-26 17:47:52 +00:00
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::marquee)) {
|
|
|
|
if ((aAttribute == nsGkAtoms::width) ||
|
|
|
|
(aAttribute == nsGkAtoms::height)) {
|
2011-02-04 19:46:16 +00:00
|
|
|
return aResult.ParseSpecialIntValue(aValue);
|
2005-11-29 16:37:15 +00:00
|
|
|
}
|
2006-12-26 17:47:52 +00:00
|
|
|
if (aAttribute == nsGkAtoms::bgcolor) {
|
2010-07-17 08:09:14 +00:00
|
|
|
return aResult.ParseColor(aValue);
|
2005-11-29 16:37:15 +00:00
|
|
|
}
|
2006-12-26 17:47:52 +00:00
|
|
|
if ((aAttribute == nsGkAtoms::hspace) ||
|
|
|
|
(aAttribute == nsGkAtoms::vspace)) {
|
2005-11-29 16:37:15 +00:00
|
|
|
return aResult.ParseIntWithBounds(aValue, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-26 17:47:52 +00:00
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::div) &&
|
|
|
|
aAttribute == nsGkAtoms::align) {
|
2005-11-29 16:37:15 +00:00
|
|
|
return ParseDivAlignValue(aValue, aResult);
|
|
|
|
}
|
1998-09-03 22:21:32 +00:00
|
|
|
}
|
2005-10-23 22:47:58 +00:00
|
|
|
|
2005-11-29 16:37:15 +00:00
|
|
|
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
|
|
|
aResult);
|
1998-09-01 19:07:50 +00:00
|
|
|
}
|
|
|
|
|
2013-11-19 19:21:29 +00:00
|
|
|
void
|
|
|
|
HTMLDivElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|
|
|
nsRuleData* aData)
|
1998-09-01 19:07:50 +00:00
|
|
|
{
|
2002-09-26 08:18:42 +00:00
|
|
|
nsGenericHTMLElement::MapDivAlignAttributeInto(aAttributes, aData);
|
2001-05-31 22:19:43 +00:00
|
|
|
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
|
1998-09-05 04:00:06 +00:00
|
|
|
}
|
|
|
|
|
2005-10-23 22:47:58 +00:00
|
|
|
static void
|
|
|
|
MapMarqueeAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData)
|
|
|
|
{
|
|
|
|
nsGenericHTMLElement::MapImageMarginAttributeInto(aAttributes, aData);
|
|
|
|
nsGenericHTMLElement::MapImageSizeAttributesInto(aAttributes, aData);
|
|
|
|
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
|
2005-10-26 20:23:56 +00:00
|
|
|
nsGenericHTMLElement::MapBGColorInto(aAttributes, aData);
|
2005-10-23 22:47:58 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHODIMP_(bool)
|
2012-12-21 14:06:50 +00:00
|
|
|
HTMLDivElement::IsAttributeMapped(const nsIAtom* aAttribute) const
|
1999-07-07 01:24:40 +00:00
|
|
|
{
|
2006-12-26 17:47:52 +00:00
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::div)) {
|
2005-10-23 22:47:58 +00:00
|
|
|
static const MappedAttributeEntry* const map[] = {
|
|
|
|
sDivAlignAttributeMap,
|
|
|
|
sCommonAttributeMap
|
|
|
|
};
|
2011-12-18 10:09:27 +00:00
|
|
|
return FindAttributeDependence(aAttribute, map);
|
2005-10-23 22:47:58 +00:00
|
|
|
}
|
2006-12-26 17:47:52 +00:00
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::marquee)) {
|
2005-10-23 22:47:58 +00:00
|
|
|
static const MappedAttributeEntry* const map[] = {
|
|
|
|
sImageMarginSizeAttributeMap,
|
2005-10-26 20:23:56 +00:00
|
|
|
sBackgroundColorAttributeMap,
|
2005-10-23 22:47:58 +00:00
|
|
|
sCommonAttributeMap
|
|
|
|
};
|
2011-12-18 10:09:27 +00:00
|
|
|
return FindAttributeDependence(aAttribute, map);
|
2005-10-23 22:47:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nsGenericHTMLElement::IsAttributeMapped(aAttribute);
|
1999-07-07 01:24:40 +00:00
|
|
|
}
|
|
|
|
|
2005-01-12 19:45:38 +00:00
|
|
|
nsMapRuleToAttributesFunc
|
2012-12-21 14:06:50 +00:00
|
|
|
HTMLDivElement::GetAttributeMappingFunction() const
|
1998-09-05 04:00:06 +00:00
|
|
|
{
|
2006-12-26 17:47:52 +00:00
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::div)) {
|
2005-10-23 22:47:58 +00:00
|
|
|
return &MapAttributesIntoRule;
|
|
|
|
}
|
2006-12-26 17:47:52 +00:00
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::marquee)) {
|
2005-10-23 22:47:58 +00:00
|
|
|
return &MapMarqueeAttributesIntoRule;
|
|
|
|
}
|
|
|
|
return nsGenericHTMLElement::GetAttributeMappingFunction();
|
1998-09-01 19:07:50 +00:00
|
|
|
}
|
2010-07-23 09:49:57 +00:00
|
|
|
|
2012-12-21 14:06:50 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|