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