Congratulations to our 2022 Qt Champions!

[SOLVED] QWebSettings::AutoLoadImages decision making

  • Hello,
    I'm trying to extend QWebSettings to make it possible to choose which images one wants to automatically load (e.g. load all images whose container is over 50x50 and that are PNGs, but no others).

    However, I can't seem to find where the decision process (load images or not) is happening.

    What has been done up to now:

    • first, I tried following the QWebView::load procedure to its origins. I ended up in WebCore::FrameLoader::load, which didn't have any references to QWebSettings
    • I then found a reference to QWebSettings* settings(), which used QWebPagePrivate to give the content. That passed through the QWebPageAdapter code, but the only checks done there were actually to see if plugins were enabled or not.
    • Finally, through lots of fgrepping, I managed to find out that QWebSettings outsource a lot of their data into WebCore::Settings, which has the loadsImagesAutomatically accessor function. However, no single reference to loadsImagesAutomatically was pertenent for my search. At that point, I decided to post here.

    Is there anyone that has had a similar issue, or does anyone know where specifically I shoud look? I'd imagine QWebSettings have been expanded greatly over time, and since the code compiles and doesn't load images if it's disabled, the reference must be in there somewhere...

  • Someone in irc told me that that isn't in the public API, but it must be somewhere within the Qt source, since the setting does affect actual behavior, right?

  • qtwebkit/Source/WebCore/loader/ImageLoader.cpp::ImageLoader::updateFromElement is the function I traced this to.
    Working through it and document->cachedResourceLoader()->autoLoadImages() was the proper path to segmenting the image selection.
    I don't have a clean solution/patch right now, since my goal was to have autoLoadImages() <- false ; to only block JPG/JPEGs. However, with this information, extending it should be far easier.

Log in to reply