From bd932d958b022c5fe02c76e976d3871d8651843b Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 26 Apr 2017 09:43:18 +0100 Subject: remove reformat from browser window operation table the reformat callback was completely unecessary and implementations appeared potentialy buggy. This rationalises the API and reduces the number of operations a frontend must provide. --- desktop/browser.c | 36 ++++++++++++++++++++++++++++++------ desktop/browser_private.h | 3 ++- desktop/gui_factory.c | 3 --- 3 files changed, 32 insertions(+), 10 deletions(-) (limited to 'desktop') diff --git a/desktop/browser.c b/desktop/browser.c index 45f300697..73a86c2e3 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -1780,6 +1780,27 @@ static void browser_window_destroy_children(struct browser_window *bw) } +/** + * internal scheduled reformat callback. + * + * scheduled reformat callback to allow reformats from unthreaded context. + * + * \param vbw The browser window to be reformatted + */ +static void scheduled_reformat(void *vbw) +{ + struct browser_window *bw = vbw; + int width; + int height; + nserror res; + + res = guit->window->get_dimensions(bw->window, &width, &height, false); + if (res == NSERROR_OK) { + browser_window_reformat(bw, false, width, height); + } +} + + /** * Release all memory associated with a browser window. * @@ -1809,8 +1830,8 @@ static void browser_window_destroy_internal(struct browser_window *bw) /* The ugly cast here is so the reformat function can be * passed a gui window pointer in its API rather than void* */ - LOG("Clearing schedule %p(%p)", guit->window->reformat, bw->window); - guit->misc->schedule(-1, (void(*)(void*))guit->window->reformat, bw->window); + LOG("Clearing reformat schedule for browser window %p", bw); + guit->misc->schedule(-1, scheduled_reformat, bw); /* If this brower window is not the root window, and has focus, unset * the root browser window's focus pointer. */ @@ -2574,13 +2595,16 @@ void browser_window_set_pointer(struct browser_window *bw, guit->window->set_pointer(root->window, gui_shape); } + /* exported function documented in netsurf/browser_window.h */ nserror browser_window_schedule_reformat(struct browser_window *bw) { - /* The ugly cast here is so the reformat function can be - * passed a gui window pointer in its API rather than void* - */ - guit->misc->schedule(0, (void(*)(void*))guit->window->reformat, bw->window); + if (bw->window == NULL) { + return NSERROR_BAD_PARAMETER; + } + + guit->misc->schedule(0, scheduled_reformat, bw); + return NSERROR_OK; } diff --git a/desktop/browser_private.h b/desktop/browser_private.h index 3e9b8467a..5a53e2f0b 100644 --- a/desktop/browser_private.h +++ b/desktop/browser_private.h @@ -17,7 +17,8 @@ * along with this program. If not, see . */ -/** \file +/** + * \file * Browser window private structure. */ diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c index e1de21ea1..559823d61 100644 --- a/desktop/gui_factory.c +++ b/desktop/gui_factory.c @@ -176,9 +176,6 @@ static nserror verify_window_register(struct gui_window_table *gwt) if (gwt->update_extent == NULL) { return NSERROR_BAD_PARAMETER; } - if (gwt->reformat == NULL) { - return NSERROR_BAD_PARAMETER; - } /* fill in the optional entries with defaults */ -- cgit v1.2.3