Re: [webkit-dev] BadMatch error when using webkit gtk in a window with rgba visual.

2009-06-09 Thread Zhe Su
I mean rgba colormap, not visual.

On Wed, Jun 10, 2009 at 2:33 PM, Zhe Su  wrote:

> Hi,
>   My program uses a gtk window with rgba visual to get translucent
> background effect. When I embed a webkit view into this window, it sometimes
> crashes with BadMatch error when loading some web page. Error message is:
>
> 20:50.170: browser_element.cc:406:
> WebViewLoadProgressChanged(Impl=0x1c1bec0, web_view=0x1785080, progress=55)
>
> (lt-ggl-gtk:19180): Gtk-CRITICAL **: gtk_paint_flat_box: assertion
> `style->depth == gdk_drawable_get_depth (window)' failed
>
> (lt-ggl-gtk:19180): Gtk-CRITICAL **: gtk_paint_shadow: assertion
> `style->depth == gdk_drawable_get_depth (window)' failed
>
> (lt-ggl-gtk:19180): Gtk-CRITICAL **: gtk_paint_flat_box: assertion
> `style->depth == gdk_drawable_get_depth (window)' failed
>
> (lt-ggl-gtk:19180): Gtk-CRITICAL **: gtk_paint_shadow: assertion
> `style->depth == gdk_drawable_get_depth (window)' failed
>
> (lt-ggl-gtk:19180): Gtk-CRITICAL **: gtk_paint_check: assertion
> `style->depth == gdk_drawable_get_depth (window)' failed
>
> (lt-ggl-gtk:19180): Gtk-CRITICAL **: gtk_paint_box: assertion `style->depth
> == gdk_drawable_get_depth (window)' failed
> The program 'lt-ggl-gtk' received an X Window System error.
> This probably reflects a bug in the program.
> The error was 'BadMatch (invalid parameter attributes)'.
>   (Details: serial 4316 error_code 8 request_code 70 minor_code 0)
>   (Note to programmers: normally, X errors are reported asynchronously;
>that is, you will receive the error a while after causing it.
>To debug your program, run it with the --sync command line
>option to change this behavior. You can then get a meaningful
>backtrace from your debugger if you break on the gdk_x_error()
> function.)
>
>   Do you have any idea about this problem? Is it a bug of webkit gtk?
>
> Regards
> James Su
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


[webkit-dev] BadMatch error when using webkit gtk in a window with rgba visual.

2009-06-09 Thread Zhe Su
Hi,
  My program uses a gtk window with rgba visual to get translucent
background effect. When I embed a webkit view into this window, it sometimes
crashes with BadMatch error when loading some web page. Error message is:

20:50.170: browser_element.cc:406:
WebViewLoadProgressChanged(Impl=0x1c1bec0, web_view=0x1785080, progress=55)

(lt-ggl-gtk:19180): Gtk-CRITICAL **: gtk_paint_flat_box: assertion
`style->depth == gdk_drawable_get_depth (window)' failed

(lt-ggl-gtk:19180): Gtk-CRITICAL **: gtk_paint_shadow: assertion
`style->depth == gdk_drawable_get_depth (window)' failed

(lt-ggl-gtk:19180): Gtk-CRITICAL **: gtk_paint_flat_box: assertion
`style->depth == gdk_drawable_get_depth (window)' failed

(lt-ggl-gtk:19180): Gtk-CRITICAL **: gtk_paint_shadow: assertion
`style->depth == gdk_drawable_get_depth (window)' failed

(lt-ggl-gtk:19180): Gtk-CRITICAL **: gtk_paint_check: assertion
`style->depth == gdk_drawable_get_depth (window)' failed

(lt-ggl-gtk:19180): Gtk-CRITICAL **: gtk_paint_box: assertion `style->depth
== gdk_drawable_get_depth (window)' failed
The program 'lt-ggl-gtk' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadMatch (invalid parameter attributes)'.
  (Details: serial 4316 error_code 8 request_code 70 minor_code 0)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the --sync command line
   option to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)

  Do you have any idea about this problem? Is it a bug of webkit gtk?

Regards
James Su
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] JSObjectCallAsFunctionCallback question

2009-05-15 Thread Zhe Su
AFAIK, there is no way to achieve what you want by using staticFunc
structure. Of course, if you use different C functions for each staticFunc
entry, you actually don't need the name.

Regards
James Su

On Fri, May 15, 2009 at 3:24 PM, Xiong  wrote:

> Thanks Su.
>
> I think i know you mean.
>
> To get the method name ["getValue"] via attach a private data to function
> object which create by JSObjectMake().
>
> Yes, it's a better way, but not for me.
>
> In my program, we have many Object and it's method and now all in
> staticFunc structure.
>
> Thanks again.
>
> -Xiong
>
>
> On Fri, May 15, 2009 at 11:57 AM, Zhe Su  wrote:
>
>> If you create a JSObject with JSObjectMake() function, you can have a
>> private data associated to the newly created JSObject. You can store
>> anything you want in the private data. So following approach might be
>> feasible for you:
>>
>> 1. define a special JSClass for your function, which has finalize and
>> callAsFunction set. In finalize() method, you need destroy the private data
>> associated to the JSObject, if necessary. callAsFunction points to your
>> getValue_cb.
>> 2. create the getValue function object by calling JSObjectMake() with the
>> function name "getValue" as private data.
>> 3. attach the function object to myObject with name "getValue". It might
>> be done in myObject class's initialize() method.
>> 4. in getValue_cb function you can retrieve the private data (which
>> contains the name) by calling JSObjectGetPrivate(function).
>>
>> The only drawback of this approach: you can't declare the function
>> statically in staticFunctions.
>>
>> Regards
>> James Su
>>
>> On Fri, May 15, 2009 at 10:53 AM, Xiong  wrote:
>>
>>> Thanks Darin.
>>>
>>> For the first problem, as you said, all the functions are objects, and
>>> also have **properties**.
>>>
>>> So,can we add a member for the "function object" to store the method
>>> name[here is "getValues"] in theoretical ?
>>>
>>> And this also like the "JSObjectRef object" variable in the callback
>>> prototype,we can get the class name like this:
>>>
>>> toJS(object)->className().data()
>>>
>>> Thanks.
>>>
>>> -Xiong
>>>
>>>
>>> On Fri, May 15, 2009 at 10:29 AM, Darin Adler  wrote:
>>>
>>>> On May 14, 2009, at 7:03 PM, Xiong wrote:
>>>>
>>>>  1what is the purpose of the "JSObjectRef function" variable? In my
>>>>> case, we never use.
>>>>>
>>>>
>>>> It’s fine to not use this if you don’t need to. In JavaScript, functions
>>>> are objects. Like other objects they can have properties. This argument is
>>>> passed to your C implementation so that it can get access to properties of
>>>> the function object if it has some reason to. In many cases there is no 
>>>> need
>>>> to do this.
>>>>
>>>>  2In this function, i want to get the propertyName of the method, in
>>>>> this case, we need "getValues", can be implemented ?
>>>>>
>>>>
>>>> No, there's no way to do that, for a good architectural reason.
>>>>
>>>> A JavaScript function is a first class object. Using JSObjectMake will
>>>> create an object with a prototype that has functions stored in its
>>>> properties, but there’s nothing to prevent the JavaScript program from
>>>> taking that function and storing it somewhere else, in a property with
>>>> another name. When the function is called, it’s just an object, and there’s
>>>> no way to go back in time and find out where that object came from.
>>>>
>>>> Consider the similar situation of a data property. When you get the
>>>> length of an array, it's a number 1, not a number 1 that knows it came from
>>>> a property named "length".
>>>>
>>>>-- Darin
>>>>
>>>>
>>>
>>> ___
>>> webkit-dev mailing list
>>> webkit-dev@lists.webkit.org
>>> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
>>>
>>>
>>
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] JSObjectCallAsFunctionCallback question

