| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1997 Martin Jones (mjones@kde.org) | 2 * Copyright (C) 1997 Martin Jones (mjones@kde.org) |
| 3 * (C) 1997 Torben Weis (weis@kde.org) | 3 * (C) 1997 Torben Weis (weis@kde.org) |
| 4 * (C) 1998 Waldo Bastian (bastian@kde.org) | 4 * (C) 1998 Waldo Bastian (bastian@kde.org) |
| 5 * (C) 1999 Lars Knoll (knoll@kde.org) | 5 * (C) 1999 Lars Knoll (knoll@kde.org) |
| 6 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 6 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2010, 2011 Apple Inc. All rights
reserved. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2010, 2011 Apple Inc. All rights
reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 64 |
| 65 HTMLTableCaptionElement* HTMLTableElement::caption() const | 65 HTMLTableCaptionElement* HTMLTableElement::caption() const |
| 66 { | 66 { |
| 67 for (Node* child = firstChild(); child; child = child->nextSibling()) { | 67 for (Node* child = firstChild(); child; child = child->nextSibling()) { |
| 68 if (child->hasTagName(captionTag)) | 68 if (child->hasTagName(captionTag)) |
| 69 return toHTMLTableCaptionElement(child); | 69 return toHTMLTableCaptionElement(child); |
| 70 } | 70 } |
| 71 return 0; | 71 return 0; |
| 72 } | 72 } |
| 73 | 73 |
| 74 void HTMLTableElement::setCaption(PassRefPtr<HTMLTableCaptionElement> newCaption
, ExceptionState& es) | 74 void HTMLTableElement::setCaption(PassRefPtr<HTMLTableCaptionElement> newCaption
, ExceptionState& exceptionState) |
| 75 { | 75 { |
| 76 deleteCaption(); | 76 deleteCaption(); |
| 77 insertBefore(newCaption, firstChild(), es); | 77 insertBefore(newCaption, firstChild(), exceptionState); |
| 78 } | 78 } |
| 79 | 79 |
| 80 HTMLTableSectionElement* HTMLTableElement::tHead() const | 80 HTMLTableSectionElement* HTMLTableElement::tHead() const |
| 81 { | 81 { |
| 82 for (Node* child = firstChild(); child; child = child->nextSibling()) { | 82 for (Node* child = firstChild(); child; child = child->nextSibling()) { |
| 83 if (child->hasTagName(theadTag)) | 83 if (child->hasTagName(theadTag)) |
| 84 return toHTMLTableSectionElement(child); | 84 return toHTMLTableSectionElement(child); |
| 85 } | 85 } |
| 86 return 0; | 86 return 0; |
| 87 } | 87 } |
| 88 | 88 |
| 89 void HTMLTableElement::setTHead(PassRefPtr<HTMLTableSectionElement> newHead, Exc
eptionState& es) | 89 void HTMLTableElement::setTHead(PassRefPtr<HTMLTableSectionElement> newHead, Exc
eptionState& exceptionState) |
| 90 { | 90 { |
| 91 deleteTHead(); | 91 deleteTHead(); |
| 92 | 92 |
| 93 Node* child; | 93 Node* child; |
| 94 for (child = firstChild(); child; child = child->nextSibling()) | 94 for (child = firstChild(); child; child = child->nextSibling()) |
| 95 if (child->isElementNode() && !child->hasTagName(captionTag) && !child->
hasTagName(colgroupTag)) | 95 if (child->isElementNode() && !child->hasTagName(captionTag) && !child->
hasTagName(colgroupTag)) |
| 96 break; | 96 break; |
| 97 | 97 |
| 98 insertBefore(newHead, child, es); | 98 insertBefore(newHead, child, exceptionState); |
| 99 } | 99 } |
| 100 | 100 |
| 101 HTMLTableSectionElement* HTMLTableElement::tFoot() const | 101 HTMLTableSectionElement* HTMLTableElement::tFoot() const |
| 102 { | 102 { |
| 103 for (Node* child = firstChild(); child; child = child->nextSibling()) { | 103 for (Node* child = firstChild(); child; child = child->nextSibling()) { |
| 104 if (child->hasTagName(tfootTag)) | 104 if (child->hasTagName(tfootTag)) |
| 105 return toHTMLTableSectionElement(child); | 105 return toHTMLTableSectionElement(child); |
| 106 } | 106 } |
| 107 return 0; | 107 return 0; |
| 108 } | 108 } |
| 109 | 109 |
| 110 void HTMLTableElement::setTFoot(PassRefPtr<HTMLTableSectionElement> newFoot, Exc
eptionState& es) | 110 void HTMLTableElement::setTFoot(PassRefPtr<HTMLTableSectionElement> newFoot, Exc
eptionState& exceptionState) |
| 111 { | 111 { |
| 112 deleteTFoot(); | 112 deleteTFoot(); |
| 113 | 113 |
| 114 Node* child; | 114 Node* child; |
| 115 for (child = firstChild(); child; child = child->nextSibling()) | 115 for (child = firstChild(); child; child = child->nextSibling()) |
| 116 if (child->isElementNode() && !child->hasTagName(captionTag) && !child->
hasTagName(colgroupTag) && !child->hasTagName(theadTag)) | 116 if (child->isElementNode() && !child->hasTagName(captionTag) && !child->
hasTagName(colgroupTag) && !child->hasTagName(theadTag)) |
| 117 break; | 117 break; |
| 118 | 118 |
| 119 insertBefore(newFoot, child, es); | 119 insertBefore(newFoot, child, exceptionState); |
| 120 } | 120 } |
| 121 | 121 |
| 122 PassRefPtr<HTMLElement> HTMLTableElement::createTHead() | 122 PassRefPtr<HTMLElement> HTMLTableElement::createTHead() |
| 123 { | 123 { |
| 124 if (HTMLTableSectionElement* existingHead = tHead()) | 124 if (HTMLTableSectionElement* existingHead = tHead()) |
| 125 return existingHead; | 125 return existingHead; |
| 126 RefPtr<HTMLTableSectionElement> head = HTMLTableSectionElement::create(thead
Tag, document()); | 126 RefPtr<HTMLTableSectionElement> head = HTMLTableSectionElement::create(thead
Tag, document()); |
| 127 setTHead(head, IGNORE_EXCEPTION); | 127 setTHead(head, IGNORE_EXCEPTION); |
| 128 return head.release(); | 128 return head.release(); |
| 129 } | 129 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 172 |
| 173 HTMLTableSectionElement* HTMLTableElement::lastBody() const | 173 HTMLTableSectionElement* HTMLTableElement::lastBody() const |
| 174 { | 174 { |
| 175 for (Node* child = lastChild(); child; child = child->previousSibling()) { | 175 for (Node* child = lastChild(); child; child = child->previousSibling()) { |
| 176 if (child->hasTagName(tbodyTag)) | 176 if (child->hasTagName(tbodyTag)) |
| 177 return toHTMLTableSectionElement(child); | 177 return toHTMLTableSectionElement(child); |
| 178 } | 178 } |
| 179 return 0; | 179 return 0; |
| 180 } | 180 } |
| 181 | 181 |
| 182 PassRefPtr<HTMLElement> HTMLTableElement::insertRow(int index, ExceptionState& e
s) | 182 PassRefPtr<HTMLElement> HTMLTableElement::insertRow(int index, ExceptionState& e
xceptionState) |
| 183 { | 183 { |
| 184 if (index < -1) { | 184 if (index < -1) { |
| 185 es.throwUninformativeAndGenericDOMException(IndexSizeError); | 185 exceptionState.throwUninformativeAndGenericDOMException(IndexSizeError); |
| 186 return 0; | 186 return 0; |
| 187 } | 187 } |
| 188 | 188 |
| 189 RefPtr<Node> protectFromMutationEvents(this); | 189 RefPtr<Node> protectFromMutationEvents(this); |
| 190 | 190 |
| 191 RefPtr<HTMLTableRowElement> lastRow = 0; | 191 RefPtr<HTMLTableRowElement> lastRow = 0; |
| 192 RefPtr<HTMLTableRowElement> row = 0; | 192 RefPtr<HTMLTableRowElement> row = 0; |
| 193 if (index == -1) | 193 if (index == -1) |
| 194 lastRow = HTMLTableRowsCollection::lastRow(this); | 194 lastRow = HTMLTableRowsCollection::lastRow(this); |
| 195 else { | 195 else { |
| 196 for (int i = 0; i <= index; ++i) { | 196 for (int i = 0; i <= index; ++i) { |
| 197 row = HTMLTableRowsCollection::rowAfter(this, lastRow.get()); | 197 row = HTMLTableRowsCollection::rowAfter(this, lastRow.get()); |
| 198 if (!row) { | 198 if (!row) { |
| 199 if (i != index) { | 199 if (i != index) { |
| 200 es.throwUninformativeAndGenericDOMException(IndexSizeError); | 200 exceptionState.throwUninformativeAndGenericDOMException(Inde
xSizeError); |
| 201 return 0; | 201 return 0; |
| 202 } | 202 } |
| 203 break; | 203 break; |
| 204 } | 204 } |
| 205 lastRow = row; | 205 lastRow = row; |
| 206 } | 206 } |
| 207 } | 207 } |
| 208 | 208 |
| 209 RefPtr<ContainerNode> parent; | 209 RefPtr<ContainerNode> parent; |
| 210 if (lastRow) | 210 if (lastRow) |
| 211 parent = row ? row->parentNode() : lastRow->parentNode(); | 211 parent = row ? row->parentNode() : lastRow->parentNode(); |
| 212 else { | 212 else { |
| 213 parent = lastBody(); | 213 parent = lastBody(); |
| 214 if (!parent) { | 214 if (!parent) { |
| 215 RefPtr<HTMLTableSectionElement> newBody = HTMLTableSectionElement::c
reate(tbodyTag, document()); | 215 RefPtr<HTMLTableSectionElement> newBody = HTMLTableSectionElement::c
reate(tbodyTag, document()); |
| 216 RefPtr<HTMLTableRowElement> newRow = HTMLTableRowElement::create(doc
ument()); | 216 RefPtr<HTMLTableRowElement> newRow = HTMLTableRowElement::create(doc
ument()); |
| 217 newBody->appendChild(newRow, es); | 217 newBody->appendChild(newRow, exceptionState); |
| 218 appendChild(newBody.release(), es); | 218 appendChild(newBody.release(), exceptionState); |
| 219 return newRow.release(); | 219 return newRow.release(); |
| 220 } | 220 } |
| 221 } | 221 } |
| 222 | 222 |
| 223 RefPtr<HTMLTableRowElement> newRow = HTMLTableRowElement::create(document())
; | 223 RefPtr<HTMLTableRowElement> newRow = HTMLTableRowElement::create(document())
; |
| 224 parent->insertBefore(newRow, row.get(), es); | 224 parent->insertBefore(newRow, row.get(), exceptionState); |
| 225 return newRow.release(); | 225 return newRow.release(); |
| 226 } | 226 } |
| 227 | 227 |
| 228 void HTMLTableElement::deleteRow(int index, ExceptionState& es) | 228 void HTMLTableElement::deleteRow(int index, ExceptionState& exceptionState) |
| 229 { | 229 { |
| 230 HTMLTableRowElement* row = 0; | 230 HTMLTableRowElement* row = 0; |
| 231 if (index == -1) | 231 if (index == -1) |
| 232 row = HTMLTableRowsCollection::lastRow(this); | 232 row = HTMLTableRowsCollection::lastRow(this); |
| 233 else { | 233 else { |
| 234 for (int i = 0; i <= index; ++i) { | 234 for (int i = 0; i <= index; ++i) { |
| 235 row = HTMLTableRowsCollection::rowAfter(this, row); | 235 row = HTMLTableRowsCollection::rowAfter(this, row); |
| 236 if (!row) | 236 if (!row) |
| 237 break; | 237 break; |
| 238 } | 238 } |
| 239 } | 239 } |
| 240 if (!row) { | 240 if (!row) { |
| 241 es.throwUninformativeAndGenericDOMException(IndexSizeError); | 241 exceptionState.throwUninformativeAndGenericDOMException(IndexSizeError); |
| 242 return; | 242 return; |
| 243 } | 243 } |
| 244 row->remove(es); | 244 row->remove(exceptionState); |
| 245 } | 245 } |
| 246 | 246 |
| 247 static inline bool isTableCellAncestor(Node* n) | 247 static inline bool isTableCellAncestor(Node* n) |
| 248 { | 248 { |
| 249 return n->hasTagName(theadTag) || n->hasTagName(tbodyTag) || | 249 return n->hasTagName(theadTag) || n->hasTagName(tbodyTag) || |
| 250 n->hasTagName(tfootTag) || n->hasTagName(trTag) || | 250 n->hasTagName(tfootTag) || n->hasTagName(trTag) || |
| 251 n->hasTagName(thTag); | 251 n->hasTagName(thTag); |
| 252 } | 252 } |
| 253 | 253 |
| 254 static bool setTableCellsChanged(Node* n) | 254 static bool setTableCellsChanged(Node* n) |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 } | 567 } |
| 568 | 568 |
| 569 void HTMLTableElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) cons
t | 569 void HTMLTableElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) cons
t |
| 570 { | 570 { |
| 571 HTMLElement::addSubresourceAttributeURLs(urls); | 571 HTMLElement::addSubresourceAttributeURLs(urls); |
| 572 | 572 |
| 573 addSubresourceURL(urls, document().completeURL(getAttribute(backgroundAttr))
); | 573 addSubresourceURL(urls, document().completeURL(getAttribute(backgroundAttr))
); |
| 574 } | 574 } |
| 575 | 575 |
| 576 } | 576 } |
| OLD | NEW |