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