2009-05-14 Thread Zhe Su
If you create a JSObject with JSObjectMake() function, you can have a
private data associated to the newly created JSObject. You can store
anything you want in the private data. So following approach might be
feasible for you:

1. define a special JSClass for your function, which has finalize and
callAsFunction set. In finalize() method, you need destroy the private data
associated to the JSObject, if necessary. callAsFunction points to your
getValue_cb.
2. create the getValue function object by calling JSObjectMake() with the
function name "getValue" as private data.
3. attach the function object to myObject with name "getValue". It might be
done in myObject class's initialize() method.
4. in getValue_cb function you can retrieve the private data (which contains
the name) by calling JSObjectGetPrivate(function).

The only drawback of this approach: you can't declare the function
statically in staticFunctions.

Regards
James Su

On Fri, May 15, 2009 at 10:53 AM, Xiong  wrote:

> Thanks Darin.
>
> For the first problem, as you said, all the functions are objects, and also
> have **properties**.
>
> So,can we add a member for the "function object" to store the method
> name[here is "getValues"] in theoretical ?
>
> And this also like the "JSObjectRef object" variable in the callback
> prototype,we can get the class name like this:
>
> toJS(object)->className().data()
>
> Thanks.
>
> -Xiong
>
>
> On Fri, May 15, 2009 at 10:29 AM, Darin Adler  wrote:
>
>> On May 14, 2009, at 7:03 PM, Xiong wrote:
>>
>>  1what is the purpose of the "JSObjectRef function" variable? In my
>>> case, we never use.
>>>
>>
>> It’s fine to not use this if you don’t need to. In JavaScript, functions
>> are objects. Like other objects they can have properties. This argument is
>> passed to your C implementation so that it can get access to properties of
>> the function object if it has some reason to. In many cases there is no need
>> to do this.
>>
>>  2In this function, i want to get the propertyName of the method, in
>>> this case, we need "getValues", can be implemented ?
>>>
>>
>> No, there's no way to do that, for a good architectural reason.
>>
>> A JavaScript function is a first class object. Using JSObjectMake will
>> create an object with a prototype that has functions stored in its
>> properties, but there’s nothing to prevent the JavaScript program from
>> taking that function and storing it somewhere else, in a property with
>> another name. When the function is called, it’s just an object, and there’s
>> no way to go back in time and find out where that object came from.
>>
>> Consider the similar situation of a data property. When you get the length
>> of an array, it's a number 1, not a number 1 that knows it came from a
>> property named "length".
>>
>>-- Darin
>>
>>
>
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
>
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] How to let webkit to be able to load local image file in html content?

2009-05-14 Thread Zhe Su
I just found that setting base_uri to "file://" can't actually solve the
problem. Though it allows loading local image file in a simple html content,
I found that using local image file in css may still not work. It looks not
like a correct behavior.

Regards
James Su

On Thu, May 14, 2009 at 3:37 PM, Holger Freyther  wrote:

> On Thursday 14 May 2009 07:14:18 Jan Alonzo wrote:
> > Hi  james,
> >
> > can you please file a bug against the WebKitGtk component at
> > http://bugs.webkit.org. I don't think that's correct.
>
> It is correct. You define the SecurityOrigin (we have a class with that
> name)
> and you want to load something from a different context. Think of a WebPage
> trying to get file:///etc/passwd. This is only allowed if the page itself
> has
> been loaded from file...
>
>
>
>z.
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] How to let webkit to be able to load local image file in html content?

2009-05-13 Thread Zhe Su
Then what's correct behavior?

On 5/14/09, Jan Alonzo  wrote:
> Hi  james,
>
> can you please file a bug against the WebKitGtk component at
> http://bugs.webkit.org. I don't think that's correct.
>
> Thanks,
> Jan
>
> On 5/14/09, Zhe Su  wrote:
>> Just found that the problem is gone when the base_uri parameter is set to
>> "file://" instead of NULL. Is it a correct way?
>>
>> Regards
>> James Su
>>
>> On Thu, May 14, 2009 at 10:40 AM, Zhe Su  wrote:
>>
>>> Attached is a simple test program. When running the program, following
>>> error occurred:
>>>
>>> console message:  @0: Not allowed to load local resource:
>>> file:///usr/share/pixmaps/elisa.svg
>>>
>>> But if you save the html content into a file and load it with
>>> GtkLauncher,
>>> then it's ok.
>>>
>>> Regards
>>> James Su
>>>
>>>
>>> On Thu, May 14, 2009 at 12:26 AM, tonikitoo (Antonio Gomes) <
>>> toniki...@gmail.com> wrote:
>>>
>>>> It sounds like we can be misusing the base_url parameter. could you
>>>> paste how you are calling the method (parameters and so) and a snippet
>>>> of the local html file.
>>>>
>>>> On Wed, May 13, 2009 at 6:58 AM, Zhe Su  wrote:
>>>> > Hi,
>>>> >   When I call webkit_web_view_load_html_string() to load a html
>>>> > content
>>>> into
>>>> > a webkitview, webkit always refuses to load local files (image)
>>>> > referred
>>>> in
>>>> > the html content. Is it possible to work around this behavior and let
>>>> webkit
>>>> > load local files?
>>>>
>>>> --
>>>> --Antonio Gomes
>>>>
>>>
>>>
>>
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] How to let webkit to be able to load local image file in html content?

2009-05-13 Thread Zhe Su
Just found that the problem is gone when the base_uri parameter is set to
"file://" instead of NULL. Is it a correct way?

