Let contents broadcast explicit status messages as well as announce that their internal status has been updated.

This commit is contained in:
Michael Drake 2012-08-15 19:00:50 +01:00
parent 5fb51a0fb7
commit e5374cc042
5 changed files with 36 additions and 18 deletions

View File

@ -169,6 +169,7 @@ nserror content_llcache_callback(llcache_handle *llcache,
(void) llcache_handle_get_source_data(llcache, &source_size); (void) llcache_handle_get_source_data(llcache, &source_size);
content_set_status(c, messages_get("Processing")); content_set_status(c, messages_get("Processing"));
msg_data.explicit_status_text = NULL;
content_broadcast(c, CONTENT_MSG_STATUS, msg_data); content_broadcast(c, CONTENT_MSG_STATUS, msg_data);
content_convert(c); content_convert(c);
@ -182,6 +183,7 @@ nserror content_llcache_callback(llcache_handle *llcache,
break; break;
case LLCACHE_EVENT_PROGRESS: case LLCACHE_EVENT_PROGRESS:
content_set_status(c, event->data.msg); content_set_status(c, event->data.msg);
msg_data.explicit_status_text = NULL;
content_broadcast(c, CONTENT_MSG_STATUS, msg_data); content_broadcast(c, CONTENT_MSG_STATUS, msg_data);
break; break;
} }

View File

@ -110,6 +110,10 @@ union content_msg_data {
int delay; int delay;
/** CONTENT_MSG_REFORMAT - Reformat should not cause a redraw */ /** CONTENT_MSG_REFORMAT - Reformat should not cause a redraw */
bool background; bool background;
/** CONTENT_MSG_STATUS - Status message update. If NULL, the content's
* internal status text has been updated, and listener should use
* content_get_status_message() */
const char *explicit_status_text;
/** CONTENT_MSG_DOWNLOAD - Low-level cache handle */ /** CONTENT_MSG_DOWNLOAD - Low-level cache handle */
struct llcache_handle *download; struct llcache_handle *download;
/** CONTENT_MSG_RFC5988_LINK - rfc5988 link data */ /** CONTENT_MSG_RFC5988_LINK - rfc5988 link data */

View File

@ -1323,7 +1323,15 @@ nserror browser_window_callback(hlcache_handle *c,
break; break;
case CONTENT_MSG_STATUS: case CONTENT_MSG_STATUS:
browser_window_set_status(bw, content_get_status_message(c)); if (event->data.explicit_status_text == NULL) {
/* Object content's status text updated */
browser_window_set_status(bw,
content_get_status_message(c));
} else {
/* Object content wants to set explicit message */
browser_window_set_status(bw,
event->data.explicit_status_text);
}
break; break;
case CONTENT_MSG_REFORMAT: case CONTENT_MSG_REFORMAT:

View File

@ -240,6 +240,7 @@ void html_finish_conversion(html_content *c)
/* convert xml tree to box tree */ /* convert xml tree to box tree */
LOG(("XML to box (%p)", c)); LOG(("XML to box (%p)", c));
content_set_status(&c->base, messages_get("Processing")); content_set_status(&c->base, messages_get("Processing"));
msg_data.explicit_status_text = NULL;
content_broadcast(&c->base, CONTENT_MSG_STATUS, msg_data); content_broadcast(&c->base, CONTENT_MSG_STATUS, msg_data);
exc = dom_document_get_document_element(c->document, (void *) &html); exc = dom_document_get_document_element(c->document, (void *) &html);
@ -1168,14 +1169,18 @@ html_object_callback(hlcache_handle *object,
LOG(("%d fetches active", c->base.active)); LOG(("%d fetches active", c->base.active));
content_add_error(&c->base, "?", 0); content_add_error(&c->base, "?", 0);
html_set_status(c, event->data.error);
content_broadcast(&c->base, CONTENT_MSG_STATUS, event->data);
html_object_failed(box, c, o->background); html_object_failed(box, c, o->background);
break; break;
case CONTENT_MSG_STATUS: case CONTENT_MSG_STATUS:
if (event->data.explicit_status_text == NULL) {
/* Object content's status text updated */
html_set_status(c, content_get_status_message(object)); html_set_status(c, content_get_status_message(object));
/* content_broadcast(&c->base, CONTENT_MSG_STATUS, 0); */ } else {
/* Object content wants to set explicit message */
content_broadcast(&c->base, CONTENT_MSG_STATUS,
event->data);
}
break; break;
case CONTENT_MSG_REFORMAT: case CONTENT_MSG_REFORMAT:
@ -1406,9 +1411,17 @@ html_convert_css_callback(hlcache_handle *css,
break; break;
case CONTENT_MSG_STATUS: case CONTENT_MSG_STATUS:
html_set_status(parent, content_get_status_message(css)); if (event->data.explicit_status_text == NULL) {
/* Object content's status text updated */
html_set_status(parent,
content_get_status_message(css));
content_broadcast(&parent->base, CONTENT_MSG_STATUS, content_broadcast(&parent->base, CONTENT_MSG_STATUS,
event->data); event->data);
} else {
/* Object content wants to set explicit message */
content_broadcast(&parent->base, CONTENT_MSG_STATUS,
event->data);
}
break; break;
default: default:

View File

@ -188,9 +188,6 @@ convert_script_async_cb(hlcache_handle *script,
break; break;
case CONTENT_MSG_STATUS: case CONTENT_MSG_STATUS:
html_set_status(parent, content_get_status_message(script));
content_broadcast(&parent->base, CONTENT_MSG_STATUS,
event->data);
break; break;
default: default:
@ -248,9 +245,6 @@ convert_script_defer_cb(hlcache_handle *script,
break; break;
case CONTENT_MSG_STATUS: case CONTENT_MSG_STATUS:
html_set_status(parent, content_get_status_message(script));
content_broadcast(&parent->base, CONTENT_MSG_STATUS,
event->data);
break; break;
default: default:
@ -345,9 +339,6 @@ convert_script_sync_cb(hlcache_handle *script,
break; break;
case CONTENT_MSG_STATUS: case CONTENT_MSG_STATUS:
html_set_status(parent, content_get_status_message(script));
content_broadcast(&parent->base, CONTENT_MSG_STATUS,
event->data);
break; break;
default: default: