From 9ce71876ce500e242e2384c21abb38a8f431138b Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 30 May 2016 11:31:35 +0100 Subject: move layout header into public API --- desktop/browser_history.c | 2 +- desktop/gui_factory.c | 2 +- desktop/gui_layout.h | 91 ----------------------------------- desktop/textarea.c | 2 +- desktop/treeview.c | 2 +- frontends/amiga/font.c | 2 +- frontends/amiga/print.c | 2 +- frontends/atari/font.c | 2 +- frontends/atari/gui.c | 2 +- frontends/beos/font.cpp | 2 +- frontends/cocoa/font.m | 2 +- frontends/framebuffer/font_freetype.c | 2 +- frontends/framebuffer/font_internal.c | 2 +- frontends/gtk/layout_pango.c | 2 +- frontends/monkey/layout.c | 2 +- frontends/riscos/font.c | 2 +- frontends/windows/font.c | 2 +- include/netsurf/layout.h | 91 +++++++++++++++++++++++++++++++++++ render/html.c | 2 +- render/html_interaction.c | 2 +- render/html_redraw.c | 2 +- render/layout.c | 2 +- render/textplain.c | 2 +- 23 files changed, 112 insertions(+), 112 deletions(-) delete mode 100644 desktop/gui_layout.h create mode 100644 include/netsurf/layout.h diff --git a/desktop/browser_history.c b/desktop/browser_history.c index 871cc3e4b..79a921ad1 100644 --- a/desktop/browser_history.c +++ b/desktop/browser_history.c @@ -36,7 +36,7 @@ #include "content/urldb.h" #include "netsurf/bitmap.h" -#include "desktop/gui_layout.h" +#include "netsurf/layout.h" #include "desktop/gui_internal.h" #include "desktop/browser_history.h" #include "desktop/browser_private.h" diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c index e2549cc74..a085c0ca8 100644 --- a/desktop/gui_factory.c +++ b/desktop/gui_factory.c @@ -37,7 +37,7 @@ #include "netsurf/search.h" #include "netsurf/clipboard.h" #include "netsurf/utf8.h" -#include "desktop/gui_layout.h" +#include "netsurf/layout.h" #include "desktop/netsurf.h" /** diff --git a/desktop/gui_layout.h b/desktop/gui_layout.h deleted file mode 100644 index 1696aee91..000000000 --- a/desktop/gui_layout.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2016 Vincent Sanders - * - * This file is part of NetSurf, http://www.netsurf-browser.org/ - * - * NetSurf is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * NetSurf is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file - * - * Interface to platform-specific layout operation table. - * - * This table is part of the layout used to measure glyphs before - * rendering, previously referred to as font functions. - * - * \note This is an old interface within the browser, it has been - * broken out purely to make the API obvious not as an indication this - * is the correct approach. - */ - -#ifndef _NETSURF_DESKTOP_GUI_LAYOUT_H_ -#define _NETSURF_DESKTOP_GUI_LAYOUT_H_ - -struct plot_font_style; - -struct gui_layout_table -{ - /** - * Measure the width of a string. - * - * \param[in] fstyle plot style for this text - * \param[in] string UTF-8 string to measure - * \param[in] length length of string, in bytes - * \param[out] width updated to width of string[0..length) - * \return NSERROR_OK and width updated or appropriate error - * code on faliure - */ - nserror (*width)(const struct plot_font_style *fstyle, const char *string, size_t length, int *width); - - - /** - * Find the position in a string where an x coordinate falls. - * - * \param[in] fstyle style for this text - * \param[in] string UTF-8 string to measure - * \param[in] length length of string, in bytes - * \param[in] x coordinate to search for - * \param[out] char_offset updated to offset in string of actual_x, [0..length] - * \param[out] actual_x updated to x coordinate of character closest to x - * \return NSERROR_OK and char_offset and actual_x updated or appropriate error code on faliure - */ - nserror (*position)(const struct plot_font_style *fstyle, const char *string, size_t length, int x, size_t *char_offset, int *actual_x); - - - /** - * Find where to split a string to make it fit a width. - * - * \param[in] fstyle style for this text - * \param[in] string UTF-8 string to measure - * \param[in] length length of string, in bytes - * \param[in] x width available - * \param[out] char_offset updated to offset in string of actual_x, [1..length] - * \param[out] actual_x updated to x coordinate of character closest to x - * \return NSERROR_OK or appropriate error code on faliure - * - * On exit, char_offset indicates first character after split point. - * - * \note char_offset of 0 must never be returned. - * - * Returns: - * char_offset giving split point closest to x, where actual_x <= x - * else - * char_offset giving split point closest to x, where actual_x > x - * - * Returning char_offset == length means no split possible - */ - nserror (*split)(const struct plot_font_style *fstyle, const char *string, size_t length, int x, size_t *char_offset, int *actual_x); -}; - -#endif diff --git a/desktop/textarea.c b/desktop/textarea.c index 833815eba..157d6c188 100644 --- a/desktop/textarea.c +++ b/desktop/textarea.c @@ -38,7 +38,7 @@ #include "desktop/plotters.h" #include "desktop/scrollbar.h" #include "netsurf/clipboard.h" -#include "desktop/gui_layout.h" +#include "netsurf/layout.h" #include "desktop/gui_internal.h" #define CARET_COLOR 0x0000FF diff --git a/desktop/treeview.c b/desktop/treeview.c index d72bf2f8d..ead0510b8 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -33,7 +33,7 @@ #include "desktop/textarea.h" #include "desktop/treeview.h" #include "netsurf/clipboard.h" -#include "desktop/gui_layout.h" +#include "netsurf/layout.h" #include "desktop/gui_internal.h" /** @todo get rid of REDRAW_MAX -- need to be able to know window size */ diff --git a/frontends/amiga/font.c b/frontends/amiga/font.c index 1c9702af2..af62652e8 100644 --- a/frontends/amiga/font.c +++ b/frontends/amiga/font.c @@ -25,7 +25,7 @@ #include "utils/log.h" #include "utils/nsoption.h" #include "desktop/browser.h" -#include "desktop/gui_layout.h" +#include "netsurf/layout.h" #include "amiga/font.h" #include "amiga/font_bullet.h" diff --git a/frontends/amiga/print.c b/frontends/amiga/print.c index ef70fe73e..573daf3b2 100644 --- a/frontends/amiga/print.c +++ b/frontends/amiga/print.c @@ -52,7 +52,7 @@ #include "desktop/plotters.h" #include "desktop/printer.h" #include "desktop/print.h" -#include "desktop/gui_layout.h" +#include "netsurf/layout.h" #include "desktop/mouse.h" #include "netsurf/window.h" #include "content/hlcache.h" diff --git a/frontends/atari/font.c b/frontends/atari/font.c index cb0c574ea..f6b91c8b9 100644 --- a/frontends/atari/font.c +++ b/frontends/atari/font.c @@ -24,7 +24,7 @@ #include "utils/utf8.h" #include "utils/log.h" #include "utils/nsoption.h" -#include "desktop/gui_layout.h" +#include "netsurf/layout.h" #include "desktop/mouse.h" #include "desktop/plotters.h" diff --git a/frontends/atari/gui.c b/frontends/atari/gui.c index 39edeb422..964983ed7 100644 --- a/frontends/atari/gui.c +++ b/frontends/atari/gui.c @@ -35,7 +35,7 @@ #include "content/hlcache.h" #include "desktop/treeview.h" #include "desktop/browser.h" -#include "desktop/gui_layout.h" +#include "netsurf/layout.h" #include "netsurf/window.h" #include "netsurf/clipboard.h" #include "netsurf/fetch.h" diff --git a/frontends/beos/font.cpp b/frontends/beos/font.cpp index 003af52b5..407918f0c 100644 --- a/frontends/beos/font.cpp +++ b/frontends/beos/font.cpp @@ -36,7 +36,7 @@ extern "C" { #include "utils/log.h" #include "utils/nsoption.h" #include "utils/nsurl.h" -#include "desktop/gui_layout.h" +#include "netsurf/layout.h" } #include "beos/gui.h" diff --git a/frontends/cocoa/font.m b/frontends/cocoa/font.m index f52ec85bc..7b594b616 100644 --- a/frontends/cocoa/font.m +++ b/frontends/cocoa/font.m @@ -22,7 +22,7 @@ #import "cocoa/font.h" #import "utils/nsoption.h" -#import "desktop/gui_layout.h" +#import "netsurf/layout.h" #import "desktop/plotters.h" diff --git a/frontends/framebuffer/font_freetype.c b/frontends/framebuffer/font_freetype.c index d1ac9ed4b..bf96cab50 100644 --- a/frontends/framebuffer/font_freetype.c +++ b/frontends/framebuffer/font_freetype.c @@ -28,7 +28,7 @@ #include "utils/log.h" #include "utils/nsoption.h" #include "netsurf/utf8.h" -#include "desktop/gui_layout.h" +#include "netsurf/layout.h" #include "desktop/browser.h" #include "framebuffer/gui.h" diff --git a/frontends/framebuffer/font_internal.c b/frontends/framebuffer/font_internal.c index 9b1585889..9164a29db 100644 --- a/frontends/framebuffer/font_internal.c +++ b/frontends/framebuffer/font_internal.c @@ -25,7 +25,7 @@ #include "utils/nsoption.h" #include "utils/utf8.h" #include "netsurf/utf8.h" -#include "desktop/gui_layout.h" +#include "netsurf/layout.h" #include "framebuffer/gui.h" #include "framebuffer/font.h" diff --git a/frontends/gtk/layout_pango.c b/frontends/gtk/layout_pango.c index 49b629399..a0196df9b 100644 --- a/frontends/gtk/layout_pango.c +++ b/frontends/gtk/layout_pango.c @@ -30,7 +30,7 @@ #include "utils/log.h" #include "utils/nsoption.h" -#include "desktop/gui_layout.h" +#include "netsurf/layout.h" #include "gtk/layout_pango.h" #include "gtk/plotters.h" diff --git a/frontends/monkey/layout.c b/frontends/monkey/layout.c index 401ca158c..00ed9dff3 100644 --- a/frontends/monkey/layout.c +++ b/frontends/monkey/layout.c @@ -25,7 +25,7 @@ #include "utils/utf8.h" #include "desktop/plot_style.h" -#include "desktop/gui_layout.h" +#include "netsurf/layout.h" #include "monkey/layout.h" diff --git a/frontends/riscos/font.c b/frontends/riscos/font.c index 2f2ba9a35..a7a394e2d 100644 --- a/frontends/riscos/font.c +++ b/frontends/riscos/font.c @@ -34,7 +34,7 @@ #include "utils/log.h" #include "utils/messages.h" #include "utils/utils.h" -#include "desktop/gui_layout.h" +#include "netsurf/layout.h" #include "riscos/gui.h" #include "riscos/font.h" diff --git a/frontends/windows/font.c b/frontends/windows/font.c index 8af7ea6db..551a0eb30 100644 --- a/frontends/windows/font.c +++ b/frontends/windows/font.c @@ -30,7 +30,7 @@ #include "utils/log.h" #include "utils/nsoption.h" #include "utils/utf8.h" -#include "desktop/gui_layout.h" +#include "netsurf/layout.h" #include "netsurf/utf8.h" #include "windows/font.h" diff --git a/include/netsurf/layout.h b/include/netsurf/layout.h new file mode 100644 index 000000000..1696aee91 --- /dev/null +++ b/include/netsurf/layout.h @@ -0,0 +1,91 @@ +/* + * Copyright 2016 Vincent Sanders + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file + * + * Interface to platform-specific layout operation table. + * + * This table is part of the layout used to measure glyphs before + * rendering, previously referred to as font functions. + * + * \note This is an old interface within the browser, it has been + * broken out purely to make the API obvious not as an indication this + * is the correct approach. + */ + +#ifndef _NETSURF_DESKTOP_GUI_LAYOUT_H_ +#define _NETSURF_DESKTOP_GUI_LAYOUT_H_ + +struct plot_font_style; + +struct gui_layout_table +{ + /** + * Measure the width of a string. + * + * \param[in] fstyle plot style for this text + * \param[in] string UTF-8 string to measure + * \param[in] length length of string, in bytes + * \param[out] width updated to width of string[0..length) + * \return NSERROR_OK and width updated or appropriate error + * code on faliure + */ + nserror (*width)(const struct plot_font_style *fstyle, const char *string, size_t length, int *width); + + + /** + * Find the position in a string where an x coordinate falls. + * + * \param[in] fstyle style for this text + * \param[in] string UTF-8 string to measure + * \param[in] length length of string, in bytes + * \param[in] x coordinate to search for + * \param[out] char_offset updated to offset in string of actual_x, [0..length] + * \param[out] actual_x updated to x coordinate of character closest to x + * \return NSERROR_OK and char_offset and actual_x updated or appropriate error code on faliure + */ + nserror (*position)(const struct plot_font_style *fstyle, const char *string, size_t length, int x, size_t *char_offset, int *actual_x); + + + /** + * Find where to split a string to make it fit a width. + * + * \param[in] fstyle style for this text + * \param[in] string UTF-8 string to measure + * \param[in] length length of string, in bytes + * \param[in] x width available + * \param[out] char_offset updated to offset in string of actual_x, [1..length] + * \param[out] actual_x updated to x coordinate of character closest to x + * \return NSERROR_OK or appropriate error code on faliure + * + * On exit, char_offset indicates first character after split point. + * + * \note char_offset of 0 must never be returned. + * + * Returns: + * char_offset giving split point closest to x, where actual_x <= x + * else + * char_offset giving split point closest to x, where actual_x > x + * + * Returning char_offset == length means no split possible + */ + nserror (*split)(const struct plot_font_style *fstyle, const char *string, size_t length, int x, size_t *char_offset, int *actual_x); +}; + +#endif diff --git a/render/html.c b/render/html.c index 6120fdf01..8307cdcf7 100644 --- a/render/html.c +++ b/render/html.c @@ -50,7 +50,7 @@ #include "javascript/js.h" #include "desktop/browser.h" #include "netsurf/utf8.h" -#include "desktop/gui_layout.h" +#include "netsurf/layout.h" #include "netsurf/misc.h" #include "desktop/gui_internal.h" diff --git a/render/html_interaction.c b/render/html_interaction.c index 4d0a903dd..0efb1286d 100644 --- a/render/html_interaction.c +++ b/render/html_interaction.c @@ -45,7 +45,7 @@ #include "desktop/textinput.h" #include "javascript/js.h" #include "netsurf/misc.h" -#include "desktop/gui_layout.h" +#include "netsurf/layout.h" #include "desktop/gui_internal.h" #include "render/box.h" diff --git a/render/html_redraw.c b/render/html_redraw.c index cf4bd6f67..e70f9bead 100644 --- a/render/html_redraw.c +++ b/render/html_redraw.c @@ -49,7 +49,7 @@ #include "desktop/scrollbar.h" #include "desktop/textarea.h" #include "netsurf/bitmap.h" -#include "desktop/gui_layout.h" +#include "netsurf/layout.h" #include "desktop/gui_internal.h" #include "render/box.h" diff --git a/render/layout.c b/render/layout.c index a7f2e8db5..c86ccd75b 100644 --- a/render/layout.c +++ b/render/layout.c @@ -52,7 +52,7 @@ #include "desktop/browser.h" #include "desktop/scrollbar.h" #include "desktop/textarea.h" -#include "desktop/gui_layout.h" +#include "netsurf/layout.h" #include "render/box.h" #include "render/font.h" diff --git a/render/textplain.c b/render/textplain.c index 5ecf1436d..9fe560d72 100644 --- a/render/textplain.c +++ b/render/textplain.c @@ -46,7 +46,7 @@ #include "desktop/search.h" #include "desktop/selection.h" #include "desktop/textinput.h" -#include "desktop/gui_layout.h" +#include "netsurf/layout.h" #include "desktop/gui_internal.h" #include "render/search.h" -- cgit v1.2.3