Gitweb links:

...log 
http://git.netsurf-browser.org/netsurf.git/shortlog/796bb0f652a5557f6903d96c6b7652a1565e6885
...commit 
http://git.netsurf-browser.org/netsurf.git/commit/796bb0f652a5557f6903d96c6b7652a1565e6885
...tree 
http://git.netsurf-browser.org/netsurf.git/tree/796bb0f652a5557f6903d96c6b7652a1565e6885

The branch, master has been updated
       via  796bb0f652a5557f6903d96c6b7652a1565e6885 (commit)
       via  5467d5e1572804a78c140180fc3387c0908ce7c7 (commit)
       via  3c264d63e60675cec987edea293316e8a40c9f08 (commit)
       via  52ee93597a168f635309e7feb6b0df1b6a11d2de (commit)
       via  be7aef9231443dba644438117106f52cf3e103f9 (commit)
       via  1e197432f89d6cee8440b5b37a29d249c46bd502 (commit)
       via  3e24dc831bc18d50ee565a3fc488f57956d498ed (commit)
       via  413ee474d2fff356a3cf2f245868ff01767d4079 (commit)
       via  72bd28d16eea3ba427a029a57818c658579f8ae8 (commit)
       via  bd932d958b022c5fe02c76e976d3871d8651843b (commit)
      from  31d98a1d2e5081ef2ca2d941f7e3b92344185399 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=796bb0f652a5557f6903d96c6b7652a1565e6885
commit 796bb0f652a5557f6903d96c6b7652a1565e6885
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>

    update framebuffer frontend to remove reformat API

diff --git a/frontends/framebuffer/gui.c b/frontends/framebuffer/gui.c
index 3de228a..0221a8e 100644
--- a/frontends/framebuffer/gui.c
+++ b/frontends/framebuffer/gui.c
@@ -1583,7 +1583,7 @@ resize_browser_widget(struct gui_window *gw, int x, int y,
                int width, int height)
 {
        fbtk_set_pos_and_size(gw->browser, x, y, width, height);
-       browser_window_reformat(gw->bw, false, width, height);
+       browser_window_schedule_reformat(gw->bw);
 }
 
 static void
@@ -1857,21 +1857,30 @@ gui_window_set_scroll(struct gui_window *gw, int sx, 
int sy)
 }
 
 
-static void
+/**
+ * Find the current dimensions of a framebuffer browser window content area.
+ *
+ * \param gw The gui window to measure content area of.
+ * \param width receives width of window
+ * \param height receives height of window
+ * \param scaled whether to return scaled values
+ * \return NSERROR_OK on sucess and width and height updated.
+ */
+static nserror
 gui_window_get_dimensions(struct gui_window *g,
                          int *width,
                          int *height,
                          bool scaled)
 {
-       float scale = browser_window_get_scale(g->bw);
-
        *width = fbtk_get_width(g->browser);
        *height = fbtk_get_height(g->browser);
 
        if (scaled) {
+               float scale = browser_window_get_scale(g->bw);
                *width /= scale;
                *height /= scale;
        }
+       return NSERROR_OK;
 }
 
 static void
@@ -2050,15 +2059,6 @@ gui_window_remove_caret(struct gui_window *g)
        }
 }
 
