#ifndef XSLStyleSheet_h
#define XSLStyleSheet_h
#if ENABLE(XSLT)
#include "ProcessingInstruction.h"
#include "StyleSheet.h"
#include <libxml/parser.h>
#include <libxslt/transform.h>
#include <wtf/PassRefPtr.h>
namespace WebCore {
class CachedResourceLoader;
class XSLImportRule;
class XSLStyleSheet final : public StyleSheet {
public:
static PassRefPtr<XSLStyleSheet> create(XSLImportRule* parentImport, const String& originalURL, const URL& finalURL)
{
return adoptRef(new XSLStyleSheet(parentImport, originalURL, finalURL));
}
static PassRefPtr<XSLStyleSheet> create(ProcessingInstruction* parentNode, const String& originalURL, const URL& finalURL)
{
return adoptRef(new XSLStyleSheet(parentNode, originalURL, finalURL, false));
}
static PassRefPtr<XSLStyleSheet> createEmbedded(ProcessingInstruction* parentNode, const URL& finalURL)
{
return adoptRef(new XSLStyleSheet(parentNode, finalURL.string(), finalURL, true));
}
static PassRefPtr<XSLStyleSheet> createForXSLTProcessor(Node* parentNode, const String& originalURL, const URL& finalURL)
{
return adoptRef(new XSLStyleSheet(parentNode, originalURL, finalURL, false));
}
virtual ~XSLStyleSheet();
bool parseString(const String&);
void checkLoaded();
const URL& finalURL() const { return m_finalURL; }
void loadChildSheets();
void loadChildSheet(const String& href);
CachedResourceLoader* cachedResourceLoader();
Document* ownerDocument();
virtual XSLStyleSheet* parentStyleSheet() const override { return m_parentStyleSheet; }
void setParentStyleSheet(XSLStyleSheet* parent);
xmlDocPtr document();
xsltStylesheetPtr compileStyleSheet();
xmlDocPtr locateStylesheetSubResource(xmlDocPtr parentDoc, const xmlChar* uri);
void clearDocuments();
void markAsProcessed();
bool processed() const { return m_processed; }
virtual String type() const override { return "text/xml"; }
virtual bool disabled() const override { return m_isDisabled; }
virtual void setDisabled(bool b) override { m_isDisabled = b; }
virtual Node* ownerNode() const override { return m_ownerNode; }
virtual String href() const override { return m_originalURL; }
virtual String title() const override { return emptyString(); }
virtual void clearOwnerNode() override { m_ownerNode = 0; }
virtual URL baseURL() const override { return m_finalURL; }
virtual bool isLoading() const override;
virtual bool isXSLStyleSheet() const override { return true; }
private:
XSLStyleSheet(Node* parentNode, const String& originalURL, const URL& finalURL, bool embedded);
XSLStyleSheet(XSLImportRule* parentImport, const String& originalURL, const URL& finalURL);
Node* m_ownerNode;
String m_originalURL;
URL m_finalURL;
bool m_isDisabled;
Vector<std::unique_ptr<XSLImportRule>> m_children;
bool m_embedded;
bool m_processed;
xmlDocPtr m_stylesheetDoc;
bool m_stylesheetDocTaken;
XSLStyleSheet* m_parentStyleSheet;
};
}
#endif // ENABLE(XSLT)
#endif // XSLStyleSheet_h