diff options
-rw-r--r-- | amiga/bitmap.c | 4 | ||||
-rwxr-xr-x | amiga/bitmap.h | 1 | ||||
-rw-r--r-- | amiga/gui.c | 43 | ||||
-rwxr-xr-x | amiga/gui.h | 3 | ||||
-rwxr-xr-x | amiga/launch.c | 1 | ||||
-rw-r--r-- | amiga/menu.c | 24 | ||||
-rw-r--r-- | amiga/options.h | 2 | ||||
-rw-r--r-- | amiga/tree.c | 2 | ||||
-rw-r--r-- | beos/Makefile.target | 2 | ||||
-rw-r--r-- | beos/gui.cpp | 20 | ||||
-rw-r--r-- | beos/plotters.cpp | 1 | ||||
-rw-r--r-- | beos/scaffolding.cpp | 9 | ||||
-rw-r--r-- | framebuffer/font_internal.c | 35 | ||||
-rw-r--r-- | framebuffer/font_internal.h | 5 | ||||
-rw-r--r-- | framebuffer/framebuffer.c | 3 |
15 files changed, 122 insertions, 33 deletions
diff --git a/amiga/bitmap.c b/amiga/bitmap.c index f25ac2b81..271978b2e 100644 --- a/amiga/bitmap.c +++ b/amiga/bitmap.c @@ -152,7 +152,9 @@ bool bitmap_save(void *bitmap, const char *path, unsigned flags) int err = 0; Object *dto = NULL; - if(!ami_download_check_overwrite(path, NULL, 0)) return false; + if ((flags & AMI_BITMAP_FORCE_OVERWRITE) == 0) { + if(!ami_download_check_overwrite(path, NULL, 0)) return false; + } if(dto = ami_datatype_object_from_bitmap(bitmap)) { diff --git a/amiga/bitmap.h b/amiga/bitmap.h index 0435aec5b..6657d2f8a 100755 --- a/amiga/bitmap.h +++ b/amiga/bitmap.h @@ -26,6 +26,7 @@ #include <libraries/Picasso96.h> #define AMI_BITMAP_FORMAT RGBFB_R8G8B8A8 +#define AMI_BITMAP_FORCE_OVERWRITE 0xFF struct bitmap { int width; diff --git a/amiga/gui.c b/amiga/gui.c index e2bb39c0c..6b02cac4f 100644 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -181,6 +181,7 @@ bool cli_force = false; static char *current_user; static char *current_user_dir; +static char *current_user_faviconcache; static const __attribute__((used)) char *stack_cookie = "\0$STACK:262144\0"; @@ -2760,9 +2761,40 @@ static void gui_quit(void) FreeVec(current_user_options); FreeVec(current_user_dir); + FreeVec(current_user_faviconcache); FreeVec(current_user); } +char *ami_gui_get_cache_favicon_name(nsurl *url, bool only_if_avail) +{ + STRPTR filename = NULL; + BPTR lock = 0; + + if (filename = ASPrintf("%s/%x", current_user_faviconcache, nsurl_hash(url))) { + LOG(("favicon cache location: %s", filename)); + + if (only_if_avail == true) { + if(lock = Lock(filename, ACCESS_READ)) { + UnLock(lock); + return filename; + } + } else { + return filename; + } + } + return NULL; +} + +static void ami_gui_cache_favicon(nsurl *url, struct bitmap *favicon) +{ + STRPTR filename = NULL; + + if (filename = ami_gui_get_cache_favicon_name(url, false)) { + if(favicon) bitmap_save(favicon, filename, AMI_BITMAP_FORCE_OVERWRITE); + FreeVec(filename); + } +} + void ami_gui_update_hotlist_button(struct gui_window_2 *gwin) { char *url; @@ -2776,6 +2808,9 @@ void ami_gui_update_hotlist_button(struct gui_window_2 *gwin) if(hotlist_has_url(nsurl)) { RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_FAVE], gwin->win, NULL, BUTTON_RenderImage, gwin->objects[GID_FAVE_RMV], TAG_DONE); + + if (gwin->bw->window->favicon) + ami_gui_cache_favicon(nsurl, content_get_bitmap(gwin->bw->window->favicon)); } else { RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_FAVE], gwin->win, NULL, BUTTON_RenderImage, gwin->objects[GID_FAVE_ADD], TAG_DONE); @@ -2986,7 +3021,10 @@ void ami_gui_hotlist_toolbar_update(struct gui_window_2 *gwin) } } -void ami_gui_hotlist_toolbar_update_all(void) +/** + * Update hotlist toolbar and recreate the menu for all windows + */ +void ami_gui_hotlist_update_all(void) { struct nsObject *node; struct nsObject *nnode; @@ -3003,6 +3041,7 @@ void ami_gui_hotlist_toolbar_update_all(void) if(node->Type == AMINS_WINDOW) { ami_gui_hotlist_toolbar_update(gwin); + ami_menu_refresh(gwin); } } while(node = nnode); } @@ -5118,8 +5157,10 @@ int main(int argc, char** argv) current_user_options = ASPrintf("%s/Choices", current_user_dir); current_user_cache = ASPrintf("%s/Cache", current_user_dir); + current_user_faviconcache = ASPrintf("%s/IconCache", current_user_dir); if(lock = CreateDirTree(current_user_cache)) UnLock(lock); + if(lock = CreateDirTree(current_user_faviconcache)) UnLock(lock); ami_mime_init("PROGDIR:Resources/mimetypes"); sprintf(temp, "%s/mimetypes.user", current_user_dir); diff --git a/amiga/gui.h b/amiga/gui.h index f5a9030c9..c106455d1 100755 --- a/amiga/gui.h +++ b/amiga/gui.h @@ -162,11 +162,12 @@ int ami_key_to_nskey(ULONG keycode, struct InputEvent *ie); bool ami_text_box_at_point(struct gui_window_2 *gwin, ULONG *x, ULONG *y); BOOL ami_gadget_hit(Object *obj, int x, int y); void ami_gui_history(struct gui_window_2 *gwin, bool back); -void ami_gui_hotlist_toolbar_update_all(void); +void ami_gui_hotlist_update_all(void); void ami_gui_tabs_toggle_all(void); bool ami_locate_resource(char *fullpath, const char *file); void ami_gui_update_hotlist_button(struct gui_window_2 *gwin); nserror ami_gui_new_blank_tab(struct gui_window_2 *gwin); +char *ami_gui_get_cache_favicon_name(nsurl *url, bool only_if_avail); struct TextFont *origrpfont; struct MinList *window_list; diff --git a/amiga/launch.c b/amiga/launch.c index 1405d6a71..d3c9ff11e 100755 --- a/amiga/launch.c +++ b/amiga/launch.c @@ -31,6 +31,7 @@ #include <proto/openurl.h> #include "utils/nsoption.h" +#include "utils/nsurl.h" #include "utils/url.h" struct Library *OpenURLBase = NULL; diff --git a/amiga/menu.c b/amiga/menu.c index 43c8c188b..784fec163 100644 --- a/amiga/menu.c +++ b/amiga/menu.c @@ -405,6 +405,13 @@ static struct gui_window_2 *ami_menu_layout(struct gui_window_2 *gwin) BITMAP_SourceFile, gwin->menuicon[i], BITMAP_Masking, TRUE, BitMapEnd; + + /* \todo make this scale the bitmap to these dimensions */ + SetAttrs(icon, + BITMAP_Width, 16, + BITMAP_Height, 16, + TAG_DONE); + GetAttr(IA_Width, icon, (ULONG *)&icon_width); if((gwin->menutype[i] == NM_ITEM) && (gwin->menutype[i+1] == NM_SUB)) { @@ -478,14 +485,6 @@ struct NewMenu *ami_create_menu(struct gui_window_2 *gwin) if(nsoption_bool(background_images) == true) gwin->menu[M_IMGBACK].nm_Flags |= CHECKED; - /* Set up scheduler to refresh the hotlist menu */ - if(nsoption_int(menu_refresh) > 0) - { - ami_schedule(nsoption_int(menu_refresh) * 10, - (void *)ami_menu_refresh, - gwin); - } - return(gwin->menu); } @@ -551,7 +550,7 @@ void ami_menu_arexx_scan(struct gui_window_2 *gwin) static bool ami_menu_hotlist_add(void *userdata, int level, int item, const char *title, nsurl *url, bool is_folder) { UBYTE type; - char *icon; + STRPTR icon; struct gui_window_2 *gw = (struct gui_window_2 *)userdata; if(item >= AMI_MENU_HOTLIST_MAX) return false; @@ -570,9 +569,10 @@ static bool ami_menu_hotlist_add(void *userdata, int level, int item, const char } if(is_folder == true) { - icon = "icons/directory.png"; + icon = ASPrintf("icons/directory.png"); } else { - icon = "icons/content.png"; + icon = ami_gui_get_cache_favicon_name(url, true); + if (icon == NULL) icon = ASPrintf("icons/content.png"); } ami_menu_alloc_item(gw, item, type, title, @@ -580,6 +580,8 @@ static bool ami_menu_hotlist_add(void *userdata, int level, int item, const char if((is_folder == true) && (type == NM_SUB)) gw->menu[item].nm_Flags = NM_ITEMDISABLED; + if(icon) FreeVec(icon); + return true; } diff --git a/amiga/options.h b/amiga/options.h index e383dcf9a..868e28fdb 100644 --- a/amiga/options.h +++ b/amiga/options.h @@ -86,6 +86,4 @@ NSOPTION_INTEGER(redraw_tile_size_y, 0) NSOPTION_INTEGER(monitor_aspect_x, 0) NSOPTION_INTEGER(monitor_aspect_y, 0) NSOPTION_BOOL(accept_lang_locale, true) -NSOPTION_INTEGER(menu_refresh, 0) - diff --git a/amiga/tree.c b/amiga/tree.c index 04c799603..18b071de3 100644 --- a/amiga/tree.c +++ b/amiga/tree.c @@ -711,7 +711,7 @@ void ami_tree_close(struct treeview_window *twin) ami_ssl_free(twin); } - ami_gui_hotlist_toolbar_update_all(); + ami_gui_hotlist_update_all(); } void ami_tree_update_quals(struct treeview_window *twin) diff --git a/beos/Makefile.target b/beos/Makefile.target index a1259d644..bbeb0be22 100644 --- a/beos/Makefile.target +++ b/beos/Makefile.target @@ -38,7 +38,7 @@ ifeq ($(HOST),beos) ifneq ($(wildcard /boot/develop/lib/*/libzeta.so),) LDFLAGS += -lzeta endif - ifneq ($(wildcard /boot/develop/lib/*/libnetwork.so),) + ifneq ($(wildcard /boot/system/develop/lib/*/libnetwork.so),) # Haiku CFLAGS += -I/boot/common/include \ -I/boot/common/include/hubbub \ diff --git a/beos/gui.cpp b/beos/gui.cpp index 8518ba1ac..f9e02d0de 100644 --- a/beos/gui.cpp +++ b/beos/gui.cpp @@ -37,6 +37,7 @@ #include <FindDirectory.h> #include <Mime.h> #include <Path.h> +#include <PathFinder.h> #include <Roster.h> #include <Screen.h> #include <String.h> @@ -79,9 +80,6 @@ extern "C" { static void *myrealloc(void *ptr, size_t len, void *pw); -/* Where to search for shared resources. Must have trailing / */ -#define RESPATH "/boot/apps/netsurf/res/" - //TODO: use resources // enable using resources instead of files #define USE_RESOURCES 1 @@ -297,7 +295,13 @@ static char *find_resource(char *buf, const char *filename, const char *def) return buf; } - strcpy(t, RESPATH); + + BPathFinder f((void*)find_resource); + + BPath p; + f.FindPath(B_FIND_PATH_APPS_DIRECTORY, "netsurf/res/", p); + strcpy(t, p.Path()); + strcat(t, filename); realpath(t, buf); if (access(buf, R_OK) == 0) @@ -488,7 +492,10 @@ static bool nslog_stream_configure(FILE *fptr) static BPath get_messages_path() { - BPath p("/boot/apps/netsurf/res"); + BPathFinder f((void*)get_messages_path); + + BPath p; + f.FindPath(B_FIND_PATH_APPS_DIRECTORY, "netsurf/res", p); // TODO: use Haiku's BLocale stuff BString lang(getenv("LC_MESSAGES")); lang.Truncate(2); @@ -978,9 +985,8 @@ static struct gui_fetch_table beos_fetch_table = { static struct gui_browser_table beos_browser_table = { gui_poll, - beos_schedule, + beos_schedule, gui_quit, - NULL, //set_search_ico gui_launch_url, NULL, //create_form_select_menu NULL, //cert_verify diff --git a/beos/plotters.cpp b/beos/plotters.cpp index c2a99fea0..52ab4ec21 100644 --- a/beos/plotters.cpp +++ b/beos/plotters.cpp @@ -36,6 +36,7 @@ extern "C" { #include "utils/log.h" #include "utils/utils.h" #include "utils/nsoption.h" +#include "utils/nsurl.h" } #include "beos/font.h" #include "beos/gui.h" diff --git a/beos/scaffolding.cpp b/beos/scaffolding.cpp index 35153b33d..0f87420a5 100644 --- a/beos/scaffolding.cpp +++ b/beos/scaffolding.cpp @@ -196,12 +196,11 @@ NSIconTextControl::NSIconTextControl(BRect frame, const char* name, fIconBitmap(NULL) { BRect r(Bounds()); - BRect frame = r; - frame.right = frame.left + ICON_WIDTH - 1; - frame.bottom = frame.top + ICON_WIDTH - 1; - frame.OffsetBy((int32)((r.IntegerHeight() - ICON_WIDTH + 3) / 2), + fIconFrame = r; + fIconFrame.right = fIconFrame.left + ICON_WIDTH - 1; + fIconFrame.bottom = fIconFrame.top + ICON_WIDTH - 1; + fIconFrame.OffsetBy((int32)((r.IntegerHeight() - ICON_WIDTH + 3) / 2), (int32)((r.IntegerHeight() - ICON_WIDTH + 1) / 2)); - fIconFrame = frame; FixupTextRect(); } diff --git a/framebuffer/font_internal.c b/framebuffer/font_internal.c index 5aada8f11..4edb4ee4c 100644 --- a/framebuffer/font_internal.c +++ b/framebuffer/font_internal.c @@ -221,6 +221,12 @@ fb_get_glyph(uint32_t ucs4, enum fb_font_style style) unsigned int offset; uint16_t g_offset; + /* Internal font has no glyphs beyond U+FFFF and there isn't + * space to render a >4 digit codepoint; just show replacement + * character. */ + if (ucs4 > 0xffff) + ucs4 = 0xfffd; + switch (style) { case FB_BOLD_ITALIC: section = fb_bold_italic_section_table[ucs4 / 256]; @@ -287,11 +293,24 @@ static nserror utf8_from_local(const char *string, return NSERROR_OK; } + static bool nsfont_width(const plot_font_style_t *fstyle, const char *string, size_t length, int *width) { - *width = FB_FONT_WIDTH * utf8_bounded_length(string, length); + size_t nxtchr = 0; + + *width = 0; + while (nxtchr < length) { + uint32_t ucs4; + ucs4 = utf8_to_ucs4(string + nxtchr, length - nxtchr); + if (codepoint_displayable(ucs4)) { + *width += FB_FONT_WIDTH; + } + + nxtchr = utf8_next(string, length, nxtchr); + } + return true; } @@ -315,10 +334,15 @@ static bool nsfont_position_in_string(const plot_font_style_t *fstyle, int x_pos = 0; while (nxtchr < length) { + uint32_t ucs4; if (abs(x_pos - x) <= (FB_FONT_WIDTH / 2)) break; - x_pos += FB_FONT_WIDTH; + ucs4 = utf8_to_ucs4(string + nxtchr, length - nxtchr); + if (codepoint_displayable(ucs4)) { + x_pos += FB_FONT_WIDTH; + } + nxtchr = utf8_next(string, length, nxtchr); } @@ -363,13 +387,18 @@ static bool nsfont_split(const plot_font_style_t *fstyle, *actual_x = 0; while (nxtchr < length) { + uint32_t ucs4; if (string[nxtchr] == ' ') { last_space_x = *actual_x; last_space_idx = nxtchr; } - *actual_x += FB_FONT_WIDTH; + ucs4 = utf8_to_ucs4(string + nxtchr, length - nxtchr); + if (codepoint_displayable(ucs4)) { + *actual_x += FB_FONT_WIDTH; + } + if (*actual_x > x && last_space_idx != 0) { /* string has exceeded available width and we've * found a space; return previous space */ diff --git a/framebuffer/font_internal.h b/framebuffer/font_internal.h index 236183ace..ead179c99 100644 --- a/framebuffer/font_internal.h +++ b/framebuffer/font_internal.h @@ -19,6 +19,8 @@ #ifndef NETSURF_FB_FONT_INTERNAL_H #define NETSURF_FB_FONT_INTERNAL_H +#include <stdbool.h> + struct fb_font_desc { const char *name; int width, height, pitch; @@ -39,5 +41,8 @@ enum fb_font_style fb_get_font_style(const plot_font_style_t *fstyle); const uint8_t * fb_get_glyph(uint32_t ucs4, enum fb_font_style style); +#define codepoint_displayable(u) \ + (!(u >= 0x200b && u <= 0x200f)) + #endif /* NETSURF_FB_FONT_INTERNAL_H */ diff --git a/framebuffer/framebuffer.c b/framebuffer/framebuffer.c index 0115d838c..4cd064c34 100644 --- a/framebuffer/framebuffer.c +++ b/framebuffer/framebuffer.c @@ -140,6 +140,9 @@ static bool framebuffer_plot_text(int x, int y, const char *text, size_t length, ucs4 = utf8_to_ucs4(text + nxtchr, length - nxtchr); nxtchr = utf8_next(text, length, nxtchr); + if (!codepoint_displayable(ucs4)) + continue; + loc.x0 = x; loc.y0 = y; loc.x1 = loc.x0 + FB_FONT_WIDTH; |