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

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

Issue 405973004: Optimize / clean up hasTagName() call sites (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 | 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, 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 } 70 }
71 71
72 void HTMLTableElement::setCaption(PassRefPtrWillBeRawPtr<HTMLTableCaptionElement > newCaption, ExceptionState& exceptionState) 72 void HTMLTableElement::setCaption(PassRefPtrWillBeRawPtr<HTMLTableCaptionElement > newCaption, ExceptionState& exceptionState)
73 { 73 {
74 deleteCaption(); 74 deleteCaption();
75 insertBefore(newCaption, firstChild(), exceptionState); 75 insertBefore(newCaption, firstChild(), exceptionState);
76 } 76 }
77 77
78 HTMLTableSectionElement* HTMLTableElement::tHead() const 78 HTMLTableSectionElement* HTMLTableElement::tHead() const
79 { 79 {
80 for (Element* child = ElementTraversal::firstWithin(*this); child; child = E lementTraversal::nextSibling(*child)) { 80 for (HTMLElement* child = Traversal<HTMLElement>::firstWithin(*this); child; child = Traversal<HTMLElement>::nextSibling(*child)) {
81 if (child->hasTagName(theadTag)) 81 if (child->hasTagName(theadTag))
82 return toHTMLTableSectionElement(child); 82 return toHTMLTableSectionElement(child);
83 } 83 }
84 return 0; 84 return 0;
85 } 85 }
86 86
87 void HTMLTableElement::setTHead(PassRefPtrWillBeRawPtr<HTMLTableSectionElement> newHead, ExceptionState& exceptionState) 87 void HTMLTableElement::setTHead(PassRefPtrWillBeRawPtr<HTMLTableSectionElement> newHead, ExceptionState& exceptionState)
88 { 88 {
89 deleteTHead(); 89 deleteTHead();
90 90
91 Element* child; 91 HTMLElement* child;
92 for (child = ElementTraversal::firstWithin(*this); child; child = ElementTra versal::nextSibling(*child)) { 92 for (child = Traversal<HTMLElement>::firstWithin(*this); child; child = Trav ersal<HTMLElement>::nextSibling(*child)) {
93 if (!child->hasTagName(captionTag) && !child->hasTagName(colgroupTag)) 93 if (!child->hasTagName(captionTag) && !child->hasTagName(colgroupTag))
94 break; 94 break;
95 } 95 }
96 96
97 insertBefore(newHead, child, exceptionState); 97 insertBefore(newHead, child, exceptionState);
98 } 98 }
99 99
100 HTMLTableSectionElement* HTMLTableElement::tFoot() const 100 HTMLTableSectionElement* HTMLTableElement::tFoot() const
101 { 101 {
102 for (Element* child = ElementTraversal::firstWithin(*this); child; child = E lementTraversal::nextSibling(*child)) { 102 for (HTMLElement* child = Traversal<HTMLElement>::firstWithin(*this); child; child = Traversal<HTMLElement>::nextSibling(*child)) {
103 if (child->hasTagName(tfootTag)) 103 if (child->hasTagName(tfootTag))
104 return toHTMLTableSectionElement(child); 104 return toHTMLTableSectionElement(child);
105 } 105 }
106 return 0; 106 return 0;
107 } 107 }
108 108
109 void HTMLTableElement::setTFoot(PassRefPtrWillBeRawPtr<HTMLTableSectionElement> newFoot, ExceptionState& exceptionState) 109 void HTMLTableElement::setTFoot(PassRefPtrWillBeRawPtr<HTMLTableSectionElement> newFoot, ExceptionState& exceptionState)
110 { 110 {
111 deleteTFoot(); 111 deleteTFoot();
112 112
113 Element* child; 113 HTMLElement* child;
114 for (child = ElementTraversal::firstWithin(*this); child; child = ElementTra versal::nextSibling(*child)) { 114 for (child = Traversal<HTMLElement>::firstWithin(*this); child; child = Trav ersal<HTMLElement>::nextSibling(*child)) {
115 if (!child->hasTagName(captionTag) && !child->hasTagName(colgroupTag) && !child->hasTagName(theadTag)) 115 if (!child->hasTagName(captionTag) && !child->hasTagName(colgroupTag) && !child->hasTagName(theadTag))
116 break; 116 break;
117 } 117 }
118 118
119 insertBefore(newFoot, child, exceptionState); 119 insertBefore(newFoot, child, exceptionState);
120 } 120 }
121 121
122 PassRefPtrWillBeRawPtr<HTMLElement> HTMLTableElement::createTHead() 122 PassRefPtrWillBeRawPtr<HTMLElement> HTMLTableElement::createTHead()
123 { 123 {
124 if (HTMLTableSectionElement* existingHead = tHead()) 124 if (HTMLTableSectionElement* existingHead = tHead())
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 return caption.release(); 165 return caption.release();
166 } 166 }
167 167
168 void HTMLTableElement::deleteCaption() 168 void HTMLTableElement::deleteCaption()
169 { 169 {
170 removeChild(caption(), IGNORE_EXCEPTION); 170 removeChild(caption(), IGNORE_EXCEPTION);
171 } 171 }
172 172
173 HTMLTableSectionElement* HTMLTableElement::lastBody() const 173 HTMLTableSectionElement* HTMLTableElement::lastBody() const
174 { 174 {
175 for (Node* child = lastChild(); child; child = child->previousSibling()) { 175 for (HTMLElement* child = Traversal<HTMLElement>::lastChild(*this); child; c hild = Traversal<HTMLElement>::previousSibling(*child)) {
176 if (child->hasTagName(tbodyTag)) 176 if (child->hasTagName(tbodyTag))
177 return toHTMLTableSectionElement(child); 177 return toHTMLTableSectionElement(child);
178 } 178 }
179 return 0; 179 return 0;
180 } 180 }
181 181
182 PassRefPtrWillBeRawPtr<HTMLElement> HTMLTableElement::insertRow(ExceptionState& exceptionState) 182 PassRefPtrWillBeRawPtr<HTMLElement> HTMLTableElement::insertRow(ExceptionState& exceptionState)
183 { 183 {
184 // The default 'index' argument value is -1. 184 // The default 'index' argument value is -1.
185 return insertRow(-1, exceptionState); 185 return insertRow(-1, exceptionState);
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 return getAttribute(summaryAttr); 576 return getAttribute(summaryAttr);
577 } 577 }
578 578
579 void HTMLTableElement::trace(Visitor* visitor) 579 void HTMLTableElement::trace(Visitor* visitor)
580 { 580 {
581 visitor->trace(m_sharedCellStyle); 581 visitor->trace(m_sharedCellStyle);
582 HTMLElement::trace(visitor); 582 HTMLElement::trace(visitor);
583 } 583 }
584 584
585 } 585 }
OLDNEW
« no previous file with comments | « Source/core/editing/ReplaceSelectionCommand.cpp ('k') | Source/core/html/HTMLTableRowElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698