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

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

Issue 262163008: HTMLTableSectionElement.insertRow(0) / HTMLTableRowElement.insertCell(0) do not behave correctly (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix nits 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.cpp ('k') | no next file » | 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, 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 PassRefPtr<HTMLElement> HTMLTableSectionElement::insertRow(int index, ExceptionS tate& exceptionState) 66 PassRefPtr<HTMLElement> HTMLTableSectionElement::insertRow(int index, ExceptionS tate& exceptionState)
67 { 67 {
68 RefPtr<HTMLCollection> children = rows(); 68 RefPtr<HTMLCollection> children = rows();
69 int numRows = children ? static_cast<int>(children->length()) : 0; 69 int numRows = children ? static_cast<int>(children->length()) : 0;
70 if (index < -1 || index > numRows) { 70 if (index < -1 || index > numRows) {
71 exceptionState.throwDOMException(IndexSizeError, "The provided index (" + String::number(index) + " is outside the range [-1, " + String::number(numRows ) + "]."); 71 exceptionState.throwDOMException(IndexSizeError, "The provided index (" + String::number(index) + " is outside the range [-1, " + String::number(numRows ) + "].");
72 return nullptr; 72 return nullptr;
73 } 73 }
74 74
75 RefPtr<HTMLTableRowElement> row = HTMLTableRowElement::create(document()); 75 RefPtr<HTMLTableRowElement> row = HTMLTableRowElement::create(document());
76 if (numRows == index || index == -1) { 76 if (numRows == index || index == -1)
77 appendChild(row, exceptionState); 77 appendChild(row, exceptionState);
78 } else { 78 else
79 Node* n = index ? children->item(index) : firstChild(); 79 insertBefore(row, children->item(index), exceptionState);
80 insertBefore(row, n, exceptionState);
81 }
82 return row.release(); 80 return row.release();
83 } 81 }
84 82
85 void HTMLTableSectionElement::deleteRow(int index, ExceptionState& exceptionStat e) 83 void HTMLTableSectionElement::deleteRow(int index, ExceptionState& exceptionStat e)
86 { 84 {
87 RefPtr<HTMLCollection> children = rows(); 85 RefPtr<HTMLCollection> children = rows();
88 int numRows = children ? (int)children->length() : 0; 86 int numRows = children ? (int)children->length() : 0;
89 if (index == -1) 87 if (index == -1)
90 index = numRows - 1; 88 index = numRows - 1;
91 if (index >= 0 && index < numRows) { 89 if (index >= 0 && index < numRows) {
(...skipping 11 matching lines...) Expand all
103 ++rowCount; 101 ++rowCount;
104 return rowCount; 102 return rowCount;
105 } 103 }
106 104
107 PassRefPtr<HTMLCollection> HTMLTableSectionElement::rows() 105 PassRefPtr<HTMLCollection> HTMLTableSectionElement::rows()
108 { 106 {
109 return ensureCachedHTMLCollection(TSectionRows); 107 return ensureCachedHTMLCollection(TSectionRows);
110 } 108 }
111 109
112 } 110 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLTableRowElement.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698