RESOLVED FIXED 226320
[GTK] Try harder to find initial WebKitWebView size
https://bugs.webkit.org/show_bug.cgi?id=226320
Summary [GTK] Try harder to find initial WebKitWebView size
Alice Mikhaylenko
Reported 2021-05-27 02:48:01 PDT
See the patch.
Attachments
Patch (5.99 KB, patch)
2021-05-27 03:01 PDT, Alice Mikhaylenko
mcatanzaro: review+
cgarcia: commit-queue-
Patch (6.90 KB, patch)
2021-05-31 03:12 PDT, Alice Mikhaylenko
no flags
Alice Mikhaylenko
Comment 1 2021-05-27 03:01:44 PDT
EWS Watchlist
Comment 2 2021-05-27 03:02:47 PDT
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See https://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Alice Mikhaylenko
Comment 3 2021-05-27 03:03:39 PDT
Since we eliminate a 0,0 -> proper size change at the beginning, the patch further regresses https://bugs.webkit.org/show_bug.cgi?id=219202 as the view will not redraw on its own, so it depends on the patch from that bug.
Adrian Perez
Comment 4 2021-05-27 03:06:16 PDT
Patch looks sensible to me, but I would like another pair of eyes to take a look as well :)
Michael Catanzaro
Comment 5 2021-05-27 09:46:19 PDT
Comment on attachment 429860 [details] Patch Looks like there is some fallout: Unexpected failures (2) /WebKit2Gtk/TestWebKitWebView /webkit/WebKitWebView/snapshot /WebKit2Gtk/TestUIClient /webkit/WebKitWebView/window-properties
Michael Catanzaro
Comment 6 2021-05-27 09:50:05 PDT
Comment on attachment 429860 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=429860&action=review This looks good to me. I would add a comment though, to explain why we are doing this, why it's not going to return a perfect result but is better than (0, 0), and probably also link to this bug report so we don't remove it by mistake in the future. BTW it's already mentioned in the patch changelog, but I'll link to it here as well: this is to fix https://gitlab.gnome.org/GNOME/epiphany/-/issues/1532. > Source/WebKit/ChangeLog:10 > + size, which will be (0, 0) because the drawing area ist still null is > Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp:2376 > + // everything is fine and we'll just use that Nit: that. with a period. > Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp:2383 > + // through the hierarchy and try to find a parent with non-0 size Nit: size. with a period.
Carlos Garcia Campos
Comment 7 2021-05-27 10:23:39 PDT
Comment on attachment 429860 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=429860&action=review > Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp:2373 > +{ > +#if USE(GTK4) > + int width = gtk_widget_get_width(GTK_WIDGET(webViewBase)); > + int height = gtk_widget_get_height(GTK_WIDGET(webViewBase)); > +#else > + int width = gtk_widget_get_allocated_width(GTK_WIDGET(webViewBase)); > + int height = gtk_widget_get_allocated_height(GTK_WIDGET(webViewBase)); > +#endif I think we could add gtk_widget_get_width/height to GtkVersioning for gtk3 that returns allocated width/height. Assuming we always want the allocated size in gtk3 when width/height is queried in gtk4
Carlos Garcia Campos
Comment 8 2021-05-27 10:24:12 PDT
Comment on attachment 429860 [details] Patch Tests are not passing.
Alice Mikhaylenko
Comment 9 2021-05-27 10:28:16 PDT
(In reply to Carlos Garcia Campos from comment #7) > I think we could add gtk_widget_get_width/height to GtkVersioning for gtk3 > that returns allocated width/height. Assuming we always want the allocated > size in gtk3 when width/height is queried in gtk4 I mean, really we want `get_width()` in both cases but it doesn't exist in GTK3, so `get_allocated_width()` is the closest we have.
Alice Mikhaylenko
Comment 10 2021-05-28 02:53:13 PDT
(In reply to Carlos Garcia Campos from comment #8) > Comment on attachment 429860 [details] > Patch > > Tests are not passing. Great, they pass locally. I wonder what the difference is.
Alice Mikhaylenko
Comment 11 2021-05-31 00:30:02 PDT
Nevermind, they pass for GTK4 and fail for GTK3. That makes more sense.
Alice Mikhaylenko
Comment 12 2021-05-31 03:12:00 PDT
Created attachment 430194 [details] Patch Ok, one thing I hadn't known is that in GTK3 the default size is 1x1 and not 0x0. Another thing is I forgot about inspector which can take up a part of the web view size. Fixed both.
Alice Mikhaylenko
Comment 13 2021-05-31 03:12:50 PDT
> I think we could add gtk_widget_get_width/height to GtkVersioning for gtk3 that returns allocated width/height. Assuming we always want the allocated size in gtk3 when width/height is queried in gtk4 I did this at first, but then reverted it - the latest version of the patch uses get_width()/height() only once and since the default size differs between GTK 3 and 4 I have an #if there anyway.
Michael Catanzaro
Comment 14 2021-06-01 04:55:52 PDT
Comment on attachment 430194 [details] Patch Thanks!
EWS
Comment 15 2021-06-01 04:59:28 PDT
Committed r278301 (238338@main): <https://commits.webkit.org/238338@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 430194 [details].
Note You need to log in before you can comment on or make changes to this bug.