~ubuntu-branches/debian/sid/tk-html3/sid

« back to all changes in this revision

Viewing changes to .pc/remove_some_asserts.patch/src/html.h

  • Committer: Package Import Robot
  • Author(s): Ole Streicher
  • Date: 2014-04-14 14:31:32 UTC
  • Revision ID: package-import@ubuntu.com-20140414143132-dmq7eyq9m0ndtdmo
Tags: 3.0~fossil20110109-3
* Push to newest standards (3.9.5) and dh (9) and solve lintian warnings
* Remove some asserts to make it more stable [Stefan Ziegler]

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * html.h --
 
3
 *
 
4
 *----------------------------------------------------------------------------
 
5
 * Copyright (c) 2005 Dan Kennedy.
 
6
 * All rights reserved.
 
7
 *
 
8
 * This Open Source project was made possible through the financial support
 
9
 * of Eolas Technologies Inc.
 
10
 * 
 
11
 * Redistribution and use in source and binary forms, with or without
 
12
 * modification, are permitted provided that the following conditions are met:
 
13
 * 
 
14
 *     * Redistributions of source code must retain the above copyright
 
15
 *       notice, this list of conditions and the following disclaimer.
 
16
 *     * Redistributions in binary form must reproduce the above copyright
 
17
 *       notice, this list of conditions and the following disclaimer in the
 
18
 *       documentation and/or other materials provided with the distribution.
 
19
 *     * Neither the name of Eolas Technologies. nor the names of its
 
20
 *       contributors may be used to endorse or promote products derived from
 
21
 *       this software without specific prior written permission.
 
22
 * 
 
23
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 
24
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
25
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
26
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 
27
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 
28
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 
29
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 
30
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 
31
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 
32
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 
33
 * POSSIBILITY OF SUCH DAMAGE.
 
34
 */
 
35
 
 
36
#ifndef __HTMLTREE_H__
 
37
#define __HTMLTREE_H__
 
38
 
 
39
/*
 
40
 * Without exception the tkhtml code uses the wrapper functions HtmlAlloc(),
 
41
 * HtmlFree() and HtmlRealloc() in place of the regular Tcl ckalloc(), ckfree()
 
42
 * and ckrealloc() functions.
 
43
 */
 
44
#ifdef HTML_DEBUG
 
45
    #include "restrack.h"
 
46
 
 
47
    #define HtmlAlloc(zTopic, n) Rt_Alloc((zTopic), n)
 
48
    #define HtmlFree(x) Rt_Free((char *)(x))
 
49
    #define HtmlRealloc(zTopic, x, n) Rt_Realloc(zTopic , (char *)(x), (n))
 
50
#else
 
51
    #define HtmlAlloc(zTopic, n) ckalloc(n)
 
52
    #define HtmlFree(x) ckfree((char *)(x))
 
53
    #define HtmlRealloc(zTopic, x, n) ckrealloc((char *)(x), n)
 
54
#endif
 
55
 
 
56
/* HtmlClearAlloc() is a version of HtmlAlloc() that returns zeroed memory */
 
57
#define HtmlClearAlloc(zTopic, x) ((char *)memset(HtmlAlloc(zTopic,(x)),0,(x)))
 
58
 
 
59
#define HtmlNew(x) ((x *)HtmlClearAlloc(#x, sizeof(x)))
 
60
 
 
61
#define USE_COMPOSITELESS_PHOTO_PUT_BLOCK
 
62
#include <tk.h>
 
63
 
 
64
#include <string.h>
 
65
#include <assert.h>
 
66
#include <stdlib.h>
 
67
 
 
68
#include "htmltokens.h"
 
69
#include "htmlmacros.h"
 
70
 
 
71
/*
 
72
 * Version information for the package mechanism.
 
73
 */
 
74
#define HTML_PKGNAME "Tkhtml"
 
75
#define HTML_PKGVERSION "3.0"
 
76
 
 
77
/*
 
78
 * Various data types.  This code is designed to run on a modern
 
79
 * cached architecture where the CPU runs a lot faster than the
 
80
 * memory bus.  Hence we try to pack as much data into as small a space
 
81
 * as possible so that it is more likely to fit in cache.  The
 
82
 * extra CPU instruction or two needed to unpack the data is not
 
83
 * normally an issue since we expect the speed of the memory bus 
 
84
 * to be the limiting factor.
 
85
 */
 
86
typedef unsigned char  Html_u8;      /* 8-bit unsigned integer */
 
87
typedef short          Html_16;      /* 16-bit signed integer */
 
88
typedef unsigned short Html_u16;     /* 16-bit unsigned integer */
 
89
typedef int            Html_32;      /* 32-bit signed integer */
 
90
 
 
91
/*
 
92
 * Linux doesn't have a stricmp() function and windows doesn't have
 
93
 * strcasecmp(). Tkhtml3 code uses stricmp (and strnicmp) because
 
94
 * it is faster to type.
 
95
 */
 
96
#ifndef __WIN32__
 
97
# define stricmp strcasecmp
 
98
# define strnicmp strncasecmp
 
99
#endif
 
100
 
 
101
/*
 
102
 * Some versions of windows do not have the vsnprintf() and snprintf()
 
103
 * macros. According to msdn, these are for "backwards compatibility" only.
 
104
 */
 
105
#ifdef __WIN32__
 
106
# define vsnprintf _vsnprintf
 
107
# define snprintf _snprintf
 
108
#endif
 
109
 
 
110
typedef struct HtmlNodeStack HtmlNodeStack;
 
111
typedef struct HtmlOptions HtmlOptions;
 
112
typedef struct HtmlTree HtmlTree;
 
113
typedef struct HtmlTreeState HtmlTreeState;
 
114
typedef struct HtmlAttributes HtmlAttributes;
 
115
typedef struct HtmlTokenMap HtmlTokenMap;
 
116
typedef struct HtmlCanvas HtmlCanvas;
 
117
typedef struct HtmlCanvasItem HtmlCanvasItem;
 
118
typedef struct HtmlFloatList HtmlFloatList;
 
119
typedef struct HtmlPropertyCache HtmlPropertyCache;
 
120
typedef struct HtmlNodeReplacement HtmlNodeReplacement;
 
121
typedef struct HtmlCallback HtmlCallback;
 
122
typedef struct HtmlNodeCmd HtmlNodeCmd;
 
123
typedef struct HtmlLayoutCache HtmlLayoutCache;
 
124
typedef struct HtmlNodeScrollbars HtmlNodeScrollbars;
 
125
 
 
126
typedef struct HtmlImageServer HtmlImageServer;
 
127
typedef struct HtmlImage2 HtmlImage2;
 
128
 
 
129
typedef struct HtmlWidgetTag HtmlWidgetTag;
 
