Check-in [13dc246a99]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Minor changes to javascript debugger. (CVS 1271)
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:13dc246a992511b432144b49274fe4c1fb3b9afe
User & Date: danielk1977 2008-03-02 14:43:49
Context
2008-03-02
15:00
Modifications so that the hv3 widget is easier to use. (CVS 1272) check-in: a6021ce249 user: danielk1977 tags: trunk
14:43
Minor changes to javascript debugger. (CVS 1271) check-in: 13dc246a99 user: danielk1977 tags: trunk
2008-02-16
06:04
Add a comment header to hv3bridge.c. (CVS 1270) check-in: 4488d01cb1 user: danielk1977 tags: trunk
Changes

Changes to hv/README.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113

Widget Wrappers
---------------

    ::hv3::scrolledwidget
    ::hv3::toolbutton

    ::hv3::scrollbar
    ::hv3::button
    ::hv3::entry
    ::hv3::text
    ::hv3::label
    ::hv3::toolbutton
  


OBJECTS
-------

Hv3 Mega-Widget Object Types:

  Widgets:

    ::hv3::hv3                   (hv3.tcl)
        Reusable mega-widget built on top of Tkhtml. There is no man-page
        yet, but the widget interface is described at the top of the
        file hv3.tcl.

    
    ::hv3::tclet                 (hv3_object.tcl)
        A widget containing a Tcl applet running in a safe interpreter.
        Widget's of this type are used as replacement objects for Tkhtml
        nodes whenever a Tclet specified as an <object> or <embed> tag
        is encountered.
    
    ::hv3::control               (hv3_form.tcl)
        A widget class for form controls. This is used as the replacement
        object for <input>, <select>, <textarea>, <isindex> and <button>
        element nodes.

    ::hv3::fileselect            (hv3_form.tcl)
        Used (and encapsulated) by ::hv3::control to implement
        <input type=file> controls.
 
    ::hv3::filedownloader        (hv3_http.tcl)
        This widget implements the file-downloading dialog (i.e. the thing
        with the progress bar and Ok/Cancel button).

    ::hv3::findwidget            (hv3_widgets.tcl)
        This widget implements logic and gui for the "find text" function. It
        currently uses Tkhtml3 interfaces only (no hv3 interfaces).  
        NOTE: This will have to change to support frameset documents.

  Other Types:

    ::hv3::hv3::selectionmanager (hv3.tcl)
    ::hv3::hv3::dynamicmanager   (hv3.tcl)
    ::hv3::hv3::hyperlinkmanager (hv3.tcl)
        Internal components to manage the selection, dynamic (i.e. :hover)
        effects and hyperlinks, respectively. These are really just used
        to break up the hv3::hv3 a bit. Eventually, each of these (and the
        formmanager) will be optional functions that may be enabled or 
        disabled by hv3 users. TODO: Images too? Should there be an 
        ::hv3::hv3::imagemanager?

    ::hv3::formmanager           (hv3_form.tcl)
    ::hv3::form                  (hv3_form.tcl)

    ::hv3::download              (hv3.tcl)

    ::hv3::uri                   (hv3.tcl)
        Type to extract components from and perform other operations on URIs.

Hv3 Protocol Object Types:

  Other Types:

    ::hv3::protocol              (hv3_http.tcl)
    ::hv3::cookiemanager         (hv3_http.tcl)

Hv3 Application Object Types:

  Widgets:

    ::hv3::frameset              (hv3_frameset.tcl)

    ::hv3::browser_frame         (hv3_main.tcl)

    ::hv3::browser (hv3_main.tcl)
         Instances of this widget are managed directly by the notebook.
         Each instance of this widget creates it's own ::hv3::protocol
         and ::hv3::history objects. It also creates and destroys
         ::hv3::findwidget widgets as requested by the user.

    ::hv3::finddialog            (hv3_widgets.tcl)
        This widget implements the find-text dialog.

  Other Types:

    ::hv3::history               (hv3_main.tcl)

Tree browser:

    HtmlDebug



NOTES ON FRAMES AND TABS
------------------------

  Both frames and tabs are implemented as part of the demo application, not
  Tkhtml or the hv3 mega-widget.


<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
1

































































































































































































































Changes to hv/hv3.tcl.



1

2












3
4
5
6
7
8
9


# This file contains the mega-widget hv3::hv3 used by the hv3 demo web 

# browser. An instance of this widget displays a single HTML frame.












#
# Standard Functionality:
#
#     xview
#     yview
#     -xscrollcommand
#     -yscrollcommand
>
>
|
>
|
>
>
>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
namespace eval hv3 { set {version($Id: hv3.tcl,v 1.247 2008/03/02 14:43:49 danielk1977 Exp $)} 1 }

# This file contains the mega-widget hv3::hv3 that is at the core
# of the Hv3 web browser implementation. An instance of this widget 
# displays a single HTML frame. Documentation for the published
# interface to this widget is found at:
#
#   http://tkhtml.tcl.tk/hv3_widget.html
#
# Other parts of the interface, used internally and by the Hv3
# web-browser, are documented in comments in this file. Eventually,
# the Hv3 web-browser will use the published interface only. But
# that is not the case yet.
#
#-------------------------------------------------------------------
#
# 
#
# Standard Functionality:
#
#     xview
#     yview
#     -xscrollcommand
#     -yscrollcommand

Changes to hv/hv3_debug.tcl.

1
2
3
4
5
6
7
8
...
261
262
263
264
265
266
267








268
269
270
271
272
273
274
...
275
276
277
278
279
280
281

282
283
284
285
286

287
288
289
290
291

292
293
294
295

296
297
298
299
300
301
302
...
304
305
306
307
308
309
310
311
312
313


314
315
316


317
318
319
320
321
322
323
...
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522


523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543

544

545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
...
585
586
587
588
589
590
591

592
593








594
595
596
597
598
599
600
namespace eval hv3 { set {version($Id: hv3_debug.tcl,v 1.16 2008/02/15 18:23:37 danielk1977 Exp $)} 1 }

namespace eval ::hv3 {
  ::snit::widget console {

    # Entry field for typing commands (entry widget):
    variable myEntryField 

................................................................................
        }
      }

      $myOutputWindow yview end
      $myOutputWindow configure -state disabled
    }









    method Display {page pageid} {
      $myCodeViewer configure -state normal -cursor xterm

      $myCodeViewer delete 0.0 end
      foreach tag $myCodeViewerLinks {
        $myCodeViewer tag delete $tag
      }
................................................................................
      set myCodeViewerLinks [list]

      switch -- $page {
        html {
          set hv3 [$pageid hv3]
          $myCodeViewer insert end [$hv3 log get html]
          $myLabel configure -text "HTML Code: [$hv3 uri get]"

        }

        index {
          $self DisplayIndex
          $myLabel configure -text ""

        }

        css {
          eval $self DisplayCss $pageid
          $myLabel configure -text "CSS Code: [lindex $pageid 1]"

        }

        javascript {
          eval $self DisplayJavascript $pageid

        }

        default {error "Internal error - bad page \"$page\""}
      }
      $myCodeViewer configure -state disabled

      set myPage $page
................................................................................
    }

    method CreateCodeViewerLink {text command} {
      set tag "link[expr rand()]"
      lappend myCodeViewerLinks $tag
      $myCodeViewer tag configure $tag -underline 1 -foreground darkblue
      $myCodeViewer tag bind $tag <1> $command
      $myCodeViewer tag bind $tag <Enter> [
          list $myCodeViewer configure -cursor hand2
      ]


      $myCodeViewer tag bind $tag <Leave> [
          list $myCodeViewer configure -cursor xterm
      ]


      $myCodeViewer insert end $text $tag
      return $tag
    }
    method OutputWindowLink {text command} {
      set tag "link[expr rand()]"
      lappend myOutputWindowLinks $tag
      set ow [$myOutputWindow widget]
................................................................................
      $myCodeViewer insert end "${zIndent}Frame: $uri\n"

      # Link for the HTML file.
      #
      $myCodeViewer insert end "${zIndent}  "
      set cmd1 [list $self Display html $frame]
      set cmd2 [list ::HtmlDebug::browse $hv3 [$hv3 node]]
      $self CreateCodeViewerLink "View Html Source" $cmd1
      $myCodeViewer insert end "   "
      $self CreateCodeViewerLink "Open Tree Browser..." $cmd2
      $myCodeViewer insert end "\n"

      # Links for each loaded CSS document.
      #
      foreach css [$hv3 log get css] {
        foreach {id filename data errors} $css break
        $myCodeViewer insert end "${zIndent}  "


        $myCodeViewer insert end "CSS: $filename  "
        if {[llength $errors] > 0} {
            set nErr [expr {[llength $errors]/2}]
            set cmd [list $self Errors css [list $frame $id]]
            set t [$self CreateCodeViewerLink "($nErr parse errors)" $cmd]
            $myCodeViewer tag configure $t -foreground red
            $myCodeViewer insert end "  "
        }
        set cmd [list $self Display css [list $frame $id]]
        $self CreateCodeViewerLink "View Source" $cmd
        $myCodeViewer insert end "\n"
      }

      # Links for each javascript file.
      #
      set dom [$hv3 dom]
      set ii 0
      foreach logscript [$dom GetLog] {
        if {[$logscript cget -isevent]} continue
        incr ii
        set cmd [list $self Display javascript [list $ii $logscript]]

        $myCodeViewer insert end $zIndent

        $myCodeViewer insert end "  Javascript: [$logscript cget -heading]  "
        if {[$logscript cget -rc]} {
          set tag [$self CreateCodeViewerLink "(Failed)" [
              list $self Errors javascript [list $ii $dom $logscript]
          ]]
          $myCodeViewer tag configure $tag -foreground red
          $myCodeViewer insert end "  "
        } else {
          $myCodeViewer insert end "(Ok)  "
        }
        $self CreateCodeViewerLink "View Source" $cmd
        set nLine [llength [split [$logscript cget -script] "\n"]]
        $myCodeViewer insert end " ($nLine lines)\n"
      }

      $myCodeViewer insert end "\n"
      foreach child [$frame child_frames] {
        $self DisplayResources $child [expr {$iIndent+4}]
      }
    }
