Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Side by Side Diff: Source/core/html/HTMLTableRowElement.cpp

Issue 18313005: Introduce isHTMLTableElement and toHTMLTableElement (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Retry Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/html/HTMLTablePartElement.cpp ('k') | Source/core/html/HTMLTableRowsCollection.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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, 2007, 2010 Apple Inc. All rights reserv ed. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2010 Apple Inc. All rights reserv ed.
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 { 52 {
53 return adoptRef(new HTMLTableRowElement(tagName, document)); 53 return adoptRef(new HTMLTableRowElement(tagName, document));
54 } 54 }
55 55
56 int HTMLTableRowElement::rowIndex() const 56 int HTMLTableRowElement::rowIndex() const
57 { 57 {
58 ContainerNode* table = parentNode(); 58 ContainerNode* table = parentNode();
59 if (!table) 59 if (!table)
60 return -1; 60 return -1;
61 table = table->parentNode(); 61 table = table->parentNode();
62 if (!table || !table->hasTagName(tableTag)) 62 if (!table || !isHTMLTableElement(table))
63 return -1; 63 return -1;
64 64
65 // To match Firefox, the row indices work like this: 65 // To match Firefox, the row indices work like this:
66 // Rows from the first <thead> are numbered before all <tbody> rows. 66 // Rows from the first <thead> are numbered before all <tbody> rows.
67 // Rows from the first <tfoot> are numbered after all <tbody> rows. 67 // Rows from the first <tfoot> are numbered after all <tbody> rows.
68 // Rows from other <thead> and <tfoot> elements don't get row indices at a ll. 68 // Rows from other <thead> and <tfoot> elements don't get row indices at a ll.
69 69
70 int rIndex = 0; 70 int rIndex = 0;
71 71
72 if (HTMLTableSectionElement* head = static_cast<HTMLTableElement*>(table)->t Head()) { 72 if (HTMLTableSectionElement* head = toHTMLTableElement(table)->tHead()) {
73 for (Node *row = head->firstChild(); row; row = row->nextSibling()) { 73 for (Node *row = head->firstChild(); row; row = row->nextSibling()) {
74 if (row == this) 74 if (row == this)
75 return rIndex; 75 return rIndex;
76 if (row->hasTagName(trTag)) 76 if (row->hasTagName(trTag))
77 ++rIndex; 77 ++rIndex;
78 } 78 }
79 } 79 }
80 80
81 for (Node *node = table->firstChild(); node; node = node->nextSibling()) { 81 for (Node *node = table->firstChild(); node; node = node->nextSibling()) {
82 if (node->hasTagName(tbodyTag)) { 82 if (node->hasTagName(tbodyTag)) {
83 HTMLTableSectionElement* section = static_cast<HTMLTableSectionEleme nt*>(node); 83 HTMLTableSectionElement* section = static_cast<HTMLTableSectionEleme nt*>(node);
84 for (Node* row = section->firstChild(); row; row = row->nextSibling( )) { 84 for (Node* row = section->firstChild(); row; row = row->nextSibling( )) {
85 if (row == this) 85 if (row == this)
86 return rIndex; 86 return rIndex;
87 if (row->hasTagName(trTag)) 87 if (row->hasTagName(trTag))
88 ++rIndex; 88 ++rIndex;
89 } 89 }
90 } 90 }
91 } 91 }
92 92
93 if (HTMLTableSectionElement* foot = static_cast<HTMLTableElement*>(table)->t Foot()) { 93 if (HTMLTableSectionElement* foot = toHTMLTableElement(table)->tFoot()) {
94 for (Node *row = foot->firstChild(); row; row = row->nextSibling()) { 94 for (Node *row = foot->firstChild(); row; row = row->nextSibling()) {
95 if (row == this) 95 if (row == this)
96 return rIndex; 96 return rIndex;
97 if (row->hasTagName(trTag)) 97 if (row->hasTagName(trTag))
98 ++rIndex; 98 ++rIndex;
99 } 99 }
100 } 100 }
101 101
102 // We get here for rows that are in <thead> or <tfoot> sections other than t he main header and footer. 102 // We get here for rows that are in <thead> or <tfoot> sections other than t he main header and footer.
103 return -1; 103 return -1;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 { 158 {
159 return ensureCachedHTMLCollection(TRCells); 159 return ensureCachedHTMLCollection(TRCells);
160 } 160 }
161 161
162 void HTMLTableRowElement::setCells(HTMLCollection*, ExceptionCode& ec) 162 void HTMLTableRowElement::setCells(HTMLCollection*, ExceptionCode& ec)
163 { 163 {
164 ec = NoModificationAllowedError; 164 ec = NoModificationAllowedError;
165 } 165 }
166 166
167 } 167 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLTablePartElement.cpp ('k') | Source/core/html/HTMLTableRowsCollection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698