On Aug 3, 2011, at 9:34 AM, Andrew Davis wrote:
So, if i do something as mentioned below, it should work. Am i right?
On Wed, Aug 3, 2011 at 9:28 PM, Dan Bernstein <email@hidden>
On Aug 3, 2011, at 8:11 AM, Andrew Davis wrote:
To be very clear on what I am looking for, i have given the pseudo below.
So, on the html side, i have something like this...
var image=new Image();
var data = "">
return data to Obj-C method
Unfortunately, the answer is probably no. The “element is participating in rendering the document” criterion may not be satisfied until the next time WebKit updates the document’s layout, which normally won’t be until the end of the current runloop iteration. You can, however, force it to update the layout earlier, by querying a property that depends on layout. Doing this just before returning to Objective-C would probably work:
On the Obj-C side, i get the result as a WebScriptObject which inturn is a DOMHTMLImageElement object. So, i get the result as this object.
- (void) setImage:(DOMHTMLImageElement *)imageData
[imageData src] -> works fine (gives me the url that has been passed to the getImage in JS)
[imageData height] --> gives the correct height of the image
[imageData width] --> gives the correct width of the image
[imageData image] --> always nil.. (It is supposed to give me the image as a NSImage* and i was to use this for populating my ImageView)
The -image method only works when the element is participating in rendering the document. In particular, if the element is not in the DOM tree or is styled with display: none or has an ancestor with display: none, then -image will return nil.
So, this is exactly what I am doing and I need that image data for my use within Obj-C. Please let me know what i can do to get this done.
Note: I have this problem only when i try to get the image data. Strings work fine.
On Mon, Aug 1, 2011 at 5:14 PM, Andrew Davis <email@hidden>
I actually want the data as a NSImage object coz I am trying to load a image view with that data.
All the other API's of DOMHTMLImageElement work fine and give me the proper result. Only the image api doesn't work as expected. I am not sure what I am missing. I tried a sample html file and loaded the images on the page using the same js. They loaded fine. Only when I send it across to cocoa, image api returns nil all the time.
On Aug 1, 2011 5:07 PM, "Mike Abdullah" <email@hidden
> On 1 Aug 2011, at 12:23, Andrew Davis wrote:
>> If you meant NSURLConnection, I can do so. But I am trying it this way. I m trying to get as much data from the js. Thanks for giving me the other options. But, I m so focussed in getting it this way.
> Well seeing as you ask for the "image data", I'm trying to narrow down what you'd ideally like. An NSImage, or a lump of NSData? Perhaps something else? If you do get the -image API to work, and want raw data, you'll have to convert to JPEG/PNG yourself which probably isn't ideal.
> Also, NSURLConnection somewhat of a last resort. You should be able to consult the web view's resources first, as well as the URL cache.
Do not post admin requests to the list. They will be ignored.
Webkitsdk-dev mailing list (email@hidden
This email sent to email@hidden