~ubuntu-branches/ubuntu/lucid/tidy/lucid

« back to all changes in this revision

Viewing changes to src/attrs.h

  • Committer: Bazaar Package Importer
  • Author(s): Jason Thomas
  • Date: 2008-01-20 21:46:03 UTC
  • mfrom: (3.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080120214603-poklofici9og61tx
Tags: 20080116cvs-2
* debian/control: build depends on xsltproc
  (closes: #461608)
* debian/tidy.preinst,postinst: add code to move old config file
  (closes: #461623)

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
/* attrs.h -- recognize HTML attributes
5
5
 
6
 
  (c) 1998-2003 (W3C) MIT, ERCIM, Keio University
 
6
  (c) 1998-2007 (W3C) MIT, ERCIM, Keio University
7
7
  See tidy.h for the copyright notice.
8
8
  
9
9
  CVS Info :
10
10
 
11
11
    $Author: arnaud02 $ 
12
 
    $Date: 2005/08/24 10:27:43 $ 
13
 
    $Revision: 1.20 $ 
 
12
    $Date: 2007/06/14 09:36:06 $ 
 
13
    $Revision: 1.29 $ 
14
14
 
15
15
*/
16
16
 
43
43
 
44
44
typedef struct _Anchor Anchor;
45
45
 
46
 
#ifdef ATTRIBUTE_HASH_LOOKUP
47
 
#define ATTRIBUTE_HASH_SIZE 178
 
46
#if !defined(ATTRIBUTE_HASH_LOOKUP)
 
47
#define ATTRIBUTE_HASH_LOOKUP 1
 
48
#endif
 
49
 
 
50
#if ATTRIBUTE_HASH_LOOKUP
 
51
enum
 
52
{
 
53
    ATTRIBUTE_HASH_SIZE=178u
 
54
};
 
55
 
 
56
struct _AttrHash
 
57
{
 
58
    Attribute const*  attr;
 
59
    struct _AttrHash* next;
 
60
};
 
61
 
 
62
typedef struct _AttrHash AttrHash;
48
63
#endif
49
64
 
50
65
struct _TidyAttribImpl
55
70
    /* Declared literal attributes */
56
71
    Attribute* declared_attr_list;
57
72
 
58
 
#ifdef ATTRIBUTE_HASH_LOOKUP
59
 
    Attribute* hashtab[ATTRIBUTE_HASH_SIZE];
 
73
#if ATTRIBUTE_HASH_LOOKUP
 
74
    AttrHash*  hashtab[ATTRIBUTE_HASH_SIZE];
60
75
#endif
61
76
};
62
77
 
64
79
 
65
80
#define XHTML_NAMESPACE "http://www.w3.org/1999/xhtml"
66
81
 
67
 
 
68
 
/*
69
 
 Bind attribute types to procedures to check values.
70
 
 You can add new procedures for better validation
71
 
 and each procedure has access to the node in which
72
 
 the attribute occurred as well as the attribute name
73
 
 and its value.
74
 
 
75
 
 By default, attributes are checked without regard
76
 
 to the element they are found on. You have the choice
77
 
 of making the procedure test which element is involved
78
 
 or in writing methods for each element which controls
79
 
 exactly how the attributes of that element are checked.
80
 
 This latter approach is best for detecting the absence
81
 
 of required attributes.
82
 
*/
83
 
 
84
 
AttrCheck CheckUrl;
85
 
AttrCheck CheckScript;
86
 
AttrCheck CheckName;
87
 
AttrCheck CheckId;
88
 
AttrCheck CheckAlign;
89
 
AttrCheck CheckValign;
90
 
AttrCheck CheckBool;
91
 
AttrCheck CheckLength;
92
 
AttrCheck CheckTarget;
93
 
AttrCheck CheckFsubmit;
94
 
AttrCheck CheckClear;
95
 
AttrCheck CheckShape;
96
 
AttrCheck CheckNumber;
97
 
AttrCheck CheckScope;
98
 
AttrCheck CheckColor;
99
 
AttrCheck CheckVType;
100
 
AttrCheck CheckScroll;
101
 
AttrCheck CheckTextDir;
102
 
AttrCheck CheckLang;
103
 
AttrCheck CheckType;
 
82
AttrCheck TY_(CheckUrl);
104
83
 
105
84
/* public method for finding attribute definition by name */
106
 
const Attribute* CheckAttribute( TidyDocImpl* doc, Node *node, AttVal *attval );
107
 
 
108
 
const Attribute* FindAttribute( TidyDocImpl* doc, AttVal *attval );
109
 
 
110
 
AttVal* GetAttrByName( Node *node, ctmbstr name );
111
 
 
112
 
AttVal* AddAttribute( TidyDocImpl* doc,
113
 
                      Node *node, ctmbstr name, ctmbstr value );
114
 
 
115
 
AttVal* RepairAttrValue(TidyDocImpl* doc, Node* node, ctmbstr name, ctmbstr value);
116
 
 
117
 
Bool IsUrl( TidyDocImpl* doc, ctmbstr attrname );
118
 
 
119
 
Bool IsBool( TidyDocImpl* doc, ctmbstr attrname );
120
 
 
121
 
Bool IsScript( TidyDocImpl* doc, ctmbstr attrname );
 
85
const Attribute* TY_(CheckAttribute)( TidyDocImpl* doc, Node *node, AttVal *attval );
 
86
 
 
87
const Attribute* TY_(FindAttribute)( TidyDocImpl* doc, AttVal *attval );
 
88
 
 
89
AttVal* TY_(GetAttrByName)( Node *node, ctmbstr name );
 
90
 
 
91
AttVal* TY_(AddAttribute)( TidyDocImpl* doc,
 
92
                           Node *node, ctmbstr name, ctmbstr value );
 
93
 
 
94
AttVal* TY_(RepairAttrValue)(TidyDocImpl* doc, Node* node, ctmbstr name, ctmbstr value);
 
95
 
 
96
Bool TY_(IsUrl)( TidyDocImpl* doc, ctmbstr attrname );
 
97
 
 
98
/* Bool IsBool( TidyDocImpl* doc, ctmbstr attrname ); */
 
99
 
 
100
Bool TY_(IsScript)( TidyDocImpl* doc, ctmbstr attrname );
122
101
 
123
102
/* may id or name serve as anchor? */
124
 
Bool IsAnchorElement( TidyDocImpl* doc, Node* node );
 
103
Bool TY_(IsAnchorElement)( TidyDocImpl* doc, Node* node );
125
104
 
126
105
/*
127
106
  In CSS1, selectors can contain only the characters A-Z, 0-9, and
137
116
 
138
117
  #508936 - CSS class naming for -clean option
139
118
*/
140
 
Bool IsCSS1Selector( ctmbstr buf );
 
119
Bool TY_(IsCSS1Selector)( ctmbstr buf );
141
120
 
142
 
Bool IsValidHTMLID(ctmbstr id);
143
 
Bool IsValidXMLID(ctmbstr id);
 
121
Bool TY_(IsValidHTMLID)(ctmbstr id);
 
122
Bool TY_(IsValidXMLID)(ctmbstr id);
144
123
 
145
124
/* removes anchor for specific node */
146
 
void RemoveAnchorByNode( TidyDocImpl* doc, Node *node );
147
 
 
148
 
/* add new anchor to namespace */
149
 
Anchor* AddAnchor( TidyDocImpl* doc, ctmbstr name, Node *node );
150
 
 
151
 
/* return node associated with anchor */
152
 
Node* GetNodeByAnchor( TidyDocImpl* doc, ctmbstr name );
 
125
void TY_(RemoveAnchorByNode)( TidyDocImpl* doc, Node *node );
153
126
 
154
127
/* free all anchors */
155
 
void FreeAnchors( TidyDocImpl* doc );
 
128
void TY_(FreeAnchors)( TidyDocImpl* doc );
156
129
 
157
130
 
158
131
/* public methods for inititializing/freeing attribute dictionary */
159
 
void InitAttrs( TidyDocImpl* doc );
160
 
void FreeAttrTable( TidyDocImpl* doc );
 
132
void TY_(InitAttrs)( TidyDocImpl* doc );
 
133
void TY_(FreeAttrTable)( TidyDocImpl* doc );
161
134
 
 
135
void TY_(AppendToClassAttr)( TidyDocImpl* doc, AttVal *classattr, ctmbstr classname );
162
136
/*
163
137
 the same attribute name can't be used
164
138
 more than once in each element
165
139
*/
166
 
void RepairDuplicateAttributes( TidyDocImpl* doc, Node* node );
167
 
 
168
 
Bool IsBoolAttribute( AttVal* attval );
169
 
Bool attrIsEvent( AttVal* attval );
170
 
 
171
 
AttVal* AttrGetById( Node* node, TidyAttrId id );
172
 
 
173
 
uint NodeAttributeVersions( Node* node, TidyAttrId id );
 
140
void TY_(RepairDuplicateAttributes)( TidyDocImpl* doc, Node* node, Bool isXml );
 
141
void TY_(SortAttributes)(Node* node, TidyAttrSortStrategy strat);
 
142
 
 
143
Bool TY_(IsBoolAttribute)( AttVal* attval );
 
144
Bool TY_(attrIsEvent)( AttVal* attval );
 
145
 
 
146
AttVal* TY_(AttrGetById)( Node* node, TidyAttrId id );
 
147
 
 
148
uint TY_(NodeAttributeVersions)( Node* node, TidyAttrId id );
174
149
 
175
150
/* 0 == TidyAttr_UNKNOWN  */
176
151
#define AttrId(av) ((av) && (av)->dict ? (av)->dict->id : TidyAttr_UNKNOWN)
178
153
 
179
154
#define AttrHasValue(attr)      ((attr) && (attr)->value)
180
155
#define AttrValueIs(attr, val)  (AttrHasValue(attr) && \
181
 
                                 tmbstrcasecmp((attr)->value, val) == 0)
 
156
                                 TY_(tmbstrcasecmp)((attr)->value, val) == 0)
