~ubuntu-branches/ubuntu/lucid/edbrowse/lucid

« back to all changes in this revision

Viewing changes to jsdom.c

  • Committer: Bazaar Package Importer
  • Author(s): Kapil Hari Paranjape
  • Date: 2007-12-05 10:39:04 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20071205103904-zr3kzzu0ym6stg16
Tags: 3.3.1-1
* New upstream version (3.3.1).
  - Messages have been internationalised.
  - Supports LANG environment variable.
  - Includes man page.
* Incorporate upstream man page:
  - debian/rules: Add rule to install upstream man page.
  - debian/edbrowse.1: Not required. Removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
{
38
38
    char *prefix, *tmp;
39
39
 
 
40
    if(debugLevel < 2)
 
41
        return;
 
42
    if(ismc)
 
43
        return;
 
44
 
40
45
    if(!report) {
41
46
        fprintf(gErrFile, "%s\n", message);
42
47
        return;
44
49
 
45
50
/* Conditionally ignore reported warnings. */
46
51
    if(JSREPORT_IS_WARNING(report->flags)) {
47
 
        if(ismc | browseLocal)
 
52
        if(browseLocal)
48
53
            return;
49
54
    }
50
55
 
54
59
    if(report->lineno) {
55
60
        tmp = prefix;
56
61
        prefix = JS_smprintf("%s%u: ", tmp ? tmp : "", report->lineno);
57
 
        JS_free(cx, tmp);
 
62
        if(tmp)
 
63
            JS_free(cx, tmp);
58
64
    }
59
65
    if(JSREPORT_IS_WARNING(report->flags)) {
60
66
        tmp = prefix;
61
67
        prefix = JS_smprintf("%s%swarning: ",
62
68
           tmp ? tmp : "", JSREPORT_IS_STRICT(report->flags) ? "strict " : "");
63
 
        JS_free(cx, tmp);
 
69
        if(tmp)
 
70
            JS_free(cx, tmp);
64
71
    }
65
72
 
66
73
    if(prefix)
67
74
        fputs(prefix, gErrFile);
68
75
    fprintf(gErrFile, "%s\n", message);
69
76
 
70
 
    JS_free(cx, prefix);
 
77
    if(prefix)
 
78
        JS_free(cx, prefix);
71
79
}                               /* my_ErrorReporter */
72
80
 
73
81
 
188
196
   jsval * rval)
189
197
{
190
198
/* It's too confusing to just close the window */
191
 
    puts("this page is finished, please use your back key or quit");
 
199
    i_puts(MSG_PageDone);
192
200
    cw->jsdead = true;
193
201
    return JS_TRUE;
194
202
}                               /* win_close */
463
471
    if(!JSVAL_IS_STRING(v))
464
472
        return JS_FALSE;
465
473
    s = JS_GetStringBytes(JSVAL_TO_STRING(v));
466
 
    puts("Sorry, innerText update not yet implemented.");
 
474
    i_puts(MSG_InnerText);
467
475
/* The string has already been updated in the object. */
468
476
    return JS_TRUE;
469
477
}                               /* setter_innerText */
609
617
    JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
610
618
};
611
619
 
 
620
static JSClass cell_class = {
 
621
    "Cell",
 
622
    JSCLASS_HAS_PRIVATE,
 
623
    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
 
624
    JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
 
625
};
 
626
 
612
627
static JSClass div_class = {
613
628
    "Div",
614
629
    JSCLASS_HAS_PRIVATE,
659
674
    {&area_class},
660
675
    {&span_class},
661
676
    {&trow_class},
 
677
    {&cell_class},
662
678
    {&option_class},
663
679
    {0}
664
680
};
729
745
/* 4 meg js space - should this be configurable? */
730
746
        jrt = JS_NewRuntime(4L * 1024L * 1024L);
731
747
        if(!jrt)
732
 
            errorPrint("2could not allocate memory for javascript operations.");
 
748
            i_printfExit(MSG_JavaMemError);
733
749
        gOutFile = stdout;
734
750
        gErrFile = stderr;
735
751
    }
736
752
 
737
753
    jcx = JS_NewContext(jrt, gStackChunkSize);
738
754
    if(!jcx)
739
 
        errorPrint("2unable to create javascript context");
 
755
        i_printfExit(MSG_JavaContextError);
740
756
    JS_SetErrorReporter(jcx, my_ErrorReporter);
741
757
    JS_SetOptions(jcx, JSOPTION_VAROBJFIX);
742
758
 
743
759
/* Create the Window object, which is the global object in DOM. */
744
760
    jwin = JS_NewObject(jcx, &window_class, NULL, NULL);
745
761
    if(!jwin)
746
 
        errorPrint("2unable to create window object for javascript");
 
762
        i_printfExit(MSG_JavaWindowError);
747
763
    JS_InitClass(jcx, jwin, 0, &window_class, window_ctor, 3,
748
764
       NULL, window_methods, NULL, NULL);
749
765
/* Ok, but the global object was created before the class,
752
768
 
753
769
/* Math, Date, Number, String, etc */
754
770
    if(!JS_InitStandardClasses(jcx, jwin))
755
 
        errorPrint("2unable to create standard classes for javascript");
 
771
        i_printfExit(MSG_JavaClassError);
756
772
 
757
773
    establish_property_object(jwin, "window", jwin);
758
774
    establish_property_object(jwin, "self", jwin);
787
803
       NULL, doc_methods, NULL, NULL);
788
804
    jdoc = JS_NewObject(jcx, &doc_class, NULL, jwin);
789
805
    if(!jdoc)
790
 
        errorPrint("2unable to create document object for javascript");
 
806
        i_printfExit(MSG_JavaObjError);
791
807
    establish_property_object(jwin, "document", jdoc);
792
808
 
793
809
    establish_property_string(jdoc, "bgcolor", "white", false);
972
988
    bool rc;
973
989
    jsval rval;
974
990
 
 
991
/* Sometimes Mac puts these three chars at the start of a text file. */
 
992
    if(!strncmp(str, "\xef\xbb\xbf", 3))
 
993
        str += 3;
 
994
 
975
995
    debugPrint(6, "javascript:\n%s", str);
976
996
    ok = JS_EvaluateScript(jcx, this, str, strlen(str),
977
997
       filename, lineno, &rval);