CefBrowser.SetSize() when window rendering is enabled?

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

CefBrowser.SetSize() when window rendering is enabled?

Postby Czarek » Sat Dec 29, 2012 12:34 pm

Hi,

From the documentation of CefBrowser.SetSize() method:

Set the size of the specified element. This method is only used when window rendering is disabled.


It is not true, I've tried calling this function when window rendering is enabled and it works. In my use case I'm trying to get capture image of the whole scrollable content on a webpage, I'm calling SetSize() and then GetImage(), but it doesn't work for the first time, the SetSize() method executes asynchrously (there is no mention about that in method documentation), only when I do something on a webpage to force the Paint event then the second call to GetImage() will get me desired result.

Is there some other way to force the paint event when window rendering is enabled?

May I rely on this behavior that this method also works when window rendering is enabled? Or may it break in the future? Creating a separate off-screen browser just to capture the image is probably not a good idea, as it won't work for ajax applications where it can't be guaranteed that the url from the on-screen browser will give me the same content when I load it in an off-screen browser.

Czarek.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: CefBrowser.SetSize() when window rendering is enabled?

Postby magreenblatt » Thu Jan 03, 2013 1:55 pm

Just to be clear, you're using SetSize to specify something other than the browser window size? Doesn't that result in visual artifacts?

It's intended to be used in off-screen rendering where there is no browser window to define the viewport size. It likely won't work with CEF3 which has a completely different implementation.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: CefBrowser.SetSize() when window rendering is enabled?

Postby Czarek » Wed Jan 09, 2013 10:11 pm

magreenblatt wrote:Just to be clear, you're using SetSize to specify something
other than the browser window size? Doesn't that result in visual artifacts?


I only noticed the scrollbars being drawn twice, one next to each other, but I think
that this was caused because the jquery code calculated document width without
scrollbars, besides that I didn't notice any "artifacts", everything seemed to
work fine, though I didn't look at it in details.

However, if you say that this is not supported I do not plan on using such feature,
but it would be a nice feature to be able to screenshot whole scrollable content
without the need to create a separate off-screen browser, as this won't work
in all cases, for example in ajax applications where the state of current page
is not represented by website's url.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 201 guests