mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +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
Notes:
sideshowbarker
2024-07-17 04:50:07 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/b10bbac061 Pull-request: https://github.com/SerenityOS/serenity/pull/15905 Reviewed-by: https://github.com/alimpfard ✅ Reviewed-by: https://github.com/linusg ✅
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…
Reference in a new issue