NetSurf
Data Structures | Typedefs | Functions | Variables
ico.c File Reference

implementation for image/ico content handler More...

#include <stdbool.h>
#include <stdlib.h>
#include <libnsbmp.h>
#include "utils/utils.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "netsurf/bitmap.h"
#include "netsurf/content.h"
#include "content/llcache.h"
#include "content/content_protected.h"
#include "content/content_factory.h"
#include "desktop/gui_internal.h"
#include "desktop/bitmap.h"
#include "image/image.h"
#include "image/ico.h"
Include dependency graph for ico.c:

Go to the source code of this file.

Data Structures

struct  nsico_content
 

Typedefs

typedef struct nsico_content nsico_content
 

Functions

static void * nsico_bitmap_create (int width, int height, unsigned int bmp_state)
 Callback for libnsbmp; forwards the call to bitmap_create() More...
 
static nserror nsico_create_ico_data (nsico_content *c)
 
static nserror nsico_create (const content_handler *handler, lwc_string *imime_type, const struct http_parameter *params, llcache_handle *llcache, const char *fallback_charset, bool quirks, struct content **c)
 
static bool nsico_convert (struct content *c)
 
static bool nsico__decode (struct bmp_image *ico)
 
static bool nsico_redraw (struct content *c, struct content_redraw_data *data, const struct rect *clip, const struct redraw_context *ctx)
 
static void nsico_destroy (struct content *c)
 
static nserror nsico_clone (const struct content *old, struct content **newc)
 
static void * nsico_get_internal (const struct content *c, void *context)
 
static content_type nsico_content_type (void)
 
static bool nsico_is_opaque (struct content *c)
 
 CONTENT_FACTORY_REGISTER_TYPES (nsico, nsico_types, nsico_content_handler)
 

Variables

static const content_handler nsico_content_handler
 
static const char * nsico_types []
 

Detailed Description

implementation for image/ico content handler

Definition in file ico.c.

Typedef Documentation

◆ nsico_content

typedef struct nsico_content nsico_content

Function Documentation

◆ CONTENT_FACTORY_REGISTER_TYPES()

CONTENT_FACTORY_REGISTER_TYPES ( nsico  ,
nsico_types  ,
nsico_content_handler   
)

◆ nsico__decode()

static bool nsico__decode ( struct bmp_image *  ico)
static

Definition at line 176 of file ico.c.

References netsurf_table::bitmap, bitmap_format_to_client(), guit, gui_bitmap_table::modified, and NSLOG.

Referenced by nsico_get_internal(), nsico_is_opaque(), and nsico_redraw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nsico_bitmap_create()

static void * nsico_bitmap_create ( int  width,
int  height,
unsigned int  bmp_state 
)
static

Callback for libnsbmp; forwards the call to bitmap_create()

Parameters
widthwidth of image in pixels
heightwidth of image in pixels
bmp_stateA flag word indicating the initial state
Returns
an opaque struct bitmap, or NULL on memory exhaustion

Definition at line 56 of file ico.c.

References netsurf_table::bitmap, BITMAP_CLEAR, BITMAP_NONE, BITMAP_OPAQUE, gui_bitmap_table::create, guit, height, and width.

Referenced by nsico_create_ico_data().

Here is the caller graph for this function:

◆ nsico_clone()

static nserror nsico_clone ( const struct content old,
struct content **  newc 
)
static

Definition at line 225 of file ico.c.

References nsico_content::base, content__clone(), content_destroy(), CONTENT_STATUS_DONE, CONTENT_STATUS_READY, NSERROR_CLONE_FAILED, NSERROR_NOMEM, NSERROR_OK, nsico_convert(), nsico_create_ico_data(), and content::status.

Here is the call graph for this function:

◆ nsico_content_type()

static content_type nsico_content_type ( void  )
static

Definition at line 281 of file ico.c.

References CONTENT_IMAGE.

◆ nsico_convert()

static bool nsico_convert ( struct content c)
static

Definition at line 119 of file ico.c.

