summaryrefslogtreecommitdiffstats
path: root/tkhtml1/src/htmlsizer.h
blob: c14bcf3dcec88f79d33fa412152f3b07a082d909 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
/* This file was automatically generated.  Do not edit! */
typedef struct HtmlWidget HtmlWidget;
typedef union HtmlElement HtmlElement;
int HtmlControlSize(HtmlWidget *htmlPtr,HtmlElement *pElem);
int HtmlGetImageAlignment(HtmlElement *p);
#define Html_Space   2
#define Html_Text    1
Tk_Font HtmlGetFont(HtmlWidget *htmlPtr,int iFont);
void HtmlSizer(HtmlWidget *htmlPtr);
char *HtmlTokenName(HtmlElement *p);
#define HtmlTrace_Style        0x00002000
extern int HtmlTraceMask;
#define DEBUG 1
#if defined(DEBUG)
extern int HtmlDepth;
# define TRACE_INDENT  printf("%*s",HtmlDepth-3,"")
#endif
#if !(defined(DEBUG))
# define TRACE_INDENT
#endif
#if defined(DEBUG)
# define TRACE(Flag, Args) \
    if( (Flag)&HtmlTraceMask ){ \
       TRACE_INDENT; printf Args; fflush(stdout); \
    }
#endif
#if !(defined(DEBUG))
# define TRACE(Flag, Args)
#endif
#define Html_VAR             147
#define Html_U               143
#define Html_TT              141
#define Html_TITLE           137
#define Html_EndTEXTAREA     134
#define Html_TEXTAREA        133
#define Html_SUP             127
#define Html_SUB             125
#define Html_STRONG          122
#define Html_SMALL           118
#define Html_SAMP            113
#define Html_STYLE           124
#define Html_STRIKE          120
#define Html_EndSELECT       117
#define Html_SELECT          116
#define Html_SCRIPT          115
#define STY_StrikeThru      0x002
#define Html_S               111
#define Html_EndXMP          151
#define Html_EndLISTING      85
#define Html_EndPRE          110
#define STY_Preformatted    0x001
#define Html_PLAINTEXT       108
#define Html_XMP             150
#define Html_LISTING         84
#define Html_PRE             109
#define Html_EndP            105
#define Html_P               104
#define Html_NOSCRIPT        98
#define Html_NOFRAME         96
#define STY_NoBreak         0x008
#define Html_NOBR            94
#define Html_MARQUEE         88
#define HTML_Visible   0x01     /* This element produces "ink" */
#define Html_OL              100
#define Html_LI              81
#define Html_KBD             79
#define Html_INPUT           77
typedef struct HtmlImage HtmlImage;
HtmlImage *HtmlGetImage(HtmlWidget *htmlPtr,HtmlElement *p);
#define Html_IMG             76
#define Html_I               73
#define Html_HR              70
#define Html_EndH6           69
#define Html_EndH5           67
#define Html_EndH4           65
#define Html_EndH3           63
#define Html_EndH2           61
#define Html_EndH1           59
#define Html_H6              68
#define Html_H5              66
#define Html_H4              64
#define Html_H3              62
#define Html_H2              60
#define Html_H1              58
#define Html_EndFORM         53
void HtmlAppendArglist(Tcl_DString *str,HtmlElement *pElem);
#define Html_FORM            52
int HtmlGetColorByName(HtmlWidget *htmlPtr,char *zColor);
#define N_FONT_SIZE       7
#define Html_FONT            50
#define Html_BASEFONT        15
#define Html_EMBED           49
#define ItalicFont(X)     ((X)+2*N_FONT_SIZE)
#define Html_EM              47
#define Html_EndDT           46
#define Html_EndDD           36
#define STY_DT              0x020
#define Html_DT              45
#define Html_DIV             41
#define Html_EndUL           146
#define Html_EndOL           101
#define Html_EndMENU         91
#define Html_EndDIR          40
#define Html_EndDL           44
#define Html_UL              145
#define Html_MENU            90
#define Html_DIR             39
#define Html_DL              43
#define Html_DD              35
#define Html_COMMENT         33
#define CWFont(X)         ((X)+4*N_FONT_SIZE)
#define Html_CODE            31
#define Html_CITE            29
#define Html_CENTER          27
#define Html_EndCAPTION      26
#define Html_CAPTION         25
#define Html_BIG             18
#define FontFamily(X)     (((X)/N_FONT_SIZE)*N_FONT_SIZE)
#define Html_EndBASEFONT     16
#define Html_EndDIV          42
char *HtmlResolveUri(HtmlWidget *htmlPtr,char *zUri);
#define Html_BASE            14
#define Html_EndVAR          148
#define Html_EndU            144
#define Html_EndTT           142
#define Html_EndTITLE        138
#define Html_EndSUP          128
#define Html_EndSUB          126
#define Html_EndSTRONG       123
#define Html_EndSTRIKE       121
#define Html_EndSMALL        119
#define Html_EndSAMP         114
#define Html_EndS            112
#define Html_EndNOSCRIPT     99
#define Html_EndNOFRAME      97
#define Html_EndNOBR         95
#define Html_EndMARQUEE      89
#define Html_EndKBD          80
#define Html_EndI            74
#define Html_EndFONT         51
#define Html_EndEM           48
#define Html_EndCOMMENT      34
#define Html_EndCODE         32
#define Html_EndCITE         30
#define Html_EndCENTER       28
#define Html_EndBIG          19
#define Html_EndB            13
#define BoldFont(X)       ((X)+N_FONT_SIZE)
#define Html_B               12
#define Html_EndAPPLET       10
#define Html_APPLET          9
#define ALIGN_None   0
#define Html_EndBLOCKQUOTE   21
#define Html_BLOCKQUOTE      20
#define Html_EndADDRESS      8
#define Html_ADDRESS         7
#define STY_Anchor          0x010
#define STY_Underline       0x004
#define Html_EndA            6
#define Html_A               5
#define STYLER_RUNNING       0x000800
void HtmlAddStyle(HtmlWidget *htmlPtr,HtmlElement *p);
#define COLOR_Visited        2      /* Color for visited hyperlinks */
int HtmlUnlock(HtmlWidget *htmlPtr);
void HtmlLock(HtmlWidget *htmlPtr);
#define COLOR_Unvisited      1      /* Index for unvisited hyperlinks */
#define STY_Invisible       0x040
#define LI_TYPE_Bullet3   3     /* A hollow square */
#define LI_TYPE_Bullet2   2     /* A hollow circle */
#define LI_TYPE_Bullet1   1     /* A solid circle */
#define LI_TYPE_Enum_i    8     /* Lower-case roman numerals */
#define LI_TYPE_Enum_I    7     /* Capitalized roman numerals */
#define LI_TYPE_Enum_1    4     /* Arabic numbers */
#define LI_TYPE_Enum_a    6     /* a, b, c, ... */
#define LI_TYPE_Enum_A    5     /* A, B, C, ... */
#define ALIGN_Center 3
#define ALIGN_Right  2
#if !defined(HAVE_STRICMP)
# define stricmp strcasecmp
#endif
#if defined(COVERAGE_TEST)
extern int HtmlTPArray[2000];
# define TestPoint(X)      {extern int HtmlTPArray[]; HtmlTPArray[X]++;}
#endif
#if !(defined(COVERAGE_TEST))
# define TestPoint(X)
#endif
#define Html_Block   4
#define HtmlIsMarkup(X) ((X)->base.type>Html_Block)
typedef struct HtmlBaseElement HtmlBaseElement;
typedef struct HtmlStyle HtmlStyle;
struct HtmlStyle {
  unsigned int font    : 6;      /* Font to use for display */
  unsigned int color   : 4;      /* Foreground color */
  signed int subscript : 4;      /* Positive for <sup>, negative for <sub> */
  unsigned int align   : 2;      /* Horizontal alignment */
  unsigned int bgcolor : 4;      /* Background color */
  unsigned int flags   : 12;     /* the STY_ flags below */
};
typedef unsigned char Html_u8;
typedef short Html_16;
struct HtmlBaseElement {
  HtmlElement *pNext;         /* Next input token in a list of them all */
  HtmlElement *pPrev;         /* Previous token in a list of them all */
  HtmlStyle style;            /* The rendering style for this token */
  Html_u8 type;               /* The token type. */
  Html_u8 flags;              /* The HTML_ flags below */
  Html_16 count;              /* Various uses, depending on "type" */
};
typedef struct HtmlTextElement HtmlTextElement;
typedef int Html_32;
struct HtmlTextElement {
  HtmlBaseElement base;       /* All the base information */
  Html_32 y;                  /* y coordinate where text should be rendered */
  Html_16 x;                  /* x coordinate where text should be rendered */
  Html_16 w;                  /* width of this token in pixels */
  Html_u8 ascent;             /* height above the baseline */
  Html_u8 descent;            /* depth below the baseline */
  Html_u8 spaceWidth;         /* Width of one space in the current font */
  char zText[1];              /* Text for this element.  Null terminated */
};
typedef struct HtmlSpaceElement HtmlSpaceElement;
struct HtmlSpaceElement {
  HtmlBaseElement base;       /* All the base information */
  Html_16 w;                  /* Width of a single space in current font */
  Html_u8 ascent;             /* height above the baseline */
  Html_u8 descent;            /* depth below the baseline */
};
typedef struct HtmlMarkupElement HtmlMarkupElement;
struct HtmlMarkupElement {
  HtmlBaseElement base;
  char **argv;
};
typedef struct HtmlCell HtmlCell;
struct HtmlCell {
  HtmlMarkupElement markup;
  Html_16 rowspan;          /* Number of rows spanned by this cell */
  Html_16 colspan;          /* Number of columns spanned by this cell */
  Html_16 x;                /* X coordinate of left edge of border */
  Html_16 w;                /* Width of the border */
  Html_32 y;                /* Y coordinate of top of border indentation */
  Html_32 h;                /* Height of the border */
  HtmlElement *pTable;      /* Pointer back to the <table> */
  HtmlElement *pEnd;        /* Element that ends this cell */
};
typedef struct HtmlTable HtmlTable;
typedef unsigned short Html_u16;
#define HTML_MAX_COLUMNS 40
struct HtmlTable {
  HtmlMarkupElement markup;
  Html_u8 borderWidth;           /* Width of the border */
  Html_u8 nCol;                  /* Number of columns */
  Html_u16 nRow;                 /* Number of rows */
  Html_32 y;                     /* top edge of table border */
  Html_32 h;                     /* height of the table border */
  Html_16 x;                     /* left edge of table border */
  Html_16 w;                     /* width of the table border */
  int minW[HTML_MAX_COLUMNS+1];  /* minimum width of each column */
  int maxW[HTML_MAX_COLUMNS+1];  /* maximum width of each column */
};
typedef struct HtmlRef HtmlRef;
struct HtmlRef {
  HtmlMarkupElement markup;
  HtmlElement *pOther;         /* Pointer to some other Html element */
};
typedef struct HtmlLi HtmlLi;
struct HtmlLi {
  HtmlMarkupElement markup;
  Html_u8 type;     /* What type of list is this? */
  Html_u8 ascent;   /* height above the baseline */
  Html_u8 descent;  /* depth below the baseline */
  Html_16 cnt;      /* Value for this element (if inside <OL>) */
  Html_16 x;        /* X coordinate of the bullet */
  Html_32 y;        /* Y coordinate of the bullet */
};
typedef struct HtmlListStart HtmlListStart;
struct HtmlListStart {
  HtmlMarkupElement markup;
  Html_u8 type;            /* One of the LI_TYPE_ defines above */
  Html_u8 compact;         /* True if the COMPACT flag is present */
  Html_u16 cnt;            /* Next value for <OL> */
  Html_u16 width;          /* How much space to allow for indentation */
  HtmlElement *pPrev;      /* Next higher level list, or NULL */
};
typedef struct HtmlImageMarkup HtmlImageMarkup;
struct HtmlImageMarkup {
  HtmlMarkupElement markup;
  Html_u8 align;          /* Alignment.  See IMAGE_ALIGN_ defines below */
  Html_u8 textAscent;     /* Ascent of text font in force at the <IMG> */
  Html_u8 textDescent;    /* Descent of text font in force at the <IMG> */
  Html_u8 redrawNeeded;   /* Need to redraw this image because the image
                          ** content changed. */
  Html_16 h;              /* Actual height of the image */
  Html_16 w;              /* Actual width of the image */
  Html_16 ascent;         /* How far image extends above "y" */
  Html_16 descent;        /* How far image extends below "y" */
  Html_16 x;              /* X coordinate of left edge of the image */
  Html_32 y;              /* Y coordinate of image baseline */
  char *zAlt;             /* Alternative text */
  HtmlImage *pImage;      /* Corresponding HtmlImage structure */
  HtmlElement *pNext;     /* Next markup using the same HtmlImage structure */
};
typedef struct HtmlInput HtmlInput;
struct HtmlInput {
  HtmlMarkupElement markup;
  HtmlElement *pForm;      /* The <FORM> to which this belongs */
  HtmlElement *pNext;      /* Next element in a list of all input elements */
  Tk_Window tkwin;         /* The window that implements this control */
  HtmlWidget *htmlPtr;     /* The whole widget.  Needed by geometry callbacks */
  HtmlElement *pEnd;       /* End tag for <TEXTAREA>, etc. */
  Html_32  y;              /* Baseline for this input element */
  Html_u16 x;              /* Left edge */
  Html_u16 w, h;           /* Width and height of this control */
  Html_u8 padLeft;         /* Extra padding on left side of the control */
  Html_u8 align;           /* One of the IMAGE_ALIGN_xxx  types */
  Html_u8 textAscent;      /* Ascent for the current font */
  Html_u8 textDescent;     /* descent for the current font */
  Html_u8 type;            /* What type of input is this? */
  Html_u8 sized;           /* True if this input has been sized already */
  Html_u16 cnt;            /* Used to derive widget name. 0 if no widget */
};
typedef struct HtmlForm HtmlForm;
struct HtmlForm {
  HtmlMarkupElement markup;
  Html_u16 id;             /* Unique number assigned to this form */
};
typedef struct HtmlHr HtmlHr;
struct HtmlHr {
  HtmlMarkupElement markup;
  Html_32  y;              /* Baseline for this input element */
  Html_u16 x;              /* Left edge */
  Html_u16 w, h;           /* Width and height of this control */
  Html_u8 is3D;            /* Is it drawn 3D? */
};
typedef struct HtmlAnchor HtmlAnchor;
struct HtmlAnchor {
  HtmlMarkupElement markup;
  Html_32  y;              /* Top edge for this element */
};
typedef struct HtmlScript HtmlScript;
struct HtmlScript {
  HtmlMarkupElement markup;
  char *zScript;           /* Complete text of this script */
  int nScript;             /* Number of characters of text */
};
typedef struct HtmlBlock HtmlBlock;
struct HtmlBlock {
  HtmlBaseElement base;      /* Superclass.  Must be first */
  char *z;                   /* Space to hold text when n>0 */
  int top, bottom;           /* Extremes of y coordinates */
  Html_u16 left, right;      /* Left and right boundry of this object */
  Html_u16 n;                /* Number of characters in z[] */
  HtmlBlock *pPrev, *pNext;  /* Linked list of all Blocks */
};
union HtmlElement {
  HtmlElement *pNext;
  HtmlBaseElement base;
  HtmlTextElement text;
  HtmlSpaceElement space;
  HtmlMarkupElement markup;
  HtmlCell cell;
  HtmlTable table;
  HtmlRef ref;
  HtmlLi li;
  HtmlListStart list;
  HtmlImageMarkup image;
  HtmlInput input;
  HtmlForm form;
  HtmlHr hr;
  HtmlAnchor anchor;
  HtmlScript script;
  HtmlBlock block;
};
char *HtmlMarkupArg(HtmlElement *p,const char *tag,char *zDefault);
#define FontSize(X)       ((X)%N_FONT_SIZE)
#define HtmlFree(A)       Tcl_Free((char*)(A))
void HtmlTPCantHappen(const char *zFile,int line);
#if defined(COVERAGE_TEST)
# define CANT_HAPPEN       HtmlTPCantHappen(__FILE__,__LINE__)
#endif
#if !(defined(COVERAGE_TEST))
# define CANT_HAPPEN
#endif
#define Html_EndTABLE        130
#define Html_EndTR           140
#define Html_TR              139
#define Html_EndTH           136
#define Html_TH              135
#define Html_EndTD           132
#define Html_TD              131
#define Html_TABLE           129
#define Html_TypeCount       151
HtmlStyle HtmlPopStyleStack(HtmlWidget *htmlPtr,int tag);
#define HtmlAlloc(A)      ((void*)Tcl_Alloc(A))
typedef struct HtmlStyleStack HtmlStyleStack;
struct HtmlStyleStack {
  HtmlStyleStack *pNext;   /* Next style on the stack */
  int type;                /* A markup that ends this style. Ex: Html_EndEM */
  HtmlStyle style;         /* The currently active style. */
};
#define ALIGN_Left   1
#define COLOR_Background     4      /* Default background color */
#define COLOR_Normal         0      /* Index for normal color (black) */
#define NormalFont(X)     (X)
typedef struct HtmlIndex HtmlIndex;
struct HtmlIndex {
  HtmlElement *p;      /* The token containing the character */
  int i;               /* Index of the character */
};
typedef struct HtmlLayoutContext HtmlLayoutContext;
typedef struct HtmlMargin HtmlMargin;
struct HtmlLayoutContext {
  HtmlWidget *htmlPtr;          /* The html widget undergoing layout */
  HtmlElement *pStart;          /* Start of elements to layout */
  HtmlElement *pEnd;            /* Stop when reaching this element */
  int headRoom;                 /* Extra space wanted above this line */
  int top;                      /* Absolute top of drawing area */
  int bottom;                   /* Bottom of previous line */
  int left, right;              /* Left and right extremes of drawing area */
  int pageWidth;                /* Width of the layout field, including
                                ** the margins */
  int maxX, maxY;               /* Maximum X and Y values of paint */
  HtmlMargin *leftMargin;       /* Stack of left margins */
  HtmlMargin *rightMargin;      /* Stack of right margins */
};
#define N_FONT_FAMILY     8
#define N_FONT            (N_FONT_FAMILY*N_FONT_SIZE)
#define N_COLOR             16      /* Total number of colors */
typedef struct GcCache GcCache;
struct GcCache {
  GC gc;                /* The graphics context */
  Html_u8 font;         /* Font used for this context */
  Html_u8 color;        /* Color used for this context */
  Html_u8 index;        /* Index used for LRU replacement */
};
#define N_CACHE_GC 16
struct HtmlWidget {
  Tk_Window tkwin;              /* The main window for this widget */
  Tk_Window clipwin;            /* The clipping window in which all text is
                                ** rendered. */
  char *zClipwin;               /* Name of the clipping window. */
  Display *display;             /* The X11 Server that contains tkwin */
  Tcl_Interp *interp;           /* The interpreter in which the widget lives */
  char *zCmdName;               /* Name of the command */
  HtmlElement *pFirst;          /* First HTML token on a list of them all */
  HtmlElement *pLast;           /* Last HTML token on the list */
  int nToken;                   /* Number of HTML tokens on the list.
                                 * Html_Block tokens don't count. */
  HtmlElement *lastSized;       /* Last HTML element that has been sized */
  HtmlElement *nextPlaced;      /* Next HTML element that needs to be 
                                 * positioned on canvas. */
  HtmlBlock *firstBlock;        /* List of all HtmlBlock tokens */
  HtmlBlock *lastBlock;         /* Last HtmlBlock in the list */
  HtmlElement *firstInput;      /* First <INPUT> element */
  HtmlElement *lastInput;       /* Last <INPUT> element */
  int nInput;                   /* The number of <INPUT> elements */
  int nForm;                    /* The number of <FORM> elements */
  int varId;                    /* Used to construct a unique name for a
                                ** global array used by <INPUT> elements */

