2004-10-18 01:05:12 +04:00
|
|
|
/*
|
2008-01-28 07:33:39 +03:00
|
|
|
* Copyright 2004-2008 James Bursa <bursa@users.sourceforge.net>
|
|
|
|
* Copyright 2004-2007 John M Bell <jmb202@ecs.soton.ac.uk>
|
|
|
|
* Copyright 2004-2007 Richard Wilson <info@tinct.net>
|
|
|
|
* Copyright 2005-2006 Adrian Lees <adrianl@users.sourceforge.net>
|
|
|
|
* Copyright 2006 Rob Kendrick <rjek@netsurf-browser.org>
|
|
|
|
* Copyright 2008 Michael Drake <tlsa@netsurf-browser.org>
|
2009-08-14 14:37:33 +04:00
|
|
|
* Copyright 2009 Paul Blokus <paul_pl@users.sourceforge.net>
|
2007-08-08 20:16:03 +04:00
|
|
|
*
|
|
|
|
* 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 <http://www.gnu.org/licenses/>.
|
2004-10-18 01:05:12 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
* Redraw of a CONTENT_HTML (implementation).
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <string.h>
|
2008-07-29 00:32:51 +04:00
|
|
|
#include <math.h>
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "utils/config.h"
|
|
|
|
#include "content/content.h"
|
|
|
|
#include "css/css.h"
|
2009-07-24 03:05:34 +04:00
|
|
|
#include "css/utils.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "desktop/gui.h"
|
|
|
|
#include "desktop/plotters.h"
|
|
|
|
#include "desktop/knockout.h"
|
|
|
|
#include "desktop/selection.h"
|
|
|
|
#include "desktop/textinput.h"
|
|
|
|
#include "desktop/options.h"
|
Second merge of Adam Blokus' GSoC work from his branch 'branches/adamblokus/netsurf'.
Merged revisions 4195-4211,4216,4219-4220,4222-4234,4236-4250,4252-4262,4264-4266,4268-4326,4329-4335,4338-4342,4344-4411,4413-4420,4422-4436,4438-4491,4494-4506,4508-4514,4516,4518-4552,4554,4556-4564,4567-4568,4570-4574,4576-4686,4689-4692,4694,4698-4709,4715-4723,4725-4755,4757-4769,4771-4919,4921-4996,4998-5110,5112-5117 via svnmerge from
svn://svn.netsurf-browser.org/branches/adamblokus/netsurf
........
r4736 | adamblokus | 2008-07-26 13:46:54 +0200 (Sat, 26 Jul 2008) | 2 lines
Sorting out some problems with svn.
........
r4737 | adamblokus | 2008-07-26 13:54:36 +0200 (Sat, 26 Jul 2008) | 4 lines
Added export tab to the options dialog.
Added the possibility of changing some print options.
........
r4897 | adamblokus | 2008-08-04 17:59:05 +0200 (Mon, 04 Aug 2008) | 5 lines
Added checking of horizontal clipping.
Added better table loosening.
Changed some minor bugs.
Applied changes in the Export options tab according to the review from tlsa.
........
r4905 | adamblokus | 2008-08-05 01:53:34 +0200 (Tue, 05 Aug 2008) | 2 lines
Fixed bug which made it impossible to export pdf's.
........
r4919 | adamblokus | 2008-08-05 16:39:33 +0200 (Tue, 05 Aug 2008) | 2 lines
Fixed some memory leaks which caused Netsurf to break.
........
r4927 | adamblokus | 2008-08-06 02:26:30 +0200 (Wed, 06 Aug 2008) | 4 lines
Fixed bug with filenames which crashed Netsurf.
Turned anti aliasing off for printing.
Fixed some scaling issues.
........
r4928 | adamblokus | 2008-08-06 17:52:44 +0200 (Wed, 06 Aug 2008) | 5 lines
Added new export/print options:
- suppressing images
- turning off backgrounds
- toggled loosening
........
r4950 | adamblokus | 2008-08-07 21:15:21 +0200 (Thu, 07 Aug 2008) | 5 lines
Added new options to PDF export:
- document compression
- document encryption
Added PDF password dialog
........
r4954 | adamblokus | 2008-08-07 22:11:31 +0200 (Thu, 07 Aug 2008) | 2 lines
Added saving print settings.
........
r4956 | adamblokus | 2008-08-07 22:44:48 +0200 (Thu, 07 Aug 2008) | 2 lines
Fixes to PDF encryption
........
r4970 | adamblokus | 2008-08-09 15:26:24 +0200 (Sat, 09 Aug 2008) | 3 lines
Fixed bug in plotting tiled bitmaps.
Fixed bug with too long text decorations.
........
r4977 | adamblokus | 2008-08-09 19:18:56 +0200 (Sat, 09 Aug 2008) | 2 lines
Fixed JPG embedding bug.
........
r4988 | adamblokus | 2008-08-10 16:59:51 +0200 (Sun, 10 Aug 2008) | 3 lines
Added clip checking to pdf plotters. No more "blank" clips.
Made PDF compression a default setting.
........
r4995 | adamblokus | 2008-08-10 20:03:00 +0200 (Sun, 10 Aug 2008) | 2 lines
Fixed Haru crash on font-size==0.
........
r4996 | adamblokus | 2008-08-10 21:04:43 +0200 (Sun, 10 Aug 2008) | 2 lines
Added changing text mode only if necessary.
........
r5045 | adamblokus | 2008-08-11 21:26:26 +0200 (Mon, 11 Aug 2008) | 3 lines
Removing gtk stuff from core code.
Little fix in options.
........
r5048 | adamblokus | 2008-08-11 21:57:45 +0200 (Mon, 11 Aug 2008) | 2 lines
Better font size checking in PDF export.
........
r5050 | adamblokus | 2008-08-11 22:19:56 +0200 (Mon, 11 Aug 2008) | 2 lines
Fixed riscos text scale bug.
........
r5073 | adamblokus | 2008-08-12 17:40:57 +0200 (Tue, 12 Aug 2008) | 2 lines
Added missing tooltips
........
r5092 | adamblokus | 2008-08-13 17:09:25 +0200 (Wed, 13 Aug 2008) | 2 lines
Moved /pdf folder to desktop/save_pdf
........
r5110 | adamblokus | 2008-08-13 22:44:50 +0200 (Wed, 13 Aug 2008) | 2 lines
Added comments.
........
r5113 | adamblokus | 2008-08-13 23:07:35 +0200 (Wed, 13 Aug 2008) | 2 lines
Cosmetic changes
........
r5116 | adamblokus | 2008-08-14 16:10:18 +0200 (Thu, 14 Aug 2008) | 2 lines
Fixed bug with BOX_INLINE_END in tree duplication.
........
r5117 | joty | 2008-08-14 21:47:46 +0200 (Thu, 14 Aug 2008) | 1 line
Improvement for r5116: use local vars when possible; rename global last to box_duplicate_last; check on box_duplicate_main_tree failure.
........
svn path=/trunk/netsurf/; revision=5118
2008-08-15 00:32:10 +04:00
|
|
|
#include "desktop/print.h"
|
2009-08-14 14:37:33 +04:00
|
|
|
#include "desktop/scroll.h"
|
2008-10-14 04:12:31 +04:00
|
|
|
#include "image/bitmap.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "render/box.h"
|
|
|
|
#include "render/font.h"
|
|
|
|
#include "render/form.h"
|
|
|
|
#include "render/layout.h"
|
|
|
|
#include "utils/log.h"
|
|
|
|
#include "utils/messages.h"
|
|
|
|
#include "utils/utils.h"
|
2004-10-18 01:05:12 +04:00
|
|
|
|
|
|
|
|
|
|
|
static bool html_redraw_box(struct box *box,
|
|
|
|
int x, int y,
|
|
|
|
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
|
2008-12-21 18:51:23 +03:00
|
|
|
float scale, colour current_background_color);
|
2006-06-26 03:07:24 +04:00
|
|
|
static bool html_redraw_box_children(struct box *box,
|
|
|
|
int x_parent, int y_parent,
|
|
|
|
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
|
|
|
|
float scale, colour current_background_color);
|
2005-07-18 20:38:59 +04:00
|
|
|
static bool html_redraw_text_box(struct box *box, int x, int y,
|
|
|
|
int x0, int y0, int x1, int y1,
|
|
|
|
float scale, colour current_background_color);
|
2006-02-16 02:09:55 +03:00
|
|
|
static bool html_redraw_caret(struct caret *caret,
|
2006-02-20 05:29:19 +03:00
|
|
|
colour current_background_color, float scale);
|
2005-05-24 02:14:09 +04:00
|
|
|
static bool html_redraw_borders(struct box *box, int x_parent, int y_parent,
|
2008-12-26 14:34:23 +03:00
|
|
|
int p_width, int p_height, float scale);
|
2008-12-21 18:51:23 +03:00
|
|
|
bool html_redraw_inline_borders(struct box *box, int x0, int y0, int x1, int y1,
|
|
|
|
float scale, bool first, bool last);
|
2005-05-24 02:14:09 +04:00
|
|
|
static bool html_redraw_border_plot(int i, int *p, colour c,
|
2009-08-02 23:19:43 +04:00
|
|
|
enum css_border_style_e style, int thickness);
|
2004-10-18 01:05:12 +04:00
|
|
|
static bool html_redraw_checkbox(int x, int y, int width, int height,
|
|
|
|
bool selected);
|
|
|
|
static bool html_redraw_radio(int x, int y, int width, int height,
|
|
|
|
bool selected);
|
|
|
|
static bool html_redraw_file(int x, int y, int width, int height,
|
|
|
|
struct box *box, float scale, colour background_colour);
|
2005-04-29 05:34:19 +04:00
|
|
|
static bool html_redraw_background(int x, int y, struct box *box, float scale,
|
|
|
|
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
|
2007-09-17 18:53:02 +04:00
|
|
|
colour *background_colour, struct box *background);
|
2008-12-21 18:51:23 +03:00
|
|
|
static bool html_redraw_inline_background(int x, int y, struct box *box,
|
|
|
|
float scale, int clip_x0, int clip_y0,
|
|
|
|
int clip_x1, int clip_y1, int px0, int py0, int px1, int py1,
|
|
|
|
bool first, bool last, colour *background_colour);
|
2005-05-23 01:50:14 +04:00
|
|
|
static bool html_redraw_text_decoration(struct box *box,
|
|
|
|
int x_parent, int y_parent, float scale,
|
|
|
|
colour background_colour);
|
|
|
|
static bool html_redraw_text_decoration_inline(struct box *box, int x, int y,
|
|
|
|
float scale, colour colour, float ratio);
|
|
|
|
static bool html_redraw_text_decoration_block(struct box *box, int x, int y,
|
|
|
|
float scale, colour colour, float ratio);
|
2004-10-18 01:05:12 +04:00
|
|
|
|
|
|
|
bool html_redraw_debug = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Draw a CONTENT_HTML using the current set of plotters (plot).
|
|
|
|
*
|
2004-11-11 02:02:11 +03:00
|
|
|
* \param c content of type CONTENT_HTML
|
|
|
|
* \param x coordinate for top-left of redraw
|
|
|
|
* \param y coordinate for top-left of redraw
|
|
|
|
* \param width available width (not used for HTML redraw)
|
|
|
|
* \param height available height (not used for HTML redraw)
|
|
|
|
* \param clip_x0 clip rectangle
|
|
|
|
* \param clip_y0 clip rectangle
|
|
|
|
* \param clip_x1 clip rectangle
|
|
|
|
* \param clip_y1 clip rectangle
|
|
|
|
* \param scale scale for redraw
|
2004-10-18 01:05:12 +04:00
|
|
|
* \param background_colour the background colour
|
|
|
|
* \return true if successful, false otherwise
|
|
|
|
*
|
|
|
|
* x, y, clip_[xy][01] are in target coordinates.
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool html_redraw(struct content *c, int x, int y,
|
|
|
|
int width, int height,
|
|
|
|
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
|
2008-09-29 02:37:13 +04:00
|
|
|
float scale, colour background_colour)
|
2004-10-18 01:05:12 +04:00
|
|
|
{
|
|
|
|
struct box *box;
|
2009-08-14 14:37:33 +04:00
|
|
|
bool result = true, want_knockout;
|
|
|
|
bool select, select_only;
|
2009-07-06 14:33:19 +04:00
|
|
|
plot_style_t pstyle_fill_bg = {
|
|
|
|
.fill_type = PLOT_OP_TYPE_SOLID,
|
|
|
|
.fill_colour = background_colour,
|
|
|
|
};
|
2004-10-18 01:05:12 +04:00
|
|
|
|
|
|
|
box = c->data.html.layout;
|
|
|
|
assert(box);
|
|
|
|
|
2008-07-30 23:17:27 +04:00
|
|
|
want_knockout = plot.option_knockout;
|
|
|
|
if (want_knockout)
|
|
|
|
knockout_plot_start(&plot);
|
2006-07-01 22:16:05 +04:00
|
|
|
|
2009-08-14 14:37:33 +04:00
|
|
|
/* The select menu needs special treating because, when opened, it
|
|
|
|
* reaches beyond its layout box.
|
|
|
|
*/
|
|
|
|
select = false;
|
|
|
|
select_only = false;
|
|
|
|
if (current_redraw_browser != NULL &&
|
|
|
|
current_redraw_browser->visible_select_menu != NULL) {
|
|
|
|
struct form_control *control =
|
|
|
|
current_redraw_browser->visible_select_menu;
|
|
|
|
select = true;
|
|
|
|
/* check if the redraw rectangle is completely inside of the
|
|
|
|
select menu */
|
|
|
|
select_only = form_clip_inside_select_menu(control, scale,
|
|
|
|
clip_x0, clip_y0, clip_x1, clip_y1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!select_only) {
|
|
|
|
/* clear to background colour */
|
|
|
|
result = plot.clip(clip_x0, clip_y0, clip_x1, clip_y1);
|
|
|
|
|
|
|
|
if (c->data.html.background_colour != NS_TRANSPARENT)
|
|
|
|
pstyle_fill_bg.fill_colour =
|
|
|
|
c->data.html.background_colour;
|
|
|
|
|
|
|
|
result &= plot.rectangle(clip_x0, clip_y0, clip_x1, clip_y1,
|
|
|
|
&pstyle_fill_bg);
|
|
|
|
|
|
|
|
result &= html_redraw_box(box, x, y,
|
|
|
|
clip_x0, clip_y0, clip_x1, clip_y1,
|
|
|
|
scale, pstyle_fill_bg.fill_colour);
|
|
|
|
}
|
2006-07-01 22:16:05 +04:00
|
|
|
|
2009-08-14 14:37:33 +04:00
|
|
|
if (select) {
|
|
|
|
int menu_x, menu_y;
|
|
|
|
box = current_redraw_browser->visible_select_menu->box;
|
|
|
|
box_coords(box, &menu_x, &menu_y);
|
|
|
|
|
|
|
|
menu_x -= box->border[LEFT].width;
|
|
|
|
menu_y += box->height + box->border[BOTTOM].width +
|
|
|
|
box->padding[BOTTOM] + box->padding[TOP];
|
|
|
|
result &= form_redraw_select_menu(
|
|
|
|
current_redraw_browser->visible_select_menu,
|
|
|
|
x + menu_x, y + menu_y,
|
|
|
|
current_redraw_browser->scale,
|
|
|
|
clip_x0, clip_y0, clip_x1, clip_y1);
|
|
|
|
}
|
|
|
|
|
2008-07-30 23:17:27 +04:00
|
|
|
if (want_knockout)
|
|
|
|
knockout_plot_end();
|
2006-07-01 22:16:05 +04:00
|
|
|
|
|
|
|
return result;
|
|
|
|
|
2004-10-18 01:05:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Recursively draw a box.
|
|
|
|
*
|
2004-11-11 02:02:11 +03:00
|
|
|
* \param box box to draw
|
2005-03-23 19:42:37 +03:00
|
|
|
* \param x_parent coordinate of parent box
|
|
|
|
* \param y_parent coordinate of parent box
|
2004-10-18 01:05:12 +04:00
|
|
|
* \param clip_x0 clip rectangle
|
|
|
|
* \param clip_y0 clip rectangle
|
|
|
|
* \param clip_x1 clip rectangle
|
|
|
|
* \param clip_y1 clip rectangle
|
|
|
|
* \param scale scale for redraw
|
|
|
|
* \param current_background_color background colour under this box
|
2008-07-19 22:46:17 +04:00
|
|
|
* \param inline_depth depth of nested inlines inside an inline container
|
2004-10-18 01:05:12 +04:00
|
|
|
* \return true if successful, false otherwise
|
|
|
|
*
|
|
|
|
* x, y, clip_[xy][01] are in target coordinates.
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool html_redraw_box(struct box *box,
|
2005-03-23 19:42:37 +03:00
|
|
|
int x_parent, int y_parent,
|
2004-10-18 01:05:12 +04:00
|
|
|
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
|
2008-12-21 18:51:23 +03:00
|
|
|
float scale, colour current_background_color)
|
2004-10-18 01:05:12 +04:00
|
|
|
{
|
2005-03-23 19:42:37 +03:00
|
|
|
int x, y;
|
2004-10-18 01:05:12 +04:00
|
|
|
int width, height;
|
|
|
|
int padding_left, padding_top, padding_width, padding_height;
|
2008-01-28 07:33:39 +03:00
|
|
|
int border_left, border_top, border_right, border_bottom;
|
2004-10-18 01:05:12 +04:00
|
|
|
int x0, y0, x1, y1;
|
|
|
|
int x_scrolled, y_scrolled;
|
2007-09-17 18:53:02 +04:00
|
|
|
struct box *bg_box = NULL;
|
2009-07-24 03:05:34 +04:00
|
|
|
css_color bgcol = 0;
|
2009-08-14 14:37:33 +04:00
|
|
|
bool has_x_scroll, has_y_scroll;
|
2008-08-25 23:30:10 +04:00
|
|
|
|
Second merge of Adam Blokus' GSoC work from his branch 'branches/adamblokus/netsurf'.
Merged revisions 4195-4211,4216,4219-4220,4222-4234,4236-4250,4252-4262,4264-4266,4268-4326,4329-4335,4338-4342,4344-4411,4413-4420,4422-4436,4438-4491,4494-4506,4508-4514,4516,4518-4552,4554,4556-4564,4567-4568,4570-4574,4576-4686,4689-4692,4694,4698-4709,4715-4723,4725-4755,4757-4769,4771-4919,4921-4996,4998-5110,5112-5117 via svnmerge from
svn://svn.netsurf-browser.org/branches/adamblokus/netsurf
........
r4736 | adamblokus | 2008-07-26 13:46:54 +0200 (Sat, 26 Jul 2008) | 2 lines
Sorting out some problems with svn.
........
r4737 | adamblokus | 2008-07-26 13:54:36 +0200 (Sat, 26 Jul 2008) | 4 lines
Added export tab to the options dialog.
Added the possibility of changing some print options.
........
r4897 | adamblokus | 2008-08-04 17:59:05 +0200 (Mon, 04 Aug 2008) | 5 lines
Added checking of horizontal clipping.
Added better table loosening.
Changed some minor bugs.
Applied changes in the Export options tab according to the review from tlsa.
........
r4905 | adamblokus | 2008-08-05 01:53:34 +0200 (Tue, 05 Aug 2008) | 2 lines
Fixed bug which made it impossible to export pdf's.
........
r4919 | adamblokus | 2008-08-05 16:39:33 +0200 (Tue, 05 Aug 2008) | 2 lines
Fixed some memory leaks which caused Netsurf to break.
........
r4927 | adamblokus | 2008-08-06 02:26:30 +0200 (Wed, 06 Aug 2008) | 4 lines
Fixed bug with filenames which crashed Netsurf.
Turned anti aliasing off for printing.
Fixed some scaling issues.
........
r4928 | adamblokus | 2008-08-06 17:52:44 +0200 (Wed, 06 Aug 2008) | 5 lines
Added new export/print options:
- suppressing images
- turning off backgrounds
- toggled loosening
........
r4950 | adamblokus | 2008-08-07 21:15:21 +0200 (Thu, 07 Aug 2008) | 5 lines
Added new options to PDF export:
- document compression
- document encryption
Added PDF password dialog
........
r4954 | adamblokus | 2008-08-07 22:11:31 +0200 (Thu, 07 Aug 2008) | 2 lines
Added saving print settings.
........
r4956 | adamblokus | 2008-08-07 22:44:48 +0200 (Thu, 07 Aug 2008) | 2 lines
Fixes to PDF encryption
........
r4970 | adamblokus | 2008-08-09 15:26:24 +0200 (Sat, 09 Aug 2008) | 3 lines
Fixed bug in plotting tiled bitmaps.
Fixed bug with too long text decorations.
........
r4977 | adamblokus | 2008-08-09 19:18:56 +0200 (Sat, 09 Aug 2008) | 2 lines
Fixed JPG embedding bug.
........
r4988 | adamblokus | 2008-08-10 16:59:51 +0200 (Sun, 10 Aug 2008) | 3 lines
Added clip checking to pdf plotters. No more "blank" clips.
Made PDF compression a default setting.
........
r4995 | adamblokus | 2008-08-10 20:03:00 +0200 (Sun, 10 Aug 2008) | 2 lines
Fixed Haru crash on font-size==0.
........
r4996 | adamblokus | 2008-08-10 21:04:43 +0200 (Sun, 10 Aug 2008) | 2 lines
Added changing text mode only if necessary.
........
r5045 | adamblokus | 2008-08-11 21:26:26 +0200 (Mon, 11 Aug 2008) | 3 lines
Removing gtk stuff from core code.
Little fix in options.
........
r5048 | adamblokus | 2008-08-11 21:57:45 +0200 (Mon, 11 Aug 2008) | 2 lines
Better font size checking in PDF export.
........
r5050 | adamblokus | 2008-08-11 22:19:56 +0200 (Mon, 11 Aug 2008) | 2 lines
Fixed riscos text scale bug.
........
r5073 | adamblokus | 2008-08-12 17:40:57 +0200 (Tue, 12 Aug 2008) | 2 lines
Added missing tooltips
........
r5092 | adamblokus | 2008-08-13 17:09:25 +0200 (Wed, 13 Aug 2008) | 2 lines
Moved /pdf folder to desktop/save_pdf
........
r5110 | adamblokus | 2008-08-13 22:44:50 +0200 (Wed, 13 Aug 2008) | 2 lines
Added comments.
........
r5113 | adamblokus | 2008-08-13 23:07:35 +0200 (Wed, 13 Aug 2008) | 2 lines
Cosmetic changes
........
r5116 | adamblokus | 2008-08-14 16:10:18 +0200 (Thu, 14 Aug 2008) | 2 lines
Fixed bug with BOX_INLINE_END in tree duplication.
........
r5117 | joty | 2008-08-14 21:47:46 +0200 (Thu, 14 Aug 2008) | 1 line
Improvement for r5116: use local vars when possible; rename global last to box_duplicate_last; check on box_duplicate_main_tree failure.
........
svn path=/trunk/netsurf/; revision=5118
2008-08-15 00:32:10 +04:00
|
|
|
if (html_redraw_printing && box->printed)
|
|
|
|
return true;
|
2004-10-18 01:05:12 +04:00
|
|
|
|
2005-04-15 09:52:11 +04:00
|
|
|
/* avoid trivial FP maths */
|
|
|
|
if (scale == 1.0) {
|
2005-05-24 02:14:09 +04:00
|
|
|
x = x_parent + box->x;
|
|
|
|
y = y_parent + box->y;
|
2005-04-15 09:52:11 +04:00
|
|
|
width = box->width;
|
|
|
|
height = box->height;
|
|
|
|
padding_left = box->padding[LEFT];
|
|
|
|
padding_top = box->padding[TOP];
|
|
|
|
padding_width = padding_left + box->width + box->padding[RIGHT];
|
2005-05-24 02:14:09 +04:00
|
|
|
padding_height = padding_top + box->height +
|
|
|
|
box->padding[BOTTOM];
|
2009-07-24 03:05:34 +04:00
|
|
|
border_left = box->border[LEFT].width;
|
|
|
|
border_top = box->border[TOP].width;
|
|
|
|
border_right = box->border[RIGHT].width;
|
|
|
|
border_bottom = box->border[BOTTOM].width;
|
2005-05-24 02:14:09 +04:00
|
|
|
} else {
|
2005-04-15 09:52:11 +04:00
|
|
|
x = (x_parent + box->x) * scale;
|
|
|
|
y = (y_parent + box->y) * scale;
|
|
|
|
width = box->width * scale;
|
|
|
|
height = box->height * scale;
|
2005-05-24 02:14:09 +04:00
|
|
|
/* left and top padding values are normally zero,
|
|
|
|
* so avoid trivial FP maths */
|
|
|
|
padding_left = box->padding[LEFT] ? box->padding[LEFT] * scale
|
|
|
|
: 0;
|
|
|
|
padding_top = box->padding[TOP] ? box->padding[TOP] * scale
|
|
|
|
: 0;
|
2005-04-15 09:52:11 +04:00
|
|
|
padding_width = (box->padding[LEFT] + box->width +
|
|
|
|
box->padding[RIGHT]) * scale;
|
|
|
|
padding_height = (box->padding[TOP] + box->height +
|
|
|
|
box->padding[BOTTOM]) * scale;
|
2009-07-24 03:05:34 +04:00
|
|
|
border_left = box->border[LEFT].width * scale;
|
|
|
|
border_top = box->border[TOP].width * scale;
|
|
|
|
border_right = box->border[RIGHT].width * scale;
|
|
|
|
border_bottom = box->border[BOTTOM].width * scale;
|
2005-04-15 09:52:11 +04:00
|
|
|
}
|
|
|
|
|
2008-01-28 07:33:39 +03:00
|
|
|
/* calculate rectangle covering this box and descendants */
|
2009-07-24 03:05:34 +04:00
|
|
|
if (box->style && css_computed_overflow(box->style) !=
|
|
|
|
CSS_OVERFLOW_VISIBLE) {
|
2008-01-28 07:33:39 +03:00
|
|
|
x0 = x - border_left;
|
|
|
|
y0 = y - border_top;
|
|
|
|
x1 = x + padding_width + border_right;
|
|
|
|
y1 = y + padding_height + border_bottom;
|
2004-11-11 02:02:11 +03:00
|
|
|
} else {
|
2004-10-18 01:05:12 +04:00
|
|
|
x0 = x + box->descendant_x0 * scale;
|
|
|
|
y0 = y + box->descendant_y0 * scale;
|
|
|
|
x1 = x + box->descendant_x1 * scale + 1;
|
|
|
|
y1 = y + box->descendant_y1 * scale + 1;
|
2008-12-27 20:29:17 +03:00
|
|
|
if (!box->parent) {
|
|
|
|
int margin_left, margin_right;
|
|
|
|
int margin_top, margin_bottom;
|
|
|
|
if (scale == 1.0) {
|
|
|
|
margin_left = box->margin[LEFT];
|
|
|
|
margin_top = box->margin[TOP];
|
|
|
|
margin_right = box->margin[RIGHT];
|
|
|
|
margin_bottom = box->margin[BOTTOM];
|
|
|
|
} else {
|
|
|
|
margin_left = box->margin[LEFT] * scale;
|
|
|
|
margin_top = box->margin[TOP] * scale;
|
|
|
|
margin_right = box->margin[RIGHT] * scale;
|
|
|
|
margin_bottom = box->margin[BOTTOM] * scale;
|
|
|
|
}
|
|
|
|
x0 = x - border_left - margin_left < x0 ?
|
|
|
|
x - border_left - margin_left : x0;
|
|
|
|
y0 = y - border_top - margin_top < y0 ?
|
|
|
|
y - border_top - margin_top : y0;
|
|
|
|
x1 = x + padding_width + border_right +
|
|
|
|
margin_right > x1 ?
|
|
|
|
x + padding_width + border_right +
|
|
|
|
margin_right : x1;
|
|
|
|
y1 = y + padding_height + border_bottom +
|
|
|
|
margin_bottom > y1 ?
|
|
|
|
y + padding_height + border_bottom +
|
|
|
|
margin_bottom : y1;
|
|
|
|
}
|
2004-11-11 02:02:11 +03:00
|
|
|
}
|
2004-10-18 01:05:12 +04:00
|
|
|
|
2008-01-28 07:33:39 +03:00
|
|
|
/* return if the rectangle is completely outside the clip rectangle */
|
|
|
|
if (clip_y1 < y0 || y1 < clip_y0 || clip_x1 < x0 || x1 < clip_x0)
|
2008-07-30 03:11:32 +04:00
|
|
|
return true;
|
2008-01-28 07:33:39 +03:00
|
|
|
|
Second merge of Adam Blokus' GSoC work from his branch 'branches/adamblokus/netsurf'.
Merged revisions 4195-4211,4216,4219-4220,4222-4234,4236-4250,4252-4262,4264-4266,4268-4326,4329-4335,4338-4342,4344-4411,4413-4420,4422-4436,4438-4491,4494-4506,4508-4514,4516,4518-4552,4554,4556-4564,4567-4568,4570-4574,4576-4686,4689-4692,4694,4698-4709,4715-4723,4725-4755,4757-4769,4771-4919,4921-4996,4998-5110,5112-5117 via svnmerge from
svn://svn.netsurf-browser.org/branches/adamblokus/netsurf
........
r4736 | adamblokus | 2008-07-26 13:46:54 +0200 (Sat, 26 Jul 2008) | 2 lines
Sorting out some problems with svn.
........
r4737 | adamblokus | 2008-07-26 13:54:36 +0200 (Sat, 26 Jul 2008) | 4 lines
Added export tab to the options dialog.
Added the possibility of changing some print options.
........
r4897 | adamblokus | 2008-08-04 17:59:05 +0200 (Mon, 04 Aug 2008) | 5 lines
Added checking of horizontal clipping.
Added better table loosening.
Changed some minor bugs.
Applied changes in the Export options tab according to the review from tlsa.
........
r4905 | adamblokus | 2008-08-05 01:53:34 +0200 (Tue, 05 Aug 2008) | 2 lines
Fixed bug which made it impossible to export pdf's.
........
r4919 | adamblokus | 2008-08-05 16:39:33 +0200 (Tue, 05 Aug 2008) | 2 lines
Fixed some memory leaks which caused Netsurf to break.
........
r4927 | adamblokus | 2008-08-06 02:26:30 +0200 (Wed, 06 Aug 2008) | 4 lines
Fixed bug with filenames which crashed Netsurf.
Turned anti aliasing off for printing.
Fixed some scaling issues.
........
r4928 | adamblokus | 2008-08-06 17:52:44 +0200 (Wed, 06 Aug 2008) | 5 lines
Added new export/print options:
- suppressing images
- turning off backgrounds
- toggled loosening
........
r4950 | adamblokus | 2008-08-07 21:15:21 +0200 (Thu, 07 Aug 2008) | 5 lines
Added new options to PDF export:
- document compression
- document encryption
Added PDF password dialog
........
r4954 | adamblokus | 2008-08-07 22:11:31 +0200 (Thu, 07 Aug 2008) | 2 lines
Added saving print settings.
........
r4956 | adamblokus | 2008-08-07 22:44:48 +0200 (Thu, 07 Aug 2008) | 2 lines
Fixes to PDF encryption
........
r4970 | adamblokus | 2008-08-09 15:26:24 +0200 (Sat, 09 Aug 2008) | 3 lines
Fixed bug in plotting tiled bitmaps.
Fixed bug with too long text decorations.
........
r4977 | adamblokus | 2008-08-09 19:18:56 +0200 (Sat, 09 Aug 2008) | 2 lines
Fixed JPG embedding bug.
........
r4988 | adamblokus | 2008-08-10 16:59:51 +0200 (Sun, 10 Aug 2008) | 3 lines
Added clip checking to pdf plotters. No more "blank" clips.
Made PDF compression a default setting.
........
r4995 | adamblokus | 2008-08-10 20:03:00 +0200 (Sun, 10 Aug 2008) | 2 lines
Fixed Haru crash on font-size==0.
........
r4996 | adamblokus | 2008-08-10 21:04:43 +0200 (Sun, 10 Aug 2008) | 2 lines
Added changing text mode only if necessary.
........
r5045 | adamblokus | 2008-08-11 21:26:26 +0200 (Mon, 11 Aug 2008) | 3 lines
Removing gtk stuff from core code.
Little fix in options.
........
r5048 | adamblokus | 2008-08-11 21:57:45 +0200 (Mon, 11 Aug 2008) | 2 lines
Better font size checking in PDF export.
........
r5050 | adamblokus | 2008-08-11 22:19:56 +0200 (Mon, 11 Aug 2008) | 2 lines
Fixed riscos text scale bug.
........
r5073 | adamblokus | 2008-08-12 17:40:57 +0200 (Tue, 12 Aug 2008) | 2 lines
Added missing tooltips
........
r5092 | adamblokus | 2008-08-13 17:09:25 +0200 (Wed, 13 Aug 2008) | 2 lines
Moved /pdf folder to desktop/save_pdf
........
r5110 | adamblokus | 2008-08-13 22:44:50 +0200 (Wed, 13 Aug 2008) | 2 lines
Added comments.
........
r5113 | adamblokus | 2008-08-13 23:07:35 +0200 (Wed, 13 Aug 2008) | 2 lines
Cosmetic changes
........
r5116 | adamblokus | 2008-08-14 16:10:18 +0200 (Thu, 14 Aug 2008) | 2 lines
Fixed bug with BOX_INLINE_END in tree duplication.
........
r5117 | joty | 2008-08-14 21:47:46 +0200 (Thu, 14 Aug 2008) | 1 line
Improvement for r5116: use local vars when possible; rename global last to box_duplicate_last; check on box_duplicate_main_tree failure.
........
svn path=/trunk/netsurf/; revision=5118
2008-08-15 00:32:10 +04:00
|
|
|
/*if the rectangle is under the page bottom but it can fit in a page,
|
|
|
|
don't print it now*/
|
2008-09-16 02:14:17 +04:00
|
|
|
if (html_redraw_printing) {
|
Second merge of Adam Blokus' GSoC work from his branch 'branches/adamblokus/netsurf'.
Merged revisions 4195-4211,4216,4219-4220,4222-4234,4236-4250,4252-4262,4264-4266,4268-4326,4329-4335,4338-4342,4344-4411,4413-4420,4422-4436,4438-4491,4494-4506,4508-4514,4516,4518-4552,4554,4556-4564,4567-4568,4570-4574,4576-4686,4689-4692,4694,4698-4709,4715-4723,4725-4755,4757-4769,4771-4919,4921-4996,4998-5110,5112-5117 via svnmerge from
svn://svn.netsurf-browser.org/branches/adamblokus/netsurf
........
r4736 | adamblokus | 2008-07-26 13:46:54 +0200 (Sat, 26 Jul 2008) | 2 lines
Sorting out some problems with svn.
........
r4737 | adamblokus | 2008-07-26 13:54:36 +0200 (Sat, 26 Jul 2008) | 4 lines
Added export tab to the options dialog.
Added the possibility of changing some print options.
........
r4897 | adamblokus | 2008-08-04 17:59:05 +0200 (Mon, 04 Aug 2008) | 5 lines
Added checking of horizontal clipping.
Added better table loosening.
Changed some minor bugs.
Applied changes in the Export options tab according to the review from tlsa.
........
r4905 | adamblokus | 2008-08-05 01:53:34 +0200 (Tue, 05 Aug 2008) | 2 lines
Fixed bug which made it impossible to export pdf's.
........
r4919 | adamblokus | 2008-08-05 16:39:33 +0200 (Tue, 05 Aug 2008) | 2 lines
Fixed some memory leaks which caused Netsurf to break.
........
r4927 | adamblokus | 2008-08-06 02:26:30 +0200 (Wed, 06 Aug 2008) | 4 lines
Fixed bug with filenames which crashed Netsurf.
Turned anti aliasing off for printing.
Fixed some scaling issues.
........
r4928 | adamblokus | 2008-08-06 17:52:44 +0200 (Wed, 06 Aug 2008) | 5 lines
Added new export/print options:
- suppressing images
- turning off backgrounds
- toggled loosening
........
r4950 | adamblokus | 2008-08-07 21:15:21 +0200 (Thu, 07 Aug 2008) | 5 lines
Added new options to PDF export:
- document compression
- document encryption
Added PDF password dialog
........
r4954 | adamblokus | 2008-08-07 22:11:31 +0200 (Thu, 07 Aug 2008) | 2 lines
Added saving print settings.
........
r4956 | adamblokus | 2008-08-07 22:44:48 +0200 (Thu, 07 Aug 2008) | 2 lines
Fixes to PDF encryption
........
r4970 | adamblokus | 2008-08-09 15:26:24 +0200 (Sat, 09 Aug 2008) | 3 lines
Fixed bug in plotting tiled bitmaps.
Fixed bug with too long text decorations.
........
r4977 | adamblokus | 2008-08-09 19:18:56 +0200 (Sat, 09 Aug 2008) | 2 lines
Fixed JPG embedding bug.
........
r4988 | adamblokus | 2008-08-10 16:59:51 +0200 (Sun, 10 Aug 2008) | 3 lines
Added clip checking to pdf plotters. No more "blank" clips.
Made PDF compression a default setting.
........
r4995 | adamblokus | 2008-08-10 20:03:00 +0200 (Sun, 10 Aug 2008) | 2 lines
Fixed Haru crash on font-size==0.
........
r4996 | adamblokus | 2008-08-10 21:04:43 +0200 (Sun, 10 Aug 2008) | 2 lines
Added changing text mode only if necessary.
........
r5045 | adamblokus | 2008-08-11 21:26:26 +0200 (Mon, 11 Aug 2008) | 3 lines
Removing gtk stuff from core code.
Little fix in options.
........
r5048 | adamblokus | 2008-08-11 21:57:45 +0200 (Mon, 11 Aug 2008) | 2 lines
Better font size checking in PDF export.
........
r5050 | adamblokus | 2008-08-11 22:19:56 +0200 (Mon, 11 Aug 2008) | 2 lines
Fixed riscos text scale bug.
........
r5073 | adamblokus | 2008-08-12 17:40:57 +0200 (Tue, 12 Aug 2008) | 2 lines
Added missing tooltips
........
r5092 | adamblokus | 2008-08-13 17:09:25 +0200 (Wed, 13 Aug 2008) | 2 lines
Moved /pdf folder to desktop/save_pdf
........
r5110 | adamblokus | 2008-08-13 22:44:50 +0200 (Wed, 13 Aug 2008) | 2 lines
Added comments.
........
r5113 | adamblokus | 2008-08-13 23:07:35 +0200 (Wed, 13 Aug 2008) | 2 lines
Cosmetic changes
........
r5116 | adamblokus | 2008-08-14 16:10:18 +0200 (Thu, 14 Aug 2008) | 2 lines
Fixed bug with BOX_INLINE_END in tree duplication.
........
r5117 | joty | 2008-08-14 21:47:46 +0200 (Thu, 14 Aug 2008) | 1 line
Improvement for r5116: use local vars when possible; rename global last to box_duplicate_last; check on box_duplicate_main_tree failure.
........
svn path=/trunk/netsurf/; revision=5118
2008-08-15 00:32:10 +04:00
|
|
|
if (y1 > html_redraw_printing_border) {
|
|
|
|
if (y1 - y0 <= html_redraw_printing_border &&
|
|
|
|
(box->type == BOX_TEXT ||
|
|
|
|
box->type == BOX_TABLE_CELL
|
|
|
|
|| box->object || box->gadget)) {
|
|
|
|
/*remember the highest of all points from the
|
|
|
|
not printed elements*/
|
|
|
|
if (y0 < html_redraw_printing_top_cropped)
|
|
|
|
html_redraw_printing_top_cropped = y0;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else box->printed = true;/*it won't be printed anymore*/
|
2008-09-16 02:14:17 +04:00
|
|
|
}
|
2008-08-25 23:30:10 +04:00
|
|
|
|
2004-10-18 01:05:12 +04:00
|
|
|
/* if visibility is hidden render children only */
|
2009-07-24 03:05:34 +04:00
|
|
|
if (box->style && css_computed_visibility(box->style) ==
|
|
|
|
CSS_VISIBILITY_HIDDEN) {
|
2009-07-06 14:33:19 +04:00
|
|
|
if ((plot.group_start) && (!plot.group_start("hidden box")))
|
2004-10-21 03:31:32 +04:00
|
|
|
return false;
|
2008-01-28 07:33:39 +03:00
|
|
|
if (!html_redraw_box_children(box, x_parent, y_parent,
|
|
|
|
x0, y0, x1, y1, scale,
|
|
|
|
current_background_color))
|
2006-06-26 03:07:24 +04:00
|
|
|
return false;
|
2008-01-28 07:33:39 +03:00
|
|
|
return ((!plot.group_end) || (plot.group_end()));
|
2004-10-18 01:05:12 +04:00
|
|
|
}
|
2008-01-27 21:15:56 +03:00
|
|
|
|
2008-01-28 07:33:39 +03:00
|
|
|
if ((plot.group_start) && (!plot.group_start("vis box")))
|
|
|
|
return false;
|
|
|
|
|
2004-10-18 01:05:12 +04:00
|
|
|
if (box->type == BOX_BLOCK || box->type == BOX_INLINE_BLOCK ||
|
|
|
|
box->type == BOX_TABLE_CELL || box->object) {
|
|
|
|
/* find intersection of clip rectangle and box */
|
|
|
|
if (x0 < clip_x0) x0 = clip_x0;
|
|
|
|
if (y0 < clip_y0) y0 = clip_y0;
|
|
|
|
if (clip_x1 < x1) x1 = clip_x1;
|
|
|
|
if (clip_y1 < y1) y1 = clip_y1;
|
2004-12-06 02:51:10 +03:00
|
|
|
/* no point trying to draw 0-width/height boxes */
|
|
|
|
if (x0 == x1 || y0 == y1)
|
2007-10-09 21:24:02 +04:00
|
|
|
/* not an error */
|
|
|
|
return ((!plot.group_end) || (plot.group_end()));
|
2004-10-18 01:05:12 +04:00
|
|
|
/* clip to it */
|
|
|
|
if (!plot.clip(x0, y0, x1, y1))
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
/* clip box unchanged */
|
|
|
|
x0 = clip_x0;
|
|
|
|
y0 = clip_y0;
|
|
|
|
x1 = clip_x1;
|
|
|
|
y1 = clip_y1;
|
|
|
|
}
|
2008-12-21 18:51:23 +03:00
|
|
|
|
2008-12-27 18:03:54 +03:00
|
|
|
/* background colour and image for block level content and replaced
|
|
|
|
* inlines */
|
2007-09-17 18:53:02 +04:00
|
|
|
|
|
|
|
/* Thanks to backwards compatibility, CSS defines the following:
|
2008-01-27 21:15:56 +03:00
|
|
|
*
|
2007-09-17 18:53:02 +04:00
|
|
|
* + If the box is for the root element and it has a background,
|
|
|
|
* use that (and then process the body box with no special case)
|
|
|
|
* + If the box is for the root element and it has no background,
|
2008-01-27 21:15:56 +03:00
|
|
|
* then use the background (if any) from the body element as if
|
|
|
|
* it were specified on the root. Then, when the box for the body
|
2007-09-17 18:53:02 +04:00
|
|
|
* element is processed, ignore the background.
|
|
|
|
* + For any other box, just use its own styling.
|
|
|
|
*/
|
2009-01-17 22:39:38 +03:00
|
|
|
if (!box->parent) {
|
|
|
|
/* Root box */
|
2009-07-24 03:05:34 +04:00
|
|
|
if (box->style && (css_computed_background_color(box->style,
|
|
|
|
&bgcol) != CSS_BACKGROUND_COLOR_TRANSPARENT ||
|
2009-01-17 22:39:38 +03:00
|
|
|
box->background)) {
|
|
|
|
/* With its own background */
|
|
|
|
bg_box = box;
|
|
|
|
} else if (!box->style ||
|
2009-07-24 03:05:34 +04:00
|
|
|
(css_computed_background_color(box->style,
|
|
|
|
&bgcol) == CSS_BACKGROUND_COLOR_TRANSPARENT &&
|
2009-01-17 22:39:38 +03:00
|
|
|
!box->background)) {
|
|
|
|
/* Without its own background */
|
|
|
|
if (box->children && box->children->style &&
|
2009-07-24 03:05:34 +04:00
|
|
|
(css_computed_background_color(
|
|
|
|
box->children->style,
|
|
|
|
&bgcol) !=
|
|
|
|
CSS_BACKGROUND_COLOR_TRANSPARENT ||
|
2009-01-17 22:39:38 +03:00
|
|
|
box->children->background)) {
|
|
|
|
/* But body has one, so use that */
|
|
|
|
bg_box = box->children;
|
Second merge of Adam Blokus' GSoC work from his branch 'branches/adamblokus/netsurf'.
Merged revisions 4195-4211,4216,4219-4220,4222-4234,4236-4250,4252-4262,4264-4266,4268-4326,4329-4335,4338-4342,4344-4411,4413-4420,4422-4436,4438-4491,4494-4506,4508-4514,4516,4518-4552,4554,4556-4564,4567-4568,4570-4574,4576-4686,4689-4692,4694,4698-4709,4715-4723,4725-4755,4757-4769,4771-4919,4921-4996,4998-5110,5112-5117 via svnmerge from
svn://svn.netsurf-browser.org/branches/adamblokus/netsurf
........
r4736 | adamblokus | 2008-07-26 13:46:54 +0200 (Sat, 26 Jul 2008) | 2 lines
Sorting out some problems with svn.
........
r4737 | adamblokus | 2008-07-26 13:54:36 +0200 (Sat, 26 Jul 2008) | 4 lines
Added export tab to the options dialog.
Added the possibility of changing some print options.
........
r4897 | adamblokus | 2008-08-04 17:59:05 +0200 (Mon, 04 Aug 2008) | 5 lines
Added checking of horizontal clipping.
Added better table loosening.
Changed some minor bugs.
Applied changes in the Export options tab according to the review from tlsa.
........
r4905 | adamblokus | 2008-08-05 01:53:34 +0200 (Tue, 05 Aug 2008) | 2 lines
Fixed bug which made it impossible to export pdf's.
........
r4919 | adamblokus | 2008-08-05 16:39:33 +0200 (Tue, 05 Aug 2008) | 2 lines
Fixed some memory leaks which caused Netsurf to break.
........
r4927 | adamblokus | 2008-08-06 02:26:30 +0200 (Wed, 06 Aug 2008) | 4 lines
Fixed bug with filenames which crashed Netsurf.
Turned anti aliasing off for printing.
Fixed some scaling issues.
........
r4928 | adamblokus | 2008-08-06 17:52:44 +0200 (Wed, 06 Aug 2008) | 5 lines
Added new export/print options:
- suppressing images
- turning off backgrounds
- toggled loosening
........
r4950 | adamblokus | 2008-08-07 21:15:21 +0200 (Thu, 07 Aug 2008) | 5 lines
Added new options to PDF export:
- document compression
- document encryption
Added PDF password dialog
........
r4954 | adamblokus | 2008-08-07 22:11:31 +0200 (Thu, 07 Aug 2008) | 2 lines
Added saving print settings.
........
r4956 | adamblokus | 2008-08-07 22:44:48 +0200 (Thu, 07 Aug 2008) | 2 lines
Fixes to PDF encryption
........
r4970 | adamblokus | 2008-08-09 15:26:24 +0200 (Sat, 09 Aug 2008) | 3 lines
Fixed bug in plotting tiled bitmaps.
Fixed bug with too long text decorations.
........
r4977 | adamblokus | 2008-08-09 19:18:56 +0200 (Sat, 09 Aug 2008) | 2 lines
Fixed JPG embedding bug.
........
r4988 | adamblokus | 2008-08-10 16:59:51 +0200 (Sun, 10 Aug 2008) | 3 lines
Added clip checking to pdf plotters. No more "blank" clips.
Made PDF compression a default setting.
........
r4995 | adamblokus | 2008-08-10 20:03:00 +0200 (Sun, 10 Aug 2008) | 2 lines
Fixed Haru crash on font-size==0.
........
r4996 | adamblokus | 2008-08-10 21:04:43 +0200 (Sun, 10 Aug 2008) | 2 lines
Added changing text mode only if necessary.
........
r5045 | adamblokus | 2008-08-11 21:26:26 +0200 (Mon, 11 Aug 2008) | 3 lines
Removing gtk stuff from core code.
Little fix in options.
........
r5048 | adamblokus | 2008-08-11 21:57:45 +0200 (Mon, 11 Aug 2008) | 2 lines
Better font size checking in PDF export.
........
r5050 | adamblokus | 2008-08-11 22:19:56 +0200 (Mon, 11 Aug 2008) | 2 lines
Fixed riscos text scale bug.
........
r5073 | adamblokus | 2008-08-12 17:40:57 +0200 (Tue, 12 Aug 2008) | 2 lines
Added missing tooltips
........
r5092 | adamblokus | 2008-08-13 17:09:25 +0200 (Wed, 13 Aug 2008) | 2 lines
Moved /pdf folder to desktop/save_pdf
........
r5110 | adamblokus | 2008-08-13 22:44:50 +0200 (Wed, 13 Aug 2008) | 2 lines
Added comments.
........
r5113 | adamblokus | 2008-08-13 23:07:35 +0200 (Wed, 13 Aug 2008) | 2 lines
Cosmetic changes
........
r5116 | adamblokus | 2008-08-14 16:10:18 +0200 (Thu, 14 Aug 2008) | 2 lines
Fixed bug with BOX_INLINE_END in tree duplication.
........
r5117 | joty | 2008-08-14 21:47:46 +0200 (Thu, 14 Aug 2008) | 1 line
Improvement for r5116: use local vars when possible; rename global last to box_duplicate_last; check on box_duplicate_main_tree failure.
........
svn path=/trunk/netsurf/; revision=5118
2008-08-15 00:32:10 +04:00
|
|
|
}
|
2009-01-17 22:39:38 +03:00
|
|
|
}
|
|
|
|
} else if (box->parent && !box->parent->parent) {
|
|
|
|
/* Body box */
|
2009-07-24 03:05:34 +04:00
|
|
|
if (box->style && (css_computed_background_color(box->style,
|
|
|
|
&bgcol) != CSS_BACKGROUND_COLOR_TRANSPARENT ||
|
2009-01-17 22:39:38 +03:00
|
|
|
box->background)) {
|
|
|
|
/* With a background */
|
|
|
|
if (box->parent->style &&
|
2009-07-24 03:05:34 +04:00
|
|
|
(css_computed_background_color(
|
|
|
|
box->parent->style, &bgcol) !=
|
|
|
|
CSS_BACKGROUND_COLOR_TRANSPARENT ||
|
2009-01-17 22:39:38 +03:00
|
|
|
box->parent->background)) {
|
|
|
|
/* Root has own background; process normally */
|
|
|
|
bg_box = box;
|
2007-09-17 18:53:02 +04:00
|
|
|
}
|
|
|
|
}
|
2009-01-17 22:39:38 +03:00
|
|
|
} else {
|
|
|
|
/* Any other box */
|
|
|
|
bg_box = box;
|
|
|
|
}
|
2008-08-25 23:30:10 +04:00
|
|
|
|
2009-01-17 22:39:38 +03:00
|
|
|
/* bg_box == NULL implies that this box should not have
|
|
|
|
* its background rendered. Otherwise filter out linebreaks,
|
|
|
|
* optimize away non-differing inlines, only plot background
|
|
|
|
* for BOX_TEXT it's in an inline and ensure the bg_box
|
|
|
|
* has something worth rendering */
|
|
|
|
if (bg_box && bg_box->style &&
|
|
|
|
bg_box->type != BOX_BR &&
|
|
|
|
bg_box->type != BOX_TEXT &&
|
|
|
|
bg_box->type != BOX_INLINE_END &&
|
|
|
|
(bg_box->type != BOX_INLINE || bg_box->object) &&
|
2009-07-24 03:05:34 +04:00
|
|
|
(css_computed_background_color(bg_box->style,
|
|
|
|
&bgcol) != CSS_BACKGROUND_COLOR_TRANSPARENT ||
|
|
|
|
bg_box->background)) {
|
2009-01-17 22:39:38 +03:00
|
|
|
/* find intersection of clip box and border edge */
|
|
|
|
int px0, py0, px1, py1;
|
|
|
|
px0 = x - border_left < x0 ? x0 : x - border_left;
|
|
|
|
py0 = y - border_top < y0 ? y0 : y - border_top;
|
|
|
|
px1 = x + padding_width + border_right < x1 ?
|
|
|
|
x + padding_width + border_right : x1;
|
|
|
|
py1 = y + padding_height + border_bottom < y1 ?
|
|
|
|
y + padding_height + border_bottom : y1;
|
|
|
|
if (!box->parent) {
|
|
|
|
/* Root element, special case:
|
|
|
|
* background covers margins too */
|
|
|
|
int m_left, m_top, m_right, m_bottom;
|
|
|
|
if (scale == 1.0) {
|
|
|
|
m_left = box->margin[LEFT];
|
|
|
|
m_top = box->margin[TOP];
|
|
|
|
m_right = box->margin[RIGHT];
|
|
|
|
m_bottom = box->margin[BOTTOM];
|
|
|
|
} else {
|
|
|
|
m_left = box->margin[LEFT] * scale;
|
|
|
|
m_top = box->margin[TOP] * scale;
|
|
|
|
m_right = box->margin[RIGHT] * scale;
|
|
|
|
m_bottom = box->margin[BOTTOM] * scale;
|
Second merge of Adam Blokus' GSoC work from his branch 'branches/adamblokus/netsurf'.
Merged revisions 4195-4211,4216,4219-4220,4222-4234,4236-4250,4252-4262,4264-4266,4268-4326,4329-4335,4338-4342,4344-4411,4413-4420,4422-4436,4438-4491,4494-4506,4508-4514,4516,4518-4552,4554,4556-4564,4567-4568,4570-4574,4576-4686,4689-4692,4694,4698-4709,4715-4723,4725-4755,4757-4769,4771-4919,4921-4996,4998-5110,5112-5117 via svnmerge from
svn://svn.netsurf-browser.org/branches/adamblokus/netsurf
........
r4736 | adamblokus | 2008-07-26 13:46:54 +0200 (Sat, 26 Jul 2008) | 2 lines
Sorting out some problems with svn.
........
r4737 | adamblokus | 2008-07-26 13:54:36 +0200 (Sat, 26 Jul 2008) | 4 lines
Added export tab to the options dialog.
Added the possibility of changing some print options.
........
r4897 | adamblokus | 2008-08-04 17:59:05 +0200 (Mon, 04 Aug 2008) | 5 lines
Added checking of horizontal clipping.
Added better table loosening.
Changed some minor bugs.
Applied changes in the Export options tab according to the review from tlsa.
........
r4905 | adamblokus | 2008-08-05 01:53:34 +0200 (Tue, 05 Aug 2008) | 2 lines
Fixed bug which made it impossible to export pdf's.
........
r4919 | adamblokus | 2008-08-05 16:39:33 +0200 (Tue, 05 Aug 2008) | 2 lines
Fixed some memory leaks which caused Netsurf to break.
........
r4927 | adamblokus | 2008-08-06 02:26:30 +0200 (Wed, 06 Aug 2008) | 4 lines
Fixed bug with filenames which crashed Netsurf.
Turned anti aliasing off for printing.
Fixed some scaling issues.
........
r4928 | adamblokus | 2008-08-06 17:52:44 +0200 (Wed, 06 Aug 2008) | 5 lines
Added new export/print options:
- suppressing images
- turning off backgrounds
- toggled loosening
........
r4950 | adamblokus | 2008-08-07 21:15:21 +0200 (Thu, 07 Aug 2008) | 5 lines
Added new options to PDF export:
- document compression
- document encryption
Added PDF password dialog
........
r4954 | adamblokus | 2008-08-07 22:11:31 +0200 (Thu, 07 Aug 2008) | 2 lines
Added saving print settings.
........
r4956 | adamblokus | 2008-08-07 22:44:48 +0200 (Thu, 07 Aug 2008) | 2 lines
Fixes to PDF encryption
........
r4970 | adamblokus | 2008-08-09 15:26:24 +0200 (Sat, 09 Aug 2008) | 3 lines
Fixed bug in plotting tiled bitmaps.
Fixed bug with too long text decorations.
........
r4977 | adamblokus | 2008-08-09 19:18:56 +0200 (Sat, 09 Aug 2008) | 2 lines
Fixed JPG embedding bug.
........
r4988 | adamblokus | 2008-08-10 16:59:51 +0200 (Sun, 10 Aug 2008) | 3 lines
Added clip checking to pdf plotters. No more "blank" clips.
Made PDF compression a default setting.
........
r4995 | adamblokus | 2008-08-10 20:03:00 +0200 (Sun, 10 Aug 2008) | 2 lines
Fixed Haru crash on font-size==0.
........
r4996 | adamblokus | 2008-08-10 21:04:43 +0200 (Sun, 10 Aug 2008) | 2 lines
Added changing text mode only if necessary.
........
r5045 | adamblokus | 2008-08-11 21:26:26 +0200 (Mon, 11 Aug 2008) | 3 lines
Removing gtk stuff from core code.
Little fix in options.
........
r5048 | adamblokus | 2008-08-11 21:57:45 +0200 (Mon, 11 Aug 2008) | 2 lines
Better font size checking in PDF export.
........
r5050 | adamblokus | 2008-08-11 22:19:56 +0200 (Mon, 11 Aug 2008) | 2 lines
Fixed riscos text scale bug.
........
r5073 | adamblokus | 2008-08-12 17:40:57 +0200 (Tue, 12 Aug 2008) | 2 lines
Added missing tooltips
........
r5092 | adamblokus | 2008-08-13 17:09:25 +0200 (Wed, 13 Aug 2008) | 2 lines
Moved /pdf folder to desktop/save_pdf
........
r5110 | adamblokus | 2008-08-13 22:44:50 +0200 (Wed, 13 Aug 2008) | 2 lines
Added comments.
........
r5113 | adamblokus | 2008-08-13 23:07:35 +0200 (Wed, 13 Aug 2008) | 2 lines
Cosmetic changes
........
r5116 | adamblokus | 2008-08-14 16:10:18 +0200 (Thu, 14 Aug 2008) | 2 lines
Fixed bug with BOX_INLINE_END in tree duplication.
........
r5117 | joty | 2008-08-14 21:47:46 +0200 (Thu, 14 Aug 2008) | 1 line
Improvement for r5116: use local vars when possible; rename global last to box_duplicate_last; check on box_duplicate_main_tree failure.
........
svn path=/trunk/netsurf/; revision=5118
2008-08-15 00:32:10 +04:00
|
|
|
}
|
2009-01-17 22:39:38 +03:00
|
|
|
px0 = px0 - m_left < x0 ? x0 : px0 - m_left;
|
|
|
|
py0 = py0 - m_top < y0 ? y0 : py0 - m_top;
|
|
|
|
px1 = px1 + m_right < x1 ? px1 + m_right : x1;
|
|
|
|
py1 = py1 + m_bottom < y1 ? py1 + m_bottom : y1;
|
|
|
|
}
|
|
|
|
/* valid clipping rectangles only */
|
|
|
|
if ((px0 < px1) && (py0 < py1)) {
|
|
|
|
/* plot background */
|
|
|
|
if (!html_redraw_background(x, y, box, scale,
|
|
|
|
px0, py0, px1, py1,
|
|
|
|
¤t_background_color, bg_box))
|
|
|
|
return false;
|
|
|
|
/* restore previous graphics window */
|
|
|
|
if (!plot.clip(x0, y0, x1, y1))
|
|
|
|
return false;
|
2008-01-28 07:33:39 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-27 18:03:54 +03:00
|
|
|
/* borders for block level content and replaced inlines */
|
2008-01-28 07:33:39 +03:00
|
|
|
if (box->style && box->type != BOX_TEXT &&
|
2008-12-21 18:51:23 +03:00
|
|
|
box->type != BOX_INLINE_END &&
|
2008-12-27 20:09:35 +03:00
|
|
|
(box->type != BOX_INLINE || box->object) &&
|
2008-01-28 07:33:39 +03:00
|
|
|
(border_top || border_right ||
|
|
|
|
border_bottom || border_left))
|
|
|
|
if (!html_redraw_borders(box, x_parent, y_parent,
|
|
|
|
padding_width, padding_height,
|
|
|
|
scale))
|
|
|
|
return false;
|
|
|
|
|
2008-12-27 18:03:54 +03:00
|
|
|
/* backgrounds and borders for non-replaced inlines */
|
2008-12-21 18:51:23 +03:00
|
|
|
if (box->style && box->type == BOX_INLINE && box->inline_end &&
|
2009-07-24 03:05:34 +04:00
|
|
|
(css_computed_background_color(box->style, &bgcol) !=
|
|
|
|
CSS_BACKGROUND_COLOR_TRANSPARENT ||
|
2008-12-26 18:10:28 +03:00
|
|
|
box->background || border_top || border_right ||
|
|
|
|
border_bottom || border_left)) {
|
2008-12-21 18:51:23 +03:00
|
|
|
/* inline backgrounds and borders span other boxes and may
|
|
|
|
* wrap onto separate lines */
|
|
|
|
struct box *ib;
|
|
|
|
bool first = true;
|
|
|
|
int ib_x;
|
|
|
|
int ib_y = y;
|
2009-05-28 00:14:36 +04:00
|
|
|
int ib_p_width;
|
2008-12-21 18:51:23 +03:00
|
|
|
int ib_b_left, ib_b_right;
|
|
|
|
int xmin = x - border_left;
|
|
|
|
int xmax = x + padding_width + border_right;
|
|
|
|
int ymin = y - border_top;
|
|
|
|
int ymax = y + padding_height + border_bottom;
|
|
|
|
int px0 = xmin < x0 ? x0 : xmin;
|
|
|
|
int px1 = xmax < x1 ? xmax : x1;
|
|
|
|
int py0 = ymin < y0 ? y0 : ymin;
|
|
|
|
int py1 = ymax < y1 ? ymax : y1;
|
|
|
|
for (ib = box; ib; ib = ib->next) {
|
|
|
|
/* to get extents of rectangle(s) associated with
|
|
|
|
* inline, cycle though all boxes in inline, skipping
|
|
|
|
* over floats */
|
|
|
|
if (ib->type == BOX_FLOAT_LEFT ||
|
|
|
|
ib->type == BOX_FLOAT_RIGHT)
|
|
|
|
continue;
|
|
|
|
if (scale == 1.0) {
|
|
|
|
ib_x = x_parent + ib->x;
|
|
|
|
ib_y = y_parent + ib->y;
|
2009-05-28 00:14:36 +04:00
|
|
|
ib_p_width = ib->padding[LEFT] + ib->width +
|
2008-12-21 18:51:23 +03:00
|
|
|
ib->padding[RIGHT];
|
2009-07-24 03:05:34 +04:00
|
|
|
ib_b_left = ib->border[LEFT].width;
|
|
|
|
ib_b_right = ib->border[RIGHT].width;
|
2008-12-21 18:51:23 +03:00
|
|
|
} else {
|
|
|
|
ib_x = (x_parent + ib->x) * scale;
|
|
|
|
ib_y = (y_parent + ib->y) * scale;
|
|
|
|
ib_p_width = (ib->padding[LEFT] + ib->width +
|
|
|
|
ib->padding[RIGHT]) * scale;
|
2009-07-24 03:05:34 +04:00
|
|
|
ib_b_left = ib->border[LEFT].width * scale;
|
|
|
|
ib_b_right = ib->border[RIGHT].width * scale;
|
2008-12-21 18:51:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ib->inline_new_line && ib != box) {
|
|
|
|
/* inline element has wrapped, plot background
|
|
|
|
* and borders */
|
|
|
|
if (!html_redraw_inline_background(
|
|
|
|
x, y, box, scale,
|
|
|
|
px0, py0, px1, py1,
|
|
|
|
xmin, ymin, xmax, ymax,
|
|
|
|
first, false,
|
|
|
|
¤t_background_color))
|
|
|
|
return false;
|
|
|
|
/* restore previous graphics window */
|
|
|
|
if (!plot.clip(x0, y0, x1, y1))
|
|
|
|
return false;
|
|
|
|
if (!html_redraw_inline_borders(box,
|
|
|
|
xmin, ymin, xmax, ymax,
|
|
|
|
scale, first, false))
|
|
|
|
return false;
|
|
|
|
/* reset coords */
|
|
|
|
xmin = ib_x - ib_b_left;
|
|
|
|
ymin = ib_y - border_top - padding_top;
|
|
|
|
ymax = ib_y + padding_height - padding_top +
|
|
|
|
border_bottom;
|
|
|
|
|
|
|
|
px0 = xmin < x0 ? x0 : xmin;
|
|
|
|
py0 = ymin < y0 ? y0 : ymin;
|
|
|
|
py1 = ymax < y1 ? ymax : y1;
|
|
|
|
|
|
|
|
first = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* increase width for current box */
|
|
|
|
xmax = ib_x + ib_p_width + ib_b_right;
|
|
|
|
px1 = xmax < x1 ? xmax : x1;
|
|
|
|
|
|
|
|
if (ib == box->inline_end)
|
|
|
|
/* reached end of BOX_INLINE span */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* plot background and borders for last rectangle of
|
|
|
|
* the inline */
|
|
|
|
if (!html_redraw_inline_background(x, ib_y, box, scale,
|
|
|
|
px0, py0, px1, py1, xmin, ymin, xmax, ymax,
|
|
|
|
first, true, ¤t_background_color))
|
|
|
|
return false;
|
|
|
|
/* restore previous graphics window */
|
|
|
|
if (!plot.clip(x0, y0, x1, y1))
|
|
|
|
return false;
|
|
|
|
if (!html_redraw_inline_borders(box, xmin, ymin, xmax, ymax,
|
|
|
|
scale, first, true))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-07-14 17:13:47 +04:00
|
|
|
/* Debug outlines */
|
2009-07-14 15:45:29 +04:00
|
|
|
if (html_redraw_debug) {
|
|
|
|
int margin_left, margin_right;
|
|
|
|
int margin_top, margin_bottom;
|
|
|
|
if (scale == 1.0) {
|
|
|
|
/* avoid trivial fp maths */
|
|
|
|
margin_left = box->margin[LEFT];
|
|
|
|
margin_top = box->margin[TOP];
|
|
|
|
margin_right = box->margin[RIGHT];
|
|
|
|
margin_bottom = box->margin[BOTTOM];
|
|
|
|
} else {
|
|
|
|
margin_left = box->margin[LEFT] * scale;
|
|
|
|
margin_top = box->margin[TOP] * scale;
|
|
|
|
margin_right = box->margin[RIGHT] * scale;
|
|
|
|
margin_bottom = box->margin[BOTTOM] * scale;
|
|
|
|
}
|
2009-07-14 16:42:02 +04:00
|
|
|
/* Content edge -- blue */
|
2009-07-14 15:45:29 +04:00
|
|
|
if (!plot.rectangle(x + padding_left,
|
|
|
|
y + padding_top,
|
|
|
|
x + padding_left + width,
|
|
|
|
y + padding_top + height,
|
2009-07-14 16:42:02 +04:00
|
|
|
plot_style_content_edge))
|
2009-07-14 15:45:29 +04:00
|
|
|
return false;
|
2009-07-14 16:42:02 +04:00
|
|
|
/* Padding edge -- red */
|
2009-07-14 15:45:29 +04:00
|
|
|
if (!plot.rectangle(x, y,
|
|
|
|
x + padding_width, y + padding_height,
|
2009-07-14 16:42:02 +04:00
|
|
|
plot_style_padding_edge))
|
2009-07-14 15:45:29 +04:00
|
|
|
return false;
|
2009-07-14 16:42:02 +04:00
|
|
|
/* Margin edge -- yellow */
|
2009-07-14 15:45:29 +04:00
|
|
|
if (!plot.rectangle(
|
|
|
|
x - border_left - margin_left,
|
|
|
|
y - border_top - margin_top,
|
|
|
|
x + padding_width + border_right +
|
|
|
|
margin_right,
|
|
|
|
y + padding_height + border_bottom +
|
|
|
|
margin_bottom,
|
2009-07-14 16:42:02 +04:00
|
|
|
plot_style_margin_edge))
|
2009-07-14 15:45:29 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-01-28 07:33:39 +03:00
|
|
|
/* clip to the padding edge for boxes with overflow hidden or scroll */
|
2009-07-24 03:05:34 +04:00
|
|
|
if (box->style && css_computed_overflow(box->style) !=
|
|
|
|
CSS_OVERFLOW_VISIBLE) {
|
2008-01-28 07:33:39 +03:00
|
|
|
x0 = x;
|
|
|
|
y0 = y;
|
|
|
|
x1 = x + padding_width;
|
|
|
|
y1 = y + padding_height;
|
|
|
|
if (x0 < clip_x0) x0 = clip_x0;
|
|
|
|
if (y0 < clip_y0) y0 = clip_y0;
|
|
|
|
if (clip_x1 < x1) x1 = clip_x1;
|
|
|
|
if (clip_y1 < y1) y1 = clip_y1;
|
|
|
|
if (x1 <= x0 || y1 <= y0)
|
|
|
|
return ((!plot.group_end) || (plot.group_end()));
|
|
|
|
if (box->type == BOX_BLOCK || box->type == BOX_INLINE_BLOCK ||
|
|
|
|
box->type == BOX_TABLE_CELL || box->object) {
|
|
|
|
if (!plot.clip(x0, y0, x1, y1))
|
2004-10-18 01:05:12 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-23 01:50:14 +04:00
|
|
|
/* text decoration */
|
|
|
|
if (box->type != BOX_TEXT && box->style &&
|
2009-07-24 03:05:34 +04:00
|
|
|
css_computed_text_decoration(box->style) !=
|
2005-05-23 01:50:14 +04:00
|
|
|
CSS_TEXT_DECORATION_NONE)
|
|
|
|
if (!html_redraw_text_decoration(box, x_parent, y_parent,
|
|
|
|
scale, current_background_color))
|
|
|
|
return false;
|
|
|
|
|
2004-10-18 01:05:12 +04:00
|
|
|
if (box->object) {
|
2009-08-14 14:37:33 +04:00
|
|
|
x_scrolled = x - scroll_get_offset(box->scroll_x) * scale;
|
|
|
|
y_scrolled = y - scroll_get_offset(box->scroll_y) * scale;
|
2004-10-18 01:05:12 +04:00
|
|
|
if (!content_redraw(box->object,
|
2004-11-21 22:45:17 +03:00
|
|
|
x_scrolled + padding_left,
|
|
|
|
y_scrolled + padding_top,
|
2004-10-18 01:05:12 +04:00
|
|
|
width, height, x0, y0, x1, y1, scale,
|
|
|
|
current_background_color))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
} else if (box->gadget && box->gadget->type == GADGET_CHECKBOX) {
|
|
|
|
if (!html_redraw_checkbox(x + padding_left, y + padding_top,
|
|
|
|
width, height,
|
|
|
|
box->gadget->selected))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
} else if (box->gadget && box->gadget->type == GADGET_RADIO) {
|
|
|
|
if (!html_redraw_radio(x + padding_left, y + padding_top,
|
|
|
|
width, height,
|
|
|
|
box->gadget->selected))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
} else if (box->gadget && box->gadget->type == GADGET_FILE) {
|
|
|
|
if (!html_redraw_file(x + padding_left, y + padding_top,
|
|
|
|
width, height, box, scale,
|
|
|
|
current_background_color))
|
|
|
|
return false;
|
|
|
|
|
2005-02-20 16:18:21 +03:00
|
|
|
} else if (box->text) {
|
2005-07-18 20:38:59 +04:00
|
|
|
if (!html_redraw_text_box(box, x, y, x0, y0, x1, y1,
|
|
|
|
scale, current_background_color))
|
|
|
|
return false;
|
2005-04-17 07:30:35 +04:00
|
|
|
|
2004-10-18 01:05:12 +04:00
|
|
|
} else {
|
2006-06-26 03:07:24 +04:00
|
|
|
if (!html_redraw_box_children(box, x_parent, y_parent,
|
|
|
|
x0, y0, x1, y1, scale,
|
|
|
|
current_background_color))
|
|
|
|
return false;
|
2004-10-18 01:05:12 +04:00
|
|
|
}
|
|
|
|
|
2006-11-05 15:58:24 +03:00
|
|
|
/* list marker */
|
|
|
|
if (box->list_marker)
|
|
|
|
if (!html_redraw_box(box->list_marker,
|
2009-08-14 14:37:33 +04:00
|
|
|
x_parent + box->x -
|
|
|
|
scroll_get_offset(box->scroll_x),
|
|
|
|
y_parent + box->y -
|
|
|
|
scroll_get_offset(box->scroll_y),
|
2006-11-05 15:58:24 +03:00
|
|
|
clip_x0, clip_y0, clip_x1, clip_y1,
|
2008-12-21 18:51:23 +03:00
|
|
|
scale, current_background_color))
|
2006-11-05 15:58:24 +03:00
|
|
|
return false;
|
|
|
|
|
2004-11-20 03:02:56 +03:00
|
|
|
/* scrollbars */
|
2009-08-14 14:37:33 +04:00
|
|
|
if (current_redraw_browser && box->style && box->type != BOX_BR &&
|
|
|
|
box->type != BOX_TABLE && box->type != BOX_INLINE &&
|
2009-07-24 03:05:34 +04:00
|
|
|
(css_computed_overflow(box->style) ==
|
|
|
|
CSS_OVERFLOW_SCROLL ||
|
|
|
|
css_computed_overflow(box->style) ==
|
2009-08-14 14:37:33 +04:00
|
|
|
CSS_OVERFLOW_AUTO)) {
|
|
|
|
|
|
|
|
has_x_scroll = false;
|
|
|
|
has_y_scroll = false;
|
|
|
|
|
|
|
|
has_x_scroll = box_hscrollbar_present(box);
|
|
|
|
|
|
|
|
has_y_scroll = box_vscrollbar_present(box);
|
|
|
|
|
|
|
|
if (!box_handle_scrollbars(box,
|
|
|
|
x_parent + box->x, y_parent + box->y,
|
|
|
|
has_x_scroll, has_y_scroll))
|
2004-11-20 03:02:56 +03:00
|
|
|
return false;
|
2009-08-14 14:37:33 +04:00
|
|
|
|
|
|
|
if (box->scroll_x != NULL)
|
|
|
|
scroll_redraw(box->scroll_x,
|
|
|
|
x_parent + box->x,
|
|
|
|
y_parent + box->y + box->padding[TOP] +
|
|
|
|
box->height + box->padding[BOTTOM] -
|
|
|
|
SCROLLBAR_WIDTH,
|
|
|
|
clip_x0, clip_y0, clip_x1, clip_y1,
|
|
|
|
scale);
|
|
|
|
if (box->scroll_y != NULL)
|
|
|
|
scroll_redraw(box->scroll_y,
|
|
|
|
x_parent + box->x + box->padding[LEFT] +
|
|
|
|
box->width + box->padding[RIGHT] -
|
|
|
|
SCROLLBAR_WIDTH,
|
|
|
|
y_parent + box->y,
|
|
|
|
clip_x0, clip_y0, clip_x1, clip_y1,
|
|
|
|
scale);
|
|
|
|
}
|
|
|
|
|
2004-11-20 03:02:56 +03:00
|
|
|
|
2004-10-18 01:05:12 +04:00
|
|
|
if (box->type == BOX_BLOCK || box->type == BOX_INLINE_BLOCK ||
|
|
|
|
box->type == BOX_TABLE_CELL || box->object)
|
|
|
|
if (!plot.clip(clip_x0, clip_y0, clip_x1, clip_y1))
|
|
|
|
return false;
|
|
|
|
|
2006-07-10 13:52:31 +04:00
|
|
|
return ((!plot.group_end) || (plot.group_end()));
|
2004-10-18 01:05:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-26 03:07:24 +04:00
|
|
|
/**
|
|
|
|
* Draw the various children of a box.
|
|
|
|
*
|
2008-12-21 18:51:23 +03:00
|
|
|
* \param box box to draw children of
|
2006-06-26 03:07:24 +04:00
|
|
|
* \param x_parent coordinate of parent box
|
|
|
|
* \param y_parent coordinate of parent box
|
|
|
|
* \param clip_x0 clip rectangle
|
|
|
|
* \param clip_y0 clip rectangle
|
|
|
|
* \param clip_x1 clip rectangle
|
|
|
|
* \param clip_y1 clip rectangle
|
|
|
|
* \param scale scale for redraw
|
|
|
|
* \param current_background_color background colour under this box
|
|
|
|
* \return true if successful, false otherwise
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool html_redraw_box_children(struct box *box,
|
|
|
|
int x_parent, int y_parent,
|
|
|
|
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
|
|
|
|
float scale, colour current_background_color)
|
|
|
|
{
|
|
|
|
struct box *c;
|
|
|
|
|
2008-07-19 22:46:17 +04:00
|
|
|
for (c = box->children; c; c = c->next) {
|
|
|
|
|
2006-06-26 03:07:24 +04:00
|
|
|
if (c->type != BOX_FLOAT_LEFT && c->type != BOX_FLOAT_RIGHT)
|
|
|
|
if (!html_redraw_box(c,
|
2009-08-14 14:37:33 +04:00
|
|
|
x_parent + box->x -
|
|
|
|
scroll_get_offset(box->scroll_x),
|
|
|
|
y_parent + box->y -
|
|
|
|
scroll_get_offset(box->scroll_y),
|
2006-06-26 03:07:24 +04:00
|
|
|
clip_x0, clip_y0, clip_x1, clip_y1,
|
2008-12-21 18:51:23 +03:00
|
|
|
scale, current_background_color))
|
2006-06-26 03:07:24 +04:00
|
|
|
return false;
|
2008-07-19 22:46:17 +04:00
|
|
|
}
|
2006-06-26 03:07:24 +04:00
|
|
|
for (c = box->float_children; c; c = c->next_float)
|
|
|
|
if (!html_redraw_box(c,
|
2009-08-14 14:37:33 +04:00
|
|
|
x_parent + box->x -
|
|
|
|
scroll_get_offset(box->scroll_x),
|
|
|
|
y_parent + box->y -
|
|
|
|
scroll_get_offset(box->scroll_y),
|
2006-06-26 03:07:24 +04:00
|
|
|
clip_x0, clip_y0, clip_x1, clip_y1,
|
2008-12-21 18:51:23 +03:00
|
|
|
scale, current_background_color))
|
2006-06-26 03:07:24 +04:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-18 20:38:59 +04:00
|
|
|
/**
|
|
|
|
* Redraw the text content of a box, possibly partially highlighted
|
|
|
|
* because the text has been selected, or matches a search operation.
|
|
|
|
*
|
|
|
|
* \param box box with text content
|
|
|
|
* \param x x co-ord of box
|
|
|
|
* \param y y co-ord of box
|
|
|
|
* \param x0 current clip rectangle
|
|
|
|
* \param y0
|
|
|
|
* \param x1
|
|
|
|
* \param y1
|
|
|
|
* \param scale current scale setting (1.0 = 100%)
|
|
|
|
* \param current_background_color
|
|
|
|
* \return true iff successful and redraw should proceed
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool html_redraw_text_box(struct box *box, int x, int y,
|
|
|
|
int x0, int y0, int x1, int y1,
|
|
|
|
float scale, colour current_background_color)
|
2006-02-16 02:09:55 +03:00
|
|
|
{
|
|
|
|
bool excluded = (box->object != NULL);
|
|
|
|
struct rect clip;
|
2009-07-21 14:59:53 +04:00
|
|
|
plot_font_style_t fstyle;
|
|
|
|
|
|
|
|
font_plot_style_from_css(box->style, &fstyle);
|
|
|
|
fstyle.background = current_background_color;
|
2006-02-16 02:09:55 +03:00
|
|
|
|
|
|
|
clip.x0 = x0;
|
|
|
|
clip.y0 = y0;
|
|
|
|
clip.x1 = x1;
|
|
|
|
clip.y1 = y1;
|
|
|
|
|
|
|
|
if (!text_redraw(box->text, box->length, box->byte_offset,
|
2009-07-21 14:59:53 +04:00
|
|
|
box->space, &fstyle, x, y,
|
|
|
|
&clip, box->height, scale, excluded))
|
2006-02-16 02:09:55 +03:00
|
|
|
return false;
|
|
|
|
|
|
|
|
/* does this textbox contain the ghost caret? */
|
|
|
|
if (ghost_caret.defined && box == ghost_caret.text_box) {
|
|
|
|
|
2008-12-26 14:34:23 +03:00
|
|
|
if (!html_redraw_caret(&ghost_caret, current_background_color,
|
|
|
|
scale))
|
2006-02-16 02:09:55 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Redraw a short text string, complete with highlighting
|
|
|
|
* (for selection/search) and ghost caret
|
|
|
|
*
|
|
|
|
* \param utf8_text pointer to UTF-8 text string
|
|
|
|
* \param utf8_len length of string, in bytes
|
|
|
|
* \param offset byte offset within textual representation
|
|
|
|
* \param space indicates whether string is followed by a space
|
2009-07-21 14:59:53 +04:00
|
|
|
* \param fstyle text style to use
|
2006-02-16 02:09:55 +03:00
|
|
|
* \param x x ordinate at which to plot text
|
|
|
|
* \param y y ordinate at which to plot text
|
|
|
|
* \param clip pointer to current clip rectangle
|
|
|
|
* \param height height of text string
|
|
|
|
* \param scale current display scale (1.0 = 100%)
|
|
|
|
* \param excluded exclude this text string from the selection
|
|
|
|
* \return true iff successful and redraw should proceed
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool text_redraw(const char *utf8_text, size_t utf8_len,
|
2009-07-21 14:59:53 +04:00
|
|
|
size_t offset, bool space, const plot_font_style_t *fstyle,
|
2006-02-16 02:09:55 +03:00
|
|
|
int x, int y, struct rect *clip,
|
|
|
|
int height,
|
2009-07-21 14:59:53 +04:00
|
|
|
float scale,
|
2006-02-16 02:09:55 +03:00
|
|
|
bool excluded)
|
2005-07-18 20:38:59 +04:00
|
|
|
{
|
|
|
|
bool highlighted = false;
|
|
|
|
|
|
|
|
/* is this box part of a selection? */
|
2006-02-16 02:09:55 +03:00
|
|
|
if (!excluded && current_redraw_browser) {
|
|
|
|
unsigned len = utf8_len + (space ? 1 : 0);
|
2005-07-18 20:38:59 +04:00
|
|
|
unsigned start_idx;
|
|
|
|
unsigned end_idx;
|
|
|
|
|
|
|
|
/* first try the browser window's current selection */
|
|
|
|
if (selection_defined(current_redraw_browser->sel) &&
|
|
|
|
selection_highlighted(current_redraw_browser->sel,
|
2006-02-16 02:09:55 +03:00
|
|
|
offset, offset + len, &start_idx, &end_idx)) {
|
2005-07-18 20:38:59 +04:00
|
|
|
highlighted = true;
|
|
|
|
}
|
|
|
|
|
2006-02-16 02:09:55 +03:00
|
|
|
/* what about the current search operation, if any? */
|
2009-01-17 22:39:38 +03:00
|
|
|
if (!highlighted && search_current_window ==
|
|
|
|
current_redraw_browser->window &&
|
|
|
|
gui_search_term_highlighted(
|
|
|
|
current_redraw_browser->window,
|
|
|
|
offset, offset + len,
|
|
|
|
&start_idx, &end_idx)) {
|
|
|
|
highlighted = true;
|
2005-07-18 20:38:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* \todo make search terms visible within selected text */
|
|
|
|
if (highlighted) {
|
|
|
|
unsigned endtxt_idx = end_idx;
|
|
|
|
bool clip_changed = false;
|
|
|
|
bool text_visible = true;
|
|
|
|
int startx, endx;
|
2009-07-06 14:33:19 +04:00
|
|
|
plot_style_t *pstyle_fill_hback = plot_style_fill_white;
|
2009-07-21 14:59:53 +04:00
|
|
|
plot_font_style_t fstyle_hback = *fstyle;
|
2005-07-18 20:38:59 +04:00
|
|
|
|
2006-02-16 02:09:55 +03:00
|
|
|
if (end_idx > utf8_len) {
|
2009-01-17 22:39:38 +03:00
|
|
|
/* adjust for trailing space, not present in
|
|
|
|
* utf8_text */
|
2006-02-16 02:09:55 +03:00
|
|
|
assert(end_idx == utf8_len + 1);
|
|
|
|
endtxt_idx = utf8_len;
|
2005-07-18 20:38:59 +04:00
|
|
|
}
|
|
|
|
|
2009-07-21 14:59:53 +04:00
|
|
|
if (!nsfont.font_width(fstyle, utf8_text, start_idx,
|
2009-01-17 22:39:38 +03:00
|
|
|
&startx))
|
2005-07-18 20:38:59 +04:00
|
|
|
startx = 0;
|
|
|
|
|
2009-07-21 14:59:53 +04:00
|
|
|
if (!nsfont.font_width(fstyle, utf8_text, endtxt_idx,
|
2009-01-17 22:39:38 +03:00
|
|
|
&endx))
|
2005-07-18 20:38:59 +04:00
|
|
|
endx = 0;
|
|
|
|
|
2009-01-17 22:39:38 +03:00
|
|
|
/* is there a trailing space that should be highlighted
|
|
|
|
* as well? */
|
2006-02-16 02:09:55 +03:00
|
|
|
if (end_idx > utf8_len) {
|
2005-07-18 20:38:59 +04:00
|
|
|
int spc_width;
|
2009-01-17 22:39:38 +03:00
|
|
|
/* \todo is there a more elegant/efficient
|
|
|
|
* solution? */
|
2009-07-21 14:59:53 +04:00
|
|
|
if (nsfont.font_width(fstyle, " ", 1,
|
2009-01-17 22:39:38 +03:00
|
|
|
&spc_width))
|
2005-07-18 20:38:59 +04:00
|
|
|
endx += spc_width;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (scale != 1.0) {
|
|
|
|
startx *= scale;
|
|
|
|
endx *= scale;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* draw any text preceding highlighted portion */
|
2006-02-04 15:02:06 +03:00
|
|
|
if (start_idx > 0 &&
|
2006-02-16 02:09:55 +03:00
|
|
|
!plot.text(x, y + (int) (height * 0.75 * scale),
|
2009-07-21 14:59:53 +04:00
|
|
|
utf8_text, start_idx,
|
|
|
|
fstyle))
|
2005-07-18 20:38:59 +04:00
|
|
|
return false;
|
|
|
|
|
2009-01-17 22:39:38 +03:00
|
|
|
/* decide whether highlighted portion is to be
|
|
|
|
* white-on-black or black-on-white */
|
2009-07-21 14:59:53 +04:00
|
|
|
if ((fstyle->background & 0x808080) == 0x808080)
|
2009-07-06 14:33:19 +04:00
|
|
|
pstyle_fill_hback = plot_style_fill_black;
|
2005-07-18 20:38:59 +04:00
|
|
|
|
|
|
|
/* highlighted portion */
|
2009-07-09 02:04:40 +04:00
|
|
|
if (!plot.rectangle(x + startx, y, x + endx,
|
2009-07-06 14:33:19 +04:00
|
|
|
y + height * scale,
|
|
|
|
pstyle_fill_hback))
|
2005-07-18 20:38:59 +04:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if (start_idx > 0) {
|
2006-02-16 02:09:55 +03:00
|
|
|
int px0 = max(x + startx, clip->x0);
|
|
|
|
int px1 = min(x + endx, clip->x1);
|
2005-07-18 20:38:59 +04:00
|
|
|
|
|
|
|
if (px0 < px1) {
|
2009-01-17 22:39:38 +03:00
|
|
|
if (!plot.clip(px0, clip->y0, px1,
|
|
|
|
clip->y1))
|
2005-07-18 20:38:59 +04:00
|
|
|
return false;
|
|
|
|
clip_changed = true;
|
2009-01-17 22:39:38 +03:00
|
|
|
} else {
|
2005-07-18 20:38:59 +04:00
|
|
|
text_visible = false;
|
2009-01-17 22:39:38 +03:00
|
|
|
}
|
2005-07-18 20:38:59 +04:00
|
|
|
}
|
|
|
|
|
2009-07-21 15:33:55 +04:00
|
|
|
fstyle_hback.background =
|
2009-07-21 14:59:53 +04:00
|
|
|
pstyle_fill_hback->fill_colour;
|
2009-07-21 15:33:55 +04:00
|
|
|
fstyle_hback.foreground =
|
|
|
|
pstyle_fill_hback->fill_colour ^ 0xffffff;
|
2009-07-21 14:59:53 +04:00
|
|
|
|
2005-07-18 20:38:59 +04:00
|
|
|
if (text_visible &&
|
2006-02-16 02:09:55 +03:00
|
|
|
!plot.text(x, y + (int) (height * 0.75 * scale),
|
2009-07-21 14:59:53 +04:00
|
|
|
utf8_text, endtxt_idx,
|
|
|
|
&fstyle_hback))
|
2005-07-18 20:38:59 +04:00
|
|
|
return false;
|
|
|
|
|
|
|
|
/* draw any text succeeding highlighted portion */
|
2006-02-16 02:09:55 +03:00
|
|
|
if (endtxt_idx < utf8_len) {
|
|
|
|
int px0 = max(x + endx, clip->x0);
|
|
|
|
if (px0 < clip->x1) {
|
2005-07-18 20:38:59 +04:00
|
|
|
|
2009-01-17 22:39:38 +03:00
|
|
|
if (!plot.clip(px0, clip->y0,
|
|
|
|
clip->x1, clip->y1))
|
2005-07-18 20:38:59 +04:00
|
|
|
return false;
|
|
|
|
|
|
|
|
clip_changed = true;
|
|
|
|
|
2009-01-17 22:39:38 +03:00
|
|
|
if (!plot.text(x, y + (int)
|
|
|
|
(height * 0.75 * scale),
|
2009-07-21 14:59:53 +04:00
|
|
|
utf8_text, utf8_len,
|
|
|
|
fstyle))
|
2005-07-18 20:38:59 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-16 02:09:55 +03:00
|
|
|
if (clip_changed &&
|
2009-01-17 22:39:38 +03:00
|
|
|
!plot.clip(clip->x0, clip->y0,
|
|
|
|
clip->x1, clip->y1))
|
2005-07-18 20:38:59 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!highlighted) {
|
2006-02-16 02:09:55 +03:00
|
|
|
if (!plot.text(x, y + (int) (height * 0.75 * scale),
|
2009-07-21 14:59:53 +04:00
|
|
|
utf8_text, utf8_len,
|
|
|
|
fstyle))
|
2005-07-18 20:38:59 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-16 02:09:55 +03:00
|
|
|
/**
|
|
|
|
* Draw text caret.
|
|
|
|
*
|
2008-12-26 14:34:23 +03:00
|
|
|
* \param c structure describing text caret
|
|
|
|
* \param current_background_color background colour under the caret
|
|
|
|
* \param scale current scale setting (1.0 = 100%)
|
2006-02-16 02:09:55 +03:00
|
|
|
* \return true iff successful and redraw should proceed
|
|
|
|
*/
|
|
|
|
|
2006-02-20 05:29:19 +03:00
|
|
|
bool html_redraw_caret(struct caret *c, colour current_background_color,
|
2006-02-16 02:09:55 +03:00
|
|
|
float scale)
|
|
|
|
{
|
|
|
|
int xc = c->x, y = c->y;
|
|
|
|
int h = c->height - 1;
|
|
|
|
int w = (h + 7) / 8;
|
|
|
|
|
|
|
|
return (plot.line(xc * scale, y * scale,
|
|
|
|
xc * scale, (y + h) * scale,
|
2009-07-10 22:36:49 +04:00
|
|
|
plot_style_caret) &&
|
2006-02-16 02:09:55 +03:00
|
|
|
plot.line((xc - w) * scale, y * scale,
|
|
|
|
(xc + w) * scale, y * scale,
|
2009-07-10 22:36:49 +04:00
|
|
|
plot_style_caret) &&
|
2006-02-16 02:09:55 +03:00
|
|
|
plot.line((xc - w) * scale, (y + h) * scale,
|
|
|
|
(xc + w) * scale, (y + h) * scale,
|
2009-07-10 22:36:49 +04:00
|
|
|
plot_style_caret));
|
2006-02-16 02:09:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-18 01:05:12 +04:00
|
|
|
/**
|
|
|
|
* Draw borders for a box.
|
|
|
|
*
|
2008-12-26 14:34:23 +03:00
|
|
|
* \param box box to draw
|
|
|
|
* \param x_parent coordinate of left padding edge of parent of box
|
|
|
|
* \param y_parent coordinate of top padding edge of parent of box
|
|
|
|
* \param p_width width of padding box
|
|
|
|
* \param p_height height of padding box
|
|
|
|
* \param scale scale for redraw
|
2004-10-18 01:05:12 +04:00
|
|
|
* \return true if successful, false otherwise
|
|
|
|
*/
|
|
|
|
|
2005-05-24 02:14:09 +04:00
|
|
|
bool html_redraw_borders(struct box *box, int x_parent, int y_parent,
|
2008-12-26 14:34:23 +03:00
|
|
|
int p_width, int p_height, float scale)
|
2004-10-18 01:05:12 +04:00
|
|
|
{
|
2009-07-24 03:05:34 +04:00
|
|
|
int top = box->border[TOP].width;
|
|
|
|
int right = box->border[RIGHT].width;
|
|
|
|
int bottom = box->border[BOTTOM].width;
|
|
|
|
int left = box->border[LEFT].width;
|
2008-12-22 00:28:12 +03:00
|
|
|
int x, y;
|
|
|
|
unsigned int i;
|
2008-12-26 14:34:23 +03:00
|
|
|
int p[20];
|
2006-02-16 02:09:55 +03:00
|
|
|
|
|
|
|
if (scale != 1.0) {
|
|
|
|
top *= scale;
|
|
|
|
right *= scale;
|
|
|
|
bottom *= scale;
|
|
|
|
left *= scale;
|
|
|
|
}
|
2004-10-18 01:05:12 +04:00
|
|
|
|
|
|
|
assert(box->style);
|
|
|
|
|
2008-12-22 00:28:12 +03:00
|
|
|
x = (x_parent + box->x) * scale;
|
|
|
|
y = (y_parent + box->y) * scale;
|
2008-12-21 18:51:23 +03:00
|
|
|
|
2008-12-26 14:34:23 +03:00
|
|
|
/* calculate border vertices */
|
|
|
|
p[0] = x; p[1] = y;
|
|
|
|
p[2] = x - left; p[3] = y - top;
|
|
|
|
p[4] = x + p_width + right; p[5] = y - top;
|
|
|
|
p[6] = x + p_width; p[7] = y;
|
|
|
|
p[8] = x + p_width; p[9] = y + p_height;
|
|
|
|
p[10] = x + p_width + right; p[11] = y + p_height + bottom;
|
|
|
|
p[12] = x - left; p[13] = y + p_height + bottom;
|
|
|
|
p[14] = x; p[15] = y + p_height;
|
|
|
|
p[16] = x; p[17] = y;
|
|
|
|
p[18] = x - left; p[19] = y - top;
|
|
|
|
|
|
|
|
for (i = 0; i != 4; i++) {
|
2009-07-24 03:05:34 +04:00
|
|
|
colour col = 0;
|
|
|
|
|
|
|
|
if (box->border[i].width == 0)
|
2008-12-26 14:34:23 +03:00
|
|
|
continue;
|
2009-07-24 03:05:34 +04:00
|
|
|
|
|
|
|
if (box->border[i].color == CSS_BORDER_COLOR_TRANSPARENT) {
|
|
|
|
col = NS_TRANSPARENT;
|
|
|
|
} else {
|
|
|
|
col = nscss_color_to_ns(box->border[i].c);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!html_redraw_border_plot(i, p, col, box->border[i].style,
|
|
|
|
box->border[i].width * scale))
|
2008-12-26 14:34:23 +03:00
|
|
|
return false;
|
2005-05-24 02:14:09 +04:00
|
|
|
}
|
2004-10-18 01:05:12 +04:00
|
|
|
|
2005-05-24 02:14:09 +04:00
|
|
|
return true;
|
|
|
|
}
|
2004-10-18 01:05:12 +04:00
|
|
|
|
|
|
|
|
2008-12-21 18:51:23 +03:00
|
|
|
/**
|
|
|
|
* Draw an inline's borders.
|
|
|
|
*
|
|
|
|
* \param box BOX_INLINE which created the border
|
|
|
|
* \param x0 coordinate of border edge rectangle
|
|
|
|
* \param y0 coordinate of border edge rectangle
|
|
|
|
* \param x1 coordinate of border edge rectangle
|
|
|
|
* \param y1 coordinate of border edge rectangle
|
|
|
|
* \param scale scale for redraw
|
|
|
|
* \param first true if this is the first rectangle associated with the inline
|
|
|
|
* \param last true if this is the last rectangle associated with the inline
|
|
|
|
* \return true if successful, false otherwise
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool html_redraw_inline_borders(struct box *box, int x0, int y0, int x1, int y1,
|
|
|
|
float scale, bool first, bool last)
|
|
|
|
{
|
2009-07-24 03:05:34 +04:00
|
|
|
int top = box->border[TOP].width;
|
|
|
|
int right = box->border[RIGHT].width;
|
|
|
|
int bottom = box->border[BOTTOM].width;
|
|
|
|
int left = box->border[LEFT].width;
|
|
|
|
colour col;
|
2009-01-31 03:41:03 +03:00
|
|
|
int p[20];
|
2008-12-26 14:34:23 +03:00
|
|
|
|
2008-12-21 18:51:23 +03:00
|
|
|
if (scale != 1.0) {
|
|
|
|
top *= scale;
|
|
|
|
right *= scale;
|
|
|
|
bottom *= scale;
|
|
|
|
left *= scale;
|
|
|
|
}
|
|
|
|
|
2009-01-31 03:41:03 +03:00
|
|
|
/* calculate border vertices */
|
|
|
|
p[0] = x0 + left; p[1] = y0 + top;
|
|
|
|
p[2] = x0; p[3] = y0;
|
|
|
|
p[4] = x1; p[5] = y0;
|
|
|
|
p[6] = x1 - right; p[7] = y0 + top;
|
|
|
|
p[8] = x1 - right; p[9] = y1 - bottom;
|
|
|
|
p[10] = x1; p[11] = y1;
|
|
|
|
p[12] = x0; p[13] = y1;
|
|
|
|
p[14] = x0 + left; p[15] = y1 - bottom;
|
|
|
|
p[16] = x0 + left; p[17] = y0 + top;
|
|
|
|
p[18] = x0; p[19] = y0;
|
|
|
|
|
2008-12-21 18:51:23 +03:00
|
|
|
assert(box->style);
|
|
|
|
|
2009-07-24 03:05:34 +04:00
|
|
|
if (box->border[LEFT].width && first) {
|
|
|
|
if (box->border[LEFT].color == CSS_BORDER_COLOR_TRANSPARENT)
|
|
|
|
col = NS_TRANSPARENT;
|
|
|
|
else
|
|
|
|
col = nscss_color_to_ns(box->border[LEFT].c);
|
|
|
|
|
|
|
|
if (!html_redraw_border_plot(LEFT, p, col,
|
|
|
|
box->border[LEFT].style,
|
|
|
|
left))
|
2008-12-26 14:34:23 +03:00
|
|
|
return false;
|
2009-07-24 03:05:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (box->border[TOP].width) {
|
|
|
|
if (box->border[TOP].color == CSS_BORDER_COLOR_TRANSPARENT)
|
|
|
|
col = NS_TRANSPARENT;
|
|
|
|
else
|
|
|
|
col = nscss_color_to_ns(box->border[TOP].c);
|
|
|
|
|
|
|
|
if (!html_redraw_border_plot(TOP, p, col,
|
|
|
|
box->border[TOP].style,
|
|
|
|
top))
|
2008-12-26 14:34:23 +03:00
|
|
|
return false;
|
2009-07-24 03:05:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (box->border[BOTTOM].width) {
|
|
|
|
if (box->border[BOTTOM].color == CSS_BORDER_COLOR_TRANSPARENT)
|
|
|
|
col = NS_TRANSPARENT;
|
|
|
|
else
|
|
|
|
col = nscss_color_to_ns(box->border[BOTTOM].c);
|
|
|
|
|
|
|
|
if (!html_redraw_border_plot(BOTTOM, p, col,
|
|
|
|
box->border[BOTTOM].style,
|
|
|
|
bottom))
|
2008-12-26 14:34:23 +03:00
|
|
|
return false;
|
2009-07-24 03:05:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (box->border[RIGHT].width && last) {
|
|
|
|
if (box->border[RIGHT].color == CSS_BORDER_COLOR_TRANSPARENT)
|
|
|
|
col = NS_TRANSPARENT;
|
|
|
|
else
|
|
|
|
col = nscss_color_to_ns(box->border[RIGHT].c);
|
|
|
|
|
|
|
|
if (!html_redraw_border_plot(RIGHT, p, col,
|
|
|
|
box->border[RIGHT].style,
|
|
|
|
right))
|
2008-12-26 14:34:23 +03:00
|
|
|
return false;
|
2009-07-24 03:05:34 +04:00
|
|
|
}
|
|
|
|
|
2008-12-21 18:51:23 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-07-14 14:03:58 +04:00
|
|
|
static plot_style_t plot_style_bdr = {
|
|
|
|
.stroke_type = PLOT_OP_TYPE_DASH,
|
|
|
|
};
|
|
|
|
static plot_style_t plot_style_fillbdr = {
|
|
|
|
.fill_type = PLOT_OP_TYPE_SOLID,
|
|
|
|
};
|
|
|
|
static plot_style_t plot_style_fillbdr_dark = {
|
|
|
|
.fill_type = PLOT_OP_TYPE_SOLID,
|
|
|
|
};
|
|
|
|
static plot_style_t plot_style_fillbdr_light = {
|
|
|
|
.fill_type = PLOT_OP_TYPE_SOLID,
|
|
|
|
};
|
|
|
|
static plot_style_t plot_style_fillbdr_ddark = {
|
|
|
|
.fill_type = PLOT_OP_TYPE_SOLID,
|
|
|
|
};
|
|
|
|
static plot_style_t plot_style_fillbdr_dlight = {
|
|
|
|
.fill_type = PLOT_OP_TYPE_SOLID,
|
|
|
|
};
|
2008-12-21 18:51:23 +03:00
|
|
|
|
2005-05-24 02:14:09 +04:00
|
|
|
/**
|
|
|
|
* Draw one border.
|
|
|
|
*
|
|
|
|
* \param i index of border (TOP, RIGHT, BOTTOM, LEFT)
|
|
|
|
* \param p array of precomputed border vertices
|
|
|
|
* \param c colour for border
|
|
|
|
* \param style border line style
|
|
|
|
* \param thickness border thickness
|
|
|
|
* \return true if successful, false otherwise
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool html_redraw_border_plot(int i, int *p, colour c,
|
2009-08-02 23:19:43 +04:00
|
|
|
enum css_border_style_e style, int thickness)
|
2005-05-24 02:14:09 +04:00
|
|
|
{
|
|
|
|
int z[8];
|
|
|
|
unsigned int light = i;
|
2009-07-14 14:03:58 +04:00
|
|
|
plot_style_t *plot_style_bdr_in;
|
|
|
|
plot_style_t *plot_style_bdr_out;
|
2005-05-24 02:14:09 +04:00
|
|
|
|
2009-07-14 14:57:07 +04:00
|
|
|
if (c == NS_TRANSPARENT)
|
2006-06-30 01:30:05 +04:00
|
|
|
return true;
|
|
|
|
|
2009-07-14 14:03:58 +04:00
|
|
|
plot_style_bdr.stroke_type = PLOT_OP_TYPE_DASH;
|
|
|
|
plot_style_bdr.stroke_colour = c;
|
|
|
|
plot_style_bdr.stroke_width = thickness;
|
|
|
|
plot_style_fillbdr.fill_colour = c;
|
|
|
|
plot_style_fillbdr_dark.fill_colour = darken_colour(c);
|
|
|
|
plot_style_fillbdr_light.fill_colour = lighten_colour(c);
|
|
|
|
plot_style_fillbdr_ddark.fill_colour = double_darken_colour(c);
|
|
|
|
plot_style_fillbdr_dlight.fill_colour = double_lighten_colour(c);
|
|
|
|
|
2005-05-24 02:14:09 +04:00
|
|
|
switch (style) {
|
|
|
|
case CSS_BORDER_STYLE_DOTTED:
|
2009-07-10 22:36:49 +04:00
|
|
|
plot_style_bdr.stroke_type = PLOT_OP_TYPE_DOT;
|
2009-07-14 15:26:44 +04:00
|
|
|
/* fall through */
|
2005-05-24 02:14:09 +04:00
|
|
|
case CSS_BORDER_STYLE_DASHED:
|
|
|
|
if (!plot.line((p[i * 4 + 0] + p[i * 4 + 2]) / 2,
|
|
|
|
(p[i * 4 + 1] + p[i * 4 + 3]) / 2,
|
|
|
|
(p[i * 4 + 4] + p[i * 4 + 6]) / 2,
|
|
|
|
(p[i * 4 + 5] + p[i * 4 + 7]) / 2,
|
2009-07-10 22:36:49 +04:00
|
|
|
&plot_style_bdr))
|
2005-05-24 02:14:09 +04:00
|
|
|
return false;
|
2009-07-10 22:36:49 +04:00
|
|
|
break;
|
2005-05-24 02:14:09 +04:00
|
|
|
|
|
|
|
case CSS_BORDER_STYLE_SOLID:
|
2009-07-14 15:26:44 +04:00
|
|
|
/* fall through to default */
|
2009-07-10 22:36:49 +04:00
|
|
|
default:
|
2009-07-14 14:03:58 +04:00
|
|
|
if (!plot.polygon(p + i * 4, 4, &plot_style_fillbdr))
|
2009-07-10 22:36:49 +04:00
|
|
|
return false;
|
2005-05-24 02:14:09 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CSS_BORDER_STYLE_DOUBLE:
|
|
|
|
z[0] = p[i * 4 + 0];
|
|
|
|
z[1] = p[i * 4 + 1];
|
|
|
|
z[2] = (p[i * 4 + 0] * 2 + p[i * 4 + 2]) / 3;
|
|
|
|
z[3] = (p[i * 4 + 1] * 2 + p[i * 4 + 3]) / 3;
|
|
|
|
z[4] = (p[i * 4 + 6] * 2 + p[i * 4 + 4]) / 3;
|
|
|
|
z[5] = (p[i * 4 + 7] * 2 + p[i * 4 + 5]) / 3;
|
|
|
|
z[6] = p[i * 4 + 6];
|
|
|
|
z[7] = p[i * 4 + 7];
|
2009-07-14 14:03:58 +04:00
|
|
|
if (!plot.polygon(z, 4, &plot_style_fillbdr))
|
2005-05-24 02:14:09 +04:00
|
|
|
return false;
|
|
|
|
z[0] = p[i * 4 + 2];
|
|
|
|
z[1] = p[i * 4 + 3];
|
|
|
|
z[2] = (p[i * 4 + 2] * 2 + p[i * 4 + 0]) / 3;
|
|
|
|
z[3] = (p[i * 4 + 3] * 2 + p[i * 4 + 1]) / 3;
|
|
|
|
z[4] = (p[i * 4 + 4] * 2 + p[i * 4 + 6]) / 3;
|
|
|
|
z[5] = (p[i * 4 + 5] * 2 + p[i * 4 + 7]) / 3;
|
|
|
|
z[6] = p[i * 4 + 4];
|
|
|
|
z[7] = p[i * 4 + 5];
|
2009-07-14 14:03:58 +04:00
|
|
|
if (!plot.polygon(z, 4, &plot_style_fillbdr))
|
2005-05-24 02:14:09 +04:00
|
|
|
return false;
|
2009-07-10 22:36:49 +04:00
|
|
|
break;
|
2005-05-24 02:14:09 +04:00
|
|
|
|
|
|
|
case CSS_BORDER_STYLE_GROOVE:
|
|
|
|
light = 3 - light;
|
2009-07-14 15:26:44 +04:00
|
|
|
/* fall through */
|
2005-05-24 02:14:09 +04:00
|
|
|
case CSS_BORDER_STYLE_RIDGE:
|
2009-07-14 15:26:44 +04:00
|
|
|
/* choose correct colours for each part of the border line */
|
2009-07-14 14:03:58 +04:00
|
|
|
if (light <= 1) {
|
|
|
|
plot_style_bdr_in = &plot_style_fillbdr_dark;
|
|
|
|
plot_style_bdr_out = &plot_style_fillbdr_light;
|
|
|
|
} else {
|
|
|
|
plot_style_bdr_in = &plot_style_fillbdr_light;
|
|
|
|
plot_style_bdr_out = &plot_style_fillbdr_dark;
|
|
|
|
}
|
2005-05-24 02:14:09 +04:00
|
|
|
z[0] = p[i * 4 + 0];
|
|
|
|
z[1] = p[i * 4 + 1];
|
|
|
|
z[2] = (p[i * 4 + 0] + p[i * 4 + 2]) / 2;
|
|
|
|
z[3] = (p[i * 4 + 1] + p[i * 4 + 3]) / 2;
|
|
|
|
z[4] = (p[i * 4 + 6] + p[i * 4 + 4]) / 2;
|
|
|
|
z[5] = (p[i * 4 + 7] + p[i * 4 + 5]) / 2;
|
|
|
|
z[6] = p[i * 4 + 6];
|
|
|
|
z[7] = p[i * 4 + 7];
|
2009-07-14 14:03:58 +04:00
|
|
|
if (!plot.polygon(z, 4, plot_style_bdr_in))
|
2005-05-24 02:14:09 +04:00
|
|
|
return false;
|
|
|
|
z[0] = p[i * 4 + 2];
|
|
|
|
z[1] = p[i * 4 + 3];
|
|
|
|
z[6] = p[i * 4 + 4];
|
|
|
|
z[7] = p[i * 4 + 5];
|
2009-07-14 14:03:58 +04:00
|
|
|
if (!plot.polygon(z, 4, plot_style_bdr_out))
|
2005-05-24 02:14:09 +04:00
|
|
|
return false;
|
2009-07-10 22:36:49 +04:00
|
|
|
break;
|
2005-05-24 02:14:09 +04:00
|
|
|
|
|
|
|
case CSS_BORDER_STYLE_INSET:
|
|
|
|
light = (light + 2) % 4;
|
2009-07-14 15:26:44 +04:00
|
|
|
/* fall through */
|
2005-05-24 02:14:09 +04:00
|
|
|
case CSS_BORDER_STYLE_OUTSET:
|
2009-07-14 15:26:44 +04:00
|
|
|
/* choose correct colours for each part of the border line */
|
2005-05-24 02:14:09 +04:00
|
|
|
switch (light) {
|
|
|
|
case 0:
|
2009-07-14 14:03:58 +04:00
|
|
|
plot_style_bdr_in = &plot_style_fillbdr_light;
|
|
|
|
plot_style_bdr_out = &plot_style_fillbdr_dlight;
|
2004-10-18 01:05:12 +04:00
|
|
|
break;
|
2005-05-24 02:14:09 +04:00
|
|
|
case 1:
|
2009-07-14 14:03:58 +04:00
|
|
|
plot_style_bdr_in = &plot_style_fillbdr_ddark;
|
|
|
|
plot_style_bdr_out = &plot_style_fillbdr_dark;
|
2009-07-11 00:38:57 +04:00
|
|
|
break;
|
2005-05-24 02:14:09 +04:00
|
|
|
case 2:
|
2009-07-14 14:03:58 +04:00
|
|
|
plot_style_bdr_in = &plot_style_fillbdr_dark;
|
|
|
|
plot_style_bdr_out = &plot_style_fillbdr_ddark;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
plot_style_bdr_in = &plot_style_fillbdr_dlight;
|
|
|
|
plot_style_bdr_out = &plot_style_fillbdr_light;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
plot_style_bdr_in = &plot_style_fillbdr;
|
|
|
|
plot_style_bdr_out = &plot_style_fillbdr;
|
2009-07-11 00:38:57 +04:00
|
|
|
break;
|
2004-10-18 01:05:12 +04:00
|
|
|
}
|
2009-07-14 14:03:58 +04:00
|
|
|
|
|
|
|
z[0] = p[i * 4 + 0];
|
|
|
|
z[1] = p[i * 4 + 1];
|
|
|
|
z[2] = (p[i * 4 + 0] + p[i * 4 + 2]) / 2;
|
|
|
|
z[3] = (p[i * 4 + 1] + p[i * 4 + 3]) / 2;
|
|
|
|
z[4] = (p[i * 4 + 6] + p[i * 4 + 4]) / 2;
|
|
|
|
z[5] = (p[i * 4 + 7] + p[i * 4 + 5]) / 2;
|
|
|
|
z[6] = p[i * 4 + 6];
|
|
|
|
z[7] = p[i * 4 + 7];
|
|
|
|
if (!plot.polygon(z, 4, plot_style_bdr_in))
|
2005-05-24 02:14:09 +04:00
|
|
|
return false;
|
|
|
|
z[0] = p[i * 4 + 2];
|
|
|
|
z[1] = p[i * 4 + 3];
|
|
|
|
z[6] = p[i * 4 + 4];
|
|
|
|
z[7] = p[i * 4 + 5];
|
2009-07-14 14:03:58 +04:00
|
|
|
if (!plot.polygon(z, 4, plot_style_bdr_out))
|
2004-10-18 01:05:12 +04:00
|
|
|
return false;
|
2005-05-24 02:14:09 +04:00
|
|
|
break;
|
2004-10-18 01:05:12 +04:00
|
|
|
}
|
|
|
|
|
2005-05-24 02:14:09 +04:00
|
|
|
|
2004-10-18 01:05:12 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Plot a checkbox.
|
|
|
|
*
|
2004-11-11 02:02:11 +03:00
|
|
|
* \param x left coordinate
|
|
|
|
* \param y top coordinate
|
2004-10-18 01:05:12 +04:00
|
|
|
* \param width dimensions of checkbox
|
|
|
|
* \param height dimensions of checkbox
|
|
|
|
* \param selected the checkbox is selected
|
|
|
|
* \return true if successful, false otherwise
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool html_redraw_checkbox(int x, int y, int width, int height,
|
|
|
|
bool selected)
|
|
|
|
{
|
2006-03-22 04:06:05 +03:00
|
|
|
double z = width * 0.15;
|
2004-10-18 01:05:12 +04:00
|
|
|
if (z == 0)
|
|
|
|
z = 1;
|
2006-03-21 20:22:41 +03:00
|
|
|
|
2009-07-10 23:53:30 +04:00
|
|
|
if (!(plot.rectangle(x, y, x + width, y + height,
|
|
|
|
plot_style_fill_wbasec) &&
|
2009-07-10 22:36:49 +04:00
|
|
|
plot.line(x, y, x + width, y, plot_style_stroke_darkwbasec) &&
|
|
|
|
plot.line(x, y, x, y + height, plot_style_stroke_darkwbasec) &&
|
2009-07-10 23:53:30 +04:00
|
|
|
plot.line(x + width, y, x + width, y + height,
|
|
|
|
plot_style_stroke_lightwbasec) &&
|
|
|
|
plot.line(x, y + height, x + width, y + height,
|
|
|
|
plot_style_stroke_lightwbasec)))
|
2004-10-18 01:05:12 +04:00
|
|
|
return false;
|
2006-03-21 20:22:41 +03:00
|
|
|
|
|
|
|
if (selected) {
|
2008-12-26 14:34:23 +03:00
|
|
|
if (width < 12 || height < 12) {
|
2006-03-22 04:06:05 +03:00
|
|
|
/* render a solid box instead of a tick */
|
2009-07-09 02:04:40 +04:00
|
|
|
if (!plot.rectangle(x + z + z, y + z + z,
|
2009-07-14 15:26:44 +04:00
|
|
|
x + width - z, y + height - z,
|
|
|
|
plot_style_fill_wblobc))
|
2006-03-22 04:06:05 +03:00
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
/* render a tick, as it'll fit comfortably */
|
2006-06-30 01:30:05 +04:00
|
|
|
if (!(plot.line(x + width - z,
|
2009-07-10 22:36:49 +04:00
|
|
|
y + z,
|
|
|
|
x + (z * 3),
|
|
|
|
y + height - z,
|
|
|
|
plot_style_stroke_wblobc) &&
|
|
|
|
|
2009-07-14 15:26:44 +04:00
|
|
|
plot.line(x + (z * 3),
|
2009-07-10 22:36:49 +04:00
|
|
|
y + height - z,
|
|
|
|
x + z + z,
|
|
|
|
y + (height / 2),
|
|
|
|
plot_style_stroke_wblobc)))
|
2006-03-22 04:06:05 +03:00
|
|
|
return false;
|
|
|
|
}
|
2006-03-21 20:22:41 +03:00
|
|
|
}
|
2004-10-18 01:05:12 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Plot a radio icon.
|
|
|
|
*
|
2004-11-11 02:02:11 +03:00
|
|
|
* \param x left coordinate
|
|
|
|
* \param y top coordinate
|
2004-10-18 01:05:12 +04:00
|
|
|
* \param width dimensions of radio icon
|
|
|
|
* \param height dimensions of radio icon
|
|
|
|
* \param selected the radio icon is selected
|
|
|
|
* \return true if successful, false otherwise
|
|
|
|
*/
|
|
|
|
bool html_redraw_radio(int x, int y, int width, int height,
|
|
|
|
bool selected)
|
|
|
|
{
|
2008-12-26 14:34:23 +03:00
|
|
|
/* plot background of radio button */
|
2009-07-14 14:57:07 +04:00
|
|
|
if (!plot.disc(x + width * 0.5,
|
2009-07-14 15:26:44 +04:00
|
|
|
y + height * 0.5,
|
|
|
|
width * 0.5 - 1,
|
|
|
|
plot_style_fill_wbasec))
|
2006-03-21 20:22:41 +03:00
|
|
|
return false;
|
|
|
|
|
|
|
|
/* plot dark arc */
|
2009-07-14 14:57:07 +04:00
|
|
|
if (!plot.arc(x + width * 0.5,
|
2009-07-14 15:26:44 +04:00
|
|
|
y + height * 0.5,
|
|
|
|
width * 0.5 - 1,
|
|
|
|
45,
|
|
|
|
225,
|
|
|
|
plot_style_fill_darkwbasec))
|
2006-03-20 13:56:54 +03:00
|
|
|
return false;
|
2006-06-30 01:30:05 +04:00
|
|
|
|
2006-03-21 20:22:41 +03:00
|
|
|
/* plot light arc */
|
2009-07-14 14:57:07 +04:00
|
|
|
if (!plot.arc(x + width * 0.5,
|
2009-07-14 15:26:44 +04:00
|
|
|
y + height * 0.5,
|
|
|
|
width * 0.5 - 1,
|
|
|
|
225,
|
|
|
|
45,
|
|
|
|
plot_style_fill_lightwbasec))
|
2004-10-18 01:05:12 +04:00
|
|
|
return false;
|
2006-03-21 20:22:41 +03:00
|
|
|
|
2008-12-26 14:34:23 +03:00
|
|
|
if (selected) {
|
2006-03-21 20:22:41 +03:00
|
|
|
/* plot selection blob */
|
2009-07-14 14:57:07 +04:00
|
|
|
if (!plot.disc(x + width * 0.5,
|
2009-07-14 15:26:44 +04:00
|
|
|
y + height * 0.5,
|
|
|
|
width * 0.3 - 1,
|
|
|
|
plot_style_fill_wblobc))
|
2004-10-18 01:05:12 +04:00
|
|
|
return false;
|
2006-03-21 20:22:41 +03:00
|
|
|
}
|
2004-10-18 01:05:12 +04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Plot a file upload input.
|
|
|
|
*
|
2004-11-11 02:02:11 +03:00
|
|
|
* \param x left coordinate
|
|
|
|
* \param y top coordinate
|
2004-10-18 01:05:12 +04:00
|
|
|
* \param width dimensions of input
|
|
|
|
* \param height dimensions of input
|
2004-11-11 02:02:11 +03:00
|
|
|
* \param box box of input
|
2004-10-18 01:05:12 +04:00
|
|
|
* \param scale scale for redraw
|
|
|
|
* \param background_colour current background colour
|
|
|
|
* \return true if successful, false otherwise
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool html_redraw_file(int x, int y, int width, int height,
|
|
|
|
struct box *box, float scale, colour background_colour)
|
|
|
|
{
|
|
|
|
int text_width;
|
|
|
|
const char *text;
|
|
|
|
size_t length;
|
2009-07-21 14:59:53 +04:00
|
|
|
plot_font_style_t fstyle;
|
|
|
|
|
|
|
|
font_plot_style_from_css(box->style, &fstyle);
|
|
|
|
fstyle.background = background_colour;
|
2004-10-18 01:05:12 +04:00
|
|
|
|
|
|
|
if (box->gadget->value)
|
|
|
|
text = box->gadget->value;
|
|
|
|
else
|
|
|
|
text = messages_get("Form_Drop");
|
|
|
|
length = strlen(text);
|
|
|
|
|
2009-07-21 14:59:53 +04:00
|
|
|
if (!nsfont.font_width(&fstyle, text, length, &text_width))
|
2005-02-20 16:18:21 +03:00
|
|
|
return false;
|
|
|
|
text_width *= scale;
|
2004-10-18 01:05:12 +04:00
|
|
|
if (width < text_width + 8)
|
|
|
|
x = x + width - text_width - 4;
|
|
|
|
else
|
|
|
|
x = x + 4;
|
|
|
|
|
2009-07-21 14:59:53 +04:00
|
|
|
return plot.text(x, y + height * 0.75, text, length, &fstyle);
|
2004-10-18 01:05:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Plot background images.
|
|
|
|
*
|
2004-11-11 02:02:11 +03:00
|
|
|
* \param x coordinate of box
|
|
|
|
* \param y coordinate of box
|
|
|
|
* \param box box to draw background image of
|
2004-10-18 01:05:12 +04:00
|
|
|
* \param scale scale for redraw
|
|
|
|
* \param background_colour current background colour
|
2007-09-17 18:53:02 +04:00
|
|
|
* \param background box containing background details (usually ::box)
|
2004-10-18 01:05:12 +04:00
|
|
|
* \return true if successful, false otherwise
|
2007-09-17 18:53:02 +04:00
|
|
|
*
|
|
|
|
* The reason for the presence of ::background is the backwards compatibility
|
2008-01-27 21:15:56 +03:00
|
|
|
* mess that is backgrounds on <body>. The background will be drawn relative
|
2007-09-17 18:53:02 +04:00
|
|
|
* to ::box, using the background information contained within ::background.
|
2004-10-18 01:05:12 +04:00
|
|
|
*/
|
|
|
|
|
2005-04-29 05:34:19 +04:00
|
|
|
bool html_redraw_background(int x, int y, struct box *box, float scale,
|
|
|
|
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
|
2007-09-17 18:53:02 +04:00
|
|
|
colour *background_colour, struct box *background)
|
2004-10-18 01:05:12 +04:00
|
|
|
{
|
|
|
|
bool repeat_x = false;
|
|
|
|
bool repeat_y = false;
|
2005-04-29 05:34:19 +04:00
|
|
|
bool plot_colour = true;
|
2006-02-21 23:49:12 +03:00
|
|
|
bool plot_content;
|
2005-04-29 05:34:19 +04:00
|
|
|
bool clip_to_children = false;
|
|
|
|
struct box *clip_box = box;
|
|
|
|
int px0 = clip_x0, py0 = clip_y0, px1 = clip_x1, py1 = clip_y1;
|
|
|
|
int ox = x, oy = y;
|
2008-12-27 03:08:25 +03:00
|
|
|
int width, height;
|
2009-07-24 03:05:34 +04:00
|
|
|
css_fixed hpos = 0, vpos = 0;
|
|
|
|
css_unit hunit = CSS_UNIT_PX, vunit = CSS_UNIT_PX;
|
2006-01-02 02:55:24 +03:00
|
|
|
struct box *parent;
|
2009-07-24 03:05:34 +04:00
|
|
|
css_color bgcol;
|
2009-07-06 14:33:19 +04:00
|
|
|
plot_style_t pstyle_fill_bg = {
|
|
|
|
.fill_type = PLOT_OP_TYPE_SOLID,
|
|
|
|
.fill_colour = *background_colour,
|
|
|
|
};
|
2005-04-29 05:34:19 +04:00
|
|
|
|
2009-01-17 22:39:38 +03:00
|
|
|
if (html_redraw_printing && option_remove_backgrounds)
|
|
|
|
return true;
|
|
|
|
|
2007-09-17 18:53:02 +04:00
|
|
|
plot_content = (background->background != NULL);
|
|
|
|
|
2006-02-21 23:49:12 +03:00
|
|
|
if (plot_content) {
|
2008-12-27 03:08:25 +03:00
|
|
|
if (!box->parent) {
|
|
|
|
/* Root element, special case:
|
|
|
|
* background origin calc. is based on margin box */
|
|
|
|
x -= box->margin[LEFT] * scale;
|
|
|
|
y -= box->margin[TOP] * scale;
|
|
|
|
width = box->margin[LEFT] + box->padding[LEFT] +
|
|
|
|
box->width + box->padding[RIGHT] +
|
|
|
|
box->margin[RIGHT];
|
|
|
|
height = box->margin[TOP] + box->padding[TOP] +
|
|
|
|
box->height + box->padding[BOTTOM] +
|
|
|
|
box->margin[BOTTOM];
|
|
|
|
} else {
|
|
|
|
width = box->padding[LEFT] + box->width +
|
|
|
|
box->padding[RIGHT];
|
|
|
|
height = box->padding[TOP] + box->height +
|
|
|
|
box->padding[BOTTOM];
|
|
|
|
}
|
2005-04-29 05:34:19 +04:00
|
|
|
/* handle background-repeat */
|
2009-07-24 03:05:34 +04:00
|
|
|
switch (css_computed_background_repeat(background->style)) {
|
2005-04-29 05:34:19 +04:00
|
|
|
case CSS_BACKGROUND_REPEAT_REPEAT:
|
|
|
|
repeat_x = repeat_y = true;
|
2008-01-27 21:15:56 +03:00
|
|
|
/* optimisation: only plot the colour if
|
2007-09-17 18:53:02 +04:00
|
|
|
* bitmap is not opaque */
|
|
|
|
if (background->background->bitmap)
|
2006-02-21 23:49:12 +03:00
|
|
|
plot_colour = !bitmap_get_opaque(
|
2007-09-17 18:53:02 +04:00
|
|
|
background->background->bitmap);
|
2005-04-29 05:34:19 +04:00
|
|
|
break;
|
|
|
|
case CSS_BACKGROUND_REPEAT_REPEAT_X:
|
|
|
|
repeat_x = true;
|
|
|
|
break;
|
|
|
|
case CSS_BACKGROUND_REPEAT_REPEAT_Y:
|
|
|
|
repeat_y = true;
|
|
|
|
break;
|
|
|
|
case CSS_BACKGROUND_REPEAT_NO_REPEAT:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2004-10-18 01:05:12 +04:00
|
|
|
|
2005-04-29 05:34:19 +04:00
|
|
|
/* handle background-position */
|
2009-07-24 03:05:34 +04:00
|
|
|
css_computed_background_position(background->style,
|
|
|
|
&hpos, &hunit, &vpos, &vunit);
|
|
|
|
if (hunit == CSS_UNIT_PCT) {
|
|
|
|
x += (width - background->background->width) *
|
|
|
|
scale * FIXTOFLT(hpos) / 100.;
|
|
|
|
} else {
|
|
|
|
x += (int) (FIXTOFLT(nscss_len2px(hpos, hunit,
|
|
|
|
background->style)) * scale);
|
2005-04-29 05:34:19 +04:00
|
|
|
}
|
2004-10-18 01:05:12 +04:00
|
|
|
|
2009-07-24 03:05:34 +04:00
|
|
|
if (vunit == CSS_UNIT_PCT) {
|
|
|
|
y += (height - background->background->height) *
|
|
|
|
scale * FIXTOFLT(vpos) / 100.;
|
|
|
|
} else {
|
|
|
|
y += (int) (FIXTOFLT(nscss_len2px(vpos, vunit,
|
|
|
|
background->style)) * scale);
|
2005-04-29 05:34:19 +04:00
|
|
|
}
|
2004-10-18 01:05:12 +04:00
|
|
|
}
|
|
|
|
|
2008-01-27 21:15:56 +03:00
|
|
|
/* special case for table rows as their background needs
|
2007-09-17 18:53:02 +04:00
|
|
|
* to be clipped to all the cells */
|
2005-04-29 05:34:19 +04:00
|
|
|
if (box->type == BOX_TABLE_ROW) {
|
2009-07-24 03:05:34 +04:00
|
|
|
css_fixed h = 0, v = 0;
|
|
|
|
css_unit hu = CSS_UNIT_PX, vu = CSS_UNIT_PX;
|
|
|
|
|
2008-01-27 21:15:56 +03:00
|
|
|
for (parent = box->parent;
|
2007-09-17 18:53:02 +04:00
|
|
|
((parent) && (parent->type != BOX_TABLE));
|
2006-01-02 02:55:24 +03:00
|
|
|
parent = parent->parent);
|
|
|
|
assert(parent && (parent->style));
|
2007-09-17 18:53:02 +04:00
|
|
|
|
2009-07-24 03:05:34 +04:00
|
|
|
css_computed_border_spacing(parent->style, &h, &hu, &v, &vu);
|
|
|
|
|
|
|
|
clip_to_children = (h > 0) || (v > 0);
|
2007-09-17 18:53:02 +04:00
|
|
|
|
2006-01-02 02:55:24 +03:00
|
|
|
if (clip_to_children)
|
|
|
|
clip_box = box->children;
|
2004-10-18 01:05:12 +04:00
|
|
|
}
|
|
|
|
|
2006-01-02 02:55:24 +03:00
|
|
|
for (; clip_box; clip_box = clip_box->next) {
|
2008-12-26 14:34:23 +03:00
|
|
|
/* clip to child boxes if needed */
|
|
|
|
if (clip_to_children) {
|
|
|
|
assert(clip_box->type == BOX_TABLE_CELL);
|
|
|
|
|
|
|
|
/* update clip_* to the child cell */
|
|
|
|
clip_x0 = ox + (clip_box->x * scale);
|
|
|
|
clip_y0 = oy + (clip_box->y * scale);
|
|
|
|
clip_x1 = clip_x0 + (clip_box->padding[LEFT] +
|
|
|
|
clip_box->width +
|
2007-09-17 18:53:02 +04:00
|
|
|
clip_box->padding[RIGHT]) * scale;
|
2008-12-26 14:34:23 +03:00
|
|
|
clip_y1 = clip_y0 + (clip_box->padding[TOP] +
|
|
|
|
clip_box->height +
|
2007-09-17 18:53:02 +04:00
|
|
|
clip_box->padding[BOTTOM]) * scale;
|
|
|
|
|
2005-04-29 05:34:19 +04:00
|
|
|
if (clip_x0 < px0) clip_x0 = px0;
|
|
|
|
if (clip_y0 < py0) clip_y0 = py0;
|
|
|
|
if (clip_x1 > px1) clip_x1 = px1;
|
|
|
|
if (clip_y1 > py1) clip_y1 = py1;
|
2005-05-23 01:50:14 +04:00
|
|
|
|
2006-01-02 02:55:24 +03:00
|
|
|
/* <td> attributes override <tr> */
|
2005-04-29 05:34:19 +04:00
|
|
|
if ((clip_x0 >= clip_x1) || (clip_y0 >= clip_y1) ||
|
2009-07-24 03:05:34 +04:00
|
|
|
(css_computed_background_color(
|
|
|
|
clip_box->style, &bgcol) !=
|
|
|
|
CSS_BACKGROUND_COLOR_TRANSPARENT) ||
|
2005-04-30 21:11:24 +04:00
|
|
|
(clip_box->background &&
|
|
|
|
clip_box->background->bitmap &&
|
2007-09-17 18:53:02 +04:00
|
|
|
bitmap_get_opaque(
|
|
|
|
clip_box->background->bitmap)))
|
2005-04-29 05:34:19 +04:00
|
|
|
continue;
|
2008-12-26 14:34:23 +03:00
|
|
|
}
|
2005-04-29 05:34:19 +04:00
|
|
|
|
|
|
|
/* plot the background colour */
|
2009-07-24 03:05:34 +04:00
|
|
|
if (css_computed_background_color(background->style, &bgcol) !=
|
|
|
|
CSS_BACKGROUND_COLOR_TRANSPARENT) {
|
|
|
|
*background_colour = nscss_color_to_ns(bgcol);
|
|
|
|
pstyle_fill_bg.fill_colour = *background_colour;
|
2005-04-29 05:34:19 +04:00
|
|
|
if (plot_colour)
|
2009-07-09 02:04:40 +04:00
|
|
|
if (!plot.rectangle(clip_x0, clip_y0,
|
2008-12-21 18:51:23 +03:00
|
|
|
clip_x1, clip_y1,
|
2009-07-06 00:10:17 +04:00
|
|
|
&pstyle_fill_bg))
|
2008-12-21 18:51:23 +03:00
|
|
|
return false;
|
2005-04-29 05:34:19 +04:00
|
|
|
}
|
|
|
|
/* and plot the image */
|
2006-02-21 23:49:12 +03:00
|
|
|
if (plot_content) {
|
2008-07-19 04:50:41 +04:00
|
|
|
if (!repeat_x) {
|
|
|
|
if (clip_x0 < x)
|
|
|
|
clip_x0 = x;
|
2008-07-19 05:36:12 +04:00
|
|
|
if (clip_x1 > x +
|
|
|
|
background->background->width *
|
|
|
|
scale)
|
2008-07-19 04:50:41 +04:00
|
|
|
clip_x1 = x + background->background->
|
2008-07-19 05:36:12 +04:00
|
|
|
width * scale;
|
2008-12-21 18:51:23 +03:00
|
|
|
}
|
|
|
|
if (!repeat_y) {
|
2008-07-19 04:50:41 +04:00
|
|
|
if (clip_y0 < y)
|
|
|
|
clip_y0 = y;
|
2008-07-19 05:36:12 +04:00
|
|
|
if (clip_y1 > y +
|
|
|
|
background->background->height *
|
|
|
|
scale)
|
2008-07-19 04:50:41 +04:00
|
|
|
clip_y1 = y + background->background->
|
2008-07-19 05:36:12 +04:00
|
|
|
height * scale;
|
2008-07-19 04:50:41 +04:00
|
|
|
}
|
|
|
|
/* valid clipping rectangles only */
|
|
|
|
if ((clip_x0 < clip_x1) && (clip_y0 < clip_y1)) {
|
|
|
|
if (!plot.clip(clip_x0, clip_y0,
|
|
|
|
clip_x1, clip_y1))
|
2005-04-29 05:34:19 +04:00
|
|
|
return false;
|
2008-07-19 04:50:41 +04:00
|
|
|
if (!content_redraw_tiled(background->
|
|
|
|
background, x, y,
|
|
|
|
ceilf(background->background->
|
|
|
|
width * scale),
|
|
|
|
ceilf(background->background->
|
|
|
|
height * scale),
|
|
|
|
clip_x0, clip_y0,
|
|
|
|
clip_x1, clip_y1,
|
|
|
|
scale, *background_colour,
|
|
|
|
repeat_x, repeat_y))
|
|
|
|
return false;
|
|
|
|
}
|
2005-04-29 05:34:19 +04:00
|
|
|
}
|
2005-05-23 01:50:14 +04:00
|
|
|
|
2006-01-02 02:55:24 +03:00
|
|
|
/* only <tr> rows being clipped to child boxes loop */
|
|
|
|
if (!clip_to_children)
|
|
|
|
return true;
|
|
|
|
}
|
2005-04-29 05:34:19 +04:00
|
|
|
return true;
|
2004-10-18 01:05:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-21 18:51:23 +03:00
|
|
|
/**
|
|
|
|
* Plot an inline's background and/or background image.
|
|
|
|
*
|
|
|
|
* \param x coordinate of box
|
|
|
|
* \param y coordinate of box
|
|
|
|
* \param box BOX_INLINE which created the background
|
|
|
|
* \param scale scale for redraw
|
|
|
|
* \param clip_x0 coordinate of clip rectangle
|
|
|
|
* \param clip_y0 coordinate of clip rectangle
|
|
|
|
* \param clip_x1 coordinate of clip rectangle
|
|
|
|
* \param clip_y1 coordinate of clip rectangle
|
|
|
|
* \param px0 coordinate of border edge rectangle
|
|
|
|
* \param py0 coordinate of border edge rectangle
|
|
|
|
* \param px1 coordinate of border edge rectangle
|
|
|
|
* \param py1 coordinate of border edge rectangle
|
|
|
|
* \param first true if this is the first rectangle associated with the inline
|
|
|
|
* \param last true if this is the last rectangle associated with the inline
|
|
|
|
* \param background_colour updated to current background colour if plotted
|
|
|
|
* \return true if successful, false otherwise
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool html_redraw_inline_background(int x, int y, struct box *box, float scale,
|
|
|
|
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
|
|
|
|
int px0, int py0, int px1, int py1,
|
|
|
|
bool first, bool last, colour *background_colour)
|
|
|
|
{
|
|
|
|
bool repeat_x = false;
|
|
|
|
bool repeat_y = false;
|
|
|
|
bool plot_colour = true;
|
|
|
|
bool plot_content;
|
2009-07-24 03:05:34 +04:00
|
|
|
css_fixed hpos = 0, vpos = 0;
|
|
|
|
css_unit hunit = CSS_UNIT_PX, vunit = CSS_UNIT_PX;
|
|
|
|
css_color bgcol;
|
2009-07-06 14:33:19 +04:00
|
|
|
plot_style_t pstyle_fill_bg = {
|
|
|
|
.fill_type = PLOT_OP_TYPE_SOLID,
|
|
|
|
.fill_colour = *background_colour,
|
|
|
|
};
|
2008-12-21 18:51:23 +03:00
|
|
|
|
|
|
|
plot_content = (box->background != NULL);
|
|
|
|
|
2009-01-17 22:39:38 +03:00
|
|
|
if (html_redraw_printing && option_remove_backgrounds)
|
|
|
|
return true;
|
|
|
|
|
2008-12-21 18:51:23 +03:00
|
|
|
if (plot_content) {
|
|
|
|
/* handle background-repeat */
|
2009-07-24 03:05:34 +04:00
|
|
|
switch (css_computed_background_repeat(box->style)) {
|
2008-12-21 18:51:23 +03:00
|
|
|
case CSS_BACKGROUND_REPEAT_REPEAT:
|
|
|
|
repeat_x = repeat_y = true;
|
|
|
|
/* optimisation: only plot the colour if
|
|
|
|
* bitmap is not opaque */
|
|
|
|
if (box->background->bitmap)
|
|
|
|
plot_colour = !bitmap_get_opaque(
|
|
|
|
box->background->bitmap);
|
|
|
|
break;
|
|
|
|
case CSS_BACKGROUND_REPEAT_REPEAT_X:
|
|
|
|
repeat_x = true;
|
|
|
|
break;
|
|
|
|
case CSS_BACKGROUND_REPEAT_REPEAT_Y:
|
|
|
|
repeat_y = true;
|
|
|
|
break;
|
|
|
|
case CSS_BACKGROUND_REPEAT_NO_REPEAT:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* handle background-position */
|
2009-07-24 03:05:34 +04:00
|
|
|
css_computed_background_position(box->style,
|
|
|
|
&hpos, &hunit, &vpos, &vunit);
|
|
|
|
if (hunit == CSS_UNIT_PCT) {
|
|
|
|
x += (px1 - px0 - box->background->width * scale) *
|
|
|
|
FIXTOFLT(hpos) / 100.;
|
|
|
|
|
|
|
|
if (!repeat_x && ((hpos < 2 && !first) ||
|
|
|
|
(hpos > 98 && !last))){
|
|
|
|
plot_content = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
x += (int) (FIXTOFLT(nscss_len2px(hpos, hunit,
|
|
|
|
box->style)) * scale);
|
2008-12-21 18:51:23 +03:00
|
|
|
}
|
|
|
|
|
2009-07-24 03:05:34 +04:00
|
|
|
if (vunit == CSS_UNIT_PCT) {
|
|
|
|
y += (py1 - py0 - box->background->height * scale) *
|
|
|
|
FIXTOFLT(vpos) / 100.;
|
|
|
|
} else {
|
|
|
|
y += (int) (FIXTOFLT(nscss_len2px(vpos, vunit,
|
|
|
|
box->style)) * scale);
|
2008-12-21 18:51:23 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* plot the background colour */
|
2009-07-24 03:05:34 +04:00
|
|
|
if (css_computed_background_color(box->style, &bgcol) !=
|
|
|
|
CSS_BACKGROUND_COLOR_TRANSPARENT) {
|
|
|
|
*background_colour = nscss_color_to_ns(bgcol);
|
|
|
|
pstyle_fill_bg.fill_colour = *background_colour;
|
2009-07-06 00:10:17 +04:00
|
|
|
|
2008-12-21 18:51:23 +03:00
|
|
|
if (plot_colour)
|
2009-07-09 02:04:40 +04:00
|
|
|
if (!plot.rectangle(clip_x0, clip_y0,
|
2008-12-21 18:51:23 +03:00
|
|
|
clip_x1, clip_y1,
|
2009-07-06 00:10:17 +04:00
|
|
|
&pstyle_fill_bg))
|
2008-12-21 18:51:23 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
/* and plot the image */
|
|
|
|
if (plot_content) {
|
|
|
|
if (!repeat_x) {
|
|
|
|
if (clip_x0 < x)
|
|
|
|
clip_x0 = x;
|
|
|
|
if (clip_x1 > x +
|
|
|
|
box->background->width *
|
|
|
|
scale)
|
|
|
|
clip_x1 = x + box->background->
|
|
|
|
width * scale;
|
|
|
|
}
|
|
|
|
if (!repeat_y) {
|
|
|
|
if (clip_y0 < y)
|
|
|
|
clip_y0 = y;
|
|
|
|
if (clip_y1 > y +
|
|
|
|
box->background->height *
|
|
|
|
scale)
|
|
|
|
clip_y1 = y + box->background->
|
|
|
|
height * scale;
|
|
|
|
}
|
|
|
|
/* valid clipping rectangles only */
|
|
|
|
if ((clip_x0 < clip_x1) && (clip_y0 < clip_y1)) {
|
|
|
|
if (!plot.clip(clip_x0, clip_y0,
|
|
|
|
clip_x1, clip_y1))
|
|
|
|
return false;
|
|
|
|
if (!content_redraw_tiled(box->
|
|
|
|
background, x, y,
|
|
|
|
ceilf(box->background->
|
|
|
|
width * scale),
|
|
|
|
ceilf(box->background->
|
|
|
|
height * scale),
|
|
|
|
clip_x0, clip_y0,
|
|
|
|
clip_x1, clip_y1,
|
|
|
|
scale, *background_colour,
|
|
|
|
repeat_x, repeat_y))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-05-23 01:50:14 +04:00
|
|
|
/**
|
|
|
|
* Plot text decoration for a box.
|
|
|
|
*
|
|
|
|
* \param box box to plot decorations for
|
|
|
|
* \param x_parent x coordinate of parent of box
|
|
|
|
* \param y_parent y coordinate of parent of box
|
|
|
|
* \param scale scale for redraw
|
|
|
|
* \param background_colour current background colour
|
|
|
|
* \return true if successful, false otherwise
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool html_redraw_text_decoration(struct box *box,
|
|
|
|
int x_parent, int y_parent, float scale,
|
|
|
|
colour background_colour)
|
|
|
|
{
|
2009-08-02 23:19:43 +04:00
|
|
|
static const enum css_text_decoration_e decoration[] = {
|
2005-05-23 01:50:14 +04:00
|
|
|
CSS_TEXT_DECORATION_UNDERLINE, CSS_TEXT_DECORATION_OVERLINE,
|
|
|
|
CSS_TEXT_DECORATION_LINE_THROUGH };
|
2005-05-23 02:16:00 +04:00
|
|
|
static const float line_ratio[] = { 0.9, 0.1, 0.5 };
|
2009-07-24 03:05:34 +04:00
|
|
|
colour fgcol;
|
2005-05-23 01:50:14 +04:00
|
|
|
unsigned int i;
|
2009-07-24 03:05:34 +04:00
|
|
|
css_color col;
|
|
|
|
|
|
|
|
css_computed_color(box->style, &col);
|
|
|
|
fgcol = nscss_color_to_ns(col);
|
2005-05-23 01:50:14 +04:00
|
|
|
|
|
|
|
/* antialias colour for under/overline */
|
2009-07-24 03:05:34 +04:00
|
|
|
if (html_redraw_printing == false)
|
|
|
|
fgcol = blend_colour(background_colour, fgcol);
|
2005-05-23 01:50:14 +04:00
|
|
|
|
|
|
|
if (box->type == BOX_INLINE) {
|
2006-02-04 15:02:06 +03:00
|
|
|
if (!box->inline_end)
|
|
|
|
return true;
|
2005-05-23 01:50:14 +04:00
|
|
|
for (i = 0; i != NOF_ELEMENTS(decoration); i++)
|
2009-07-24 03:05:34 +04:00
|
|
|
if (css_computed_text_decoration(box->style) &
|
|
|
|
decoration[i])
|
2005-05-23 01:50:14 +04:00
|
|
|
if (!html_redraw_text_decoration_inline(box,
|
|
|
|
x_parent, y_parent, scale,
|
2009-07-24 03:05:34 +04:00
|
|
|
fgcol, line_ratio[i]))
|
2005-05-23 01:50:14 +04:00
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
for (i = 0; i != NOF_ELEMENTS(decoration); i++)
|
2009-07-24 03:05:34 +04:00
|
|
|
if (css_computed_text_decoration(box->style) &
|
|
|
|
decoration[i])
|
2005-05-23 01:50:14 +04:00
|
|
|
if (!html_redraw_text_decoration_block(box,
|
|
|
|
x_parent + box->x,
|
|
|
|
y_parent + box->y,
|
|
|
|
scale,
|
2009-07-24 03:05:34 +04:00
|
|
|
fgcol, line_ratio[i]))
|
2005-05-23 01:50:14 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Plot text decoration for an inline box.
|
|
|
|
*
|
|
|
|
* \param box box to plot decorations for, of type BOX_INLINE
|
|
|
|
* \param x x coordinate of parent of box
|
|
|
|
* \param y y coordinate of parent of box
|
|
|
|
* \param scale scale for redraw
|
|
|
|
* \param colour colour for decorations
|
|
|
|
* \param ratio position of line as a ratio of line height
|
|
|
|
* \return true if successful, false otherwise
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool html_redraw_text_decoration_inline(struct box *box, int x, int y,
|
|
|
|
float scale, colour colour, float ratio)
|
|
|
|
{
|
2008-08-13 22:08:05 +04:00
|
|
|
struct box *c;
|
2009-07-10 22:36:49 +04:00
|
|
|
plot_style_t plot_style_box = {
|
|
|
|
.stroke_type = PLOT_OP_TYPE_SOLID,
|
|
|
|
.stroke_colour = colour,
|
|
|
|
};
|
|
|
|
|
2008-08-13 22:08:05 +04:00
|
|
|
for (c = box->next;
|
2005-06-06 00:54:37 +04:00
|
|
|
c && c != box->inline_end;
|
2005-05-23 01:50:14 +04:00
|
|
|
c = c->next) {
|
2008-12-23 00:57:56 +03:00
|
|
|
if (c->type != BOX_TEXT)
|
|
|
|
continue;
|
2005-05-23 01:50:14 +04:00
|
|
|
if (!plot.line((x + c->x) * scale,
|
|
|
|
(y + c->y + c->height * ratio) * scale,
|
|
|
|
(x + c->x + c->width) * scale,
|
|
|
|
(y + c->y + c->height * ratio) * scale,
|
2009-07-10 22:36:49 +04:00
|
|
|
&plot_style_box))
|
2005-05-23 01:50:14 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Plot text decoration for an non-inline box.
|
|
|
|
*
|
|
|
|
* \param box box to plot decorations for, of type other than BOX_INLINE
|
|
|
|
* \param x x coordinate of box
|
|
|
|
* \param y y coordinate of box
|
|
|
|
* \param scale scale for redraw
|
|
|
|
* \param colour colour for decorations
|
|
|
|
* \param ratio position of line as a ratio of line height
|
|
|
|
* \return true if successful, false otherwise
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool html_redraw_text_decoration_block(struct box *box, int x, int y,
|
|
|
|
float scale, colour colour, float ratio)
|
|
|
|
{
|
2008-08-13 22:08:05 +04:00
|
|
|
struct box *c;
|
2009-07-10 22:36:49 +04:00
|
|
|
plot_style_t plot_style_box = {
|
|
|
|
.stroke_type = PLOT_OP_TYPE_SOLID,
|
|
|
|
.stroke_colour = colour,
|
|
|
|
};
|
|
|
|
|
2005-05-23 01:50:14 +04:00
|
|
|
/* draw through text descendants */
|
2008-08-13 22:08:05 +04:00
|
|
|
for (c = box->children; c; c = c->next) {
|
2005-05-23 01:50:14 +04:00
|
|
|
if (c->type == BOX_TEXT) {
|
|
|
|
if (!plot.line((x + c->x) * scale,
|
|
|
|
(y + c->y + c->height * ratio) * scale,
|
|
|
|
(x + c->x + c->width) * scale,
|
|
|
|
(y + c->y + c->height * ratio) * scale,
|
2009-07-10 22:36:49 +04:00
|
|
|
&plot_style_box))
|
2005-05-23 01:50:14 +04:00
|
|
|
return false;
|
|
|
|
} else if (c->type == BOX_INLINE_CONTAINER ||
|
|
|
|
c->type == BOX_BLOCK) {
|
|
|
|
if (!html_redraw_text_decoration_block(c,
|
|
|
|
x + c->x, y + c->y,
|
|
|
|
scale, colour, ratio))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|