130
typedef struct HtmlTaggedRegion HtmlTaggedRegion;
 
131
typedef struct HtmlText HtmlText;
 
132
 
 
133
typedef struct HtmlNode HtmlNode;
 
134
typedef struct HtmlElementNode HtmlElementNode;
 
135
typedef struct HtmlTextNode HtmlTextNode;
 
136
 
 
137
typedef struct HtmlTextToken HtmlTextToken;
 
138
typedef struct HtmlTextIter HtmlTextIter;
 
139
 
 
140
typedef struct HtmlDamage HtmlDamage;
 
141
 
 
142
typedef struct HtmlFragmentContext HtmlFragmentContext;
 
143
typedef struct HtmlSearchCache HtmlSearchCache;
 
144
 
 
145
#include "css.h"
 
146
#include "htmlprop.h"
 
147
 
 
148
typedef int (*HtmlContentTest)(HtmlTree *, HtmlNode *, int);
 
149
 
 
150
#define FLOAT_LEFT       CSS_CONST_LEFT
 
151
#define FLOAT_RIGHT      CSS_CONST_RIGHT
 
152
#define FLOAT_NONE       CSS_CONST_NONE
 
153
 
 
154
#define CLEAR_NONE       CSS_CONST_NONE
 
155
#define CLEAR_LEFT       CSS_CONST_LEFT
 
156
#define CLEAR_RIGHT      CSS_CONST_RIGHT
 
157
#define CLEAR_BOTH       CSS_CONST_BOTH
 
158
 
 
159
struct HtmlTokenMap {
 
160
  char *zName;                    /* Name of a markup */
 
161
  Html_16 type;                   /* Markup type code */
 
162
  Html_u8 flags;                  /* Combination of HTMLTAG values */
 
163
  HtmlContentTest xClose;         /* Function to identify close tag */
 
164
  HtmlTokenMap *pCollide;         /* Hash table collision chain */
 
165
};
 
166
 
 
167
#define HTMLTAG_INLINE      0x02  /* Set for an HTML inline tag */
 
168
#define HTMLTAG_BLOCK       0x04  /* Set for an HTML block tag */
 
169
#define HTMLTAG_EMPTY       0x08  /* Set for an empty tag (i.e. <img>) */
 
170
 
 
171
#define HTMLTAG_HEAD        0x10  /* Element must go in <head> */
 
172
#define HTMLTAG_BODY        0x20  /* Element must go in <body> */
 
173
#define HTMLTAG_FRAMESET    0x40  /* Element is from a frameset document */
 
174
#define HTMLTAG_PCDATA      0x80  /* Contents of element is PCDATA */
 
175
 
 
176
#define TAG_CLOSE    1
 
177
#define TAG_PARENT   2
 
178
#define TAG_OK       3
 
179
 
 
180
struct HtmlAttributes {
 
181
    int nAttr;
 
182
    struct HtmlAttribute {
 
183
        char *zName;
 
184
        char *zValue;
 
185
    } a[1];
 
186
};
 
187
 
 
188
/*
 
189
 * For a replaced node, the HtmlNode.pReplacement variable points to an
 
190
 * instance of the following structure. The member objects are the name of
 
191
 * the replaced object (widget handle), the configure script if any, and the
 
192
 * delete script if any. i.e. in Tcl:
 
193
 *
 
194
 *     $nodeHandle replace $pReplace \
 
195
 *             -configurecmd $pConfigure -deletecmd $pDelete
 
196
 *
 
197
 * The iOffset variable holds the integer returned by any -configurecmd
 
198
 * script (default value 0). This is assumed to be the number of pixels
 
199
 * between the bottom of the replacement window and the point that should
 
200
 * be aligned with the bottom of a line-box. i.e. equivalent to the 
 
201
 * "descent" property of a font.
 
202
 */
 
203
struct HtmlNodeReplacement {
 
204
    Tcl_Obj *pReplace;            /* Replacement window name */
 
205
    Tk_Window win;                /* Replacement window (if any) */
 
206
    Tcl_Obj *pConfigureCmd;       /* Script passed to -configurecmd */
 
207
    Tcl_Obj *pStyleCmd;           /* Script passed to -stylecmd */
 
208
    Tcl_Obj *pDelete;             /* Script passed to -deletecmd */
 
209
    int iOffset;                  /* See above */
 
210
 
 
211
    /* Display related variables */
 
212
    int clipped;                  /* Boolean. If true, do not display */
 
213
    int iCanvasX;                 /* Current X canvas coordinate of window */
 
214
    int iCanvasY;                 /* Current Y canvas coordinate of window */
 
215
    int iWidth;                   /* Current calculated pixel width of window*/
 
216
    int iHeight;                  /* Current calculated pixel height of window*/
 
217
    HtmlNodeReplacement *pNext;   /* Next element in HtmlTree.pMapped list */
 
218
};
 
219
 
 
220
/*
 
221
 * When a Tcl command representing a node-handle is created, an instance of the 
 
222
 * following structure is allocated.
 
223
 */
 
224
struct HtmlNodeCmd {
 
225
    Tcl_Obj *pCommand;
 
226
    HtmlTree *pTree;
 
227
};
 
228
 
 
229
struct HtmlNodeStack {
 
230
    HtmlElementNode *pElem;
 
231
    int eType;              /* Usage defined in htmlstyle.c */
 
232
 
 
233
    HtmlNodeStack *pNext;
 
234
    HtmlNodeStack *pPrev;
 
235
 
 
236
    /* These three are set by HtmlRestackNodes() after the style-engine
 
237
     * runs, and used by htmldraw.c at during drawing to determine the
 
238
     * relative z-axis position of each drawing primitive.
 
239
     */
 
240
    int iInlineZ;
 
241
    int iBlockZ;
 
242
    int iStackingZ;
 
243
};
 
244
 
 
245
/*
 
246
 * Scrollbar information for nodes with "overflow:auto" or "overflow:scroll".
 
247
 * Nodes for which the overflow property takes one of the other values 
 
248
 * ("hidden" or "visible") do not have an associated instance of this
 
249
 * structure. 
 
250
 *
 
251
 * The structure itself is allocated and released seperately for
 
252
 * each node by style-engine code. The layout-engine takes care of
 
253
 * creating the scrollbars (if required).
 
254
 */
 
255
struct HtmlNodeScrollbars {
 
256
    HtmlNodeReplacement vertical;
 
257
    HtmlNodeReplacement horizontal;
 
258
 
 
259
    int iVertical;
 
260
    int iHorizontal;
 
261
 
 
262
    int iHeight;               /* Height of viewport */
 
263
    int iWidth;                /* Width of viewport */
 
264
    int iVerticalMax;          /* Height of scrollable area */
 
265
    int iHorizontalMax;        /* Width of scrollable area */
 
266
};
 
