summaryrefslogtreecommitdiff
path: root/Source/WebCore/html/HTMLTableElement.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2016-04-10 09:28:39 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2016-04-10 09:28:39 +0000
commit32761a6cee1d0dee366b885b7b9c777e67885688 (patch)
treed6bec92bebfb216f4126356e55518842c2f476a1 /Source/WebCore/html/HTMLTableElement.cpp
parenta4e969f4965059196ca948db781e52f7cfebf19e (diff)
downloadWebKitGtk-tarball-32761a6cee1d0dee366b885b7b9c777e67885688.tar.gz
webkitgtk-2.4.11webkitgtk-2.4.11
Diffstat (limited to 'Source/WebCore/html/HTMLTableElement.cpp')
-rw-r--r--Source/WebCore/html/HTMLTableElement.cpp200
1 files changed, 89 insertions, 111 deletions
diff --git a/Source/WebCore/html/HTMLTableElement.cpp b/Source/WebCore/html/HTMLTableElement.cpp
index 5410456f3..bf22d0087 100644
--- a/Source/WebCore/html/HTMLTableElement.cpp
+++ b/Source/WebCore/html/HTMLTableElement.cpp
@@ -25,20 +25,19 @@
#include "config.h"
#include "HTMLTableElement.h"
+#include "Attribute.h"
#include "CSSImageValue.h"
#include "CSSPropertyNames.h"
#include "CSSValueKeywords.h"
#include "CSSValuePool.h"
#include "ExceptionCode.h"
#include "ExceptionCodePlaceholder.h"
-#include "GenericCachedHTMLCollection.h"
#include "HTMLNames.h"
#include "HTMLParserIdioms.h"
#include "HTMLTableCaptionElement.h"
#include "HTMLTableRowElement.h"
#include "HTMLTableRowsCollection.h"
#include "HTMLTableSectionElement.h"
-#include "NodeRareData.h"
#include "RenderTable.h"
#include "StyleProperties.h"
#include <wtf/Ref.h>
@@ -58,153 +57,133 @@ HTMLTableElement::HTMLTableElement(const QualifiedName& tagName, Document& docum
ASSERT(hasTagName(tableTag));
}
-Ref<HTMLTableElement> HTMLTableElement::create(Document& document)
+PassRefPtr<HTMLTableElement> HTMLTableElement::create(Document& document)
{
- return adoptRef(*new HTMLTableElement(tableTag, document));
+ return adoptRef(new HTMLTableElement(tableTag, document));
}
-Ref<HTMLTableElement> HTMLTableElement::create(const QualifiedName& tagName, Document& document)
+PassRefPtr<HTMLTableElement> HTMLTableElement::create(const QualifiedName& tagName, Document& document)
{
- return adoptRef(*new HTMLTableElement(tagName, document));
+ return adoptRef(new HTMLTableElement(tagName, document));
}
HTMLTableCaptionElement* HTMLTableElement::caption() const
{
for (Node* child = firstChild(); child; child = child->nextSibling()) {
- if (is<HTMLTableCaptionElement>(*child))
- return downcast<HTMLTableCaptionElement>(child);
+ if (child->hasTagName(captionTag))
+ return toHTMLTableCaptionElement(child);
}
- return nullptr;
+ return 0;
}
void HTMLTableElement::setCaption(PassRefPtr<HTMLTableCaptionElement> newCaption, ExceptionCode& ec)
{
deleteCaption();
- if (newCaption)
- insertBefore(*newCaption, firstChild(), ec);
+ insertBefore(newCaption, firstChild(), ec);
}
HTMLTableSectionElement* HTMLTableElement::tHead() const
{
for (Node* child = firstChild(); child; child = child->nextSibling()) {
if (child->hasTagName(theadTag))
- return downcast<HTMLTableSectionElement>(child);
+ return toHTMLTableSectionElement(child);
}
- return nullptr;
+ return 0;
}
void HTMLTableElement::setTHead(PassRefPtr<HTMLTableSectionElement> newHead, ExceptionCode& ec)
{
- if (UNLIKELY(newHead && !newHead->hasTagName(theadTag))) {
- ec = HIERARCHY_REQUEST_ERR;
- return;
- }
-
deleteTHead();
- if (!newHead)
- return;
-
Node* child;
for (child = firstChild(); child; child = child->nextSibling())
if (child->isElementNode() && !child->hasTagName(captionTag) && !child->hasTagName(colgroupTag))
break;
- insertBefore(*newHead, child, ec);
+ insertBefore(newHead, child, ec);
}
HTMLTableSectionElement* HTMLTableElement::tFoot() const
{
for (Node* child = firstChild(); child; child = child->nextSibling()) {
if (child->hasTagName(tfootTag))
- return downcast<HTMLTableSectionElement>(child);
+ return toHTMLTableSectionElement(child);
}
- return nullptr;
+ return 0;
}
void HTMLTableElement::setTFoot(PassRefPtr<HTMLTableSectionElement> newFoot, ExceptionCode& ec)
{
- if (UNLIKELY(newFoot && !newFoot->hasTagName(tfootTag))) {
- ec = HIERARCHY_REQUEST_ERR;
- return;
- }
-
deleteTFoot();
- if (!newFoot)
- return;
-
Node* child;
for (child = firstChild(); child; child = child->nextSibling())
if (child->isElementNode() && !child->hasTagName(captionTag) && !child->hasTagName(colgroupTag) && !child->hasTagName(theadTag))
break;
- insertBefore(*newFoot, child, ec);
+ insertBefore(newFoot, child, ec);
}
-Ref<HTMLTableSectionElement> HTMLTableElement::createTHead()
+PassRefPtr<HTMLElement> HTMLTableElement::createTHead()
{
if (HTMLTableSectionElement* existingHead = tHead())
- return *existingHead;
- Ref<HTMLTableSectionElement> head = HTMLTableSectionElement::create(theadTag, document());
- setTHead(head.ptr(), IGNORE_EXCEPTION);
- return head;
+ return existingHead;
+ RefPtr<HTMLTableSectionElement> head = HTMLTableSectionElement::create(theadTag, document());
+ setTHead(head, IGNORE_EXCEPTION);
+ return head.release();
}
void HTMLTableElement::deleteTHead()
{
- if (auto* tHead = this->tHead())
- removeChild(*tHead, IGNORE_EXCEPTION);
+ removeChild(tHead(), IGNORE_EXCEPTION);
}
-Ref<HTMLTableSectionElement> HTMLTableElement::createTFoot()
+PassRefPtr<HTMLElement> HTMLTableElement::createTFoot()
{
if (HTMLTableSectionElement* existingFoot = tFoot())
- return *existingFoot;
- Ref<HTMLTableSectionElement> foot = HTMLTableSectionElement::create(tfootTag, document());
- setTFoot(foot.ptr(), IGNORE_EXCEPTION);
- return foot;
+ return existingFoot;
+ RefPtr<HTMLTableSectionElement> foot = HTMLTableSectionElement::create(tfootTag, document());
+ setTFoot(foot, IGNORE_EXCEPTION);
+ return foot.release();
}
void HTMLTableElement::deleteTFoot()
{
- if (auto* tFoot = this->tFoot())
- removeChild(*tFoot, IGNORE_EXCEPTION);
+ removeChild(tFoot(), IGNORE_EXCEPTION);
}
-Ref<HTMLTableSectionElement> HTMLTableElement::createTBody()
+PassRefPtr<HTMLElement> HTMLTableElement::createTBody()
{
- Ref<HTMLTableSectionElement> body = HTMLTableSectionElement::create(tbodyTag, document());
- Node* referenceElement = lastBody() ? lastBody()->nextSibling() : nullptr;
- insertBefore(body.copyRef(), referenceElement, ASSERT_NO_EXCEPTION);
- return body;
+ RefPtr<HTMLTableSectionElement> body = HTMLTableSectionElement::create(tbodyTag, document());
+ Node* referenceElement = lastBody() ? lastBody()->nextSibling() : 0;
+ insertBefore(body, referenceElement, ASSERT_NO_EXCEPTION);
+ return body.release();
}
-Ref<HTMLTableCaptionElement> HTMLTableElement::createCaption()
+PassRefPtr<HTMLElement> HTMLTableElement::createCaption()
{
if (HTMLTableCaptionElement* existingCaption = caption())
- return *existingCaption;
- Ref<HTMLTableCaptionElement> caption = HTMLTableCaptionElement::create(captionTag, document());
- setCaption(caption.ptr(), IGNORE_EXCEPTION);
- return caption;
+ return existingCaption;
+ RefPtr<HTMLTableCaptionElement> caption = HTMLTableCaptionElement::create(captionTag, document());
+ setCaption(caption, IGNORE_EXCEPTION);
+ return caption.release();
}
void HTMLTableElement::deleteCaption()
{
- if (auto* caption = this->caption())
- removeChild(*caption, IGNORE_EXCEPTION);
+ removeChild(caption(), IGNORE_EXCEPTION);
}
HTMLTableSectionElement* HTMLTableElement::lastBody() const
{
for (Node* child = lastChild(); child; child = child->previousSibling()) {
if (child->hasTagName(tbodyTag))
- return downcast<HTMLTableSectionElement>(child);
+ return toHTMLTableSectionElement(child);
}
- return nullptr;
+ return 0;
}
-RefPtr<HTMLElement> HTMLTableElement::insertRow(int index, ExceptionCode& ec)
+PassRefPtr<HTMLElement> HTMLTableElement::insertRow(int index, ExceptionCode& ec)
{
if (index < -1) {
ec = INDEX_SIZE_ERR;
@@ -216,10 +195,10 @@ RefPtr<HTMLElement> HTMLTableElement::insertRow(int index, ExceptionCode& ec)
RefPtr<HTMLTableRowElement> lastRow = 0;
RefPtr<HTMLTableRowElement> row = 0;
if (index == -1)
- lastRow = HTMLTableRowsCollection::lastRow(*this);
+ lastRow = HTMLTableRowsCollection::lastRow(this);
else {
for (int i = 0; i <= index; ++i) {
- row = HTMLTableRowsCollection::rowAfter(*this, lastRow.get());
+ row = HTMLTableRowsCollection::rowAfter(this, lastRow.get());
if (!row) {
if (i != index) {
ec = INDEX_SIZE_ERR;
@@ -237,27 +216,27 @@ RefPtr<HTMLElement> HTMLTableElement::insertRow(int index, ExceptionCode& ec)
else {
parent = lastBody();
if (!parent) {
- Ref<HTMLTableSectionElement> newBody = HTMLTableSectionElement::create(tbodyTag, document());
- Ref<HTMLTableRowElement> newRow = HTMLTableRowElement::create(document());
- newBody->appendChild(newRow.copyRef(), ec);
- appendChild(WTFMove(newBody), ec);
- return WTFMove(newRow);
+ RefPtr<HTMLTableSectionElement> newBody = HTMLTableSectionElement::create(tbodyTag, document());
+ RefPtr<HTMLTableRowElement> newRow = HTMLTableRowElement::create(document());
+ newBody->appendChild(newRow, ec);
+ appendChild(newBody.release(), ec);
+ return newRow.release();
}
}
- Ref<HTMLTableRowElement> newRow = HTMLTableRowElement::create(document());
- parent->insertBefore(newRow.copyRef(), row.get(), ec);
- return WTFMove(newRow);
+ RefPtr<HTMLTableRowElement> newRow = HTMLTableRowElement::create(document());
+ parent->insertBefore(newRow, row.get(), ec);
+ return newRow.release();
}
void HTMLTableElement::deleteRow(int index, ExceptionCode& ec)
{
- HTMLTableRowElement* row = nullptr;
+ HTMLTableRowElement* row = 0;
if (index == -1)
- row = HTMLTableRowsCollection::lastRow(*this);
+ row = HTMLTableRowsCollection::lastRow(this);
else {
for (int i = 0; i <= index; ++i) {
- row = HTMLTableRowsCollection::rowAfter(*this, row);
+ row = HTMLTableRowsCollection::rowAfter(this, row);
if (!row)
break;
}
@@ -301,21 +280,21 @@ static bool getBordersFromFrameAttributeValue(const AtomicString& value, bool& b
borderBottom = false;
borderLeft = false;
- if (equalLettersIgnoringASCIICase(value, "above"))
+ if (equalIgnoringCase(value, "above"))
borderTop = true;
- else if (equalLettersIgnoringASCIICase(value, "below"))
+ else if (equalIgnoringCase(value, "below"))
borderBottom = true;
- else if (equalLettersIgnoringASCIICase(value, "hsides"))
+ else if (equalIgnoringCase(value, "hsides"))
borderTop = borderBottom = true;
- else if (equalLettersIgnoringASCIICase(value, "vsides"))
+ else if (equalIgnoringCase(value, "vsides"))
borderLeft = borderRight = true;
- else if (equalLettersIgnoringASCIICase(value, "lhs"))
+ else if (equalIgnoringCase(value, "lhs"))
borderLeft = true;
- else if (equalLettersIgnoringASCIICase(value, "rhs"))
+ else if (equalIgnoringCase(value, "rhs"))
borderRight = true;
- else if (equalLettersIgnoringASCIICase(value, "box") || equalLettersIgnoringASCIICase(value, "border"))
+ else if (equalIgnoringCase(value, "box") || equalIgnoringCase(value, "border"))
borderTop = borderBottom = borderLeft = borderRight = true;
- else if (!equalLettersIgnoringASCIICase(value, "void"))
+ else if (!equalIgnoringCase(value, "void"))
return false;
return true;
}
@@ -351,7 +330,7 @@ void HTMLTableElement::collectStyleForPresentationAttribute(const QualifiedName&
addHTMLLengthToStyle(style, CSSPropertyMarginRight, value);
} else if (name == alignAttr) {
if (!value.isEmpty()) {
- if (equalLettersIgnoringASCIICase(value, "center")) {
+ if (equalIgnoringCase(value, "center")) {
addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitMarginStart, CSSValueAuto);
addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitMarginEnd, CSSValueAuto);
} else
@@ -403,15 +382,15 @@ void HTMLTableElement::parseAttribute(const QualifiedName& name, const AtomicStr
m_frameAttr = getBordersFromFrameAttributeValue(value, borderTop, borderRight, borderBottom, borderLeft);
} else if (name == rulesAttr) {
m_rulesAttr = UnsetRules;
- if (equalLettersIgnoringASCIICase(value, "none"))
+ if (equalIgnoringCase(value, "none"))
m_rulesAttr = NoneRules;
- else if (equalLettersIgnoringASCIICase(value, "groups"))
+ else if (equalIgnoringCase(value, "groups"))
m_rulesAttr = GroupsRules;
- else if (equalLettersIgnoringASCIICase(value, "rows"))
+ else if (equalIgnoringCase(value, "rows"))
m_rulesAttr = RowsRules;
- else if (equalLettersIgnoringASCIICase(value, "cols"))
+ else if (equalIgnoringCase(value, "cols"))
m_rulesAttr = ColsRules;
- else if (equalLettersIgnoringASCIICase(value, "all"))
+ else if (equalIgnoringCase(value, "all"))
m_rulesAttr = AllRules;
} else if (name == cellpaddingAttr) {
if (!value.isEmpty())
@@ -424,7 +403,7 @@ void HTMLTableElement::parseAttribute(const QualifiedName& name, const AtomicStr
HTMLElement::parseAttribute(name, value);
if (bordersBefore != cellBorders() || oldPadding != m_padding) {
- m_sharedCellStyle = nullptr;
+ m_sharedCellStyle = 0;
bool cellChanged = false;
for (Node* child = firstChild(); child; child = child->nextSibling())
cellChanged |= setTableCellsChanged(child);
@@ -489,35 +468,34 @@ HTMLTableElement::CellBorders HTMLTableElement::cellBorders() const
return NoBorders;
}
-RefPtr<StyleProperties> HTMLTableElement::createSharedCellStyle()
+PassRefPtr<StyleProperties> HTMLTableElement::createSharedCellStyle()
{
RefPtr<MutableStyleProperties> style = MutableStyleProperties::create();
- auto& cssValuePool = CSSValuePool::singleton();
switch (cellBorders()) {
case SolidBordersColsOnly:
style->setProperty(CSSPropertyBorderLeftWidth, CSSValueThin);
style->setProperty(CSSPropertyBorderRightWidth, CSSValueThin);
style->setProperty(CSSPropertyBorderLeftStyle, CSSValueSolid);
style->setProperty(CSSPropertyBorderRightStyle, CSSValueSolid);
- style->setProperty(CSSPropertyBorderColor, cssValuePool.createInheritedValue());
+ style->setProperty(CSSPropertyBorderColor, cssValuePool().createInheritedValue());
break;
case SolidBordersRowsOnly:
style->setProperty(CSSPropertyBorderTopWidth, CSSValueThin);
style->setProperty(CSSPropertyBorderBottomWidth, CSSValueThin);
style->setProperty(CSSPropertyBorderTopStyle, CSSValueSolid);
style->setProperty(CSSPropertyBorderBottomStyle, CSSValueSolid);
- style->setProperty(CSSPropertyBorderColor, cssValuePool.createInheritedValue());
+ style->setProperty(CSSPropertyBorderColor, cssValuePool().createInheritedValue());
break;
case SolidBorders:
- style->setProperty(CSSPropertyBorderWidth, cssValuePool.createValue(1, CSSPrimitiveValue::CSS_PX));
- style->setProperty(CSSPropertyBorderStyle, cssValuePool.createIdentifierValue(CSSValueSolid));
- style->setProperty(CSSPropertyBorderColor, cssValuePool.createInheritedValue());
+ style->setProperty(CSSPropertyBorderWidth, cssValuePool().createValue(1, CSSPrimitiveValue::CSS_PX));
+ style->setProperty(CSSPropertyBorderStyle, cssValuePool().createIdentifierValue(CSSValueSolid));
+ style->setProperty(CSSPropertyBorderColor, cssValuePool().createInheritedValue());
break;
case InsetBorders:
- style->setProperty(CSSPropertyBorderWidth, cssValuePool.createValue(1, CSSPrimitiveValue::CSS_PX));
- style->setProperty(CSSPropertyBorderStyle, cssValuePool.createIdentifierValue(CSSValueInset));
- style->setProperty(CSSPropertyBorderColor, cssValuePool.createInheritedValue());
+ style->setProperty(CSSPropertyBorderWidth, cssValuePool().createValue(1, CSSPrimitiveValue::CSS_PX));
+ style->setProperty(CSSPropertyBorderStyle, cssValuePool().createIdentifierValue(CSSValueInset));
+ style->setProperty(CSSPropertyBorderColor, cssValuePool().createInheritedValue());
break;
case NoBorders:
// If 'rules=none' then allow any borders set at cell level to take effect.
@@ -525,9 +503,9 @@ RefPtr<StyleProperties> HTMLTableElement::createSharedCellStyle()
}
if (m_padding)
- style->setProperty(CSSPropertyPadding, cssValuePool.createValue(m_padding, CSSPrimitiveValue::CSS_PX));
+ style->setProperty(CSSPropertyPadding, cssValuePool().createValue(m_padding, CSSPrimitiveValue::CSS_PX));
- return style;
+ return style.release();
}
const StyleProperties* HTMLTableElement::additionalCellStyle()
@@ -572,31 +550,31 @@ bool HTMLTableElement::isURLAttribute(const Attribute& attribute) const
return attribute.name() == backgroundAttr || HTMLElement::isURLAttribute(attribute);
}
-Ref<HTMLCollection> HTMLTableElement::rows()
+PassRefPtr<HTMLCollection> HTMLTableElement::rows()
{
- return ensureRareData().ensureNodeLists().addCachedCollection<HTMLTableRowsCollection>(*this, TableRows);
+ return ensureCachedHTMLCollection(TableRows);
}
-Ref<HTMLCollection> HTMLTableElement::tBodies()
+PassRefPtr<HTMLCollection> HTMLTableElement::tBodies()
{
- return ensureRareData().ensureNodeLists().addCachedCollection<GenericCachedHTMLCollection<CollectionTypeTraits<TableTBodies>::traversalType>>(*this, TableTBodies);
+ return ensureCachedHTMLCollection(TableTBodies);
}
-const AtomicString& HTMLTableElement::rules() const
+String HTMLTableElement::rules() const
{
- return fastGetAttribute(rulesAttr);
+ return getAttribute(rulesAttr);
}
-const AtomicString& HTMLTableElement::summary() const
+String HTMLTableElement::summary() const
{
- return fastGetAttribute(summaryAttr);
+ return getAttribute(summaryAttr);
}
void HTMLTableElement::addSubresourceAttributeURLs(ListHashSet<URL>& urls) const
{
HTMLElement::addSubresourceAttributeURLs(urls);
- addSubresourceURL(urls, document().completeURL(fastGetAttribute(backgroundAttr)));
+ addSubresourceURL(urls, document().completeURL(getAttribute(backgroundAttr)));
}
}