  /*
   * Information about the selected region of text
   */
  HtmlIndex selBegin;           /* Start of the selection */
  HtmlIndex selEnd;             /* End of the selection */
  HtmlBlock *pSelStartBlock;    /* Block in which selection starts */
  Html_16 selStartIndex;        /* Index in pSelStartBlock of first selected
                                 * character */
  Html_16 selEndIndex;          /* Index of last selecte char in pSelEndBlock */
  HtmlBlock *pSelEndBlock;      /* Block in which selection ends */

  /*
   * Information about the insertion cursor 
   */
  int insOnTime;                /* How long the cursor states one (millisec) */
  int insOffTime;               /* How long it is off (milliseconds) */
  int insStatus;                /* Is it visible? */
  Tcl_TimerToken insTimer;      /* Timer used to flash the insertion cursor */
  HtmlIndex ins;                /* The insertion cursor position */
  HtmlBlock *pInsBlock;         /* The HtmlBlock containing the cursor */
  int insIndex;                 /* Index in pInsBlock of the cursor */

  /*
   * The following fields hold state information used by
   * the tokenizer.
   */
  char *zText;                  /* Complete text of the unparsed HTML */
  int nText;                    /* Number of characters in zText */
  int nAlloc;                   /* Space allocated for zText */
  int nComplete;                /* How much of zText has actually been
                                 * converted into tokens */
  int iCol;                     /* The column in which zText[nComplete]
                                 * occurs.  Used to resolve tabs in input */
  int iPlaintext;               /* If not zero, this is the token type that
                                 * caused us to go into plaintext mode.  One
                                 * of Html_PLAINTEXT, Html_LISTING or
                                 * Html_XMP */
  HtmlScript *pScript;            /* <SCRIPT> currently being parsed */
  char *zHandler[Html_TypeCount]; /* If not NULL, this is a TCL routine that
                                 * is used to process tokens of the given 
                                 * type */
  /*
   * These fields hold state information used by the HtmlAddStyle routine.
   * We have to store this state information here since HtmlAddStyle
   * operates incrementally.  This information must be carried from
   * one incremental execution to the next.
   */
  HtmlStyleStack *styleStack;   /* The style stack */
  int paraAlignment;            /* Justification associated with <p> */
  int rowAlignment;             /* Justification associated with <tr> */
  int anchorFlags;              /* Style flags associated with <A>...</A> */
  int inDt;                     /* Style flags associated with <DT>...</DT> */
  int inTr;                     /* True if within <tr>..</tr> */
  int inTd;                     /* True if within <td>..</td> or <th>..</th> */
  HtmlElement *anchorStart;     /* Most recent <a href=...> */
  HtmlElement *formStart;       /* Most recent <form> */
  HtmlElement *formElemStart;   /* Most recent <textarea> or <select> */
  HtmlElement *innerList;       /* The inner most <OL> or <UL> */

