darin@apple.com | eb70180 | 2008-01-03 01:25:51 +0000 | [diff] [blame] | 1 | /* |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 2 | * Copyright (C) 1997 Martin Jones (mjones@kde.org) |
| 3 | * (C) 1997 Torben Weis (weis@kde.org) |
| 4 | * (C) 1998 Waldo Bastian (bastian@kde.org) |
| 5 | * (C) 1999 Lars Knoll (knoll@kde.org) |
| 6 | * (C) 1999 Antti Koivisto (koivisto@kde.org) |
kling@webkit.org | e72793e | 2011-12-24 21:24:59 +0000 | [diff] [blame] | 7 | * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2010, 2011 Apple Inc. All rights reserved. |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 8 | * |
| 9 | * This library is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU Library General Public |
| 11 | * License as published by the Free Software Foundation; either |
| 12 | * version 2 of the License, or (at your option) any later version. |
| 13 | * |
| 14 | * This library is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 | * Library General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU Library General Public License |
| 20 | * along with this library; see the file COPYING.LIB. If not, write to |
ddkilzer | c8eccec | 2007-09-26 02:29:57 +0000 | [diff] [blame] | 21 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 22 | * Boston, MA 02110-1301, USA. |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 23 | */ |
darin@apple.com | eb70180 | 2008-01-03 01:25:51 +0000 | [diff] [blame] | 24 | |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 25 | #include "config.h" |
| 26 | #include "HTMLTableElement.h" |
| 27 | |
weinig@apple.com | c360893 | 2010-05-19 17:48:06 +0000 | [diff] [blame] | 28 | #include "Attribute.h" |
kling@webkit.org | 8b0e843 | 2012-02-11 19:29:49 +0000 | [diff] [blame] | 29 | #include "CSSImageValue.h" |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 30 | #include "CSSPropertyNames.h" |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 31 | #include "CSSValueKeywords.h" |
kling@webkit.org | 2340d5e | 2012-02-25 17:43:32 +0000 | [diff] [blame] | 32 | #include "CSSValuePool.h" |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 33 | #include "ExceptionCode.h" |
mkwst@chromium.org | 33cdf43 | 2013-02-08 14:21:48 +0000 | [diff] [blame] | 34 | #include "ExceptionCodePlaceholder.h" |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 35 | #include "HTMLNames.h" |
darin@apple.com | 7b7981b | 2010-10-01 00:04:02 +0000 | [diff] [blame] | 36 | #include "HTMLParserIdioms.h" |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 37 | #include "HTMLTableCaptionElement.h" |
darin@apple.com | eb70180 | 2008-01-03 01:25:51 +0000 | [diff] [blame] | 38 | #include "HTMLTableRowElement.h" |
darin@apple.com | 9a925fa | 2009-05-04 18:00:34 +0000 | [diff] [blame] | 39 | #include "HTMLTableRowsCollection.h" |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 40 | #include "HTMLTableSectionElement.h" |
| 41 | #include "RenderTable.h" |
akling@apple.com | 179f7df | 2013-02-25 15:49:25 +0000 | [diff] [blame] | 42 | #include "StylePropertySet.h" |
akling@apple.com | f851598 | 2013-09-02 18:50:01 +0000 | [diff] [blame] | 43 | #include <wtf/Ref.h> |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 44 | |
| 45 | namespace WebCore { |
| 46 | |
| 47 | using namespace HTMLNames; |
| 48 | |
weinig@apple.com | 4917883 | 2013-09-15 00:39:29 +0000 | [diff] [blame] | 49 | HTMLTableElement::HTMLTableElement(const QualifiedName& tagName, Document& document) |
weinig@apple.com | dedf67e | 2013-09-15 05:23:01 +0000 | [diff] [blame] | 50 | : HTMLElement(tagName, document) |
hyatt | eef21e0 | 2006-09-17 07:57:56 +0000 | [diff] [blame] | 51 | , m_borderAttr(false) |
| 52 | , m_borderColorAttr(false) |
| 53 | , m_frameAttr(false) |
| 54 | , m_rulesAttr(UnsetRules) |
| 55 | , m_padding(1) |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 56 | { |
jchaffraix@webkit.org | 94d95b0 | 2008-12-04 22:39:05 +0000 | [diff] [blame] | 57 | ASSERT(hasTagName(tableTag)); |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 58 | } |
| 59 | |
weinig@apple.com | 4917883 | 2013-09-15 00:39:29 +0000 | [diff] [blame] | 60 | PassRefPtr<HTMLTableElement> HTMLTableElement::create(Document& document) |
darin@apple.com | 877ce5b | 2010-05-28 15:38:58 +0000 | [diff] [blame] | 61 | { |
darin@apple.com | f190b3d | 2010-06-16 23:07:32 +0000 | [diff] [blame] | 62 | return adoptRef(new HTMLTableElement(tableTag, document)); |
darin@apple.com | 877ce5b | 2010-05-28 15:38:58 +0000 | [diff] [blame] | 63 | } |
| 64 | |
weinig@apple.com | 4917883 | 2013-09-15 00:39:29 +0000 | [diff] [blame] | 65 | PassRefPtr<HTMLTableElement> HTMLTableElement::create(const QualifiedName& tagName, Document& document) |
darin@apple.com | 877ce5b | 2010-05-28 15:38:58 +0000 | [diff] [blame] | 66 | { |
darin@apple.com | f190b3d | 2010-06-16 23:07:32 +0000 | [diff] [blame] | 67 | return adoptRef(new HTMLTableElement(tagName, document)); |
darin@apple.com | 877ce5b | 2010-05-28 15:38:58 +0000 | [diff] [blame] | 68 | } |
| 69 | |
darin@apple.com | eb70180 | 2008-01-03 01:25:51 +0000 | [diff] [blame] | 70 | HTMLTableCaptionElement* HTMLTableElement::caption() const |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 71 | { |
darin@apple.com | eb70180 | 2008-01-03 01:25:51 +0000 | [diff] [blame] | 72 | for (Node* child = firstChild(); child; child = child->nextSibling()) { |
| 73 | if (child->hasTagName(captionTag)) |
gyuyoung.kim@samsung.com | b86fc58 | 2013-11-21 04:45:49 +0000 | [diff] [blame^] | 74 | return toHTMLTableCaptionElement(child); |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 75 | } |
darin@apple.com | eb70180 | 2008-01-03 01:25:51 +0000 | [diff] [blame] | 76 | return 0; |
| 77 | } |
| 78 | |
| 79 | void HTMLTableElement::setCaption(PassRefPtr<HTMLTableCaptionElement> newCaption, ExceptionCode& ec) |
| 80 | { |
| 81 | deleteCaption(); |
| 82 | insertBefore(newCaption, firstChild(), ec); |
| 83 | } |
| 84 | |
| 85 | HTMLTableSectionElement* HTMLTableElement::tHead() const |
| 86 | { |
| 87 | for (Node* child = firstChild(); child; child = child->nextSibling()) { |
| 88 | if (child->hasTagName(theadTag)) |
commit-queue@webkit.org | a8be419 | 2013-11-20 18:26:34 +0000 | [diff] [blame] | 89 | return static_cast<HTMLTableSectionElement*>(child); |
darin@apple.com | eb70180 | 2008-01-03 01:25:51 +0000 | [diff] [blame] | 90 | } |
| 91 | return 0; |
| 92 | } |
| 93 | |
| 94 | void HTMLTableElement::setTHead(PassRefPtr<HTMLTableSectionElement> newHead, ExceptionCode& ec) |
| 95 | { |
| 96 | deleteTHead(); |
| 97 | |
| 98 | Node* child; |
| 99 | for (child = firstChild(); child; child = child->nextSibling()) |
| 100 | if (child->isElementNode() && !child->hasTagName(captionTag) && !child->hasTagName(colgroupTag)) |
| 101 | break; |
| 102 | |
| 103 | insertBefore(newHead, child, ec); |
| 104 | } |
| 105 | |
| 106 | HTMLTableSectionElement* HTMLTableElement::tFoot() const |
| 107 | { |
| 108 | for (Node* child = firstChild(); child; child = child->nextSibling()) { |
| 109 | if (child->hasTagName(tfootTag)) |
commit-queue@webkit.org | a8be419 | 2013-11-20 18:26:34 +0000 | [diff] [blame] | 110 | return static_cast<HTMLTableSectionElement*>(child); |
darin@apple.com | eb70180 | 2008-01-03 01:25:51 +0000 | [diff] [blame] | 111 | } |
| 112 | return 0; |
| 113 | } |
| 114 | |
| 115 | void HTMLTableElement::setTFoot(PassRefPtr<HTMLTableSectionElement> newFoot, ExceptionCode& ec) |
| 116 | { |
| 117 | deleteTFoot(); |
| 118 | |
| 119 | Node* child; |
| 120 | for (child = firstChild(); child; child = child->nextSibling()) |
| 121 | if (child->isElementNode() && !child->hasTagName(captionTag) && !child->hasTagName(colgroupTag) && !child->hasTagName(theadTag)) |
| 122 | break; |
| 123 | |
| 124 | insertBefore(newFoot, child, ec); |
| 125 | } |
| 126 | |
| 127 | PassRefPtr<HTMLElement> HTMLTableElement::createTHead() |
| 128 | { |
| 129 | if (HTMLTableSectionElement* existingHead = tHead()) |
| 130 | return existingHead; |
weinig@apple.com | 4917883 | 2013-09-15 00:39:29 +0000 | [diff] [blame] | 131 | RefPtr<HTMLTableSectionElement> head = HTMLTableSectionElement::create(theadTag, document()); |
mkwst@chromium.org | 33cdf43 | 2013-02-08 14:21:48 +0000 | [diff] [blame] | 132 | setTHead(head, IGNORE_EXCEPTION); |
darin@apple.com | eb70180 | 2008-01-03 01:25:51 +0000 | [diff] [blame] | 133 | return head.release(); |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | void HTMLTableElement::deleteTHead() |
| 137 | { |
mkwst@chromium.org | 33cdf43 | 2013-02-08 14:21:48 +0000 | [diff] [blame] | 138 | removeChild(tHead(), IGNORE_EXCEPTION); |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 139 | } |
| 140 | |
darin@apple.com | eb70180 | 2008-01-03 01:25:51 +0000 | [diff] [blame] | 141 | PassRefPtr<HTMLElement> HTMLTableElement::createTFoot() |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 142 | { |
darin@apple.com | eb70180 | 2008-01-03 01:25:51 +0000 | [diff] [blame] | 143 | if (HTMLTableSectionElement* existingFoot = tFoot()) |
| 144 | return existingFoot; |
weinig@apple.com | 4917883 | 2013-09-15 00:39:29 +0000 | [diff] [blame] | 145 | RefPtr<HTMLTableSectionElement> foot = HTMLTableSectionElement::create(tfootTag, document()); |
mkwst@chromium.org | 33cdf43 | 2013-02-08 14:21:48 +0000 | [diff] [blame] | 146 | setTFoot(foot, IGNORE_EXCEPTION); |
darin@apple.com | eb70180 | 2008-01-03 01:25:51 +0000 | [diff] [blame] | 147 | return foot.release(); |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | void HTMLTableElement::deleteTFoot() |
| 151 | { |
mkwst@chromium.org | 33cdf43 | 2013-02-08 14:21:48 +0000 | [diff] [blame] | 152 | removeChild(tFoot(), IGNORE_EXCEPTION); |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 153 | } |
| 154 | |
alexis.menard@openbossa.org | 83fc9ae | 2012-04-25 02:11:26 +0000 | [diff] [blame] | 155 | PassRefPtr<HTMLElement> HTMLTableElement::createTBody() |
| 156 | { |
weinig@apple.com | 4917883 | 2013-09-15 00:39:29 +0000 | [diff] [blame] | 157 | RefPtr<HTMLTableSectionElement> body = HTMLTableSectionElement::create(tbodyTag, document()); |
alexis.menard@openbossa.org | 83fc9ae | 2012-04-25 02:11:26 +0000 | [diff] [blame] | 158 | Node* referenceElement = lastBody() ? lastBody()->nextSibling() : 0; |
| 159 | insertBefore(body, referenceElement, ASSERT_NO_EXCEPTION); |
| 160 | return body.release(); |
| 161 | } |
| 162 | |
darin@apple.com | eb70180 | 2008-01-03 01:25:51 +0000 | [diff] [blame] | 163 | PassRefPtr<HTMLElement> HTMLTableElement::createCaption() |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 164 | { |
darin@apple.com | eb70180 | 2008-01-03 01:25:51 +0000 | [diff] [blame] | 165 | if (HTMLTableCaptionElement* existingCaption = caption()) |
| 166 | return existingCaption; |
weinig@apple.com | 6becaaf | 2013-09-14 21:33:13 +0000 | [diff] [blame] | 167 | RefPtr<HTMLTableCaptionElement> caption = HTMLTableCaptionElement::create(captionTag, document()); |
mkwst@chromium.org | 33cdf43 | 2013-02-08 14:21:48 +0000 | [diff] [blame] | 168 | setCaption(caption, IGNORE_EXCEPTION); |
darin@apple.com | eb70180 | 2008-01-03 01:25:51 +0000 | [diff] [blame] | 169 | return caption.release(); |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | void HTMLTableElement::deleteCaption() |
| 173 | { |
mkwst@chromium.org | 33cdf43 | 2013-02-08 14:21:48 +0000 | [diff] [blame] | 174 | removeChild(caption(), IGNORE_EXCEPTION); |
darin@apple.com | eb70180 | 2008-01-03 01:25:51 +0000 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | HTMLTableSectionElement* HTMLTableElement::lastBody() const |
| 178 | { |
| 179 | for (Node* child = lastChild(); child; child = child->previousSibling()) { |
| 180 | if (child->hasTagName(tbodyTag)) |
commit-queue@webkit.org | a8be419 | 2013-11-20 18:26:34 +0000 | [diff] [blame] | 181 | return static_cast<HTMLTableSectionElement*>(child); |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 182 | } |
darin@apple.com | eb70180 | 2008-01-03 01:25:51 +0000 | [diff] [blame] | 183 | return 0; |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 184 | } |
| 185 | |
darin | f0d1934 | 2007-05-01 19:59:53 +0000 | [diff] [blame] | 186 | PassRefPtr<HTMLElement> HTMLTableElement::insertRow(int index, ExceptionCode& ec) |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 187 | { |
darin@apple.com | eb70180 | 2008-01-03 01:25:51 +0000 | [diff] [blame] | 188 | if (index < -1) { |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 189 | ec = INDEX_SIZE_ERR; |
darin | f0d1934 | 2007-05-01 19:59:53 +0000 | [diff] [blame] | 190 | return 0; |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 191 | } |
darin@apple.com | eb70180 | 2008-01-03 01:25:51 +0000 | [diff] [blame] | 192 | |
akling@apple.com | f851598 | 2013-09-02 18:50:01 +0000 | [diff] [blame] | 193 | Ref<HTMLTableElement> protectFromMutationEvents(*this); |
inferno@chromium.org | 50a2ce7 | 2012-03-01 18:19:03 +0000 | [diff] [blame] | 194 | |
| 195 | RefPtr<HTMLTableRowElement> lastRow = 0; |
| 196 | RefPtr<HTMLTableRowElement> row = 0; |
darin@apple.com | eb70180 | 2008-01-03 01:25:51 +0000 | [diff] [blame] | 197 | if (index == -1) |
| 198 | lastRow = HTMLTableRowsCollection::lastRow(this); |
| 199 | else { |
| 200 | for (int i = 0; i <= index; ++i) { |
inferno@chromium.org | 50a2ce7 | 2012-03-01 18:19:03 +0000 | [diff] [blame] | 201 | row = HTMLTableRowsCollection::rowAfter(this, lastRow.get()); |
darin@apple.com | eb70180 | 2008-01-03 01:25:51 +0000 | [diff] [blame] | 202 | if (!row) { |
| 203 | if (i != index) { |
| 204 | ec = INDEX_SIZE_ERR; |
| 205 | return 0; |
| 206 | } |
| 207 | break; |
| 208 | } |
| 209 | lastRow = row; |
| 210 | } |
| 211 | } |
| 212 | |
inferno@chromium.org | 50a2ce7 | 2012-03-01 18:19:03 +0000 | [diff] [blame] | 213 | RefPtr<ContainerNode> parent; |
darin@apple.com | eb70180 | 2008-01-03 01:25:51 +0000 | [diff] [blame] | 214 | if (lastRow) |
dglazkov@chromium.org | e43caa7 | 2010-11-18 00:20:10 +0000 | [diff] [blame] | 215 | parent = row ? row->parentNode() : lastRow->parentNode(); |
darin@apple.com | eb70180 | 2008-01-03 01:25:51 +0000 | [diff] [blame] | 216 | else { |
| 217 | parent = lastBody(); |
| 218 | if (!parent) { |
weinig@apple.com | 4917883 | 2013-09-15 00:39:29 +0000 | [diff] [blame] | 219 | RefPtr<HTMLTableSectionElement> newBody = HTMLTableSectionElement::create(tbodyTag, document()); |
| 220 | RefPtr<HTMLTableRowElement> newRow = HTMLTableRowElement::create(document()); |
darin@apple.com | eb70180 | 2008-01-03 01:25:51 +0000 | [diff] [blame] | 221 | newBody->appendChild(newRow, ec); |
| 222 | appendChild(newBody.release(), ec); |
| 223 | return newRow.release(); |
| 224 | } |
| 225 | } |
| 226 | |
weinig@apple.com | 4917883 | 2013-09-15 00:39:29 +0000 | [diff] [blame] | 227 | RefPtr<HTMLTableRowElement> newRow = HTMLTableRowElement::create(document()); |
inferno@chromium.org | 50a2ce7 | 2012-03-01 18:19:03 +0000 | [diff] [blame] | 228 | parent->insertBefore(newRow, row.get(), ec); |
darin@apple.com | eb70180 | 2008-01-03 01:25:51 +0000 | [diff] [blame] | 229 | return newRow.release(); |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 230 | } |
| 231 | |
| 232 | void HTMLTableElement::deleteRow(int index, ExceptionCode& ec) |
| 233 | { |
darin@apple.com | eb70180 | 2008-01-03 01:25:51 +0000 | [diff] [blame] | 234 | HTMLTableRowElement* row = 0; |
| 235 | if (index == -1) |
| 236 | row = HTMLTableRowsCollection::lastRow(this); |
| 237 | else { |
| 238 | for (int i = 0; i <= index; ++i) { |
| 239 | row = HTMLTableRowsCollection::rowAfter(this, row); |
| 240 | if (!row) |
| 241 | break; |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 242 | } |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 243 | } |
darin@apple.com | eb70180 | 2008-01-03 01:25:51 +0000 | [diff] [blame] | 244 | if (!row) { |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 245 | ec = INDEX_SIZE_ERR; |
darin@apple.com | eb70180 | 2008-01-03 01:25:51 +0000 | [diff] [blame] | 246 | return; |
| 247 | } |
| 248 | row->remove(ec); |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 249 | } |
| 250 | |
rwlbuis | da67f4e | 2007-08-25 16:57:13 +0000 | [diff] [blame] | 251 | static inline bool isTableCellAncestor(Node* n) |
| 252 | { |
| 253 | return n->hasTagName(theadTag) || n->hasTagName(tbodyTag) || |
| 254 | n->hasTagName(tfootTag) || n->hasTagName(trTag) || |
| 255 | n->hasTagName(thTag); |
| 256 | } |
| 257 | |
| 258 | static bool setTableCellsChanged(Node* n) |
| 259 | { |
| 260 | ASSERT(n); |
| 261 | bool cellChanged = false; |
| 262 | |
| 263 | if (n->hasTagName(tdTag)) |
| 264 | cellChanged = true; |
| 265 | else if (isTableCellAncestor(n)) { |
| 266 | for (Node* child = n->firstChild(); child; child = child->nextSibling()) |
| 267 | cellChanged |= setTableCellsChanged(child); |
| 268 | } |
| 269 | |
| 270 | if (cellChanged) |
hyatt@apple.com | f6d72f3 | 2009-04-10 00:05:02 +0000 | [diff] [blame] | 271 | n->setNeedsStyleRecalc(); |
rwlbuis | da67f4e | 2007-08-25 16:57:13 +0000 | [diff] [blame] | 272 | |
| 273 | return cellChanged; |
| 274 | } |
| 275 | |
kling@webkit.org | 8b0e843 | 2012-02-11 19:29:49 +0000 | [diff] [blame] | 276 | static bool getBordersFromFrameAttributeValue(const AtomicString& value, bool& borderTop, bool& borderRight, bool& borderBottom, bool& borderLeft) |
| 277 | { |
| 278 | borderTop = false; |
| 279 | borderRight = false; |
| 280 | borderBottom = false; |
| 281 | borderLeft = false; |
| 282 | |
| 283 | if (equalIgnoringCase(value, "above")) |
| 284 | borderTop = true; |
| 285 | else if (equalIgnoringCase(value, "below")) |
| 286 | borderBottom = true; |
| 287 | else if (equalIgnoringCase(value, "hsides")) |
| 288 | borderTop = borderBottom = true; |
| 289 | else if (equalIgnoringCase(value, "vsides")) |
| 290 | borderLeft = borderRight = true; |
| 291 | else if (equalIgnoringCase(value, "lhs")) |
| 292 | borderLeft = true; |
| 293 | else if (equalIgnoringCase(value, "rhs")) |
| 294 | borderRight = true; |
| 295 | else if (equalIgnoringCase(value, "box") || equalIgnoringCase(value, "border")) |
| 296 | borderTop = borderBottom = borderLeft = borderRight = true; |
| 297 | else if (!equalIgnoringCase(value, "void")) |
| 298 | return false; |
| 299 | return true; |
| 300 | } |
| 301 | |
weinig@apple.com | ac1cc35 | 2013-11-09 03:24:55 +0000 | [diff] [blame] | 302 | void HTMLTableElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomicString& value, MutableStylePropertySet& style) |
kling@webkit.org | 8b0e843 | 2012-02-11 19:29:49 +0000 | [diff] [blame] | 303 | { |
akling@apple.com | b75eeea | 2013-02-23 17:57:50 +0000 | [diff] [blame] | 304 | if (name == widthAttr) |
| 305 | addHTMLLengthToStyle(style, CSSPropertyWidth, value); |
| 306 | else if (name == heightAttr) |
| 307 | addHTMLLengthToStyle(style, CSSPropertyHeight, value); |
| 308 | else if (name == borderAttr) |
| 309 | addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderWidth, parseBorderWidthAttribute(value), CSSPrimitiveValue::CSS_PX); |
| 310 | else if (name == bordercolorAttr) { |
| 311 | if (!value.isEmpty()) |
| 312 | addHTMLColorToStyle(style, CSSPropertyBorderColor, value); |
| 313 | } else if (name == bgcolorAttr) |
| 314 | addHTMLColorToStyle(style, CSSPropertyBackgroundColor, value); |
| 315 | else if (name == backgroundAttr) { |
| 316 | String url = stripLeadingAndTrailingHTMLSpaces(value); |
kling@webkit.org | 8b0e843 | 2012-02-11 19:29:49 +0000 | [diff] [blame] | 317 | if (!url.isEmpty()) |
weinig@apple.com | ac1cc35 | 2013-11-09 03:24:55 +0000 | [diff] [blame] | 318 | style.setProperty(CSSProperty(CSSPropertyBackgroundImage, CSSImageValue::create(document().completeURL(url).string()))); |
akling@apple.com | b75eeea | 2013-02-23 17:57:50 +0000 | [diff] [blame] | 319 | } else if (name == valignAttr) { |
| 320 | if (!value.isEmpty()) |
| 321 | addPropertyToPresentationAttributeStyle(style, CSSPropertyVerticalAlign, value); |
| 322 | } else if (name == cellspacingAttr) { |
| 323 | if (!value.isEmpty()) |
| 324 | addHTMLLengthToStyle(style, CSSPropertyBorderSpacing, value); |
| 325 | } else if (name == vspaceAttr) { |
| 326 | addHTMLLengthToStyle(style, CSSPropertyMarginTop, value); |
| 327 | addHTMLLengthToStyle(style, CSSPropertyMarginBottom, value); |
| 328 | } else if (name == hspaceAttr) { |
| 329 | addHTMLLengthToStyle(style, CSSPropertyMarginLeft, value); |
| 330 | addHTMLLengthToStyle(style, CSSPropertyMarginRight, value); |
| 331 | } else if (name == alignAttr) { |
| 332 | if (!value.isEmpty()) { |
| 333 | if (equalIgnoringCase(value, "center")) { |
kling@webkit.org | 569556d | 2012-11-12 23:52:12 +0000 | [diff] [blame] | 334 | addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitMarginStart, CSSValueAuto); |
| 335 | addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitMarginEnd, CSSValueAuto); |
kling@webkit.org | 8b0e843 | 2012-02-11 19:29:49 +0000 | [diff] [blame] | 336 | } else |
akling@apple.com | b75eeea | 2013-02-23 17:57:50 +0000 | [diff] [blame] | 337 | addPropertyToPresentationAttributeStyle(style, CSSPropertyFloat, value); |
kling@webkit.org | 8b0e843 | 2012-02-11 19:29:49 +0000 | [diff] [blame] | 338 | } |
akling@apple.com | b75eeea | 2013-02-23 17:57:50 +0000 | [diff] [blame] | 339 | } else if (name == rulesAttr) { |
kling@webkit.org | 8b0e843 | 2012-02-11 19:29:49 +0000 | [diff] [blame] | 340 | // The presence of a valid rules attribute causes border collapsing to be enabled. |
| 341 | if (m_rulesAttr != UnsetRules) |
kling@webkit.org | 569556d | 2012-11-12 23:52:12 +0000 | [diff] [blame] | 342 | addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderCollapse, CSSValueCollapse); |
akling@apple.com | b75eeea | 2013-02-23 17:57:50 +0000 | [diff] [blame] | 343 | } else if (name == frameAttr) { |
kling@webkit.org | 8b0e843 | 2012-02-11 19:29:49 +0000 | [diff] [blame] | 344 | bool borderTop; |
| 345 | bool borderRight; |
| 346 | bool borderBottom; |
| 347 | bool borderLeft; |
akling@apple.com | b75eeea | 2013-02-23 17:57:50 +0000 | [diff] [blame] | 348 | if (getBordersFromFrameAttributeValue(value, borderTop, borderRight, borderBottom, borderLeft)) { |
kling@webkit.org | 569556d | 2012-11-12 23:52:12 +0000 | [diff] [blame] | 349 | addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderWidth, CSSValueThin); |
| 350 | addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderTopStyle, borderTop ? CSSValueSolid : CSSValueHidden); |
| 351 | addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderBottomStyle, borderBottom ? CSSValueSolid : CSSValueHidden); |
| 352 | addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderLeftStyle, borderLeft ? CSSValueSolid : CSSValueHidden); |
| 353 | addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderRightStyle, borderRight ? CSSValueSolid : CSSValueHidden); |
kling@webkit.org | 8b0e843 | 2012-02-11 19:29:49 +0000 | [diff] [blame] | 354 | } |
| 355 | } else |
akling@apple.com | b75eeea | 2013-02-23 17:57:50 +0000 | [diff] [blame] | 356 | HTMLElement::collectStyleForPresentationAttribute(name, value, style); |
kling@webkit.org | 8b0e843 | 2012-02-11 19:29:49 +0000 | [diff] [blame] | 357 | } |
| 358 | |
kling@webkit.org | 44bc0dd | 2012-02-28 22:21:02 +0000 | [diff] [blame] | 359 | bool HTMLTableElement::isPresentationAttribute(const QualifiedName& name) const |
kling@webkit.org | 11f2556 | 2012-02-13 10:36:55 +0000 | [diff] [blame] | 360 | { |
kling@webkit.org | 44bc0dd | 2012-02-28 22:21:02 +0000 | [diff] [blame] | 361 | if (name == widthAttr || name == heightAttr || name == bgcolorAttr || name == backgroundAttr || name == valignAttr || name == vspaceAttr || name == hspaceAttr || name == alignAttr || name == cellspacingAttr || name == borderAttr || name == bordercolorAttr || name == frameAttr || name == rulesAttr) |
kling@webkit.org | 11f2556 | 2012-02-13 10:36:55 +0000 | [diff] [blame] | 362 | return true; |
kling@webkit.org | 44bc0dd | 2012-02-28 22:21:02 +0000 | [diff] [blame] | 363 | return HTMLElement::isPresentationAttribute(name); |
kling@webkit.org | 11f2556 | 2012-02-13 10:36:55 +0000 | [diff] [blame] | 364 | } |
| 365 | |
akling@apple.com | 43e9d04 | 2012-11-18 16:55:06 +0000 | [diff] [blame] | 366 | void HTMLTableElement::parseAttribute(const QualifiedName& name, const AtomicString& value) |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 367 | { |
darin@apple.com | 1230411 | 2008-01-04 01:17:05 +0000 | [diff] [blame] | 368 | CellBorders bordersBefore = cellBorders(); |
hyatt@apple.com | cd9e409 | 2008-01-18 21:56:31 +0000 | [diff] [blame] | 369 | unsigned short oldPadding = m_padding; |
| 370 | |
akling@apple.com | 43e9d04 | 2012-11-18 16:55:06 +0000 | [diff] [blame] | 371 | if (name == borderAttr) { |
kling@webkit.org | 8b0e843 | 2012-02-11 19:29:49 +0000 | [diff] [blame] | 372 | // FIXME: This attribute is a mess. |
akling@apple.com | b75eeea | 2013-02-23 17:57:50 +0000 | [diff] [blame] | 373 | m_borderAttr = parseBorderWidthAttribute(value); |
akling@apple.com | 43e9d04 | 2012-11-18 16:55:06 +0000 | [diff] [blame] | 374 | } else if (name == bordercolorAttr) { |
| 375 | m_borderColorAttr = !value.isEmpty(); |
| 376 | } else if (name == frameAttr) { |
kling@webkit.org | 8b0e843 | 2012-02-11 19:29:49 +0000 | [diff] [blame] | 377 | // FIXME: This attribute is a mess. |
| 378 | bool borderTop; |
| 379 | bool borderRight; |
| 380 | bool borderBottom; |
| 381 | bool borderLeft; |
akling@apple.com | 43e9d04 | 2012-11-18 16:55:06 +0000 | [diff] [blame] | 382 | m_frameAttr = getBordersFromFrameAttributeValue(value, borderTop, borderRight, borderBottom, borderLeft); |
| 383 | } else if (name == rulesAttr) { |
hyatt | eef21e0 | 2006-09-17 07:57:56 +0000 | [diff] [blame] | 384 | m_rulesAttr = UnsetRules; |
akling@apple.com | 43e9d04 | 2012-11-18 16:55:06 +0000 | [diff] [blame] | 385 | if (equalIgnoringCase(value, "none")) |
hyatt | eef21e0 | 2006-09-17 07:57:56 +0000 | [diff] [blame] | 386 | m_rulesAttr = NoneRules; |
akling@apple.com | 43e9d04 | 2012-11-18 16:55:06 +0000 | [diff] [blame] | 387 | else if (equalIgnoringCase(value, "groups")) |
hyatt | eef21e0 | 2006-09-17 07:57:56 +0000 | [diff] [blame] | 388 | m_rulesAttr = GroupsRules; |
akling@apple.com | 43e9d04 | 2012-11-18 16:55:06 +0000 | [diff] [blame] | 389 | else if (equalIgnoringCase(value, "rows")) |
hyatt | eef21e0 | 2006-09-17 07:57:56 +0000 | [diff] [blame] | 390 | m_rulesAttr = RowsRules; |
akling@apple.com | 43e9d04 | 2012-11-18 16:55:06 +0000 | [diff] [blame] | 391 | else if (equalIgnoringCase(value, "cols")) |
hyatt | eef21e0 | 2006-09-17 07:57:56 +0000 | [diff] [blame] | 392 | m_rulesAttr = ColsRules; |
akling@apple.com | 43e9d04 | 2012-11-18 16:55:06 +0000 | [diff] [blame] | 393 | else if (equalIgnoringCase(value, "all")) |
hyatt | eef21e0 | 2006-09-17 07:57:56 +0000 | [diff] [blame] | 394 | m_rulesAttr = AllRules; |
akling@apple.com | 43e9d04 | 2012-11-18 16:55:06 +0000 | [diff] [blame] | 395 | } else if (name == cellpaddingAttr) { |
| 396 | if (!value.isEmpty()) |
andersca@apple.com | ff9adb8 | 2013-10-25 01:15:36 +0000 | [diff] [blame] | 397 | m_padding = std::max(0, value.toInt()); |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 398 | else |
hyatt | eef21e0 | 2006-09-17 07:57:56 +0000 | [diff] [blame] | 399 | m_padding = 1; |
akling@apple.com | 43e9d04 | 2012-11-18 16:55:06 +0000 | [diff] [blame] | 400 | } else if (name == colsAttr) { |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 401 | // ### |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 402 | } else |
akling@apple.com | 43e9d04 | 2012-11-18 16:55:06 +0000 | [diff] [blame] | 403 | HTMLElement::parseAttribute(name, value); |
darin@apple.com | 1230411 | 2008-01-04 01:17:05 +0000 | [diff] [blame] | 404 | |
hyatt@apple.com | cd9e409 | 2008-01-18 21:56:31 +0000 | [diff] [blame] | 405 | if (bordersBefore != cellBorders() || oldPadding != m_padding) { |
kling@webkit.org | 854221b | 2012-01-26 19:02:27 +0000 | [diff] [blame] | 406 | m_sharedCellStyle = 0; |
darin@apple.com | 1230411 | 2008-01-04 01:17:05 +0000 | [diff] [blame] | 407 | bool cellChanged = false; |
| 408 | for (Node* child = firstChild(); child; child = child->nextSibling()) |
| 409 | cellChanged |= setTableCellsChanged(child); |
| 410 | if (cellChanged) |
hyatt@apple.com | f6d72f3 | 2009-04-10 00:05:02 +0000 | [diff] [blame] | 411 | setNeedsStyleRecalc(); |
darin@apple.com | 1230411 | 2008-01-04 01:17:05 +0000 | [diff] [blame] | 412 | } |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 413 | } |
| 414 | |
alexis@webkit.org | 71873a0 | 2013-06-19 22:07:23 +0000 | [diff] [blame] | 415 | static StylePropertySet* leakBorderStyle(CSSValueID value) |
kling@webkit.org | 854221b | 2012-01-26 19:02:27 +0000 | [diff] [blame] | 416 | { |
akling@apple.com | 1290708 | 2013-04-14 14:24:46 +0000 | [diff] [blame] | 417 | RefPtr<MutableStylePropertySet> style = MutableStylePropertySet::create(); |
kling@webkit.org | 854221b | 2012-01-26 19:02:27 +0000 | [diff] [blame] | 418 | style->setProperty(CSSPropertyBorderTopStyle, value); |
| 419 | style->setProperty(CSSPropertyBorderBottomStyle, value); |
| 420 | style->setProperty(CSSPropertyBorderLeftStyle, value); |
| 421 | style->setProperty(CSSPropertyBorderRightStyle, value); |
| 422 | return style.release().leakRef(); |
| 423 | } |
| 424 | |
kling@webkit.org | 569556d | 2012-11-12 23:52:12 +0000 | [diff] [blame] | 425 | const StylePropertySet* HTMLTableElement::additionalPresentationAttributeStyle() |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 426 | { |
robert@webkit.org | ceeb5dc | 2012-04-24 19:03:44 +0000 | [diff] [blame] | 427 | if (m_frameAttr) |
kling@webkit.org | 854221b | 2012-01-26 19:02:27 +0000 | [diff] [blame] | 428 | return 0; |
robert@webkit.org | ceeb5dc | 2012-04-24 19:03:44 +0000 | [diff] [blame] | 429 | |
| 430 | if (!m_borderAttr && !m_borderColorAttr) { |
| 431 | // Setting the border to 'hidden' allows it to win over any border |
| 432 | // set on the table's cells during border-conflict resolution. |
| 433 | if (m_rulesAttr != UnsetRules) { |
| 434 | static StylePropertySet* solidBorderStyle = leakBorderStyle(CSSValueHidden); |
| 435 | return solidBorderStyle; |
| 436 | } |
| 437 | return 0; |
| 438 | } |
darin@apple.com | 48ac3c4 | 2008-06-14 08:46:51 +0000 | [diff] [blame] | 439 | |
kling@webkit.org | 854221b | 2012-01-26 19:02:27 +0000 | [diff] [blame] | 440 | if (m_borderColorAttr) { |
antti@apple.com | e89e04d | 2012-02-03 19:46:48 +0000 | [diff] [blame] | 441 | static StylePropertySet* solidBorderStyle = leakBorderStyle(CSSValueSolid); |
kling@webkit.org | 854221b | 2012-01-26 19:02:27 +0000 | [diff] [blame] | 442 | return solidBorderStyle; |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 443 | } |
antti@apple.com | e89e04d | 2012-02-03 19:46:48 +0000 | [diff] [blame] | 444 | static StylePropertySet* outsetBorderStyle = leakBorderStyle(CSSValueOutset); |
kling@webkit.org | 854221b | 2012-01-26 19:02:27 +0000 | [diff] [blame] | 445 | return outsetBorderStyle; |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 446 | } |
| 447 | |
darin@apple.com | 1230411 | 2008-01-04 01:17:05 +0000 | [diff] [blame] | 448 | HTMLTableElement::CellBorders HTMLTableElement::cellBorders() const |
| 449 | { |
| 450 | switch (m_rulesAttr) { |
| 451 | case NoneRules: |
| 452 | case GroupsRules: |
| 453 | return NoBorders; |
| 454 | case AllRules: |
| 455 | return SolidBorders; |
| 456 | case ColsRules: |
| 457 | return SolidBordersColsOnly; |
| 458 | case RowsRules: |
| 459 | return SolidBordersRowsOnly; |
| 460 | case UnsetRules: |
| 461 | if (!m_borderAttr) |
| 462 | return NoBorders; |
| 463 | if (m_borderColorAttr) |
| 464 | return SolidBorders; |
| 465 | return InsetBorders; |
| 466 | } |
| 467 | ASSERT_NOT_REACHED(); |
| 468 | return NoBorders; |
| 469 | } |
| 470 | |
antti@apple.com | e89e04d | 2012-02-03 19:46:48 +0000 | [diff] [blame] | 471 | PassRefPtr<StylePropertySet> HTMLTableElement::createSharedCellStyle() |
hyatt@apple.com | cd9e409 | 2008-01-18 21:56:31 +0000 | [diff] [blame] | 472 | { |
akling@apple.com | 1290708 | 2013-04-14 14:24:46 +0000 | [diff] [blame] | 473 | RefPtr<MutableStylePropertySet> style = MutableStylePropertySet::create(); |
hyatt@apple.com | cd9e409 | 2008-01-18 21:56:31 +0000 | [diff] [blame] | 474 | |
kling@webkit.org | 854221b | 2012-01-26 19:02:27 +0000 | [diff] [blame] | 475 | switch (cellBorders()) { |
| 476 | case SolidBordersColsOnly: |
| 477 | style->setProperty(CSSPropertyBorderLeftWidth, CSSValueThin); |
| 478 | style->setProperty(CSSPropertyBorderRightWidth, CSSValueThin); |
| 479 | style->setProperty(CSSPropertyBorderLeftStyle, CSSValueSolid); |
| 480 | style->setProperty(CSSPropertyBorderRightStyle, CSSValueSolid); |
kling@webkit.org | b01b797 | 2012-04-10 00:44:20 +0000 | [diff] [blame] | 481 | style->setProperty(CSSPropertyBorderColor, cssValuePool().createInheritedValue()); |
kling@webkit.org | 854221b | 2012-01-26 19:02:27 +0000 | [diff] [blame] | 482 | break; |
| 483 | case SolidBordersRowsOnly: |
| 484 | style->setProperty(CSSPropertyBorderTopWidth, CSSValueThin); |
| 485 | style->setProperty(CSSPropertyBorderBottomWidth, CSSValueThin); |
| 486 | style->setProperty(CSSPropertyBorderTopStyle, CSSValueSolid); |
| 487 | style->setProperty(CSSPropertyBorderBottomStyle, CSSValueSolid); |
kling@webkit.org | b01b797 | 2012-04-10 00:44:20 +0000 | [diff] [blame] | 488 | style->setProperty(CSSPropertyBorderColor, cssValuePool().createInheritedValue()); |
kling@webkit.org | 854221b | 2012-01-26 19:02:27 +0000 | [diff] [blame] | 489 | break; |
| 490 | case SolidBorders: |
kling@webkit.org | b01b797 | 2012-04-10 00:44:20 +0000 | [diff] [blame] | 491 | style->setProperty(CSSPropertyBorderWidth, cssValuePool().createValue(1, CSSPrimitiveValue::CSS_PX)); |
| 492 | style->setProperty(CSSPropertyBorderStyle, cssValuePool().createIdentifierValue(CSSValueSolid)); |
| 493 | style->setProperty(CSSPropertyBorderColor, cssValuePool().createInheritedValue()); |
kling@webkit.org | 854221b | 2012-01-26 19:02:27 +0000 | [diff] [blame] | 494 | break; |
| 495 | case InsetBorders: |
kling@webkit.org | b01b797 | 2012-04-10 00:44:20 +0000 | [diff] [blame] | 496 | style->setProperty(CSSPropertyBorderWidth, cssValuePool().createValue(1, CSSPrimitiveValue::CSS_PX)); |
| 497 | style->setProperty(CSSPropertyBorderStyle, cssValuePool().createIdentifierValue(CSSValueInset)); |
| 498 | style->setProperty(CSSPropertyBorderColor, cssValuePool().createInheritedValue()); |
kling@webkit.org | 854221b | 2012-01-26 19:02:27 +0000 | [diff] [blame] | 499 | break; |
| 500 | case NoBorders: |
robert@webkit.org | f911cc3 | 2012-08-25 16:20:23 +0000 | [diff] [blame] | 501 | // If 'rules=none' then allow any borders set at cell level to take effect. |
kling@webkit.org | 854221b | 2012-01-26 19:02:27 +0000 | [diff] [blame] | 502 | break; |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 503 | } |
kling@webkit.org | e72793e | 2011-12-24 21:24:59 +0000 | [diff] [blame] | 504 | |
kling@webkit.org | 2340d5e | 2012-02-25 17:43:32 +0000 | [diff] [blame] | 505 | if (m_padding) |
kling@webkit.org | b01b797 | 2012-04-10 00:44:20 +0000 | [diff] [blame] | 506 | style->setProperty(CSSPropertyPadding, cssValuePool().createValue(m_padding, CSSPrimitiveValue::CSS_PX)); |
kling@webkit.org | e72793e | 2011-12-24 21:24:59 +0000 | [diff] [blame] | 507 | |
kling@webkit.org | 854221b | 2012-01-26 19:02:27 +0000 | [diff] [blame] | 508 | return style.release(); |
hyatt@apple.com | cd9e409 | 2008-01-18 21:56:31 +0000 | [diff] [blame] | 509 | } |
| 510 | |
kling@webkit.org | 513d26f | 2012-08-06 13:14:04 +0000 | [diff] [blame] | 511 | const StylePropertySet* HTMLTableElement::additionalCellStyle() |
kling@webkit.org | 854221b | 2012-01-26 19:02:27 +0000 | [diff] [blame] | 512 | { |
| 513 | if (!m_sharedCellStyle) |
| 514 | m_sharedCellStyle = createSharedCellStyle(); |
kling@webkit.org | dc26b37 | 2012-02-09 07:14:55 +0000 | [diff] [blame] | 515 | return m_sharedCellStyle.get(); |
kling@webkit.org | 854221b | 2012-01-26 19:02:27 +0000 | [diff] [blame] | 516 | } |
| 517 | |
antti@apple.com | e89e04d | 2012-02-03 19:46:48 +0000 | [diff] [blame] | 518 | static StylePropertySet* leakGroupBorderStyle(int rows) |
kling@webkit.org | 854221b | 2012-01-26 19:02:27 +0000 | [diff] [blame] | 519 | { |
akling@apple.com | 1290708 | 2013-04-14 14:24:46 +0000 | [diff] [blame] | 520 | RefPtr<MutableStylePropertySet> style = MutableStylePropertySet::create(); |
kling@webkit.org | 854221b | 2012-01-26 19:02:27 +0000 | [diff] [blame] | 521 | if (rows) { |
| 522 | style->setProperty(CSSPropertyBorderTopWidth, CSSValueThin); |
| 523 | style->setProperty(CSSPropertyBorderBottomWidth, CSSValueThin); |
| 524 | style->setProperty(CSSPropertyBorderTopStyle, CSSValueSolid); |
| 525 | style->setProperty(CSSPropertyBorderBottomStyle, CSSValueSolid); |
| 526 | } else { |
| 527 | style->setProperty(CSSPropertyBorderLeftWidth, CSSValueThin); |
| 528 | style->setProperty(CSSPropertyBorderRightWidth, CSSValueThin); |
| 529 | style->setProperty(CSSPropertyBorderLeftStyle, CSSValueSolid); |
| 530 | style->setProperty(CSSPropertyBorderRightStyle, CSSValueSolid); |
| 531 | } |
| 532 | return style.release().leakRef(); |
| 533 | } |
| 534 | |
kling@webkit.org | 513d26f | 2012-08-06 13:14:04 +0000 | [diff] [blame] | 535 | const StylePropertySet* HTMLTableElement::additionalGroupStyle(bool rows) |
hyatt | eef21e0 | 2006-09-17 07:57:56 +0000 | [diff] [blame] | 536 | { |
| 537 | if (m_rulesAttr != GroupsRules) |
kling@webkit.org | 854221b | 2012-01-26 19:02:27 +0000 | [diff] [blame] | 538 | return 0; |
hyatt | eef21e0 | 2006-09-17 07:57:56 +0000 | [diff] [blame] | 539 | |
kling@webkit.org | 854221b | 2012-01-26 19:02:27 +0000 | [diff] [blame] | 540 | if (rows) { |
antti@apple.com | e89e04d | 2012-02-03 19:46:48 +0000 | [diff] [blame] | 541 | static StylePropertySet* rowBorderStyle = leakGroupBorderStyle(true); |
kling@webkit.org | 854221b | 2012-01-26 19:02:27 +0000 | [diff] [blame] | 542 | return rowBorderStyle; |
hyatt | eef21e0 | 2006-09-17 07:57:56 +0000 | [diff] [blame] | 543 | } |
antti@apple.com | e89e04d | 2012-02-03 19:46:48 +0000 | [diff] [blame] | 544 | static StylePropertySet* columnBorderStyle = leakGroupBorderStyle(false); |
kling@webkit.org | 854221b | 2012-01-26 19:02:27 +0000 | [diff] [blame] | 545 | return columnBorderStyle; |
hyatt | eef21e0 | 2006-09-17 07:57:56 +0000 | [diff] [blame] | 546 | } |
| 547 | |
kling@webkit.org | d8a6d15 | 2012-05-08 16:27:04 +0000 | [diff] [blame] | 548 | bool HTMLTableElement::isURLAttribute(const Attribute& attribute) const |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 549 | { |
kling@webkit.org | d8a6d15 | 2012-05-08 16:27:04 +0000 | [diff] [blame] | 550 | return attribute.name() == backgroundAttr || HTMLElement::isURLAttribute(attribute); |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 551 | } |
| 552 | |
rniwa@webkit.org | 4823cc1 | 2012-07-09 17:40:09 +0000 | [diff] [blame] | 553 | PassRefPtr<HTMLCollection> HTMLTableElement::rows() |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 554 | { |
rniwa@webkit.org | 28acc31 | 2012-06-29 23:56:42 +0000 | [diff] [blame] | 555 | return ensureCachedHTMLCollection(TableRows); |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 556 | } |
| 557 | |
rniwa@webkit.org | 4823cc1 | 2012-07-09 17:40:09 +0000 | [diff] [blame] | 558 | PassRefPtr<HTMLCollection> HTMLTableElement::tBodies() |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 559 | { |
kling@webkit.org | a3a65e3 | 2012-01-01 21:05:42 +0000 | [diff] [blame] | 560 | return ensureCachedHTMLCollection(TableTBodies); |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 561 | } |
| 562 | |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 563 | String HTMLTableElement::rules() const |
| 564 | { |
commit-queue@webkit.org | 03477c8 | 2011-09-02 17:07:51 +0000 | [diff] [blame] | 565 | return getAttribute(rulesAttr); |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 566 | } |
| 567 | |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 568 | String HTMLTableElement::summary() const |
| 569 | { |
commit-queue@webkit.org | 03477c8 | 2011-09-02 17:07:51 +0000 | [diff] [blame] | 570 | return getAttribute(summaryAttr); |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 571 | } |
| 572 | |
darin@apple.com | 5ffbb5c | 2013-09-27 16:39:41 +0000 | [diff] [blame] | 573 | void HTMLTableElement::addSubresourceAttributeURLs(ListHashSet<URL>& urls) const |
beidson@apple.com | a4fb38f | 2008-03-27 04:08:17 +0000 | [diff] [blame] | 574 | { |
commit-queue@webkit.org | bd9bc9a | 2012-05-30 20:50:31 +0000 | [diff] [blame] | 575 | HTMLElement::addSubresourceAttributeURLs(urls); |
ddkilzer@apple.com | e9a5504 | 2008-12-23 00:00:14 +0000 | [diff] [blame] | 576 | |
akling@apple.com | 622b1a4 | 2013-08-30 14:30:12 +0000 | [diff] [blame] | 577 | addSubresourceURL(urls, document().completeURL(getAttribute(backgroundAttr))); |
beidson@apple.com | a4fb38f | 2008-03-27 04:08:17 +0000 | [diff] [blame] | 578 | } |
| 579 | |
eseidel | 787da6b | 2006-05-12 19:44:03 +0000 | [diff] [blame] | 580 | } |