source: gaycko/trunk/src/dom/dom.h @ 4768

Last change on this file since 4768 was 4768, checked in by Jean-Yves Lamoureux, 10 years ago
  • Reworked table handling
File size: 2.1 KB
Line 
1/*
2 *  Gaycko        Text mode web browser
3 *  Copyright (c) 2011 Jean-Yves Lamoureux <jylam@lnxscene.org>
4 *                All Rights Reserved
5 *
6 *  This library is free software. It comes without any warranty, to
7 *  the extent permitted by applicable law. You can redistribute it
8 *  and/or modify it under the terms of the Do What The Fuck You Want
9 *  To Public License, Version 2, as published by Sam Hocevar. See
10 *  http://sam.zoy.org/wtfpl/COPYING for more details.
11 */
12#ifndef _DOM_H
13#define _DOM_H
14
15#include <libxml/parser.h>
16#include <libxml/xinclude.h>
17#include <libxml/tree.h>
18#include <libxml/xmlIO.h>
19#include <libxml/HTMLparser.h>
20
21
22typedef enum  {
23    ELEM_UNKNOW = 0,
24    ELEM_TEXT,
25    ELEM_HTML,
26    ELEM_HEAD,
27    ELEM_TITLE,
28    ELEM_META,
29    ELEM_BODY,
30    ELEM_H1,
31    ELEM_H2,
32    ELEM_H3,
33    ELEM_BR,
34    ELEM_HR,
35    ELEM_P,
36    ELEM_IMG,
37    ELEM_TABLE,
38    ELEM_TR,
39    ELEM_TD
40}nodeType;
41
42typedef struct gNode_ gNode;
43
44struct gProperty_ {
45    unsigned int x, y;
46    unsigned int width, height;
47};
48typedef struct gProperty_ gProperty;
49
50
51
52struct gAttribute_ {
53    char *name;
54    char *value;
55};
56typedef struct gAttribute_ gAttribute;
57
58
59
60struct gTable_ {
61    unsigned int border;
62        unsigned int tr_count;
63    gNode  **tr;
64   
65};
66typedef struct gTable_ gTable;
67
68
69struct gTr_ {
70    unsigned int border;
71        unsigned int td_count;
72    gNode **td;
73};
74typedef struct gTr_ gTr;
75
76
77struct gNode_ {
78   
79    /* General */
80    nodeType  type;
81        char        *name;
82    unsigned int level;
83   
84    unsigned int children_count;
85    gNode   **children;
86   
87   
88    unsigned int attribute_count;
89    gAttribute  *attributes;
90    char        *text;
91   
92    gNode     *parent;
93
94   
95    /* Rendering */
96    gProperty *properties;
97    union  {
98        gTable *table;
99        gTr    *tr;
100    }specific;
101
102};
103
104
105struct gDOM_ {
106        gNode *root;
107};
108
109typedef struct gDOM_ gDOM;
110
111
112gDOM *gaycko_convert_dom(htmlDocPtr doc);
113gNode* explore(gNode **elem, htmlNodePtr element, unsigned int level , gNode *parent);
114gNode *add_node(htmlNodePtr node);
115void destroy_node(gNode *elem);
116void pretty_print(gNode *elem);
117
118#endif
Note: See TracBrowser for help on using the repository browser.