From 2f0a2865f24b94aec389d3d539aaa630e59a9471 Mon Sep 17 00:00:00 2001 From: Matthew Olsson Date: Mon, 10 May 2021 10:33:32 -0700 Subject: [PATCH] LibPDF: Give Parser a reference to the Document The Parser will need to call resolve_to on certain values. --- Userland/Libraries/LibPDF/Document.cpp | 2 ++ Userland/Libraries/LibPDF/Parser.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/Userland/Libraries/LibPDF/Document.cpp b/Userland/Libraries/LibPDF/Document.cpp index a4a7abc945..7d7d01c79a 100644 --- a/Userland/Libraries/LibPDF/Document.cpp +++ b/Userland/Libraries/LibPDF/Document.cpp @@ -12,6 +12,8 @@ namespace PDF { Document::Document(const ReadonlyBytes& bytes) : m_parser(Parser({}, bytes)) { + m_parser.set_document(this); + VERIFY(m_parser.perform_validation()); auto [xref_table, trailer] = m_parser.parse_last_xref_table_and_trailer(); diff --git a/Userland/Libraries/LibPDF/Parser.h b/Userland/Libraries/LibPDF/Parser.h index 3158f9d795..e4f2fc64cb 100644 --- a/Userland/Libraries/LibPDF/Parser.h +++ b/Userland/Libraries/LibPDF/Parser.h @@ -19,6 +19,8 @@ class Parser { public: Parser(Badge, const ReadonlyBytes&); + void set_document(RefPtr document) { m_document = document; } + bool perform_validation(); struct XRefTableAndTrailer { @@ -74,6 +76,7 @@ private: void consume(char); Reader m_reader; + RefPtr m_document; }; }