radkovo / CSSBox

CSSBox is an (X)HTML/CSS rendering engine written in pure Java. Its primary purpose is to provide a complete information about the rendered page suitable for further processing. However, it also allows displaying the rendered document.
http://cssbox.sourceforge.net/
GNU Lesser General Public License v3.0
234 stars 76 forks source link

No possibility to indicate that some images not loaded #38

Closed Dedrakot closed 7 years ago

Dedrakot commented 7 years ago

If image not loaded it will be usefull to know that result is not complete. Now in a ContentImage we just log error and possibly call ImageCache.putFailed(url).

Dedrakot commented 7 years ago

I am making some content caching. So I just don`t want to cache not complete pages. I don't know the best way to do it because I am not familiar with the code base. But for the moment I added ContentObserver and pass it through BoxFactory (commit in my forked repo). It will be grate if similar functionality will be added in future.

radkovo commented 7 years ago

I like the concept of ContentObserver. However, I have implemented a slightly different way of registering the observer to be consistent with the rest of the API. See this commit.

The observer is configured via the BrowserCanvas config, e.g.:

canvas.getConfig().setContentObserver(x);

similarly to the other configuration options.

I was not sure about your changes in ContentImage; I have just proposed a solution with minimal necessary changes. If this does not fit your use case, feel free to adapt the code and submit a pull request. Just please include only the necessary changes in the PR, no code reformatting and unrelated improvements. Thanks!

Once this is completed, I may create a new project release.

Dedrakot commented 7 years ago

Thanks and sorry for late answer. My changes in ContentImage not important and possibly not precisely correct and put observer through config is definitely better.