Raw images now have scrollbars in rev 3202

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.

Raw images now have scrollbars in rev 3202

Postby callum » Thu Dec 07, 2017 7:33 pm

Users of our Windows app that embeds CEF sometimes use it to load images.

In the version that uses CEF 2526, when the browser is set to the image size, the image loads and fills the space as expected.

In the version that uses CEF 3202 under the same conditions, the image appears but scroll bars also appear at the bottom/right sides. They have no effect (scroll thumb doesn't move). The image pixels appear in the same location - I.E. the image still fits inside the browser space exactly and the scroll bars are appearing needlessly.

I've suggested wrapping the image is a tiny fragment of CSS via a data URL to remove the scrollbars but that's not a viable solution for the hundreds of instances out there.

Is that a known issue or is there a flag I can set that will replicate the previous behavior?
callum
Expert
 
Posts: 323
Joined: Mon Feb 23, 2015 6:19 pm

Re: Raw images now have scrollbars in rev 3202

Postby callum » Fri Dec 08, 2017 3:39 pm

I notice if I set the browser size to say 1024 x 1024 in my code and visit one of the web pages that uses JavaScript to display what it thinks the browser size is (e.g. http://browsersize.com), I get 1019 x 1019 which of course explains the scroll bars.

I don't know (a) if those pages/ sizes are reliable and (b) if not getting *exactly* the size you ask for is expected - something to dig into at least.
callum
Expert
 
Posts: 323
Joined: Mon Feb 23, 2015 6:19 pm

Re: Raw images now have scrollbars in rev 3202

Postby magreenblatt » Fri Dec 08, 2017 4:31 pm

Are you using windowed or off-screen rendering? How does it behave in Google Chrome at the same version?
magreenblatt
Site Admin
 
Posts: 12383
Joined: Fri May 29, 2009 6:57 pm

Re: Raw images now have scrollbars in rev 3202

Postby callum » Fri Dec 08, 2017 4:43 pm

Using off screen rendering.

Not sure how to (easily at least) set desktop Chrome browser size to an exact size but in any case, if the image is bigger that the browser window, Chrome seems to resize and center it.
callum
Expert
 
Posts: 323
Joined: Mon Feb 23, 2015 6:19 pm

Re: Raw images now have scrollbars in rev 3202

Postby magreenblatt » Fri Dec 08, 2017 4:46 pm

Does the problem reproduce in cefclient? What if you use windowed mode instead?
magreenblatt
Site Admin
 
Posts: 12383
Joined: Fri May 29, 2009 6:57 pm

Re: Raw images now have scrollbars in rev 3202

Postby magreenblatt » Fri Dec 08, 2017 4:49 pm

Also check what value you're specifying for CefBrowserSettings.image_shrink_standalone_to_fit (--image-shrink-standalone-to-fit command-line flag).
magreenblatt
Site Admin
 
Posts: 12383
Joined: Fri May 29, 2009 6:57 pm

Re: Raw images now have scrollbars in rev 3202

Postby callum » Fri Dec 08, 2017 7:51 pm

I tried the same thing inside cefclient with --off-screen-rendering-enabled and it appears to behave like Chrome and shrink the image to fit the browser size.

Moreover, visiting http://browsersize.com inside cefclient reports the browser size matching the window size whereas mine is 5 pixels different.

I don't see a reference to --image-shrink-standalone-to-fit in cefclient but I added to my app both via CefSettings and the command line - in both cases it appeared to make no difference and I still see scroll bars - surprising, I figured that'd be a solution.

I thought maybe my code in my implementation of GetViewRect was too simple (just sets width/height in pixels) - the code in cefclient scales things but I confirmed with a breakpoint there that the scale factor is 1.000000 so I don't think that's it.

Will continue to dig.
callum
Expert
 
Posts: 323
Joined: Mon Feb 23, 2015 6:19 pm

Re: Raw images now have scrollbars in rev 3202

Postby callum » Fri Dec 08, 2017 8:07 pm

I figured it out and as usual, it was my fault. We have a requirement to allow page scaling with a linear factor and so I have some code in there to scale the page with a call to CefBrowserHost::SetZoomLevel() after I convert the linear scale we use.

Some kind of rounding error and removing the call to SetZoomLevel makes things work as expected.

Sigh!

Code: Select all
    // Convert "Dullahan page zoom" to "CEF/Chromium page zoom"
    // The value we pass into CEF::SetZoomLevel is not on a linear scale and described here:
    // http://www.magpcss.org/ceforum/viewtopic.php?f=6&t=11491
    // Dullahan scale: 1.0 is 1:1 scale, 2.0 is double, 0.5 is half etc.
    // CEF scale is more complex :) and from that post above, this is the best we can do for now:
    // note: CEF/Chromium max scale seems to be 5 x normal - values higher than that are ignored
    double cef_zoom_level = 5.46 * log(mRequestedPageZoom * 100.0) - 25.12;

    if (mBrowser.get() && mBrowser->GetHost())
    {
        // if the zoom has not been established (being careful for floating point issues)
        if (fabs(mBrowser->GetHost()->GetZoomLevel() - cef_zoom_level) > 0.000001)
        {
         mBrowser->GetHost()->SetZoomLevel(cef_zoom_level);
        }
    }
callum
Expert
 
Posts: 323
Joined: Mon Feb 23, 2015 6:19 pm


Return to Support Forum

Who is online

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