Chromium Code Reviews| Index: Source/core/dom/ProcessingInstruction.cpp |
| diff --git a/Source/core/dom/ProcessingInstruction.cpp b/Source/core/dom/ProcessingInstruction.cpp |
| index 2a6eced3750e5638964983dacaa21606591b50e1..e570770a912c5d07f4b7b4f29b8f8c7a5678be03 100644 |
| --- a/Source/core/dom/ProcessingInstruction.cpp |
| +++ b/Source/core/dom/ProcessingInstruction.cpp |
| @@ -32,6 +32,7 @@ |
| #include "core/fetch/FetchRequest.h" |
| #include "core/fetch/ResourceFetcher.h" |
| #include "core/fetch/XSLStyleSheetResource.h" |
| +#include "core/xml/DocumentXSLT.h" |
| #include "core/xml/XSLStyleSheet.h" |
| #include "core/xml/parser/XMLDocumentParser.h" // for parseAttributes() |
| @@ -45,6 +46,7 @@ inline ProcessingInstruction::ProcessingInstruction(Document& document, const St |
| , m_createdByParser(false) |
| , m_isCSS(false) |
| , m_isXSL(false) |
| + , m_listenerForXSLT(nullptr) |
| { |
| } |
| @@ -62,12 +64,8 @@ ProcessingInstruction::~ProcessingInstruction() |
| // FIXME: ProcessingInstruction should not be in document here. |
| // However, if we add ASSERT(!inDocument()), fast/xsl/xslt-entity.xml |
| // crashes. We need to investigate ProcessingInstruction lifetime. |
| - if (inDocument()) { |
| - if (m_isCSS) |
| - document().styleEngine()->removeStyleSheetCandidateNode(this); |
| - else if (m_isXSL) |
| - document().styleEngine()->removeXSLStyleSheet(this); |
| - } |
| + if (inDocument() && m_isCSS) |
| + document().styleEngine()->removeStyleSheetCandidateNode(this); |
| #endif |
| } |
| @@ -162,7 +160,8 @@ void ProcessingInstruction::process(const String& href, const String& charset) |
| if (resource) { |
| m_loading = true; |
| - document().styleEngine()->addPendingSheet(); |
| + if (!m_isXSL) |
| + document().styleEngine()->addPendingSheet(); |
| setResource(resource); |
| } |
| } |
| @@ -179,6 +178,10 @@ bool ProcessingInstruction::isLoading() const |
| bool ProcessingInstruction::sheetLoaded() |
| { |
| if (!isLoading()) { |
| + if (m_isXSL) { |
| + DocumentXSLT::sheetLoaded(document(), this); |
| + return true; |
| + } |
| document().styleEngine()->removePendingSheet(this); |
| return true; |
| } |
| @@ -258,10 +261,13 @@ Node::InsertionNotificationRequest ProcessingInstruction::insertedInto(Container |
| String href; |
| String charset; |
| bool isValid = checkStyleSheet(href, charset); |
| - if (m_isCSS) |
| + if (m_isCSS) { |
| document().styleEngine()->addStyleSheetCandidateNode(this, m_createdByParser); |
| - else if (m_isXSL) |
| - document().styleEngine()->addXSLStyleSheet(this, m_createdByParser); |
| + } else if (m_isXSL) { |
| + // No need to register XSLStyleSheet to StyleEngine. |
| + m_listenerForXSLT = DocumentXSLT::addDOMContentLoadedListenerForXSLT(document(), this); |
| + ASSERT(m_listenerForXSLT); |
|
tasak
2014/11/19 09:23:03
Should be ASSERT(m_listenerForXSLT || !RuntimeEnab
|
| + } |
| if (isValid) |
| process(href, charset); |
| return InsertionDone; |
| @@ -273,11 +279,14 @@ void ProcessingInstruction::removedFrom(ContainerNode* insertionPoint) |
| if (!insertionPoint->inDocument()) |
| return; |
| - if (m_isCSS) |
| + if (m_isCSS) { |
| document().styleEngine()->removeStyleSheetCandidateNode(this); |
| - else if (m_isXSL) |
| - document().styleEngine()->removeXSLStyleSheet(this); |
| + } else if (m_isXSL) { |
|
tasak
2014/11/19 09:23:03
Should be (m_isXSL && m_listenerForXSLT)
|
| + document().removeEventListener(EventTypeNames::DOMContentLoaded, m_listenerForXSLT, false); |
| + m_listenerForXSLT.clear(); |
| + } |
| + // No need to remove XSLStyleSheet from StyleEngine. |
| RefPtrWillBeRawPtr<StyleSheet> removedSheet = m_sheet; |
| if (m_sheet) { |