182
157
#define AttrContains(attr, val) (AttrHasValue(attr) && \
183
 
                                 tmbsubstr((attr)->value, val) != NULL)
 
158
                                 TY_(tmbsubstr)((attr)->value, val) != NULL)
184
159
#define AttrVersions(attr)      ((attr) && (attr)->dict ? (attr)->dict->versions : VERS_PROPRIETARY)
185
160
 
186
161
#define AttrsHaveSameId(a, b) (a && b && a->dict && b->dict && a->dict->id && \
344
319
 
345
320
/* Attribute Retrieval macros
346
321
*/
347
 
#define attrGetHREF( nod )        AttrGetById( nod, TidyAttr_HREF  )
348
 
#define attrGetSRC( nod )         AttrGetById( nod, TidyAttr_SRC  )
349
 
#define attrGetID( nod )          AttrGetById( nod, TidyAttr_ID  )
350
 
#define attrGetNAME( nod )        AttrGetById( nod, TidyAttr_NAME  )
351
 
#define attrGetSUMMARY( nod )     AttrGetById( nod, TidyAttr_SUMMARY  )
352
 
#define attrGetALT( nod )         AttrGetById( nod, TidyAttr_ALT  )
353
 
#define attrGetLONGDESC( nod )    AttrGetById( nod, TidyAttr_LONGDESC  )
354
 