267
 
 
268
/*
 
269
 * Widget tag properties. Each widget tag is stored in the 
 
270
 * HtmlTree.aTag hash table.
 
271
 */
 
272
struct HtmlWidgetTag {
 
273
    XColor *foreground;        /* Foreground color to use for tagged regions */
 
274
    XColor *background;        /* Background color to use for tagged regions */
 
275
};
 
276
 
 
277
/*
 
278
 * Each text node has a list of "tagged regions" attached to it (the 
 
279
 * list may be empty). See the HtmlTextNode.pTagged variable.
 
280
 */
 
281
struct HtmlTaggedRegion {
 
282
    int iFrom;                 /* Index the region starts at */
 
283
    int iTo;                   /* Index the region ends at */
 
284
    HtmlWidgetTag *pTag;       /* Tag properties */
 
285
    HtmlTaggedRegion *pNext;   /* Next tagged region of this text node */
 
286
};
 
287
 
 
288
/* 
 
289
 * Each node of the document tree is represented as an HtmlNode structure.
 
290
 * This structure carries no information to do with the node itself, it is
 
291
 * simply used to build the tree structure. All the information for the
 
292
 * node is carried by the derived classes HtmlTextNode and HtmlElementNode.
 
293
 */
 
294
struct HtmlNode {
 
295
    ClientData clientData;
 
296
    HtmlNode *pParent;             /* Parent of this node */
 
297
    int iNode;                     /* Node index */
 
298
 
 
299
    Html_u8 eTag;                  /* Tag type (or 0) */
 
300
    const char *zTag;              /* Atom string for tag type */
 
301
 
 
302
    int iSnapshot;                 /* Last changed snapshot */
 
303
    HtmlNodeCmd *pNodeCmd;         /* Tcl command for this node */
 
304
 
 
305
    /* Cache used for [$widget bbox] */
 
306
    int iBboxX; int iBboxY;
 
307
    int iBboxX2; int iBboxY2;
 
308
};
 
309
 
 
310
/* Value of HtmlNode.iNode for orphan and generated nodes. */
 
311
#define HTML_NODE_ORPHAN -23
 
312
#define HTML_NODE_GENERATED -1
 
313
 
 
314
/*
 
315
 * Structure to store a text node.
 
316
 */
 
317
struct HtmlTextNode {
 
318
    HtmlNode node;                 /* Base class. MUST BE FIRST. */
 
319
    HtmlTaggedRegion *pTagged;     /* List of applied Widget tags */
 
320
 
 
321
    /* These variables are manipulated by code in htmltext.c. They are
 
322
     * populated when this structure is allocated (function HtmlTextNew()),
 
323
     * and accessed using the HtmlTextIterXXX() API. See comments in 
 
324
     * htmltext.c for a description.
 
325
     */
 
326
    HtmlTextToken *aToken;
 
327
    char *zText;
 
328
};
 
329
 
 
330
/*
 
331
 * The name of the attribute parsed to generate inline-style properties
 
332
 * for an element (HtmlElementNode.pStyle).
 
333
 */
 
334
#define HTML_INLINE_STYLE_ATTR "style"
 
335
 
 
336
/*
 
337
 * Structure to store an element (non-text) node.
 
338
 */
 
339
struct HtmlElementNode {
 
340
    HtmlNode node;          /* Base class. MUST BE FIRST. */
 
341
 
 
342
    HtmlAttributes *pAttributes;      /* Html attributes associated with node */
 
343
 
 
344
    /* Children of this element node */
 
345
    int nChild;                    /* Number of child nodes */
 
346
    HtmlNode **apChildren;         /* Array of pointers to children nodes */
 
347
 
 
348
    CssPropertySet *pStyle;                /* Parsed inline style */
 
349
 
 
350
    /* Information generated by the style engine */
 
351
    HtmlComputedValues *pPropertyValues;   /* Current CSS property values */
 
352
    HtmlComputedValues *pPreviousValues;   /* Previous CSS property values */
 
353
    CssDynamic *pDynamic;                  /* CSS dynamic conditions */
 
354
    Tcl_Obj *pOverride;                    /* List of property overrides */
 
355
    HtmlNodeStack *pStack;                 /* Stacking context */
 
356
    HtmlNode *pBefore;                     /* Generated :before content */
 
357
    HtmlNode *pAfter;                      /* Generated :after content */
 
358
 
 
359
    /* Manipulated by the [nodeHandle dynamic] command */
 
360
    Html_u8 flags;                         /* HTML_DYNAMIC_XXX flags */
 
361
 
 
362
    HtmlNodeReplacement *pReplacement;     /* Replaced object, if any */
 
363
    HtmlLayoutCache *pLayoutCache;         /* Cached layout, if any */
 
364
    HtmlNodeScrollbars *pScrollbar;        /* Internal scrollbars, if any */
 
365
 
 
366
    HtmlCanvasItem *pBox;
 
367
};
 
368
 
 
369
/* Alias for HtmlNodeXXX() methods */
 
370
#define HtmlElemParent(p) ((HtmlElementNode *)HtmlNodeParent(&(p)->node))
 
371
 
 
372
/* Values for HtmlNode.flags. These may be set and cleared via the Tcl
 
373
 * interface on the node command: [$node dynamic set|clear ...]
 
374
 */
 
375
#define HTML_DYNAMIC_HOVER    0x01
 
376
#define HTML_DYNAMIC_FOCUS    0x02
 
377
#define HTML_DYNAMIC_ACTIVE   0x04
 
378
#define HTML_DYNAMIC_LINK     0x08
 
379
#define HTML_DYNAMIC_VISITED  0x10
 
380
#define HTML_DYNAMIC_USERFLAG 0x20
 
381
 
 
382
struct HtmlCanvas {
 
383
    int left;
 
384
    int right;
 
385
    int top;
 
386
    int bottom;
 
387
    HtmlCanvasItem *pFirst;
 
388
    HtmlCanvasItem *pLast;
 
389
};
 
390
 
 
391
/*
 
392
 * All widget options are stored in this structure, which is a part of
 
393
 * the HtmlTree structure (HtmlTree.options).
 
394
 *
 
395
 * All of the options in this structure should be documented in the 
 
396
 * Tkhtml3 man-page. If they are not, please report a bug.
 
397
 */
 
