OLD | NEW |
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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 return m_top.get(); | 388 return m_top.get(); |
389 } | 389 } |
390 | 390 |
391 HTMLStackItem* HTMLElementStack::oneBelowTop() const | 391 HTMLStackItem* HTMLElementStack::oneBelowTop() const |
392 { | 392 { |
393 // We should never call this if there are fewer than 2 elements on the stack
. | 393 // We should never call this if there are fewer than 2 elements on the stack
. |
394 ASSERT(m_top); | 394 ASSERT(m_top); |
395 ASSERT(m_top->next()); | 395 ASSERT(m_top->next()); |
396 if (m_top->next()->stackItem()->isElementNode()) | 396 if (m_top->next()->stackItem()->isElementNode()) |
397 return m_top->next()->stackItem().get(); | 397 return m_top->next()->stackItem().get(); |
398 return 0; | 398 return nullptr; |
399 } | 399 } |
400 | 400 |
401 void HTMLElementStack::removeHTMLHeadElement(Element* element) | 401 void HTMLElementStack::removeHTMLHeadElement(Element* element) |
402 { | 402 { |
403 ASSERT(m_headElement == element); | 403 ASSERT(m_headElement == element); |
404 if (m_top->element() == element) { | 404 if (m_top->element() == element) { |
405 popHTMLHeadElement(); | 405 popHTMLHeadElement(); |
406 return; | 406 return; |
407 } | 407 } |
408 m_headElement = nullptr; | 408 m_headElement = nullptr; |
409 removeNonTopCommon(element); | 409 removeNonTopCommon(element); |
410 } | 410 } |
411 | 411 |
412 void HTMLElementStack::remove(Element* element) | 412 void HTMLElementStack::remove(Element* element) |
413 { | 413 { |
414 ASSERT(!isHTMLHeadElement(element)); | 414 ASSERT(!isHTMLHeadElement(element)); |
415 if (m_top->element() == element) { | 415 if (m_top->element() == element) { |
416 pop(); | 416 pop(); |
417 return; | 417 return; |
418 } | 418 } |
419 removeNonTopCommon(element); | 419 removeNonTopCommon(element); |
420 } | 420 } |
421 | 421 |
422 HTMLElementStack::ElementRecord* HTMLElementStack::find(Element* element) const | 422 HTMLElementStack::ElementRecord* HTMLElementStack::find(Element* element) const |
423 { | 423 { |
424 for (ElementRecord* pos = m_top.get(); pos; pos = pos->next()) { | 424 for (ElementRecord* pos = m_top.get(); pos; pos = pos->next()) { |
425 if (pos->node() == element) | 425 if (pos->node() == element) |
426 return pos; | 426 return pos; |
427 } | 427 } |
428 return 0; | 428 return nullptr; |
429 } | 429 } |
430 | 430 |
431 HTMLElementStack::ElementRecord* HTMLElementStack::topmost(const AtomicString& t
agName) const | 431 HTMLElementStack::ElementRecord* HTMLElementStack::topmost(const AtomicString& t
agName) const |
432 { | 432 { |
433 for (ElementRecord* pos = m_top.get(); pos; pos = pos->next()) { | 433 for (ElementRecord* pos = m_top.get(); pos; pos = pos->next()) { |
434 if (pos->stackItem()->matchesHTMLTag(tagName)) | 434 if (pos->stackItem()->matchesHTMLTag(tagName)) |
435 return pos; | 435 return pos; |
436 } | 436 } |
437 return 0; | 437 return nullptr; |
438 } | 438 } |
439 | 439 |
440 bool HTMLElementStack::contains(Element* element) const | 440 bool HTMLElementStack::contains(Element* element) const |
441 { | 441 { |
442 return !!find(element); | 442 return !!find(element); |
443 } | 443 } |
444 | 444 |
445 bool HTMLElementStack::contains(const AtomicString& tagName) const | 445 bool HTMLElementStack::contains(const AtomicString& tagName) const |
446 { | 446 { |
447 return !!topmost(tagName); | 447 return !!topmost(tagName); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 HTMLElementStack::ElementRecord* HTMLElementStack::furthestBlockForFormattingEle
ment(Element* formattingElement) const | 606 HTMLElementStack::ElementRecord* HTMLElementStack::furthestBlockForFormattingEle
ment(Element* formattingElement) const |
607 { | 607 { |
608 ElementRecord* furthestBlock = 0; | 608 ElementRecord* furthestBlock = 0; |
609 for (ElementRecord* pos = m_top.get(); pos; pos = pos->next()) { | 609 for (ElementRecord* pos = m_top.get(); pos; pos = pos->next()) { |
610 if (pos->element() == formattingElement) | 610 if (pos->element() == formattingElement) |
611 return furthestBlock; | 611 return furthestBlock; |
612 if (pos->stackItem()->isSpecialNode()) | 612 if (pos->stackItem()->isSpecialNode()) |
613 furthestBlock = pos; | 613 furthestBlock = pos; |
614 } | 614 } |
615 ASSERT_NOT_REACHED(); | 615 ASSERT_NOT_REACHED(); |
616 return 0; | 616 return nullptr; |
617 } | 617 } |
618 | 618 |
619 void HTMLElementStack::trace(Visitor* visitor) | 619 void HTMLElementStack::trace(Visitor* visitor) |
620 { | 620 { |
621 visitor->trace(m_top); | 621 visitor->trace(m_top); |
622 visitor->trace(m_rootNode); | 622 visitor->trace(m_rootNode); |
623 visitor->trace(m_headElement); | 623 visitor->trace(m_headElement); |
624 visitor->trace(m_bodyElement); | 624 visitor->trace(m_bodyElement); |
625 } | 625 } |
626 | 626 |
627 #ifndef NDEBUG | 627 #ifndef NDEBUG |
628 | 628 |
629 void HTMLElementStack::show() | 629 void HTMLElementStack::show() |
630 { | 630 { |
631 for (ElementRecord* record = m_top.get(); record; record = record->next()) | 631 for (ElementRecord* record = m_top.get(); record; record = record->next()) |
632 record->element()->showNode(); | 632 record->element()->showNode(); |
633 } | 633 } |
634 | 634 |
635 #endif | 635 #endif |
636 | 636 |
637 } | 637 } |
OLD | NEW |