mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:04:59 +00:00
LibXML+LibWeb: Store the XML document's original source
Similar to how we store an HTML document's original source. This allows the source to be inspected with "View Source" in the Browser.
This commit is contained in:
parent
e7412717b4
commit
b10bbac061
4 changed files with 8 additions and 0 deletions
|
@ -46,6 +46,11 @@ XMLDocumentBuilder::XMLDocumentBuilder(DOM::Document& document, XMLScriptingSupp
|
|||
{
|
||||
}
|
||||
|
||||
void XMLDocumentBuilder::set_source(String source)
|
||||
{
|
||||
m_document.set_source(move(source));
|
||||
}
|
||||
|
||||
void XMLDocumentBuilder::element_start(const XML::Name& name, HashMap<XML::Name, String> const& attributes)
|
||||
{
|
||||
if (m_has_error)
|
||||
|
|
|
@ -29,6 +29,7 @@ public:
|
|||
bool has_error() const { return m_has_error; }
|
||||
|
||||
private:
|
||||
virtual void set_source(String) override;
|
||||
virtual void element_start(XML::Name const& name, HashMap<XML::Name, String> const& attributes) override;
|
||||
virtual void element_end(XML::Name const& name) override;
|
||||
virtual void text(String const& data) override;
|
||||
|
|
|
@ -174,6 +174,7 @@ ErrorOr<void, ParseError> Parser::parse_with_listener(Listener& listener)
|
|||
{
|
||||
m_listener = &listener;
|
||||
ScopeGuard unset_listener { [this] { m_listener = nullptr; } };
|
||||
m_listener->set_source(m_source);
|
||||
m_listener->document_start();
|
||||
auto result = parse_internal();
|
||||
if (result.is_error())
|
||||
|
|
|
@ -29,6 +29,7 @@ struct ParseError {
|
|||
struct Listener {
|
||||
virtual ~Listener() { }
|
||||
|
||||
virtual void set_source(String) { }
|
||||
virtual void document_start() { }
|
||||
virtual void document_end() { }
|
||||
virtual void element_start(Name const&, HashMap<Name, String> const&) { }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue