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
|
|
|
|
2012-12-27 18:45:57 -08:00
|
|
|
#include "mozilla/dom/HTMLTableSectionElement.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsMappedAttributes.h"
|
2012-09-30 09:40:24 -07:00
|
|
|
#include "nsAttrValueInlines.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsRuleData.h"
|
2012-12-29 06:07:48 -08:00
|
|
|
#include "mozilla/dom/BindingUtils.h"
|
|
|
|
#include "mozilla/dom/HTMLTableSectionElementBinding.h"
|
2013-01-31 15:11:49 -08:00
|
|
|
#include "nsContentUtils.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_IMPL_NS_NEW_HTML_ELEMENT(TableSection)
|
|
|
|
|
2012-12-27 18:45:57 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-12-27 18:45:57 -08:00
|
|
|
// you will see the phrases "rowgroup" and "section" used interchangably
|
|
|
|
|
2014-07-08 14:23:16 -07:00
|
|
|
HTMLTableSectionElement::~HTMLTableSectionElement()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-12-29 06:07:48 -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
|
|
|
HTMLTableSectionElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
2007-03-22 10:30:00 -07: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 07:13:33 -07:00
|
|
|
return HTMLTableSectionElementBinding::Wrap(aCx, this, aGivenProto);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-08-01 18:29:05 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLTableSectionElement)
|
|
|
|
|
2012-12-27 18:45:57 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLTableSectionElement,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsGenericHTMLElement)
|
2012-11-14 23:32:40 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRows)
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
2012-12-27 18:45:57 -08:00
|
|
|
NS_IMPL_ADDREF_INHERITED(HTMLTableSectionElement, Element)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(HTMLTableSectionElement, Element)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-12-27 18:45:57 -08:00
|
|
|
// QueryInterface implementation for HTMLTableSectionElement
|
2013-08-01 15:24:22 -07:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(HTMLTableSectionElement)
|
2013-08-07 13:23:08 -07:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(nsGenericHTMLElement)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
|
2012-12-27 18:45:57 -08:00
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLTableSectionElement)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-12-29 06:07:48 -08:00
|
|
|
nsIHTMLCollection*
|
|
|
|
HTMLTableSectionElement::Rows()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (!mRows) {
|
|
|
|
mRows = new nsContentList(this,
|
|
|
|
mNodeInfo->NamespaceID(),
|
2010-08-31 19:47:00 -07:00
|
|
|
nsGkAtoms::tr,
|
|
|
|
nsGkAtoms::tr,
|
2011-10-17 07:59:28 -07:00
|
|
|
false);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-12-29 06:07:48 -08:00
|
|
|
return mRows;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-12-29 06:07:48 -08:00
|
|
|
already_AddRefed<nsGenericHTMLElement>
|
|
|
|
HTMLTableSectionElement::InsertRow(int32_t aIndex, ErrorResult& aError)
|
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
if (aIndex < -1) {
|
2012-12-29 06:07:48 -08:00
|
|
|
aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-12-29 06:07:48 -08:00
|
|
|
nsIHTMLCollection* rows = Rows();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-12-29 06:07:48 -08:00
|
|
|
uint32_t rowCount = rows->Length();
|
2012-08-22 08:56:38 -07:00
|
|
|
if (aIndex > (int32_t)rowCount) {
|
2012-12-29 06:07:48 -08:00
|
|
|
aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
bool doInsert = (aIndex < int32_t(rowCount)) && (aIndex != -1);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// create the row
|
2014-06-19 19:01:40 -07:00
|
|
|
nsRefPtr<mozilla::dom::NodeInfo> nodeInfo;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsContentUtils::NameChanged(mNodeInfo, nsGkAtoms::tr,
|
|
|
|
getter_AddRefs(nodeInfo));
|
|
|
|
|
2012-12-29 06:07:48 -08:00
|
|
|
nsRefPtr<nsGenericHTMLElement> rowContent =
|
|
|
|
NS_NewHTMLTableRowElement(nodeInfo.forget());
|
2010-07-23 02:49:57 -07:00
|
|
|
if (!rowContent) {
|
2012-12-29 06:07:48 -08:00
|
|
|
aError.Throw(NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (doInsert) {
|
2012-12-29 06:07:48 -08:00
|
|
|
nsINode::InsertBefore(*rowContent, rows->Item(aIndex), aError);
|
2007-03-22 10:30:00 -07:00
|
|
|
} else {
|
2012-12-29 06:07:48 -08:00
|
|
|
nsINode::AppendChild(*rowContent, aError);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-12-29 06:07:48 -08:00
|
|
|
return rowContent.forget();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-12-29 06:07:48 -08:00
|
|
|
void
|
|
|
|
HTMLTableSectionElement::DeleteRow(int32_t aValue, ErrorResult& aError)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (aValue < -1) {
|
2012-12-29 06:07:48 -08:00
|
|
|
aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
|
|
|
return;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-12-29 06:07:48 -08:00
|
|
|
nsIHTMLCollection* rows = Rows();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t refIndex;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (aValue == -1) {
|
2012-12-29 06:07:48 -08:00
|
|
|
refIndex = rows->Length();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (refIndex == 0) {
|
2012-12-29 06:07:48 -08:00
|
|
|
return;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
--refIndex;
|
|
|
|
}
|
|
|
|
else {
|
2012-08-22 08:56:38 -07:00
|
|
|
refIndex = (uint32_t)aValue;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-12-29 06:07:48 -08:00
|
|
|
nsINode* row = rows->Item(refIndex);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!row) {
|
2012-12-29 06:07:48 -08:00
|
|
|
aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
|
|
|
return;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-12-29 06:07:48 -08:00
|
|
|
nsINode::RemoveChild(*row, aError);
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2012-12-27 18:45:57 -08:00
|
|
|
HTMLTableSectionElement::ParseAttribute(int32_t aNamespaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
|
|
|
nsAttrValue& aResult)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (aNamespaceID == kNameSpaceID_None) {
|
|
|
|
/* ignore these attributes, stored simply as strings
|
|
|
|
ch
|
|
|
|
*/
|
|
|
|
if (aAttribute == nsGkAtoms::charoff) {
|
|
|
|
return aResult.ParseIntWithBounds(aValue, 0);
|
|
|
|
}
|
|
|
|
if (aAttribute == nsGkAtoms::height) {
|
2011-02-04 11:46:16 -08:00
|
|
|
return aResult.ParseSpecialIntValue(aValue);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
if (aAttribute == nsGkAtoms::align) {
|
|
|
|
return ParseTableCellHAlignValue(aValue, aResult);
|
|
|
|
}
|
|
|
|
if (aAttribute == nsGkAtoms::bgcolor) {
|
2010-07-17 01:09:14 -07:00
|
|
|
return aResult.ParseColor(aValue);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
if (aAttribute == nsGkAtoms::valign) {
|
|
|
|
return ParseTableVAlignValue(aValue, aResult);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-24 10:50:49 -07:00
|
|
|
return nsGenericHTMLElement::ParseBackgroundAttribute(aNamespaceID,
|
|
|
|
aAttribute, aValue,
|
|
|
|
aResult) ||
|
|
|
|
nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
2007-03-22 10:30:00 -07:00
|
|
|
aResult);
|
|
|
|
}
|
|
|
|
|
2013-11-19 11:21:29 -08:00
|
|
|
void
|
|
|
|
HTMLTableSectionElement::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(Position)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// height: value
|
2011-03-17 20:14:31 -07:00
|
|
|
nsCSSValue* height = aData->ValueForHeight();
|
|
|
|
if (height->GetUnit() == eCSSUnit_Null) {
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::height);
|
|
|
|
if (value && value->Type() == nsAttrValue::eInteger)
|
2011-03-17 20:14:31 -07:00
|
|
|
height->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
2007-10-08 14:58:22 -07:00
|
|
|
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Text)) {
|
2011-03-17 20:14:31 -07:00
|
|
|
nsCSSValue* textAlign = aData->ValueForTextAlign();
|
|
|
|
if (textAlign->GetUnit() == eCSSUnit_Null) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// align: enum
|
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
|
|
|
|
if (value && value->Type() == nsAttrValue::eEnum)
|
2011-03-17 20:14:31 -07:00
|
|
|
textAlign->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
2007-10-08 14:58:22 -07:00
|
|
|
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(TextReset)) {
|
2011-03-17 20:14:31 -07:00
|
|
|
nsCSSValue* verticalAlign = aData->ValueForVerticalAlign();
|
|
|
|
if (verticalAlign->GetUnit() == eCSSUnit_Null) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// valign: enum
|
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::valign);
|
|
|
|
if (value && value->Type() == nsAttrValue::eEnum)
|
2011-03-17 20:14:31 -07:00
|
|
|
verticalAlign->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsGenericHTMLElement::MapBackgroundAttributesInto(aAttributes, aData);
|
|
|
|
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHODIMP_(bool)
|
2012-12-27 18:45:57 -08:00
|
|
|
HTMLTableSectionElement::IsAttributeMapped(const nsIAtom* aAttribute) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
static const MappedAttributeEntry attributes[] = {
|
2013-08-01 15:24:22 -07:00
|
|
|
{ &nsGkAtoms::align },
|
2007-03-22 10:30:00 -07:00
|
|
|
{ &nsGkAtoms::valign },
|
|
|
|
{ &nsGkAtoms::height },
|
2012-07-30 07:20:58 -07:00
|
|
|
{ nullptr }
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static const MappedAttributeEntry* const map[] = {
|
|
|
|
attributes,
|
|
|
|
sCommonAttributeMap,
|
|
|
|
sBackgroundAttributeMap,
|
|
|
|
};
|
|
|
|
|
2011-12-18 02:09:27 -08:00
|
|
|
return FindAttributeDependence(aAttribute, map);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nsMapRuleToAttributesFunc
|
2012-12-27 18:45:57 -08:00
|
|
|
HTMLTableSectionElement::GetAttributeMappingFunction() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return &MapAttributesIntoRule;
|
|
|
|
}
|
2012-12-27 18:45:57 -08:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|