From 07dd8540ae72b0e7be64d04c38d8c19b83d184b6 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Mon, 24 Jun 2013 21:01:27 +0100 Subject: Update pdf_obj's to have a pdf_document field. Remove the fz_context field to avoid the structure growing. --- source/pdf/js/pdf-js.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'source/pdf/js') diff --git a/source/pdf/js/pdf-js.c b/source/pdf/js/pdf-js.c index 4a2313f1..5ea9872f 100644 --- a/source/pdf/js/pdf-js.c +++ b/source/pdf/js/pdf-js.c @@ -138,13 +138,14 @@ static pdf_jsimp_obj *app_launchURL(void *jsctx, void *obj, int argc, pdf_jsimp_ return NULL; } -static pdf_obj *load_color(fz_context *ctx, pdf_jsimp *imp, pdf_jsimp_obj *val) +static pdf_obj *load_color(pdf_document *doc, pdf_jsimp *imp, pdf_jsimp_obj *val) { pdf_obj *col = NULL; pdf_obj *comp = NULL; pdf_jsimp_obj *jscomp = NULL; int i; int n; + fz_context *ctx = doc->ctx; n = pdf_jsimp_array_len(imp, val); @@ -154,7 +155,7 @@ static pdf_obj *load_color(fz_context *ctx, pdf_jsimp *imp, pdf_jsimp_obj *val) if (n <= 1) return NULL; - col = pdf_new_array(ctx, n-1); + col = pdf_new_array(doc, n-1); fz_var(comp); fz_var(jscomp); @@ -163,7 +164,7 @@ static pdf_obj *load_color(fz_context *ctx, pdf_jsimp *imp, pdf_jsimp_obj *val) for (i = 0; i < n-1; i++) { jscomp = pdf_jsimp_array_item(imp, val, i+1); - comp = pdf_new_real(ctx, pdf_jsimp_to_number(imp, jscomp)); + comp = pdf_new_real(doc, pdf_jsimp_to_number(imp, jscomp)); pdf_array_push(col, comp); pdf_jsimp_drop_obj(imp, jscomp); jscomp = NULL; @@ -264,7 +265,7 @@ static void field_setFillColor(void *jsctx, void *obj, pdf_jsimp_obj *val) if (!field) return; - col = load_color(js->doc->ctx, js->imp, val); + col = load_color(js->doc, js->imp, val); fz_try(ctx) { pdf_field_set_fill_color(js->doc, field, col); @@ -294,7 +295,7 @@ static void field_setTextColor(void *jsctx, void *obj, pdf_jsimp_obj *val) if (!field) return; - col = load_color(js->doc->ctx, js->imp, val); + col = load_color(js->doc, js->imp, val); fz_try(ctx) { pdf_field_set_text_color(js->doc, field, col); -- cgit v1.2.3