................................................................................
}

# This [namespace eval] block adds the special commands designed for
# interactive use from the debugging console:
#
#     primitives
#     breakpoints

#
namespace eval ::hv3::console_commands {









  proc primitives {} {
    set zRet ""
    set iIndent 0
    foreach primitive [hv3_html _primitives] {
      set t [lindex $primitive 0]
      if {$t eq "draw_origin_end"} {incr iIndent -4}
|







 







>
>
>
>
>
>
>
>







 







>





>





>




>







 







|
|
<
>
>
|
|
<
>
>







 







|
|








>
>
|







<
<











>
|
>
|

|



<



<
<
|







 







>


>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
...
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
...
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
...
316
317
318
319
320
321
322
323
324

325
326
327
328

329
330
331
332
333
334
335
336
337
...
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546


547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566

567
568
569


570
571
572
573
574
575
576
577
...
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
namespace eval hv3 { set {version($Id: hv3_debug.tcl,v 1.17 2008/03/02 14:43:49 danielk1977 Exp $)} 1 }

namespace eval ::hv3 {
  ::snit::widget console {

    # Entry field for typing commands (entry widget):
    variable myEntryField 

................................................................................
        }
      }

      $myOutputWindow yview end
      $myOutputWindow configure -state disabled
    }

    # This proc is called to display a page in the "code viewer" pane 
    # (the top one). Parameter $page must be one of the following: 
    #
    #     html
    #     index
    #     css
    #     javascript
    #
    method Display {page pageid} {
      $myCodeViewer configure -state normal -cursor xterm

      $myCodeViewer delete 0.0 end
      foreach tag $myCodeViewerLinks {
        $myCodeViewer tag delete $tag
      }
................................................................................
      set myCodeViewerLinks [list]

      switch -- $page {
        html {
          set hv3 [$pageid hv3]
          $myCodeViewer insert end [$hv3 log get html]
          $myLabel configure -text "HTML Code: [$hv3 uri get]"
          $myCodeViewer configure -wrap word
        }

        index {
          $self DisplayIndex
          $myLabel configure -text ""
          $myCodeViewer configure -wrap none
        }

        css {
          eval $self DisplayCss $pageid
          $myLabel configure -text "CSS Code: [lindex $pageid 1]"
          $myCodeViewer configure -wrap word
        }

        javascript {
          eval $self DisplayJavascript $pageid
          $myCodeViewer configure -wrap word
        }

        default {error "Internal error - bad page \"$page\""}
      }
      $myCodeViewer configure -state disabled

      set myPage $page
................................................................................
    }

    method CreateCodeViewerLink {text command} {
      set tag "link[expr rand()]"
      lappend myCodeViewerLinks $tag
      $myCodeViewer tag configure $tag -underline 1 -foreground darkblue
      $myCodeViewer tag bind $tag <1> $command
      $myCodeViewer tag bind $tag <Enter> "
          $myCodeViewer configure -cursor hand2

          $myCodeViewer tag configure $tag -background #d9d9d9
      "
      $myCodeViewer tag bind $tag <Leave> "
          $myCodeViewer configure -cursor xterm

          $myCodeViewer tag configure $tag -background white
      "
      $myCodeViewer insert end $text $tag
      return $tag
    }
    method OutputWindowLink {text command} {
      set tag "link[expr rand()]"
      lappend myOutputWindowLinks $tag
      set ow [$myOutputWindow widget]
................................................................................
      $myCodeViewer insert end "${zIndent}Frame: $uri\n"

      # Link for the HTML file.
      #
      $myCodeViewer insert end "${zIndent}  "
      set cmd1 [list $self Display html $frame]
      set cmd2 [list ::HtmlDebug::browse $hv3 [$hv3 node]]
      $self CreateCodeViewerLink "View Html" $cmd1
      $myCodeViewer insert end "         "
      $self CreateCodeViewerLink "Open Tree Browser..." $cmd2
      $myCodeViewer insert end "\n"

      # Links for each loaded CSS document.
      #
      foreach css [$hv3 log get css] {
        foreach {id filename data errors} $css break
        $myCodeViewer insert end "${zIndent}  "
        set cmd [list $self Display css [list $frame $id]]
        $self CreateCodeViewerLink "View CSS" $cmd
        $myCodeViewer insert end ":         $filename  "
        if {[llength $errors] > 0} {
            set nErr [expr {[llength $errors]/2}]
            set cmd [list $self Errors css [list $frame $id]]
            set t [$self CreateCodeViewerLink "($nErr parse errors)" $cmd]
            $myCodeViewer tag configure $t -foreground red
            $myCodeViewer insert end "  "
        }


        $myCodeViewer insert end "\n"
      }

      # Links for each javascript file.
      #
      set dom [$hv3 dom]
      set ii 0
      foreach logscript [$dom GetLog] {
        if {[$logscript cget -isevent]} continue
        incr ii
        set cmd [list $self Display javascript [list $ii $logscript]]
        set nLine [llength [split [$logscript cget -script] "\n"]]
        $myCodeViewer insert end "$zIndent  "
        $self CreateCodeViewerLink "View Javascript" $cmd
        $myCodeViewer insert end ":  [$logscript cget -heading]  "
        if {[$logscript cget -rc]} {
          set tag [$self CreateCodeViewerLink "(Failed)  " [
              list $self Errors javascript [list $ii $dom $logscript]
          ]]
          $myCodeViewer tag configure $tag -foreground red

        } else {
          $myCodeViewer insert end "(Ok)  "
        }


        $myCodeViewer insert end "($nLine lines)\n"
      }

      $myCodeViewer insert end "\n"
      foreach child [$frame child_frames] {
        $self DisplayResources $child [expr {$iIndent+4}]
      }
    }
................................................................................
}

# This [namespace eval] block adds the special commands designed for
# interactive use from the debugging console:
#
#     primitives
#     breakpoints
#     heapdebug
#
namespace eval ::hv3::console_commands {

