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, 2010 Apple Inc. All rights reserved. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2010 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 13 matching lines...) Expand all Loading... |
24 | 24 |
25 #include "config.h" | 25 #include "config.h" |
26 #include "core/html/HTMLTableCellElement.h" | 26 #include "core/html/HTMLTableCellElement.h" |
27 | 27 |
28 #include "core/CSSPropertyNames.h" | 28 #include "core/CSSPropertyNames.h" |
29 #include "core/CSSValueKeywords.h" | 29 #include "core/CSSValueKeywords.h" |
30 #include "core/HTMLNames.h" | 30 #include "core/HTMLNames.h" |
31 #include "core/dom/Attribute.h" | 31 #include "core/dom/Attribute.h" |
32 #include "core/dom/ElementTraversal.h" | 32 #include "core/dom/ElementTraversal.h" |
33 #include "core/html/HTMLTableElement.h" | 33 #include "core/html/HTMLTableElement.h" |
| 34 #include "core/html/parser/HTMLParserIdioms.h" |
34 #include "core/rendering/RenderTableCell.h" | 35 #include "core/rendering/RenderTableCell.h" |
35 | 36 |
36 using std::max; | 37 using std::max; |
37 using std::min; | 38 using std::min; |
38 | 39 |
39 namespace blink { | 40 namespace blink { |
40 | 41 |
41 // Clamp rowspan and colspan at 8k. | 42 // Clamp rowspan and colspan at 8k. |
42 // Firefox used a limit of 8190 for rowspan but they changed it to 65,534. | 43 // Firefox used a limit of 8190 for rowspan but they changed it to 65,534. |
43 // (FIXME: We should consider increasing this limit (crbug.com/78577). | 44 // (FIXME: We should consider increasing this limit (crbug.com/78577). |
44 // Firefox uses a limit of 1,000 for colspan and resets the value to 1 | 45 // Firefox uses a limit of 1,000 for colspan and resets the value to 1 |
45 // but we don't discriminate between rowspan / colspan as it is artificial. | 46 // but we don't discriminate between rowspan / colspan as it is artificial. |
46 static const int maxColRowSpan = 8190; | 47 static const int maxColRowSpan = 8190; |
47 | 48 |
48 using namespace HTMLNames; | 49 using namespace HTMLNames; |
49 | 50 |
50 inline HTMLTableCellElement::HTMLTableCellElement(const QualifiedName& tagName,
Document& document) | 51 inline HTMLTableCellElement::HTMLTableCellElement(const QualifiedName& tagName,
Document& document) |
51 : HTMLTablePartElement(tagName, document) | 52 : HTMLTablePartElement(tagName, document) |
52 { | 53 { |
53 } | 54 } |
54 | 55 |
55 DEFINE_ELEMENT_FACTORY_WITH_TAGNAME(HTMLTableCellElement) | 56 DEFINE_ELEMENT_FACTORY_WITH_TAGNAME(HTMLTableCellElement) |
56 | 57 |
57 int HTMLTableCellElement::colSpan() const | 58 int HTMLTableCellElement::colSpan() const |
58 { | 59 { |
59 const AtomicString& colSpanValue = fastGetAttribute(colspanAttr); | 60 const AtomicString& colSpanValue = fastGetAttribute(colspanAttr); |
60 return max(1, min(colSpanValue.toInt(), maxColRowSpan)); | 61 int value = 0; |
| 62 if (colSpanValue.isEmpty() || !parseHTMLInteger(colSpanValue, value)) |
| 63 return 1; |
| 64 return max(1, min(value, maxColRowSpan)); |
61 } | 65 } |
62 | 66 |
63 int HTMLTableCellElement::rowSpan() const | 67 int HTMLTableCellElement::rowSpan() const |
64 { | 68 { |
65 const AtomicString& rowSpanValue = fastGetAttribute(rowspanAttr); | 69 const AtomicString& rowSpanValue = fastGetAttribute(rowspanAttr); |
66 return max(1, min(rowSpanValue.toInt(), maxColRowSpan)); | 70 int value = 0; |
| 71 if (rowSpanValue.isEmpty() || !parseHTMLInteger(rowSpanValue, value)) |
| 72 return 1; |
| 73 return max(1, min(value, maxColRowSpan)); |
67 } | 74 } |
68 | 75 |
69 int HTMLTableCellElement::cellIndex() const | 76 int HTMLTableCellElement::cellIndex() const |
70 { | 77 { |
71 if (!isHTMLTableRowElement(parentElement())) | 78 if (!isHTMLTableRowElement(parentElement())) |
72 return -1; | 79 return -1; |
73 | 80 |
74 int index = 0; | 81 int index = 0; |
75 for (const HTMLTableCellElement* element = Traversal<HTMLTableCellElement>::
previousSibling(*this); element; element = Traversal<HTMLTableCellElement>::prev
iousSibling(*element)) | 82 for (const HTMLTableCellElement* element = Traversal<HTMLTableCellElement>::
previousSibling(*this); element; element = Traversal<HTMLTableCellElement>::prev
iousSibling(*element)) |
76 ++index; | 83 ++index; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 | 186 |
180 RenderTableCell* tableCellRenderer = toRenderTableCell(cellRenderer); | 187 RenderTableCell* tableCellRenderer = toRenderTableCell(cellRenderer); |
181 RenderTableCell* cellAboveRenderer = tableCellRenderer->table()->cellAbove(t
ableCellRenderer); | 188 RenderTableCell* cellAboveRenderer = tableCellRenderer->table()->cellAbove(t
ableCellRenderer); |
182 if (!cellAboveRenderer) | 189 if (!cellAboveRenderer) |
183 return nullptr; | 190 return nullptr; |
184 | 191 |
185 return toHTMLTableCellElement(cellAboveRenderer->node()); | 192 return toHTMLTableCellElement(cellAboveRenderer->node()); |
186 } | 193 } |
187 | 194 |
188 } // namespace blink | 195 } // namespace blink |
OLD | NEW |