2015-05-03 22:32:37 +03: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 15:12:37 +04: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 09:50:08 +04:00
|
|
|
|
2012-12-28 06:45:57 +04:00
|
|
|
#include "mozilla/dom/HTMLTableCellElement.h"
|
|
|
|
#include "mozilla/dom/HTMLTableElement.h"
|
2012-12-29 18:07:56 +04:00
|
|
|
#include "mozilla/dom/HTMLTableRowElement.h"
|
2017-01-27 03:51:01 +03:00
|
|
|
#include "mozilla/GenericSpecifiedValuesInlines.h"
|
2004-01-26 22:22:05 +03:00
|
|
|
#include "nsMappedAttributes.h"
|
2012-09-30 20:40:24 +04:00
|
|
|
#include "nsAttrValueInlines.h"
|
2011-08-20 14:18:50 +04:00
|
|
|
#include "nsRuleWalker.h"
|
2008-07-16 19:02:18 +04:00
|
|
|
#include "celldata.h"
|
2012-12-29 18:07:56 +04:00
|
|
|
#include "mozilla/dom/HTMLTableCellElementBinding.h"
|
1998-09-02 04:56:01 +04:00
|
|
|
|
2004-05-19 00:58:12 +04:00
|
|
|
NS_IMPL_NS_NEW_HTML_ELEMENT(TableCell)
|
2000-12-23 13:56:31 +03:00
|
|
|
|
2012-12-28 06:45:57 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2000-12-23 13:56:31 +03:00
|
|
|
|
2012-12-28 06:45:57 +04:00
|
|
|
HTMLTableCellElement::~HTMLTableCellElement()
|
1998-09-02 04:56:01 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-12-29 18:07:56 +04: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 17:13:33 +03:00
|
|
|
HTMLTableCellElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
2012-12-29 18:07:56 +04: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 17:13:33 +03:00
|
|
|
return HTMLTableCellElementBinding::Wrap(aCx, this, aGivenProto);
|
2012-12-29 18:07:56 +04:00
|
|
|
}
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED(HTMLTableCellElement, nsGenericHTMLElement,
|
|
|
|
nsIDOMHTMLTableCellElement)
|
1998-09-02 04:56:01 +04:00
|
|
|
|
2012-12-28 06:45:57 +04:00
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLTableCellElement)
|
2000-12-23 13:56:31 +03:00
|
|
|
|
1998-09-02 04:56:01 +04:00
|
|
|
|
1998-12-18 20:05:17 +03:00
|
|
|
// protected method
|
2012-12-29 18:07:56 +04:00
|
|
|
HTMLTableRowElement*
|
2012-12-28 06:45:57 +04:00
|
|
|
HTMLTableCellElement::GetRow() const
|
1998-12-18 20:05:17 +03:00
|
|
|
{
|
2012-12-29 18:07:56 +04:00
|
|
|
return HTMLTableRowElement::FromContentOrNull(GetParent());
|
1998-12-18 20:05:17 +03:00
|
|
|
}
|
|
|
|
|
2003-07-13 02:12:59 +04:00
|
|
|
// protected method
|
2012-12-28 06:45:57 +04:00
|
|
|
HTMLTableElement*
|
|
|
|
HTMLTableCellElement::GetTable() const
|
2003-07-13 02:12:59 +04:00
|
|
|
{
|
2004-08-10 14:22:36 +04:00
|
|
|
nsIContent *parent = GetParent();
|
2011-11-16 11:50:19 +04:00
|
|
|
if (!parent) {
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2011-11-16 11:50:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// parent should be a row.
|
|
|
|
nsIContent* section = parent->GetParent();
|
|
|
|
if (!section) {
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2011-11-16 11:50:19 +04:00
|
|
|
}
|
|
|
|
|
2015-03-03 14:08:59 +03:00
|
|
|
if (section->IsHTMLElement(nsGkAtoms::table)) {
|
2011-11-16 11:50:19 +04:00
|
|
|
// XHTML, without a row group.
|
2012-12-28 06:45:57 +04:00
|
|
|
return static_cast<HTMLTableElement*>(section);
|
2003-07-13 02:12:59 +04:00
|
|
|
}
|
2011-11-16 11:50:19 +04:00
|
|
|
|
|
|
|
// We have a row group.
|
|
|
|
nsIContent* result = section->GetParent();
|
2015-03-03 14:08:59 +03:00
|
|
|
if (result && result->IsHTMLElement(nsGkAtoms::table)) {
|
2012-12-28 06:45:57 +04:00
|
|
|
return static_cast<HTMLTableElement*>(result);
|
2011-11-16 11:50:19 +04:00
|
|
|
}
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2003-07-13 02:12:59 +04:00
|
|
|
}
|
|
|
|
|
2012-12-29 18:07:56 +04:00
|
|
|
int32_t
|
|
|
|
HTMLTableCellElement::CellIndex() const
|
1998-09-02 04:56:01 +04:00
|
|
|
{
|
2012-12-29 18:07:56 +04:00
|
|
|
HTMLTableRowElement* row = GetRow();
|
2001-02-06 05:11:30 +03:00
|
|
|
if (!row) {
|
2012-12-29 18:07:56 +04:00
|
|
|
return -1;
|
2001-02-06 05:11:30 +03:00
|
|
|
}
|
|
|
|
|
2012-12-29 18:07:57 +04:00
|
|
|
nsIHTMLCollection* cells = row->Cells();
|
2001-02-06 05:11:30 +03:00
|
|
|
if (!cells) {
|
2012-12-29 18:07:56 +04:00
|
|
|
return -1;
|
2001-02-06 05:11:30 +03:00
|
|
|
}
|
|
|
|
|
2012-12-29 18:07:57 +04:00
|
|
|
uint32_t numCells = cells->Length();
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < numCells; i++) {
|
2012-12-29 18:07:57 +04:00
|
|
|
if (cells->Item(i) == this) {
|
2012-12-29 18:07:56 +04:00
|
|
|
return i;
|
1998-12-18 20:05:17 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-29 18:07:56 +04:00
|
|
|
return -1;
|
1998-09-02 04:56:01 +04:00
|
|
|
}
|
|
|
|
|
2013-07-31 07:32:35 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::GetCellIndex(int32_t* aCellIndex)
|
|
|
|
{
|
|
|
|
*aCellIndex = CellIndex();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-05-27 03:47:19 +04:00
|
|
|
NS_IMETHODIMP
|
2012-12-28 06:45:57 +04:00
|
|
|
HTMLTableCellElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker)
|
1999-05-27 03:47:19 +04:00
|
|
|
{
|
2004-02-10 22:36:43 +03:00
|
|
|
nsresult rv = nsGenericHTMLElement::WalkContentStyleRules(aRuleWalker);
|
2003-09-11 05:34:29 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2012-12-28 06:45:57 +04:00
|
|
|
if (HTMLTableElement* table = GetTable()) {
|
2011-08-20 14:18:50 +04:00
|
|
|
nsMappedAttributes* tableInheritedAttributes =
|
|
|
|
table->GetAttributesMappedForCell();
|
2011-11-16 11:50:19 +04:00
|
|
|
if (tableInheritedAttributes) {
|
2011-08-20 14:18:50 +04:00
|
|
|
aRuleWalker->Forward(tableInheritedAttributes);
|
2011-11-16 11:50:19 +04:00
|
|
|
}
|
1999-05-27 03:47:19 +04:00
|
|
|
}
|
2011-08-20 14:18:50 +04:00
|
|
|
return NS_OK;
|
1999-05-27 03:47:19 +04:00
|
|
|
}
|
|
|
|
|
2013-07-31 07:32:35 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::SetAbbr(const nsAString& aAbbr)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetAbbr(aAbbr, rv);
|
2015-04-27 16:18:51 +03:00
|
|
|
return rv.StealNSResult();
|
2013-07-31 07:32:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::GetAbbr(nsAString& aAbbr)
|
|
|
|
{
|
2015-02-13 04:27:39 +03:00
|
|
|
DOMString abbr;
|
2013-07-31 07:32:35 +04:00
|
|
|
GetAbbr(abbr);
|
2015-02-13 04:27:39 +03:00
|
|
|
abbr.ToString(aAbbr);
|
2013-07-31 07:32:35 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::SetAxis(const nsAString& aAxis)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetAxis(aAxis, rv);
|
2015-04-27 16:18:51 +03:00
|
|
|
return rv.StealNSResult();
|
2013-07-31 07:32:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::GetAxis(nsAString& aAxis)
|
|
|
|
{
|
2015-02-13 04:27:39 +03:00
|
|
|
DOMString axis;
|
2013-07-31 07:32:35 +04:00
|
|
|
GetAxis(axis);
|
2015-02-13 04:27:39 +03:00
|
|
|
axis.ToString(aAxis);
|
2013-07-31 07:32:35 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::SetAlign(const nsAString& aAlign)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetAlign(aAlign, rv);
|
2015-04-27 16:18:51 +03:00
|
|
|
return rv.StealNSResult();
|
2013-07-31 07:32:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::GetAlign(nsAString& aAlign)
|
|
|
|
{
|
2015-02-13 04:27:39 +03:00
|
|
|
DOMString align;
|
2013-07-31 07:32:35 +04:00
|
|
|
GetAlign(align);
|
2015-02-13 04:27:39 +03:00
|
|
|
align.ToString(aAlign);
|
2013-07-31 07:32:35 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::SetVAlign(const nsAString& aVAlign)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetVAlign(aVAlign, rv);
|
2015-04-27 16:18:51 +03:00
|
|
|
return rv.StealNSResult();
|
2013-07-31 07:32:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::GetVAlign(nsAString& aVAlign)
|
|
|
|
{
|
2015-02-13 04:27:39 +03:00
|
|
|
DOMString vAlign;
|
2013-07-31 07:32:35 +04:00
|
|
|
GetVAlign(vAlign);
|
2015-02-13 04:27:39 +03:00
|
|
|
vAlign.ToString(aVAlign);
|
2013-07-31 07:32:35 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::SetCh(const nsAString& aCh)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetCh(aCh, rv);
|
2015-04-27 16:18:51 +03:00
|
|
|
return rv.StealNSResult();
|
2013-07-31 07:32:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::GetCh(nsAString& aCh)
|
|
|
|
{
|
2015-02-13 04:27:39 +03:00
|
|
|
DOMString ch;
|
2013-07-31 07:32:35 +04:00
|
|
|
GetCh(ch);
|
2015-02-13 04:27:39 +03:00
|
|
|
ch.ToString(aCh);
|
2013-07-31 07:32:35 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::SetChOff(const nsAString& aChOff)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetChOff(aChOff, rv);
|
2015-04-27 16:18:51 +03:00
|
|
|
return rv.StealNSResult();
|
2013-07-31 07:32:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::GetChOff(nsAString& aChOff)
|
|
|
|
{
|
2015-02-13 04:27:39 +03:00
|
|
|
DOMString chOff;
|
2013-07-31 07:32:35 +04:00
|
|
|
GetChOff(chOff);
|
2015-02-13 04:27:39 +03:00
|
|
|
chOff.ToString(aChOff);
|
2013-07-31 07:32:35 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::SetBgColor(const nsAString& aBgColor)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetBgColor(aBgColor, rv);
|
2015-04-27 16:18:51 +03:00
|
|
|
return rv.StealNSResult();
|
2013-07-31 07:32:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::GetBgColor(nsAString& aBgColor)
|
|
|
|
{
|
2015-02-13 04:27:39 +03:00
|
|
|
DOMString bgColor;
|
2013-07-31 07:32:35 +04:00
|
|
|
GetBgColor(bgColor);
|
2015-02-13 04:27:39 +03:00
|
|
|
bgColor.ToString(aBgColor);
|
2013-07-31 07:32:35 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::SetHeight(const nsAString& aHeight)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetHeight(aHeight, rv);
|
2015-04-27 16:18:51 +03:00
|
|
|
return rv.StealNSResult();
|
2013-07-31 07:32:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::GetHeight(nsAString& aHeight)
|
|
|
|
{
|
2015-02-13 04:27:39 +03:00
|
|
|
DOMString height;
|
2013-07-31 07:32:35 +04:00
|
|
|
GetHeight(height);
|
2015-02-13 04:27:39 +03:00
|
|
|
height.ToString(aHeight);
|
2013-07-31 07:32:35 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::SetWidth(const nsAString& aWidth)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetWidth(aWidth, rv);
|
2015-04-27 16:18:51 +03:00
|
|
|
return rv.StealNSResult();
|
2013-07-31 07:32:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::GetWidth(nsAString& aWidth)
|
|
|
|
{
|
2015-02-13 04:27:39 +03:00
|
|
|
DOMString width;
|
2013-07-31 07:32:35 +04:00
|
|
|
GetWidth(width);
|
2015-02-13 04:27:39 +03:00
|
|
|
width.ToString(aWidth);
|
2013-07-31 07:32:35 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::SetNoWrap(bool aNoWrap)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetNoWrap(aNoWrap, rv);
|
2015-04-27 16:18:51 +03:00
|
|
|
return rv.StealNSResult();
|
2013-07-31 07:32:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::GetNoWrap(bool* aNoWrap)
|
|
|
|
{
|
|
|
|
*aNoWrap = NoWrap();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::SetScope(const nsAString& aScope)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetScope(aScope, rv);
|
2015-04-27 16:18:51 +03:00
|
|
|
return rv.StealNSResult();
|
2013-07-31 07:32:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::GetScope(nsAString& aScope)
|
|
|
|
{
|
2015-02-13 04:27:39 +03:00
|
|
|
DOMString scope;
|
2013-07-31 07:32:35 +04:00
|
|
|
GetScope(scope);
|
2015-02-13 04:27:39 +03:00
|
|
|
scope.ToString(aScope);
|
2013-07-31 07:32:35 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::SetHeaders(const nsAString& aHeaders)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetHeaders(aHeaders, rv);
|
2015-04-27 16:18:51 +03:00
|
|
|
return rv.StealNSResult();
|
2013-07-31 07:32:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::GetHeaders(nsAString& aHeaders)
|
|
|
|
{
|
2015-02-13 04:27:39 +03:00
|
|
|
DOMString headers;
|
2013-07-31 07:32:35 +04:00
|
|
|
GetHeaders(headers);
|
2015-02-13 04:27:39 +03:00
|
|
|
headers.ToString(aHeaders);
|
2013-07-31 07:32:35 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::SetColSpan(int32_t aColSpan)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetColSpan(aColSpan, rv);
|
2015-04-27 16:18:51 +03:00
|
|
|
return rv.StealNSResult();
|
2013-07-31 07:32:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::GetColSpan(int32_t* aColSpan)
|
|
|
|
{
|
|
|
|
*aColSpan = ColSpan();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::SetRowSpan(int32_t aRowSpan)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetRowSpan(aRowSpan, rv);
|
2015-04-27 16:18:51 +03:00
|
|
|
return rv.StealNSResult();
|
2013-07-31 07:32:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::GetRowSpan(int32_t* aRowSpan)
|
|
|
|
{
|
|
|
|
*aRowSpan = RowSpan();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-12-29 18:07:56 +04:00
|
|
|
void
|
2015-02-13 04:27:39 +03:00
|
|
|
HTMLTableCellElement::GetAlign(DOMString& aValue)
|
2012-12-29 18:07:56 +04:00
|
|
|
{
|
|
|
|
if (!GetAttr(kNameSpaceID_None, nsGkAtoms::align, aValue)) {
|
|
|
|
// There's no align attribute, ask the row for the alignment.
|
|
|
|
HTMLTableRowElement* row = GetRow();
|
|
|
|
if (row) {
|
|
|
|
row->GetAlign(aValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-09-11 05:57:40 +04:00
|
|
|
|
2005-01-25 03:02:58 +03:00
|
|
|
static const nsAttrValue::EnumTable kCellScopeTable[] = {
|
1998-09-15 21:58:24 +04:00
|
|
|
{ "row", NS_STYLE_CELL_SCOPE_ROW },
|
|
|
|
{ "col", NS_STYLE_CELL_SCOPE_COL },
|
|
|
|
{ "rowgroup", NS_STYLE_CELL_SCOPE_ROWGROUP },
|
|
|
|
{ "colgroup", NS_STYLE_CELL_SCOPE_COLGROUP },
|
2016-09-07 05:20:17 +03:00
|
|
|
{ nullptr, 0 }
|
1998-09-15 21:58:24 +04:00
|
|
|
};
|
|
|
|
|
2016-05-05 21:29:54 +03:00
|
|
|
void
|
|
|
|
HTMLTableCellElement::GetScope(DOMString& aScope)
|
|
|
|
{
|
|
|
|
GetEnumAttr(nsGkAtoms::scope, nullptr, aScope);
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2012-12-28 06:45:57 +04:00
|
|
|
HTMLTableCellElement::ParseAttribute(int32_t aNamespaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
|
|
|
nsAttrValue& aResult)
|
1998-09-02 04:56:01 +04:00
|
|
|
{
|
2005-11-29 19:37:15 +03:00
|
|
|
if (aNamespaceID == kNameSpaceID_None) {
|
|
|
|
/* ignore these attributes, stored simply as strings
|
|
|
|
abbr, axis, ch, headers
|
|
|
|
*/
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::charoff) {
|
2005-11-29 19:37:15 +03:00
|
|
|
/* attributes that resolve to integers with a min of 0 */
|
|
|
|
return aResult.ParseIntWithBounds(aValue, 0);
|
|
|
|
}
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::colspan) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool res = aResult.ParseIntWithBounds(aValue, -1);
|
2005-11-29 19:37:15 +03:00
|
|
|
if (res) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t val = aResult.GetIntegerValue();
|
2005-11-29 19:37:15 +03:00
|
|
|
// reset large colspan values as IE and opera do
|
2016-01-27 19:02:12 +03:00
|
|
|
if (val > MAX_COLSPAN || val <= 0) {
|
2015-03-13 04:46:57 +03:00
|
|
|
aResult.SetTo(1, &aValue);
|
2005-11-29 19:37:15 +03:00
|
|
|
}
|
2004-11-16 18:46:55 +03:00
|
|
|
}
|
2005-11-29 19:37:15 +03:00
|
|
|
return res;
|
2004-11-16 18:46:55 +03:00
|
|
|
}
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::rowspan) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool res = aResult.ParseIntWithBounds(aValue, -1, MAX_ROWSPAN);
|
2005-11-29 19:37:15 +03:00
|
|
|
if (res) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t val = aResult.GetIntegerValue();
|
2005-11-29 19:37:15 +03:00
|
|
|
// quirks mode does not honor the special html 4 value of 0
|
2011-10-18 14:53:36 +04:00
|
|
|
if (val < 0 || (0 == val && InNavQuirksMode(OwnerDoc()))) {
|
2015-03-13 04:46:57 +03:00
|
|
|
aResult.SetTo(1, &aValue);
|
2005-11-29 19:37:15 +03:00
|
|
|
}
|
1999-09-14 00:18:33 +04:00
|
|
|
}
|
2005-11-29 19:37:15 +03:00
|
|
|
return res;
|
|
|
|
}
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::height) {
|
2011-02-04 22:46:16 +03:00
|
|
|
return aResult.ParseSpecialIntValue(aValue);
|
2005-11-29 19:37:15 +03:00
|
|
|
}
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::width) {
|
2011-02-04 22:46:16 +03:00
|
|
|
return aResult.ParseSpecialIntValue(aValue);
|
2005-11-29 19:37:15 +03:00
|
|
|
}
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::align) {
|
2005-11-29 19:37:15 +03:00
|
|
|
return ParseTableCellHAlignValue(aValue, aResult);
|
|
|
|
}
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::bgcolor) {
|
2010-07-17 12:09:14 +04:00
|
|
|
return aResult.ParseColor(aValue);
|
2005-11-29 19:37:15 +03:00
|
|
|
}
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::scope) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return aResult.ParseEnumValue(aValue, kCellScopeTable, false);
|
2005-11-29 19:37:15 +03:00
|
|
|
}
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::valign) {
|
2005-11-29 19:37:15 +03:00
|
|
|
return ParseTableVAlignValue(aValue, aResult);
|
1999-07-24 23:55:35 +04:00
|
|
|
}
|
1998-09-15 21:58:24 +04:00
|
|
|
}
|
2000-12-23 13:56:31 +03:00
|
|
|
|
2012-08-24 21:50:49 +04:00
|
|
|
return nsGenericHTMLElement::ParseBackgroundAttribute(aNamespaceID,
|
|
|
|
aAttribute, aValue,
|
|
|
|
aResult) ||
|
|
|
|
nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
2005-11-29 19:37:15 +03:00
|
|
|
aResult);
|
1998-09-02 04:56:01 +04:00
|
|
|
}
|
|
|
|
|
2013-11-19 23:21:29 +04:00
|
|
|
void
|
|
|
|
HTMLTableCellElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
2017-01-27 03:51:01 +03:00
|
|
|
GenericSpecifiedValues* aData)
|
1998-09-02 04:56:01 +04:00
|
|
|
{
|
2017-01-27 03:51:01 +03:00
|
|
|
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Position))) {
|
2001-06-01 02:19:43 +04:00
|
|
|
// width: value
|
2017-01-27 03:51:01 +03:00
|
|
|
if (!aData->PropertyIsSet(eCSSProperty_width)) {
|
2006-12-26 20:47:52 +03:00
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
|
2004-04-13 20:45:59 +04:00
|
|
|
if (value && value->Type() == nsAttrValue::eInteger) {
|
|
|
|
if (value->GetIntegerValue() > 0)
|
2017-01-27 03:51:01 +03:00
|
|
|
aData->SetPixelValue(eCSSProperty_width, (float)value->GetIntegerValue());
|
2001-06-01 02:19:43 +04:00
|
|
|
// else 0 implies auto for compatibility.
|
1999-10-14 08:01:26 +04:00
|
|
|
}
|
2004-04-13 20:45:59 +04:00
|
|
|
else if (value && value->Type() == nsAttrValue::ePercent) {
|
|
|
|
if (value->GetPercentValue() > 0.0f)
|
2017-01-27 03:51:01 +03:00
|
|
|
aData->SetPercentValue(eCSSProperty_width, value->GetPercentValue());
|
2001-06-01 02:19:43 +04:00
|
|
|
// else 0 implies auto for compatibility
|
1999-10-14 08:01:26 +04:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
// height: value
|
2017-01-27 03:51:01 +03:00
|
|
|
if (!aData->PropertyIsSet(eCSSProperty_height)) {
|
2006-12-26 20:47:52 +03:00
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::height);
|
2004-04-13 20:45:59 +04:00
|
|
|
if (value && value->Type() == nsAttrValue::eInteger) {
|
|
|
|
if (value->GetIntegerValue() > 0)
|
2017-01-27 03:51:01 +03:00
|
|
|
aData->SetPixelValue(eCSSProperty_height, (float)value->GetIntegerValue());
|
2001-06-01 02:19:43 +04:00
|
|
|
// else 0 implies auto for compatibility.
|
2001-05-03 17:20:48 +04:00
|
|
|
}
|
2004-04-13 20:45:59 +04:00
|
|
|
else if (value && value->Type() == nsAttrValue::ePercent) {
|
|
|
|
if (value->GetPercentValue() > 0.0f)
|
2017-01-27 03:51:01 +03:00
|
|
|
aData->SetPercentValue(eCSSProperty_height, value->GetPercentValue());
|
2001-06-01 02:19:43 +04:00
|
|
|
// else 0 implies auto for compatibility
|
2001-05-03 17:20:48 +04:00
|
|
|
}
|
1999-08-26 01:49:18 +04:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
2017-01-27 03:51:01 +03:00
|
|
|
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Text))) {
|
|
|
|
if (!aData->PropertyIsSet(eCSSProperty_white_space)) {
|
2003-09-11 05:34:29 +04:00
|
|
|
// nowrap: enum
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttributes->GetAttr(nsGkAtoms::nowrap)) {
|
2009-11-18 01:50:06 +03:00
|
|
|
// See if our width is not a nonzero integer width.
|
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
|
2017-01-27 03:51:01 +03:00
|
|
|
nsCompatibility mode = aData->PresContext()->CompatibilityMode();
|
2009-11-18 01:50:06 +03:00
|
|
|
if (!value || value->Type() != nsAttrValue::eInteger ||
|
|
|
|
value->GetIntegerValue() == 0 ||
|
|
|
|
eCompatibility_NavQuirks != mode) {
|
2017-01-27 03:51:01 +03:00
|
|
|
aData->SetKeywordValue(eCSSProperty_white_space, NS_STYLE_WHITESPACE_NOWRAP);
|
2009-11-18 01:50:06 +03:00
|
|
|
}
|
2001-05-03 17:20:48 +04:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
2003-09-11 05:34:29 +04:00
|
|
|
}
|
2017-01-27 03:51:01 +03:00
|
|
|
|
|
|
|
nsGenericHTMLElement::MapDivAlignAttributeInto(aAttributes, aData);
|
|
|
|
nsGenericHTMLElement::MapVAlignAttributeInto(aAttributes, aData);
|
|
|
|
nsGenericHTMLElement::MapBackgroundAttributesInto(aAttributes, aData);
|
|
|
|
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
|
1998-09-02 04:56:01 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP_(bool)
|
2012-12-28 06:45:57 +04:00
|
|
|
HTMLTableCellElement::IsAttributeMapped(const nsIAtom* aAttribute) const
|
1999-07-07 05:24:40 +04:00
|
|
|
{
|
2004-02-26 00:04:50 +03:00
|
|
|
static const MappedAttributeEntry attributes[] = {
|
2006-12-26 20:47:52 +03:00
|
|
|
{ &nsGkAtoms::align },
|
|
|
|
{ &nsGkAtoms::valign },
|
|
|
|
{ &nsGkAtoms::nowrap },
|
2003-07-12 01:16:12 +04:00
|
|
|
#if 0
|
|
|
|
// XXXldb If these are implemented, they might need to move to
|
|
|
|
// GetAttributeChangeHint (depending on how, and preferably not).
|
2006-12-26 20:47:52 +03:00
|
|
|
{ &nsGkAtoms::abbr },
|
|
|
|
{ &nsGkAtoms::axis },
|
|
|
|
{ &nsGkAtoms::headers },
|
|
|
|
{ &nsGkAtoms::scope },
|
2003-07-12 01:16:12 +04:00
|
|
|
#endif
|
2006-12-26 20:47:52 +03:00
|
|
|
{ &nsGkAtoms::width },
|
|
|
|
{ &nsGkAtoms::height },
|
2012-07-30 18:20:58 +04:00
|
|
|
{ nullptr }
|
2003-04-17 00:54:20 +04:00
|
|
|
};
|
|
|
|
|
2004-02-26 00:04:50 +03:00
|
|
|
static const MappedAttributeEntry* const map[] = {
|
2003-04-17 00:54:20 +04:00
|
|
|
attributes,
|
|
|
|
sCommonAttributeMap,
|
|
|
|
sBackgroundAttributeMap,
|
|
|
|
};
|
|
|
|
|
2011-12-18 14:09:27 +04:00
|
|
|
return FindAttributeDependence(aAttribute, map);
|
1999-07-07 05:24:40 +04:00
|
|
|
}
|
|
|
|
|
2005-01-12 22:45:38 +03:00
|
|
|
nsMapRuleToAttributesFunc
|
2012-12-28 06:45:57 +04:00
|
|
|
HTMLTableCellElement::GetAttributeMappingFunction() const
|
1998-09-05 08:00:06 +04:00
|
|
|
{
|
2005-01-12 22:45:38 +03:00
|
|
|
return &MapAttributesIntoRule;
|
1998-09-05 08:00:06 +04:00
|
|
|
}
|
2012-12-28 06:45:57 +04:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|