Chromium Code Reviews| Index: Source/core/dom/ProcessingInstruction.cpp |
| diff --git a/Source/core/dom/ProcessingInstruction.cpp b/Source/core/dom/ProcessingInstruction.cpp |
| index d0112335a1b8409dcfbefff4dcc78bc5107fc488..2105de0e53b5c4f0ac9bd916ba7f2bfdc8629360 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 with StyleEngine. |
|
haraken
2014/11/17 14:18:31
with => to
tasak
2014/11/19 08:23:16
Done.
|
| + m_listenerForXSLT = DocumentXSLT::addDOMContentLoadedListenerForXSLT(document(), this); |
| + ASSERT(m_listenerForXSLT); |
| + } |
| 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) { |
| + 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) { |
| @@ -301,6 +310,7 @@ void ProcessingInstruction::clearSheet() |
| void ProcessingInstruction::trace(Visitor* visitor) |
| { |
| visitor->trace(m_sheet); |
| + visitor->trace(m_listenerForXSLT); |
|
haraken
2014/11/17 14:18:31
You shouldn't trace m_listenerForXSLT, since m_lis
tasak
2014/11/19 08:23:16
Done.
|
| CharacterData::trace(visitor); |
| } |