398
struct HtmlOptions {
 
399
 
 
400
    /* Tkhtml3 supports the following standard Tk options */
 
401
    int      width;
 
402
    int      height;
 
403
    int      xscrollincrement;
 
404
    int      yscrollincrement;
 
405
    Tcl_Obj *yscrollcommand;
 
406
    Tcl_Obj *xscrollcommand;
 
407
 
 
408
    Tcl_Obj *defaultstyle;
 
409
    double   fontscale;
 
410
    Tcl_Obj *fonttable;
 
411
    int      forcefontmetrics;
 
412
    int      forcewidth;
 
413
    Tcl_Obj *imagecmd;
 
414
    int      imagecache;
 
415
    int      imagepixmapify;
 
416
    int      mode;                      /* One of the HTML_MODE_XXX values */
 
417
    int      shrink;                    /* Boolean */
 
418
    double   zoom;                      /* Universal scaling factor. */
 
419
 
 
420
    int      parsemode;                 /* One of the HTML_PARSEMODE values */
 
421
 
 
422
    /* Debugging options. Not part of the official interface. */
 
423
    int      enablelayout;
 
424
    int      layoutcache;
 
425
    Tcl_Obj *logcmd;
 
426
    Tcl_Obj *timercmd;
 
427
};
 
428
 
 
429
#define HTML_MODE_QUIRKS    0
 
430
#define HTML_MODE_ALMOST    1
 
431
#define HTML_MODE_STANDARDS 2
 
432
 
 
433
#define HTML_PARSEMODE_HTML    0
 
434
#define HTML_PARSEMODE_XHTML   1
 
435
#define HTML_PARSEMODE_XML     2
 
436
 
 
437
void HtmlLog(HtmlTree *, CONST char *, CONST char *, ...);
 
438
void HtmlTimer(HtmlTree *, CONST char *, CONST char *, ...);
 
439
 
 
440
typedef struct HtmlCanvasSnapshot HtmlCanvasSnapshot;
 
441
 
 
442
struct HtmlDamage {
 
443
  int x;
 
444
  int y;
 
445
  int w;
 
446
  int h;
 
447
  int windowsrepair;
 
448
  HtmlDamage *pNext;
 
449
};
 
450
 
 
451
/*
 
452
 * Widget state information information is stored in an instance of this
 
453
 * structure, which is a part of the HtmlTree. The variables within control 
 
454
 * the behaviour of the idle callback scheduled to update the display.
 
455
 */
 
456
struct HtmlCallback {
 
457
    int flags;                  /* Comb. of HTML_XXX bitmasks defined below */
 
458
    int inProgress;             /* Prevent recursive invocation */
 
459
    int isForce;                /* Not an idle callback */
 
460
 
 
461
    /* Snapshot of layout before the latest round of changes. This is
 
462
     * used to reduce the area repainted during "animation" changes.
 
463
     * (drag and drop, menus etc. in javascript).
 
464
     */
 
465
    HtmlCanvasSnapshot *pSnapshot;
 
466
 
 
467
    /* HTML_DYNAMIC */
 
468
    HtmlNode *pDynamic;         /* Recalculate dynamic CSS for this node */
 
469
 
 
470
    /* HTML_DAMAGE */
 
471
    HtmlDamage *pDamage;
 
472
 
 
473
    /* HTML_RESTYLE */
 
474
    HtmlNode *pRestyle;         /* Restyle this node */
 
475
 
 
476
    /* HTML_SCROLL */
 
477
    int iScrollX;               /* New HtmlTree.iScrollX value */
 
478
    int iScrollY;               /* New HtmlTree.iScrollY value */
 
479
};
 
480
 
 
481
/* Values for HtmlCallback.flags */
 
482
#define HTML_DYNAMIC    0x01
 
483
#define HTML_DAMAGE     0x02
 
484
#define HTML_RESTYLE    0x04
 
485
#define HTML_LAYOUT     0x08
 
486
#define HTML_SCROLL     0x10
 
487
#define HTML_STACK      0x20
 
488
#define HTML_NODESCROLL 0x40
 
489
 
 
490
/* 
 
491
 * Functions used to schedule callbacks and set the HtmlCallback state. 
 
492
 */
 
493
void HtmlCallbackForce(HtmlTree *);
 
494
void HtmlCallbackDynamic(HtmlTree *, HtmlNode *);
 
495
void HtmlCallbackDamage(HtmlTree *, int, int, int, int);
 
496
void HtmlCallbackLayout(HtmlTree *, HtmlNode *);
 
497
void HtmlCallbackRestyle(HtmlTree *, HtmlNode *);
 
498
 
 
499
void HtmlCallbackScrollX(HtmlTree *, int);
 
500
void HtmlCallbackScrollY(HtmlTree *, int);
 
501
 
 
502
void HtmlCallbackDamageNode(HtmlTree *, HtmlNode *);
 
503
 
 
504
/*
 
505
 * An instance of the following structure stores state for the tree
 
506
 * construction phase. See the following functions:
 
507
 *
 
508
 *     HtmlTreeAddElement()
 
509
 *     HtmlTreeAddText()
 
510
 *     HtmlTreeAddClosingTag()
 
511
 */
 
512
struct HtmlTreeState {
 
513
    HtmlNode *pCurrent;     /* By default, add new elements as children here */
 
514
    HtmlNode *pFoster;      /* The current node in the foster tree (if any) */
 
515
    int isCdataInHead;      /* True if previous token was <title> */
 
516
};
 
