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

Last change on this file since 4759 was 4759, checked in by Jean-Yves Lamoureux, 10 years ago
  • Added fix_table and fix_tr
File size: 2.0 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
42
43struct gProperty_ {
44    unsigned int x, y;
45    unsigned int width, height;
46};
47typedef struct gProperty_ gProperty;
48
49
50
51struct gAttribute_ {
52    char *name;
53    char *value;
54};
55typedef struct gAttribute_ gAttribute;
56
57struct gTable_ {
58    unsigned int border;
59        unsigned int tr_count; 
60};
61typedef struct gTable_ gTable;
62
63struct gTr_ {
64    unsigned int border;
65        unsigned int td_count; 
66};
67typedef struct gTr_ gTr;
68
69typedef struct gNode_ gNode;
70struct gNode_ {
71   
72    /* General */
73    nodeType  type;
74        char        *name;
75    unsigned int level;
76   
77    unsigned int children_count;
78    gNode   **children;
79   
80   
81    unsigned int attribute_count;
82    gAttribute  *attributes;
83    char        *text;
84   
85    gNode     *parent;
86
87   
88    /* Rendering */
89    gProperty *properties;
90    union  {
91        gTable *table;
92        gTr    *tr;
93    }specific;
94
95};
96
97
98struct gDOM_ {
99        gNode *root;
100};
101
102typedef struct gDOM_ gDOM;
103
104
105gDOM *gaycko_convert_dom(htmlDocPtr doc);
106gNode* explore(gNode **elem, htmlNodePtr element, unsigned int level , gNode *parent);
107gNode *add_node(htmlNodePtr node);
108void destroy_node(gNode *elem);
109void pretty_print(gNode *elem);
110
111#endif
Note: See TracBrowser for help on using the repository browser.