#define attrGetUSEMAP( nod )      AttrGetById( nod, TidyAttr_USEMAP  )
355
 
#define attrGetISMAP( nod )       AttrGetById( nod, TidyAttr_ISMAP  )
356
 
#define attrGetLANGUAGE( nod )    AttrGetById( nod, TidyAttr_LANGUAGE  )
357
 
#define attrGetTYPE( nod )        AttrGetById( nod, TidyAttr_TYPE  )
358
 
#define attrGetVALUE( nod )       AttrGetById( nod, TidyAttr_VALUE  )
359
 
#define attrGetCONTENT( nod )     AttrGetById( nod, TidyAttr_CONTENT  )
360
 
#define attrGetTITLE( nod )       AttrGetById( nod, TidyAttr_TITLE  )
361
 
#define attrGetXMLNS( nod )       AttrGetById( nod, TidyAttr_XMLNS  )
362
 
#define attrGetDATAFLD( nod )     AttrGetById( nod, TidyAttr_DATAFLD  )
363
 
#define attrGetWIDTH( nod )       AttrGetById( nod, TidyAttr_WIDTH  )
364
 
#define attrGetHEIGHT( nod )      AttrGetById( nod, TidyAttr_HEIGHT  )
365
 
#define attrGetFOR( nod )         AttrGetById( nod, TidyAttr_FOR  )
366
 
#define attrGetSELECTED( nod )    AttrGetById( nod, TidyAttr_SELECTED  )
367
 
#define attrGetCHECKED( nod )     AttrGetById( nod, TidyAttr_CHECKED  )
368
 
#define attrGetLANG( nod )        AttrGetById( nod, TidyAttr_LANG  )
369
 
#define attrGetTARGET( nod )      AttrGetById( nod, TidyAttr_TARGET  )
370
 
#define attrGetHTTP_EQUIV( nod )  AttrGetById( nod, TidyAttr_HTTP_EQUIV  )
371
 
