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 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 { | 592 { |
593 ASSERT(!shouldFosterParent()); | 593 ASSERT(!shouldFosterParent()); |
594 m_head = HTMLStackItem::create(createHTMLElement(token), token); | 594 m_head = HTMLStackItem::create(createHTMLElement(token), token); |
595 attachLater(currentNode(), m_head->element()); | 595 attachLater(currentNode(), m_head->element()); |
596 m_openElements.pushHTMLHeadElement(m_head); | 596 m_openElements.pushHTMLHeadElement(m_head); |
597 } | 597 } |
598 | 598 |
599 void HTMLConstructionSite::insertHTMLBodyElement(AtomicHTMLToken* token) | 599 void HTMLConstructionSite::insertHTMLBodyElement(AtomicHTMLToken* token) |
600 { | 600 { |
601 ASSERT(!shouldFosterParent()); | 601 ASSERT(!shouldFosterParent()); |
602 RefPtrWillBeRawPtr<Element> body = createHTMLElement(token); | 602 RefPtrWillBeRawPtr<HTMLElement> body = createHTMLElement(token); |
603 attachLater(currentNode(), body); | 603 attachLater(currentNode(), body); |
604 m_openElements.pushHTMLBodyElement(HTMLStackItem::create(body.release(), tok
en)); | 604 m_openElements.pushHTMLBodyElement(HTMLStackItem::create(body.release(), tok
en)); |
605 if (LocalFrame* frame = m_document->frame()) | 605 if (LocalFrame* frame = m_document->frame()) |
606 frame->loader().client()->dispatchWillInsertBody(); | 606 frame->loader().client()->dispatchWillInsertBody(); |
607 } | 607 } |
608 | 608 |
609 void HTMLConstructionSite::insertHTMLFormElement(AtomicHTMLToken* token, bool is
Demoted) | 609 void HTMLConstructionSite::insertHTMLFormElement(AtomicHTMLToken* token, bool is
Demoted) |
610 { | 610 { |
611 RefPtrWillBeRawPtr<Element> element = createHTMLElement(token); | 611 RefPtrWillBeRawPtr<HTMLElement> element = createHTMLElement(token); |
612 ASSERT(isHTMLFormElement(element)); | 612 ASSERT(isHTMLFormElement(element)); |
613 m_form = static_pointer_cast<HTMLFormElement>(element.release()); | 613 m_form = static_pointer_cast<HTMLFormElement>(element.release()); |
614 m_form->setDemoted(isDemoted); | 614 m_form->setDemoted(isDemoted); |
615 attachLater(currentNode(), m_form.get()); | 615 attachLater(currentNode(), m_form.get()); |
616 m_openElements.push(HTMLStackItem::create(m_form.get(), token)); | 616 m_openElements.push(HTMLStackItem::create(m_form.get(), token)); |
617 } | 617 } |
618 | 618 |
619 void HTMLConstructionSite::insertHTMLElement(AtomicHTMLToken* token) | 619 void HTMLConstructionSite::insertHTMLElement(AtomicHTMLToken* token) |
620 { | 620 { |
621 RefPtrWillBeRawPtr<Element> element = createHTMLElement(token); | 621 RefPtrWillBeRawPtr<HTMLElement> element = createHTMLElement(token); |
622 attachLater(currentNode(), element); | 622 attachLater(currentNode(), element); |
623 m_openElements.push(HTMLStackItem::create(element.release(), token)); | 623 m_openElements.push(HTMLStackItem::create(element.release(), token)); |
624 } | 624 } |
625 | 625 |
626 void HTMLConstructionSite::insertSelfClosingHTMLElement(AtomicHTMLToken* token) | 626 void HTMLConstructionSite::insertSelfClosingHTMLElement(AtomicHTMLToken* token) |
627 { | 627 { |
628 ASSERT(token->type() == HTMLToken::StartTag); | 628 ASSERT(token->type() == HTMLToken::StartTag); |
629 // Normally HTMLElementStack is responsible for calling finishParsingChildre
n, | 629 // Normally HTMLElementStack is responsible for calling finishParsingChildre
n, |
630 // but self-closing elements are never in the element stack so the stack | 630 // but self-closing elements are never in the element stack so the stack |
631 // doesn't get a chance to tell them that we're done parsing their children. | 631 // doesn't get a chance to tell them that we're done parsing their children. |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 return element.release(); | 736 return element.release(); |
737 } | 737 } |
738 | 738 |
739 inline Document& HTMLConstructionSite::ownerDocumentForCurrentNode() | 739 inline Document& HTMLConstructionSite::ownerDocumentForCurrentNode() |
740 { | 740 { |
741 if (isHTMLTemplateElement(*currentNode())) | 741 if (isHTMLTemplateElement(*currentNode())) |
742 return toHTMLTemplateElement(currentElement())->content()->document(); | 742 return toHTMLTemplateElement(currentElement())->content()->document(); |
743 return currentNode()->document(); | 743 return currentNode()->document(); |
744 } | 744 } |
745 | 745 |
746 PassRefPtrWillBeRawPtr<Element> HTMLConstructionSite::createHTMLElement(AtomicHT
MLToken* token) | 746 PassRefPtrWillBeRawPtr<HTMLElement> HTMLConstructionSite::createHTMLElement(Atom
icHTMLToken* token) |
747 { | 747 { |
748 Document& document = ownerDocumentForCurrentNode(); | 748 Document& document = ownerDocumentForCurrentNode(); |
749 // Only associate the element with the current form if we're creating the ne
w element | 749 // Only associate the element with the current form if we're creating the ne
w element |
750 // in a document with a browsing context (rather than in <template> contents
). | 750 // in a document with a browsing context (rather than in <template> contents
). |
751 HTMLFormElement* form = document.frame() ? m_form.get() : 0; | 751 HTMLFormElement* form = document.frame() ? m_form.get() : 0; |
752 // FIXME: This can't use HTMLConstructionSite::createElement because we | 752 // FIXME: This can't use HTMLConstructionSite::createElement because we |
753 // have to pass the current form element. We should rework form association | 753 // have to pass the current form element. We should rework form association |
754 // to occur after construction to allow better code sharing here. | 754 // to occur after construction to allow better code sharing here. |
755 RefPtrWillBeRawPtr<Element> element = HTMLElementFactory::createHTMLElement(
token->name(), document, form, true); | 755 RefPtrWillBeRawPtr<HTMLElement> element = HTMLElementFactory::createHTMLElem
ent(token->name(), document, form, true); |
756 setAttributes(element.get(), token, m_parserContentPolicy); | 756 setAttributes(element.get(), token, m_parserContentPolicy); |
757 ASSERT(element->isHTMLElement()); | |
758 return element.release(); | 757 return element.release(); |
759 } | 758 } |
760 | 759 |
761 PassRefPtrWillBeRawPtr<HTMLStackItem> HTMLConstructionSite::createElementFromSav
edToken(HTMLStackItem* item) | 760 PassRefPtrWillBeRawPtr<HTMLStackItem> HTMLConstructionSite::createElementFromSav
edToken(HTMLStackItem* item) |
762 { | 761 { |
763 RefPtrWillBeRawPtr<Element> element; | 762 RefPtrWillBeRawPtr<Element> element; |
764 // NOTE: Moving from item -> token -> item copies the Attribute vector twice
! | 763 // NOTE: Moving from item -> token -> item copies the Attribute vector twice
! |
765 AtomicHTMLToken fakeToken(HTMLToken::StartTag, item->localName(), item->attr
ibutes()); | 764 AtomicHTMLToken fakeToken(HTMLToken::StartTag, item->localName(), item->attr
ibutes()); |
766 if (item->namespaceURI() == HTMLNames::xhtmlNamespaceURI) | 765 if (item->namespaceURI() == HTMLNames::xhtmlNamespaceURI) |
767 element = createHTMLElement(&fakeToken); | 766 element = createHTMLElement(&fakeToken); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 } | 869 } |
871 | 870 |
872 void HTMLConstructionSite::PendingText::trace(Visitor* visitor) | 871 void HTMLConstructionSite::PendingText::trace(Visitor* visitor) |
873 { | 872 { |
874 visitor->trace(parent); | 873 visitor->trace(parent); |
875 visitor->trace(nextChild); | 874 visitor->trace(nextChild); |
876 } | 875 } |
877 | 876 |
878 | 877 |
879 } | 878 } |
OLD | NEW |