OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 // When a section of the document is contentEditable, all tables should be | 96 // When a section of the document is contentEditable, all tables should be |
97 // treated as data tables, otherwise users may not be able to work with rich | 97 // treated as data tables, otherwise users may not be able to work with rich |
98 // text editors that allow creating and editing tables. | 98 // text editors that allow creating and editing tables. |
99 if (node() && node()->rendererIsEditable()) | 99 if (node() && node()->rendererIsEditable()) |
100 return true; | 100 return true; |
101 | 101 |
102 // This employs a heuristic to determine if this table should appear. | 102 // This employs a heuristic to determine if this table should appear. |
103 // Only "data" tables should be exposed as tables. | 103 // Only "data" tables should be exposed as tables. |
104 // Unfortunately, there is no good way to determine the difference | 104 // Unfortunately, there is no good way to determine the difference |
105 // between a "layout" table and a "data" table. | 105 // between a "layout" table and a "data" table. |
106 | 106 |
107 RenderTable* table = toRenderTable(m_renderer); | 107 RenderTable* table = toRenderTable(m_renderer); |
108 Node* tableNode = table->node(); | 108 Node* tableNode = table->node(); |
109 if (!tableNode || !tableNode->hasTagName(tableTag)) | 109 if (!tableNode || !isHTMLTableElement(tableNode)) |
110 return false; | 110 return false; |
111 | 111 |
112 // if there is a caption element, summary, THEAD, or TFOOT section, it's mos
t certainly a data table | 112 // if there is a caption element, summary, THEAD, or TFOOT section, it's mos
t certainly a data table |
113 HTMLTableElement* tableElement = static_cast<HTMLTableElement*>(tableNode); | 113 HTMLTableElement* tableElement = toHTMLTableElement(tableNode); |
114 if (!tableElement->summary().isEmpty() || tableElement->tHead() || tableElem
ent->tFoot() || tableElement->caption()) | 114 if (!tableElement->summary().isEmpty() || tableElement->tHead() || tableElem
ent->tFoot() || tableElement->caption()) |
115 return true; | 115 return true; |
116 | 116 |
117 // if someone used "rules" attribute than the table should appear | 117 // if someone used "rules" attribute than the table should appear |
118 if (!tableElement->rules().isEmpty()) | 118 if (!tableElement->rules().isEmpty()) |
119 return true; | 119 return true; |
120 | 120 |
121 // if there's a colgroup or col element, it's probably a data table. | 121 // if there's a colgroup or col element, it's probably a data table. |
122 for (Node* child = tableElement->firstChild(); child; child = child->nextSib
ling()) { | 122 for (Node* child = tableElement->firstChild(); child; child = child->nextSib
ling()) { |
123 if (child->hasTagName(colTag) || child->hasTagName(colgroupTag)) | 123 if (child->hasTagName(colTag) || child->hasTagName(colgroupTag)) |
124 return true; | 124 return true; |
125 } | 125 } |
126 | 126 |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 } | 524 } |
525 | 525 |
526 String AccessibilityTable::title() const | 526 String AccessibilityTable::title() const |
527 { | 527 { |
528 if (!isAccessibilityTable()) | 528 if (!isAccessibilityTable()) |
529 return AccessibilityRenderObject::title(); | 529 return AccessibilityRenderObject::title(); |
530 | 530 |
531 String title; | 531 String title; |
532 if (!m_renderer) | 532 if (!m_renderer) |
533 return title; | 533 return title; |
534 | 534 |
535 // see if there is a caption | 535 // see if there is a caption |
536 Node* tableElement = m_renderer->node(); | 536 Node* tableElement = m_renderer->node(); |
537 if (tableElement && tableElement->hasTagName(tableTag)) { | 537 if (tableElement && isHTMLTableElement(tableElement)) { |
538 HTMLTableCaptionElement* caption = static_cast<HTMLTableElement*>(tableE
lement)->caption(); | 538 HTMLTableCaptionElement* caption = toHTMLTableElement(tableElement)->cap
tion(); |
539 if (caption) | 539 if (caption) |
540 title = caption->innerText(); | 540 title = caption->innerText(); |
541 } | 541 } |
542 | 542 |
543 // try the standard | 543 // try the standard |
544 if (title.isEmpty()) | 544 if (title.isEmpty()) |
545 title = AccessibilityRenderObject::title(); | 545 title = AccessibilityRenderObject::title(); |
546 | 546 |
547 return title; | 547 return title; |
548 } | 548 } |
549 | 549 |
550 } // namespace WebCore | 550 } // namespace WebCore |
OLD | NEW |