make content close check the content status itself
make content handler open and close return error status
This commit is contained in:
parent
f46b77160a
commit
c2fa6af0ff
|
@ -826,22 +826,32 @@ void content_broadcast_errorcode(struct content *c, nserror errorcode)
|
|||
*
|
||||
* \param h handle to content that has been opened
|
||||
* \param bw browser window containing the content
|
||||
* \param page content of type CONTENT_HTML containing h, or 0 if not an
|
||||
* \param page content of type CONTENT_HTML containing h, or NULL if not an
|
||||
* object within a page
|
||||
* \param params object parameters, or 0 if not an object
|
||||
* \param params object parameters, or NULL if not an object
|
||||
*
|
||||
* Calls the open function for the content.
|
||||
*/
|
||||
|
||||
void content_open(hlcache_handle *h, struct browser_window *bw,
|
||||
struct content *page, struct object_params *params)
|
||||
nserror
|
||||
content_open(hlcache_handle *h,
|
||||
struct browser_window *bw,
|
||||
struct content *page,
|
||||
struct object_params *params)
|
||||
{
|
||||
struct content *c = hlcache_handle_get_content(h);
|
||||
struct content *c;
|
||||
nserror res;
|
||||
|
||||
c = hlcache_handle_get_content(h);
|
||||
assert(c != 0);
|
||||
NSLOG(netsurf, INFO, "content %p %s", c,
|
||||
nsurl_access_log(llcache_handle_get_url(c->llcache)));
|
||||
if (c->handler->open != NULL)
|
||||
c->handler->open(c, bw, page, params);
|
||||
if (c->handler->open != NULL) {
|
||||
res = c->handler->open(c, bw, page, params);
|
||||
} else {
|
||||
res = NSERROR_OK;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
@ -851,14 +861,30 @@ void content_open(hlcache_handle *h, struct browser_window *bw,
|
|||
* Calls the close function for the content.
|
||||
*/
|
||||
|
||||
void content_close(hlcache_handle *h)
|
||||
nserror content_close(hlcache_handle *h)
|
||||
{
|
||||
struct content *c = hlcache_handle_get_content(h);
|
||||
assert(c != 0);
|
||||
struct content *c;
|
||||
nserror res;
|
||||
|
||||
c = hlcache_handle_get_content(h);
|
||||
if (c == NULL) {
|
||||
return NSERROR_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
if ((c->status != CONTENT_STATUS_READY) &&
|
||||
(c->status != CONTENT_STATUS_DONE)) {
|
||||
/* status is not read or done so nothing to do */
|
||||
return NSERROR_INVALID;
|
||||
}
|
||||
|
||||
NSLOG(netsurf, INFO, "content %p %s", c,
|
||||
nsurl_access_log(llcache_handle_get_url(c->llcache)));
|
||||
if (c->handler->close != NULL)
|
||||
c->handler->close(c);
|
||||
if (c->handler->close != NULL) {
|
||||
res = c->handler->close(c);
|
||||
} else {
|
||||
res = NSERROR_OK;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1506,4 +1532,3 @@ nserror content_abort(struct content *c)
|
|||
/* And for now, abort our llcache object */
|
||||
return llcache_handle_abort(c->llcache);
|
||||
}
|
||||
|
||||
|
|
|
@ -278,10 +278,10 @@ void content_mouse_action(struct hlcache_handle *h, struct browser_window *bw,
|
|||
bool content_keypress(struct hlcache_handle *h, uint32_t key);
|
||||
|
||||
|
||||
void content_open(struct hlcache_handle *h, struct browser_window *bw,
|
||||
nserror content_open(struct hlcache_handle *h, struct browser_window *bw,
|
||||
struct content *page, struct object_params *params);
|
||||
|
||||
void content_close(struct hlcache_handle *h);
|
||||
nserror content_close(struct hlcache_handle *h);
|
||||
|
||||
void content_clear_selection(struct hlcache_handle *h);
|
||||
|
||||
|
|
|
@ -16,8 +16,9 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Content factory (implementation)
|
||||
/**
|
||||
* \file
|
||||
* Content factory implementation
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
|
|
|
@ -60,9 +60,9 @@ struct content_handler {
|
|||
bool (*redraw)(struct content *c, struct content_redraw_data *data,
|
||||
const struct rect *clip,
|
||||
const struct redraw_context *ctx);
|
||||
void (*open)(struct content *c, struct browser_window *bw,
|
||||
nserror (*open)(struct content *c, struct browser_window *bw,
|
||||
struct content *page, struct object_params *params);
|
||||
void (*close)(struct content *c);
|
||||
nserror (*close)(struct content *c);
|
||||
void (*clear_selection)(struct content *c);
|
||||
char * (*get_selection)(struct content *c);
|
||||
nserror (*get_contextual_content)(struct content *c, int x, int y,
|
||||
|
|
|
@ -1774,7 +1774,7 @@ static nserror html_clone(const struct content *old, struct content **newc)
|
|||
* Handle a window containing a CONTENT_HTML being opened.
|
||||
*/
|
||||
|
||||
static void
|
||||
static nserror
|
||||
html_open(struct content *c,
|
||||
struct browser_window *bw,
|
||||
struct content *page,
|
||||
|
@ -1794,6 +1794,8 @@ html_open(struct content *c,
|
|||
html->selection_owner.none = true;
|
||||
|
||||
html_object_open_objects(html, bw);
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1801,7 +1803,7 @@ html_open(struct content *c,
|
|||
* Handle a window containing a CONTENT_HTML being closed.
|
||||
*/
|
||||
|
||||
static void html_close(struct content *c)
|
||||
static nserror html_close(struct content *c)
|
||||
{
|
||||
html_content *htmlc = (html_content *) c;
|
||||
|
||||
|
@ -1822,6 +1824,8 @@ static void html_close(struct content *c)
|
|||
|
||||
/* remove all object references from the html content */
|
||||
html_object_close_objects(htmlc);
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -16,8 +16,9 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Content for javascript (implementation)
|
||||
/**
|
||||
* \file
|
||||
* javascript content implementation
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
|
|
|
@ -1204,7 +1204,7 @@ textplain_redraw(struct content *c,
|
|||
/**
|
||||
* Handle a window containing a CONTENT_TEXTPLAIN being opened.
|
||||
*/
|
||||
static void
|
||||
static nserror
|
||||
textplain_open(struct content *c,
|
||||
struct browser_window *bw,
|
||||
struct content *page,
|
||||
|
@ -1216,13 +1216,15 @@ textplain_open(struct content *c,
|
|||
|
||||
/* text selection */
|
||||
selection_init(&text->sel, NULL, NULL);
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle a window containing a CONTENT_TEXTPLAIN being closed.
|
||||
*/
|
||||
static void textplain_close(struct content *c)
|
||||
static nserror textplain_close(struct content *c)
|
||||
{
|
||||
textplain_content *text = (textplain_content *) c;
|
||||
|
||||
|
@ -1231,6 +1233,8 @@ static void textplain_close(struct content *c)
|
|||
}
|
||||
|
||||
text->bw = NULL;
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -16,8 +16,9 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* High-level resource cache (interface)
|
||||
/**
|
||||
* \file
|
||||
* High-level resource cache interface
|
||||
*/
|
||||
|
||||
#ifndef NETSURF_CONTENT_HLCACHE_H_
|
||||
|
|
Loading…
Reference in New Issue