517
 
 
518
struct HtmlTree {
 
519
 
 
520
    /*
 
521
     * The interpreter hosting this widget instance.
 
522
     */
 
523
    Tcl_Interp *interp;             /* Tcl interpreter */
 
524
 
 
525
    /*
 
526
     * The widget window.
 
527
     */
 
528
    Tk_Window tkwin;           /* Widget window */
 
529
    int iScrollX;              /* Number of pixels offscreen to the left */
 
530
    int iScrollY;              /* Number of pixels offscreen to the top */
 
531
 
 
532
    Tk_Window docwin;          /* Document window */
 
533
 
 
534
    /*
 
535
     * The widget command.
 
536
     */
 
537
    Tcl_Command cmd;           /* Widget command */
 
538
    int isDeleted;             /* True once the widget-delete has begun */
 
539
 
 
540
    /*
 
541
     * The image server object.
 
542
     */
 
543
    HtmlImageServer *pImageServer;
 
544
 
 
545
    /*
 
546
     * The search cache object.
 
547
     */
 
548
    HtmlSearchCache *pSearchCache;
 
549
 
 
550
    /* The following variables are used to stored the text of the current
 
551
     * document (i.e. the *.html file) as it is being parsed.
 
552
     *
 
553
     * nParsed and nCharParsed are kept in sync. If the document consists
 
554
     * entirely of 7-bit ASCII, then they are equal. The nCharParsed variable
 
555
     * is required so that the offsets passed to parse-handler callbacks
 
556
     * are in characters, not bytes. TODO! See ticket #126.
 
557
     */
 
558
    Tcl_Obj *pDocument;             /* Text of the html document */
 
559
    int nParsed;                    /* Bytes of pDocument tokenized */
 
560
    int nCharParsed;                /* TODO: Characters parsed */
 
561
 
 
562
    int iWriteInsert;               /* Byte offset in pDocument for [write] */
 
563
    int eWriteState;                /* One of the HTML_WRITE_XXX values */
 
564
 
 
565
    int isIgnoreNewline;            /* True after an opening tag */
 
566
    int isParseFinished;            /* True if the html parse is finished */
 
567
 
 
568
    HtmlNode *pRoot;                /* The root-node of the document. */
 
569
 
 
570
    Tcl_HashTable aAtom;            /* String atoms for this widget */
 
571
 
 
572
    HtmlTreeState state;
 
573
 
 
574
    /* Sub-trees that are not currently linked into the tree rooted at 
 
575
     * pRoot are stored in the following hash-table. The HTML_NODE_ORPHAN
 
576
     * flag is set in the HtmlNode.flags member of the root of each tree.
 
577
     *
 
578
     * The key for each entry is the pointer to the HtmlNode structure
 
579
     * that is the root of the orphaned tree. Hash entry data is not used.
 
580
     */
 
581
    Tcl_HashTable aOrphan;          /* Orphan nodes (see [$html fragment]) */
 
582
 
 
583
    /* This pointer is used to store context during the exeuction of 
 
584
     * the [$html fragment] command. See htmltree.c for details.
 
585
     */
 
586
    HtmlFragmentContext *pFragment;
 
587
 
 
588
    int isFixed;                    /* True if any "fixed" graphics */
 
589
 
 
590
    /*
 
591
     * Handler callbacks configured by the [$widget handler] command.
 
592
     *
 
593
     * The aScriptHandler hash table contains entries representing
 
594
     * script-handler callbacks. Each entry maps a tag-type (i.e. Html_P)
 
595
     * to a Tcl_Obj* that contains the Tcl script to call when the tag type is
 
596
     * encountered. A single argument is appended to the script - all the text
 
597
     * between the start and end tag. The ref-count of the Tcl_Obj* should be
 
598
     * decremented if it is removed from the hash table.
 
599
     *
 
600
     * The node-handler and parse-handler tables are similar.
 
601
     */
 
602
    Tcl_HashTable aScriptHandler;     /* Script handler callbacks. */
 
603
    Tcl_HashTable aNodeHandler;       /* Node handler callbacks. */
 
604
    Tcl_HashTable aParseHandler;      /* Parse handler callbacks. */
 
605
    Tcl_HashTable aAttributeHandler;  /* Attribute handler callbacks. */
 
606
 
 
607
    CssStyleSheet *pStyle;          /* Style sheet configuration */
 
608
 
 
609
    /* Used by code in HtmlStyleApply() */
 
610
    void *pStyleApply;
 
611
 
 
612
    HtmlOptions options;            /* Configurable options */
 
613
    Tk_OptionTable optionTable;     /* Option table */
 
614
 
 
615
    /* Linked list of stacking contexts */
 
616
    HtmlNodeStack *pStack;
 
617
    int nStack;                   /* Number of elements in linked list */
 
618
 
 
619
    /*
 
620
     * Internal representation of a completely layed-out document.
 
621
     */
 
622
    HtmlCanvas canvas;              /* Canvas to render into */
 
623
    int iCanvasWidth;               /* Width of window for canvas */
 
624
    int iCanvasHeight;              /* Height of window for canvas */
 
625
 
 
626
    /* Linked list of currently mapped replacement objects */
 
627
    HtmlNodeReplacement *pMapped;
 
628
 
 
629
    /* 
 
630
     * Tables managed by code in htmlprop.c. Initialised in function
 
631
     * HtmlComputedValuesSetupTables(), except for aFontSizeTable[], which is
 
632
     * set via the -fonttable option. 
 
633
     */
 
634
    Tcl_HashTable aColor;
 
635
    HtmlFontCache fontcache;
 
636
    Tcl_HashTable aValues;
 
637
    Tcl_HashTable aFontFamilies;
 
638
    Tcl_HashTable aCounterLists;
 
639
    HtmlComputedValuesCreator *pPrototypeCreator;
 
640
 
 
641
    int aFontSizeTable[7];
 
642
 
 
643
    /*
 
644
     * Hash table for all html widget tags (similar to text widget tags -
 
645
     * nothing to do with markup tags).
 
646
     */
 
647
    Tcl_HashTable aTag;
 
648
    Tk_OptionTable tagOptionTable;     /* Option table for tags*/
 
649
 
 
650
    /* The isSequenceOk variable is true if the HtmlNode.iNode values for all
 
651
     * nodes in the tree are currently in tree order.
 
652
     */
 
653
    int isSequenceOk;    
 
654
    int iNextNode;       /* Next node index to allocate */
 
655
 
 
656
    /* True if the HtmlElementNode.iBboxX and HtmlElementNode.iBboxY values
 
657
     * for all elements in the tree are valid.
 
658
     */
 
659
    int isBboxOk;
 
660
 
 
661
    HtmlCallback cb;                /* See structure definition comments */
 
662
    int iLastSnapshotId;            /* Last snapshot id allocated */
 
663
    Tcl_TimerToken delayToken;
 
664
 
 
665
    /* 
 
666
     * Data structure used by the [widget text] commands. See the
 
667
     * HtmlTextXXX() API below. 
 
668
     */
 
669
    HtmlText *pText;
 
670
 
 
671
#ifdef TKHTML_ENABLE_PROFILE
 
672
    /*
 
673
     * Client data from instrument command ([::tkhtml::instrument]).
 
674
     */
 
675
    ClientData pInstrumentData;
 
676
#endif
 
677
};
 
678
 
 
679
#define HTML_WRITE_NONE           0
 
680
#define HTML_WRITE_INHANDLER      1
 
681
#define HTML_WRITE_INHANDLERWAIT  2
 
682
#define HTML_WRITE_INHANDLERRESET 3
 
683
#define HTML_WRITE_WAIT           4
 
684
#define HTML_PARSE_NODEHANDLER    5
 
685
int HtmlWriteWait(HtmlTree *);
 
686
int HtmlWriteText(HtmlTree *, Tcl_Obj *);
 
687
int HtmlWriteContinue(HtmlTree *);
 
688
 
 
689
 
 
690
#define MAX(x,y)   ((x)>(y)?(x):(y))
 
691
#define MIN(x,y)   ((x)<(y)?(x):(y))
 
692
#define INTEGER(x) ((int)((x) + (((x) > 0.0) ? 0.49 : -0.49)))
 
