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

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

Issue 195813003: Use new is*Element() helper functions further more in HTML code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix bad assertion Created 6 years, 9 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 | Annotate | Revision Log
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 { 48 {
49 return adoptRef(new HTMLTableRowElement(document)); 49 return adoptRef(new HTMLTableRowElement(document));
50 } 50 }
51 51
52 int HTMLTableRowElement::rowIndex() const 52 int HTMLTableRowElement::rowIndex() const
53 { 53 {
54 ContainerNode* table = parentNode(); 54 ContainerNode* table = parentNode();
55 if (!table) 55 if (!table)
56 return -1; 56 return -1;
57 table = table->parentNode(); 57 table = table->parentNode();
58 if (!table || !table->hasTagName(tableTag)) 58 if (!isHTMLTableElement(table))
59 return -1; 59 return -1;
60 60
61 // To match Firefox, the row indices work like this: 61 // To match Firefox, the row indices work like this:
62 // Rows from the first <thead> are numbered before all <tbody> rows. 62 // Rows from the first <thead> are numbered before all <tbody> rows.
63 // Rows from the first <tfoot> are numbered after all <tbody> rows. 63 // Rows from the first <tfoot> are numbered after all <tbody> rows.
64 // Rows from other <thead> and <tfoot> elements don't get row indices at a ll. 64 // Rows from other <thead> and <tfoot> elements don't get row indices at a ll.
65 65
66 int rIndex = 0; 66 int rIndex = 0;
67 67
68 if (HTMLTableSectionElement* head = toHTMLTableElement(table)->tHead()) { 68 if (HTMLTableSectionElement* head = toHTMLTableElement(table)->tHead()) {
(...skipping 23 matching lines...) Expand all
92 } 92 }
93 } 93 }
94 94
95 // We get here for rows that are in <thead> or <tfoot> sections other than t he main header and footer. 95 // We get here for rows that are in <thead> or <tfoot> sections other than t he main header and footer.
96 return -1; 96 return -1;
97 } 97 }
98 98
99 int HTMLTableRowElement::sectionRowIndex() const 99 int HTMLTableRowElement::sectionRowIndex() const
100 { 100 {
101 int rIndex = 0; 101 int rIndex = 0;
102 const Node *n = this; 102 const Node* n = this;
103 do { 103 do {
104 n = n->previousSibling(); 104 n = n->previousSibling();
105 if (n && n->hasTagName(trTag)) 105 if (n && isHTMLTableRowElement(*n))
106 rIndex++; 106 ++rIndex;
107 } 107 } while (n);
108 while (n);
109 108
110 return rIndex; 109 return rIndex;
111 } 110 }
112 111
113 PassRefPtr<HTMLElement> HTMLTableRowElement::insertCell(int index, ExceptionStat e& exceptionState) 112 PassRefPtr<HTMLElement> HTMLTableRowElement::insertCell(int index, ExceptionStat e& exceptionState)
114 { 113 {
115 RefPtr<HTMLCollection> children = cells(); 114 RefPtr<HTMLCollection> children = cells();
116 int numCells = children ? children->length() : 0; 115 int numCells = children ? children->length() : 0;
117 if (index < -1 || index > numCells) { 116 if (index < -1 || index > numCells) {
118 exceptionState.throwDOMException(IndexSizeError, "The value provided (" + String::number(index) + ") is outside the range [-1, " + String::number(numCel ls) + "]."); 117 exceptionState.throwDOMException(IndexSizeError, "The value provided (" + String::number(index) + ") is outside the range [-1, " + String::number(numCel ls) + "].");
(...skipping 27 matching lines...) Expand all
146 exceptionState.throwDOMException(IndexSizeError, "The value provided (" + String::number(index) + ") is outside the range [0, " + String::number(numCell s) + ")."); 145 exceptionState.throwDOMException(IndexSizeError, "The value provided (" + String::number(index) + ") is outside the range [0, " + String::number(numCell s) + ").");
147 } 146 }
148 } 147 }
149 148
150 PassRefPtr<HTMLCollection> HTMLTableRowElement::cells() 149 PassRefPtr<HTMLCollection> HTMLTableRowElement::cells()
151 { 150 {
152 return ensureCachedHTMLCollection(TRCells); 151 return ensureCachedHTMLCollection(TRCells);
153 } 152 }
154 153
155 } 154 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698