Bug 534120 - [Browser] Add api to retrieve width and height required to render HTML page without scrolling.
Summary: [Browser] Add api to retrieve width and height required to render HTML page w...
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.8   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2018-04-26 16:05 EDT by Leo Ufimtsev CLA
Modified: 2018-04-26 16:09 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Leo Ufimtsev CLA 2018-04-26 16:05:20 EDT
In this bug:
232501 – Browser#computeSize(..) does not compute size
https://bugs.eclipse.org/bugs/show_bug.cgi?id=232501

It was outlined that computeSize(..) doesn't retrieve the size necessary to render the inner HTML content.

However, implementing this api has some issues:
- HTML by design doesn't actually specify it's size, so we can't read the size based on raw html text. HTML is designed so that it can fit onto different types of screens (mobile, desktop, half-sized windows etc..).

- I hunted around webkit2 api and could not find any native api that retrieves the inner height/width of the inner html.

- One way we found to get this done is to wait until the page is loaded and then retrieve some properties by executing javascript: 
document.body.scrollWidth
document.body.scrollHeight

As per commit:
https://git.eclipse.org/r/#/c/121346/4/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet372.java

The problem with this approach is that it only works after the page is loaded, where as regular swt/widget api dictates that we need to know the size when the shell is being laid out. So while it works in a particular use case, it's not universal enough to adopt as api.

Another problem is that this doesn't work when javascript execution is disabled on the Browser widget. So having api that conditionally works when javascript is a bit flaky.

It would be nice to have this sort of API, but I can't think of an implementation that would result in a stable behavior across platforms with the current available API's. So for the time being, leaving as an open Enhancement request. ~Suggestions are welcome.