693
 
 
694
void HtmlFinishNodeHandlers(HtmlTree *);
 
695
 
 
696
Tcl_ObjCmdProc HtmlTreeCollapseWhitespace;
 
697
Tcl_ObjCmdProc HtmlStyleSyntaxErrs;
 
698
Tcl_ObjCmdProc HtmlLayoutSize;
 
699
Tcl_ObjCmdProc HtmlLayoutNode;
 
700
Tcl_ObjCmdProc HtmlLayoutImage;
 
701
Tcl_ObjCmdProc HtmlLayoutPrimitives;
 
702
Tcl_ObjCmdProc HtmlCssStyleConfigDump;
 
703
Tcl_ObjCmdProc Rt_AllocCommand;
 
704
Tcl_ObjCmdProc HtmlWidgetBboxCmd;
 
705
Tcl_ObjCmdProc HtmlImageServerReport;
 
706
 
 
707
Tcl_ObjCmdProc HtmlDebug;
 
708
Tcl_ObjCmdProc HtmlDecode;
 
709
Tcl_ObjCmdProc HtmlEncode;
 
710
Tcl_ObjCmdProc HtmlEscapeUriComponent;
 
711
Tcl_ObjCmdProc HtmlResolveUri;
 
712
Tcl_ObjCmdProc HtmlCreateUri;
 
713
 
 
714
char *HtmlPropertyToString(CssProperty *, char **);
 
715
 
 
716
int HtmlStyleApply(HtmlTree *, HtmlNode *);
 
717
int HtmlStyleCounter(HtmlTree *, const char *);
 
718
int HtmlStyleCounters(HtmlTree *, const char *, int *, int);
 
719
void HtmlStyleHandleCounters(HtmlTree *, HtmlComputedValues *);
 
720
 
 
721
int HtmlLayout(HtmlTree *);
 
722
void HtmlLayoutMarkerBox(int, int, int, char *);
 
723
 
 
724
int HtmlStyleParse(HtmlTree*, Tcl_Obj*, Tcl_Obj*, Tcl_Obj*, Tcl_Obj*, Tcl_Obj*);
 
725
void HtmlTokenizerAppend(HtmlTree *, const char *, int, int);
 
726
int HtmlNameToType(void *, char *);
 
727
Html_u8 HtmlMarkupFlags(int);
 
728
 
 
729
 
 
730
#define HTML_WALK_ABANDON            4
 
731
#define HTML_WALK_DESCEND            5
 
732
#define HTML_WALK_DO_NOT_DESCEND     6
 
733
typedef int (*html_walk_tree_cb)(HtmlTree*,HtmlNode*,ClientData);
 
734
int HtmlWalkTree(HtmlTree*, HtmlNode *, html_walk_tree_cb, ClientData);
 
735
 
 
736
int HtmlTreeClear(HtmlTree *);
 
737
int         HtmlNodeNumChildren(HtmlNode *);
 
738
HtmlNode *  HtmlNodeBefore(HtmlNode *);
 
739
HtmlNode *  HtmlNodeAfter(HtmlNode *);
 
740
HtmlNode *  HtmlNodeRightSibling(HtmlNode *);
 
741
HtmlNode *  HtmlNodeLeftSibling(HtmlNode *);
 
742
char CONST *HtmlNodeTagName(HtmlNode *);
 
743
char CONST *HtmlNodeAttr(HtmlNode *, char CONST *);
 
744
char *      HtmlNodeToString(HtmlNode *);
 
745
HtmlNode *  HtmlNodeGetPointer(HtmlTree *, char CONST *);
 
746
int         HtmlNodeIsOrphan(HtmlNode *);
 
747
 
 
748
int HtmlNodeAddChild(HtmlElementNode *, int, const char *, HtmlAttributes *);
 
749
int HtmlNodeAddTextChild(HtmlNode *, HtmlTextNode *);
 
750
 
 
751
Html_u8     HtmlNodeTagType(HtmlNode *);
 
752
 
 
753
Tcl_Obj *HtmlNodeCommand(HtmlTree *, HtmlNode *pNode);
 
754
int HtmlNodeDeleteCommand(HtmlTree *, HtmlNode *pNode);
 
755
 
 
756
void HtmlDrawCleanup(HtmlTree *, HtmlCanvas *);
 
757
void HtmlDrawDeleteControls(HtmlTree *, HtmlCanvas *);
 
758
 
 
759
void HtmlDrawCanvas(HtmlCanvas*,HtmlCanvas*,int,int,HtmlNode*);
 
760
void HtmlDrawText(HtmlCanvas*,const char*,int,int,int,int,int,HtmlNode*,int);
 
761
void HtmlDrawTextExtend(HtmlCanvas*, int, int);
 
762
int HtmlDrawTextLength(HtmlCanvas*);
 
763
 
 
764
#define CANVAS_BOX_OPEN_LEFT    0x01      /* Open left-border */
 
765
#define CANVAS_BOX_OPEN_RIGHT   0x02      /* Open right-border */
 
766
HtmlCanvasItem *HtmlDrawBox(
 
767
HtmlCanvas *, int, int, int, int, HtmlNode *, int, int, HtmlCanvasItem *);
 
768
void HtmlDrawLine(HtmlCanvas *, int, int, int, int, int, HtmlNode *, int);
 
769
 
 
770
void HtmlDrawWindow(HtmlCanvas *, HtmlNode *, int, int, int, int, int);
 
771
void HtmlDrawBackground(HtmlCanvas *, XColor *, int);
 
772
void HtmlDrawQuad(HtmlCanvas*,int,int,int,int,int,int,int,int,XColor*,int);
 
773
int  HtmlDrawIsEmpty(HtmlCanvas *);
 
774
 
 
775
void HtmlDrawImage(HtmlCanvas*, HtmlImage2*, int, int, int, int, HtmlNode*, int);
 
776
void HtmlDrawOrigin(HtmlCanvas*);
 
777
void HtmlDrawCopyCanvas(HtmlCanvas*, HtmlCanvas*);
 
778
 
 
779
void HtmlDrawOverflow(HtmlCanvas*, HtmlNode*, int, int);
 
780
 
 
781
HtmlCanvasItem *HtmlDrawAddMarker(HtmlCanvas*, int, int, int);
 
782
int HtmlDrawGetMarker(HtmlCanvas*, HtmlCanvasItem *, int*, int*);
 
783
 
 
784
void HtmlDrawAddLinebox(HtmlCanvas*, int, int);
 
785
int HtmlDrawFindLinebox(HtmlCanvas*, int*, int*);
 
786
 
 
787
HtmlCanvasSnapshot *HtmlDrawSnapshotZero(HtmlTree *);
 
