File indexing completed on 2024-12-29 04:51:00

0001 /*
0002    SPDX-FileCopyrightText: 2017-2021 Volker Krause <vkrause@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <KItinerary/ExtractorDocumentProcessor>
0010 
0011 namespace KItinerary {
0012 
0013 class HtmlElement;
0014 
0015 /** Processor for HTML documents. */
0016 class HtmlDocumentProcessor : public ExtractorDocumentProcessor
0017 {
0018 public:
0019     bool canHandleData(const QByteArray &encodedData, QStringView fileName) const override;
0020     ExtractorDocumentNode createNodeFromData(const QByteArray &encodedData) const override;
0021     ExtractorDocumentNode createNodeFromContent(const QVariant& decodedData) const override;
0022     void expandNode(ExtractorDocumentNode &node, const ExtractorEngine *engine) const override;
0023     void preExtract(ExtractorDocumentNode &node, const ExtractorEngine *engine) const override;
0024     void postExtract(ExtractorDocumentNode &node, const ExtractorEngine *engine) const override;
0025     QJSValue contentToScriptValue(const ExtractorDocumentNode &node, QJSEngine *engine) const override;
0026     void destroyNode(ExtractorDocumentNode &node) const override;
0027 
0028 private:
0029     void expandElementRecursive(ExtractorDocumentNode &node, const HtmlElement &elem, const ExtractorEngine *engine) const;
0030     void expandDataUrl(ExtractorDocumentNode &node, QStringView data, const ExtractorEngine *engine) const;
0031 };
0032 
0033 }
0034