NetSurf
|
Implementation of HTML image maps. More...
#include <assert.h>
#include <stdbool.h>
#include <string.h>
#include <strings.h>
#include <dom/dom.h>
#include "utils/log.h"
#include "utils/corestrings.h"
#include "content/content_protected.h"
#include "content/hlcache.h"
#include "html/box.h"
#include "html/box_construct.h"
#include "html/private.h"
#include "html/imagemap.h"
Go to the source code of this file.
Data Structures | |
struct | mapentry |
struct | imagemap |
Macros | |
#define | HASH_SIZE 31 /* fixed size hash table */ |
Enumerations | |
enum | imagemap_entry_type { IMAGEMAP_DEFAULT , IMAGEMAP_RECT , IMAGEMAP_CIRCLE , IMAGEMAP_POLY } |
Functions | |
static bool | imagemap_create (html_content *c) |
Create hashtable of imagemaps. More... | |
static unsigned int | imagemap_hash (const char *key) |
Hash function. More... | |
static bool | imagemap_add (html_content *c, dom_string *key, struct mapentry *list) |
Add an imagemap to the hashtable, creating it if it doesn't exist. More... | |
static void | imagemap_freelist (struct mapentry *list) |
Free list of imagemap entries. More... | |
void | imagemap_destroy (html_content *c) |
Destroy hashtable of imagemaps. More... | |
void | imagemap_dump (html_content *c) |
Dump imagemap data to the log. More... | |
static bool | imagemap_addtolist (const struct html_content *c, dom_node *n, nsurl *base_url, struct mapentry **entry, dom_string *tagtype) |
Adds an imagemap entry to the list. More... | |
static bool | imagemap_extract_map_entries (dom_node *node, html_content *c, struct mapentry **entry, dom_string *tname) |
Extract an imagemap from html source. More... | |
static bool | imagemap_extract_map (dom_node *node, html_content *c, struct mapentry **entry) |
Extract an imagemap from html source. More... | |
nserror | imagemap_extract (html_content *c) |
Extract all imagemaps from a document tree. More... | |
static int | imagemap_point_in_poly (int num, float *xpt, float *ypt, unsigned long x, unsigned long y, unsigned long click_x, unsigned long click_y) |
Test if a point lies within an arbitrary polygon Modified from comp.graphics.algorithms FAQ 2.03. More... | |
nsurl * | imagemap_get (struct html_content *c, const char *key, unsigned long x, unsigned long y, unsigned long click_x, unsigned long click_y, const char **target) |
Retrieve url associated with imagemap entry. More... | |
Implementation of HTML image maps.
Definition in file imagemap.c.
#define HASH_SIZE 31 /* fixed size hash table */ |
Definition at line 43 of file imagemap.c.
enum imagemap_entry_type |
Enumerator | |
---|---|
IMAGEMAP_DEFAULT | |
IMAGEMAP_RECT | |
IMAGEMAP_CIRCLE | |
IMAGEMAP_POLY |
Definition at line 45 of file imagemap.c.
|
static |
Add an imagemap to the hashtable, creating it if it doesn't exist.
c | The containing content |
key | The name of the imagemap |
list | List of map regions |
Definition at line 131 of file imagemap.c.
References imagemap_create(), imagemap_hash(), html_content::imagemaps, imagemap::key, imagemap::list, and imagemap::next.
Referenced by imagemap_extract().
|
static |
Adds an imagemap entry to the list.
c | The html content that the imagemap belongs to |
n | The xmlNode representing the entry to add |
base_url | Base URL for resolving relative URLs |
entry | Pointer to list of entries |
tagtype | The type of tag |
Definition at line 303 of file imagemap.c.
References mapentry::bounds, box_extract_link(), mapentry::circle, IMAGEMAP_CIRCLE, IMAGEMAP_DEFAULT, IMAGEMAP_POLY, IMAGEMAP_RECT, mapentry::next, nsurl_unref(), mapentry::num, mapentry::poly, mapentry::r, mapentry::rect, mapentry::target, mapentry::type, mapentry::url, mapentry::x, mapentry::x0, mapentry::x1, mapentry::xcoords, mapentry::y, mapentry::y0, mapentry::y1, and mapentry::ycoords.
Referenced by imagemap_extract_map_entries().
|
static |
Create hashtable of imagemaps.
c | The containing content |
Definition at line 89 of file imagemap.c.
References HASH_SIZE, and html_content::imagemaps.
Referenced by imagemap_add().
void imagemap_destroy | ( | html_content * | c | ) |
Destroy hashtable of imagemaps.
c | The containing content |
Definition at line 200 of file imagemap.c.
References HASH_SIZE, imagemap_freelist(), html_content::imagemaps, imagemap::key, imagemap::list, and imagemap::next.
Referenced by html_destroy().
void imagemap_dump | ( | html_content * | c | ) |
Dump imagemap data to the log.
c | The containing content |
Definition at line 231 of file imagemap.c.
References mapentry::bounds, mapentry::circle, HASH_SIZE, IMAGEMAP_CIRCLE, IMAGEMAP_DEFAULT, IMAGEMAP_POLY, IMAGEMAP_RECT, html_content::imagemaps, imagemap::key, imagemap::list, mapentry::next, imagemap::next, NSLOG, nsurl_access(), mapentry::num, mapentry::poly, mapentry::r, mapentry::rect, mapentry::type, mapentry::url, mapentry::x, mapentry::x0, mapentry::x1, mapentry::xcoords, mapentry::y, mapentry::y0, mapentry::y1, and mapentry::ycoords.
nserror imagemap_extract | ( | html_content * | c | ) |
Extract all imagemaps from a document tree.
c | The content to extract imagemaps from. |
Definition at line 603 of file imagemap.c.
References html_content::document, imagemap_add(), imagemap_extract_map(), imagemap_freelist(), NSERROR_DOM, NSERROR_NOMEM, and NSERROR_OK.
Referenced by html_box_convert_done().
|
static |
Extract an imagemap from html source.
node | XML node containing map |
c | Content containing document |
entry | List of map entries |
Definition at line 586 of file imagemap.c.
References imagemap_extract_map_entries().
Referenced by imagemap_extract().
|
static |
Extract an imagemap from html source.
node | XML node containing map |
c | Content containing document |
entry | List of map entries |
tname | The sub-tags to consider on this pass |
Definition at line 537 of file imagemap.c.
References html_content::base_url, and imagemap_addtolist().
Referenced by imagemap_extract_map().
|
static |
Free list of imagemap entries.
list | Pointer to head of list |
Definition at line 169 of file imagemap.c.
References mapentry::bounds, IMAGEMAP_POLY, mapentry::next, nsurl_unref(), mapentry::poly, mapentry::target, mapentry::type, mapentry::url, mapentry::xcoords, and mapentry::ycoords.
Referenced by imagemap_destroy(), and imagemap_extract().
nsurl * imagemap_get | ( | struct html_content * | c, |
const char * | key, | ||
unsigned long | x, | ||
unsigned long | y, | ||
unsigned long | click_x, | ||
unsigned long | click_y, | ||
const char ** | target | ||
) |
Retrieve url associated with imagemap entry.
c | The containing content |
key | The map name to search for |
x | The left edge of the containing box |
y | The top edge of the containing box |
click_x | The horizontal location of the click |
click_y | The vertical location of the click |
target | Pointer to location to receive target pointer (if any) |
Definition at line 737 of file imagemap.c.
References mapentry::bounds, mapentry::circle, IMAGEMAP_CIRCLE, IMAGEMAP_DEFAULT, imagemap_hash(), imagemap_point_in_poly(), IMAGEMAP_POLY, IMAGEMAP_RECT, html_content::imagemaps, imagemap::key, imagemap::list, mapentry::next, imagemap::next, mapentry::num, mapentry::poly, mapentry::r, mapentry::rect, mapentry::target, mapentry::type, mapentry::url, mapentry::x, mapentry::x0, mapentry::xcoords, mapentry::y, mapentry::y0, and mapentry::ycoords.
Referenced by get_mouse_action_node(), and html_get_contextual_content().
|
static |
Hash function.
key | The key to hash. |
Definition at line 109 of file imagemap.c.
References HASH_SIZE, and imagemap::key.
Referenced by imagemap_add(), and imagemap_get().
|
static |
Test if a point lies within an arbitrary polygon Modified from comp.graphics.algorithms FAQ 2.03.
num | Number of vertices |
xpt | Array of x coordinates |
ypt | Array of y coordinates |
x | Left hand edge of containing box |
y | Top edge of containing box |
click_x | X coordinate of click |
click_y | Y coordinate of click |
Definition at line 706 of file imagemap.c.
References mapentry::num, mapentry::x, and mapentry::y.
Referenced by imagemap_get().