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

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

Issue 263323004: HTMLTableRowElement.insertCell()'s argument default value should be -1 (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 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
« no previous file with comments | « Source/core/html/HTMLTableRowElement.h ('k') | Source/core/html/HTMLTableRowElement.idl » ('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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 const Node* n = this; 112 const Node* n = this;
113 do { 113 do {
114 n = n->previousSibling(); 114 n = n->previousSibling();
115 if (n && isHTMLTableRowElement(*n)) 115 if (n && isHTMLTableRowElement(*n))
116 ++rIndex; 116 ++rIndex;
117 } while (n); 117 } while (n);
118 118
119 return rIndex; 119 return rIndex;
120 } 120 }
121 121
122 PassRefPtr<HTMLElement> HTMLTableRowElement::insertCell(ExceptionState& exceptio nState)
123 {
124 // The default 'index' argument value is -1.
125 return insertCell(-1, exceptionState);
126 }
127
122 PassRefPtr<HTMLElement> HTMLTableRowElement::insertCell(int index, ExceptionStat e& exceptionState) 128 PassRefPtr<HTMLElement> HTMLTableRowElement::insertCell(int index, ExceptionStat e& exceptionState)
123 { 129 {
124 RefPtr<HTMLCollection> children = cells(); 130 RefPtr<HTMLCollection> children = cells();
125 int numCells = children ? children->length() : 0; 131 int numCells = children ? children->length() : 0;
126 if (index < -1 || index > numCells) { 132 if (index < -1 || index > numCells) {
127 exceptionState.throwDOMException(IndexSizeError, "The value provided (" + String::number(index) + ") is outside the range [-1, " + String::number(numCel ls) + "]."); 133 exceptionState.throwDOMException(IndexSizeError, "The value provided (" + String::number(index) + ") is outside the range [-1, " + String::number(numCel ls) + "].");
128 return nullptr; 134 return nullptr;
129 } 135 }
130 136
131 RefPtr<HTMLTableCellElement> cell = HTMLTableCellElement::create(tdTag, docu ment()); 137 RefPtr<HTMLTableCellElement> cell = HTMLTableCellElement::create(tdTag, docu ment());
132 if (index < 0 || index >= numCells) 138 if (index < 0 || index >= numCells)
133 appendChild(cell, exceptionState); 139 appendChild(cell, exceptionState);
134 else { 140 else {
135 Node* n; 141 Node* n;
136 if (index < 1) 142 if (index < 1)
137 n = firstChild(); 143 n = firstChild();
arv (Not doing code reviews) 2014/05/06 18:19:50 This should be firstElementChild as well.
Inactive 2014/05/06 18:21:38 Do you mind if I fix those in a separate patch? I
138 else 144 else
139 n = children->item(index); 145 n = children->item(index);
140 insertBefore(cell, n, exceptionState); 146 insertBefore(cell, n, exceptionState);
141 } 147 }
142 return cell.release(); 148 return cell.release();
143 } 149 }
144 150
145 void HTMLTableRowElement::deleteCell(int index, ExceptionState& exceptionState) 151 void HTMLTableRowElement::deleteCell(int index, ExceptionState& exceptionState)
146 { 152 {
147 RefPtr<HTMLCollection> children = cells(); 153 RefPtr<HTMLCollection> children = cells();
148 int numCells = children ? children->length() : 0; 154 int numCells = children ? children->length() : 0;
149 if (index == -1) 155 if (index == -1)
150 index = numCells-1; 156 index = numCells-1;
151 if (index >= 0 && index < numCells) { 157 if (index >= 0 && index < numCells) {
152 RefPtr<Element> cell = children->item(index); 158 RefPtr<Element> cell = children->item(index);
153 HTMLElement::removeChild(cell.get(), exceptionState); 159 HTMLElement::removeChild(cell.get(), exceptionState);
154 } else { 160 } else {
155 exceptionState.throwDOMException(IndexSizeError, "The value provided (" + String::number(index) + ") is outside the range [0, " + String::number(numCell s) + ")."); 161 exceptionState.throwDOMException(IndexSizeError, "The value provided (" + String::number(index) + ") is outside the range [0, " + String::number(numCell s) + ").");
156 } 162 }
157 } 163 }
158 164
159 PassRefPtr<HTMLCollection> HTMLTableRowElement::cells() 165 PassRefPtr<HTMLCollection> HTMLTableRowElement::cells()
160 { 166 {
161 return ensureCachedHTMLCollection(TRCells); 167 return ensureCachedHTMLCollection(TRCells);
162 } 168 }
163 169
164 } 170 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLTableRowElement.h ('k') | Source/core/html/HTMLTableRowElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698