Regards
James Su

On Thu, May 14, 2009 at 10:40 AM, Zhe Su  wrote:

> Attached is a simple test program. When running the program, following
> error occurred:
>
> console message:  @0: Not allowed to load local resource:
> file:///usr/share/pixmaps/elisa.svg
>
> But if you save the html content into a file and load it with GtkLauncher,
> then it's ok.
>
> Regards
> James Su
>
>
> On Thu, May 14, 2009 at 12:26 AM, tonikitoo (Antonio Gomes) <
> toniki...@gmail.com> wrote:
>
>> It sounds like we can be misusing the base_url parameter. could you
>> paste how you are calling the method (parameters and so) and a snippet
>> of the local html file.
>>
>> On Wed, May 13, 2009 at 6:58 AM, Zhe Su  wrote:
>> > Hi,
>> >   When I call webkit_web_view_load_html_string() to load a html content
>> into
>> > a webkitview, webkit always refuses to load local files (image) referred
>> in
>> > the html content. Is it possible to work around this behavior and let
>> webkit
>> > load local files?
>>
>> --
>> --Antonio Gomes
>>
>
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] How to let webkit to be able to load local image file in html content?

2009-05-13 Thread Zhe Su
Attached is a simple test program. When running the program, following error
occurred:

console message:  @0: Not allowed to load local resource:
file:///usr/share/pixmaps/elisa.svg

But if you save the html content into a file and load it with GtkLauncher,
then it's ok.

Regards
James Su

On Thu, May 14, 2009 at 12:26 AM, tonikitoo (Antonio Gomes) <
toniki...@gmail.com> wrote:

> It sounds like we can be misusing the base_url parameter. could you
> paste how you are calling the method (parameters and so) and a snippet
> of the local html file.
>
> On Wed, May 13, 2009 at 6:58 AM, Zhe Su  wrote:
> > Hi,
> >   When I call webkit_web_view_load_html_string() to load a html content
> into
> > a webkitview, webkit always refuses to load local files (image) referred
> in
> > the html content. Is it possible to work around this behavior and let
> webkit
> > load local files?
>
> --
> --Antonio Gomes
>
#include
#include 

static const char kHtml[] =
"\n"
"  \n"
"\n"
"  \n"
"";

int main(int argc, char *argv[]) {
  GtkWidget *window;
  GtkWidget *web_view;
  gtk_init(&argc, &argv);
  g_thread_init(NULL);

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  web_view = GTK_WIDGET(webkit_web_view_new());

  gtk_container_add(GTK_CONTAINER(window), web_view);
  gtk_widget_show_all(window);

  webkit_web_view_load_html_string(WEBKIT_WEB_VIEW(web_view), kHtml, NULL);
  gtk_main();
}
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


[webkit-dev] How to let webkit to be able to load local image file in html content?

2009-05-13 Thread Zhe Su
Hi,
  When I call webkit_web_view_load_html_string() to load a html content into
a webkitview, webkit always refuses to load local files (image) referred in
the html content. Is it possible to work around this behavior and let webkit
load local files?

Regards
James Su
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] Error building Webkit Gtk on MacOSX

2009-05-09 Thread Zhe Su
Just worked around this issue by modifying Intrinsic.h. webkit was built
successfully and GtkLauncher loaded www.google.com successfully. But it then
crashed with following error:

dyld: lazy symbol binding failed: Symbol not found:
__ZN7WebCore15PurgeableBuffer6createEPKcm
  Referenced from: /opt/local/lib/libwebkit-1.0.2.dylib
  Expected in: dynamic lookup

dyld: Symbol not found: __ZN7WebCore15PurgeableBuffer6createEPKcm
  Referenced from: /opt/local/lib/libwebkit-1.0.2.dylib
  Expected in: dynamic lookup

Regards
James Su

On Sat, May 9, 2009 at 8:51 PM, Holger Freyther  wrote:

