diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2009-07-23 23:05:34 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2009-07-23 23:05:34 +0000 |
commit | ddeadd1c02880367ad786b113d352a519f45ec73 (patch) | |
tree | 00b8b46ee1a3fc84e5492c2183dfaa8192d261f9 /desktop | |
parent | b20949a35025b23da1bf0ac6003f4575eb94281d (diff) | |
download | netsurf-ddeadd1c02880367ad786b113d352a519f45ec73.tar.gz netsurf-ddeadd1c02880367ad786b113d352a519f45ec73.tar.bz2 |
Merge LibCSS port to trunk.
svn path=/trunk/netsurf/; revision=8752
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/browser.c | 171 | ||||
-rw-r--r-- | desktop/plot_style.c | 2 | ||||
-rw-r--r-- | desktop/plot_style.h | 11 | ||||
-rw-r--r-- | desktop/print.c | 64 | ||||
-rw-r--r-- | desktop/print.h | 4 | ||||
-rw-r--r-- | desktop/save_pdf/font_haru.c | 6 | ||||
-rw-r--r-- | desktop/save_pdf/pdf_plotters.c | 19 | ||||
-rw-r--r-- | desktop/save_text.c | 4 | ||||
-rw-r--r-- | desktop/textarea.c | 16 | ||||
-rw-r--r-- | desktop/textarea.h | 4 |
10 files changed, 162 insertions, 139 deletions
diff --git a/desktop/browser.c b/desktop/browser.c index b188316ea..d19281e9d 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -1421,10 +1421,12 @@ void browser_window_mouse_action_html(struct browser_window *bw, while ((next_box = box_at_point(box, x, y, &box_x, &box_y, &content)) != NULL) { + enum css_overflow overflow = CSS_OVERFLOW_VISIBLE; + box = next_box; - if (box->style && - box->style->visibility == CSS_VISIBILITY_HIDDEN) + if (box->style && css_computed_visibility(box->style) == + CSS_VISIBILITY_HIDDEN) continue; if (box->object) @@ -1458,14 +1460,16 @@ void browser_window_mouse_action_html(struct browser_window *bw, if (box->title) title = box->title; - if (box->style && box->style->cursor != CSS_CURSOR_UNKNOWN) - pointer = get_pointer_shape(bw, box, false); + pointer = get_pointer_shape(bw, box, false); + + if (box->style) + overflow = css_computed_overflow(box->style); if (box->style && box->type != BOX_BR && box->type != BOX_INLINE && box->type != BOX_TEXT && - (box->style->overflow == CSS_OVERFLOW_SCROLL || - box->style->overflow == CSS_OVERFLOW_AUTO) && + (overflow == CSS_OVERFLOW_SCROLL || + overflow == CSS_OVERFLOW_AUTO) && ((box_vscrollbar_present(box) && box_x + box->scroll_x + box->padding[LEFT] + box->width < x) || @@ -2464,7 +2468,9 @@ gui_pointer_shape get_pointer_shape(struct browser_window *bw, struct box *box, bool imagemap) { gui_pointer_shape pointer; - struct css_style *style; + css_computed_style *style; + enum css_cursor cursor; + lwc_string **cursor_uris; assert(bw); @@ -2481,84 +2487,83 @@ gui_pointer_shape get_pointer_shape(struct browser_window *bw, struct box *box, else style = box->style; - assert(style); - switch (style->cursor) { - case CSS_CURSOR_AUTO: - if (box->href || (box->gadget && - (box->gadget->type == GADGET_IMAGE || - box->gadget->type == GADGET_SUBMIT)) || - imagemap) { - /* link */ - pointer = GUI_POINTER_POINT; - } else if (box->gadget && - (box->gadget->type == GADGET_TEXTBOX || - box->gadget->type == GADGET_PASSWORD || - box->gadget->type == GADGET_TEXTAREA)) { - /* text input */ - pointer = GUI_POINTER_CARET; - } else { - /* anything else */ - if (loading) - /* loading new content */ - pointer = GUI_POINTER_PROGRESS; - else - pointer = GUI_POINTER_DEFAULT; - } - break; - case CSS_CURSOR_CROSSHAIR: - pointer = GUI_POINTER_CROSS; - break; - case CSS_CURSOR_POINTER: + if (style == NULL) + return GUI_POINTER_DEFAULT; + + cursor = css_computed_cursor(style, &cursor_uris); + + switch (cursor) { + case CSS_CURSOR_AUTO: + if (box->href || (box->gadget && + (box->gadget->type == GADGET_IMAGE || + box->gadget->type == GADGET_SUBMIT)) || + imagemap) { + /* link */ pointer = GUI_POINTER_POINT; - break; - case CSS_CURSOR_MOVE: - pointer = GUI_POINTER_MOVE; - break; - case CSS_CURSOR_E_RESIZE: - pointer = GUI_POINTER_RIGHT; - break; - case CSS_CURSOR_W_RESIZE: - pointer = GUI_POINTER_LEFT; - break; - case CSS_CURSOR_N_RESIZE: - pointer = GUI_POINTER_UP; - break; - case CSS_CURSOR_S_RESIZE: - pointer = GUI_POINTER_DOWN; - break; - case CSS_CURSOR_NE_RESIZE: - pointer = GUI_POINTER_RU; - break; - case CSS_CURSOR_SW_RESIZE: - pointer = GUI_POINTER_LD; - break; - case CSS_CURSOR_SE_RESIZE: - pointer = GUI_POINTER_RD; - break; - case CSS_CURSOR_NW_RESIZE: - pointer = GUI_POINTER_LU; - break; - case CSS_CURSOR_TEXT: + } else if (box->gadget && + (box->gadget->type == GADGET_TEXTBOX || + box->gadget->type == GADGET_PASSWORD || + box->gadget->type == GADGET_TEXTAREA)) { + /* text input */ pointer = GUI_POINTER_CARET; - break; - case CSS_CURSOR_WAIT: - pointer = GUI_POINTER_WAIT; - break; - case CSS_CURSOR_PROGRESS: - pointer = GUI_POINTER_PROGRESS; - break; - case CSS_CURSOR_NO_DROP: - pointer = GUI_POINTER_NO_DROP; - break; - case CSS_CURSOR_NOT_ALLOWED: - pointer = GUI_POINTER_NOT_ALLOWED; - break; - case CSS_CURSOR_HELP: - pointer = GUI_POINTER_HELP; - break; - default: - pointer = GUI_POINTER_DEFAULT; - break; + } else { + /* anything else */ + if (loading) { + /* loading new content */ + pointer = GUI_POINTER_PROGRESS; + } else { + pointer = GUI_POINTER_DEFAULT; + } + } + break; + case CSS_CURSOR_CROSSHAIR: + pointer = GUI_POINTER_CROSS; + break; + case CSS_CURSOR_POINTER: + pointer = GUI_POINTER_POINT; + break; + case CSS_CURSOR_MOVE: + pointer = GUI_POINTER_MOVE; + break; + case CSS_CURSOR_E_RESIZE: + pointer = GUI_POINTER_RIGHT; + break; + case CSS_CURSOR_W_RESIZE: + pointer = GUI_POINTER_LEFT; + break; + case CSS_CURSOR_N_RESIZE: + pointer = GUI_POINTER_UP; + break; + case CSS_CURSOR_S_RESIZE: + pointer = GUI_POINTER_DOWN; + break; + case CSS_CURSOR_NE_RESIZE: + pointer = GUI_POINTER_RU; + break; + case CSS_CURSOR_SW_RESIZE: + pointer = GUI_POINTER_LD; + break; + case CSS_CURSOR_SE_RESIZE: + pointer = GUI_POINTER_RD; + break; + case CSS_CURSOR_NW_RESIZE: + pointer = GUI_POINTER_LU; + break; + case CSS_CURSOR_TEXT: + pointer = GUI_POINTER_CARET; + break; + case CSS_CURSOR_WAIT: + pointer = GUI_POINTER_WAIT; + break; + case CSS_CURSOR_PROGRESS: + pointer = GUI_POINTER_PROGRESS; + break; + case CSS_CURSOR_HELP: + pointer = GUI_POINTER_HELP; + break; + default: + pointer = GUI_POINTER_DEFAULT; + break; } return pointer; diff --git a/desktop/plot_style.c b/desktop/plot_style.c index 54dbd40ce..94e52ca00 100644 --- a/desktop/plot_style.c +++ b/desktop/plot_style.c @@ -140,7 +140,7 @@ plot_style_t *plot_style_stroke_history = &plot_style_stroke_history_static; /* Generic font style */ static const plot_font_style_t plot_style_font_static = { .family = PLOT_FONT_FAMILY_SANS_SERIF, - .size = 10, + .size = 10 * FONT_SIZE_SCALE, .weight = 400, .flags = FONTF_NONE, .background = 0xffffff, diff --git a/desktop/plot_style.h b/desktop/plot_style.h index 088f0d275..a3b3f0103 100644 --- a/desktop/plot_style.h +++ b/desktop/plot_style.h @@ -23,6 +23,8 @@ #ifndef _NETSURF_DESKTOP_PLOT_STYLE_H_ #define _NETSURF_DESKTOP_PLOT_STYLE_H_ +#include <stdint.h> + /* html widget colours */ #define WIDGET_BASEC 0xd9d9d9 #define WIDGET_BLOBC 0x000000 @@ -63,6 +65,15 @@ ((((c0 & 0xff) + (c1 & 0xff)) >> 1) << 0) /** + * Colour type: XBGR + */ +typedef uint32_t colour; +/** + * Magical transparent value + */ +#define NS_TRANSPARENT 0x01000000 + +/** * Type of plot operation */ typedef enum { diff --git a/desktop/print.c b/desktop/print.c index 1fdd5170d..4f86bbc22 100644 --- a/desktop/print.c +++ b/desktop/print.c @@ -26,10 +26,10 @@ #include <string.h> #include "content/content.h" +#include "css/utils.h" #include "desktop/options.h" #include "desktop/print.h" #include "desktop/printer.h" -#include "render/loosen.h" #include "render/box.h" #include "utils/log.h" #include "utils/talloc.h" @@ -197,8 +197,7 @@ struct content *print_init(struct content *content, } /** - * The content is resized to fit page width. In case it is to wide, it is - * loosened. + * The content is resized to fit page width. * * \param content The content to be printed * \param settings The settings for printing to use @@ -213,24 +212,18 @@ bool print_apply_settings(struct content *content, /*Apply settings - adjust page size etc*/ page_content_width = (settings->page_width - - settings->margins[MARGINLEFT] - - settings->margins[MARGINRIGHT]) / settings->scale; + FIXTOFLT(FSUB(settings->margins[MARGINLEFT], + settings->margins[MARGINRIGHT]))) / settings->scale; page_content_height = (settings->page_height - - settings->margins[MARGINTOP] - - settings->margins[MARGINBOTTOM]) / settings->scale; + FIXTOFLT(FSUB(settings->margins[MARGINTOP], + settings->margins[MARGINBOTTOM]))) / settings->scale; content_reformat(content, page_content_width, 0); LOG(("New layout applied.New height = %d ; New width = %d ", content->height, content->width)); - /*check if loosening is necessary and requested*/ - if (option_enable_loosening && content->width > page_content_width) - return loosen_document_layout(content, - content->data.html.layout, - page_content_width, page_content_height); - return true; } @@ -275,9 +268,8 @@ struct print_settings *print_make_settings(print_configuration configuration, const char *filename, const struct font_functions *font_func) { struct print_settings *settings; - struct css_length length; - - length.unit = CSS_UNIT_MM; + css_fixed length = 0; + css_unit unit = CSS_UNIT_MM; switch (configuration){ case PRINT_DEFAULT: @@ -292,14 +284,18 @@ struct print_settings *print_make_settings(print_configuration configuration, settings->scale = DEFAULT_EXPORT_SCALE; - length.value = DEFAULT_MARGIN_LEFT_MM; - settings->margins[MARGINLEFT] = css_len2px(&length, 0); - length.value = DEFAULT_MARGIN_RIGHT_MM; - settings->margins[MARGINRIGHT] = css_len2px(&length, 0); - length.value = DEFAULT_MARGIN_TOP_MM; - settings->margins[MARGINTOP] = css_len2px(&length, 0); - length.value = DEFAULT_MARGIN_BOTTOM_MM; - settings->margins[MARGINBOTTOM] = css_len2px(&length, 0); + length = INTTOFIX(DEFAULT_MARGIN_LEFT_MM); + settings->margins[MARGINLEFT] = + nscss_len2px(length, unit, NULL); + length = INTTOFIX(DEFAULT_MARGIN_RIGHT_MM); + settings->margins[MARGINRIGHT] = + nscss_len2px(length, unit, NULL); + length = INTTOFIX(DEFAULT_MARGIN_TOP_MM); + settings->margins[MARGINTOP] = + nscss_len2px(length, unit, NULL); + length = INTTOFIX(DEFAULT_MARGIN_BOTTOM_MM); + settings->margins[MARGINBOTTOM] = + nscss_len2px(length, unit, NULL); break; /* use settings from the Export options tab */ case PRINT_OPTIONS: @@ -314,14 +310,18 @@ struct print_settings *print_make_settings(print_configuration configuration, settings->scale = (float)option_export_scale / 100; - length.value = option_margin_left; - settings->margins[MARGINLEFT] = css_len2px(&length, 0); - length.value = option_margin_right; - settings->margins[MARGINRIGHT] = css_len2px(&length, 0); - length.value = option_margin_top; - settings->margins[MARGINTOP] = css_len2px(&length, 0); - length.value = option_margin_bottom; - settings->margins[MARGINBOTTOM] = css_len2px(&length, 0); + length = INTTOFIX(option_margin_left); + settings->margins[MARGINLEFT] = + nscss_len2px(length, unit, NULL); + length = INTTOFIX(option_margin_right); + settings->margins[MARGINRIGHT] = + nscss_len2px(length, unit, NULL); + length = INTTOFIX(option_margin_top); + settings->margins[MARGINTOP] = + nscss_len2px(length, unit, NULL); + length = INTTOFIX(option_margin_bottom); + settings->margins[MARGINBOTTOM] = + nscss_len2px(length, unit, NULL); break; default: return NULL; diff --git a/desktop/print.h b/desktop/print.h index bc07e377e..fece526be 100644 --- a/desktop/print.h +++ b/desktop/print.h @@ -34,6 +34,8 @@ #include <stdbool.h> +#include "css/css.h" + struct content; struct printer; @@ -48,7 +50,7 @@ typedef enum { PRINT_DEFAULT, PRINT_OPTIONS } print_configuration; struct print_settings{ /*Standard parameters*/ float page_width, page_height; - int margins[4]; + css_fixed margins[4]; float scale; diff --git a/desktop/save_pdf/font_haru.c b/desktop/save_pdf/font_haru.c index 0bf86c340..c90753121 100644 --- a/desktop/save_pdf/font_haru.c +++ b/desktop/save_pdf/font_haru.c @@ -37,6 +37,7 @@ #include <hpdf.h> #include "css/css.h" +#include "css/utils.h" #include "desktop/options.h" #include "desktop/save_pdf/font_haru.h" @@ -216,8 +217,7 @@ bool haru_nsfont_position_in_string(const plot_font_style_t *fstyle, /** * Find where to split a string to make it fit a width. * - * \param fstyle css_style for this text, with style->font_size.size == - * CSS_FONT_SIZE_LENGTH + * \param fstyle style for this text * \param string string to measure (no UTF-8 currently) * \param length length of string * \param x width available @@ -268,7 +268,7 @@ bool haru_nsfont_split(const plot_font_style_t *fstyle, /** * Apply font style to a Haru HPDF_Page * - * \param style plot style for this page + * \param fstyle plot style for this page * \param doc document owning the page * \param page the page to apply the style to * \param font if this is non NULL it is updated to the font based diff --git a/desktop/save_pdf/pdf_plotters.c b/desktop/save_pdf/pdf_plotters.c index a29db2415..8dbe43971 100644 --- a/desktop/save_pdf/pdf_plotters.c +++ b/desktop/save_pdf/pdf_plotters.c @@ -146,7 +146,7 @@ bool pdf_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *psty { DashPattern_e dash; #ifdef PDF_DEBUG - LOG(("%d %d %d %d %f %X", x0, y0, x1, y1, page_height - y0, style->fill_colour)); + LOG(("%d %d %d %d %f %X", x0, y0, x1, y1, page_height - y0, pstyle->fill_colour)); #endif if (pstyle->fill_type != PLOT_OP_TYPE_NONE) { @@ -353,7 +353,7 @@ bool pdf_plot_disc(int x, int y, int radius, const plot_style_t *style) bool pdf_plot_arc(int x, int y, int radius, int angle1, int angle2, const plot_style_t *style) { #ifdef PDF_DEBUG - LOG(("%d %d %d %d %d %X", x, y, radius, angle1, angle2, c)); + LOG(("%d %d %d %d %d %X", x, y, radius, angle1, angle2, style->stroke_colour)); #endif /* FIXME: line width 1 is ok ? */ @@ -381,8 +381,8 @@ bool pdf_plot_bitmap_tile(int x, int y, int width, int height, HPDF_REAL max_width, max_height; #ifdef PDF_DEBUG - LOG(("%d %d %d %d %p 0x%x %p", x, y, width, height, - bitmap, bg, content)); + LOG(("%d %d %d %d %p 0x%x", x, y, width, height, + bitmap, bg)); #endif if (width == 0 || height == 0) return true; @@ -662,10 +662,12 @@ bool pdf_begin(struct print_settings *print_settings) settings = print_settings; - page_width = settings->page_width - settings->margins[MARGINLEFT] - - settings->margins[MARGINRIGHT]; + page_width = settings->page_width - + FIXTOFLT(FSUB(settings->margins[MARGINLEFT], + settings->margins[MARGINRIGHT])); - page_height = settings->page_height - settings->margins[MARGINTOP]; + page_height = settings->page_height - + FIXTOFLT(settings->margins[MARGINTOP]); #ifndef PDF_DEBUG @@ -708,7 +710,8 @@ bool pdf_next_page(void) HPDF_Page_SetWidth (pdf_page, settings->page_width); HPDF_Page_SetHeight(pdf_page, settings->page_height); - HPDF_Page_Concat(pdf_page, 1, 0, 0, 1, settings->margins[MARGINLEFT], 0); + HPDF_Page_Concat(pdf_page, 1, 0, 0, 1, + FIXTOFLT(settings->margins[MARGINLEFT]), 0); pdfw_gs_save(pdf_page); diff --git a/desktop/save_text.c b/desktop/save_text.c index 535fec461..15f41702e 100644 --- a/desktop/save_text.c +++ b/desktop/save_text.c @@ -141,9 +141,9 @@ void save_text_solve_whitespace(struct box *box, bool *first, (box->type != BOX_INLINE && (box->parent && box->parent->list_marker == box)) || (box->parent->style && - (box->parent->style->white_space == + (css_computed_white_space(box->parent->style) == CSS_WHITE_SPACE_PRE || - box->parent->style->white_space == + css_computed_white_space(box->parent->style) == CSS_WHITE_SPACE_PRE_WRAP) && box->type == BOX_INLINE_CONTAINER))) { if (*before == WHITESPACE_ONE_NEW_LINE) diff --git a/desktop/textarea.c b/desktop/textarea.c index 1b48d9d55..43ac85b0c 100644 --- a/desktop/textarea.c +++ b/desktop/textarea.c @@ -24,6 +24,7 @@ #include <stdint.h> #include <string.h> #include "css/css.h" +#include "css/utils.h" #include "desktop/textarea.h" #include "desktop/textinput.h" #include "desktop/plotters.h" @@ -135,14 +136,14 @@ static void textarea_normalise_text(struct text_area *ta, * \param width width of the text area * \param height width of the text area * \param flags text area flags - * \param style css style (font style properties are used only) + * \param style font style * \param redraw_start_callback will be called when textarea wants to redraw * \param redraw_end_callback will be called when textarea finisjes redrawing * \param data user specified data which will be passed to redraw callbacks * \return Opaque handle for textarea or 0 on error */ struct text_area *textarea_create(int x, int y, int width, int height, - unsigned int flags, const struct css_style *style, + unsigned int flags, const plot_font_style_t *style, textarea_start_redraw_callback redraw_start_callback, textarea_end_redraw_callback redraw_end_callback, void *data) { @@ -183,9 +184,10 @@ struct text_area *textarea_create(int x, int y, int width, int height, ret->text_len = 1; ret->text_utf8_len = 0; - font_plot_style_from_css(style, &ret->fstyle); - ret->line_height = css_len2px(&(style->line_height.value.length), - style); + ret->fstyle = *style; + + ret->line_height = FIXTOINT(FDIVI(FMUL( + FLTTOFIX(1.2 * style->size), nscss_screen_dpi), 72)); ret->caret_pos.line = ret->caret_pos.char_off = 0; ret->selection_start = -1; @@ -427,7 +429,7 @@ bool textarea_set_caret(struct text_area *ta, int caret) int index; int x, y; int x0, y0, x1, y1; - int height; + int height = 0; if (ta->flags & TEXTAREA_READONLY) @@ -440,7 +442,7 @@ bool textarea_set_caret(struct text_area *ta, int caret) if (caret != -1 && (unsigned)caret > c_len) caret = c_len; - height = ta->fstyle.size * css_screen_dpi / 72; + height = ta->fstyle.size * nscss_screen_dpi / 72; /* Delete the old caret */ if (ta->caret_pos.char_off != -1) { diff --git a/desktop/textarea.h b/desktop/textarea.h index 14e93f5e8..ca02927b4 100644 --- a/desktop/textarea.h +++ b/desktop/textarea.h @@ -26,8 +26,8 @@ #include <stdint.h> #include <stdbool.h> -#include "css/css.h" #include "desktop/browser.h" +#include "desktop/plot_style.h" /* Text area flags */ #define TEXTAREA_MULTILINE 0x01 /**< Text area is multiline */ @@ -39,7 +39,7 @@ typedef void(*textarea_start_redraw_callback)(void *data); typedef void(*textarea_end_redraw_callback)(void *data); struct text_area *textarea_create(int x, int y, int width, int height, - unsigned int flags, const struct css_style *style, + unsigned int flags, const plot_font_style_t *style, textarea_start_redraw_callback redraw_start_callback, textarea_end_redraw_callback redraw_end_callback, void *data); void textarea_set_position(struct text_area *ta, int x, int y); |