예제 #1
0
static nserror
html_convert_css_callback(hlcache_handle *css,
                          const hlcache_event *event,
                          void *pw)
{
    html_content *parent = pw;
    unsigned int i;
    struct html_stylesheet *s;

    /* Find sheet */
    for (i = 0, s = parent->stylesheets;
            i != parent->stylesheet_count;
            i++, s++) {
        if (s->sheet == css)
            break;
    }

    assert(i != parent->stylesheet_count);

    switch (event->type) {
    case CONTENT_MSG_LOADING:
        break;

    case CONTENT_MSG_READY:
        break;

    case CONTENT_MSG_DONE:
        LOG(("done stylesheet slot %d '%s'", i,
             nsurl_access(hlcache_handle_get_url(css))));
        parent->base.active--;
        LOG(("%d fetches active", parent->base.active));
        break;

    case CONTENT_MSG_ERROR:
        LOG(("stylesheet %s failed: %s",
             nsurl_access(hlcache_handle_get_url(css)),
             event->data.error));
        hlcache_handle_release(css);
        s->sheet = NULL;
        parent->base.active--;
        LOG(("%d fetches active", parent->base.active));
        content_add_error(&parent->base, "?", 0);
        break;

    case CONTENT_MSG_STATUS:
        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,
                              event->data);
        } else {
            /* Object content wants to set explicit message */
            content_broadcast(&parent->base, CONTENT_MSG_STATUS,
                              event->data);
        }
        break;

    case CONTENT_MSG_POINTER:
        /* Really don't want this to continue after the switch */
        return NSERROR_OK;

    default:
        assert(0);
    }

    if (html_can_begin_conversion(parent)) {
        html_begin_conversion(parent);
    }

    return NSERROR_OK;
}
예제 #2
0
nserror favicon_callback(hlcache_handle *icon,
		const hlcache_event *event, void *pw)
{
	struct content *c = pw;

	switch (event->type) {
	case CONTENT_MSG_LOADING:
		/* check that the favicon is really a correct image type */
		if (content_get_type(icon) == CONTENT_UNKNOWN) {
			union content_msg_data msg_data;

			LOG(("%s is not a favicon", content_get_url(icon)));

			hlcache_handle_abort(icon);
			hlcache_handle_release(icon);
			c->data.html.favicon = NULL;
			c->active -= 1;

			content_add_error(c, "NotFavIco", 0);

			msg_data.error = messages_get("NotFavIco");
			content_broadcast(c, CONTENT_MSG_STATUS, msg_data);
		}
		break;

	case CONTENT_MSG_READY:
		break;
	case CONTENT_MSG_DONE:
		c->active -= 1;
		break;

	case CONTENT_MSG_ERROR:
		LOG(("favicon %s failed: %s", 
				content_get_url(icon), event->data.error));
		hlcache_handle_release(c->data.html.favicon);
		c->data.html.favicon = NULL;

		content_add_error(c, "?", 0);
		
		c->active -= 1;
		break;

	case CONTENT_MSG_STATUS:
		content_broadcast(c, CONTENT_MSG_STATUS, event->data);
		break;

	case CONTENT_MSG_REDRAW:
		/* Fall through */
	case CONTENT_MSG_REFRESH:
		/* Fall through */
	case CONTENT_MSG_REFORMAT:
		break;

	default:
		assert(0);
	}

	if (c->active == 0) {
		/* all objects have arrived */
		content__reformat(c, c->available_width, c->height);
		html_set_status(c, "");
		content_set_done(c);
	}
	
	return NSERROR_OK;
}