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/HTMLTableColElement.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:57 +00:00
|
|
|
#include "mozilla/dom/HTMLTableColElementBinding.h"
|
1998-09-02 00:56:01 +00:00
|
|
|
|
2012-12-28 02:45:57 +00:00
|
|
|
NS_IMPL_NS_NEW_HTML_ELEMENT(TableCol)
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2011-10-11 05:50:08 +00:00
|
|
|
|
2002-11-19 15:43:22 +00:00
|
|
|
// use the same protection as ancient code did
|
|
|
|
// http://lxr.mozilla.org/classic/source/lib/layout/laytable.c#46
|
|
|
|
#define MAX_COLSPAN 1000
|
|
|
|
|
2012-12-28 02:45:57 +00:00
|
|
|
HTMLTableColElement::~HTMLTableColElement()
|
1998-09-02 00:56:01 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-12-29 14:07: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
|
|
|
HTMLTableColElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
2012-12-29 14:07: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 HTMLTableColElementBinding::Wrap(aCx, this, aGivenProto);
|
2012-12-29 14:07:57 +00:00
|
|
|
}
|
|
|
|
|
2012-12-28 02:45:57 +00:00
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLTableColElement)
|
1998-09-02 00:56:01 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2012-12-28 02:45:57 +00:00
|
|
|
HTMLTableColElement::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) {
|
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::span) {
|
2005-11-29 16:37:15 +00:00
|
|
|
/* protection from unrealistic large colspan values */
|
|
|
|
return aResult.ParseIntWithBounds(aValue, 1, MAX_COLSPAN);
|
|
|
|
}
|
2006-12-26 17:47:52 +00:00
|
|
|
if (aAttribute == nsGkAtoms::width) {
|
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::valign) {
|
2005-11-29 16:37:15 +00:00
|
|
|
return ParseTableVAlignValue(aValue, aResult);
|
|
|
|
}
|
1998-09-15 17:58:24 +00:00
|
|
|
}
|
2000-12-23 10:56:31 +00:00
|
|
|
|
2005-11-29 16:37:15 +00:00
|
|
|
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
|
|
|
aResult);
|
1998-09-02 00:56:01 +00:00
|
|
|
}
|
|
|
|
|
2013-11-19 19:21:29 +00:00
|
|
|
void
|
|
|
|
HTMLTableColElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|
|
|
nsRuleData* aData)
|
1998-09-02 00:56:01 +00:00
|
|
|
{
|
2011-03-18 03:14:31 +00:00
|
|
|
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Table)) {
|
|
|
|
nsCSSValue *span = aData->ValueForSpan();
|
|
|
|
if (span->GetUnit() == eCSSUnit_Null) {
|
|
|
|
// span: int
|
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::span);
|
|
|
|
if (value && value->Type() == nsAttrValue::eInteger) {
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t val = value->GetIntegerValue();
|
2011-03-18 03:14:31 +00:00
|
|
|
// Note: Do NOT use this code for table cells! The value "0"
|
|
|
|
// means something special for colspan and rowspan, but for <col
|
|
|
|
// span> and <colgroup span> it's just disallowed.
|
|
|
|
if (val > 0) {
|
|
|
|
span->SetIntValue(value->GetIntegerValue(), eCSSUnit_Integer);
|
|
|
|
}
|
2008-02-15 04:19:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-03-18 03:14:31 +00:00
|
|
|
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) {
|
|
|
|
nsCSSValue* width = aData->ValueForWidth();
|
|
|
|
if (width->GetUnit() == eCSSUnit_Null) {
|
|
|
|
// width
|
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
|
|
|
|
if (value) {
|
|
|
|
switch (value->Type()) {
|
|
|
|
case nsAttrValue::ePercent: {
|
|
|
|
width->SetPercentValue(value->GetPercentValue());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case nsAttrValue::eInteger: {
|
|
|
|
width->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
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);
|
2001-05-31 22:19:43 +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-11-12 18:37:28 +00:00
|
|
|
}
|
1998-09-15 17:58:24 +00:00
|
|
|
}
|
1998-11-12 18:37:28 +00:00
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
|
1998-09-05 04:00:06 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHODIMP_(bool)
|
2012-12-28 02:45:57 +00:00
|
|
|
HTMLTableColElement::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[] = {
|
2006-12-26 17:47:52 +00:00
|
|
|
{ &nsGkAtoms::width },
|
|
|
|
{ &nsGkAtoms::align },
|
|
|
|
{ &nsGkAtoms::valign },
|
|
|
|
{ &nsGkAtoms::span },
|
2012-07-30 14:20:58 +00:00
|
|
|
{ nullptr }
|
2003-04-16 20:54:20 +00:00
|
|
|
};
|
|
|
|
|
2008-02-15 04:19:28 +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
|
|
|
}
|
|
|
|
|
1998-09-15 17:58:24 +00:00
|
|
|
|
2005-01-12 19:45:38 +00:00
|
|
|
nsMapRuleToAttributesFunc
|
2012-12-28 02:45:57 +00:00
|
|
|
HTMLTableColElement::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
|
|
|
}
|
2012-12-28 02:45:57 +00:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|