1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 23:38:12 +00:00

LibPDF: Allow operators to receive optional resources

Operators usually assume that the resources its operations will require
will be the Page's. This assumption breaks however when XObjects with
their own resources come into the picture (and maybe other cases too).
In that case, the XObject's resources take precedence, but they should
also contain the Page's resources. Because of this, one can safely use
the XObject resources alone when given, and default to the Page's if
not.

This commit adds all operator calls an extra argument with optional
resources, which will be fed by XObjects as necessary.
This commit is contained in:
Rodrigo Tobar 2022-11-21 13:28:41 +08:00 committed by Andreas Kling
parent e58165ed7a
commit b3007c17bd
2 changed files with 17 additions and 16 deletions

View file

@ -97,13 +97,13 @@ private:
PDFErrorOr<void> render();
PDFErrorOr<void> handle_operator(Operator const&);
PDFErrorOr<void> handle_operator(Operator const&, Optional<NonnullRefPtr<DictObject>> = {});
#define V(name, snake_name, symbol) \
PDFErrorOr<void> handle_##snake_name(Vector<Value> const& args);
PDFErrorOr<void> handle_##snake_name(Vector<Value> const& args, Optional<NonnullRefPtr<DictObject>> = {});
ENUMERATE_OPERATORS(V)
#undef V
PDFErrorOr<void> handle_text_next_line_show_string(Vector<Value> const& args);
PDFErrorOr<void> handle_text_next_line_show_string_set_spacing(Vector<Value> const& args);
PDFErrorOr<void> handle_text_next_line_show_string(Vector<Value> const& args, Optional<NonnullRefPtr<DictObject>> = {});
PDFErrorOr<void> handle_text_next_line_show_string_set_spacing(Vector<Value> const& args, Optional<NonnullRefPtr<DictObject>> = {});
void begin_path_paint();
void end_path_paint();