-static void framebuffer_window_reformat(struct gui_window *gw)
-{
-       /** @todo if we ever do zooming reformat should be implemented */
-       LOG("window:%p", gw);
-
-       /*
-         browser_window_reformat(gw->bw, false, width, height);
-       */
-}
 
 static struct gui_window_table framebuffer_window_table = {
        .create = gui_window_create,
@@ -2068,7 +2068,6 @@ static struct gui_window_table framebuffer_window_table = 
{
        .set_scroll = gui_window_set_scroll,
        .get_dimensions = gui_window_get_dimensions,
        .update_extent = gui_window_update_extent,
-       .reformat = framebuffer_window_reformat,
 
        .set_url = gui_window_set_url,
        .set_status = gui_window_set_status,


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=5467d5e1572804a78c140180fc3387c0908ce7c7
commit 5467d5e1572804a78c140180fc3387c0908ce7c7
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>

    update beos frontend to remove reformat API

diff --git a/frontends/beos/window.cpp b/frontends/beos/window.cpp
index 4db7b3c..f3d63da 100644
--- a/frontends/beos/window.cpp
+++ b/frontends/beos/window.cpp
@@ -911,28 +911,6 @@ void nsbeos_reflow_all_windows(void)
 }
 
 
-
-/**
- * callback from core to reformat a window.
- */
-static void beos_window_reformat(struct gui_window *g)
-{
-        if (g == NULL) {
-                return;
-        }
-
-        NSBrowserFrameView *view = g->view;
-        if (view && view->LockLooper()) {
-                BRect bounds = view->Bounds();
-                view->UnlockLooper();
-#warning XXX why - 1 & - 2 !???
-                browser_window_reformat(g->bw,
-                                        false,
-                                        bounds.Width() + 1 /* - 2*/,
-                                        bounds.Height() + 1);
-        }        
-}
-
 void nsbeos_window_destroy_browser(struct gui_window *g)
 {
        browser_window_destroy(g->bw);
@@ -1334,19 +1312,32 @@ static struct gui_clipboard_table clipboard_table = {
 
 struct gui_clipboard_table *beos_clipboard_table = &clipboard_table;
 
-static void gui_window_get_dimensions(struct gui_window *g, int *width, int 
*height,
-                              bool scaled)
+/**
+ * Find the current dimensions of a beos browser window content area.
+ *
+ * \param gw The gui window to measure content area of.
+ * \param width receives width of window
+ * \param height receives height of window
+ * \param scaled whether to return scaled values
+ * \return NSERROR_OK on sucess and width and height updated
+ *          else error code.
+ */
+static nserror
+gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
+                          bool scaled)
 {
-       if (g->view && g->view->LockLooper()) {
-               *width = g->view->Bounds().Width() + 1;
-               *height = g->view->Bounds().Height() + 1;
-               g->view->UnlockLooper();
-       }
-
-       if (scaled) {
-               *width /= g->scale;
-               *height /= g->scale;
-       }
+        if (g->view &&
+            g->view->LockLooper()) {
+                *width = g->view->Bounds().Width() + 1;
+                *height = g->view->Bounds().Height() + 1;
+                g->view->UnlockLooper();
+
+                if (scaled) {
+                        *width /= g->scale;
+                        *height /= g->scale;
+                }
+        }
+        return NSERROR_OK;
 }
 
 static struct gui_window_table window_table = {
@@ -1357,7 +1348,6 @@ static struct gui_window_table window_table = {
        gui_window_set_scroll,
        gui_window_get_dimensions,
        gui_window_update_extent,
-        beos_window_reformat,
 
        /* from scaffold */
        gui_window_set_title,


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=3c264d63e60675cec987edea293316e8a40c9f08
commit 3c264d63e60675cec987edea293316e8a40c9f08
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>

    update atari frontend to remove reformat API

diff --git a/frontends/atari/gui.c b/frontends/atari/gui.c
index ad568b7..cdea953 100644
--- a/frontends/atari/gui.c
+++ b/frontends/atari/gui.c
@@ -293,25 +293,27 @@ void gui_window_destroy(struct gui_window *gw)
 }
 
 /**
- * Find the current dimensions of a browser window's content area.
+ * Find the current dimensions of a atari browser window content area.
  *
- * \param w     gui_window to measure
- * \param width         receives width of window
+ * \param gw The gui window to measure content area of.
+ * \param width receives width of window
  * \param height receives height of window
  * \param scaled whether to return scaled values
+ * \return NSERROR_OK on sucess and width and height updated
+ *          else error code.
  */
-static void
-gui_window_get_dimensions(struct gui_window *w,
+static nserror
+gui_window_get_dimensions(struct gui_window *gw,
                          int *width,
                          int *height,
                          bool scaled)
 {
-    if (w == NULL)
-       return;
     GRECT rect;
-    window_get_grect(w->root, BROWSER_AREA_CONTENT, &rect);
+    window_get_grect(gw->root, BROWSER_AREA_CONTENT, &rect);
     *width = rect.g_w;
     *height = rect.g_h;
+
+    return NSERROR_OK;
 }
 
 /**
@@ -375,16 +377,6 @@ void atari_window_set_status(struct gui_window *w, const 
char *text)
        window_set_stauts(w->root, (char*)text);
 }
 
-static void atari_window_reformat(struct gui_window *gw)
-{
-    int width = 0, height = 0;
-
-    if (gw != NULL) {
-       gui_window_get_dimensions(gw, &width, &height, true);
-       browser_window_reformat(gw->browser->bw, false, width, height);
-    }
-}
-
 
 /**
  * Invalidates an area of an atari browser window
@@ -1063,7 +1055,6 @@ static struct gui_window_table atari_window_table = {
     .set_scroll = gui_window_set_scroll,
     .get_dimensions = gui_window_get_dimensions,
     .update_extent = gui_window_update_extent,
-    .reformat = atari_window_reformat,
 
     .set_title = gui_window_set_title,
     .set_url = gui_window_set_url,


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=52ee93597a168f635309e7feb6b0df1b6a11d2de
commit 52ee93597a168f635309e7feb6b0df1b6a11d2de
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>

    update monkey frontend to remove reformat API

diff --git a/frontends/monkey/browser.c b/frontends/monkey/browser.c
index 7cd3d07..8d5154e 100644
--- a/frontends/monkey/browser.c
+++ b/frontends/monkey/browser.c
@@ -61,15 +61,6 @@ monkey_find_window_by_num(uint32_t win_num)
   return ret;
 }
 
-
-/**
- * callback from core to reformat a window.
- */
-static void monkey_window_reformat(struct gui_window *gw)
-{
-       browser_window_reformat(gw->bw, false, gw->width, gw->height);
-}
-
 void
 monkey_kill_browser_windows(void)
 {
@@ -118,7 +109,16 @@ gui_window_set_title(struct gui_window *g, const char 
*title)
   fprintf(stdout, "WINDOW TITLE WIN %u STR %s\n", g->win_num, title);
 }
 
-static void
+/**
+ * Find the current dimensions of a monkey browser window content area.
+ *
+ * \param gw The gui window to measure content area of.
+ * \param width receives width of window
+ * \param height receives height of window
+ * \param scaled whether to return scaled values
+ * \return NSERROR_OK on sucess and width and height updated.
+ */
+static nserror
 gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
                           bool scaled)
 {
@@ -126,6 +126,8 @@ gui_window_get_dimensions(struct gui_window *g, int *width, 
int *height,
           g->win_num, g->width, g->height);
   *width = g->width;
   *height = g->height;
+
+  return NSERROR_OK;
 }
 
 static void
@@ -515,7 +517,6 @@ static struct gui_window_table window_table = {
        .set_scroll = gui_window_set_scroll,
        .get_dimensions = gui_window_get_dimensions,
        .update_extent = gui_window_update_extent,
-       .reformat = monkey_window_reformat,
 
        .set_title = gui_window_set_title,
        .set_url = gui_window_set_url,


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=be7aef9231443dba644438117106f52cf3e103f9
commit be7aef9231443dba644438117106f52cf3e103f9
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>

    update riscos frontend to remove reformat API

diff --git a/frontends/riscos/window.c b/frontends/riscos/window.c
index 6b5089c..1d5c093 100644
--- a/frontends/riscos/window.c
+++ b/frontends/riscos/window.c
@@ -927,16 +927,20 @@ static void gui_window_scroll_visible(struct gui_window 
*g, int x0, int y0, int
  * \param height receives height of window
  * \param scaled whether to return scaled values
  */
-
-static void gui_window_get_dimensions(struct gui_window *g, int *width, int 
*height, bool scaled)
+static nserror
+gui_window_get_dimensions(struct gui_window *gw,
+                         int *width, int *height,
+                         bool scaled)
 {
        /* use the cached window sizes */
-       *width = g->old_width / 2;
-       *height = g->old_height / 2;
+       *width = gw->old_width / 2;
+       *height = gw->old_height / 2;
+
        if (scaled) {
-               *width /= g->scale;
-               *height /= g->scale;
+               *width /= gw->scale;
+               *height /= gw->scale;
        }
+       return NSERROR_OK;
 }
 
 
@@ -4207,18 +4211,6 @@ void ro_gui_window_update_boxes(void)
 
 
 /**
- * callback from core to reformat a window.
- */
-static void riscos_window_reformat(struct gui_window *gw)
-{
-       if (gw != NULL) {
-               browser_window_reformat(gw->bw, false,
-                                       gw->old_width / 2,
-                                       gw->old_height / 2);
-       }
-}
-
-/**
  * Destroy all browser windows.
  */
 
@@ -4986,7 +4978,6 @@ static struct gui_window_table window_table = {
        .set_scroll = gui_window_set_scroll,
        .get_dimensions = gui_window_get_dimensions,
        .update_extent = gui_window_update_extent,
-       .reformat = riscos_window_reformat,
 
        .set_title = gui_window_set_title,
        .set_url = ro_gui_window_set_url,


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=1e197432f89d6cee8440b5b37a29d249c46bd502
commit 1e197432f89d6cee8440b5b37a29d249c46bd502
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>

    update amiga frontend to remove reformat API

diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index a6164db..bf3102a 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -1643,15 +1643,26 @@ static void ami_gui_menu_update_all(void)
        } while((node = nnode));
 }
 
-static void gui_window_get_dimensions(struct gui_window *g,
+/**
+ * Find the current dimensions of a amiga browser window content area.
+ *
+ * \param gw The gui window to measure content area of.
+ * \param width receives width of window
+ * \param height receives height of window
+ * \param scaled whether to return scaled values
+ * \return NSERROR_OK on sucess and width and height updated
+ *          else error code.
+ */
+static nserror gui_window_get_dimensions(struct gui_window *gw,
                int *restrict width, int *restrict height, bool scaled)
 {
        struct IBox *bbox;
-       if(!g) return;
+       nserror res;
 
-       if(ami_gui_get_space_box((Object *)g->shared->objects[GID_BROWSER], 
&bbox) != NSERROR_OK) {
+       res = ami_gui_get_space_box((Object *)gw->shared->objects[GID_BROWSER], 
&bbox);
+       if(res != NSERROR_OK) {
                amiga_warn_user("NoMemory", "");
-               return;
+               return res;
        }
 
        *width = bbox->Width;
@@ -1659,11 +1670,12 @@ static void gui_window_get_dimensions(struct gui_window 
*g,
 
        ami_gui_free_space_box(bbox);
 
-       if(scaled)
-       {
-               *width /= g->scale;
-               *height /= g->scale;
+       if(scaled) {
+               *width /= gw->scale;
+               *height /= gw->scale;
        }
+
+       return NSERROR_OK;
 }
 
 /* Add a horizontal scroller, if not already present
@@ -4828,26 +4840,6 @@ bool ami_gui_window_update_box_deferred_check(struct 
MinList *deferred_rects,
 }
 
 
-/**
- * callback from core to reformat a window.
- */
-static void amiga_window_reformat(struct gui_window *gw)
-{
-       struct IBox *bbox;
-
-       LOG("reformat window %p", gw);
-
-       if (gw != NULL) {
-               if(ami_gui_get_space_box((Object 
*)gw->shared->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
-                       amiga_warn_user("NoMemory", "");
-                       return;
-               }
-               browser_window_reformat(gw->bw, false, bbox->Width, 
bbox->Height);
-               gw->shared->redraw_scroll = false;
-               ami_gui_free_space_box(bbox);
-       }
-}
-
 static void ami_do_redraw(struct gui_window_2 *gwin)
 {
        ULONG hcurrent,vcurrent,xoffset,yoffset,width=800,height=600;
@@ -5576,7 +5568,6 @@ static struct gui_window_table amiga_window_table = {
        .set_scroll = gui_window_set_scroll,
        .get_dimensions = gui_window_get_dimensions,
        .update_extent = gui_window_update_extent,
-       .reformat = amiga_window_reformat,
 
        .set_icon = gui_window_set_icon,
        .set_title = gui_window_set_title,


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=3e24dc831bc18d50ee565a3fc488f57956d498ed
commit 3e24dc831bc18d50ee565a3fc488f57956d498ed
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>

    update windows frontend to remove reformat

diff --git a/frontends/windows/window.c b/frontends/windows/window.c
index c0af46f..829067b 100644
--- a/frontends/windows/window.c
+++ b/frontends/windows/window.c
@@ -1236,7 +1236,7 @@ nsws_window_command(HWND hwnd,
                        browser_window_debug(gw->bw, CONTENT_DEBUG_REDRAW);
                        /* TODO: This should only redraw, not reformat.
                         * (Layout doesn't change, so reformat is a waste of 
time) */
-                       browser_window_reformat(gw->bw, false, gw->width, 
gw->height);
+                       browser_window_schedule_reformat(gw->bw);
                }
                break;
 
@@ -1548,18 +1548,17 @@ static void win32_window_destroy(struct gui_window *w)
  * \param height receives height of window
  * \param scaled whether to return scaled values
  */
-static void
+static nserror
 win32_window_get_dimensions(struct gui_window *gw,
                            int *width, int *height,
                            bool scaled)
 {
-       if (gw == NULL)
-               return;
-
-       LOG("get dimensions %p w=%d h=%d", gw, gw->width, gw->height);
-
        *width = gw->width;
        *height = gw->height;
+
+       LOG("gw:%p w=%d h=%d", gw, *width, *height);
+
+       return NSERROR_OK;
 }
 
 
@@ -1576,19 +1575,6 @@ static void win32_window_update_extent(struct gui_window 
*w)
 
 
 /**
- * callback from core to reformat a win32 window.
- *
- * \param gw The win32 gui window to reformat.
- */
-static void win32_window_reformat(struct gui_window *gw)
-{
-       if (gw != NULL) {
-               browser_window_reformat(gw->bw, false, gw->width, gw->height);
-       }
-}
-
-
-/**
  * set win32 browser window title
  *
  * \param w the win32 gui window.
@@ -1773,7 +1759,6 @@ static struct gui_window_table window_table = {
        .set_scroll = win32_window_set_scroll,
        .get_dimensions = win32_window_get_dimensions,
        .update_extent = win32_window_update_extent,
-       .reformat = win32_window_reformat,
 
        .set_title = win32_window_set_title,
        .set_url = win32_window_set_url,


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=413ee474d2fff356a3cf2f245868ff01767d4079
commit 413ee474d2fff356a3cf2f245868ff01767d4079
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>

    update cocoa frontend with reformat API change

diff --git a/frontends/cocoa/BrowserView.h b/frontends/cocoa/BrowserView.h
index c626c8c..1d02fb0 100644
--- a/frontends/cocoa/BrowserView.h
+++ b/frontends/cocoa/BrowserView.h
@@ -47,7 +47,6 @@
 - (void) removeCaret;
 - (void) addCaretAt: (NSPoint) point height: (CGFloat) height;
 
-- (void) reformat;
 - (void) updateHistory;
 
 @end
diff --git a/frontends/cocoa/BrowserView.m b/frontends/cocoa/BrowserView.m
index f1259d8..e6e8e0b 100644
--- a/frontends/cocoa/BrowserView.m
+++ b/frontends/cocoa/BrowserView.m
@@ -43,8 +43,6 @@
 - (void) scrollVertical: (CGFloat) amount;
 - (CGFloat) pageScroll;
 
-- (void) reformat;
-
 - (void) popUpContextMenuForEvent: (NSEvent *) event;
 
 - (IBAction) cmOpenURLInTab: (id) sender;
@@ -505,14 +503,6 @@ static browser_mouse_state cocoa_mouse_flags_for_event( 
NSEvent *evt )
         return NSHeight( [[self superview] frame] ) - [[self 
enclosingScrollView] pageScroll];
 }
 
-- (void) reformat
-{
-        NSRect size = [[self superview] frame];
-        browser_window_reformat(browser,
-                                false,
-                                cocoa_pt_to_px( NSWidth( size ) ),
-                                cocoa_pt_to_px( NSHeight( size ) ) );
-}
 
 - (void) popUpContextMenuForEvent: (NSEvent *) event
 {
diff --git a/frontends/cocoa/gui.m b/frontends/cocoa/gui.m
index 7e180fa..1bf191f 100644
--- a/frontends/cocoa/gui.m
+++ b/frontends/cocoa/gui.m
@@ -129,18 +129,19 @@ static void gui_window_set_scroll(struct gui_window *g, 
int sx, int sy)
        [[(BrowserViewController *)g browserView] scrollPoint: cocoa_point( sx, 
sy )];
 }
 
-/**
- * callback from core to reformat a window.
- */
-static void cocoa_window_reformat(struct gui_window *gw)
-{
-       if (gw != NULL) {
-                [[(BrowserViewController *)gw browserView] reformat ];
-       }
-}
 
 
-static void gui_window_get_dimensions(struct gui_window *g,
+/**
+ * Find the current dimensions of a cocoa browser window content area.
+ *
+ * \param gw The gui window to measure content area of.
+ * \param width receives width of window
+ * \param height receives height of window
+ * \param scaled whether to return scaled values
+ * \return NSERROR_OK on sucess and width and height updated
+ *          else error code.
+ */
+static nserror gui_window_get_dimensions(struct gui_window *g,
                                       int *width, int *height,
                                       bool scaled)
 {
@@ -154,6 +155,8 @@ static void gui_window_get_dimensions(struct gui_window *g,
        }
        *width = cocoa_pt_to_px( NSWidth( frame ) );
        *height = cocoa_pt_to_px( NSHeight( frame ) );
+
+        return NSERROR_OK;
 }
 
 static void gui_window_update_extent(struct gui_window *g)
@@ -304,7 +307,6 @@ static struct gui_window_table window_table = {
        .set_scroll = gui_window_set_scroll,
        .get_dimensions = gui_window_get_dimensions,
        .update_extent = gui_window_update_extent,
-       .reformat = cocoa_window_reformat,
 
        .set_title = gui_window_set_title,
        .set_url = gui_window_set_url,


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=72bd28d16eea3ba427a029a57818c658579f8ae8
commit 72bd28d16eea3ba427a029a57818c658579f8ae8
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>

    update GTK frontend for reformat API change

diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c
index 25b975e..ecd6d0a 100644
--- a/frontends/gtk/window.c
+++ b/frontends/gtk/window.c
@@ -895,21 +895,6 @@ void nsgtk_reflow_all_windows(void)
 }
 
 
-/**
- * callback from core to reformat a window.
- */
-static void nsgtk_window_reformat(struct gui_window *gw)
-{
-       GtkAllocation alloc;
-
-       if (gw != NULL) {
-               /** @todo consider gtk_widget_get_allocated_width() */
-               nsgtk_widget_get_allocation(GTK_WIDGET(gw->layout), &alloc);
-
-               browser_window_reformat(gw->bw, false, alloc.width, 
alloc.height);
-       }
-}
-
 void nsgtk_window_destroy_browser(struct gui_window *gw)
 {
        /* remove tab */
@@ -1203,24 +1188,37 @@ static void gui_window_place_caret(struct gui_window 
*g, int x, int y, int heigh
 }
 
 
-static void gui_window_get_dimensions(struct gui_window *g, int *width, int 
*height,
-                              bool scaled)
+/**
+ * Find the current dimensions of a GTK browser window content area.
+ *
+ * \param gw The gui window to measure content area of.
+ * \param width receives width of window
+ * \param height receives height of window
+ * \param scaled whether to return scaled values
+ * \return NSERROR_OK on sucess and width and height updated
+ *          else error code.
+ */
+static nserror
+gui_window_get_dimensions(struct gui_window *gw,
+                         int *width, int *height,
+                         bool scaled)
 {
        GtkAllocation alloc;
 
-       /* @todo consider gtk_widget_get_allocated_width() */
-       nsgtk_widget_get_allocation(GTK_WIDGET(g->layout), &alloc);
+       /** @todo consider gtk_widget_get_allocated_width() */
+       nsgtk_widget_get_allocation(GTK_WIDGET(gw->layout), &alloc);
 
        *width = alloc.width;
        *height = alloc.height;
 
        if (scaled) {
-               float scale = browser_window_get_scale(g->bw);
+               float scale = browser_window_get_scale(gw->bw);
                *width /= scale;
                *height /= scale;
        }
-       LOG("width: %i", *width);
-       LOG("height: %i", *height);
+       LOG("gw:%p width:%i height:%i", gw, *width, *height);
+
+       return NSERROR_OK;
 }
 
 static void gui_window_start_selection(struct gui_window *g)
@@ -1321,7 +1319,6 @@ static struct gui_window_table window_table = {
        .set_scroll = gui_window_set_scroll,
        .get_dimensions = gui_window_get_dimensions,
        .update_extent = gui_window_update_extent,
-       .reformat = nsgtk_window_reformat,
 
        .set_icon = gui_window_set_icon,
        .set_status = gui_window_set_status,


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=bd932d958b022c5fe02c76e976d3871d8651843b
commit bd932d958b022c5fe02c76e976d3871d8651843b
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>

    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.

diff --git a/desktop/browser.c b/desktop/browser.c
index 45f3006..73a86c2 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -1781,6 +1781,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.
  *
  * \param  bw  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 3e9b846..5a53e2f 100644
--- a/desktop/browser_private.h
+++ b/desktop/browser_private.h
@@ -17,7 +17,8 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-/** \file
+/**
+ * \file
  * Browser window private structure.
  */
 
diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c
index e1de21e..559823d 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 */
diff --git a/include/netsurf/browser_window.h b/include/netsurf/browser_window.h
index 858d4ae..c56cf55 100644
--- a/include/netsurf/browser_window.h
+++ b/include/netsurf/browser_window.h
@@ -296,16 +296,23 @@ void browser_window_reload(struct browser_window *bw, 
bool all);
  */
 void browser_window_destroy(struct browser_window *bw);
 
+
 /**
  * Reformat a browser window contents to a new width or height.
  *
+ * This API is not safe to call from all contexts and care must be used.
+ *
+ * \warning This API is generally only useful within the browser core
+ * and is only exposed for historical reasons. A frontend almost
+ * certianly actually wants browser_window_schedule_reformat() and not
+ * this.
+ *
  * \param bw         The browser window to reformat.
  * \param background Reformat in the background.
  * \param width      new width
  * \param height     new height
  */
-void browser_window_reformat(struct browser_window *bw, bool background,
-               int width, int height);
+void browser_window_reformat(struct browser_window *bw, bool background, int 
width, int height);
 
 
 /**
@@ -411,6 +418,7 @@ void browser_window_mouse_click(struct browser_window *bw,
 void browser_window_mouse_track(struct browser_window *bw,
                browser_mouse_state mouse, int x, int y);
 
+
 /**
  * Locate a browser window in the specified stack according.
  *
@@ -423,21 +431,28 @@ struct browser_window *browser_window_find_target(
                struct browser_window *bw, const char *target,
                browser_mouse_state mouse);
 
+
 /**
- * Cause the frontends reformat entry to be called in safe context.
+ * Reformat the browser window contents in a safe context.
  *
- * The browser_window_reformat call cannot safely be called from some
- * contexts, this call allows for the reformat to happen from a safe
+ * The browser_window_reformat() call cannot safely be called from some
+ * contexts, This interface allows for the reformat to happen from a safe
  * top level context.
  *
- * The callback is frontend provided as the context information (size
- * etc.) about the windowing toolkit is only available to the
- * frontend.
+ * The reformat uses the window table get_dimensions() callback as the
+ * correct viewport dimensions are only available to the frontend.
+ *
+ * \param bw The browser window to reformat the content of.
+ * \return NSERROR_OK on success else appropriate error code.
  */
 nserror browser_window_schedule_reformat(struct browser_window *bw);
 
 
-
+/**
+ * callback for select menu widget
+ *
+ * \todo This API needs investigating
+ */
 void browser_select_menu_callback(void *client_data,
                int x, int y, int width, int height);
 
diff --git a/include/netsurf/window.h b/include/netsurf/window.h
index 434a795..b9a6863 100644
--- a/include/netsurf/window.h
+++ b/include/netsurf/window.h
@@ -23,8 +23,8 @@
  * operations.
  */
 
-#ifndef _NETSURF_WINDOW_H_
-#define _NETSURF_WINDOW_H_
+#ifndef NETSURF_WINDOW_H
+#define NETSURF_WINDOW_H
 
 typedef enum gui_save_type {
        GUI_SAVE_SOURCE,
@@ -50,10 +50,13 @@ typedef enum {
        GDRAGGING_OTHER
 } gui_drag_type;
 
+/**
+ * Window creation control flags.
+ */
 typedef enum {
-       GW_CREATE_NONE          = 0,            /* New window */
-       GW_CREATE_CLONE         = (1 << 0),     /* Clone existing window */
-       GW_CREATE_TAB           = (1 << 1)      /* In same window as existing */
+       GW_CREATE_NONE = 0, /**< New window */
+       GW_CREATE_CLONE = (1 << 0), /**< Clone existing window */
+       GW_CREATE_TAB = (1 << 1) /**< In same window as existing */
 } gui_window_create_flags;
 
 struct browser_window;
@@ -90,6 +93,7 @@ struct gui_window_table {
                        struct gui_window *existing,
                        gui_window_create_flags flags);
 
+
        /**
         * Destroy previously created gui window
         *
@@ -97,6 +101,7 @@ struct gui_window_table {
         */
        void (*destroy)(struct gui_window *gw);
 
+
        /**
         * Invalidate an area of a window.
         *
@@ -116,6 +121,7 @@ struct gui_window_table {
         */
        nserror (*invalidate)(struct gui_window *g, const struct rect *rect);
 
+
        /**
         * Get the scroll position of a browser window.
         *
@@ -126,6 +132,7 @@ struct gui_window_table {
         */
        bool (*get_scroll)(struct gui_window *g, int *sx, int *sy);
 
+
        /**
         * Set the scroll position of a browser window.
         *
@@ -135,18 +142,24 @@ struct gui_window_table {
         */
        void (*set_scroll)(struct gui_window *g, int sx, int sy);
 
+
        /**
         * Find the current dimensions of a browser window's content area.
         *
-        * @todo The implementations of this are buggy and its only
-        * used from frames code.
+        * This is used to determine the actual available drawing size
+        * in pixels. This is used to allow contents that can be
+        * dynamicaly reformatted, such as HTML, to better use the
+        * available space.
         *
-        * \param g      gui_window to measure
-        * \param width  receives width of window
+        * \param gw The gui window to measure content area of.
+        * \param width receives width of window
         * \param height receives height of window
         * \param scaled whether to return scaled values
+        * \return NSERROR_OK on sucess and width and height updated
+        *          else error code.
         */
-       void (*get_dimensions)(struct gui_window *g, int *width, int *height, 
bool scaled);
+       nserror (*get_dimensions)(struct gui_window *gw, int *width, int 
*height, bool scaled);
+
 
        /**
         * Update the extent of the inside of a browser window to that of the
@@ -159,18 +172,6 @@ struct gui_window_table {
         */
        void (*update_extent)(struct gui_window *g);
 
-       /**
-        * Reformat a window.
-        *
-        * This is used to perform reformats when the page contents
-        * require reformatting. The reformat is requested using
-        * browser_window_schedule_reformat and occurs via a scheduled
-        * callback hence from top level context.
-        *
-        * \param g gui_window to reformat.
-        */
-       void (*reformat)(struct gui_window *g);
-
 
        /* Optional entries */
 


-----------------------------------------------------------------------

Summary of changes:
 desktop/browser.c                |   36 +++++++++++++++++++----
 desktop/browser_private.h        |    3 +-
 desktop/gui_factory.c            |    3 --
 frontends/amiga/gui.c            |   49 +++++++++++++------------------
 frontends/atari/gui.c            |   29 +++++++-----------
 frontends/beos/window.cpp        |   60 ++++++++++++++++----------------------
 frontends/cocoa/BrowserView.h    |    1 -
 frontends/cocoa/BrowserView.m    |   10 -------
 frontends/cocoa/gui.m            |   24 ++++++++-------
 frontends/framebuffer/gui.c      |   27 +++++++++--------
 frontends/gtk/window.c           |   43 +++++++++++++--------------
 frontends/monkey/browser.c       |   23 ++++++++-------
 frontends/riscos/window.c        |   29 +++++++-----------
 frontends/windows/window.c       |   27 ++++-------------
 include/netsurf/browser_window.h |   33 +++++++++++++++------
 include/netsurf/window.h         |   45 ++++++++++++++--------------
 16 files changed, 208 insertions(+), 234 deletions(-)

diff --git a/desktop/browser.c b/desktop/browser.c
index 45f3006..73a86c2 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -1781,6 +1781,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.
  *
  * \param  bw  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 3e9b846..5a53e2f 100644
--- a/desktop/browser_private.h
+++ b/desktop/browser_private.h
@@ -17,7 +17,8 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-/** \file
+/**
+ * \file
  * Browser window private structure.
  */
 
diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c
index e1de21e..559823d 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 */
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index a6164db..bf3102a 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -1643,15 +1643,26 @@ static void ami_gui_menu_update_all(void)
        } while((node = nnode));
 }
 
-static void gui_window_get_dimensions(struct gui_window *g,
+/**
+ * Find the current dimensions of a amiga browser window content area.
+ *
+ * \param gw The gui window to measure content area of.
+ * \param width receives width of window
+ * \param height receives height of window
+ * \param scaled whether to return scaled values
+ * \return NSERROR_OK on sucess and width and height updated
+ *          else error code.
+ */
+static nserror gui_window_get_dimensions(struct gui_window *gw,
                int *restrict width, int *restrict height, bool scaled)
 {
        struct IBox *bbox;
-       if(!g) return;
+       nserror res;
 
-       if(ami_gui_get_space_box((Object *)g->shared->objects[GID_BROWSER], 
&bbox) != NSERROR_OK) {
+       res = ami_gui_get_space_box((Object *)gw->shared->objects[GID_BROWSER], 
&bbox);
+       if(res != NSERROR_OK) {
                amiga_warn_user("NoMemory", "");
-               return;
+               return res;
        }
 
        *width = bbox->Width;
@@ -1659,11 +1670,12 @@ static void gui_window_get_dimensions(struct gui_window 
*g,
 
        ami_gui_free_space_box(bbox);
 
-       if(scaled)
-       {
-               *width /= g->scale;
-               *height /= g->scale;
+       if(scaled) {
+               *width /= gw->scale;
+               *height /= gw->scale;
        }
+
+       return NSERROR_OK;
 }
 
 /* Add a horizontal scroller, if not already present
@@ -4828,26 +4840,6 @@ bool ami_gui_window_update_box_deferred_check(struct 
MinList *deferred_rects,
 }
 
 
-/**
- * callback from core to reformat a window.
- */
-static void amiga_window_reformat(struct gui_window *gw)
-{
-       struct IBox *bbox;
-
-       LOG("reformat window %p", gw);
-
-       if (gw != NULL) {
-               if(ami_gui_get_space_box((Object 
*)gw->shared->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
-                       amiga_warn_user("NoMemory", "");
-                       return;
-               }
-               browser_window_reformat(gw->bw, false, bbox->Width, 
bbox->Height);
-               gw->shared->redraw_scroll = false;
-               ami_gui_free_space_box(bbox);
-       }
-}
-
 static void ami_do_redraw(struct gui_window_2 *gwin)
 {
        ULONG hcurrent,vcurrent,xoffset,yoffset,width=800,height=600;
@@ -5576,7 +5568,6 @@ static struct gui_window_table amiga_window_table = {
        .set_scroll = gui_window_set_scroll,
        .get_dimensions = gui_window_get_dimensions,
        .update_extent = gui_window_update_extent,
-       .reformat = amiga_window_reformat,
 
        .set_icon = gui_window_set_icon,
        .set_title = gui_window_set_title,
diff --git a/frontends/atari/gui.c b/frontends/atari/gui.c
index ad568b7..cdea953 100644
--- a/frontends/atari/gui.c
+++ b/frontends/atari/gui.c
@@ -293,25 +293,27 @@ void gui_window_destroy(struct gui_window *gw)
 }
 
 /**
- * Find the current dimensions of a browser window's content area.
+ * Find the current dimensions of a atari browser window content area.
  *
- * \param w     gui_window to measure
- * \param width         receives width of window
+ * \param gw The gui window to measure content area of.
+ * \param width receives width of window
  * \param height receives height of window
  * \param scaled whether to return scaled values
+ * \return NSERROR_OK on sucess and width and height updated
+ *          else error code.
  */
-static void
-gui_window_get_dimensions(struct gui_window *w,
+static nserror
+gui_window_get_dimensions(struct gui_window *gw,
                          int *width,
                          int *height,
                          bool scaled)
 {
-    if (w == NULL)
-       return;
     GRECT rect;
-    window_get_grect(w->root, BROWSER_AREA_CONTENT, &rect);
+    window_get_grect(gw->root, BROWSER_AREA_CONTENT, &rect);
     *width = rect.g_w;
     *height = rect.g_h;
+
+    return NSERROR_OK;
 }
 
 /**
@@ -375,16 +377,6 @@ void atari_window_set_status(struct gui_window *w, const 
char *text)
        window_set_stauts(w->root, (char*)text);
 }
 
-static void atari_window_reformat(struct gui_window *gw)
-{
-    int width = 0, height = 0;
-
-    if (gw != NULL) {
-       gui_window_get_dimensions(gw, &width, &height, true);
-       browser_window_reformat(gw->browser->bw, false, width, height);
-    }
-}
-
 
 /**
  * Invalidates an area of an atari browser window
@@ -1063,7 +1055,6 @@ static struct gui_window_table atari_window_table = {
     .set_scroll = gui_window_set_scroll,
     .get_dimensions = gui_window_get_dimensions,
     .update_extent = gui_window_update_extent,
-    .reformat = atari_window_reformat,
 
     .set_title = gui_window_set_title,
     .set_url = gui_window_set_url,
diff --git a/frontends/beos/window.cpp b/frontends/beos/window.cpp
index 4db7b3c..f3d63da 100644
--- a/frontends/beos/window.cpp
+++ b/frontends/beos/window.cpp
@@ -911,28 +911,6 @@ void nsbeos_reflow_all_windows(void)
 }
 
 
-
-/**
- * callback from core to reformat a window.
- */
-static void beos_window_reformat(struct gui_window *g)
-{
-        if (g == NULL) {
-                return;
-        }
-
-        NSBrowserFrameView *view = g->view;
-        if (view && view->LockLooper()) {
-                BRect bounds = view->Bounds();
-                view->UnlockLooper();
-#warning XXX why - 1 & - 2 !???
-                browser_window_reformat(g->bw,
-                                        false,
-                                        bounds.Width() + 1 /* - 2*/,
-                                        bounds.Height() + 1);
-        }        
-}
-
 void nsbeos_window_destroy_browser(struct gui_window *g)
 {
        browser_window_destroy(g->bw);
@@ -1334,19 +1312,32 @@ static struct gui_clipboard_table clipboard_table = {
 
 struct gui_clipboard_table *beos_clipboard_table = &clipboard_table;
 
-static void gui_window_get_dimensions(struct gui_window *g, int *width, int 
*height,
-                              bool scaled)
+/**
+ * Find the current dimensions of a beos browser window content area.
+ *
+ * \param gw The gui window to measure content area of.
+ * \param width receives width of window
+ * \param height receives height of window
+ * \param scaled whether to return scaled values
+ * \return NSERROR_OK on sucess and width and height updated
+ *          else error code.
+ */
+static nserror
+gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
+                          bool scaled)
 {
-       if (g->view && g->view->LockLooper()) {
-               *width = g->view->Bounds().Width() + 1;
-               *height = g->view->Bounds().Height() + 1;
-               g->view->UnlockLooper();
-       }
-
-       if (scaled) {
-               *width /= g->scale;
-               *height /= g->scale;
-       }
+        if (g->view &&
+            g->view->LockLooper()) {
+                *width = g->view->Bounds().Width() + 1;
+                *height = g->view->Bounds().Height() + 1;
+                g->view->UnlockLooper();
+
+                if (scaled) {
+                        *width /= g->scale;
+                        *height /= g->scale;
+                }
+        }
+        return NSERROR_OK;
 }
 
 static struct gui_window_table window_table = {
@@ -1357,7 +1348,6 @@ static struct gui_window_table window_table = {
        gui_window_set_scroll,
        gui_window_get_dimensions,
        gui_window_update_extent,
-        beos_window_reformat,
 
        /* from scaffold */
        gui_window_set_title,
diff --git a/frontends/cocoa/BrowserView.h b/frontends/cocoa/BrowserView.h
index c626c8c..1d02fb0 100644
--- a/frontends/cocoa/BrowserView.h
+++ b/frontends/cocoa/BrowserView.h
@@ -47,7 +47,6 @@
 - (void) removeCaret;
 - (void) addCaretAt: (NSPoint) point height: (CGFloat) height;
 
-- (void) reformat;
 - (void) updateHistory;
 
 @end
diff --git a/frontends/cocoa/BrowserView.m b/frontends/cocoa/BrowserView.m
index f1259d8..e6e8e0b 100644
--- a/frontends/cocoa/BrowserView.m
+++ b/frontends/cocoa/BrowserView.m
@@ -43,8 +43,6 @@
 - (void) scrollVertical: (CGFloat) amount;
 - (CGFloat) pageScroll;
 
-- (void) reformat;
-
 - (void) popUpContextMenuForEvent: (NSEvent *) event;
 
 - (IBAction) cmOpenURLInTab: (id) sender;
@@ -505,14 +503,6 @@ static browser_mouse_state cocoa_mouse_flags_for_event( 
NSEvent *evt )
         return NSHeight( [[self superview] frame] ) - [[self 
enclosingScrollView] pageScroll];
 }
 
-- (void) reformat
-{
-        NSRect size = [[self superview] frame];
-        browser_window_reformat(browser,
-                                false,
-                                cocoa_pt_to_px( NSWidth( size ) ),
-                                cocoa_pt_to_px( NSHeight( size ) ) );
-}
 
 - (void) popUpContextMenuForEvent: (NSEvent *) event
 {
diff --git a/frontends/cocoa/gui.m b/frontends/cocoa/gui.m
index 7e180fa..1bf191f 100644
--- a/frontends/cocoa/gui.m
+++ b/frontends/cocoa/gui.m
@@ -129,18 +129,19 @@ static void gui_window_set_scroll(struct gui_window *g, 
int sx, int sy)
        [[(BrowserViewController *)g browserView] scrollPoint: cocoa_point( sx, 
sy )];
 }
 
-/**
- * callback from core to reformat a window.
- */
-static void cocoa_window_reformat(struct gui_window *gw)
-{
-       if (gw != NULL) {
-                [[(BrowserViewController *)gw browserView] reformat ];
-       }
-}
 
 
-static void gui_window_get_dimensions(struct gui_window *g,
+/**
+ * Find the current dimensions of a cocoa browser window content area.
+ *
+ * \param gw The gui window to measure content area of.
+ * \param width receives width of window
+ * \param height receives height of window
+ * \param scaled whether to return scaled values
+ * \return NSERROR_OK on sucess and width and height updated
+ *          else error code.
+ */
+static nserror gui_window_get_dimensions(struct gui_window *g,
                                       int *width, int *height,
                                       bool scaled)
 {
@@ -154,6 +155,8 @@ static void gui_window_get_dimensions(struct gui_window *g,
        }
        *width = cocoa_pt_to_px( NSWidth( frame ) );
        *height = cocoa_pt_to_px( NSHeight( frame ) );
+
+        return NSERROR_OK;
 }
 
 static void gui_window_update_extent(struct gui_window *g)
@@ -304,7 +307,6 @@ static struct gui_window_table window_table = {
        .set_scroll = gui_window_set_scroll,
        .get_dimensions = gui_window_get_dimensions,
        .update_extent = gui_window_update_extent,
-       .reformat = cocoa_window_reformat,
 
        .set_title = gui_window_set_title,
        .set_url = gui_window_set_url,
diff --git a/frontends/framebuffer/gui.c b/frontends/framebuffer/gui.c
index 3de228a..0221a8e 100644
--- a/frontends/framebuffer/gui.c
+++ b/frontends/framebuffer/gui.c
@@ -1583,7 +1583,7 @@ resize_browser_widget(struct gui_window *gw, int x, int y,
                int width, int height)
 {
        fbtk_set_pos_and_size(gw->browser, x, y, width, height);
-       browser_window_reformat(gw->bw, false, width, height);
+       browser_window_schedule_reformat(gw->bw);
 }
 
 static void
@@ -1857,21 +1857,30 @@ gui_window_set_scroll(struct gui_window *gw, int sx, 
int sy)
 }
 
 
-static void
+/**
+ * Find the current dimensions of a framebuffer browser window content area.
+ *
+ * \param gw The gui window to measure content area of.
+ * \param width receives width of window
+ * \param height receives height of window
+ * \param scaled whether to return scaled values
+ * \return NSERROR_OK on sucess and width and height updated.
+ */
+static nserror
 gui_window_get_dimensions(struct gui_window *g,
                          int *width,
                          int *height,
                          bool scaled)
 {
-       float scale = browser_window_get_scale(g->bw);
-
        *width = fbtk_get_width(g->browser);
        *height = fbtk_get_height(g->browser);
 
        if (scaled) {
+               float scale = browser_window_get_scale(g->bw);
                *width /= scale;
                *height /= scale;
        }
+       return NSERROR_OK;
 }
 
 static void
@@ -2050,15 +2059,6 @@ gui_window_remove_caret(struct gui_window *g)
        }
 }
 
-static void framebuffer_window_reformat(struct gui_window *gw)
-{
-       /** @todo if we ever do zooming reformat should be implemented */
-       LOG("window:%p", gw);
-
-       /*
-         browser_window_reformat(gw->bw, false, width, height);
-       */
-}
 
 static struct gui_window_table framebuffer_window_table = {
        .create = gui_window_create,
@@ -2068,7 +2068,6 @@ static struct gui_window_table framebuffer_window_table = 
{
        .set_scroll = gui_window_set_scroll,
        .get_dimensions = gui_window_get_dimensions,
        .update_extent = gui_window_update_extent,
-       .reformat = framebuffer_window_reformat,
 
        .set_url = gui_window_set_url,
        .set_status = gui_window_set_status,
diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c
index 25b975e..ecd6d0a 100644
--- a/frontends/gtk/window.c
+++ b/frontends/gtk/window.c
@@ -895,21 +895,6 @@ void nsgtk_reflow_all_windows(void)
 }
 
 
-/**
- * callback from core to reformat a window.
- */
-static void nsgtk_window_reformat(struct gui_window *gw)
-{
-       GtkAllocation alloc;
-
-       if (gw != NULL) {
-               /** @todo consider gtk_widget_get_allocated_width() */
-               nsgtk_widget_get_allocation(GTK_WIDGET(gw->layout), &alloc);
-
-               browser_window_reformat(gw->bw, false, alloc.width, 
alloc.height);
-       }
-}
-
 void nsgtk_window_destroy_browser(struct gui_window *gw)
 {
        /* remove tab */
@@ -1203,24 +1188,37 @@ static void gui_window_place_caret(struct gui_window 
*g, int x, int y, int heigh
 }
 
 
-static void gui_window_get_dimensions(struct gui_window *g, int *width, int 
*height,
-                              bool scaled)
+/**
+ * Find the current dimensions of a GTK browser window content area.
+ *
+ * \param gw The gui window to measure content area of.
+ * \param width receives width of window
+ * \param height receives height of window
+ * \param scaled whether to return scaled values
+ * \return NSERROR_OK on sucess and width and height updated
+ *          else error code.
+ */
+static nserror
+gui_window_get_dimensions(struct gui_window *gw,
+                         int *width, int *height,
+                         bool scaled)
 {
        GtkAllocation alloc;
 
-       /* @todo consider gtk_widget_get_allocated_width() */
-       nsgtk_widget_get_allocation(GTK_WIDGET(g->layout), &alloc);
+       /** @todo consider gtk_widget_get_allocated_width() */
+       nsgtk_widget_get_allocation(GTK_WIDGET(gw->layout), &alloc);
 
        *width = alloc.width;
        *height = alloc.height;
 
        if (scaled) {
-               float scale = browser_window_get_scale(g->bw);
+               float scale = browser_window_get_scale(gw->bw);
                *width /= scale;
                *height /= scale;
        }
-       LOG("width: %i", *width);
-       LOG("height: %i", *height);
+       LOG("gw:%p width:%i height:%i", gw, *width, *height);
+
+       return NSERROR_OK;
 }
 
 static void gui_window_start_selection(struct gui_window *g)
@@ -1321,7 +1319,6 @@ static struct gui_window_table window_table = {
        .set_scroll = gui_window_set_scroll,
        .get_dimensions = gui_window_get_dimensions,
        .update_extent = gui_window_update_extent,
-       .reformat = nsgtk_window_reformat,
 
        .set_icon = gui_window_set_icon,
        .set_status = gui_window_set_status,
diff --git a/frontends/monkey/browser.c b/frontends/monkey/browser.c
index 7cd3d07..8d5154e 100644
--- a/frontends/monkey/browser.c
+++ b/frontends/monkey/browser.c
@@ -61,15 +61,6 @@ monkey_find_window_by_num(uint32_t win_num)
   return ret;
 }
 
-
-/**
- * callback from core to reformat a window.
- */
-static void monkey_window_reformat(struct gui_window *gw)
-{
-       browser_window_reformat(gw->bw, false, gw->width, gw->height);
-}
-
 void
 monkey_kill_browser_windows(void)
 {
@@ -118,7 +109,16 @@ gui_window_set_title(struct gui_window *g, const char 
*title)
   fprintf(stdout, "WINDOW TITLE WIN %u STR %s\n", g->win_num, title);
 }
 
-static void
+/**
+ * Find the current dimensions of a monkey browser window content area.
+ *
+ * \param gw The gui window to measure content area of.
+ * \param width receives width of window
+ * \param height receives height of window
+ * \param scaled whether to return scaled values
+ * \return NSERROR_OK on sucess and width and height updated.
+ */
+static nserror
 gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
                           bool scaled)
 {
@@ -126,6 +126,8 @@ gui_window_get_dimensions(struct gui_window *g, int *width, 
int *height,
           g->win_num, g->width, g->height);
   *width = g->width;
   *height = g->height;
+
+  return NSERROR_OK;
 }
 
 static void
@@ -515,7 +517,6 @@ static struct gui_window_table window_table = {
        .set_scroll = gui_window_set_scroll,
        .get_dimensions = gui_window_get_dimensions,
        .update_extent = gui_window_update_extent,
-       .reformat = monkey_window_reformat,
 
        .set_title = gui_window_set_title,
        .set_url = gui_window_set_url,
diff --git a/frontends/riscos/window.c b/frontends/riscos/window.c
index 6b5089c..1d5c093 100644
--- a/frontends/riscos/window.c
+++ b/frontends/riscos/window.c
@@ -927,16 +927,20 @@ static void gui_window_scroll_visible(struct gui_window 
*g, int x0, int y0, int
  * \param height receives height of window
  * \param scaled whether to return scaled values
  */
-
-static void gui_window_get_dimensions(struct gui_window *g, int *width, int 
*height, bool scaled)
+static nserror
+gui_window_get_dimensions(struct gui_window *gw,
+                         int *width, int *height,
+                         bool scaled)
 {
        /* use the cached window sizes */
-       *width = g->old_width / 2;
-       *height = g->old_height / 2;
+       *width = gw->old_width / 2;
+       *height = gw->old_height / 2;
+
        if (scaled) {
-               *width /= g->scale;
-               *height /= g->scale;
+               *width /= gw->scale;
+               *height /= gw->scale;
        }
+       return NSERROR_OK;
 }
 
 
@@ -4207,18 +4211,6 @@ void ro_gui_window_update_boxes(void)
 
 
 /**
- * callback from core to reformat a window.
- */
-static void riscos_window_reformat(struct gui_window *gw)
-{
-       if (gw != NULL) {
-               browser_window_reformat(gw->bw, false,
-                                       gw->old_width / 2,
-                                       gw->old_height / 2);
-       }
-}
-
-/**
  * Destroy all browser windows.
  */
 
@@ -4986,7 +4978,6 @@ static struct gui_window_table window_table = {
        .set_scroll = gui_window_set_scroll,
        .get_dimensions = gui_window_get_dimensions,
        .update_extent = gui_window_update_extent,
-       .reformat = riscos_window_reformat,
 
        .set_title = gui_window_set_title,
        .set_url = ro_gui_window_set_url,
diff --git a/frontends/windows/window.c b/frontends/windows/window.c
index c0af46f..829067b 100644
--- a/frontends/windows/window.c
+++ b/frontends/windows/window.c
@@ -1236,7 +1236,7 @@ nsws_window_command(HWND hwnd,
                        browser_window_debug(gw->bw, CONTENT_DEBUG_REDRAW);
                        /* TODO: This should only redraw, not reformat.
                         * (Layout doesn't change, so reformat is a waste of 
time) */
-                       browser_window_reformat(gw->bw, false, gw->width, 
gw->height);
+                       browser_window_schedule_reformat(gw->bw);
                }
                break;
 
@@ -1548,18 +1548,17 @@ static void win32_window_destroy(struct gui_window *w)
  * \param height receives height of window
  * \param scaled whether to return scaled values
  */
-static void
+static nserror
 win32_window_get_dimensions(struct gui_window *gw,
                            int *width, int *height,
                            bool scaled)
 {
-       if (gw == NULL)
-               return;
-
-       LOG("get dimensions %p w=%d h=%d", gw, gw->width, gw->height);
-
        *width = gw->width;
        *height = gw->height;
+
+       LOG("gw:%p w=%d h=%d", gw, *width, *height);
+
+       return NSERROR_OK;
 }
 
 
@@ -1576,19 +1575,6 @@ static void win32_window_update_extent(struct gui_window 
*w)
 
 
 /**
- * callback from core to reformat a win32 window.
- *
- * \param gw The win32 gui window to reformat.
- */
-static void win32_window_reformat(struct gui_window *gw)
-{
-       if (gw != NULL) {
-               browser_window_reformat(gw->bw, false, gw->width, gw->height);
-       }
-}
-
-
-/**
  * set win32 browser window title
  *
  * \param w the win32 gui window.
@@ -1773,7 +1759,6 @@ static struct gui_window_table window_table = {
        .set_scroll = win32_window_set_scroll,
        .get_dimensions = win32_window_get_dimensions,
        .update_extent = win32_window_update_extent,
-       .reformat = win32_window_reformat,
 
        .set_title = win32_window_set_title,
        .set_url = win32_window_set_url,
diff --git a/include/netsurf/browser_window.h b/include/netsurf/browser_window.h
index 858d4ae..c56cf55 100644
--- a/include/netsurf/browser_window.h
+++ b/include/netsurf/browser_window.h
@@ -296,16 +296,23 @@ void browser_window_reload(struct browser_window *bw, 
bool all);
  */
 void browser_window_destroy(struct browser_window *bw);
 
+
 /**
  * Reformat a browser window contents to a new width or height.
  *
+ * This API is not safe to call from all contexts and care must be used.
+ *
+ * \warning This API is generally only useful within the browser core
+ * and is only exposed for historical reasons. A frontend almost
+ * certianly actually wants browser_window_schedule_reformat() and not
+ * this.
+ *
  * \param bw         The browser window to reformat.
  * \param background Reformat in the background.
  * \param width      new width
  * \param height     new height
  */
-void browser_window_reformat(struct browser_window *bw, bool background,
-               int width, int height);
+void browser_window_reformat(struct browser_window *bw, bool background, int 
width, int height);
 
 
 /**
@@ -411,6 +418,7 @@ void browser_window_mouse_click(struct browser_window *bw,
 void browser_window_mouse_track(struct browser_window *bw,
                browser_mouse_state mouse, int x, int y);
 
+
 /**
  * Locate a browser window in the specified stack according.
  *
@@ -423,21 +431,28 @@ struct browser_window *browser_window_find_target(
                struct browser_window *bw, const char *target,
                browser_mouse_state mouse);
 
+
 /**
- * Cause the frontends reformat entry to be called in safe context.
+ * Reformat the browser window contents in a safe context.
  *
- * The browser_window_reformat call cannot safely be called from some
- * contexts, this call allows for the reformat to happen from a safe
+ * The browser_window_reformat() call cannot safely be called from some
+ * contexts, This interface allows for the reformat to happen from a safe
  * top level context.
  *
- * The callback is frontend provided as the context information (size
- * etc.) about the windowing toolkit is only available to the
- * frontend.
+ * The reformat uses the window table get_dimensions() callback as the
+ * correct viewport dimensions are only available to the frontend.
+ *
+ * \param bw The browser window to reformat the content of.
+ * \return NSERROR_OK on success else appropriate error code.
  */
 nserror browser_window_schedule_reformat(struct browser_window *bw);
 
 
-
+/**
+ * callback for select menu widget
+ *
+ * \todo This API needs investigating
+ */
 void browser_select_menu_callback(void *client_data,
                int x, int y, int width, int height);
 
diff --git a/include/netsurf/window.h b/include/netsurf/window.h
index 434a795..b9a6863 100644
--- a/include/netsurf/window.h
+++ b/include/netsurf/window.h
@@ -23,8 +23,8 @@
  * operations.
  */
 
-#ifndef _NETSURF_WINDOW_H_
-#define _NETSURF_WINDOW_H_
+#ifndef NETSURF_WINDOW_H
+#define NETSURF_WINDOW_H
 
 typedef enum gui_save_type {
        GUI_SAVE_SOURCE,
@@ -50,10 +50,13 @@ typedef enum {
        GDRAGGING_OTHER
 } gui_drag_type;
 
+/**
+ * Window creation control flags.
+ */
 typedef enum {
-       GW_CREATE_NONE          = 0,            /* New window */
-       GW_CREATE_CLONE         = (1 << 0),     /* Clone existing window */
-       GW_CREATE_TAB           = (1 << 1)      /* In same window as existing */
+       GW_CREATE_NONE = 0, /**< New window */
+       GW_CREATE_CLONE = (1 << 0), /**< Clone existing window */
+       GW_CREATE_TAB = (1 << 1) /**< In same window as existing */
 } gui_window_create_flags;
 
 struct browser_window;
@@ -90,6 +93,7 @@ struct gui_window_table {
                        struct gui_window *existing,
                        gui_window_create_flags flags);
 
+
        /**
         * Destroy previously created gui window
         *
@@ -97,6 +101,7 @@ struct gui_window_table {
         */
        void (*destroy)(struct gui_window *gw);
 
+
        /**
         * Invalidate an area of a window.
         *
@@ -116,6 +121,7 @@ struct gui_window_table {
         */
        nserror (*invalidate)(struct gui_window *g, const struct rect *rect);
 
+
        /**
         * Get the scroll position of a browser window.
         *
@@ -126,6 +132,7 @@ struct gui_window_table {
         */
        bool (*get_scroll)(struct gui_window *g, int *sx, int *sy);
 
+
        /**
         * Set the scroll position of a browser window.
         *
@@ -135,18 +142,24 @@ struct gui_window_table {
         */
        void (*set_scroll)(struct gui_window *g, int sx, int sy);
 
+
        /**
         * Find the current dimensions of a browser window's content area.
         *
-        * @todo The implementations of this are buggy and its only
-        * used from frames code.
+        * This is used to determine the actual available drawing size
+        * in pixels. This is used to allow contents that can be
+        * dynamicaly reformatted, such as HTML, to better use the
+        * available space.
         *
-        * \param g      gui_window to measure
-        * \param width  receives width of window
+        * \param gw The gui window to measure content area of.
+        * \param width receives width of window
         * \param height receives height of window
         * \param scaled whether to return scaled values
+        * \return NSERROR_OK on sucess and width and height updated
+        *          else error code.
         */
-       void (*get_dimensions)(struct gui_window *g, int *width, int *height, 
bool scaled);
+       nserror (*get_dimensions)(struct gui_window *gw, int *width, int 
*height, bool scaled);
+
 
        /**
         * Update the extent of the inside of a browser window to that of the
@@ -159,18 +172,6 @@ struct gui_window_table {
         */
        void (*update_extent)(struct gui_window *g);
 
-       /**
-        * Reformat a window.
-        *
-        * This is used to perform reformats when the page contents
-        * require reformatting. The reformat is requested using
-        * browser_window_schedule_reformat and occurs via a scheduled
-        * callback hence from top level context.
-        *
-        * \param g gui_window to reformat.
-        */
-       void (*reformat)(struct gui_window *g);
-
 
        /* Optional entries */
 


-- 
NetSurf Browser

_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org

Reply via email to