/** * Handle notification that a CSS object is done * * \param css CSS object * \param pw Private data */ void nscss_content_done(struct content_css_data *css, void *pw) { union content_msg_data msg_data; struct content *c = pw; uint32_t i; size_t size; css_error error; /* Retrieve the size of this sheet */ error = css_stylesheet_size(css->sheet, &size); if (error != CSS_OK) { msg_data.error = "?"; content_broadcast(c, CONTENT_MSG_ERROR, msg_data); content_set_error(c); return; } c->size += size; /* Add on the size of the imported sheets */ for (i = 0; i < css->import_count; i++) { if (css->imports[i].c != NULL) { struct content *import = hlcache_handle_get_content( css->imports[i].c); if (import != NULL) { c->size += import->size; } } } /* Finally, catch the content's users up with reality */ content_set_ready(c); content_set_done(c); }
void content_clear_selection(hlcache_handle *h) { struct content *c = hlcache_handle_get_content(h); assert(c != 0); if (c->handler->get_selection != NULL) c->handler->clear_selection(c); }
/** * Retrieve the stylesheet object associated with a CSS content * * \param h Stylesheet content * \return Pointer to stylesheet object */ css_stylesheet *nscss_get_stylesheet(struct hlcache_handle *h) { nscss_content *c = (nscss_content *) hlcache_handle_get_content(h); assert(c != NULL); return c->data.sheet; }
void content_debug_dump(struct hlcache_handle *h, FILE *f) { struct content *c = hlcache_handle_get_content(h); assert(c != 0); if (c->handler->debug_dump != NULL) c->handler->debug_dump(c, f); }
void content_search_clear(struct hlcache_handle *h) { struct content *c = hlcache_handle_get_content(h); assert(c != 0); if (c->handler->search_clear != NULL) c->handler->search_clear(c); }
void content_close(hlcache_handle *h) { struct content *c = hlcache_handle_get_content(h); assert(c != 0); LOG("content %p %s", c, nsurl_access(llcache_handle_get_url(c->llcache))); if (c->handler->close != NULL) c->handler->close(c); }
/** * Get whether a content can reformat * * \param h content to check * \return whether the content can reformat */ bool content_can_reformat(hlcache_handle *h) { struct content *c = hlcache_handle_get_content(h); if (c == NULL) return false; return (c->handler->reformat != NULL); }
/* exported interface documented in content/content.h */ bool content_get_quirks(hlcache_handle *h) { struct content *c = hlcache_handle_get_content(h); if (c == NULL) return false; return c->quirks; }
/* exported interface documented in content/content.h */ content_type content_get_type(hlcache_handle *h) { struct content *c = hlcache_handle_get_content(h); if (c == NULL) return CONTENT_NONE; return c->handler->type(); }
void content_open(hlcache_handle *h, struct browser_window *bw, struct content *page, struct object_params *params) { struct content *c = hlcache_handle_get_content(h); assert(c != 0); LOG("content %p %s", c, nsurl_access(llcache_handle_get_url(c->llcache))); if (c->handler->open != NULL) c->handler->open(c, bw, page, params); }
bool content_keypress(struct hlcache_handle *h, uint32_t key) { struct content *c = hlcache_handle_get_content(h); assert(c != NULL); if (c->handler->keypress != NULL) return c->handler->keypress(c, key); return false; }
char * content_get_selection(hlcache_handle *h) { struct content *c = hlcache_handle_get_content(h); assert(c != 0); if (c->handler->get_selection != NULL) return c->handler->get_selection(c); else return NULL; }
void content_search(struct hlcache_handle *h, void *context, search_flags_t flags, const char *string) { struct content *c = hlcache_handle_get_content(h); assert(c != 0); if (c->handler->search != NULL) { c->handler->search(c, context, flags, string); } }
void content_search(struct hlcache_handle *h, struct gui_search_callbacks *gui_callbacks, void *gui_data, search_flags_t flags, const char *string) { struct content *c = hlcache_handle_get_content(h); assert(c != 0); if (c->handler->search != NULL) c->handler->search(c, gui_callbacks, gui_data, flags, string); }
/** * Register an import with a stylesheet * * \param c CSS object that requested the import * \param import Cache handle of import, or NULL for blank * \return CSS_OK on success, appropriate error otherwise */ css_error nscss_register_import(struct content_css_data *c, const hlcache_handle *import) { css_stylesheet *sheet; css_error error; if (import != NULL) { nscss_content *s = (nscss_content *) hlcache_handle_get_content(import); sheet = s->data.sheet; } else { /* Create a blank sheet if needed. */ if (blank_import == NULL) { css_stylesheet_params params; params.params_version = CSS_STYLESHEET_PARAMS_VERSION_1; params.level = CSS_LEVEL_DEFAULT; params.charset = NULL; params.url = ""; params.title = NULL; params.allow_quirks = false; params.inline_style = false; params.resolve = nscss_resolve_url; params.resolve_pw = NULL; params.import = NULL; params.import_pw = NULL; params.color = gui_system_colour; params.color_pw = NULL; params.font = NULL; params.font_pw = NULL; error = css_stylesheet_create(¶ms, ns_realloc, NULL, &blank_import); if (error != CSS_OK) { return error; } error = css_stylesheet_data_done(blank_import); if (error != CSS_OK) { css_stylesheet_destroy(blank_import); return error; } } sheet = blank_import; } error = css_stylesheet_register_import(c->sheet, sheet); if (error != CSS_OK) { return error; } return error; }
/* exported interface documented in render/html.h */ struct html_stylesheet *html_get_stylesheets(hlcache_handle *h, unsigned int *n) { html_content *c = (html_content *) hlcache_handle_get_content(h); assert(c != NULL); assert(n != NULL); *n = c->stylesheet_count; return c->stylesheets; }
/** * Retrieve objects used by HTML document * * \param h Content to retrieve objects from * \param n Pointer to location to receive number of objects * \return Pointer to list of objects */ struct content_html_object *html_get_objects(hlcache_handle *h, unsigned int *n) { html_content *c = (html_content *) hlcache_handle_get_content(h); assert(c != NULL); assert(n != NULL); *n = c->num_objects; return c->object_list; }
/** * Retrieve imported stylesheets * * \param h Stylesheet containing imports * \param n Pointer to location to receive number of imports * \return Pointer to array of imported stylesheets */ struct nscss_import *nscss_get_imports(hlcache_handle *h, uint32_t *n) { nscss_content *c = (nscss_content *) hlcache_handle_get_content(h); assert(c != NULL); assert(n != NULL); *n = c->data.import_count; return c->data.imports; }
bool content_scroll_at_point(struct hlcache_handle *h, int x, int y, int scrx, int scry) { struct content *c = hlcache_handle_get_content(h); assert(c != 0); if (c->handler->scroll_at_point != NULL) return c->handler->scroll_at_point(c, x, y, scrx, scry); return false; }
/* exported interface documented in content/content.h */ nserror content_debug_dump(struct hlcache_handle *h, FILE *f, enum content_debug op) { struct content *c = hlcache_handle_get_content(h); assert(c != 0); if (c->handler->debug_dump == NULL) { return NSERROR_NOT_IMPLEMENTED; } return c->handler->debug_dump(c, f, op); }
bool content_drop_file_at_point(struct hlcache_handle *h, int x, int y, char *file) { struct content *c = hlcache_handle_get_content(h); assert(c != 0); if (c->handler->drop_file_at_point != NULL) return c->handler->drop_file_at_point(c, x, y, file); return false; }
void content_mouse_action(hlcache_handle *h, struct browser_window *bw, browser_mouse_state mouse, int x, int y) { struct content *c = hlcache_handle_get_content(h); assert(c != NULL); if (c->handler->mouse_action != NULL) c->handler->mouse_action(c, bw, mouse, x, y); return; }
/* exported interface documented in content/content.h */ nserror content_get_contextual_content(struct hlcache_handle *h, int x, int y, struct browser_window_features *data) { struct content *c = hlcache_handle_get_content(h); assert(c != 0); if (c->handler->get_contextual_content != NULL) { return c->handler->get_contextual_content(c, x, y, data); } data->object = h; return NSERROR_OK; }
/* exported interface documented in content/content.h */ nserror content_debug(struct hlcache_handle *h, enum content_debug op) { struct content *c = hlcache_handle_get_content(h); if (c == NULL) { return NSERROR_BAD_PARAMETER; } if (c->handler->debug == NULL) { return NSERROR_NOT_IMPLEMENTED; } return c->handler->debug(c, op); }
void content_get_contextual_content(struct hlcache_handle *h, int x, int y, struct contextual_content *data) { struct content *c = hlcache_handle_get_content(h); assert(c != 0); if (c->handler->get_contextual_content != NULL) { c->handler->get_contextual_content(c, x, y, data); return; } else { data->object = h; return; } }
/* exported interface documented in content/content.h */ struct content_rfc5988_link * content_find_rfc5988_link(hlcache_handle *h, lwc_string *rel) { struct content *c = hlcache_handle_get_content(h); struct content_rfc5988_link *link = c->links; bool rel_match = false; while (link != NULL) { if (lwc_string_caseless_isequal(link->rel, rel, &rel_match) == lwc_error_ok && rel_match) { break; } link = link->next; } return link; }
void content_mouse_track(hlcache_handle *h, struct browser_window *bw, browser_mouse_state mouse, int x, int y) { struct content *c = hlcache_handle_get_content(h); assert(c != NULL); if (c->handler->mouse_track != NULL) { c->handler->mouse_track(c, bw, mouse, x, y); } else { union content_msg_data msg_data; msg_data.pointer = BROWSER_POINTER_AUTO; content_broadcast(c, CONTENT_MSG_POINTER, msg_data); } return; }
bool nsico_set_bitmap_from_size(hlcache_handle *h, int width, int height) { struct content *c = hlcache_handle_get_content(h); struct bmp_image *bmp; assert(c != NULL); bmp = ico_find(c->data.ico.ico, width, height); if (bmp == NULL) return false; if ((bmp->decoded == false) && (bmp_decode(bmp) != BMP_OK)) return false; c->bitmap = bmp->bitmap; return true; }
bool content_redraw(hlcache_handle *h, struct content_redraw_data *data, const struct rect *clip, const struct redraw_context *ctx) { struct content *c = hlcache_handle_get_content(h); assert(c != NULL); if (c->locked) { /* not safe to attempt redraw */ return true; } /* ensure we have a redrawable content */ if (c->handler->redraw == NULL) { return true; } return c->handler->redraw(c, data, clip, ctx); }
/* exported interface, documented in content/content.h */ bool content_scaled_redraw(struct hlcache_handle *h, int width, int height, const struct redraw_context *ctx) { struct content *c = hlcache_handle_get_content(h); struct redraw_context new_ctx = *ctx; struct rect clip; struct content_redraw_data data; bool plot_ok = true; assert(c != NULL); /* ensure it is safe to attempt redraw */ if (c->locked) { return true; } /* ensure we have a redrawable content */ if (c->handler->redraw == NULL) { return true; } LOG("Content %p %dx%d ctx:%p", c, width, height, ctx); if (ctx->plot->option_knockout) { knockout_plot_start(ctx, &new_ctx); } /* Set clip rectangle to required thumbnail size */ clip.x0 = 0; clip.y0 = 0; clip.x1 = width; clip.y1 = height; new_ctx.plot->clip(&clip); /* Plot white background */ plot_ok &= new_ctx.plot->rectangle(clip.x0, clip.y0, clip.x1, clip.y1, plot_style_fill_white); /* Set up content redraw data */ data.x = 0; data.y = 0; data.width = width; data.height = height; data.background_colour = 0xFFFFFF; data.repeat_x = false; data.repeat_y = false; /* Find the scale factor to use if the content has a width */ if (c->width) { data.scale = (float)width / (float)c->width; } else { data.scale = 1.0; } /* Render the content */ plot_ok &= c->handler->redraw(c, &data, &clip, &new_ctx); if (ctx->plot->option_knockout) { knockout_plot_end(); } return plot_ok; }