  /*
   * These fields are used to hold the state of the layout engine.
   * Because the layout is incremental, this state must be held for
   * the life of the widget.
   */
  HtmlLayoutContext layoutContext;

  /*
   * Information used when displaying the widget:
   */
  Tk_3DBorder border;		/* Background color */
  int borderWidth;		/* Width of the border. */
  int relief;			/* 3-D effect: TK_RELIEF_RAISED, etc. */
  int highlightWidth;		/* Width in pixels of highlight to draw
				 * around widget when it has the focus.
				 * <= 0 means don't draw a highlight. */
  XColor *highlightBgColorPtr;  /* Color for drawing traversal highlight
				 * area when highlight is off. */
  XColor *highlightColorPtr;	/* Color for drawing traversal highlight. */
  int inset;			/* Total width of highlight and 3-D border */
  Tk_Font aFont[N_FONT];	/* Information about all screen fonts */
  char fontValid[(N_FONT+7)/8]; /* If bit N%8 of work N/8 of this field is 0
                                 * if aFont[N] needs to be reallocated before
                                 * being used. */
  XColor *apColor[N_COLOR];     /* Information about all colors */
  int colorUsed;                /* bit N is 1 if color N is in use.  Only
                                ** applies to colors that aren't predefined */
  int iDark[N_COLOR];           /* Dark 3D shadow of color K is iDark[K] */
  int iLight[N_COLOR];          /* Light 3D shadow of color K is iLight[K] */
  XColor *fgColor;              /* Color of normal text. apColor[0] */
  XColor *newLinkColor;         /* Color of unvisitied links. apColor[1] */
  XColor *oldLinkColor;         /* Color of visitied links. apColor[2] */
  XColor *selectionColor;       /* Background color for selections */
  GcCache aGcCache[N_CACHE_GC]; /* A cache of GCs for general use */
  int lastGC;                   /* Index of recently used GC */
  HtmlImage *imageList;         /* A list of all images */
  int width, height;		/* User-requested size of the usable drawing
                                 * area, in pixels.   Borders and padding
                                 * make the actual window a little larger */
  int realWidth, realHeight;    /* The actual physical size of tkwin as
                                 * reported in the most recent ConfigureNotify
                                 * event. */
  int padx, pady;               /* Separation between the edge of the window
                                 * and rendered HTML.  */
  int underlineLinks;           /* TRUE if we should underline hyperlinks */