#define attrGetREL( nod )         AttrGetById( nod, TidyAttr_REL  )
372
 
 
373
 
#define attrGetOnMOUSEMOVE( nod ) AttrGetById( nod, TidyAttr_OnMOUSEMOVE  )
374
 
#define attrGetOnMOUSEDOWN( nod ) AttrGetById( nod, TidyAttr_OnMOUSEDOWN  )
375
 
#define attrGetOnMOUSEUP( nod )   AttrGetById( nod, TidyAttr_OnMOUSEUP  )
376
 
#define attrGetOnCLICK( nod )     AttrGetById( nod, TidyAttr_OnCLICK  )
377
 
#define attrGetOnMOUSEOVER( nod ) AttrGetById( nod, TidyAttr_OnMOUSEOVER  )
378
 
#define attrGetOnMOUSEOUT( nod )  AttrGetById( nod, TidyAttr_OnMOUSEOUT  )
379
 
#define attrGetOnKEYDOWN( nod )   AttrGetById( nod, TidyAttr_OnKEYDOWN  )
380
 
#define attrGetOnKEYUP( nod )     AttrGetById( nod, TidyAttr_OnKEYUP  )
381
 
#define attrGetOnKEYPRESS( nod )  AttrGetById( nod, TidyAttr_OnKEYPRESS  )
382
 
#define attrGetOnFOCUS( nod )     AttrGetById( nod, TidyAttr_OnFOCUS  )
383
 
#define attrGetOnBLUR( nod )      AttrGetById( nod, TidyAttr_OnBLUR  )
384
 
 
385
 
#define attrGetBGCOLOR( nod )     AttrGetById( nod, TidyAttr_BGCOLOR  )
386
 
 
387
 
#define attrGetLINK( nod )        AttrGetById( nod, TidyAttr_LINK  )
388
 
#define attrGetALINK( nod )       AttrGetById( nod, TidyAttr_ALINK  )
389
 
#define attrGetVLINK( nod )       AttrGetById( nod, TidyAttr_VLINK  )
390
 
 
391
 
#define attrGetTEXT( nod )        AttrGetById( nod, TidyAttr_TEXT  )
392
 
#define attrGetSTYLE( nod )       AttrGetById( nod, TidyAttr_STYLE  )
393
 
#define attrGetABBR( nod )        AttrGetById( nod, TidyAttr_ABBR  )
394
 
#define attrGetCOLSPAN( nod )     AttrGetById( nod, TidyAttr_COLSPAN  )
395
 
#define attrGetFONT( nod )        AttrGetById( nod, TidyAttr_FONT  )
396
 
#define attrGetBASEFONT( nod )    AttrGetById( nod, TidyAttr_BASEFONT  )
397
 
#define attrGetROWSPAN( nod )     AttrGetById( nod, TidyAttr_ROWSPAN  )
 
322
#define attrGetHREF( nod )        TY_(AttrGetById)( nod, TidyAttr_HREF  )
 
323
#define attrGetSRC( nod )         TY_(AttrGetById)( nod, TidyAttr_SRC  )
 
324
#define attrGetID( nod )          TY_(AttrGetById)( nod, TidyAttr_ID  )
 
325
#define attrGetNAME( nod )        TY_(AttrGetById)( nod, TidyAttr_NAME  )
 
326
#define attrGetSUMMARY( nod )     TY_(AttrGetById)( nod, TidyAttr_SUMMARY  )
 
327
#define attrGetALT( nod )         TY_(AttrGetById)( nod, TidyAttr_ALT  )
 
328
#define attrGetLONGDESC( nod )    TY_(AttrGetById)( nod, TidyAttr_LONGDESC  )
 
329
#define attrGetUSEMAP( nod )      TY_(AttrGetById)( nod, TidyAttr_USEMAP  )
 
330
#define attrGetISMAP( nod )       TY_(AttrGetById)( nod, TidyAttr_ISMAP  )
 
331
#define attrGetLANGUAGE( nod )    TY_(AttrGetById)( nod, TidyAttr_LANGUAGE  )
 
332
#define attrGetTYPE( nod )        TY_(AttrGetById)( nod, TidyAttr_TYPE  )
 
333
#define attrGetVALUE( nod )       TY_(AttrGetById)( nod, TidyAttr_VALUE  )
 
334
#define attrGetCONTENT( nod )     TY_(AttrGetById)( nod, TidyAttr_CONTENT  )
 
335
#define attrGetTITLE( nod )       TY_(AttrGetById)( nod, TidyAttr_TITLE  )
 
