4
*----------------------------------------------------------------------------
5
* Copyright (c) 2005 Dan Kennedy.
8
* This Open Source project was made possible through the financial support
9
* of Eolas Technologies Inc.
11
* Redistribution and use in source and binary forms, with or without
12
* modification, are permitted provided that the following conditions are met:
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.
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.
36
#ifndef __HTMLTREE_H__
37
#define __HTMLTREE_H__
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.
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))
51
#define HtmlAlloc(zTopic, n) ckalloc(n)
52
#define HtmlFree(x) ckfree((char *)(x))
53
#define HtmlRealloc(zTopic, x, n) ckrealloc((char *)(x), n)
56
/* HtmlClearAlloc() is a version of HtmlAlloc() that returns zeroed memory */
57
#define HtmlClearAlloc(zTopic, x) ((char *)memset(HtmlAlloc(zTopic,(x)),0,(x)))
59
#define HtmlNew(x) ((x *)HtmlClearAlloc(#x, sizeof(x)))
61
#define USE_COMPOSITELESS_PHOTO_PUT_BLOCK
68
#include "htmltokens.h"
69
#include "htmlmacros.h"
72
* Version information for the package mechanism.
74
#define HTML_PKGNAME "Tkhtml"
75
#define HTML_PKGVERSION "3.0"
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.
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 */
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.
97
# define stricmp strcasecmp
98
# define strnicmp strncasecmp
102
* Some versions of windows do not have the vsnprintf() and snprintf()
103
* macros. According to msdn, these are for "backwards compatibility" only.
106
# define vsnprintf _vsnprintf
107
# define snprintf _snprintf
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;
126
typedef struct HtmlImageServer HtmlImageServer;
127
typedef struct HtmlImage2 HtmlImage2;
129
typedef struct HtmlWidgetTag HtmlWidgetTag;
130
typedef struct HtmlTaggedRegion HtmlTaggedRegion;
131
typedef struct HtmlText HtmlText;
133
typedef struct HtmlNode HtmlNode;
134
typedef struct HtmlElementNode HtmlElementNode;
135
typedef struct HtmlTextNode HtmlTextNode;
137
typedef struct HtmlTextToken HtmlTextToken;
138
typedef struct HtmlTextIter HtmlTextIter;
140
typedef struct HtmlDamage HtmlDamage;
142
typedef struct HtmlFragmentContext HtmlFragmentContext;
143
typedef struct HtmlSearchCache HtmlSearchCache;
146
#include "htmlprop.h"
148
typedef int (*HtmlContentTest)(HtmlTree *, HtmlNode *, int);
150
#define FLOAT_LEFT CSS_CONST_LEFT
151
#define FLOAT_RIGHT CSS_CONST_RIGHT
152
#define FLOAT_NONE CSS_CONST_NONE
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
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 */
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>) */
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 */
180
struct HtmlAttributes {
182
struct HtmlAttribute {
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:
194
* $nodeHandle replace $pReplace \
195
* -configurecmd $pConfigure -deletecmd $pDelete
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.
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 */
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 */
221
* When a Tcl command representing a node-handle is created, an instance of the
222
* following structure is allocated.
229
struct HtmlNodeStack {
230
HtmlElementNode *pElem;
231
int eType; /* Usage defined in htmlstyle.c */
233
HtmlNodeStack *pNext;
234
HtmlNodeStack *pPrev;
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.
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
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).
255
struct HtmlNodeScrollbars {
256
HtmlNodeReplacement vertical;
257
HtmlNodeReplacement horizontal;
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 */
269
* Widget tag properties. Each widget tag is stored in the
270
* HtmlTree.aTag hash table.
272
struct HtmlWidgetTag {
273
XColor *foreground; /* Foreground color to use for tagged regions */
274
XColor *background; /* Background color to use for tagged regions */
278
* Each text node has a list of "tagged regions" attached to it (the
279
* list may be empty). See the HtmlTextNode.pTagged variable.
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 */
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.
295
ClientData clientData;
296
HtmlNode *pParent; /* Parent of this node */
297
int iNode; /* Node index */
299
Html_u8 eTag; /* Tag type (or 0) */
300
const char *zTag; /* Atom string for tag type */
302
int iSnapshot; /* Last changed snapshot */
303
HtmlNodeCmd *pNodeCmd; /* Tcl command for this node */
305
/* Cache used for [$widget bbox] */
306
int iBboxX; int iBboxY;
307
int iBboxX2; int iBboxY2;
310
/* Value of HtmlNode.iNode for orphan and generated nodes. */
311
#define HTML_NODE_ORPHAN -23
312
#define HTML_NODE_GENERATED -1
315
* Structure to store a text node.
317
struct HtmlTextNode {
318
HtmlNode node; /* Base class. MUST BE FIRST. */
319
HtmlTaggedRegion *pTagged; /* List of applied Widget tags */
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.
326
HtmlTextToken *aToken;
331
* The name of the attribute parsed to generate inline-style properties
332
* for an element (HtmlElementNode.pStyle).
334
#define HTML_INLINE_STYLE_ATTR "style"
337
* Structure to store an element (non-text) node.
339
struct HtmlElementNode {
340
HtmlNode node; /* Base class. MUST BE FIRST. */
342
HtmlAttributes *pAttributes; /* Html attributes associated with node */
344
/* Children of this element node */
345
int nChild; /* Number of child nodes */
346
HtmlNode **apChildren; /* Array of pointers to children nodes */
348
CssPropertySet *pStyle; /* Parsed inline style */
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 */
359
/* Manipulated by the [nodeHandle dynamic] command */
360
Html_u8 flags; /* HTML_DYNAMIC_XXX flags */
362
HtmlNodeReplacement *pReplacement; /* Replaced object, if any */
363
HtmlLayoutCache *pLayoutCache; /* Cached layout, if any */
364
HtmlNodeScrollbars *pScrollbar; /* Internal scrollbars, if any */
366
HtmlCanvasItem *pBox;
369
/* Alias for HtmlNodeXXX() methods */
370
#define HtmlElemParent(p) ((HtmlElementNode *)HtmlNodeParent(&(p)->node))
372
/* Values for HtmlNode.flags. These may be set and cleared via the Tcl
373
* interface on the node command: [$node dynamic set|clear ...]
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
387
HtmlCanvasItem *pFirst;
388
HtmlCanvasItem *pLast;
392
* All widget options are stored in this structure, which is a part of
393
* the HtmlTree structure (HtmlTree.options).
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.
400
/* Tkhtml3 supports the following standard Tk options */
403
int xscrollincrement;
404
int yscrollincrement;
405
Tcl_Obj *yscrollcommand;
406
Tcl_Obj *xscrollcommand;
408
Tcl_Obj *defaultstyle;
411
int forcefontmetrics;
416
int mode; /* One of the HTML_MODE_XXX values */
417
int shrink; /* Boolean */
418
double zoom; /* Universal scaling factor. */
420
int parsemode; /* One of the HTML_PARSEMODE values */
422
/* Debugging options. Not part of the official interface. */
429
#define HTML_MODE_QUIRKS 0
430
#define HTML_MODE_ALMOST 1
431
#define HTML_MODE_STANDARDS 2
433
#define HTML_PARSEMODE_HTML 0
434
#define HTML_PARSEMODE_XHTML 1
435
#define HTML_PARSEMODE_XML 2
437
void HtmlLog(HtmlTree *, CONST char *, CONST char *, ...);
438
void HtmlTimer(HtmlTree *, CONST char *, CONST char *, ...);
440
typedef struct HtmlCanvasSnapshot HtmlCanvasSnapshot;
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.
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 */
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).
465
HtmlCanvasSnapshot *pSnapshot;
468
HtmlNode *pDynamic; /* Recalculate dynamic CSS for this node */
474
HtmlNode *pRestyle; /* Restyle this node */
477
int iScrollX; /* New HtmlTree.iScrollX value */
478
int iScrollY; /* New HtmlTree.iScrollY value */
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
491
* Functions used to schedule callbacks and set the HtmlCallback state.
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 *);
499
void HtmlCallbackScrollX(HtmlTree *, int);
500
void HtmlCallbackScrollY(HtmlTree *, int);
502
void HtmlCallbackDamageNode(HtmlTree *, HtmlNode *);
505
* An instance of the following structure stores state for the tree
506
* construction phase. See the following functions:
508
* HtmlTreeAddElement()
510
* HtmlTreeAddClosingTag()
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> */
521
* The interpreter hosting this widget instance.
523
Tcl_Interp *interp; /* Tcl interpreter */
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 */
532
Tk_Window docwin; /* Document window */
535
* The widget command.
537
Tcl_Command cmd; /* Widget command */
538
int isDeleted; /* True once the widget-delete has begun */
541
* The image server object.
543
HtmlImageServer *pImageServer;
546
* The search cache object.
548
HtmlSearchCache *pSearchCache;
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.
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.
558
Tcl_Obj *pDocument; /* Text of the html document */
559
int nParsed; /* Bytes of pDocument tokenized */
560
int nCharParsed; /* TODO: Characters parsed */
562
int iWriteInsert; /* Byte offset in pDocument for [write] */
563
int eWriteState; /* One of the HTML_WRITE_XXX values */
565
int isIgnoreNewline; /* True after an opening tag */
566
int isParseFinished; /* True if the html parse is finished */
568
HtmlNode *pRoot; /* The root-node of the document. */
570
Tcl_HashTable aAtom; /* String atoms for this widget */
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.
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.
581
Tcl_HashTable aOrphan; /* Orphan nodes (see [$html fragment]) */
583
/* This pointer is used to store context during the exeuction of
584
* the [$html fragment] command. See htmltree.c for details.
586
HtmlFragmentContext *pFragment;
588
int isFixed; /* True if any "fixed" graphics */
591
* Handler callbacks configured by the [$widget handler] command.
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.
600
* The node-handler and parse-handler tables are similar.
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. */
607
CssStyleSheet *pStyle; /* Style sheet configuration */
609
/* Used by code in HtmlStyleApply() */
612
HtmlOptions options; /* Configurable options */
613
Tk_OptionTable optionTable; /* Option table */
615
/* Linked list of stacking contexts */
616
HtmlNodeStack *pStack;
617
int nStack; /* Number of elements in linked list */
620
* Internal representation of a completely layed-out document.
622
HtmlCanvas canvas; /* Canvas to render into */
623
int iCanvasWidth; /* Width of window for canvas */
624
int iCanvasHeight; /* Height of window for canvas */
626
/* Linked list of currently mapped replacement objects */
627
HtmlNodeReplacement *pMapped;
630
* Tables managed by code in htmlprop.c. Initialised in function
631
* HtmlComputedValuesSetupTables(), except for aFontSizeTable[], which is
632
* set via the -fonttable option.
634
Tcl_HashTable aColor;
635
HtmlFontCache fontcache;
636
Tcl_HashTable aValues;
637
Tcl_HashTable aFontFamilies;
638
Tcl_HashTable aCounterLists;
639
HtmlComputedValuesCreator *pPrototypeCreator;
641
int aFontSizeTable[7];
644
* Hash table for all html widget tags (similar to text widget tags -
645
* nothing to do with markup tags).
648
Tk_OptionTable tagOptionTable; /* Option table for tags*/
650
/* The isSequenceOk variable is true if the HtmlNode.iNode values for all
651
* nodes in the tree are currently in tree order.
654
int iNextNode; /* Next node index to allocate */
656
/* True if the HtmlElementNode.iBboxX and HtmlElementNode.iBboxY values
657
* for all elements in the tree are valid.
661
HtmlCallback cb; /* See structure definition comments */
662
int iLastSnapshotId; /* Last snapshot id allocated */
663
Tcl_TimerToken delayToken;
666
* Data structure used by the [widget text] commands. See the
667
* HtmlTextXXX() API below.
671
#ifdef TKHTML_ENABLE_PROFILE
673
* Client data from instrument command ([::tkhtml::instrument]).
675
ClientData pInstrumentData;
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 *);
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)))
694
void HtmlFinishNodeHandlers(HtmlTree *);
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;
707
Tcl_ObjCmdProc HtmlDebug;
708
Tcl_ObjCmdProc HtmlDecode;
709
Tcl_ObjCmdProc HtmlEncode;
710
Tcl_ObjCmdProc HtmlEscapeUriComponent;
711
Tcl_ObjCmdProc HtmlResolveUri;
712
Tcl_ObjCmdProc HtmlCreateUri;
714
char *HtmlPropertyToString(CssProperty *, char **);
716
int HtmlStyleApply(HtmlTree *, HtmlNode *);
717
int HtmlStyleCounter(HtmlTree *, const char *);
718
int HtmlStyleCounters(HtmlTree *, const char *, int *, int);
719
void HtmlStyleHandleCounters(HtmlTree *, HtmlComputedValues *);
721
int HtmlLayout(HtmlTree *);
722
void HtmlLayoutMarkerBox(int, int, int, char *);
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);
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);
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 *);
748
int HtmlNodeAddChild(HtmlElementNode *, int, const char *, HtmlAttributes *);
749
int HtmlNodeAddTextChild(HtmlNode *, HtmlTextNode *);
751
Html_u8 HtmlNodeTagType(HtmlNode *);
753
Tcl_Obj *HtmlNodeCommand(HtmlTree *, HtmlNode *pNode);
754
int HtmlNodeDeleteCommand(HtmlTree *, HtmlNode *pNode);
756
void HtmlDrawCleanup(HtmlTree *, HtmlCanvas *);
757
void HtmlDrawDeleteControls(HtmlTree *, HtmlCanvas *);
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*);
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);
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 *);
775
void HtmlDrawImage(HtmlCanvas*, HtmlImage2*, int, int, int, int, HtmlNode*, int);
776
void HtmlDrawOrigin(HtmlCanvas*);
777
void HtmlDrawCopyCanvas(HtmlCanvas*, HtmlCanvas*);
779
void HtmlDrawOverflow(HtmlCanvas*, HtmlNode*, int, int);
781
HtmlCanvasItem *HtmlDrawAddMarker(HtmlCanvas*, int, int, int);
782
int HtmlDrawGetMarker(HtmlCanvas*, HtmlCanvasItem *, int*, int*);
784
void HtmlDrawAddLinebox(HtmlCanvas*, int, int);
785
int HtmlDrawFindLinebox(HtmlCanvas*, int*, int*);
787
HtmlCanvasSnapshot *HtmlDrawSnapshotZero(HtmlTree *);
788
HtmlCanvasSnapshot *HtmlDrawSnapshot(HtmlTree *, int);
789
void HtmlDrawSnapshotDamage(HtmlTree*,HtmlCanvasSnapshot*,HtmlCanvasSnapshot**);
790
void HtmlDrawSnapshotFree(HtmlTree *, HtmlCanvasSnapshot *);
792
void HtmlDrawCanvasItemRelease(HtmlTree *, HtmlCanvasItem *);
793
void HtmlDrawCanvasItemReference(HtmlCanvasItem *);
795
void HtmlWidgetDamageText(HtmlTree *, HtmlNode *, int, HtmlNode *, int);
796
int HtmlWidgetNodeTop(HtmlTree *, HtmlNode *);
797
void HtmlWidgetOverflowBox(HtmlTree *, HtmlNode *, int *, int *, int *, int *);
799
HtmlTokenMap *HtmlMarkup(int);
800
CONST char * HtmlMarkupName(int);
801
char * HtmlMarkupArg(HtmlAttributes *, CONST char *, char *);
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);
814
HtmlPropertyCache * HtmlNewPropertyCache();
815
void HtmlSetPropertyCache(HtmlPropertyCache *, int, CssProperty *);
816
void HtmlAttributesToPropertyCache(HtmlNode *pNode);
818
Tcl_HashKeyType * HtmlCaseInsenstiveHashType();
819
Tcl_HashKeyType * HtmlFontKeyHashType();
820
Tcl_HashKeyType * HtmlComputedValuesHashType();
822
CONST char *HtmlDefaultTcl();
823
CONST char *HtmlDefaultCss();
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 *);
843
void HtmlImageServerSuspendGC(HtmlTree *);
844
void HtmlImageServerDoGC(HtmlTree *);
845
int HtmlImageServerCount(HtmlTree *);
847
void HtmlLayoutPaintNode(HtmlTree *, HtmlNode *);
848
void HtmlLayoutInvalidateCache(HtmlTree *, HtmlNode *);
849
void HtmlWidgetNodeBox(HtmlTree *, HtmlNode *, int *, int *, int *, int *);
851
void HtmlWidgetSetViewport(HtmlTree *, int, int, int);
852
void HtmlWidgetRepair(HtmlTree *, int, int, int, int, int);
854
int HtmlNodeClearStyle(HtmlTree *, HtmlElementNode *);
855
int HtmlNodeClearGenerated(HtmlTree *, HtmlElementNode *);
856
void HtmlNodeClearRecursive(HtmlTree *, HtmlNode *);
858
void HtmlTranslateEscapes(char *);
859
void HtmlRestackNodes(HtmlTree *pTree);
860
void HtmlDelStackingInfo(HtmlTree *, HtmlElementNode *);
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 *);
871
Tcl_ObjCmdProc HtmlTextTextCmd;
872
Tcl_ObjCmdProc HtmlTextIndexCmd;
873
Tcl_ObjCmdProc HtmlTextBboxCmd;
874
Tcl_ObjCmdProc HtmlTextOffsetCmd;
875
void HtmlTextInvalidate(HtmlTree *);
877
void HtmlWidgetBboxText(
878
HtmlTree *, HtmlNode *, int, HtmlNode *, int, int *, int *, int *, int*);
879
int HtmlNodeScrollbarDoCallback(HtmlTree *, HtmlNode *);
881
void HtmlDelScrollbars(HtmlTree *, HtmlNode *);
883
HtmlAttributes * HtmlAttributesNew(int, char const **, int *, int);
885
void HtmlParseFragment(HtmlTree *, const char *);
886
void HtmlSequenceNodes(HtmlTree *);
888
void HtmlFontReference(HtmlFont *);
889
void HtmlFontRelease(HtmlTree *, HtmlFont *);
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)
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).
902
* The functions invoked by the tokenizer when it is parsing a document
905
* fragmentAddElement()
907
* fragmentAddClosingTag()
909
* These are also in htmltree.c but are not defined with external linkage.
911
void HtmlTreeAddElement(HtmlTree *, int, const char *, HtmlAttributes *, int);
912
void HtmlTreeAddText(HtmlTree *, HtmlTextNode *, int);
913
void HtmlTreeAddClosingTag(HtmlTree *, int, const char *, int);
915
void HtmlInitTree(HtmlTree *);
917
void HtmlHashInit(void *, int);
918
HtmlTokenMap * HtmlHashLookup(void *, const char *zType);
920
/*******************************************************************
921
* Interface to code in htmltext.c
922
*******************************************************************/
925
* Creation, modification and deletion of HtmlTextNode objects.
927
HtmlTextNode * HtmlTextNew(int, const char *, int, int);
928
void HtmlTextSet(HtmlTextNode *, int, const char *, int, int);
929
void HtmlTextFree(HtmlTextNode *);
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.
935
struct HtmlTextIter {
936
HtmlTextNode *pTextNode;
942
* Functions for iterating through the tokens of a text node. Used as
945
* HtmlTextNode *pText = ...
949
* HtmlTextIterFirst(&iter);
950
* HtmlTextIterIsValid(&iter);
951
* HtmlTextIterNext(&iter)
956
void HtmlTextIterFirst(HtmlTextNode *, HtmlTextIter *);
957
void HtmlTextIterNext(HtmlTextIter *);
958
int HtmlTextIterIsValid(HtmlTextIter *);
959
int HtmlTextIterIsLast(HtmlTextIter *);
962
* Query functions to discover the token type, length and data.
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.
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
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
977
int HtmlTextIterType(HtmlTextIter *);
978
int HtmlTextIterLength(HtmlTextIter *);
979
const char *HtmlTextIterData(HtmlTextIter *);
982
#define HtmlCheckRestylePoint(x)
984
void HtmlCheckRestylePoint(HtmlTree *pTree);
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
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.
998
#define HTML_TEXT_TOKEN_END 0
999
#define HTML_TEXT_TOKEN_LONGTEXT 5
1002
* The following symbols are used for the built-in instrumentation
1003
* function. (profile data).
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
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);
1018
const char *HtmlTypeToName(void *, int);