788
HtmlCanvasSnapshot *HtmlDrawSnapshot(HtmlTree *, int);
 
789
void HtmlDrawSnapshotDamage(HtmlTree*,HtmlCanvasSnapshot*,HtmlCanvasSnapshot**);
 
790
void HtmlDrawSnapshotFree(HtmlTree *, HtmlCanvasSnapshot *);
 
791
 
 
792
void HtmlDrawCanvasItemRelease(HtmlTree *, HtmlCanvasItem *);
 
793
void HtmlDrawCanvasItemReference(HtmlCanvasItem *);
 
794
 
 
795
void HtmlWidgetDamageText(HtmlTree *, HtmlNode *, int, HtmlNode *, int);
 
796
int HtmlWidgetNodeTop(HtmlTree *, HtmlNode *);
 
797
void HtmlWidgetOverflowBox(HtmlTree *, HtmlNode *, int *, int *, int *, int *);
 
798
 
 
799
HtmlTokenMap *HtmlMarkup(int);
 
800
CONST char * HtmlMarkupName(int);
 
801
char * HtmlMarkupArg(HtmlAttributes *, CONST char *, char *);
 
802
 
 
803
void HtmlFloatListAdd(HtmlFloatList*, int, int, int, int);
 
804
HtmlFloatList *HtmlFloatListNew();
 
805
void HtmlFloatListDelete();
 
806
int HtmlFloatListPlace(HtmlFloatList*, int, int, int, int);
 
807
int HtmlFloatListClear(HtmlFloatList*, int, int);
 
808
int HtmlFloatListClearTop(HtmlFloatList*, int);
 
809
void HtmlFloatListNormalize(HtmlFloatList*, int, int);
 
810
void HtmlFloatListMargins(HtmlFloatList*, int, int, int *, int *);
 
811
void HtmlFloatListLog(HtmlTree *, CONST char *, CONST char *, HtmlFloatList *);
 
812
int HtmlFloatListIsConstant(HtmlFloatList*, int, int);
 
813
 
 
814
HtmlPropertyCache * HtmlNewPropertyCache();
 
815
void HtmlSetPropertyCache(HtmlPropertyCache *, int, CssProperty *);
 
816
void HtmlAttributesToPropertyCache(HtmlNode *pNode);
 
817
 
 
818
Tcl_HashKeyType * HtmlCaseInsenstiveHashType();
 
819
Tcl_HashKeyType * HtmlFontKeyHashType();
 
820
Tcl_HashKeyType * HtmlComputedValuesHashType();
 
821
 
 
822
CONST char *HtmlDefaultTcl();
 
823
CONST char *HtmlDefaultCss();
 
824
 
 
825
/* Functions from htmlimage.c */
 
826
void HtmlImageServerInit(HtmlTree *);
 
827
void HtmlImageServerShutdown(HtmlTree *);
 
828
HtmlImage2 *HtmlImageServerGet(HtmlImageServer *, const char *);
 
829
HtmlImage2 *HtmlImageScale(HtmlImage2 *, int *, int *, int);
 
830
void HtmlImageSize(HtmlImage2 *, int *, int *);
 
831
Tcl_Obj *HtmlImageUnscaledName(HtmlImage2 *);
 
832
Tk_Image HtmlImageImage(HtmlImage2 *);
 
833
Tk_Image HtmlImageTile(HtmlImage2 *, int*, int *);
 
834
Pixmap HtmlImageTilePixmap(HtmlImage2 *, int*, int *);
 
835
Pixmap HtmlImagePixmap(HtmlImage2 *);
 
836
void HtmlImageFree(HtmlImage2 *);
 
837
void HtmlImageRef(HtmlImage2 *);
 
838
const char *HtmlImageUrl(HtmlImage2 *);
 
839
void HtmlImageCheck(HtmlImage2 *);
 
840
Tcl_Obj *HtmlXImageToImage(HtmlTree *, XImage *, int, int);
 
841
int HtmlImageAlphaChannel(HtmlImage2 *);
 
842
 
 
843
void HtmlImageServerSuspendGC(HtmlTree *);
 
844
void HtmlImageServerDoGC(HtmlTree *);
 
845
int HtmlImageServerCount(HtmlTree *);
 
846
 
 
847
void HtmlLayoutPaintNode(HtmlTree *, HtmlNode *);
 
848
void HtmlLayoutInvalidateCache(HtmlTree *, HtmlNode *);
 
849
void HtmlWidgetNodeBox(HtmlTree *, HtmlNode *, int *, int *, int *, int *);
 
850
 
 
851
void HtmlWidgetSetViewport(HtmlTree *, int, int, int);
 
852
void HtmlWidgetRepair(HtmlTree *, int, int, int, int, int);
 
853
 
 
854
int HtmlNodeClearStyle(HtmlTree *, HtmlElementNode *);
 
855
int HtmlNodeClearGenerated(HtmlTree *, HtmlElementNode *);
 
856
void HtmlNodeClearRecursive(HtmlTree *, HtmlNode *);
 
857
 
 
858
void HtmlTranslateEscapes(char *);
 
859
void HtmlRestackNodes(HtmlTree *pTree);
 
860
void HtmlDelStackingInfo(HtmlTree *, HtmlElementNode *);
 
861
 
 
862
#define HTML_TAG_ADD 10
 
863
#define HTML_TAG_REMOVE 11
 
864
#define HTML_TAG_SET 12
 
865
int HtmlTagAddRemoveCmd(ClientData, Tcl_Interp *, int, Tcl_Obj *CONST[], int);
 
866
Tcl_ObjCmdProc HtmlTagDeleteCmd;
 
867
Tcl_ObjCmdProc HtmlTagConfigureCmd;
 
868
void HtmlTagCleanupNode(HtmlTextNode *);
 
869
void HtmlTagCleanupTree(HtmlTree *);
 
870
 
 
871
Tcl_ObjCmdProc HtmlTextTextCmd;
 
872
Tcl_ObjCmdProc HtmlTextIndexCmd;
 
873
Tcl_ObjCmdProc HtmlTextBboxCmd;
 
874
Tcl_ObjCmdProc HtmlTextOffsetCmd;
 
875
void HtmlTextInvalidate(HtmlTree *);
 
876
 
 
877
void HtmlWidgetBboxText(
 
878
HtmlTree *, HtmlNode *, int, HtmlNode *, int, int *, int *, int *, int*);
 
879
int HtmlNodeScrollbarDoCallback(HtmlTree *, HtmlNode *);
 
880
 
 
881
void HtmlDelScrollbars(HtmlTree *, HtmlNode *);
 
882
 
 
883
HtmlAttributes * HtmlAttributesNew(int, char const **, int *, int);
 
884
 
 
885
void HtmlParseFragment(HtmlTree *, const char *);
 
