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

Side by Side Diff: Source/core/html/parser/HTMLElementStack.cpp

Issue 198453003: Use new is*Element() helper functions more in HTML code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 9 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) 2010 Google, Inc. All Rights Reserved. 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved.
3 * Copyright (C) 2011 Apple Inc. All rights reserved. 3 * Copyright (C) 2011 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 13 matching lines...) Expand all
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27 #include "config.h" 27 #include "config.h"
28 #include "core/html/parser/HTMLElementStack.h" 28 #include "core/html/parser/HTMLElementStack.h"
29 29
30 #include "HTMLNames.h" 30 #include "HTMLNames.h"
31 #include "MathMLNames.h" 31 #include "MathMLNames.h"
32 #include "SVGNames.h" 32 #include "SVGNames.h"
33 #include "core/dom/Element.h" 33 #include "core/dom/Element.h"
34 #include "core/html/HTMLElement.h"
34 35
35 namespace WebCore { 36 namespace WebCore {
36 37
37 using namespace HTMLNames; 38 using namespace HTMLNames;
38 39
39 40
40 namespace { 41 namespace {
41 42
42 inline bool isRootNode(HTMLStackItem* item) 43 inline bool isRootNode(HTMLStackItem* item)
43 { 44 {
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 if (m_top->element() == element) { 394 if (m_top->element() == element) {
394 popHTMLHeadElement(); 395 popHTMLHeadElement();
395 return; 396 return;
396 } 397 }
397 m_headElement = 0; 398 m_headElement = 0;
398 removeNonTopCommon(element); 399 removeNonTopCommon(element);
399 } 400 }
400 401
401 void HTMLElementStack::remove(Element* element) 402 void HTMLElementStack::remove(Element* element)
402 { 403 {
403 ASSERT(!element->hasTagName(HTMLNames::headTag)); 404 ASSERT(!isHTMLHeadElement(element));
404 if (m_top->element() == element) { 405 if (m_top->element() == element) {
405 pop(); 406 pop();
406 return; 407 return;
407 } 408 }
408 removeNonTopCommon(element); 409 removeNonTopCommon(element);
409 } 410 }
410 411
411 HTMLElementStack::ElementRecord* HTMLElementStack::find(Element* element) const 412 HTMLElementStack::ElementRecord* HTMLElementStack::find(Element* element) const
412 { 413 {
413 for (ElementRecord* pos = m_top.get(); pos; pos = pos->next()) { 414 for (ElementRecord* pos = m_top.get(); pos; pos = pos->next()) {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 ASSERT(!topStackItem()->hasTagName(headTag) || !m_headElement); 570 ASSERT(!topStackItem()->hasTagName(headTag) || !m_headElement);
570 ASSERT(!topStackItem()->hasTagName(bodyTag) || !m_bodyElement); 571 ASSERT(!topStackItem()->hasTagName(bodyTag) || !m_bodyElement);
571 top()->finishParsingChildren(); 572 top()->finishParsingChildren();
572 m_top = m_top->releaseNext(); 573 m_top = m_top->releaseNext();
573 574
574 m_stackDepth--; 575 m_stackDepth--;
575 } 576 }
576 577
577 void HTMLElementStack::removeNonTopCommon(Element* element) 578 void HTMLElementStack::removeNonTopCommon(Element* element)
578 { 579 {
579 ASSERT(!element->hasTagName(htmlTag)); 580 ASSERT(!isHTMLHtmlElement(element));
580 ASSERT(!element->hasTagName(bodyTag)); 581 ASSERT(!isHTMLBodyElement(element));
581 ASSERT(top() != element); 582 ASSERT(top() != element);
582 for (ElementRecord* pos = m_top.get(); pos; pos = pos->next()) { 583 for (ElementRecord* pos = m_top.get(); pos; pos = pos->next()) {
583 if (pos->next()->element() == element) { 584 if (pos->next()->element() == element) {
584 // FIXME: Is it OK to call finishParsingChildren() 585 // FIXME: Is it OK to call finishParsingChildren()
585 // when the children aren't actually finished? 586 // when the children aren't actually finished?
586 element->finishParsingChildren(); 587 element->finishParsingChildren();
587 pos->setNext(pos->next()->releaseNext()); 588 pos->setNext(pos->next()->releaseNext());
588 m_stackDepth--; 589 m_stackDepth--;
589 return; 590 return;
590 } 591 }
(...skipping 18 matching lines...) Expand all
609 610
610 void HTMLElementStack::show() 611 void HTMLElementStack::show()
611 { 612 {
612 for (ElementRecord* record = m_top.get(); record; record = record->next()) 613 for (ElementRecord* record = m_top.get(); record; record = record->next())
613 record->element()->showNode(); 614 record->element()->showNode();
614 } 615 }
615 616
616 #endif 617 #endif
617 618
618 } 619 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698