Fix being unable to scroll a message while remote images are loading.

* src/client/conversation-viewer/conversation-list-box.vala
  (EmailRow::on_size_allocate): Disable should-scroll when we have a
  valid height, not when loaded, so we stop pinning the scroll value and
  let users scroll, even when remote images loads are still running.

* src/client/components/client-web-view.vala (WebView): Replace is_loaded
  with has_valid_height, so we can if the body has been parsed and some
  content is visible. This still isn't perfect, but better than using
  load-ended. Fix call sites.
This commit is contained in:
Michael James Gratton 2017-01-03 21:48:02 +11:00
parent e002f0c320
commit 5e114cfcac
3 changed files with 9 additions and 11 deletions

View file

@ -134,7 +134,7 @@ public class ClientWebView : WebKit.WebView {
}
public bool is_loaded { get; private set; default = false; }
public bool has_valid_height = false;
public string allow_prefix { get; private set; default = ""; }
@ -215,11 +215,6 @@ public class ClientWebView : WebKit.WebView {
// XXX get the allow prefix from the extension somehow
this.decide_policy.connect(on_decide_policy);
this.load_changed.connect((web_view, event) => {
if (event == WebKit.LoadEvent.FINISHED) {
this.is_loaded = true;
}
});
this.web_process_crashed.connect(() => {
debug("Web process crashed");
return Gdk.EVENT_PROPAGATE;
@ -229,7 +224,10 @@ public class ClientWebView : WebKit.WebView {
(result) => {
try {
this.preferred_height = (int) WebKitUtil.to_number(result);
queue_resize();
if (this.preferred_height >= 1) {
this.has_valid_height = true;
queue_resize();
}
} catch (Geary.JS.Error err) {
debug("Could not get preferred height: %s", err.message);
} finally {

View file

@ -633,7 +633,7 @@ public class ConversationEmail : Gtk.Box {
view.web_view.notify["load-status"].connect(() => {
bool all_loaded = true;
message_view_iterator().foreach((view) => {
if (!view.web_view.is_loaded) {
if (!view.web_view.has_valid_height) {
all_loaded = false;
return false;
}

View file

@ -190,7 +190,7 @@ public class ConversationListBox : Gtk.ListBox {
public override void expand() {
this.is_expanded = true;
this.view.message_view_iterator().foreach((view) => {
if (!view.web_view.is_loaded) {
if (!view.web_view.has_valid_height) {
view.web_view.queue_resize();
}
return true;
@ -209,7 +209,7 @@ public class ConversationListBox : Gtk.ListBox {
// message has a non-trivial height, and then wait for it
// to be reallocated, so that it picks up the web_view's
// height.
if (view.primary_message.web_view.is_loaded) {
if (view.primary_message.web_view.has_valid_height) {
// Disable should_scroll after the message body has
// been loaded so we don't keep on scrolling later,
// like when the window has been resized.
@ -535,7 +535,7 @@ public class ConversationListBox : Gtk.ListBox {
// size of the body will be off, affecting the visibility
// of emails further down the conversation.
if (email_view.email.is_unread().is_certain() &&
conversation_message.web_view.is_loaded &&
conversation_message.web_view.has_valid_height &&
!email_view.is_manually_read) {
int body_top = 0;
int body_left = 0;