  /* Information about the selection
  */
  int exportSelection;          /* True if the selection is automatically
                                 * exported to the clipboard */

  /* Callback commands.  The HTML parser will invoke callbacks from time
  ** to time to find out information it needs to complete formatting of
  ** the document.  The following fields define the callback commands.
  */
  char *zIsVisited;             /* Command to tell if a hyperlink has already
                                ** been visited */
  char *zGetImage;              /* Command to get an image from a URL */
  char *zFrameCommand;          /* Command for handling <frameset> markup */
  char *zAppletCommand;         /* Command to process applets */
  char *zResolverCommand;       /* Command to resolve URIs */
  char *zFormCommand;           /* When user presses Submit */
  char *zHyperlinkCommand;      /* Invoked when a hyperlink is clicked */
  char *zFontCommand;           /* Invoked to find font names */
  char *zScriptCommand;         /* Invoked for each <SCRIPT> markup */

   /*
    * Miscellaneous information:
    */
  int tableRelief;              /* 3d effects on <TABLE> */
  int ruleRelief;               /* 3d effects on <HR> */
  char *zBase;                  /* The base URI */
  char *zBaseHref;              /* zBase as modified by <BASE HREF=..> markup */
  Tk_Cursor cursor;		/* Current cursor for window, or None. */
  char *takeFocus;		/* Value of -takefocus option;  not used in
				 * the C code, but used by keyboard traversal
				 * scripts.  Malloc'ed, but may be NULL. */
  char *yScrollCmd;		/* Command prefix for communicating with
				 * vertical scrollbar.  NULL means no command
				 * to issue.  Malloc'ed. */
  char *xScrollCmd;		/* Command prefix for communicating with
				 * horizontal scrollbar.  NULL means no command
				 * to issue.  Malloc'ed. */
  int xOffset, yOffset;         /* Current scroll position.  These form the
                                 * coordinate in the virtual canvas that
                                 * corresponds to (0,0) on the physical screen
                                 * in window tkwin */
  int maxX, maxY;               /* Maximum extent of any "paint" that appears
                                 * on the virtual canvas.  Used to compute 
                                 * scrollbar positions. */
  int dirtyLeft, dirtyTop;      /* Top left corner of region to redraw.  These
                                 * are physical screen coordinates relative to
                                 * clipwin, not tkwin. */
  int dirtyRight, dirtyBottom;  /* Bottom right corner of region to redraw */
  int locked;                   /* Number of locks on this structure. Don't
                                ** delete until it reaches zero. */
  int flags;			/* Various flags;  see below for
				 * definitions. */
};
struct HtmlImage {
  HtmlWidget *htmlPtr;     /* The owner of this image */
  Tk_Image image;          /* The Tk image token */
  Html_32 w;               /* Requested width of this image (0 if none) */
  Html_32 h;               /* Requested height of this image (0 if none) */
  char *zUrl;              /* The URL for this image. */
  char *zWidth, *zHeight;  /* Width and height in the <img> markup. */
  HtmlImage *pNext;        /* Next image on the list */
  HtmlElement *pList;      /* List of all <IMG> markups that use this 
                           ** same image */
};
struct HtmlMargin {
  int indent;          /* Size of the current margin */
  int bottom;          /* Y value at which this margin expires */
  int tag;             /* Markup that will cancel this margin */
  HtmlMargin *pNext;   /* Previous margin */
};