  proc help {} {
    return "
      primitives
      breakpoints
      heapdebug
    "
  }

  proc primitives {} {
    set zRet ""
    set iIndent 0
    foreach primitive [hv3_html _primitives] {
      set t [lindex $primitive 0]
      if {$t eq "draw_origin_end"} {incr iIndent -4}

Changes to hv/hv3_main.tcl.

1
2
3
4
5
6
7
8
...
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
namespace eval hv3 { set {version($Id: hv3_main.tcl,v 1.189 2008/02/15 18:54:58 danielk1977 Exp $)} 1 }

catch {memory init on}

proc sourcefile {file} [string map              \
  [list %HV3_DIR% [file dirname [info script]]] \
{ 
  return [file join {%HV3_DIR%} $file] 
................................................................................
    -enableimages     1                         Boolean \
    -enablejavascript 0                         Boolean \
    -forcefontmetrics 1                         Boolean \
    -hidegui          0                         Boolean \
    -zoom             1.0                       Double  \
    -fontscale        1.0                       Double  \
    -guifont          11                        Integer \
    -icons            default_icons             bcons   \
    -debuglevel       0                         Integer \
    -fonttable        [list 8 9 10 11 13 15 17] SevenIntegers \
  ] {
    option $opt -default $def -validatemethod $type -configuremethod SetOption
  }
  
  constructor {db args} {
|







 







|







1
2
3
4
5
6
7
8
...
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
namespace eval hv3 { set {version($Id: hv3_main.tcl,v 1.190 2008/03/02 14:43:49 danielk1977 Exp $)} 1 }

catch {memory init on}

proc sourcefile {file} [string map              \
  [list %HV3_DIR% [file dirname [info script]]] \
{ 
  return [file join {%HV3_DIR%} $file] 
................................................................................
    -enableimages     1                         Boolean \
    -enablejavascript 0                         Boolean \
    -forcefontmetrics 1                         Boolean \
    -hidegui          0                         Boolean \
    -zoom             1.0                       Double  \
    -fontscale        1.0                       Double  \
    -guifont          11                        Integer \
    -icons            default_icons             Icons   \
    -debuglevel       0                         Integer \
    -fonttable        [list 8 9 10 11 13 15 17] SevenIntegers \
  ] {
    option $opt -default $def -validatemethod $type -configuremethod SetOption
  }
  
  constructor {db args} {

Changes to hv/hv3_notebook.tcl.

1
2
3
4
5
6
7
8
...
322
323
324
325
326
327
328
329


330
331
332
333
334
335
336
namespace eval hv3 { set {version($Id: hv3_notebook.tcl,v 1.11 2008/02/15 18:23:37 danielk1977 Exp $)} 1 }

# This file contains the implementation of three snit widgets:
#
#     ::hv3::notebook_header
#     ::hv3::notebook
#     ::hv3::tabset
#
................................................................................
    grid rowconfigure $win 1 -weight 1
    grid propagate $win 0
    grid $myHeader -row 0 -column 0 -sticky ew

    $self configurelist $args
  }

  destructor { }



  # add WIDGET ?TITLE? ?UPDATE?
  # 
  #     Add a new widget to the set of tabbed windows.
  #
  method add {widget {zTitle ""} {update false}} {

|







 







|
>
>







1
2
3
4
5
6
7
8
...
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
namespace eval hv3 { set {version($Id: hv3_notebook.tcl,v 1.12 2008/03/02 14:43:49 danielk1977 Exp $)} 1 }

# This file contains the implementation of three snit widgets:
#
#     ::hv3::notebook_header
#     ::hv3::notebook
#     ::hv3::tabset
#
................................................................................
    grid rowconfigure $win 1 -weight 1
    grid propagate $win 0
    grid $myHeader -row 0 -column 0 -sticky ew

    $self configurelist $args
  }

  destructor {
    after cancel [list event generate $win <<NotebookTabChanged>>]
  }

  # add WIDGET ?TITLE? ?UPDATE?
  # 
  #     Add a new widget to the set of tabbed windows.
  #
  method add {widget {zTitle ""} {update false}} {

Changes to hv/hv3bridge.c.

124
125
126
127
128
129
130
131
132

133
134
135
136
137
138
139
    struct SEE_interpreter *pInterp;
    struct SEE_interpreter *pForiegnInterp;
    SEE_try_context_t *pForiegnTry;
{
    struct SEE_value *pForiegnVal = SEE_CAUGHT(*pForiegnTry);
    if (pForiegnVal) {
        struct SEE_value exception;
        struct SEE_traceback *pTrace;
#if 0

printf("throw: ");
SEE_PrintValue(pForiegnInterp, pForiegnVal, stdout);
printf("\n");
SEE_ToString(pForiegnInterp, pForiegnVal, &exception);
SEE_PrintValue(pForiegnInterp, &exception, stdout);
printf("\n");
#endif







<

>







124
125
126
127
128
129
130

131
132
133
134
135
136
137
138
139
    struct SEE_interpreter *pInterp;
    struct SEE_interpreter *pForiegnInterp;
    SEE_try_context_t *pForiegnTry;
{
    struct SEE_value *pForiegnVal = SEE_CAUGHT(*pForiegnTry);
    if (pForiegnVal) {
        struct SEE_value exception;

#if 0
struct SEE_traceback *pTrace;
printf("throw: ");
SEE_PrintValue(pForiegnInterp, pForiegnVal, stdout);
printf("\n");
SEE_ToString(pForiegnInterp, pForiegnVal, &exception);
SEE_PrintValue(pForiegnInterp, &exception, stdout);
printf("\n");
#endif