2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
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/HTMLTableCellElement.h"
|
|
|
|
#include "mozilla/dom/HTMLTableElement.h"
|
2012-12-29 06:07:56 -08:00
|
|
|
#include "mozilla/dom/HTMLTableRowElement.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"
|
2011-08-20 03:18:50 -07:00
|
|
|
#include "nsRuleWalker.h"
|
2008-07-16 08:02:18 -07:00
|
|
|
#include "celldata.h"
|
2012-12-29 06:07:56 -08:00
|
|
|
#include "mozilla/dom/HTMLTableCellElementBinding.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_IMPL_NS_NEW_HTML_ELEMENT(TableCell)
|
|
|
|
|
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
|
|
|
HTMLTableCellElement::~HTMLTableCellElement()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-12-29 06:07:56 -08:00
|
|
|
JSObject*
|
2014-04-08 15:27:17 -07:00
|
|
|
HTMLTableCellElement::WrapNode(JSContext *aCx)
|
2012-12-29 06:07:56 -08:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-08 15:27:17 -07:00
|
|
|
return HTMLTableCellElementBinding::Wrap(aCx, this);
|
2012-12-29 06:07:56 -08:00
|
|
|
}
|
|
|
|
|
2014-04-27 00:06:00 -07:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED(HTMLTableCellElement, nsGenericHTMLElement,
|
|
|
|
nsIDOMHTMLTableCellElement)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-12-27 18:45:57 -08:00
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLTableCellElement)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
|
|
|
|
// protected method
|
2012-12-29 06:07:56 -08:00
|
|
|
HTMLTableRowElement*
|
2012-12-27 18:45:57 -08:00
|
|
|
HTMLTableCellElement::GetRow() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-12-29 06:07:56 -08:00
|
|
|
return HTMLTableRowElement::FromContentOrNull(GetParent());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// protected method
|
2012-12-27 18:45:57 -08:00
|
|
|
HTMLTableElement*
|
|
|
|
HTMLTableCellElement::GetTable() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsIContent *parent = GetParent();
|
2011-11-15 23:50:19 -08:00
|
|
|
if (!parent) {
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2011-11-15 23:50:19 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// parent should be a row.
|
|
|
|
nsIContent* section = parent->GetParent();
|
|
|
|
if (!section) {
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2011-11-15 23:50:19 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (section->IsHTML(nsGkAtoms::table)) {
|
|
|
|
// XHTML, without a row group.
|
2012-12-27 18:45:57 -08:00
|
|
|
return static_cast<HTMLTableElement*>(section);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2011-11-15 23:50:19 -08:00
|
|
|
|
|
|
|
// We have a row group.
|
|
|
|
nsIContent* result = section->GetParent();
|
|
|
|
if (result && result->IsHTML(nsGkAtoms::table)) {
|
2012-12-27 18:45:57 -08:00
|
|
|
return static_cast<HTMLTableElement*>(result);
|
2011-11-15 23:50:19 -08:00
|
|
|
}
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-12-29 06:07:56 -08:00
|
|
|
int32_t
|
|
|
|
HTMLTableCellElement::CellIndex() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-12-29 06:07:56 -08:00
|
|
|
HTMLTableRowElement* row = GetRow();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!row) {
|
2012-12-29 06:07:56 -08:00
|
|
|
return -1;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-12-29 06:07:57 -08:00
|
|
|
nsIHTMLCollection* cells = row->Cells();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!cells) {
|
2012-12-29 06:07:56 -08:00
|
|
|
return -1;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-12-29 06:07:57 -08:00
|
|
|
uint32_t numCells = cells->Length();
|
2012-08-22 08:56:38 -07:00
|
|
|
for (uint32_t i = 0; i < numCells; i++) {
|
2012-12-29 06:07:57 -08:00
|
|
|
if (cells->Item(i) == this) {
|
2012-12-29 06:07:56 -08:00
|
|
|
return i;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-29 06:07:56 -08:00
|
|
|
return -1;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-07-30 20:32:35 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::GetCellIndex(int32_t* aCellIndex)
|
|
|
|
{
|
|
|
|
*aCellIndex = CellIndex();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHODIMP
|
2012-12-27 18:45:57 -08:00
|
|
|
HTMLTableCellElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsresult rv = nsGenericHTMLElement::WalkContentStyleRules(aRuleWalker);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2012-12-27 18:45:57 -08:00
|
|
|
if (HTMLTableElement* table = GetTable()) {
|
2011-08-20 03:18:50 -07:00
|
|
|
nsMappedAttributes* tableInheritedAttributes =
|
|
|
|
table->GetAttributesMappedForCell();
|
2011-11-15 23:50:19 -08:00
|
|
|
if (tableInheritedAttributes) {
|
2011-08-20 03:18:50 -07:00
|
|
|
aRuleWalker->Forward(tableInheritedAttributes);
|
2011-11-15 23:50:19 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2011-08-20 03:18:50 -07:00
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-07-30 20:32:35 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::SetAbbr(const nsAString& aAbbr)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetAbbr(aAbbr, rv);
|
|
|
|
return rv.ErrorCode();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::GetAbbr(nsAString& aAbbr)
|
|
|
|
{
|
|
|
|
nsString abbr;
|
|
|
|
GetAbbr(abbr);
|
|
|
|
aAbbr = abbr;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::SetAxis(const nsAString& aAxis)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetAxis(aAxis, rv);
|
|
|
|
return rv.ErrorCode();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::GetAxis(nsAString& aAxis)
|
|
|
|
{
|
|
|
|
nsString axis;
|
|
|
|
GetAxis(axis);
|
|
|
|
aAxis = axis;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::SetAlign(const nsAString& aAlign)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetAlign(aAlign, rv);
|
|
|
|
return rv.ErrorCode();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::GetAlign(nsAString& aAlign)
|
|
|
|
{
|
|
|
|
nsString align;
|
|
|
|
GetAlign(align);
|
|
|
|
aAlign = align;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::SetVAlign(const nsAString& aVAlign)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetVAlign(aVAlign, rv);
|
|
|
|
return rv.ErrorCode();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::GetVAlign(nsAString& aVAlign)
|
|
|
|
{
|
|
|
|
nsString vAlign;
|
|
|
|
GetVAlign(vAlign);
|
|
|
|
aVAlign = vAlign;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::SetCh(const nsAString& aCh)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetCh(aCh, rv);
|
|
|
|
return rv.ErrorCode();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::GetCh(nsAString& aCh)
|
|
|
|
{
|
|
|
|
nsString ch;
|
|
|
|
GetCh(ch);
|
|
|
|
aCh = ch;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::SetChOff(const nsAString& aChOff)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetChOff(aChOff, rv);
|
|
|
|
return rv.ErrorCode();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::GetChOff(nsAString& aChOff)
|
|
|
|
{
|
|
|
|
nsString chOff;
|
|
|
|
GetChOff(chOff);
|
|
|
|
aChOff = chOff;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::SetBgColor(const nsAString& aBgColor)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetBgColor(aBgColor, rv);
|
|
|
|
return rv.ErrorCode();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::GetBgColor(nsAString& aBgColor)
|
|
|
|
{
|
|
|
|
nsString bgColor;
|
|
|
|
GetBgColor(bgColor);
|
|
|
|
aBgColor = bgColor;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::SetHeight(const nsAString& aHeight)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetHeight(aHeight, rv);
|
|
|
|
return rv.ErrorCode();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::GetHeight(nsAString& aHeight)
|
|
|
|
{
|
|
|
|
nsString height;
|
|
|
|
GetHeight(height);
|
|
|
|
aHeight = height;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::SetWidth(const nsAString& aWidth)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetWidth(aWidth, rv);
|
|
|
|
return rv.ErrorCode();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::GetWidth(nsAString& aWidth)
|
|
|
|
{
|
|
|
|
nsString width;
|
|
|
|
GetWidth(width);
|
|
|
|
aWidth = width;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::SetNoWrap(bool aNoWrap)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetNoWrap(aNoWrap, rv);
|
|
|
|
return rv.ErrorCode();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::GetNoWrap(bool* aNoWrap)
|
|
|
|
{
|
|
|
|
*aNoWrap = NoWrap();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::SetScope(const nsAString& aScope)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetScope(aScope, rv);
|
|
|
|
return rv.ErrorCode();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::GetScope(nsAString& aScope)
|
|
|
|
{
|
|
|
|
nsString scope;
|
|
|
|
GetScope(scope);
|
|
|
|
aScope = scope;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::SetHeaders(const nsAString& aHeaders)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetHeaders(aHeaders, rv);
|
|
|
|
return rv.ErrorCode();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::GetHeaders(nsAString& aHeaders)
|
|
|
|
{
|
|
|
|
nsString headers;
|
|
|
|
GetHeaders(headers);
|
|
|
|
aHeaders = headers;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::SetColSpan(int32_t aColSpan)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetColSpan(aColSpan, rv);
|
|
|
|
return rv.ErrorCode();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::GetColSpan(int32_t* aColSpan)
|
|
|
|
{
|
|
|
|
*aColSpan = ColSpan();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::SetRowSpan(int32_t aRowSpan)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetRowSpan(aRowSpan, rv);
|
|
|
|
return rv.ErrorCode();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLTableCellElement::GetRowSpan(int32_t* aRowSpan)
|
|
|
|
{
|
|
|
|
*aRowSpan = RowSpan();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-12-29 06:07:56 -08:00
|
|
|
void
|
|
|
|
HTMLTableCellElement::GetAlign(nsString& aValue)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
static const nsAttrValue::EnumTable kCellScopeTable[] = {
|
|
|
|
{ "row", NS_STYLE_CELL_SCOPE_ROW },
|
|
|
|
{ "col", NS_STYLE_CELL_SCOPE_COL },
|
|
|
|
{ "rowgroup", NS_STYLE_CELL_SCOPE_ROWGROUP },
|
|
|
|
{ "colgroup", NS_STYLE_CELL_SCOPE_COLGROUP },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2012-12-27 18:45:57 -08:00
|
|
|
HTMLTableCellElement::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
|
|
|
|
abbr, axis, ch, headers
|
|
|
|
*/
|
|
|
|
if (aAttribute == nsGkAtoms::charoff) {
|
|
|
|
/* attributes that resolve to integers with a min of 0 */
|
|
|
|
return aResult.ParseIntWithBounds(aValue, 0);
|
|
|
|
}
|
|
|
|
if (aAttribute == nsGkAtoms::colspan) {
|
2011-09-28 23:19:26 -07:00
|
|
|
bool res = aResult.ParseIntWithBounds(aValue, -1);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (res) {
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t val = aResult.GetIntegerValue();
|
2007-03-22 10:30:00 -07:00
|
|
|
// reset large colspan values as IE and opera do
|
|
|
|
// quirks mode does not honor the special html 4 value of 0
|
|
|
|
if (val > MAX_COLSPAN || val < 0 ||
|
2011-10-18 03:53:36 -07:00
|
|
|
(0 == val && InNavQuirksMode(OwnerDoc()))) {
|
2007-03-22 10:30:00 -07:00
|
|
|
aResult.SetTo(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
if (aAttribute == nsGkAtoms::rowspan) {
|
2011-09-28 23:19:26 -07:00
|
|
|
bool res = aResult.ParseIntWithBounds(aValue, -1, MAX_ROWSPAN);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (res) {
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t val = aResult.GetIntegerValue();
|
2007-03-22 10:30:00 -07:00
|
|
|
// quirks mode does not honor the special html 4 value of 0
|
2011-10-18 03:53:36 -07:00
|
|
|
if (val < 0 || (0 == val && InNavQuirksMode(OwnerDoc()))) {
|
2007-03-22 10:30:00 -07:00
|
|
|
aResult.SetTo(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
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::width) {
|
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::scope) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return aResult.ParseEnumValue(aValue, kCellScopeTable, false);
|
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
|
|
|
|
HTMLTableCellElement::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
|
|
|
// width: value
|
2011-03-17 20:14:31 -07:00
|
|
|
nsCSSValue* width = aData->ValueForWidth();
|
|
|
|
if (width->GetUnit() == eCSSUnit_Null) {
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
|
|
|
|
if (value && value->Type() == nsAttrValue::eInteger) {
|
|
|
|
if (value->GetIntegerValue() > 0)
|
2011-03-17 20:14:31 -07:00
|
|
|
width->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
2007-03-22 10:30:00 -07:00
|
|
|
// else 0 implies auto for compatibility.
|
|
|
|
}
|
|
|
|
else if (value && value->Type() == nsAttrValue::ePercent) {
|
|
|
|
if (value->GetPercentValue() > 0.0f)
|
2011-03-17 20:14:31 -07:00
|
|
|
width->SetPercentValue(value->GetPercentValue());
|
2007-03-22 10:30:00 -07:00
|
|
|
// else 0 implies auto for compatibility
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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) {
|
|
|
|
if (value->GetIntegerValue() > 0)
|
2011-03-17 20:14:31 -07:00
|
|
|
height->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
2007-03-22 10:30:00 -07:00
|
|
|
// else 0 implies auto for compatibility.
|
|
|
|
}
|
|
|
|
else if (value && value->Type() == nsAttrValue::ePercent) {
|
|
|
|
if (value->GetPercentValue() > 0.0f)
|
2011-03-17 20:14:31 -07:00
|
|
|
height->SetPercentValue(value->GetPercentValue());
|
2007-03-22 10:30:00 -07:00
|
|
|
// else 0 implies auto for compatibility
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2011-03-17 20:14:31 -07:00
|
|
|
nsCSSValue* whiteSpace = aData->ValueForWhiteSpace();
|
|
|
|
if (whiteSpace->GetUnit() == eCSSUnit_Null) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// nowrap: enum
|
|
|
|
if (aAttributes->GetAttr(nsGkAtoms::nowrap)) {
|
2009-11-17 14:50:06 -08:00
|
|
|
// See if our width is not a nonzero integer width.
|
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
|
|
|
|
nsCompatibility mode = aData->mPresContext->CompatibilityMode();
|
|
|
|
if (!value || value->Type() != nsAttrValue::eInteger ||
|
|
|
|
value->GetIntegerValue() == 0 ||
|
|
|
|
eCompatibility_NavQuirks != mode) {
|
2011-03-17 20:14:31 -07:00
|
|
|
whiteSpace->SetIntValue(NS_STYLE_WHITESPACE_NOWRAP, eCSSUnit_Enumerated);
|
2009-11-17 14:50:06 -08:00
|
|
|
}
|
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
|
|
|
HTMLTableCellElement::IsAttributeMapped(const nsIAtom* aAttribute) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
static const MappedAttributeEntry attributes[] = {
|
|
|
|
{ &nsGkAtoms::align },
|
|
|
|
{ &nsGkAtoms::valign },
|
|
|
|
{ &nsGkAtoms::nowrap },
|
|
|
|
#if 0
|
|
|
|
// XXXldb If these are implemented, they might need to move to
|
|
|
|
// GetAttributeChangeHint (depending on how, and preferably not).
|
|
|
|
{ &nsGkAtoms::abbr },
|
|
|
|
{ &nsGkAtoms::axis },
|
|
|
|
{ &nsGkAtoms::headers },
|
|
|
|
{ &nsGkAtoms::scope },
|
|
|
|
#endif
|
|
|
|
{ &nsGkAtoms::width },
|
|
|
|
{ &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
|
|
|
HTMLTableCellElement::GetAttributeMappingFunction() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return &MapAttributesIntoRule;
|
|
|
|
}
|
2012-12-27 18:45:57 -08:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|