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

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

Issue 471173003: Introduce HasHTMLTagName functor and use it with ElementTraversal (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add comment Created 6 years, 4 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/HTMLElement.h ('k') | Source/core/html/HTMLTableRowElement.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, 2008, 2010, 2011 Apple Inc. All rights reserved. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2010, 2011 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 71 }
72 72
73 void HTMLTableElement::setCaption(PassRefPtrWillBeRawPtr<HTMLTableCaptionElement > newCaption, ExceptionState& exceptionState) 73 void HTMLTableElement::setCaption(PassRefPtrWillBeRawPtr<HTMLTableCaptionElement > newCaption, ExceptionState& exceptionState)
74 { 74 {
75 deleteCaption(); 75 deleteCaption();
76 insertBefore(newCaption, firstChild(), exceptionState); 76 insertBefore(newCaption, firstChild(), exceptionState);
77 } 77 }
78 78
79 HTMLTableSectionElement* HTMLTableElement::tHead() const 79 HTMLTableSectionElement* HTMLTableElement::tHead() const
80 { 80 {
81 for (HTMLElement* child = Traversal<HTMLElement>::firstChild(*this); child; child = Traversal<HTMLElement>::nextSibling(*child)) { 81 return toHTMLTableSectionElement(Traversal<HTMLElement>::firstChild(*this, H asHTMLTagName(theadTag)));
82 if (child->hasTagName(theadTag))
83 return toHTMLTableSectionElement(child);
84 }
85 return 0;
86 } 82 }
87 83
88 void HTMLTableElement::setTHead(PassRefPtrWillBeRawPtr<HTMLTableSectionElement> newHead, ExceptionState& exceptionState) 84 void HTMLTableElement::setTHead(PassRefPtrWillBeRawPtr<HTMLTableSectionElement> newHead, ExceptionState& exceptionState)
89 { 85 {
90 deleteTHead(); 86 deleteTHead();
91 87
92 HTMLElement* child; 88 HTMLElement* child;
93 for (child = Traversal<HTMLElement>::firstChild(*this); child; child = Trave rsal<HTMLElement>::nextSibling(*child)) { 89 for (child = Traversal<HTMLElement>::firstChild(*this); child; child = Trave rsal<HTMLElement>::nextSibling(*child)) {
94 if (!child->hasTagName(captionTag) && !child->hasTagName(colgroupTag)) 90 if (!child->hasTagName(captionTag) && !child->hasTagName(colgroupTag))
95 break; 91 break;
96 } 92 }
97 93
98 insertBefore(newHead, child, exceptionState); 94 insertBefore(newHead, child, exceptionState);
99 } 95 }
100 96
101 HTMLTableSectionElement* HTMLTableElement::tFoot() const 97 HTMLTableSectionElement* HTMLTableElement::tFoot() const
102 { 98 {
103 for (HTMLElement* child = Traversal<HTMLElement>::firstChild(*this); child; child = Traversal<HTMLElement>::nextSibling(*child)) { 99 return toHTMLTableSectionElement(Traversal<HTMLElement>::firstChild(*this, H asHTMLTagName(tfootTag)));
104 if (child->hasTagName(tfootTag))
105 return toHTMLTableSectionElement(child);
106 }
107 return 0;
108 } 100 }
109 101
110 void HTMLTableElement::setTFoot(PassRefPtrWillBeRawPtr<HTMLTableSectionElement> newFoot, ExceptionState& exceptionState) 102 void HTMLTableElement::setTFoot(PassRefPtrWillBeRawPtr<HTMLTableSectionElement> newFoot, ExceptionState& exceptionState)
111 { 103 {
112 deleteTFoot(); 104 deleteTFoot();
113 105
114 HTMLElement* child; 106 HTMLElement* child;
115 for (child = Traversal<HTMLElement>::firstChild(*this); child; child = Trave rsal<HTMLElement>::nextSibling(*child)) { 107 for (child = Traversal<HTMLElement>::firstChild(*this); child; child = Trave rsal<HTMLElement>::nextSibling(*child)) {
116 if (!child->hasTagName(captionTag) && !child->hasTagName(colgroupTag) && !child->hasTagName(theadTag)) 108 if (!child->hasTagName(captionTag) && !child->hasTagName(colgroupTag) && !child->hasTagName(theadTag))
117 break; 109 break;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 return caption.release(); 158 return caption.release();
167 } 159 }
168 160
169 void HTMLTableElement::deleteCaption() 161 void HTMLTableElement::deleteCaption()
170 { 162 {
171 removeChild(caption(), IGNORE_EXCEPTION); 163 removeChild(caption(), IGNORE_EXCEPTION);
172 } 164 }
173 165
174 HTMLTableSectionElement* HTMLTableElement::lastBody() const 166 HTMLTableSectionElement* HTMLTableElement::lastBody() const
175 { 167 {
176 for (HTMLElement* child = Traversal<HTMLElement>::lastChild(*this); child; c hild = Traversal<HTMLElement>::previousSibling(*child)) { 168 return toHTMLTableSectionElement(Traversal<HTMLElement>::lastChild(*this, Ha sHTMLTagName(tbodyTag)));
177 if (child->hasTagName(tbodyTag))
178 return toHTMLTableSectionElement(child);
179 }
180 return 0;
181 } 169 }
182 170
183 PassRefPtrWillBeRawPtr<HTMLElement> HTMLTableElement::insertRow(ExceptionState& exceptionState) 171 PassRefPtrWillBeRawPtr<HTMLElement> HTMLTableElement::insertRow(ExceptionState& exceptionState)
184 { 172 {
185 // The default 'index' argument value is -1. 173 // The default 'index' argument value is -1.
186 return insertRow(-1, exceptionState); 174 return insertRow(-1, exceptionState);
187 } 175 }
188 176
189 PassRefPtrWillBeRawPtr<HTMLElement> HTMLTableElement::insertRow(int index, Excep tionState& exceptionState) 177 PassRefPtrWillBeRawPtr<HTMLElement> HTMLTableElement::insertRow(int index, Excep tionState& exceptionState)
190 { 178 {
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 return getAttribute(summaryAttr); 565 return getAttribute(summaryAttr);
578 } 566 }
579 567
580 void HTMLTableElement::trace(Visitor* visitor) 568 void HTMLTableElement::trace(Visitor* visitor)
581 { 569 {
582 visitor->trace(m_sharedCellStyle); 570 visitor->trace(m_sharedCellStyle);
583 HTMLElement::trace(visitor); 571 HTMLElement::trace(visitor);
584 } 572 }
585 573
586 } 574 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLElement.h ('k') | Source/core/html/HTMLTableRowElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698