| 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 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 ASSERT(!shouldFosterParent()); | 589 ASSERT(!shouldFosterParent()); |
| 590 RefPtr<Element> body = createHTMLElement(token); | 590 RefPtr<Element> body = createHTMLElement(token); |
| 591 attachLater(currentNode(), body); | 591 attachLater(currentNode(), body); |
| 592 m_openElements.pushHTMLBodyElement(HTMLStackItem::create(body.release(), tok
en)); | 592 m_openElements.pushHTMLBodyElement(HTMLStackItem::create(body.release(), tok
en)); |
| 593 if (LocalFrame* frame = m_document->frame()) | 593 if (LocalFrame* frame = m_document->frame()) |
| 594 frame->loader().client()->dispatchWillInsertBody(); | 594 frame->loader().client()->dispatchWillInsertBody(); |
| 595 } | 595 } |
| 596 | 596 |
| 597 void HTMLConstructionSite::insertHTMLFormElement(AtomicHTMLToken* token, bool is
Demoted) | 597 void HTMLConstructionSite::insertHTMLFormElement(AtomicHTMLToken* token, bool is
Demoted) |
| 598 { | 598 { |
| 599 RefPtr<Element> element = createHTMLElement(token); | 599 RefPtrWillBeRawPtr<Element> element = createHTMLElement(token); |
| 600 ASSERT(isHTMLFormElement(element)); | 600 ASSERT(isHTMLFormElement(element)); |
| 601 m_form = static_pointer_cast<HTMLFormElement>(element.release()); | 601 m_form = static_pointer_cast<HTMLFormElement>(element.release()); |
| 602 m_form->setDemoted(isDemoted); | 602 m_form->setDemoted(isDemoted); |
| 603 attachLater(currentNode(), m_form); | 603 attachLater(currentNode(), m_form.get()); |
| 604 m_openElements.push(HTMLStackItem::create(m_form, token)); | 604 m_openElements.push(HTMLStackItem::create(m_form.get(), token)); |
| 605 } | 605 } |
| 606 | 606 |
| 607 void HTMLConstructionSite::insertHTMLElement(AtomicHTMLToken* token) | 607 void HTMLConstructionSite::insertHTMLElement(AtomicHTMLToken* token) |
| 608 { | 608 { |
| 609 RefPtr<Element> element = createHTMLElement(token); | 609 RefPtr<Element> element = createHTMLElement(token); |
| 610 attachLater(currentNode(), element); | 610 attachLater(currentNode(), element); |
| 611 m_openElements.push(HTMLStackItem::create(element.release(), token)); | 611 m_openElements.push(HTMLStackItem::create(element.release(), token)); |
| 612 } | 612 } |
| 613 | 613 |
| 614 void HTMLConstructionSite::insertSelfClosingHTMLElement(AtomicHTMLToken* token) | 614 void HTMLConstructionSite::insertSelfClosingHTMLElement(AtomicHTMLToken* token) |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 return element.release(); | 724 return element.release(); |
| 725 } | 725 } |
| 726 | 726 |
| 727 inline Document& HTMLConstructionSite::ownerDocumentForCurrentNode() | 727 inline Document& HTMLConstructionSite::ownerDocumentForCurrentNode() |
| 728 { | 728 { |
| 729 if (isHTMLTemplateElement(*currentNode())) | 729 if (isHTMLTemplateElement(*currentNode())) |
| 730 return toHTMLTemplateElement(currentElement())->content()->document(); | 730 return toHTMLTemplateElement(currentElement())->content()->document(); |
| 731 return currentNode()->document(); | 731 return currentNode()->document(); |
| 732 } | 732 } |
| 733 | 733 |
| 734 PassRefPtr<Element> HTMLConstructionSite::createHTMLElement(AtomicHTMLToken* tok
en) | 734 PassRefPtrWillBeRawPtr<Element> HTMLConstructionSite::createHTMLElement(AtomicHT
MLToken* token) |
| 735 { | 735 { |
| 736 Document& document = ownerDocumentForCurrentNode(); | 736 Document& document = ownerDocumentForCurrentNode(); |
| 737 // Only associate the element with the current form if we're creating the ne
w element | 737 // Only associate the element with the current form if we're creating the ne
w element |
| 738 // in a document with a browsing context (rather than in <template> contents
). | 738 // in a document with a browsing context (rather than in <template> contents
). |
| 739 HTMLFormElement* form = document.frame() ? m_form.get() : 0; | 739 HTMLFormElement* form = document.frame() ? m_form.get() : 0; |
| 740 // FIXME: This can't use HTMLConstructionSite::createElement because we | 740 // FIXME: This can't use HTMLConstructionSite::createElement because we |
| 741 // have to pass the current form element. We should rework form association | 741 // have to pass the current form element. We should rework form association |
| 742 // to occur after construction to allow better code sharing here. | 742 // to occur after construction to allow better code sharing here. |
| 743 #if ENABLE(OILPAN) |
| 744 // FIXME: Oilpan: HTMLElementFactory::createHTMLElement should return a raw |
| 745 // pointer. |
| 746 RawPtr<Element> element = HTMLElementFactory::createHTMLElement(token->name(
), document, form, true).get(); |
| 747 #else |
| 743 RefPtr<Element> element = HTMLElementFactory::createHTMLElement(token->name(
), document, form, true); | 748 RefPtr<Element> element = HTMLElementFactory::createHTMLElement(token->name(
), document, form, true); |
| 749 #endif |
| 744 setAttributes(element.get(), token, m_parserContentPolicy); | 750 setAttributes(element.get(), token, m_parserContentPolicy); |
| 745 ASSERT(element->isHTMLElement()); | 751 ASSERT(element->isHTMLElement()); |
| 746 return element.release(); | 752 return element.release(); |
| 747 } | 753 } |
| 748 | 754 |
| 749 PassRefPtr<HTMLStackItem> HTMLConstructionSite::createElementFromSavedToken(HTML
StackItem* item) | 755 PassRefPtr<HTMLStackItem> HTMLConstructionSite::createElementFromSavedToken(HTML
StackItem* item) |
| 750 { | 756 { |
| 751 RefPtr<Element> element; | 757 RefPtr<Element> element; |
| 752 // NOTE: Moving from item -> token -> item copies the Attribute vector twice
! | 758 // NOTE: Moving from item -> token -> item copies the Attribute vector twice
! |
| 753 AtomicHTMLToken fakeToken(HTMLToken::StartTag, item->localName(), item->attr
ibutes()); | 759 AtomicHTMLToken fakeToken(HTMLToken::StartTag, item->localName(), item->attr
ibutes()); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 void HTMLConstructionSite::fosterParent(PassRefPtr<Node> node) | 857 void HTMLConstructionSite::fosterParent(PassRefPtr<Node> node) |
| 852 { | 858 { |
| 853 HTMLConstructionSiteTask task(HTMLConstructionSiteTask::Insert); | 859 HTMLConstructionSiteTask task(HTMLConstructionSiteTask::Insert); |
| 854 findFosterSite(task); | 860 findFosterSite(task); |
| 855 task.child = node; | 861 task.child = node; |
| 856 ASSERT(task.parent); | 862 ASSERT(task.parent); |
| 857 queueTask(task); | 863 queueTask(task); |
| 858 } | 864 } |
| 859 | 865 |
| 860 } | 866 } |
| OLD | NEW |