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 26 matching lines...) Expand all Loading... |
37 using std::max; | 37 using std::max; |
38 using std::min; | 38 using std::min; |
39 | 39 |
40 namespace blink { | 40 namespace blink { |
41 | 41 |
42 // Clamp rowspan and colspan at 8k. | 42 // Clamp rowspan and colspan at 8k. |
43 // 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. |
44 // (FIXME: We should consider increasing this limit (crbug.com/78577). | 44 // (FIXME: We should consider increasing this limit (crbug.com/78577). |
45 // 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 |
46 // 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. |
47 static const int maxColRowSpan = 8190; | 47 static const unsigned maxColRowSpan = 8190; |
48 | 48 |
49 using namespace HTMLNames; | 49 using namespace HTMLNames; |
50 | 50 |
51 inline HTMLTableCellElement::HTMLTableCellElement(const QualifiedName& tagName,
Document& document) | 51 inline HTMLTableCellElement::HTMLTableCellElement(const QualifiedName& tagName,
Document& document) |
52 : HTMLTablePartElement(tagName, document) | 52 : HTMLTablePartElement(tagName, document) |
53 { | 53 { |
54 } | 54 } |
55 | 55 |
56 DEFINE_ELEMENT_FACTORY_WITH_TAGNAME(HTMLTableCellElement) | 56 DEFINE_ELEMENT_FACTORY_WITH_TAGNAME(HTMLTableCellElement) |
57 | 57 |
58 int HTMLTableCellElement::colSpan() const | 58 unsigned HTMLTableCellElement::colSpan() const |
59 { | 59 { |
60 const AtomicString& colSpanValue = fastGetAttribute(colspanAttr); | 60 const AtomicString& colSpanValue = fastGetAttribute(colspanAttr); |
61 int value = 0; | 61 unsigned value = 0; |
62 if (colSpanValue.isEmpty() || !parseHTMLInteger(colSpanValue, value)) | 62 if (colSpanValue.isEmpty() || !parseHTMLNonNegativeInteger(colSpanValue, val
ue)) |
63 return 1; | 63 return 1; |
64 return max(1, min(value, maxColRowSpan)); | 64 return max(1u, min(value, maxColRowSpan)); |
65 } | 65 } |
66 | 66 |
67 int HTMLTableCellElement::rowSpan() const | 67 unsigned HTMLTableCellElement::rowSpan() const |
68 { | 68 { |
69 const AtomicString& rowSpanValue = fastGetAttribute(rowspanAttr); | 69 const AtomicString& rowSpanValue = fastGetAttribute(rowspanAttr); |
70 int value = 0; | 70 unsigned value = 0; |
71 if (rowSpanValue.isEmpty() || !parseHTMLInteger(rowSpanValue, value)) | 71 if (rowSpanValue.isEmpty() || !parseHTMLNonNegativeInteger(rowSpanValue, val
ue)) |
72 return 1; | 72 return 1; |
73 return max(1, min(value, maxColRowSpan)); | 73 return max(1u, min(value, maxColRowSpan)); |
74 } | 74 } |
75 | 75 |
76 int HTMLTableCellElement::cellIndex() const | 76 int HTMLTableCellElement::cellIndex() const |
77 { | 77 { |
78 if (!isHTMLTableRowElement(parentElement())) | 78 if (!isHTMLTableRowElement(parentElement())) |
79 return -1; | 79 return -1; |
80 | 80 |
81 int index = 0; | 81 int index = 0; |
82 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)) |
83 ++index; | 83 ++index; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 const AtomicString& HTMLTableCellElement::abbr() const | 149 const AtomicString& HTMLTableCellElement::abbr() const |
150 { | 150 { |
151 return fastGetAttribute(abbrAttr); | 151 return fastGetAttribute(abbrAttr); |
152 } | 152 } |
153 | 153 |
154 const AtomicString& HTMLTableCellElement::axis() const | 154 const AtomicString& HTMLTableCellElement::axis() const |
155 { | 155 { |
156 return fastGetAttribute(axisAttr); | 156 return fastGetAttribute(axisAttr); |
157 } | 157 } |
158 | 158 |
159 void HTMLTableCellElement::setColSpan(int n) | 159 void HTMLTableCellElement::setColSpan(unsigned n) |
160 { | 160 { |
161 setIntegralAttribute(colspanAttr, n); | 161 setUnsignedIntegralAttribute(colspanAttr, n); |
162 } | 162 } |
163 | 163 |
164 const AtomicString& HTMLTableCellElement::headers() const | 164 const AtomicString& HTMLTableCellElement::headers() const |
165 { | 165 { |
166 return fastGetAttribute(headersAttr); | 166 return fastGetAttribute(headersAttr); |
167 } | 167 } |
168 | 168 |
169 void HTMLTableCellElement::setRowSpan(int n) | 169 void HTMLTableCellElement::setRowSpan(unsigned n) |
170 { | 170 { |
171 setIntegralAttribute(rowspanAttr, n); | 171 setUnsignedIntegralAttribute(rowspanAttr, n); |
172 } | 172 } |
173 | 173 |
174 const AtomicString& HTMLTableCellElement::scope() const | 174 const AtomicString& HTMLTableCellElement::scope() const |
175 { | 175 { |
176 return fastGetAttribute(scopeAttr); | 176 return fastGetAttribute(scopeAttr); |
177 } | 177 } |
178 | 178 |
179 HTMLTableCellElement* HTMLTableCellElement::cellAbove() const | 179 HTMLTableCellElement* HTMLTableCellElement::cellAbove() const |
180 { | 180 { |
181 LayoutObject* cellLayoutObject = layoutObject(); | 181 LayoutObject* cellLayoutObject = layoutObject(); |
182 if (!cellLayoutObject) | 182 if (!cellLayoutObject) |
183 return nullptr; | 183 return nullptr; |
184 if (!cellLayoutObject->isTableCell()) | 184 if (!cellLayoutObject->isTableCell()) |
185 return nullptr; | 185 return nullptr; |
186 | 186 |
187 LayoutTableCell* tableCellLayoutObject = toLayoutTableCell(cellLayoutObject)
; | 187 LayoutTableCell* tableCellLayoutObject = toLayoutTableCell(cellLayoutObject)
; |
188 LayoutTableCell* cellAboveLayoutObject = tableCellLayoutObject->table()->cel
lAbove(tableCellLayoutObject); | 188 LayoutTableCell* cellAboveLayoutObject = tableCellLayoutObject->table()->cel
lAbove(tableCellLayoutObject); |
189 if (!cellAboveLayoutObject) | 189 if (!cellAboveLayoutObject) |
190 return nullptr; | 190 return nullptr; |
191 | 191 |
192 return toHTMLTableCellElement(cellAboveLayoutObject->node()); | 192 return toHTMLTableCellElement(cellAboveLayoutObject->node()); |
193 } | 193 } |
194 | 194 |
195 } // namespace blink | 195 } // namespace blink |
OLD | NEW |