> On Saturday 09 May 2009 13:58:34 Zhe Su wrote:
>
> > './'`WebCore/plugins/gtk/PluginViewGtk.cpp
> > /opt/local/include/X11/Intrinsic.h:158: error: conflicting declaration
> > ‘typedef char Boolean’
> >
> /System/Library/Frameworks/CoreServices.framework/Headers/../Frameworks/Car
> >bonCore.framework/Headers/MacTypes.h:279: error: ‘Boolean’ has a previous
> > declaration as ‘typedef unsigned char Boolean’
> > make[1]: *** [WebCore/plugins/gtk/libWebCore_la-PluginViewGtk.lo] Error 1
> > make: *** [all] Error 2
>
> Yeah, I saw that too but didn't come around making a proper patch. The
> thing
> is that something should be included with PLATFORM(MAC) but not
> PLATFORM(DARWIN) (or such).
>
> Please see http://webkit.org/coding/contributing.html on how to contribute
> a
> patch.
>
>
> thanks
>z.
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


[webkit-dev] Error building Webkit Gtk on MacOSX

2009-05-09 Thread Zhe Su
When building Webkit Gtk (latest svn) on MacOSX, I got following error:

/opt/local/bin/gmkdir -p ./.deps/DerivedSources
./doltlibtool --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I.
-DWTF_USE_ICU_UNICODE=1 -DBUILDING_CAIRO__=1 -DBUILDING_GTK__=1
-DWTF_CHANGES -DPACKAGE_LOCALE_DIR=\"/opt/local/share/locale\"  -DXP_UNIX
-DNDEBUG-I./WebCore -I./WebCore/bindings/js -I./WebCore/bridge
-I./WebCore/bridge/c -I./WebCore/css -I./WebCore/dom -I./WebCore/editing
-I./WebCore/history -I./WebCore/html -I./WebCore/inspector
-I./WebCore/loader -I./WebCore/loader/appcache -I./WebCore/loader/archive
-I./WebCore/loader/icon -I./WebCore/page -I./WebCore/page/animation
-I./WebCore/platform -I./WebCore/platform/animation
-I./WebCore/platform/graphics -I./WebCore/platform/graphics/filters
-I./WebCore/platform/graphics/transforms -I./WebCore/platform/image-decoders
-I./WebCore/platform/image-decoders/bmp
-I./WebCore/platform/image-decoders/gif
-I./WebCore/platform/image-decoders/ico
-I./WebCore/platform/image-decoders/jpeg
-I./WebCore/platform/image-decoders/png
-I./WebCore/platform/image-decoders/xbm -I./WebCore/platform/network
-I./WebCore/platform/text -I./WebCore/plugins -I./WebCore/rendering
-I./WebCore/rendering/style -I./WebCore/workers -I./WebCore/xml
-I./WebCore/bindings/js -DWTF_USE_SOUP=1 -I./WebCore/platform/network/soup
-DENABLE_JAVASCRIPT_DEBUGGER=1 -DENABLE_OFFLINE_WEB_APPLICATIONS=1
-DENABLE_DASHBOARD_SUPPORT=1 -DENABLE_DATABASE=1 -I./WebCore/platform/sql
-I./WebCore/storage -DENABLE_DOM_STORAGE=1 -I./WebCore/storage
-DENABLE_ICONDATABASE=1 -DENABLE_VIDEO=1  -DENABLE_XPATH=1 -DENABLE_XSLT=1
-DENABLE_WORKERS=1   -DENABLE_SVG=1 -I\./WebCore/svg
-I\./WebCore/svg/animation -I\./WebCore/svg/graphics
-I\./WebCore/svg/graphics/filters -DENABLE_SVG_USE=1
-DENABLE_SVG_FOREIGN_OBJECT=1 -DENABLE_SVG_FONTS=1  -DENABLE_SVG_AS_IMAGE=1
-DENABLE_SVG_ANIMATION=1 -DDATA_DIR=\"/opt/local/share\" -I./JavaScriptCore
-I./JavaScriptCore/ForwardingHeaders -I./JavaScriptCore/parser
-I./JavaScriptCore/wtf -I./DerivedSources -I./JavaScriptCore/API
-I./JavaScriptCore/ForwardingHeaders -I./JavaScriptCore/interpreter
-I./JavaScriptCore/bytecode -I./JavaScriptCore/bytecompiler
-I./JavaScriptCore/debugger -I./JavaScriptCore/jit -I./JavaScriptCore/pcre
-I./JavaScriptCore/profiler -I./JavaScriptCore/runtime
-I./JavaScriptCore/wrec -I./JavaScriptCore/jit -I./JavaScriptCore/assembler
-I./JavaScriptCore/wtf/unicode -I./JavaScriptCore/yarr
-I./JavaScriptCore/pcre -I./JavaScriptCore/parser
-I./JavaScriptCore/runtime  -I./WebCore/loader/gtk -I./WebCore/page/gtk
-I./WebCore/platform/graphics/cairo -I./WebCore/platform/graphics/gtk
-I./WebCore/platform/gtk -DUSE_FREETYPE=1  -I./WebCore/svg/graphics/cairo
-I/opt/local/include -fvisibility-inlines-hidden -fno-rtti
-fno-strict-aliasing -Wall -W -Wcast-align -Wchar-subscripts -Wreturn-type
-Wformat -Wformat-security -Wno-format-y2k -Wundef
-Wmissing-format-attribute -Wpointer-arith -Wwrite-strings
-Wno-unused-parameter -Wno-parentheses -fno-exceptions -fvisibility=hidden
-D_REENTRANT -I/opt/local/include/glib-2.0 -I/opt/local/lib/glib-2.0/include
-I/opt/local/include   -I./JavaScriptCore/icu -I./WebCore/icu
-I/opt/local/include/libxml2   -I/opt/local/include/cairo
-I/opt/local/include/pixman-1 -I/opt/local/include/freetype2
-I/opt/local/include -I/opt/local/include/libpng12
-I/opt/local/include/pango-1.0 -I/opt/local/include/glib-2.0
-I/opt/local/lib/glib-2.0/include -I/opt/local/include
-I/opt/local/include/freetype2   -I/opt/local/include/gtk-2.0
-I/opt/local/lib/gtk-2.0/include -I/opt/local/include/atk-1.0
-I/opt/local/include/cairo -I/opt/local/include/pango-1.0
-I/opt/local/include -I/opt/local/include/glib-2.0
-I/opt/local/lib/glib-2.0/include -I/opt/local/include/pixman-1
-I/opt/local/include/freetype2 -I/opt/local/include/libpng12
-I/opt/local/include   -I/opt/local/include/libsoup-2.4
-I/opt/local/include/libxml2 -I/opt/local/include
-I/opt/local/include/glib-2.0 -I/opt/local/lib/glib-2.0/include
-I/opt/local/include/cairo -I/opt/local/include/freetype2
-I/opt/local/include -I/opt/local/include/pixman-1
-I/opt/local/include/libpng12   -I/opt/local/include   -D_REENTRANT
-I/opt/local/include/gstreamer-0.10 -I/opt/local/include/glib-2.0
-I/opt/local/lib/glib-2.0/include -I/opt/local/include
-I/opt/local/include/libxml2   -I/opt/local/include
-I/opt/local/include/libxml2 -I/opt/local/include/enchant
-I/opt/local/include/glib-2.0 -I/opt/local/lib/glib-2.0/include
-I/opt/local/include-O2 -MT
WebCore/plugins/gtk/libWebCore_la-PluginViewGtk.lo -MD -MP -MF
WebCore/plugins/gtk/.deps/libWebCore_la-PluginViewGtk.Tpo -c -o
WebCore/plugins/gtk/libWebCore_la-PluginViewGtk.lo `test -f
'WebCore/plugins/gtk/PluginViewGtk.cpp' || echo
'./'`WebCore/plugins/gtk/PluginViewGtk.cpp
/opt/local/include/X11/Intrinsic.h:158: error: conflicting declaration
‘typedef char Boolean’
/System/Library/Frameworks/CoreServices.framework/Headers/../Frameworks/CarbonCore.framework/Headers/MacTypes.h:279:
error: ‘Boolean’ h

Re: [webkit-dev] How to build Webkit GTK on macos

2009-05-06 Thread Zhe Su
Maybe you need MacPorts .

Regards
James Su

On Wed, May 6, 2009 at 2:27 PM, Lucius Fox  wrote:

> >From http://trac.webkit.org/wiki/BuildingGtk, it said i need to install
>  ATK
>  Cairo
>  cURL
>  fontconfig
>  freetype2
>  gettext
>  gtk+
>  libjpeg
>  libpng
>  libtiff
>  libxml2
>  libxslt
>  pango
>  SQLite
>
> My question is how to install these packages on Macos so that i can
> compile Webkit gtk on Macos?
>
> Thank you.
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] Is it possible to block webkit_web_view_load_html_string() until the content is actually loaded?

2009-05-04 Thread Zhe Su
It works.

Thanks a lot.

On Mon, May 4, 2009 at 4:33 PM, Holger Freyther  wrote:

> On Monday 04 May 2009 06:36:46 Zhe Su wrote:
> > Hi,
> >   I'm writing an application which uses webkit to display some html
> > content. webkit_web_view_load_html_string() is used to set content into
> > webkit. I found this function will return before the content is actually
> > loaded, then webkit will load the content in background. However my
> > application needs block until the content is actually loaded. I know that
> > webkit has a signal "load-finished", which will be emitted when the
> content
> > is fully loaded. But because of some limitation, my application can only
> > block at somewhere until the content is fully loaded. Because it's a
> single
> > thread application, I don't know how to do it. Any suggestions to solve
> > this problem?
>
> Run your own event loop and leave it once load-finished got called or your
> timeout is reached...
>
>
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


[webkit-dev] Is it possible to block webkit_web_view_load_html_string() until the content is actually loaded?

2009-05-03 Thread Zhe Su
Hi,
  I'm writing an application which uses webkit to display some html content.
webkit_web_view_load_html_string() is used to set content into webkit. I
found this function will return before the content is actually loaded, then
webkit will load the content in background. However my application needs
block until the content is actually loaded. I know that webkit has a signal
"load-finished", which will be emitted when the content is fully loaded. But
because of some limitation, my application can only block at somewhere until
the content is fully loaded. Because it's a single thread application, I
don't know how to do it. Any suggestions to solve this problem?

Thanks
James Su
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] webkit-gtk issue: destroying webview widget directly causes crash.

2009-04-03 Thread Zhe Su
bug filed: https://bugs.webkit.org/show_bug.cgi?id=25042

Thanks.

On Sat, Apr 4, 2009 at 3:27 AM, Christian Dywan wrote:

> Am Sat, 4 Apr 2009 02:13:49 +0800
> schrieb Zhe Su :
>
> > Hi,
> >   Recently I encountered a crash issue related to webkit-gtk.
> > Attached program will crash when destroying webview widget. The
> > backtrace is:
> >
> > tested against webkit-gtk 1.1.1. Is it a bug?
> >
> > Regards
> > James Su
>
> Hey James,
>
> the best way to solve this would be to enhance the unit tests to test
> creation and destroying. Have a look at
> WebKit/gtk/tests/testwebframe.c . And please file a bug, otherwise it
> will be lost on the list.
>
> Yours,
>Christian
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


[webkit-dev] webkit-gtk issue: destroying webview widget directly causes crash.

2009-04-03 Thread Zhe Su
Hi,
  Recently I encountered a crash issue related to webkit-gtk.  Attached
program will crash when destroying webview widget. The backtrace is:

Program received signal SIGSEGV, Segmentation fault.
webkit_web_view_screen_changed (this=) at
WebKit/gtk/webkit/webkitwebview.cpp:1624
1624Settings* settings = core(webView)->settings();
Current language:  auto; currently c++
(gdb) bt
#0  0x00389ae6fb8b in webkit_web_view_screen_changed (this=) from /usr/lib64/libwebkit-1.0.so.2
#1  0x00388ba0b8ee in IA__g_closure_invoke (closure=0x692770,
return_value=0x0, n_param_values=2, param_values=0x6796d0,
invocation_hint=0x7fffd9b0) at gclosure.c:767
#2  0x00388ba21f18 in signal_emit_unlocked_R (node=0x65e040,
detail=, instance=,
emission_return=, instance_and_params=) at gsignal.c:3244
#3  0x00388ba232fe in IA__g_signal_emit_valist (instance=0x690030,
signal_id=, detail=0, var_args=0x7fffdba0)
at gsignal.c:2977
#4  0x00388ba23893 in IA__g_signal_emit (instance=0x690030,
signal_id=6488272, detail=0) at gsignal.c:3034
#5  0x00389343602a in gtk_widget_propagate_hierarchy_changed_recurse
(widget=0x690030, client_data=0x7fffdca0) at gtkwidget.c:6185
#6  0x003893439a80 in _gtk_widget_propagate_hierarchy_changed
(widget=0x690030, previous_toplevel=0x681090) at gtkwidget.c:6225
#7  0x003893443899 in IA__gtk_widget_unparent (widget=0x690030) at
gtkwidget.c:2916
#8  0x00389327a600 in gtk_bin_remove (container=0x681090,
child=0x6300d0) at gtkbin.c:109
#9  0x00388ba0b8ee in IA__g_closure_invoke (closure=0x6615d0,
return_value=0x0, n_param_values=2, param_values=0x679800,
invocation_hint=0x7fffdf00) at gclosure.c:767
#10 0x00388ba21715 in signal_emit_unlocked_R (node=0x661640,
detail=, instance=,
emission_return=, instance_and_params=) at gsignal.c:3174
#11 0x00388ba232fe in IA__g_signal_emit_valist (instance=0x681090,
signal_id=, detail=0, var_args=0x7fffe0f0)
at gsignal.c:2977
#12 0x00388ba23893 in IA__g_signal_emit (instance=0x690030,
signal_id=6488272, detail=0) at gsignal.c:3034
#13 0x00389343ed85 in gtk_widget_dispose (object=0x690030) at
gtkwidget.c:7898
#14 0x00388ba0ddd0 in IA__g_object_run_dispose (object=0x690030) at
gobject.c:789
#15 0x00400a23 in main (argc=1, argv=0x7fffe308) at webkit.c:12
(gdb)

tested against webkit-gtk 1.1.1. Is it a bug?

Regards
James Su


webkit.c
Description: Binary data
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] How to interrupt a running javascript code via JavaScriptCore C++ API?

2009-04-03 Thread Zhe Su
Does anyone know how to do it?

Thanks

On Tue, Mar 10, 2009 at 10:25 AM, Zhe Su  wrote:

> Hi,
>   When running a piece of javascript code by using JSEvaluateScript() or
> JSObjectCallAsFunction(), the native code might be blocked because of dead
> loop or some other abnormal things in javascript code. In this case, a
> mechanism to let native code be able to interrupt the javascript code by
> throwing a javascript exception would be very useful. Seems that current
> JavaScriptCore API doesn't have such ability.
>
> Regards
> James Su
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] A question regarding to JavaScriptCore's garbage collection mechanism.

2009-03-17 Thread Zhe Su
Thanks. I'll try to trace it to see what exactly happens.

On Wed, Mar 18, 2009 at 2:34 AM, Geoffrey Garen  wrote:

> This code was tested against webkit svn. Anyone can help me explain this
>> behavior? Is it a bug of JavaScriptCore?
>>
>
> Most likely, the conservative nature of the garbage collector prevents the
> function from being reclaimed in this case.
>
> You can step through JSC::Heap::collect() to see exactly why the object is
> not reclaimed.
>
> Without further evidence, I wouldn't consider this a bug.
>
> Geoff
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


[webkit-dev] A question regarding to JavaScriptCore's garbage collection mechanism.

2009-03-17 Thread Zhe Su
Hi,
  Recently I encountered a weird issue regarding to JavaScriptCore's garbage
collection mechanism. See following javascript code:

function TestNativeObject(s) {
>   var cb = function() {
>   };
>   cb.call(s);
> }
>
> function Test() {
>   var s = new NativeObject();
>   TestNativeObject(s);
>   s = null;
>   CollectGarbage();
> }
>
> Test();
>

In above code, NativeObject is a class object defined in C++ code, it can
track the lifetime of its instances. CollectGarbage() is a global method
registered from C++ code, which just call JSGarbageCollect() to do garbage
collection forcely. Ideally, the NativeObject created in Test() should be
destroyed when calling CollectGarbage(). But unfortunately, it won't. The
tricky thing is: removing the line "cb.call(s)" in TestNativeObject()
function solves this issue, though cb is just an empty function.

This code was tested against webkit svn. Anyone can help me explain this
behavior? Is it a bug of JavaScriptCore?

Regards
James Su
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] How to interrupt a running javascript code via JavaScriptCore C++ API?

2009-03-09 Thread Zhe Su
Just filed an enhancement request:
https://bugs.webkit.org/show_bug.cgi?id=24478

On Tue, Mar 10, 2009 at 10:25 AM, Zhe Su  wrote:

> Hi,
>   When running a piece of javascript code by using JSEvaluateScript() or
> JSObjectCallAsFunction(), the native code might be blocked because of dead
> loop or some other abnormal things in javascript code. In this case, a
> mechanism to let native code be able to interrupt the javascript code by
> throwing a javascript exception would be very useful. Seems that current
> JavaScriptCore API doesn't have such ability.
>
> Regards
> James Su
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] Is it possible to get current source URL and line number from JavaScriptCore API?

2009-03-09 Thread Zhe Su
https://bugs.webkit.org/show_bug.cgi?id=24476

On Tue, Mar 10, 2009 at 10:32 AM, Mark Rowe  wrote:

>
> On 2009-03-09, at 19:18, Zhe Su wrote:
>
> Thanks. Do I need report a bug or something?
>
>
> Yes.  Please file an enhancement request at <http://webkit.org/new-bug>.
>
> - Mark
>
> On Tue, Mar 10, 2009 at 2:42 AM, Geoffrey Garen  wrote:
>
>>  I'm writing a C++ to JavaScript binding based on JavaScriptCore, and
>>> would like to know current source URL and line number information in the
>>> callback functions. However I didn't find any related API. It there any way
>>> to do it?
>>>
>>
>> No.
>>
>> Sounds like a reasonable feature request.
>>
>> Geoff
>>
>
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
>
>
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


[webkit-dev] How to interrupt a running javascript code via JavaScriptCore C++ API?

2009-03-09 Thread Zhe Su
Hi,
  When running a piece of javascript code by using JSEvaluateScript() or
JSObjectCallAsFunction(), the native code might be blocked because of dead
loop or some other abnormal things in javascript code. In this case, a
mechanism to let native code be able to interrupt the javascript code by
throwing a javascript exception would be very useful. Seems that current
JavaScriptCore API doesn't have such ability.

Regards
James Su
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] Is it possible to get current source URL and line number from JavaScriptCore API?

2009-03-09 Thread Zhe Su
Thanks. Do I need report a bug or something?

Regards
James Su

On Tue, Mar 10, 2009 at 2:42 AM, Geoffrey Garen  wrote:

>  I'm writing a C++ to JavaScript binding based on JavaScriptCore, and would
>> like to know current source URL and line number information in the callback
>> functions. However I didn't find any related API. It there any way to do it?
>>
>
> No.
>
> Sounds like a reasonable feature request.
>
> Geoff
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


[webkit-dev] Is it possible to get current source URL and line number from JavaScriptCore API?

2009-03-09 Thread Zhe Su
Hi,
  I'm writing a C++ to JavaScript binding based on JavaScriptCore, and would
like to know current source URL and line number information in the callback
functions. However I didn't find any related API. It there any way to do it?

Regards
James Su
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] A question regarding to JavaScriptCore's C/C++ API.

2009-03-06 Thread Zhe Su
Thanks for your reply.

On Sat, Mar 7, 2009 at 7:41 AM, Geoffrey Garen  wrote:

> Hi Zhe.
>
>I'm developing an application which uses webkit's JavaScriptCore and a
>> customized global object (by providing a special class when creating the
>> context). My customized global object provides some built-in properties that
>> can be accessed by javascript code. Now, I want to support a special
>> behavior: allows javascript code to override a built-in property of global
>> object by using variable declaraction statement. For example, assuming the
>> global object has a built-in property, named "foo", a "var foo;" statement
>> shall create a javascript variable, named "foo" and the original built-in
>> "foo" shall be overrid by this new javascript variable. But if there is no
>> "var foo;" statement, the built-in foo shall be able to get and set from
>> javascript code.
>>
>> Now the problem is, current JavaScriptCore's C API (especially those
>> HasProperty, GetProperty, SetProperty callbacks of a class definition) can't
>> distinguish variable delcaration statement and variable assigment statement.
>> I checked SpiderMonkey's API and found it can distinguish such things by
>> providing a flag when calling ResolveProperty callback.
>>
>
> I'm surprised to hear that SpiderMonkey's property setting API includes a
> flag distinguishing var declarations from other kinds of property setting.
> Internet Explorer supports shadowing global properties with var
> declarations, but Firefox does not. (Perhaps you're thinking of the
> SpiderMonkey flag to distinguish "x = y" syntax from "this.x = y" syntax,
> which is slightly different.)

SpiderMonkey can distinguish among many different type of statements. See
https://developer.mozilla.org/En/SpiderMonkey/JSAPI_Reference/JSNewResolveOp


>
>
> It may not be my place, but I would discourage you from giving var
> declarations a special behavior, distinct from their behavior on the web.
> Much of the value of JavaScript derives from the fact that so many
> programmers understand how it works, due to their experience with the web.

I also don't want to support such non-standard behavior, however we need
support legacy javascript code written for windows which rely on this
behavior. What a pity. Anyway, thanks for your reply.


>
>
>  Do you have any idea on this issue? How can I implement such behavior
>> based on current API?
>>
>
> There is no API in JavaScriptCore for distinguishing between "var" and
> other property setting. I'm not sure how you would implement that.

JavaScriptCore's API is simple and easy to use, however in most cases, it's
too simple to achieve some feature, comparing to SpiderMonkey, which is too
complex and flexible.


>
>
> Geoff
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] A question regarding to JavaScriptCore's C/C++ API.

2009-03-06 Thread Zhe Su
ping.

On Thu, Mar 5, 2009 at 2:44 PM, Zhe Su  wrote:

> Hi,
>I'm developing an application which uses webkit's JavaScriptCore and a
> customized global object (by providing a special class when creating the
> context). My customized global object provides some built-in properties that
> can be accessed by javascript code. Now, I want to support a special
> behavior: allows javascript code to override a built-in property of global
> object by using variable declaraction statement. For example, assuming the
> global object has a built-in property, named "foo", a "var foo;" statement
> shall create a javascript variable, named "foo" and the original built-in
> "foo" shall be overrid by this new javascript variable. But if there is no
> "var foo;" statement, the built-in foo shall be able to get and set from
> javascript code.
>
> Now the problem is, current JavaScriptCore's C API (especially those
> HasProperty, GetProperty, SetProperty callbacks of a class definition) can't
> distinguish variable delcaration statement and variable assigment statement.
> I checked SpiderMonkey's API and found it can distinguish such things by
> providing a flag when calling ResolveProperty callback.
>
> Do you have any idea on this issue? How can I implement such behavior based
> on current API?
>
> Regards
> James Su
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


[webkit-dev] A question regarding to JavaScriptCore's C/C++ API.

2009-03-04 Thread Zhe Su
Hi,
   I'm developing an application which uses webkit's JavaScriptCore and a
customized global object (by providing a special class when creating the
context). My customized global object provides some built-in properties that
can be accessed by javascript code. Now, I want to support a special
behavior: allows javascript code to override a built-in property of global
object by using variable declaraction statement. For example, assuming the
global object has a built-in property, named "foo", a "var foo;" statement
shall create a javascript variable, named "foo" and the original built-in
"foo" shall be overrid by this new javascript variable. But if there is no
"var foo;" statement, the built-in foo shall be able to get and set from
javascript code.

Now the problem is, current JavaScriptCore's C API (especially those
HasProperty, GetProperty, SetProperty callbacks of a class definition) can't
distinguish variable delcaration statement and variable assigment statement.
I checked SpiderMonkey's API and found it can distinguish such things by
providing a flag when calling ResolveProperty callback.

Do you have any idea on this issue? How can I implement such behavior based
on current API?

Regards
James Su
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] Question about JavaScriptCore's JSEvaluateScript function.

2009-03-02 Thread Zhe Su
I see. Thanks.

On Mon, Mar 2, 2009 at 7:28 PM, Zoltan Herczeg wrote:

> Why do you want to use the original context pointer? The context is
> something like "current machine state". It is important for JS function
> return, exception handling, and many other things. It is not a global
> pointer, like JSGlobalData (JSContextGroupRef), it points to the current
> context.
>
> Zoltan
>
> > Thanks for your answer. Then, in the callback function (such as
> > GetPropertyCallback), is it ok to use the original context pointer
> created
> > at beginning? Or the ctx passed to the callback must be used instead?
> >
> > Regards
> > James Su
> >
> > On Mon, Mar 2, 2009 at 4:52 PM, Zoltan Herczeg
> > wrote:
> >
> >> Hi,
> >>
> >> that is intended, since the context pointer is the current
> >> CallFrame/ExecState. WebKit creates its own stack (called RegisterFile)
> >> to
> >> run JavaScript. The stack base of the current function is pointed by
> >> CallFrame (similar to ebp in x86, or fp in ARM architectures). When you
> >> call a JS function, several important pointers are stored on the top of
> >> the stack, like return value, current code block, previous call frame,
> >> and
> >> these values are accessed through the CallFrame pointer. It is essential
> >> for JavaScriptCore, there is no workaround.
> >>
> >> Zoltan
> >>
> >> > Hi,
> >> >   Recently, I'm writing an application which uses JavaScriptCore to
> >> > execute
> >> > javascript code. I just encountered a problem when using
> >> JSEvaluateScript
> >> > function to evaluate a piece of script. When executing the script,
> >> some
> >> > callbacks provided by my code will be called, but I found that the
> >> context
> >> > received by callbacks are different than the context I created and
> >> passed
> >> > to
> >> > JSEvaluateScript function.
> >> >
> >> > Attached is a test program.
> >> > Below is the output of this program on my system (ubuntu 8.04 64bit
> >> with
> >> > latest webkit svn):
> >> >
> >> > Create context 0x7faf5d567e88, global object 0x7faf5d53
> >> > InitializeCallback(ctx=0x7faf5d567e88, obj=0x7faf5d532400)
> >> > HasPropertyCallback(ctx=0x7faf50c4b048, obj=0x7faf5d532400,
> >> > prop=prototype)
> >> > CallAsConstructorCallback(ctx=0x7faf50c4b0c0, obj=0x7faf5d532400)
> >> > InitializeCallback(ctx=0x7faf50c4b0c0, obj=0x7faf5d532440)
> >> > SetPropertyCallback(ctx=0x7faf50c4b048, obj=0x7faf5d532440,
> >> prop=prop1)
> >> > HasPropertyCallback(ctx=0x7faf50c4b048, obj=0x7faf5d532440,
> >> prop=prop1)
> >> > FinalizeCallback(obj=0x7faf5d532400)
> >> > FinalizeCallback(obj=0x7faf5d532440)
> >> >
> >> > You can see that, the callback functions received several different
> >> > context
> >> > pointers comparing to the one created at first beginning.
> >> >
> >> > Is it an intend behavior or a bug of webkit? And how can I avoid or
> >> > workaround this problem?
> >> >
> >> > Thanks a lot.
> >> >
> >> > James Su
> >> > ___
> >> > webkit-dev mailing list
> >> > webkit-dev@lists.webkit.org
> >> > http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
> >> >
> >>
> >>
> >> ___
> >> webkit-dev mailing list
> >> webkit-dev@lists.webkit.org
> >> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
> >>
> > ___
> > webkit-dev mailing list
> > webkit-dev@lists.webkit.org
> > http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
> >
>
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] Question about JavaScriptCore's JSEvaluateScript function.

2009-03-02 Thread Zhe Su
Thanks for your answer. Then, in the callback function (such as
GetPropertyCallback), is it ok to use the original context pointer created
at beginning? Or the ctx passed to the callback must be used instead?

Regards
James Su

On Mon, Mar 2, 2009 at 4:52 PM, Zoltan Herczeg wrote:

> Hi,
>
> that is intended, since the context pointer is the current
> CallFrame/ExecState. WebKit creates its own stack (called RegisterFile) to
> run JavaScript. The stack base of the current function is pointed by
> CallFrame (similar to ebp in x86, or fp in ARM architectures). When you
> call a JS function, several important pointers are stored on the top of
> the stack, like return value, current code block, previous call frame, and
> these values are accessed through the CallFrame pointer. It is essential
> for JavaScriptCore, there is no workaround.
>
> Zoltan
>
> > Hi,
> >   Recently, I'm writing an application which uses JavaScriptCore to
> > execute
> > javascript code. I just encountered a problem when using JSEvaluateScript
> > function to evaluate a piece of script. When executing the script, some
> > callbacks provided by my code will be called, but I found that the
> context
> > received by callbacks are different than the context I created and passed
> > to
> > JSEvaluateScript function.
> >
> > Attached is a test program.
> > Below is the output of this program on my system (ubuntu 8.04 64bit with
> > latest webkit svn):
> >
> > Create context 0x7faf5d567e88, global object 0x7faf5d53
> > InitializeCallback(ctx=0x7faf5d567e88, obj=0x7faf5d532400)
> > HasPropertyCallback(ctx=0x7faf50c4b048, obj=0x7faf5d532400,
> > prop=prototype)
> > CallAsConstructorCallback(ctx=0x7faf50c4b0c0, obj=0x7faf5d532400)
> > InitializeCallback(ctx=0x7faf50c4b0c0, obj=0x7faf5d532440)
> > SetPropertyCallback(ctx=0x7faf50c4b048, obj=0x7faf5d532440, prop=prop1)
> > HasPropertyCallback(ctx=0x7faf50c4b048, obj=0x7faf5d532440, prop=prop1)
> > FinalizeCallback(obj=0x7faf5d532400)
> > FinalizeCallback(obj=0x7faf5d532440)
> >
> > You can see that, the callback functions received several different
> > context
> > pointers comparing to the one created at first beginning.
> >
> > Is it an intend behavior or a bug of webkit? And how can I avoid or
> > workaround this problem?
> >
> > Thanks a lot.
> >
> > James Su
> > ___
> > webkit-dev mailing list
> > webkit-dev@lists.webkit.org
> > http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
> >
>
>
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


[webkit-dev] Question about JavaScriptCore's JSEvaluateScript function.

2009-03-01 Thread Zhe Su
Hi,
  Recently, I'm writing an application which uses JavaScriptCore to execute
javascript code. I just encountered a problem when using JSEvaluateScript
function to evaluate a piece of script. When executing the script, some
callbacks provided by my code will be called, but I found that the context
received by callbacks are different than the context I created and passed to
JSEvaluateScript function.

Attached is a test program.
Below is the output of this program on my system (ubuntu 8.04 64bit with
latest webkit svn):

Create context 0x7faf5d567e88, global object 0x7faf5d53
InitializeCallback(ctx=0x7faf5d567e88, obj=0x7faf5d532400)
HasPropertyCallback(ctx=0x7faf50c4b048, obj=0x7faf5d532400, prop=prototype)
CallAsConstructorCallback(ctx=0x7faf50c4b0c0, obj=0x7faf5d532400)
InitializeCallback(ctx=0x7faf50c4b0c0, obj=0x7faf5d532440)
SetPropertyCallback(ctx=0x7faf50c4b048, obj=0x7faf5d532440, prop=prop1)
HasPropertyCallback(ctx=0x7faf50c4b048, obj=0x7faf5d532440, prop=prop1)
FinalizeCallback(obj=0x7faf5d532400)
FinalizeCallback(obj=0x7faf5d532440)

You can see that, the callback functions received several different context
pointers comparing to the one created at first beginning.

Is it an intend behavior or a bug of webkit? And how can I avoid or
workaround this problem?

Thanks a lot.

James Su
#include 
#include 
#include 

static std::string ConvertJSString(JSStringRef js_str) {
  size_t bufsize = JSStringGetMaximumUTF8CStringSize(js_str);
  char *buf = new char[bufsize];
  buf[JSStringGetUTF8CString(js_str, buf, bufsize)] = 0;
  std::string result(buf);
  delete buf;
  return result;
}

static void InitializeCallback(JSContextRef ctx, JSObjectRef object) {
  printf("InitializeCallback(ctx=%p, obj=%p)\n", ctx, object);
}

static void FinalizeCallback(JSObjectRef object) {
  printf("FinalizeCallback(obj=%p)\n", object);
}

static bool HasPropertyCallback(JSContextRef ctx,
JSObjectRef object,
JSStringRef property_name) {
  printf("HasPropertyCallback(ctx=%p, obj=%p, prop=%s)\n",
 ctx, object, ConvertJSString(property_name).c_str());
  return false;
}

static JSValueRef GetPropertyCallback(JSContextRef ctx,
  JSObjectRef object,
  JSStringRef property_name,
  JSValueRef* exception) {
  printf("GetPropertyCallback(ctx=%p, obj=%p, prop=%s)\n",
 ctx, object, ConvertJSString(property_name).c_str());
  return NULL;
}

static bool SetPropertyCallback(JSContextRef ctx,
JSObjectRef object,
JSStringRef property_name,
JSValueRef value,
JSValueRef* exception) {
  printf("SetPropertyCallback(ctx=%p, obj=%p, prop=%s)\n",
 ctx, object, ConvertJSString(property_name).c_str());
  return false;
}

// Only for custom registered classes.
static JSObjectRef CallAsConstructorCallback(JSContextRef ctx,
 JSObjectRef constructor,
 size_t argument_count,
 const JSValueRef arguments[],
 JSValueRef* exception) {
  printf("CallAsConstructorCallback(ctx=%p, obj=%p)\n", ctx, constructor);
  JSClassRef class_ref =
  static_cast(JSObjectGetPrivate(constructor));
  return JSObjectMake(ctx, class_ref, NULL);
}

static const JSClassDefinition
kClassDefinition = {
  0,// version, shall be 0
  kJSClassAttributeNone,// attributes
  "Hello",  // className, utf-8 encoded
  NULL, // parentClass
  NULL, // staticValues
  NULL, // staticFunctions
  InitializeCallback,
  FinalizeCallback,
  HasPropertyCallback,
  GetPropertyCallback,
  SetPropertyCallback,
  NULL, // deleteProperty
  NULL,
  NULL,
  CallAsConstructorCallback,
  NULL, // hasInstance,
  NULL, // convertToType
};

static const char kTestScript[] =
"var v1 = new Hello;\n"
"v1.prop1 = 123;\n"
"var v2 = v1.prop1;\n";

int main() {
  JSGlobalContextRef context = JSGlobalContextCreate(NULL);
  JSObjectRef global_object = JSContextGetGlobalObject(context);
  printf("Create context %p, global object %p\n", context, global_object);
  JSClassRef hello_class = JSClassCreate(&kClassDefinition);
  JSObjectRef class_object =
  JSObjectMake(context, hello_class, NULL);
  JSObjectSetPrivate(class_object, hello_class);

  JSStringRef class_name = JSStringCreateWithUTF8CString("Hello");
  JSObjectSetProperty(context, global_object, class_name, class_object, 0, NULL);
  JSStringRelease(class_name);

  JSStringRef test_script =
  JSStringCreateWithUTF8CString(kTestScript);
  JSEvaluateScript(context, te