References content__get_source_data(), content__set_title(), content_broadcast_error(), content_set_done(), content_set_ready(), content_set_status(), content::height, nsico_content::ico, content::llcache, llcache_handle_get_url(), messages_get_buff(), NSERROR_ICO_ERROR, NSERROR_NOMEM, NSLOG, nsurl_access_leaf(), content::size, and content::width.

Referenced by nsico_clone().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nsico_create()

static nserror nsico_create ( const content_handler handler,
lwc_string *  imime_type,
const struct http_parameter params,
llcache_handle llcache,
const char *  fallback_charset,
bool  quirks,
struct content **  c 
)
static

Definition at line 87 of file ico.c.

References content__init(), llcache, NSERROR_NOMEM, NSERROR_OK, nsico_create_ico_data(), and result.

Here is the call graph for this function:

◆ nsico_create_ico_data()

static nserror nsico_create_ico_data ( nsico_content c)
static

Definition at line 69 of file ico.c.

References nsico_content::base, netsurf_table::bitmap, content_broadcast_error(), gui_bitmap_table::destroy, gui_bitmap_table::get_buffer, guit, nsico_content::ico, NSERROR_NOMEM, NSERROR_OK, and nsico_bitmap_create().

Referenced by nsico_clone(), and nsico_create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nsico_destroy()

static void nsico_destroy ( struct content c)
static

Definition at line 217 of file ico.c.

References nsico_content::ico.

◆ nsico_get_internal()

static void * nsico_get_internal ( const struct content c,
void *  context 
)
static

Definition at line 260 of file ico.c.

References nsico_content::ico, nsico__decode(), and NSLOG.

Here is the call graph for this function:

◆ nsico_is_opaque()

static bool nsico_is_opaque ( struct content c)
static
Todo:
Pick best size for purpose. Currently assumes it's for a URL bar.

Definition at line 286 of file ico.c.

References netsurf_table::bitmap, gui_bitmap_table::get_opaque, guit, nsico_content::ico, nsico__decode(), and NSLOG.

Here is the call graph for this function:

◆ nsico_redraw()

static bool nsico_redraw ( struct content c,
struct content_redraw_data data,
const struct rect clip,
const struct redraw_context ctx 
)
static

Definition at line 194 of file ico.c.

References clip(), content_redraw_data::height, nsico_content::ico, image_bitmap_plot(), nsico__decode(), NSLOG, and content_redraw_data::width.

Here is the call graph for this function:

Variable Documentation

◆ nsico_content_handler

const content_handler nsico_content_handler
static
Initial value:
= {
.create = nsico_create,
.data_complete = nsico_convert,
.destroy = nsico_destroy,
.redraw = nsico_redraw,
.clone = nsico_clone,
.get_internal = nsico_get_internal,
.is_opaque = nsico_is_opaque,
.no_share = false,
}
static nserror nsico_create(const content_handler *handler, lwc_string *imime_type, const struct http_parameter *params, llcache_handle *llcache, const char *fallback_charset, bool quirks, struct content **c)
Definition: ico.c:87
static bool nsico_redraw(struct content *c, struct content_redraw_data *data, const struct rect *clip, const struct redraw_context *ctx)
Definition: ico.c:194
static content_type nsico_content_type(void)
Definition: ico.c:281
static bool nsico_is_opaque(struct content *c)
Definition: ico.c:286
static void nsico_destroy(struct content *c)
Definition: ico.c:217
static nserror nsico_clone(const struct content *old, struct content **newc)
Definition: ico.c:225
static void * nsico_get_internal(const struct content *c, void *context)
Definition: ico.c:260
static bool nsico_convert(struct content *c)
Definition: ico.c:119

Definition at line 309 of file ico.c.

◆ nsico_types

const char* nsico_types[]
static
Initial value:
= {
"application/ico",
"application/x-ico",
"image/ico",
"image/vnd.microsoft.icon",
"image/x-icon"
}

Definition at line 321 of file ico.c.