GNOME Bugzilla – Bug 763640
Webkit initially unaware of window width and height
Last modified: 2018-06-29 23:48:03 UTC
This bug is not immediately visible in our current use of webkit. To see it, one would have to alter the code to generate a chart. Here's one way to discover this issue: 1. in src/report/report-system/html-barchart.scm replace (push "<div id=\"")(push chart-id)(push "\" style=\"width:") (push (gnc:html-barchart-width barchart)) (push "px;height:") (push (gnc:html-barchart-height barchart)) (push "px;\"></div>\n") with (push "<div id=\"")(push chart-id) (push "\" style=\"width: 100%;height:100%;\"></div>\n") 2. save the file and have gnucash use it (either rebuild gnucash, or copy the altered file over the original one wherever gnucash is installed) 3. open gnucash and generate any barchart report With the changes above, the chart should be drawn on the full width and height of the window (width: 100% and height: 100%) instead of at a fixed width and height as was done before. Instead however the chart is still rendered in a small area. By adding some debug code in javascript, I found the width is still 400px and webkit believes the body element is only one pixel wide. Opening the exact same generated html file in firefox on the other hand will render the chart properly full width/height. So the issue is not in the html code, but somewhere in webkit or how we are using webkit. I believe it's the latter, because when with the report still open in gnucash: 4. open the report options window, and change an arbitrary option, like the report name 5. hit ok Suddenly the chart gets rendered full width/height. So for some reason webkit doesn't know the full width/height yet, but after changing a report option, it does. As we are currently not depending on this, the bug is pretty low priority. However in the future we may be able to provide a better report experience if we can depend on full width/height support, like allowing users to draw charts in relative sizes instead of fixed sizes.
Update: is simple page reload fixes the chart size as well, so it's not even necessary to change a report option.
And one more data point: reducing the window width when the chart is full size, will not dynamically reduce the chart's size. So it will be too big to fit the window at this point. Again a page reload will fix that. So it appears we are not properly informing webkit of window size or resize events.
I had a look at this and created a pull request 107 on github for a possible fix. The main problem was that the webkit view is not realized before the report is created and so webkit does not know the view size to use when the page is created. To overcome this I moved the report creating to an idle add function along with some other changes. Bob
Bob's work has been merged into master (with backward compat changes on maint), so this bug can be closed. Thanks a lot!
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=763640. Please update any external references or bookmarks.