336
#define attrGetXMLNS( nod )       TY_(AttrGetById)( nod, TidyAttr_XMLNS  )
 
337
#define attrGetDATAFLD( nod )     TY_(AttrGetById)( nod, TidyAttr_DATAFLD  )
 
338
#define attrGetWIDTH( nod )       TY_(AttrGetById)( nod, TidyAttr_WIDTH  )
 
339
#define attrGetHEIGHT( nod )      TY_(AttrGetById)( nod, TidyAttr_HEIGHT  )
 
340
#define attrGetFOR( nod )         TY_(AttrGetById)( nod, TidyAttr_FOR  )
 
341
#define attrGetSELECTED( nod )    TY_(AttrGetById)( nod, TidyAttr_SELECTED  )
 
342
#define attrGetCHECKED( nod )     TY_(AttrGetById)( nod, TidyAttr_CHECKED  )
 
343
#define attrGetLANG( nod )        TY_(AttrGetById)( nod, TidyAttr_LANG  )
 
344
#define attrGetTARGET( nod )      TY_(AttrGetById)( nod, TidyAttr_TARGET  )
 
345
#define attrGetHTTP_EQUIV( nod )  TY_(AttrGetById)( nod, TidyAttr_HTTP_EQUIV  )
 
346
#define attrGetREL( nod )         TY_(AttrGetById)( nod, TidyAttr_REL  )
 
347
 
 
348
#define attrGetOnMOUSEMOVE( nod ) TY_(AttrGetById)( nod, TidyAttr_OnMOUSEMOVE  )
 
349
#define attrGetOnMOUSEDOWN( nod ) TY_(AttrGetById)( nod, TidyAttr_OnMOUSEDOWN  )
 
350
#define attrGetOnMOUSEUP( nod )   TY_(AttrGetById)( nod, TidyAttr_OnMOUSEUP  )
 
351
#define attrGetOnCLICK( nod )     TY_(AttrGetById)( nod, TidyAttr_OnCLICK  )
 
352
#define attrGetOnMOUSEOVER( nod ) TY_(AttrGetById)( nod, TidyAttr_OnMOUSEOVER  )
 
353
#define attrGetOnMOUSEOUT( nod )  TY_(AttrGetById)( nod, TidyAttr_OnMOUSEOUT  )
 
354
#define attrGetOnKEYDOWN( nod )   TY_(AttrGetById)( nod, TidyAttr_OnKEYDOWN  )
 
355
#define attrGetOnKEYUP( nod )     TY_(AttrGetById)( nod, TidyAttr_OnKEYUP  )
 
356
#define attrGetOnKEYPRESS( nod )  TY_(AttrGetById)( nod, TidyAttr_OnKEYPRESS  )
 
357
#define attrGetOnFOCUS( nod )     TY_(AttrGetById)( nod, TidyAttr_OnFOCUS  )
 
358
#define attrGetOnBLUR( nod )      TY_(AttrGetById)( nod, TidyAttr_OnBLUR  )
 
359
 
 
360
#define attrGetBGCOLOR( nod )     TY_(AttrGetById)( nod, TidyAttr_BGCOLOR  )
 
361
 
 
362
#define attrGetLINK( nod )        TY_(AttrGetById)( nod, TidyAttr_LINK  )
 
363
#define attrGetALINK( nod )       TY_(AttrGetById)( nod, TidyAttr_ALINK  )
 
364
#define attrGetVLINK( nod )       TY_(AttrGetById)( nod, TidyAttr_VLINK  )
 
365
 
 
366
#define attrGetTEXT( nod )        TY_(AttrGetById)( nod, TidyAttr_TEXT  )
 
367
#define attrGetSTYLE( nod )       TY_(AttrGetById)( nod, TidyAttr_STYLE  )
 
368
#define attrGetABBR( nod )        TY_(AttrGetById)( nod, TidyAttr_ABBR  )
 
369
#define attrGetCOLSPAN( nod )     TY_(AttrGetById)( nod, TidyAttr_COLSPAN  )
 
370
#define attrGetFONT( nod )        TY_(AttrGetById)( nod, TidyAttr_FONT  )
 
371
#define attrGetBASEFONT( nod )    TY_(AttrGetById)( nod, TidyAttr_BASEFONT  )
 
372
#define attrGetROWSPAN( nod )     TY_(AttrGetById)( nod, TidyAttr_ROWSPAN  )
398
373
 
399
374
#endif /* __ATTRS_H__ */