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

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

Issue 171663005: Consistently use ElementTraversal API when looking for an Element (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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/HTMLObjectElement.cpp ('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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 ScriptWrappable::init(this); 58 ScriptWrappable::init(this);
59 } 59 }
60 60
61 PassRefPtr<HTMLTableElement> HTMLTableElement::create(Document& document) 61 PassRefPtr<HTMLTableElement> HTMLTableElement::create(Document& document)
62 { 62 {
63 return adoptRef(new HTMLTableElement(document)); 63 return adoptRef(new HTMLTableElement(document));
64 } 64 }
65 65
66 HTMLTableCaptionElement* HTMLTableElement::caption() const 66 HTMLTableCaptionElement* HTMLTableElement::caption() const
67 { 67 {
68 for (Node* child = firstChild(); child; child = child->nextSibling()) { 68 for (Element* child = ElementTraversal::firstWithin(*this); child; child = E lementTraversal::nextSibling(*child)) {
69 if (child->hasTagName(captionTag)) 69 if (child->hasTagName(captionTag))
70 return toHTMLTableCaptionElement(child); 70 return toHTMLTableCaptionElement(child);
71 } 71 }
72 return 0; 72 return 0;
73 } 73 }
74 74
75 void HTMLTableElement::setCaption(PassRefPtr<HTMLTableCaptionElement> newCaption , ExceptionState& exceptionState) 75 void HTMLTableElement::setCaption(PassRefPtr<HTMLTableCaptionElement> newCaption , ExceptionState& exceptionState)
76 { 76 {
77 deleteCaption(); 77 deleteCaption();
78 insertBefore(newCaption, firstChild(), exceptionState); 78 insertBefore(newCaption, firstChild(), exceptionState);
79 } 79 }
80 80
81 HTMLTableSectionElement* HTMLTableElement::tHead() const 81 HTMLTableSectionElement* HTMLTableElement::tHead() const
82 { 82 {
83 for (Node* child = firstChild(); child; child = child->nextSibling()) { 83 for (Element* child = ElementTraversal::firstWithin(*this); child; child = E lementTraversal::nextSibling(*child)) {
84 if (child->hasTagName(theadTag)) 84 if (child->hasTagName(theadTag))
85 return toHTMLTableSectionElement(child); 85 return toHTMLTableSectionElement(child);
86 } 86 }
87 return 0; 87 return 0;
88 } 88 }
89 89
90 void HTMLTableElement::setTHead(PassRefPtr<HTMLTableSectionElement> newHead, Exc eptionState& exceptionState) 90 void HTMLTableElement::setTHead(PassRefPtr<HTMLTableSectionElement> newHead, Exc eptionState& exceptionState)
91 { 91 {
92 deleteTHead(); 92 deleteTHead();
93 93
94 Node* child; 94 Element* child;
95 for (child = firstChild(); child; child = child->nextSibling()) 95 for (child = ElementTraversal::firstWithin(*this); child; child = ElementTra versal::nextSibling(*child)) {
96 if (child->isElementNode() && !child->hasTagName(captionTag) && !child-> hasTagName(colgroupTag)) 96 if (!child->hasTagName(captionTag) && !child->hasTagName(colgroupTag))
97 break; 97 break;
98 }
98 99
99 insertBefore(newHead, child, exceptionState); 100 insertBefore(newHead, child, exceptionState);
100 } 101 }
101 102
102 HTMLTableSectionElement* HTMLTableElement::tFoot() const 103 HTMLTableSectionElement* HTMLTableElement::tFoot() const
103 { 104 {
104 for (Node* child = firstChild(); child; child = child->nextSibling()) { 105 for (Element* child = ElementTraversal::firstWithin(*this); child; child = E lementTraversal::nextSibling(*child)) {
105 if (child->hasTagName(tfootTag)) 106 if (child->hasTagName(tfootTag))
106 return toHTMLTableSectionElement(child); 107 return toHTMLTableSectionElement(child);
107 } 108 }
108 return 0; 109 return 0;
109 } 110 }
110 111
111 void HTMLTableElement::setTFoot(PassRefPtr<HTMLTableSectionElement> newFoot, Exc eptionState& exceptionState) 112 void HTMLTableElement::setTFoot(PassRefPtr<HTMLTableSectionElement> newFoot, Exc eptionState& exceptionState)
112 { 113 {
113 deleteTFoot(); 114 deleteTFoot();
114 115
115 Node* child; 116 Element* child;
116 for (child = firstChild(); child; child = child->nextSibling()) 117 for (child = ElementTraversal::firstWithin(*this); child; child = ElementTra versal::nextSibling(*child)) {
117 if (child->isElementNode() && !child->hasTagName(captionTag) && !child-> hasTagName(colgroupTag) && !child->hasTagName(theadTag)) 118 if (!child->hasTagName(captionTag) && !child->hasTagName(colgroupTag) && !child->hasTagName(theadTag))
118 break; 119 break;
120 }
119 121
120 insertBefore(newFoot, child, exceptionState); 122 insertBefore(newFoot, child, exceptionState);
121 } 123 }
122 124
123 PassRefPtr<HTMLElement> HTMLTableElement::createTHead() 125 PassRefPtr<HTMLElement> HTMLTableElement::createTHead()
124 { 126 {
125 if (HTMLTableSectionElement* existingHead = tHead()) 127 if (HTMLTableSectionElement* existingHead = tHead())
126 return existingHead; 128 return existingHead;
127 RefPtr<HTMLTableSectionElement> head = HTMLTableSectionElement::create(thead Tag, document()); 129 RefPtr<HTMLTableSectionElement> head = HTMLTableSectionElement::create(thead Tag, document());
128 setTHead(head, IGNORE_EXCEPTION); 130 setTHead(head, IGNORE_EXCEPTION);
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 { 569 {
568 return getAttribute(rulesAttr); 570 return getAttribute(rulesAttr);
569 } 571 }
570 572
571 const AtomicString& HTMLTableElement::summary() const 573 const AtomicString& HTMLTableElement::summary() const
572 { 574 {
573 return getAttribute(summaryAttr); 575 return getAttribute(summaryAttr);
574 } 576 }
575 577
576 } 578 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLObjectElement.cpp ('k') | Source/core/html/HTMLTableRowElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698