886
void HtmlSequenceNodes(HtmlTree *);
 
887
 
 
888
void HtmlFontReference(HtmlFont *);
 
889
void HtmlFontRelease(HtmlTree *, HtmlFont *);
 
890
 
 
891
/* HTML Tokenizer function. */
 
892
int HtmlTokenize(HtmlTree *, char const *, int,
 
893
    void (*)(HtmlTree *, HtmlTextNode *, int),
 
894
    void (*)(HtmlTree *, int, const char *, HtmlAttributes *, int),
 
895
    void (*)(HtmlTree *, int, const char *, int)
 
896
);
 
897
 
 
898
/* The following three HtmlTreeAddXXX() functions - defined in htmltree.c - 
 
899
 * are invoked by the tokenizer (function HtmlTokenize()) when it is invoked 
 
900
 * to parse the main document (not a fragment).
 
901
 *
 
902
 * The functions invoked by the tokenizer when it is parsing a document
 
903
 * fragment are:
 
904
 *
 
905
 *     fragmentAddElement()
 
906
 *     fragmentAddText()
 
907
 *     fragmentAddClosingTag()
 
908
 *
 
909
 * These are also in htmltree.c but are not defined with external linkage.
 
910
 */
 
911
void HtmlTreeAddElement(HtmlTree *, int, const char *, HtmlAttributes *, int);
 
912
void HtmlTreeAddText(HtmlTree *, HtmlTextNode *, int);
 
913
void HtmlTreeAddClosingTag(HtmlTree *, int, const char *, int);
 
914
 
 
915
void HtmlInitTree(HtmlTree *);
 
916
 
 
917
void HtmlHashInit(void *, int);
 
918
HtmlTokenMap * HtmlHashLookup(void *, const char *zType);
 
919
 
 
920
/*******************************************************************
 
921
 * Interface to code in htmltext.c
 
922
 *******************************************************************/
 
923
 
 
924
/*
 
925
 * Creation, modification and deletion of HtmlTextNode objects.
 
926
 */
 
927
HtmlTextNode * HtmlTextNew(int, const char *, int, int);
 
928
void           HtmlTextSet(HtmlTextNode *, int, const char *, int, int);
 
929
void           HtmlTextFree(HtmlTextNode *);
 
930
 
 
931
/* The details of this structure should be considered private to
 
932
 * htmltext.c. They are here because other code needs to know the
 
933
 * size of the structure so that it may be allocated on the stack.
 
934
 */
 
935
struct HtmlTextIter {
 
936
    HtmlTextNode *pTextNode;
 
937
    int iText;
 
938
    int iToken;
 
939
};
 
940
 
 
941
/*
 
942
 * Functions for iterating through the tokens of a text node. Used as 
 
943
 * follows:
 
944
 *
 
945
 * HtmlTextNode *pText = ...
 
946
 * HtmlTextIter iter;
 
947
 *
 
948
 * for (
 
949
 *     HtmlTextIterFirst(&iter);
 
950
 *     HtmlTextIterIsValid(&iter);
 
951
 *     HtmlTextIterNext(&iter)
 
952
 * ) {
 
953
 *    ...
 
954
 * } 
 
955
 */
 
956
void HtmlTextIterFirst(HtmlTextNode *, HtmlTextIter *);
 
957
void HtmlTextIterNext(HtmlTextIter *);
 
958
int HtmlTextIterIsValid(HtmlTextIter *);
 
959
int HtmlTextIterIsLast(HtmlTextIter *);
 
960
 
 
961
/*
 
962
 * Query functions to discover the token type, length and data.
 
963
 *
 
964
 * If the token type is HTML_TEXT_TOKEN_TEXT, then the length 
 
965
 * is the number of bytes of text. The text is returned as the data.
 
966
 *
 
967
 * If the token type is SPACE or NEWLINE, then it is an error to
 
968
 * call HtmlTextTokenData(). TokenLength() returns the number of
 
969
 * consecutive space or newline characters that occured in the
 
970
 * document.
 
971
 *
 
972
 * If the token type is HARDNEWLINE, this must have come from CSS
 
973
 * generated content like this: "\A". In this case a newline will
 
974
 * be rendered no matter the value of the 'white-space' property 
 
975
 * and so on.
 
976
 */
 
977
int         HtmlTextIterType(HtmlTextIter *);
 
978
int         HtmlTextIterLength(HtmlTextIter *);
 
979
const char *HtmlTextIterData(HtmlTextIter *);
 
980
 
 
981
#ifdef NDEBUG
 
982
  #define HtmlCheckRestylePoint(x)
 
983
#else
 
984
  void HtmlCheckRestylePoint(HtmlTree *pTree);
 
985
#endif
 
986
 
 
987
/* Values returned by HtmlTextTokenType */
 
988
#define HTML_TEXT_TOKEN_TEXT          1
 
989
#define HTML_TEXT_TOKEN_SPACE         2
 
990
#define HTML_TEXT_TOKEN_NEWLINE       3
 
991
#define HTML_TEXT_TOKEN_HARDNEWLINE   4
 
992
 
 
993
/* These values are used internally by the htmltext.c module. They
 
994
 * should never be returned by HtmlTextTokenType(). But define them
 
995
 * here to make it easier to keep them distinct from the other
 
996
 * HTML_TEXT_* values defined above.
 
997
 */
 
998
#define HTML_TEXT_TOKEN_END       0
 
999
#define HTML_TEXT_TOKEN_LONGTEXT  5
 
1000
 
 
1001
/*
 
1002
 * The following symbols are used for the built-in instrumentation 
 
1003
 * function. (profile data).
 
1004
 */
 
1005
#define HTML_INSTRUMENT_SCRIPT_CALLBACK      0
 
1006
#define HTML_INSTRUMENT_CALLBACK             1
 
1007
#define HTML_INSTRUMENT_DYNAMIC_STYLE_ENGINE 2
 
1008
#define HTML_INSTRUMENT_STYLE_ENGINE         3
 
1009
#define HTML_INSTRUMENT_LAYOUT_ENGINE        4
 
1010
#define HTML_INSTRUMENT_ALLOCATE_FONT        5
 
1011
 
 
1012
#define HTML_INSTRUMENT_NUM_SYMS             6
 
1013
void HtmlInstrumentInit(Tcl_Interp *);
 
1014
void HtmlInstrumentCall(ClientData, int, void(*)(ClientData), ClientData);
 
1015
void *HtmlInstrumentCall2(ClientData, int, void*(*)(ClientData), ClientData);
 
1016
 
 
1017
/* htmltagdb.c */
 
1018
const char *HtmlTypeToName(void *, int);
 
1019
 
 
1020
#endif
 
1021