Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGHtmlParse.cxx
Go to the documentation of this file.
1// $Id: TGHtmlParse.cxx,v 1.1 2007/05/04 17:07:01 brun Exp $
2// Author: Valeriy Onuchin 03/05/2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2001, Rene Brun, Fons Rademakers and Reiner Rohlfs *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12/**************************************************************************
13
14 HTML widget for xclass. Based on tkhtml 1.28
15 Copyright (C) 1997-2000 D. Richard Hipp <drh@acm.org>
16 Copyright (C) 2002-2003 Hector Peraza.
17
18 This library is free software; you can redistribute it and/or
19 modify it under the terms of the GNU Library General Public
20 License as published by the Free Software Foundation; either
21 version 2 of the License, or (at your option) any later version.
22
23 This library is distributed in the hope that it will be useful,
24 but WITHOUT ANY WARRANTY; without even the implied warranty of
25 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 Library General Public License for more details.
27
28 You should have received a copy of the GNU Library General Public
29 License along with this library; if not, write to the Free
30 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31
32**************************************************************************/
33
34// A tokenizer that converts raw HTML into a linked list of HTML elements.
35
36#include "TGHtml.h"
37#include "TGHtmlTokens.h"
38#include "strlcpy.h"
39
40#include <cstring>
41#include <cstdlib>
42#include <cstdio>
43#include <cctype>
44
45//----------------------------------------------------------------------
46
48
49
50/****************** Begin Escape Sequence Translator *************/
51
52// The next section of code implements routines used to translate
53// the '&' escape sequences of SGML to individual characters.
54// Examples:
55//
56// &amp; &
57// &lt; <
58// &gt; >
59// &nbsp; nonbreakable space
60//
61
62// Each escape sequence is recorded as an instance of the following
63// structure
64
65struct SgEsc_t {
66 const char *fZName; // The name of this escape sequence. ex: "amp"
67 char fValue[8]; // The value for this sequence. ex: "&"
68 SgEsc_t *fPNext; // Next sequence with the same hash on zName
69};
70
71// The following is a table of all escape sequences. Add new sequences
72// by adding entries to this table.
73
74static struct SgEsc_t gEscSequences[] = {
75 { "quot", "\"", 0 },
76 { "amp", "&", 0 },
77 { "lt", "<", 0 },
78 { "gt", ">", 0 },
79 { "nbsp", " ", 0 },
80 { "iexcl", "\241", 0 },
81 { "cent", "\242", 0 },
82 { "pound", "\243", 0 },
83 { "curren", "\244", 0 },
84 { "yen", "\245", 0 },
85 { "brvbar", "\246", 0 },
86 { "sect", "\247", 0 },
87 { "uml", "\250", 0 },
88 { "copy", "\251", 0 },
89 { "ordf", "\252", 0 },
90 { "laquo", "\253", 0 },
91 { "not", "\254", 0 },
92 { "shy", "\255", 0 },
93 { "reg", "\256", 0 },
94 { "macr", "\257", 0 },
95 { "deg", "\260", 0 },
96 { "plusmn", "\261", 0 },
97 { "sup2", "\262", 0 },
98 { "sup3", "\263", 0 },
99 { "acute", "\264", 0 },
100 { "micro", "\265", 0 },
101 { "para", "\266", 0 },
102 { "middot", "\267", 0 },
103 { "cedil", "\270", 0 },
104 { "sup1", "\271", 0 },
105 { "ordm", "\272", 0 },
106 { "raquo", "\273", 0 },
107 { "frac14", "\274", 0 },
108 { "frac12", "\275", 0 },
109 { "frac34", "\276", 0 },
110 { "iquest", "\277", 0 },
111 { "Agrave", "\300", 0 },
112 { "Aacute", "\301", 0 },
113 { "Acirc", "\302", 0 },
114 { "Atilde", "\303", 0 },
115 { "Auml", "\304", 0 },
116 { "Aring", "\305", 0 },
117 { "AElig", "\306", 0 },
118 { "Ccedil", "\307", 0 },
119 { "Egrave", "\310", 0 },
120 { "Eacute", "\311", 0 },
121 { "Ecirc", "\312", 0 },
122 { "Euml", "\313", 0 },
123 { "Igrave", "\314", 0 },
124 { "Iacute", "\315", 0 },
125 { "Icirc", "\316", 0 },
126 { "Iuml", "\317", 0 },
127 { "ETH", "\320", 0 },
128 { "Ntilde", "\321", 0 },
129 { "Ograve", "\322", 0 },
130 { "Oacute", "\323", 0 },
131 { "Ocirc", "\324", 0 },
132 { "Otilde", "\325", 0 },
133 { "Ouml", "\326", 0 },
134 { "times", "\327", 0 },
135 { "Oslash", "\330", 0 },
136 { "Ugrave", "\331", 0 },
137 { "Uacute", "\332", 0 },
138 { "Ucirc", "\333", 0 },
139 { "Uuml", "\334", 0 },
140 { "Yacute", "\335", 0 },
141 { "THORN", "\336", 0 },
142 { "szlig", "\337", 0 },
143 { "agrave", "\340", 0 },
144 { "aacute", "\341", 0 },
145 { "acirc", "\342", 0 },
146 { "atilde", "\343", 0 },
147 { "auml", "\344", 0 },
148 { "aring", "\345", 0 },
149 { "aelig", "\346", 0 },
150 { "ccedil", "\347", 0 },
151 { "egrave", "\350", 0 },
152 { "eacute", "\351", 0 },
153 { "ecirc", "\352", 0 },
154 { "euml", "\353", 0 },
155 { "igrave", "\354", 0 },
156 { "iacute", "\355", 0 },
157 { "icirc", "\356", 0 },
158 { "iuml", "\357", 0 },
159 { "eth", "\360", 0 },
160 { "ntilde", "\361", 0 },
161 { "ograve", "\362", 0 },
162 { "oacute", "\363", 0 },
163 { "ocirc", "\364", 0 },
164 { "otilde", "\365", 0 },
165 { "ouml", "\366", 0 },
166 { "divide", "\367", 0 },
167 { "oslash", "\370", 0 },
168 { "ugrave", "\371", 0 },
169 { "uacute", "\372", 0 },
170 { "ucirc", "\373", 0 },
171 { "uuml", "\374", 0 },
172 { "yacute", "\375", 0 },
173 { "thorn", "\376", 0 },
174 { "yuml", "\377", 0 },
175};
176
177
178// The size of the handler hash table. For best results this should
179// be a prime number which is about the same size as the number of
180// escape sequences known to the system.
181
182#define ESC_HASH_SIZE (sizeof(gEscSequences)/sizeof(gEscSequences[0])+7)
183
184
185// The hash table
186//
187// If the name of an escape sequence hashes to the value H, then
188// gApEscHash[H] will point to a linked list of Esc structures, one of
189// which will be the Esc structure for that escape sequence.
190
192
193
194// Hash a escape sequence name. The value returned is an integer
195// between 0 and ESC_HASH_SIZE-1, inclusive.
196
197static int EscHash(const char *zName) {
198 int h = 0; // The hash value to be returned
199 char c; // The next character in the name being hashed
200
201 while ((c = *zName) != 0) {
202 h = h<<5 ^ h ^ c;
203 zName++;
204 }
205 if (h < 0) h = -h;
206
207 return h % ESC_HASH_SIZE;
208}
209
210#ifdef TEST
211// Compute the longest and average collision chain length for the
212// escape sequence hash table
213
214static void EscHashStats()
215{
216 int i;
217 int sum = 0;
218 int max = 0;
219 int cnt;
220 int notempty = 0;
221 struct SgEsc_t *p;
222
223 for (i = 0; i < sizeof(gEscSequences) / sizeof(gEscSequences[0]); i++) {
224 cnt = 0;
225 p = gApEscHash[i];
226 if (p) notempty++;
227 while (p) {
228 ++cnt;
229 p = p->fPNext;
230 }
231 sum += cnt;
232 if (cnt > max) max = cnt;
233 }
234 printf("Longest chain=%d avg=%g slots=%d empty=%d (%g%%)\n",
235 max, (double)sum/(double)notempty, i, i-notempty,
236 100.0*(i-notempty)/(double)i);
237}
238#endif
239
240// Initialize the escape sequence hash table
241
242static void EscInit() {
243 int i; /* For looping thru the list of escape sequences */
244 int h; /* The hash on a sequence */
245
246 for (i = 0; i < int(sizeof(gEscSequences) / sizeof(gEscSequences[i])); i++) {
247/* #ifdef XCLASS_UTF_MAX */
248#if 0
249 int c = gEscSequences[i].value[0];
250 xclass::UniCharToUtf(c, gEscSequences[i].value);
251 }
252#endif
254 gEscSequences[i].fPNext = gApEscHash[h];
256 }
257#ifdef TEST
258 EscHashStats();
259#endif
260}
261
262
263// This table translates the non-standard microsoft characters between 0x80
264// and 0x9f into plain ASCII so that the characters will be visible on Unix
265// systems. Care is taken to translate the characters into values less than
266// 0x80, to avoid UTF-8 problems.
267
268static char gAcMsChar[] = {
269 /* 0x80 */ 'C',
270 /* 0x81 */ ' ',
271 /* 0x82 */ ',',
272 /* 0x83 */ 'f',
273 /* 0x84 */ '"',
274 /* 0x85 */ '.',
275 /* 0x86 */ '*',
276 /* 0x87 */ '*',
277 /* 0x88 */ '^',
278 /* 0x89 */ '%',
279 /* 0x8a */ 'S',
280 /* 0x8b */ '<',
281 /* 0x8c */ 'O',
282 /* 0x8d */ ' ',
283 /* 0x8e */ 'Z',
284 /* 0x8f */ ' ',
285 /* 0x90 */ ' ',
286 /* 0x91 */ '\'',
287 /* 0x92 */ '\'',
288 /* 0x93 */ '"',
289 /* 0x94 */ '"',
290 /* 0x95 */ '*',
291 /* 0x96 */ '-',
292 /* 0x97 */ '-',
293 /* 0x98 */ '~',
294 /* 0x99 */ '@',
295 /* 0x9a */ 's',
296 /* 0x9b */ '>',
297 /* 0x9c */ 'o',
298 /* 0x9d */ ' ',
299 /* 0x9e */ 'z',
300 /* 0x9f */ 'Y',
301};
302
303
304////////////////////////////////////////////////////////////////////////////////
305/// Translate escape sequences in the string "z". "z" is overwritten
306/// with the translated sequence.
307///
308/// Unrecognized escape sequences are unaltered.
309///
310/// Example:
311///
312/// input = "AT&amp;T &gt MCI"
313/// output = "AT&T > MCI"
314
316{
317 int from; // Read characters from this position in z[]
318 int to; // Write characters into this position in z[]
319 int h; // A hash on the escape sequence
320 struct SgEsc_t *p; // For looping down the escape sequence collision chain
321 static int isInit = 0; // True after initialization
322
323 from = to = 0;
324 if (!isInit) {
325 EscInit();
326 isInit = 1;
327 }
328 while (z[from]) {
329 if (z[from] == '&') {
330 if (z[from+1] == '#') {
331 int i = from + 2;
332 int v = 0;
333 while (isdigit(z[i])) {
334 v = v*10 + z[i] - '0';
335 i++;
336 }
337 if (z[i] == ';') { i++; }
338
339 // Translate the non-standard microsoft characters in the range of
340 // 0x80 to 0x9f into something we can see.
341
342 if (v >= 0x80 && v < 0xa0) {
343 v = gAcMsChar[v & 0x1f];
344 }
345
346 // Put the character in the output stream in place of the "&#000;".
347 // How we do this depends on whether or not we are using UTF-8.
348
349 z[to++] = v;
350 from = i;
351 } else {
352 int i = from+1;
353 int c;
354 while (z[i] && isalnum(z[i])) ++i;
355 c = z[i];
356 z[i] = 0;
357 h = EscHash(&z[from+1]);
358 p = gApEscHash[h];
359 while (p && strcmp(p->fZName, &z[from+1]) != 0) p = p->fPNext;
360 z[i] = c;
361 if (p) {
362 int j;
363 for (j = 0; p->fValue[j]; ++j) z[to++] = p->fValue[j];
364 from = i;
365 if (c == ';') from++;
366 } else {
367 z[to++] = z[from++];
368 }
369 }
370
371 // Look for the non-standard microsoft characters between 0x80 and 0x9f
372 // and translate them into printable ASCII codes. Separate algorithms
373 // are required to do this for plain ascii and for utf-8.
374
375 } else if (((unsigned char) z[from]) >= 0x80 &&
376 ((unsigned char) z[from]) < 0xa0) {
377 z[to++] = gAcMsChar[z[from++] & 0x1f];
378 } else {
379 z[to++] = z[from++];
380 }
381 }
382 z[to] = 0;
383}
384
385/******************* End Escape Sequence Translator ***************/
386
387/******************* Begin HTML tokenizer code *******************/
388
389// The following variable becomes TRUE when the markup hash table
390// (stored in HtmlMarkupMap[]) is initialized.
391
392static int gIsInit = 0;
393
394// The hash table for HTML markup names.
395//
396// If an HTML markup name hashes to H, then gApMap[H] will point to
397// a linked list of sgMap structure, one of which will describe the
398// the particular markup (if it exists.)
399
401
402// Hash a markup name
403//
404// HTML markup is case insensitive, so this function will give the
405// same hash regardless of the case of the markup name.
406//
407// The value returned is an integer between 0 and HTML_MARKUP_HASH_SIZE-1,
408// inclusive.
409
410static int HtmlHash(const char *zName) {
411 int h = 0;
412 char c;
413
414 while ((c = *zName) != 0) {
415 if (isupper(c)) { // do we have to check for this??????
416 c = tolower(c);
417 }
418 h = h<<5 ^ h ^ c;
419 zName++;
420 }
421 if (h < 0) {
422 h = -h;
423 }
424
425 return h % HTML_MARKUP_HASH_SIZE;
426}
427
428
429#ifdef TEST
430// Compute the longest and average collision chain length for the
431// markup hash table
432
433static void HtmlHashStats() {
434 int i;
435 int sum = 0;
436 int max = 0;
437 int cnt;
438 int notempty = 0;
439 struct sgMap *p;
440
441 for (i = 0; i < HTML_MARKUP_COUNT; i++) {
442 cnt = 0;
443 p = gApMap[i];
444 if (p) notempty++;
445 while (p) {
446 cnt++;
447 p = p->fPCollide;
448 }
449 sum += cnt;
450 if (cnt > max) max = cnt;
451 }
452
453 printf("longest chain=%d avg=%g slots=%d empty=%d (%g%%)\n",
454 max, (double)sum/(double)notempty, i, i-notempty,
455 100.0*(i-notempty)/(double)i);
456}
457#endif
458
459
460// Initialize the escape sequence hash table
461
462static void HtmlHashInit(void){
463 int i;
464 int h; // The hash on a markup name
465
466 for (i = 0; i < HTML_MARKUP_COUNT; i++) {
467 h = HtmlHash(HtmlMarkupMap[i].fZName);
469 gApMap[h] = &HtmlMarkupMap[i];
470 }
471#ifdef TEST
473#endif
474}
475
476////////////////////////////////////////////////////////////////////////////////
477/// Append the given TGHtmlElement to the tokenizers list of elements
478
480{
481 pElem->fPNext = 0;
482 pElem->fPPrev = fPLast;
483 if (fPFirst == 0) {
484 fPFirst = pElem;
485 } else {
487 }
488 fPLast = pElem;
489 fNToken++;
490}
491
492////////////////////////////////////////////////////////////////////////////////
493/// Insert token pNew before token p
494
496{
497 if (offs < 0) {
498 if (p) {
499 offs = p->fOffs;
500 } else {
501 offs = fNText;
502 }
503 }
504
505////if (p) { pNew->fStyle = p->fStyle; pNew->fFlags = p->fFlags; }
506
507// pNew->fCount = 0;
508 pNew->fOffs = offs;
509 pNew->fPNext = p;
510 if (p) {
511 pNew->fElId = p->fElId;
512 p->fElId = ++fIdind;
513 pNew->fPPrev = p->fPPrev;
514 if (p->fPPrev) p->fPPrev->fPNext = pNew;
515 if (fPFirst == p) fPFirst = pNew;
516 p->fPPrev = pNew;
517 } else {
518 pNew->fElId = ++fIdind;
520 }
521 fNToken++;
522}
523
524////////////////////////////////////////////////////////////////////////////////
525/// Compute the new column index following the given character.
526
527static int NextColumn(int iCol, char c)
528{
529 switch (c) {
530 case '\n': return 0;
531 case '\t': return (iCol | 7) + 1;
532 default: return iCol+1;
533 }
534 /* NOT REACHED */
535}
536
537////////////////////////////////////////////////////////////////////////////////
538/// Convert a string to all lower-case letters.
539
540void ToLower(char *z)
541{
542 while (*z) {
543 if (isupper(*z)) *z = tolower(*z);
544 z++;
545 }
546}
547
548////////////////////////////////////////////////////////////////////////////////
549/// Process as much of the input HTML as possible. Construct new
550/// TGHtmlElement objects and appended them to the list. Return
551/// the number of characters actually processed.
552///
553/// This routine may invoke a callback procedure which could delete
554/// the HTML widget.
555///
556/// This routine is not reentrant for the same HTML widget. To
557/// prevent reentrancy (during a callback), the p->fICol field is
558/// set to a negative number. This is a flag to future invocations
559/// not to reentry this routine. The p->fICol field is restored
560/// before exiting, of course.
561
563{
564 char *z; // The input HTML text
565 int c; // The next character of input
566 int n; // Number of characters processed so far
567 int inpCol; // Column of input
568 int i, j; // Loop counters
569 int h; // Result from HtmlHash()
570 TGHtmlElement *pElem;// A new HTML element
571 int selfClose; // True for content free elements. Ex: <br/>
572 int argc; // The number of arguments on a markup
573 SHtmlTokenMap_t *pMap; // For searching the markup name hash table
574# define mxARG 200 // Maximum number of parameters in a single markup
575 char *argv[mxARG]; // Pointers to each markup argument.
576 int arglen[mxARG]; // Length of each markup argument
577 //int rl, ol;
578#ifdef pIsInMeachnism
579 int pIsInScript = 0;
580 int pIsInNoScript = 0;
581 int pIsInNoFrames = 0;
582#endif
583 int inLi = 0;
584
585 static char null[1] = { "" };
586
587 inpCol = fICol;
588 n = fNComplete;
589 z = fZText;
590 if (inpCol < 0) return n; // Prevents recursion
591 fICol = -1;
592 pElem = 0;
593
594 while ((c = z[n]) != 0) {
595
596 if (c == -64 && z[n+1] == -128) {
597 n += 2;
598 continue;
599 }
600
601 if (fPScript) {
602
603 // We are in the middle of <SCRIPT>...</SCRIPT>. Just look for
604 // the </SCRIPT> markup. (later:) Treat <STYLE>...</STYLE> the
605 // same way.
606
608 const char *zEnd;
609 int nEnd;
610 //int curline, curch, curlast = n;
611 int sqcnt;
612 if (pScr->fType == Html_SCRIPT) {
613 zEnd = "</script>";
614 nEnd = 9;
615 } else if (pScr->fType == Html_NOSCRIPT) {
616 zEnd = "</noscript>";
617 nEnd = 11;
618 } else if (pScr->fType == Html_NOFRAMES) {
619 zEnd = "</noframes>";
620 nEnd = 11;
621 } else {
622 zEnd = "</style>";
623 nEnd = 8;
624 }
625 if (pScr->fNStart < 0) {
626 pScr->fNStart = n;
627 pScr->fNScript = 0;
628 }
629 sqcnt = 0;
630 for (i = n /*pScr->fNStart + pScr->fNScript*/; z[i]; i++) {
631 if (z[i] == '\'' || z[i] == '"') {
632 sqcnt++; // Skip if odd # quotes
633 } else if (z[i] == '\n') {
634 sqcnt = 0;
635 }
636 if (z[i] == '<' && z[i+1] == '/' &&
637 strncasecmp(&z[i], zEnd, nEnd) == 0) {
638 if (zEnd[3] == 'c' && ((sqcnt % 2) == 1)) continue;
639 pScr->fNScript = i - n;
640 fPScript = 0;
641 n = i + nEnd;
642 break;
643 }
644 }
645 if (z[i] == 0) goto incomplete;
646 if (fPScript) {
647 pScr->fNScript = i - n;
648 n = i;
649 }
650 else {
651#ifdef pIsInMeachnism
652 // If there is a script, execute it now and insert any output
653 // to the html stream for parsing as html. (ie. client side scripting)
654
656
657 //for (curch = 0, curline = 1; curch <= curlast; curch++)
658 // if (z[curch] == '\n') curline++;
659
660 // arglist in pElem and text pointers in pScr?
661 // Inline scripts can contain unmatched brackets :-)
662 //char varind[50];
663 //sprintf(varind, "HtmlScrVar%d", p->varind++);
664 //char savech = fZText[pScr->fNStart + pScr->fNScript];
665 //fZText[pScr->fNStart + pScr->fNScript] = 0;
666 //char *scriptBody = StrDup(fZText[pScr->fNStart]);
667 //fZText[pScr->fNStart + pScr->fNScript] = savech;
669 inParse++;
670 char *result = ProcessScript((TGHtmlScript *) pElem); // pElem or pScr??
671 inParse--;
672 if (result) {
673 ol = fNAlloc;
674 rl = strlen(result);
675 fNAlloc += rl;
676 z = fZText = HtmlRealloc(z, ol+rl);
677 memmove(z + n + rl, z+n, ol - n);
678 memmove(z + n, result, rl);
679 }
680 }
681 pIsInScript = 0;
682 pIsInNoScript = 0;
683 pIsInNoFrames = 0;
684#endif
685 }
686 //continue;
687
688 }
689 else if (isspace((unsigned char)c)) {
690
691 // White space
692 for (i = 0;
693 (c = z[n+i]) != 0 && isspace((unsigned char)c) && c != '\n' && c != '\r';
694 i++) { }
695 if (c == '\r' && z[n+i+1] == '\n') ++i;
697 if (pElem == 0) goto incomplete;
698 ((TGHtmlSpaceElement *)pElem)->fW = 0;
699 pElem->fOffs = n;
700 pElem->fElId = ++fIdind;
701 if (c == '\n' || c == '\r') {
702 pElem->fFlags = HTML_NewLine;
703 pElem->fCount = 1;
704 i++;
705 inpCol = 0;
706 } else {
707 int iColStart = inpCol;
708 pElem->fFlags = 0;
709 for (j = 0; j < i; j++) {
710 inpCol = NextColumn(inpCol, z[n+j]);
711 }
712 pElem->fCount = inpCol - iColStart;
713 }
715 n += i;
716
717 }
718 else if (c != '<' || fIPlaintext != 0 ||
719 (!isalpha(z[n+1]) && z[n+1] != '/' && z[n+1] != '!' && z[n+1] != '?')) {
720
721 // Ordinary text
722 for (i = 1; (c = z[n+i]) != 0 && !isspace((unsigned char)c) && c != '<'; i++) {}
723 if (c == 0) goto incomplete;
724 if (fIPlaintext != 0 && z[n] == '<') {
725 switch (fIPlaintext) {
726 case Html_LISTING:
727 if (i >= 10 && strncasecmp(&z[n], "</listing>", 10) == 0) {
728 fIPlaintext = 0;
729 goto doMarkup;
730 }
731 break;
732
733 case Html_XMP:
734 if (i >= 6 && strncasecmp(&z[n], "</xmp>", 6) == 0) {
735 fIPlaintext = 0;
736 goto doMarkup;
737 }
738 break;
739
740 case Html_TEXTAREA:
741 if (i >= 11 && strncasecmp(&z[n], "</textarea>", 11) == 0) {
742 fIPlaintext = 0;
743 goto doMarkup;
744 }
745 break;
746
747 default:
748 break;
749 }
750 }
751 pElem = new TGHtmlTextElement(i);
752 if (pElem == 0) goto incomplete;
754 tpElem->fElId = ++fIdind;
755 tpElem->fOffs = n;
756 strncpy(tpElem->fZText, &z[n], i);
757 tpElem->fZText[i] = 0;
759 if (fIPlaintext == 0 || fIPlaintext == Html_TEXTAREA) {
761 }
762 pElem->fCount = (Html_16_t) strlen(tpElem->fZText);
763 n += i;
764 inpCol += i;
765
766 } else if (strncmp(&z[n], "<!--", 4) == 0) {
767
768 // An HTML comment. Just skip it.
769 for (i = 4; z[n+i]; i++) {
770 if (z[n+i] == '-' && strncmp(&z[n+i], "-->", 3) == 0) break;
771 }
772 if (z[n+i] == 0) goto incomplete;
773
774 pElem = new TGHtmlTextElement(i);
775 if (pElem == 0) goto incomplete;
777 tpElem->fType = Html_COMMENT;
778 tpElem->fElId = ++fIdind;
779 tpElem->fOffs = n;
780 strncpy(tpElem->fZText, &z[n+4], i-4);
781 tpElem->fZText[i-4] = 0;
782 tpElem->fCount = 0;
784
786 AppToken(pElem, 0, n+4);
787
788 for (j = 0; j < i+3; j++) {
789 inpCol = NextColumn(inpCol, z[n+j]);
790 }
791 n += i + 3;
792
793 }
794 else {
795
796 // Markup.
797 //
798 // First get the name of the markup
800 argc = 1;
801 argv[0] = &z[n+1];
802 for (i = 1;
803 (c = z[n+i]) != 0 && !isspace((unsigned char)c) && c != '>' && (i < 2 || c != '/');
804 i++) {}
805 arglen[0] = i - 1;
806 if (c == 0) goto incomplete;
807
808 // Now parse up the arguments
809
810 while (isspace((unsigned char)z[n+i])) ++i;
811 while ((c = z[n+i]) != 0 && c != '>' && (c != '/' || z[n+i+1] != '>')) {
812 if (argc > mxARG - 3) argc = mxARG - 3;
813 argv[argc] = &z[n+i];
814 j = 0;
815 while ((c = z[n+i+j]) != 0 && !isspace((unsigned char)c) && c != '>' &&
816 c != '=' && (c != '/' || z[n+i+j+1] != '>')) ++j;
817 arglen[argc] = j;
818 if (c == 0) goto incomplete;
819 i += j;
820 while (isspace((unsigned char)c)) {
821 i++;
822 c = z[n+i];
823 }
824 if (c == 0) goto incomplete;
825 argc++;
826 if (c != '=') {
827 argv[argc] = null;
828 arglen[argc] = 0;
829 argc++;
830 continue;
831 }
832 i++;
833 c = z[n+i];
834 while (isspace((unsigned char)c)) {
835 i++;
836 c = z[n+i];
837 }
838 if (c == 0) goto incomplete;
839 if (c == '\'' || c == '"') {
840 int cQuote = c;
841 i++;
842 argv[argc] = &z[n+i];
843 for (j = 0; (c = z[n+i+j]) != 0 && c != cQuote; j++) {}
844 if (c == 0) goto incomplete;
845 arglen[argc] = j;
846 i += j+1;
847 } else {
848 argv[argc] = &z[n+i];
849 for (j = 0; (c = z[n+i+j]) != 0 && !isspace((unsigned char)c) && c != '>'; j++) {}
850 if (c == 0) goto incomplete;
851 arglen[argc] = j;
852 i += j;
853 }
854 argc++;
855 while (isspace(z[n+i])) ++i;
856 }
857 if (c == '/') {
858 i++;
859 c = z[n+i];
860 selfClose = 1;
861 } else {
862 selfClose = 0;
863 }
864 if (c == 0) goto incomplete;
865 for (j = 0; j < i+1; j++) {
866 inpCol = NextColumn(inpCol, z[n+j]);
867 }
868 n += i + 1;
869
870 // Lookup the markup name in the hash table
871
872 if (!gIsInit) {
873 HtmlHashInit();
874 gIsInit = 1;
875 }
876 c = argv[0][arglen[0]];
877 argv[0][arglen[0]] = 0;
878 h = HtmlHash(argv[0]);
879 for (pMap = gApMap[h]; pMap; pMap = pMap->fPCollide) {
880 if (strcasecmp(pMap->fZName, argv[0]) == 0) break;
881 }
882 argv[0][arglen[0]] = c;
883 if (pMap == 0) continue; // Ignore unknown markup
884
886 // Construct a TGHtmlMarkupElement object for this markup.
887
888 pElem = MakeMarkupEntry(pMap->fObjType, pMap->fType, argc, arglen, argv);
889 if (pElem == 0) goto incomplete;
890
891 pElem->fElId = ++fIdind;
892 pElem->fOffs = n;
893
895
896 // The new markup has now been constructed in pElem. But before
897 // appending it to the list, check to see if there is a special
898 // handler for this markup type.
899
900 if (ProcessToken(pElem, pMap->fZName, pMap->fType)) {
901 // delete pElem;
902
903 // Tricky, tricky. The user function might have caused the p->fZText
904 // pointer to change, so renew our copy of that pointer.
905
906 z = fZText;
907 if (z == 0) {
908 n = 0;
909 inpCol = 0;
910 goto incomplete;
911 }
912 continue;
913 }
914
915 // No special handler for this markup. Just append it to the
916 // list of all tokens.
917
919 switch (pMap->fType) {
920 case Html_TABLE:
921 break;
922
923 case Html_PLAINTEXT:
924 case Html_LISTING:
925 case Html_XMP:
926 case Html_TEXTAREA:
927 fIPlaintext = pMap->fType;
928 break;
929
930 case Html_NOFRAMES:
931 if (!fHasFrames) break;
932#ifdef pIsInMeachnism
933 pIsInNoFrames = 1;
934#endif
935 case Html_NOSCRIPT:
936 break;
937 case Html_SCRIPT:
938#ifdef pIsInMeachnism
939 pIsInScript = 1;
940#endif
941 // fallthrough
942 case Html_STYLE:
944 break;
945
946 case Html_LI:
947 if (!fAddEndTags) break;
948 if (inLi) {
950 AppToken(e, pElem, n);
951 } else {
952 inLi = 1;
953 }
954 break;
955
956 case Html_EndLI:
957 inLi=0;
958 break;
959
960 case Html_EndOL:
961 case Html_EndUL:
962 if (!fAddEndTags) break;
963 if (inLi) {
965 AppToken(e, pElem, n);
966 } else {
967 inLi = 0;
968 }
969 break;
970
971 default:
972 break;
973 }
974
975 // If this is self-closing markup (ex: <br/> or <img/>) then
976 // synthesize a closing token.
977
978 if (selfClose && argv[0][0] != '/' &&
979 strcmp(&pMap[1].fZName[1], pMap->fZName) == 0) {
980 selfClose = 0;
981 pMap++;
982 argc = 1;
983 goto makeMarkupEntry;
984 }
985 }
986 }
987
989 fICol = inpCol;
990 ////fPScript = 0;
991
992 return n;
993}
994
995/************************** End HTML Tokenizer Code ***************************/
996
997////////////////////////////////////////////////////////////////////////////////
998/// Make one markup entry.
999
1001 int arglen[], char *argv[])
1002{
1004
1005 switch (objType) {
1006 case O_HtmlCell:
1007 e = new TGHtmlCell(type, argc, arglen, argv);
1008 break;
1009
1010 case O_HtmlTable:
1011 e = new TGHtmlTable(type, argc, arglen, argv);
1012 break;
1013
1014 case O_HtmlRef:
1015 e = new TGHtmlRef(type, argc, arglen, argv);
1016 break;
1017
1018 case O_HtmlLi:
1019 e = new TGHtmlLi(type, argc, arglen, argv);
1020 break;
1021
1022 case O_HtmlListStart:
1024 break;
1025
1026 case O_HtmlImageMarkup:
1028 break;
1029
1030 case O_HtmlInput:
1031 e = new TGHtmlInput(type, argc, arglen, argv);
1032 break;
1033
1034 case O_HtmlForm:
1035 e = new TGHtmlForm(type, argc, arglen, argv);
1036 break;
1037
1038 case O_HtmlHr:
1039 e = new TGHtmlHr(type, argc, arglen, argv);
1040 break;
1041
1042 case O_HtmlAnchor:
1043 e = new TGHtmlAnchor(type, argc, arglen, argv);
1044 break;
1045
1046 case O_HtmlScript:
1047 e = new TGHtmlScript(type, argc, arglen, argv);
1048 break;
1049
1050 case O_HtmlMapArea:
1051 e = new TGHtmlMapArea(type, argc, arglen, argv);
1052 break;
1053
1054 default:
1056 break;
1057 }
1058
1059 return e;
1060}
1061
1062////////////////////////////////////////////////////////////////////////////////
1063/// Append text to the tokenizer engine.
1064
1066{
1067 int len = strlen(text);
1068
1069 if (fNText == 0) {
1070 fNAlloc = len + 100;
1071 fZText = new char [fNAlloc];
1072 } else if (fNText + len >= fNAlloc) {
1073 fNAlloc += len + 100;
1074 char *tmp = new char[fNAlloc];
1076 delete[] fZText;
1077 fZText = tmp;
1078 }
1079
1080 if (fZText == 0) {
1081 fNText = 0;
1082 UNTESTED;
1083 return;
1084 }
1085
1087 fNText += len;
1088 fNComplete = Tokenize();
1089}
1090
1091////////////////////////////////////////////////////////////////////////////////
1092/// This routine takes a text representation of a token, converts it into an
1093/// TGHtmlElement object and inserts it immediately prior to pToken. If pToken
1094/// is 0, then the newly created TGHtmlElement is appended.
1095///
1096/// This routine does nothing to resize, restyle, relayout or redisplay
1097/// the HTML. That is the calling routines responsibility.
1098///
1099/// Return the new TGHtmlElement object if successful. Return zero if
1100/// zType is not a known markup name.
1101///
1102/// pToken - Insert before this. Append if pToken == 0
1103/// zType - Type of markup. Ex: "/a" or "table"
1104/// zArgs - List of arguments
1105/// offs - Calculate offset, and insert changed text into fZText!
1106
1108 char *zType, char *zArgs, int offs)
1109{
1110 SHtmlTokenMap_t *pMap; // For searching the markup name hash table
1111 int h; // The hash on zType
1112 TGHtmlElement *pElem; // The new element
1113 //int nByte; // How many bytes to allocate
1114 //int i; // Loop counter
1115
1116 if (!gIsInit) {
1117 HtmlHashInit();
1118 gIsInit = 1;
1119 }
1120
1121 if (strcmp(zType, "Text") == 0) {
1123 if (pElem == 0) return 0;
1124 if (zArgs) {
1125 // coverity[secure_coding]
1126 strcpy (((TGHtmlTextElement *)pElem)->fZText, zArgs); // NOLINT
1127 pElem->fCount = (Html_16_t) strlen(zArgs);
1128 }
1129 } else if (!strcmp(zType, "Space")) {
1130 pElem = new TGHtmlSpaceElement();
1131 if (pElem == 0) return 0;
1132 } else {
1133 h = HtmlHash(zType);
1134 for (pMap = gApMap[h]; pMap; pMap = pMap->fPCollide) {
1135 if (strcasecmp(pMap->fZName, zType) == 0) break;
1136 }
1137 if (pMap == 0) return 0;
1138 if (zArgs == 0 || *zArgs == 0) {
1139 // Special case of no arguments. This is a lot easier...
1140 // well... now its the same thing!
1141 pElem = MakeMarkupEntry(pMap->fObjType, pMap->fType, 1, 0, 0);
1142 if (pElem == 0) return 0;
1143 } else {
1144 // The general case. There are arguments that need to be parsed
1145 // up. This is slower, but we gotta do it.
1146 //int argc;
1147 //char **argv;
1148 //char *zBuf;
1149
1150#if 0
1151 if (!SplitList(zArgs, &argc, &argv)) return 0;
1152
1153 // shall we insert a dummy argv[0]?
1154
1155 pElem = MakeMarkupEntry(pMap->fObjType, pMap->fType, argc/*+1??*/, 0, argv);
1156 if (pElem == 0) return 1;
1157
1158 while (--argc >= 0) if (argv[argc]) delete[] argv[argc];
1159 delete[] argv;
1160#else
1161 return 0;
1162#endif
1163 }
1164 }
1165
1166 pElem->fElId = ++fIdind;
1167
1169
1170 return pElem;
1171}
1172
1173////////////////////////////////////////////////////////////////////////////////
1174/// Insert text into text token, or break token into two text tokens.
1175/// Also, handle backspace char by deleting text.
1176/// Should also handle newline char by splitting text.
1177
1178int TGHtml::TextInsertCmd(int /*argc*/, char ** /*argv*/)
1179{
1180#if 0
1182 int i, l, n = 0;
1183 int idx = 0;
1184 int ptyp = Html_Unknown;
1185 int istxt = 0;
1186 char *cp = 0, c, *cp2;
1187
1188 if (GetIndex(argv[3], &p, &i) != 0) {
1189 // sprintf(tmp, "malformed index: \"%s\"", argv[3]);
1190 return 0;
1191 }
1192 if (p) {
1193 ptyp = p->fType;
1194 if ((istxt = (ptyp == Html_Text))) {
1195 l = p->fCount;
1196 cp = ((TGHtmlTextElement *)p)->fZText;
1197 }
1198 }
1199 if (argv[2][0] == 'b') { // Break text token into two.
1200 if (!istxt) return 1;
1201 if (i == 0 || i == l) return 1;
1202 pElem = InsertToken(p->fPNext, "Text", cp + i, -1);
1203 cp[i] = 0;
1204 p->fCount = i;
1205 return 1;
1206 }
1207 c = argv[4][0];
1208 if (!c) return 1;
1209 if (c == '\b') {
1210 if ((!istxt) || (!l) || (!i)) {
1211 if (!p) return 1;
1212 if (p->fType == Html_BR)
1213 RemoveElements(p, p);
1214 return 1;
1215 }
1216 if (p && l == 1) {
1217 RemoveElements(p, p);
1218 return 1;
1219 }
1220 if (i == l)
1221 cp[p->fCount] = 0;
1222 else
1223 memcpy(cp+i-1, cp+i, l-i+1);
1224
1225 cp[--p->fCount] = 0;
1226 if (ins.i-- <= 0) ins.i = 0;
1227 ins.p = p;
1228 return 1;
1229 }
1230 if (c == '\n' || c == '\r') {
1231 }
1232 if (istxt) {
1233 char *cp;
1234 int t, j, alen = strlen(argv[4]);
1235 n = alen + l;
1236
1238
1239 if (text->fZText == (char*) ((&text->fZText)+1)) {
1240 cp = new char[n+1];
1241 strcpy(cp, text->fZText);
1242 } else {
1243 cp = new char[n+1];
1244 strcpy(cp, text->fZText);
1245 }
1246 cp2 = new char[alen+1];
1247 memcpy(cp2, argv[4], alen+1);
1249 alen = strlen(cp2);
1250 memmove(cp+alen+i, cp+i, l-i+1);
1251 for (j = 0; j < alen; j++) cp[i+j] = cp2[j];
1252 delete[] cp2;
1253 delete[] text->fZText;
1254 text->fZText = cp;
1255 p->fCount = strlen(cp);
1256 ins.p = p;
1257 ins.i = i+alen;
1258 } else {
1259 p = InsertToken(p ? p->fPNext : 0, "Text", argv[4], -1);
1260 AddStyle(p);
1261 i = 0;
1262 ins.p = p;
1263 ins.i = 1;
1264 }
1265 if (p) {
1266 idx = p->base.id;
1267 AddStrOffset(p, argv[4], i);
1268 }
1269#endif
1270 return 1;
1271}
1272
1273////////////////////////////////////////////////////////////////////////////////
1274/// Returns token map matching zType name.
1275
1277{
1278 SHtmlTokenMap_t *pMap; // For searching the markup name hash table
1279 int h; // The hash on zType
1280
1281 if (!gIsInit) {
1282 HtmlHashInit();
1283 gIsInit = 1;
1284 }
1285 h = HtmlHash(zType);
1286 for (pMap = gApMap[h]; pMap; pMap = pMap->fPCollide) {
1287 if (strcasecmp(pMap->fZName, zType) == 0) break;
1288 }
1289
1290 return pMap;
1291}
1292
1293////////////////////////////////////////////////////////////////////////////////
1294/// Convert a markup name into a type integer
1295
1297{
1299 return pMap ? pMap->fType : (int)Html_Unknown;
1300}
1301
1302////////////////////////////////////////////////////////////////////////////////
1303/// Convert a type into a symbolic name
1304
1305const char *TGHtml::TypeToName(int type)
1306{
1307 if (type >= Html_A && type <= Html_EndXMP) {
1309 return pMap->fZName;
1310 } else {
1311 return "???";
1312 }
1313}
1314
1315////////////////////////////////////////////////////////////////////////////////
1316/// For debugging purposes, print information about a token
1317
1319{
1320//#ifdef DEBUG
1321 static char zBuf[200];
1322 int j;
1323 const char *zName;
1324
1325 if (p == 0) {
1326 snprintf(zBuf, 200, "NULL");
1327 return zBuf;
1328 }
1329 switch (p->fType) {
1330 case Html_Text:
1331 snprintf(zBuf, 200, "text: \"%.*s\"", p->fCount, ((TGHtmlTextElement *)p)->fZText);
1332 break;
1333
1334 case Html_Space:
1335 if (p->fFlags & HTML_NewLine) {
1336 snprintf(zBuf, 200, "space: \"\\n\"");
1337 } else {
1338 snprintf(zBuf, 200, "space: \" \"");
1339 }
1340 break;
1341
1342 case Html_Block: {
1344 if (block->fN > 0) {
1345 int n = block->fN;
1346 if (n > 150) n = 150;
1347 snprintf(zBuf, 200, "<Block z=\"%.*s\">", n, block->fZ);
1348 } else {
1349 snprintf(zBuf, 200, "<Block>");
1350 }
1351 break;
1352 }
1353
1354 default:
1355 if (p->fType >= HtmlMarkupMap[0].fType
1356 && p->fType <= HtmlMarkupMap[HTML_MARKUP_COUNT-1].fType) {
1358 } else {
1359 zName = "Unknown";
1360 }
1361 snprintf(zBuf, 200, "markup (%d) <%s", p->fType, zName);
1362 for (j = 1 ; j < p->fCount; j += 2) {
1363 snprintf(&zBuf[strlen(zBuf)], 200-strlen(zBuf), " %s=\"%s\"",
1364 ((TGHtmlMarkupElement *)p)->fArgv[j-1],
1365 ((TGHtmlMarkupElement *)p)->fArgv[j]);
1366 }
1367 // coverity[secure_coding]
1368 strlcat(zBuf, ">", sizeof(zBuf));
1369 break;
1370 }
1371 return zBuf;
1372//#else
1373// return 0;
1374//#endif
1375}
1376
1377////////////////////////////////////////////////////////////////////////////////
1378/// Append all the arguments of the given markup to the given TGString.
1379///
1380/// Example: If the markup is <IMG SRC=image.gif ALT="hello!">
1381/// then the following text is appended to the TGString:
1382///
1383/// "src image.gif alt hello!"
1384///
1385/// Notice how all attribute names are converted to lower case.
1386/// This conversion happens in the parser.
1387
1389{
1390 int i;
1391
1392 for (i = 0; i + 1 < pElem->fCount; i += 2) {
1393 str->Append(pElem->fArgv[i]);
1394 str->Append("=");
1395 str->Append(pElem->fArgv[i+1]);
1396 str->Append(" ");
1397 }
1398}
1399
1400////////////////////////////////////////////////////////////////////////////////
1401/// Returns token name of html element p.
1402
1404{
1405 static char zBuf[200];
1406 //int j;
1407 const char *zName;
1408
1409 zBuf[0] = 0;
1410 if (p == 0) {
1411 // coverity[secure_coding]: zBuf is large enough
1412 strcpy(zBuf, "NULL");
1413 return zBuf;
1414 }
1415 switch (p->fType) {
1416 case Html_Text:
1417 case Html_Space:
1418 break;
1419
1420 case Html_Block:
1421 break;
1422
1423 default:
1424 if (p->fType >= HtmlMarkupMap[0].fType &&
1425 p->fType <= HtmlMarkupMap[HTML_MARKUP_COUNT-1].fType) {
1427 } else {
1428 zName = "Unknown";
1429 }
1430 strlcpy(zBuf, zName, sizeof(zBuf));
1431 break;
1432 }
1433
1434 return zBuf;
1435}
1436
1437////////////////////////////////////////////////////////////////////////////////
1438/// Returns token map at location n.
1439
1444
1445////////////////////////////////////////////////////////////////////////////////
1446/// Return all tokens between the two elements as a string list.
1447
1449{
1450 TGString *str;
1451 int i;
1452 const char *zName;
1453 char zLine[100];
1454
1455 str = new TGString("");
1456 while (p && p != pEnd) {
1457 switch (p->fType) {
1458 case Html_Block:
1459 break;
1460
1461 case Html_Text:
1462 str->Append("{ Text \"");
1463 str->Append(((TGHtmlTextElement *)p)->fZText);
1464 str->Append("\" } ");
1465 break;
1466
1467 case Html_Space:
1468 snprintf(zLine, 100, "Space %d %d ",
1469 p->fCount, (p->fFlags & HTML_NewLine) != 0);
1470 str->Append(zLine);
1471 break;
1472
1473 case Html_Unknown:
1474 str->Append("Unknown ");
1475 break;
1476
1477 default:
1478 str->Append("{ Markup ");
1479 if (p->fType >= HtmlMarkupMap[0].fType &&
1480 p->fType <= HtmlMarkupMap[HTML_MARKUP_COUNT-1].fType) {
1482 } else {
1483 zName = "Unknown";
1484 }
1485 str->Append(zName);
1486 str->Append(" ");
1487 for (i = 0; i < p->fCount; ++i) {
1488 str->Append(((TGHtmlMarkupElement *)p)->fArgv[i]);
1489 str->Append(" ");
1490 }
1491 str->Append("} ");
1492 break;
1493 }
1494 p = p->fPNext;
1495 }
1496
1497 return str;
1498}
1499
1500////////////////////////////////////////////////////////////////////////////////
1501/// Print a list of tokens
1502
1504{
1506
1507 for (p = first; p != last; p = p->fPNext) {
1508 if (p->fType == Html_Block) {
1510 const char *z = block->fZ;
1511 int n = block->fN;
1512 if (n == 0 || z == 0) {
1513 n = 1;
1514 z = "";
1515 }
1516 printf("Block flags=%02x cnt=%d x=%d..%d y=%d..%d z=\"%.*s\"\n",
1517 p->fFlags, p->fCount, block->fLeft, block->fRight,
1518 block->fTop, block->fBottom, n, z);
1519 } else {
1520 printf("Token font=%2d color=%2d align=%d flags=0x%04x name=%s\n",
1521 p->fStyle.fFont, p->fStyle.fColor,
1522 p->fStyle.fAlign, p->fStyle.fFlags, DumpToken(p));
1523 }
1524 }
1525}
#define c(i)
Definition RSha256.hxx:101
#define h(i)
Definition RSha256.hxx:106
#define e(i)
Definition RSha256.hxx:103
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void HtmlTranslateEscapes(char *z)
Translate escape sequences in the string "z".
void ToLower(char *z)
Convert a string to all lower-case letters.
static int EscHash(const char *zName)
static int HtmlHash(const char *zName)
static char gAcMsChar[]
static int gIsInit
static int NextColumn(int iCol, char c)
Compute the new column index following the given character.
static SHtmlTokenMap_t * gApMap[HTML_MARKUP_HASH_SIZE]
void HtmlTranslateEscapes(char *z)
Translate escape sequences in the string "z".
SHtmlTokenMap_t HtmlMarkupMap[]
static struct SgEsc_t gEscSequences[]
#define mxARG
static void HtmlHashInit(void)
static struct SgEsc_t * gApEscHash[(sizeof(gEscSequences)/sizeof(gEscSequences[0])+7)]
#define ESC_HASH_SIZE
static void EscInit()
@ Html_COMMENT
@ Html_TEXTAREA
@ Html_XMP
@ Html_STYLE
@ Html_SCRIPT
@ Html_LI
@ Html_LISTING
@ Html_TABLE
@ Html_EndUL
@ Html_EndOL
@ Html_NOFRAMES
@ Html_PLAINTEXT
@ Html_Block
@ Html_Space
@ Html_Text
@ Html_A
@ Html_NOSCRIPT
@ Html_EndLI
@ Html_EndXMP
@ Html_BR
@ Html_Unknown
@ Html_EndCOMMENT
#define HTML_MARKUP_HASH_SIZE
#define HTML_MARKUP_COUNT
#define O_HtmlInput
Definition TGHtml.h:858
#define O_HtmlHr
Definition TGHtml.h:860
#define O_HtmlTable
Definition TGHtml.h:853
#define UNTESTED
Definition TGHtml.h:65
#define HTML_NewLine
Definition TGHtml.h:276
#define O_HtmlImageMarkup
Definition TGHtml.h:857
short Html_16_t
Definition TGHtml.h:137
#define O_HtmlAnchor
Definition TGHtml.h:861
#define O_HtmlLi
Definition TGHtml.h:855
#define O_HtmlMapArea
Definition TGHtml.h:863
#define O_HtmlRef
Definition TGHtml.h:854
#define O_HtmlCell
Definition TGHtml.h:852
#define O_HtmlScript
Definition TGHtml.h:862
#define O_HtmlListStart
Definition TGHtml.h:856
#define O_HtmlForm
Definition TGHtml.h:859
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Option_t Option_t TPoint TPoint const char text
TGHtmlElement * fPNext
Definition TGHtml.h:262
Html_16_t fW
Definition TGHtml.h:309
int fAddEndTags
Definition TGHtml.h:1254
TGString * ListTokens(TGHtmlElement *p, TGHtmlElement *pEnd)
Return all tokens between the two elements as a string list.
int fICol
Definition TGHtml.h:1181
void AppToken(TGHtmlElement *pNew, TGHtmlElement *p, int offs)
Insert token pNew before token p.
int fIdind
Definition TGHtml.h:1279
int TextInsertCmd(int argc, char **argv)
Insert text into text token, or break token into two text tokens.
void TokenizerAppend(const char *text)
Append text to the tokenizer engine.
TGHtmlElement * fPFirst
Definition TGHtml.h:1136
void AddStyle(TGHtmlElement *p)
This routine adds information to the input texts that doesn't change when the display is resized or w...
virtual char * ProcessScript(TGHtmlScript *)
Definition TGHtml.h:958
int fNToken
Definition TGHtml.h:1138
TGHtmlElement * InsertToken(TGHtmlElement *pToken, char *zType, char *zArgs, int offs)
This routine takes a text representation of a token, converts it into an TGHtmlElement object and ins...
const char * TypeToName(int type)
Convert a type into a symbolic name.
int Tokenize()
Process as much of the input HTML as possible.
int NameToType(char *zType)
Convert a markup name into a type integer.
int fIPlaintext
Definition TGHtml.h:1183
void AppendArglist(TGString *str, TGHtmlMarkupElement *pElem)
Append all the arguments of the given markup to the given TGString.
char * fZText
Definition TGHtml.h:1176
int fNAlloc
Definition TGHtml.h:1178
void AppendElement(TGHtmlElement *pElem)
Append the given TGHtmlElement to the tokenizers list of elements.
virtual int ProcessToken(TGHtmlElement *, const char *, int)
Definition TGHtml.h:928
TGHtmlScript * fPScript
Definition TGHtml.h:1187
int fHasFrames
Definition TGHtml.h:1253
TGHtmlMarkupElement * MakeMarkupEntry(int objType, int type, int argc, int arglen[], char *argv[])
Make one markup entry.
TGHtmlElement * fPLast
Definition TGHtml.h:1137
SHtmlTokenMap_t * GetMarkupMap(int n)
Returns token map at location n.
int fNComplete
Definition TGHtml.h:1179
SHtmlTokenMap_t * NameToPmap(char *zType)
Returns token map matching zType name.
char * DumpToken(TGHtmlElement *p)
For debugging purposes, print information about a token.
char * GetTokenName(TGHtmlElement *p)
Returns token name of html element p.
int GetIndex(const char *zIndex, TGHtmlElement **ppToken, int *pIndex)
This routine decodes a complete index specification.
void PrintList(TGHtmlElement *first, TGHtmlElement *last)
Print a list of tokens.
void AddFormInfo(TGHtmlElement *p)
Add the DOM control information for form elements.
int fNText
Definition TGHtml.h:1177
TGString wraps a TString and adds some graphics routines like drawing, size of string on screen depen...
Definition TGString.h:20
const Int_t n
Definition legend1.C:16
const char * cnt
Definition TXMLSetup.cxx:74
Html_16_t fType
Definition TGHtml.h:842
SHtmlTokenMap_t * fPCollide
Definition TGHtml.h:844
const char * fZName
Definition TGHtml.h:841
char fValue[8]
SgEsc_t * fPNext
const char * fZName
TLine l
Definition textangle.C:4
static uint64_t sum(uint64_t i)
Definition Factory.cxx:2335