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>
|
2018-05-10 13:34:26 +03: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
|
|
|
*/
|
|
|
|
|
2014-10-13 14:56:31 +04:00
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
*
|
|
|
|
* Redrawing CONTENT_HTML implementation.
|
2004-10-18 01:05:12 +04:00
|
|
|
*/
|
|
|
|
|
2014-10-17 15:21:06 +04:00
|
|
|
#include "utils/config.h"
|
2004-10-18 01:05:12 +04:00
|
|
|
#include <assert.h>
|
|
|
|
#include <stdbool.h>
|
2010-08-14 17:03:57 +04:00
|
|
|
#include <stdlib.h>
|
2004-10-18 01:05:12 +04:00
|
|
|
#include <string.h>
|
2008-07-29 00:32:51 +04:00
|
|
|
#include <math.h>
|
2012-03-25 00:55:22 +04:00
|
|
|
#include <dom/dom.h>
|
2014-10-13 14:56:31 +04:00
|
|
|
|
|
|
|
#include "utils/log.h"
|
|
|
|
#include "utils/messages.h"
|
|
|
|
#include "utils/utils.h"
|
2014-10-17 15:21:06 +04:00
|
|
|
#include "utils/nsoption.h"
|
2016-06-06 10:59:23 +03:00
|
|
|
#include "netsurf/content.h"
|
2016-05-30 19:32:57 +03:00
|
|
|
#include "netsurf/browser_window.h"
|
2016-05-30 23:05:57 +03:00
|
|
|
#include "netsurf/plotters.h"
|
2016-06-06 10:59:23 +03:00
|
|
|
#include "netsurf/bitmap.h"
|
|
|
|
#include "netsurf/layout.h"
|
|
|
|
#include "content/content_protected.h"
|
2016-06-06 16:47:27 +03:00
|
|
|
#include "css/utils.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "desktop/selection.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"
|
2011-05-10 02:49:17 +04:00
|
|
|
#include "desktop/scrollbar.h"
|
2013-02-07 02:39:45 +04:00
|
|
|
#include "desktop/textarea.h"
|
2016-04-24 01:32:21 +03:00
|
|
|
#include "desktop/gui_internal.h"
|
2014-10-13 14:56:31 +04:00
|
|
|
|
2018-05-10 13:34:26 +03:00
|
|
|
#include "html/box.h"
|
|
|
|
#include "html/font.h"
|
|
|
|
#include "html/form_internal.h"
|
|
|
|
#include "html/html_internal.h"
|
|
|
|
#include "html/layout.h"
|
|
|
|
#include "html/search.h"
|
2006-07-01 22:16:05 +04:00
|
|
|
|
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
bool html_redraw_debug = false;
|
2004-10-18 01:05:12 +04:00
|
|
|
|
2011-01-29 22:22:12 +03:00
|
|
|
/**
|
|
|
|
* Determine if a box has a background that needs drawing
|
|
|
|
*
|
|
|
|
* \param box Box to consider
|
|
|
|
* \return True if box has a background, false otherwise.
|
|
|
|
*/
|
|
|
|
static bool html_redraw_box_has_background(struct box *box)
|
|
|
|
{
|
|
|
|
if (box->background != NULL)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (box->style != NULL) {
|
|
|
|
css_color colour;
|
|
|
|
|
|
|
|
css_computed_background_color(box->style, &colour);
|
|
|
|
|
|
|
|
if (nscss_color_is_transparent(colour) == false)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Find the background box for a box
|
|
|
|
*
|
|
|
|
* \param box Box to find background box for
|
|
|
|
* \return Pointer to background box, or NULL if there is none
|
|
|
|
*/
|
|
|
|
static struct box *html_redraw_find_bg_box(struct box *box)
|
|
|
|
{
|
|
|
|
/* Thanks to backwards compatibility, CSS defines the following:
|
|
|
|
*
|
|
|
|
* + 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,
|
|
|
|
* 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
|
|
|
|
* element is processed, ignore the background.
|
|
|
|
* + For any other box, just use its own styling.
|
|
|
|
*/
|
|
|
|
if (box->parent == NULL) {
|
|
|
|
/* Root box */
|
|
|
|
if (html_redraw_box_has_background(box))
|
|
|
|
return box;
|
|
|
|
|
|
|
|
/* No background on root box: consider body box, if any */
|
|
|
|
if (box->children != NULL) {
|
|
|
|
if (html_redraw_box_has_background(box->children))
|
|
|
|
return box->children;
|
|
|
|
}
|
|
|
|
} else if (box->parent != NULL && box->parent->parent == NULL) {
|
|
|
|
/* Body box: only render background if root has its own */
|
|
|
|
if (html_redraw_box_has_background(box) &&
|
|
|
|
html_redraw_box_has_background(box->parent))
|
|
|
|
return box;
|
|
|
|
} else {
|
|
|
|
/* Any other box */
|
|
|
|
if (html_redraw_box_has_background(box))
|
|
|
|
return box;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2004-10-18 01:05:12 +04:00
|
|
|
|
|
|
|
/**
|
2013-01-02 22:02:15 +04:00
|
|
|
* Redraw a short text string, complete with highlighting
|
|
|
|
* (for selection/search)
|
2004-10-18 01:05:12 +04:00
|
|
|
*
|
2014-11-12 19:21:23 +03:00
|
|
|
* \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 width of space that follows string (0 = no space)
|
|
|
|
* \param fstyle text style to use (pass text size unscaled)
|
|
|
|
* \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
|
|
|
|
* \param c Content being redrawn.
|
|
|
|
* \param sel Selection context
|
|
|
|
* \param search Search context
|
|
|
|
* \param ctx current redraw context
|
2013-01-02 22:02:15 +04:00
|
|
|
* \return true iff successful and redraw should proceed
|
2004-10-18 01:05:12 +04:00
|
|
|
*/
|
|
|
|
|
2018-05-10 13:34:26 +03:00
|
|
|
static bool
|
2017-02-11 16:54:08 +03:00
|
|
|
text_redraw(const char *utf8_text,
|
|
|
|
size_t utf8_len,
|
|
|
|
size_t offset,
|
|
|
|
int space,
|
|
|
|
const plot_font_style_t *fstyle,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
const struct rect *clip,
|
|
|
|
int height,
|
|
|
|
float scale,
|
|
|
|
bool excluded,
|
|
|
|
struct content *c,
|
|
|
|
const struct selection *sel,
|
|
|
|
struct search_context *search,
|
|
|
|
const struct redraw_context *ctx)
|
2004-10-18 01:05:12 +04:00
|
|
|
{
|
2013-01-02 22:02:15 +04:00
|
|
|
bool highlighted = false;
|
|
|
|
plot_font_style_t plot_fstyle = *fstyle;
|
2017-02-11 16:54:08 +03:00
|
|
|
nserror res;
|
2008-08-25 23:30:10 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* Need scaled text size to pass to plotters */
|
|
|
|
plot_fstyle.size *= scale;
|
2004-10-18 01:05:12 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* is this box part of a selection? */
|
|
|
|
if (!excluded && ctx->interactive == true) {
|
|
|
|
unsigned len = utf8_len + (space ? 1 : 0);
|
|
|
|
unsigned start_idx;
|
|
|
|
unsigned end_idx;
|
2005-04-15 09:52:11 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* first try the browser window's current selection */
|
|
|
|
if (selection_defined(sel) && selection_highlighted(sel,
|
|
|
|
offset, offset + len,
|
|
|
|
&start_idx, &end_idx)) {
|
|
|
|
highlighted = true;
|
2008-12-27 20:29:17 +03:00
|
|
|
}
|
2004-10-18 01:05:12 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* what about the current search operation, if any? */
|
|
|
|
if (!highlighted && (search != NULL) &&
|
|
|
|
search_term_highlighted(c,
|
|
|
|
offset, offset + len,
|
|
|
|
&start_idx, &end_idx,
|
|
|
|
search)) {
|
|
|
|
highlighted = true;
|
|
|
|
}
|
2008-01-28 07:33:39 +03:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* \todo make search terms visible within selected text */
|
|
|
|
if (highlighted) {
|
|
|
|
struct rect r;
|
|
|
|
unsigned endtxt_idx = end_idx;
|
|
|
|
bool clip_changed = false;
|
|
|
|
bool text_visible = true;
|
|
|
|
int startx, endx;
|
2013-02-15 20:07:56 +04:00
|
|
|
plot_style_t pstyle_fill_hback = *plot_style_fill_white;
|
2013-01-02 22:02:15 +04:00
|
|
|
plot_font_style_t fstyle_hback = plot_fstyle;
|
|
|
|
|
|
|
|
if (end_idx > utf8_len) {
|
|
|
|
/* adjust for trailing space, not present in
|
|
|
|
* utf8_text */
|
|
|
|
assert(end_idx == utf8_len + 1);
|
|
|
|
endtxt_idx = utf8_len;
|
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
|
|
|
}
|
2008-08-25 23:30:10 +04:00
|
|
|
|
2016-04-24 01:32:21 +03:00
|
|
|
res = guit->layout->width(fstyle,
|
|
|
|
utf8_text, start_idx,
|
|
|
|
&startx);
|
|
|
|
if (res != NSERROR_OK) {
|
2013-01-02 22:02:15 +04:00
|
|
|
startx = 0;
|
2016-04-24 01:32:21 +03:00
|
|
|
}
|
2008-01-27 21:15:56 +03:00
|
|
|
|
2016-04-24 01:32:21 +03:00
|
|
|
res = guit->layout->width(fstyle,
|
|
|
|
utf8_text, endtxt_idx,
|
|
|
|
&endx);
|
|
|
|
if (res != NSERROR_OK) {
|
2013-01-02 22:02:15 +04:00
|
|
|
endx = 0;
|
2016-04-24 01:32:21 +03:00
|
|
|
}
|
2008-01-28 07:33:39 +03:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* is there a trailing space that should be highlighted
|
|
|
|
* as well? */
|
|
|
|
if (end_idx > utf8_len) {
|
|
|
|
endx += space;
|
|
|
|
}
|
2012-11-06 22:19:37 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
if (scale != 1.0) {
|
|
|
|
startx *= scale;
|
|
|
|
endx *= scale;
|
|
|
|
}
|
2012-11-06 22:19:37 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* draw any text preceding highlighted portion */
|
2017-02-11 16:54:08 +03:00
|
|
|
if ((start_idx > 0) &&
|
|
|
|
(ctx->plot->text(ctx,
|
|
|
|
&plot_fstyle,
|
|
|
|
x,
|
|
|
|
y + (int)(height * 0.75 * scale),
|
|
|
|
utf8_text,
|
|
|
|
start_idx) != NSERROR_OK))
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
2012-11-06 22:19:37 +04:00
|
|
|
|
2013-02-15 20:07:56 +04:00
|
|
|
pstyle_fill_hback.fill_colour = fstyle->foreground;
|
2012-11-06 22:19:37 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* highlighted portion */
|
2017-02-11 16:54:08 +03:00
|
|
|
r.x0 = x + startx;
|
|
|
|
r.y0 = y;
|
|
|
|
r.x1 = x + endx;
|
|
|
|
r.y1 = y + height * scale;
|
|
|
|
res = ctx->plot->rectangle(ctx, &pstyle_fill_hback, &r);
|
|
|
|
if (res != NSERROR_OK) {
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
2017-02-11 16:54:08 +03:00
|
|
|
}
|
2012-11-06 22:19:37 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
if (start_idx > 0) {
|
|
|
|
int px0 = max(x + startx, clip->x0);
|
|
|
|
int px1 = min(x + endx, clip->x1);
|
2012-11-06 22:19:37 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
if (px0 < px1) {
|
|
|
|
r.x0 = px0;
|
|
|
|
r.y0 = clip->y0;
|
|
|
|
r.x1 = px1;
|
|
|
|
r.y1 = clip->y1;
|
2017-02-11 16:54:08 +03:00
|
|
|
res = ctx->plot->clip(ctx, &r);
|
|
|
|
if (res != NSERROR_OK) {
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
2017-02-11 16:54:08 +03:00
|
|
|
}
|
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
clip_changed = true;
|
|
|
|
} else {
|
|
|
|
text_visible = false;
|
|
|
|
}
|
|
|
|
}
|
2008-12-21 18:51:23 +03:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
fstyle_hback.background =
|
2013-02-15 20:07:56 +04:00
|
|
|
pstyle_fill_hback.fill_colour;
|
|
|
|
fstyle_hback.foreground = colour_to_bw_furthest(
|
|
|
|
pstyle_fill_hback.fill_colour);
|
2007-09-17 18:53:02 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
if (text_visible &&
|
2017-02-11 16:54:08 +03:00
|
|
|
(ctx->plot->text(ctx,
|
|
|
|
&fstyle_hback,
|
|
|
|
x,
|
|
|
|
y + (int)(height * 0.75 * scale),
|
|
|
|
utf8_text,
|
|
|
|
endtxt_idx) != NSERROR_OK)) {
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
2017-02-11 16:54:08 +03:00
|
|
|
}
|
2008-08-25 23:30:10 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* draw any text succeeding highlighted portion */
|
|
|
|
if (endtxt_idx < utf8_len) {
|
|
|
|
int px0 = max(x + endx, clip->x0);
|
|
|
|
if (px0 < clip->x1) {
|
|
|
|
|
|
|
|
r.x0 = px0;
|
|
|
|
r.y0 = clip->y0;
|
|
|
|
r.x1 = clip->x1;
|
|
|
|
r.y1 = clip->y1;
|
2017-02-11 16:54:08 +03:00
|
|
|
res = ctx->plot->clip(ctx, &r);
|
|
|
|
if (res != NSERROR_OK) {
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
2017-02-11 16:54:08 +03:00
|
|
|
}
|
2013-01-02 22:02:15 +04:00
|
|
|
|
|
|
|
clip_changed = true;
|
|
|
|
|
2017-02-11 16:54:08 +03:00
|
|
|
res = ctx->plot->text(ctx,
|
|
|
|
&plot_fstyle,
|
|
|
|
x,
|
|
|
|
y + (int)(height * 0.75 * scale),
|
|
|
|
utf8_text,
|
|
|
|
utf8_len);
|
|
|
|
if (res != NSERROR_OK) {
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
2017-02-11 16:54:08 +03:00
|
|
|
}
|
2013-01-02 22:02:15 +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
|
|
|
}
|
2013-01-02 22:02:15 +04:00
|
|
|
|
|
|
|
if (clip_changed &&
|
2017-02-11 16:54:08 +03:00
|
|
|
(ctx->plot->clip(ctx, clip) != NSERROR_OK)) {
|
2009-01-17 22:39:38 +03:00
|
|
|
return false;
|
2017-02-11 16:54:08 +03:00
|
|
|
}
|
2008-01-28 07:33:39 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
if (!highlighted) {
|
2017-02-11 16:54:08 +03:00
|
|
|
res = ctx->plot->text(ctx,
|
|
|
|
&plot_fstyle,
|
|
|
|
x,
|
|
|
|
y + (int) (height * 0.75 * scale),
|
|
|
|
utf8_text,
|
|
|
|
utf8_len);
|
|
|
|
if (res != NSERROR_OK) {
|
2008-01-28 07:33:39 +03:00
|
|
|
return false;
|
2017-02-11 16:54:08 +03:00
|
|
|
}
|
2010-08-26 16:30:22 +04:00
|
|
|
}
|
2013-01-02 22:02:15 +04:00
|
|
|
return true;
|
|
|
|
}
|
2008-01-28 07:33:39 +03:00
|
|
|
|
2010-08-26 16:30:22 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/**
|
|
|
|
* Plot a checkbox.
|
|
|
|
*
|
|
|
|
* \param x left coordinate
|
|
|
|
* \param y top coordinate
|
|
|
|
* \param width dimensions of checkbox
|
|
|
|
* \param height dimensions of checkbox
|
|
|
|
* \param selected the checkbox is selected
|
|
|
|
* \param ctx current redraw context
|
|
|
|
* \return true if successful, false otherwise
|
|
|
|
*/
|
2010-08-26 14:01:26 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
static bool html_redraw_checkbox(int x, int y, int width, int height,
|
|
|
|
bool selected, const struct redraw_context *ctx)
|
|
|
|
{
|
2017-02-11 16:54:08 +03:00
|
|
|
double z;
|
|
|
|
nserror res;
|
|
|
|
struct rect rect;
|
|
|
|
|
|
|
|
z = width * 0.15;
|
|
|
|
if (z == 0) {
|
2013-01-02 22:02:15 +04:00
|
|
|
z = 1;
|
2017-02-11 16:54:08 +03:00
|
|
|
}
|
2010-08-14 14:52:25 +04:00
|
|
|
|
2017-02-11 16:54:08 +03:00
|
|
|
rect.x0 = x;
|
|
|
|
rect.y0 = y ;
|
|
|
|
rect.x1 = x + width;
|
|
|
|
rect.y1 = y + height;
|
|
|
|
res = ctx->plot->rectangle(ctx, plot_style_fill_wbasec, &rect);
|
|
|
|
if (res != NSERROR_OK) {
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
2017-02-11 16:54:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* dark line across top */
|
|
|
|
rect.y1 = y;
|
|
|
|
res = ctx->plot->line(ctx, plot_style_stroke_darkwbasec, &rect);
|
|
|
|
if (res != NSERROR_OK) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* dark line across left */
|
|
|
|
rect.x1 = x;
|
|
|
|
rect.y1 = y + height;
|
|
|
|
res = ctx->plot->line(ctx, plot_style_stroke_darkwbasec, &rect);
|
|
|
|
if (res != NSERROR_OK) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* light line across right */
|
|
|
|
rect.x0 = x + width;
|
|
|
|
rect.x1 = x + width;
|
|
|
|
res = ctx->plot->line(ctx, plot_style_stroke_lightwbasec, &rect);
|
|
|
|
if (res != NSERROR_OK) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-05-10 13:34:26 +03:00
|
|
|
/* light line across bottom */
|
2017-02-11 16:54:08 +03:00
|
|
|
rect.x0 = x;
|
|
|
|
rect.y0 = y + height;
|
|
|
|
res = ctx->plot->line(ctx, plot_style_stroke_lightwbasec, &rect);
|
|
|
|
if (res != NSERROR_OK) {
|
|
|
|
return false;
|
|
|
|
}
|
2010-08-26 16:30:22 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
if (selected) {
|
|
|
|
if (width < 12 || height < 12) {
|
|
|
|
/* render a solid box instead of a tick */
|
2017-02-11 16:54:08 +03:00
|
|
|
rect.x0 = x + z + z;
|
|
|
|
rect.y0 = y + z + z;
|
|
|
|
rect.x1 = x + width - z;
|
|
|
|
rect.y1 = y + height - z;
|
|
|
|
res = ctx->plot->rectangle(ctx, plot_style_fill_wblobc, &rect);
|
|
|
|
if (res != NSERROR_OK) {
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
2017-02-11 16:54:08 +03:00
|
|
|
}
|
2013-01-02 22:02:15 +04:00
|
|
|
} else {
|
|
|
|
/* render a tick, as it'll fit comfortably */
|
2017-02-11 16:54:08 +03:00
|
|
|
rect.x0 = x + width - z;
|
|
|
|
rect.y0 = y + z;
|
|
|
|
rect.x1 = x + (z * 3);
|
|
|
|
rect.y1 = y + height - z;
|
|
|
|
res = ctx->plot->line(ctx, plot_style_stroke_wblobc, &rect);
|
|
|
|
if (res != NSERROR_OK) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
rect.x0 = x + (z * 3);
|
|
|
|
rect.y0 = y + height - z;
|
|
|
|
rect.x1 = x + z + z;
|
|
|
|
rect.y1 = y + (height / 2);
|
|
|
|
res = ctx->plot->line(ctx, plot_style_stroke_wblobc, &rect);
|
|
|
|
if (res != NSERROR_OK) {
|
2010-08-26 16:30:22 +04:00
|
|
|
return false;
|
2017-02-11 16:54:08 +03:00
|
|
|
}
|
2010-08-14 01:07:46 +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
|
|
|
/**
|
2013-01-02 22:02:15 +04:00
|
|
|
* Plot a radio icon.
|
2008-12-21 18:51:23 +03:00
|
|
|
*
|
2013-01-02 22:02:15 +04:00
|
|
|
* \param x left coordinate
|
|
|
|
* \param y top coordinate
|
|
|
|
* \param width dimensions of radio icon
|
|
|
|
* \param height dimensions of radio icon
|
|
|
|
* \param selected the radio icon is selected
|
|
|
|
* \param ctx current redraw context
|
2008-12-21 18:51:23 +03:00
|
|
|
* \return true if successful, false otherwise
|
|
|
|
*/
|
2013-01-02 22:02:15 +04:00
|
|
|
static bool html_redraw_radio(int x, int y, int width, int height,
|
|
|
|
bool selected, const struct redraw_context *ctx)
|
2008-12-21 18:51:23 +03:00
|
|
|
{
|
2017-02-11 16:54:08 +03:00
|
|
|
nserror res;
|
2008-12-26 14:34:23 +03:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* plot background of radio button */
|
2017-02-11 16:54:08 +03:00
|
|
|
res = ctx->plot->disc(ctx,
|
|
|
|
plot_style_fill_wbasec,
|
|
|
|
x + width * 0.5,
|
|
|
|
y + height * 0.5,
|
|
|
|
width * 0.5 - 1);
|
|
|
|
if (res != NSERROR_OK) {
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
2017-02-11 16:54:08 +03:00
|
|
|
}
|
2008-12-21 18:51:23 +03:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* plot dark arc */
|
2017-02-11 16:54:08 +03:00
|
|
|
res = ctx->plot->arc(ctx,
|
|
|
|
plot_style_fill_darkwbasec,
|
|
|
|
x + width * 0.5,
|
|
|
|
y + height * 0.5,
|
|
|
|
width * 0.5 - 1,
|
|
|
|
45,
|
|
|
|
225);
|
|
|
|
if (res != NSERROR_OK) {
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
2017-02-11 16:54:08 +03:00
|
|
|
}
|
2009-01-31 03:41:03 +03:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* plot light arc */
|
2017-02-11 16:54:08 +03:00
|
|
|
res = ctx->plot->arc(ctx,
|
|
|
|
plot_style_fill_lightwbasec,
|
|
|
|
x + width * 0.5,
|
|
|
|
y + height * 0.5,
|
|
|
|
width * 0.5 - 1,
|
|
|
|
225,
|
|
|
|
45);
|
|
|
|
if (res != NSERROR_OK) {
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
2017-02-11 16:54:08 +03:00
|
|
|
}
|
2008-12-21 18:51:23 +03:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
if (selected) {
|
|
|
|
/* plot selection blob */
|
2017-02-11 16:54:08 +03:00
|
|
|
res = ctx->plot->disc(ctx,
|
|
|
|
plot_style_fill_wblobc,
|
|
|
|
x + width * 0.5,
|
|
|
|
y + height * 0.5,
|
|
|
|
width * 0.3 - 1);
|
|
|
|
if (res != NSERROR_OK) {
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
2017-02-11 16:54:08 +03:00
|
|
|
}
|
2013-01-02 22:02:15 +04:00
|
|
|
}
|
2010-08-14 01:07:46 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
return true;
|
|
|
|
}
|
2010-08-14 14:52:25 +04:00
|
|
|
|
2011-01-29 22:22:12 +03:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/**
|
|
|
|
* Plot a file upload input.
|
|
|
|
*
|
|
|
|
* \param x left coordinate
|
|
|
|
* \param y top coordinate
|
|
|
|
* \param width dimensions of input
|
|
|
|
* \param height dimensions of input
|
|
|
|
* \param box box of input
|
|
|
|
* \param scale scale for redraw
|
|
|
|
* \param background_colour current background colour
|
2018-01-04 02:58:18 +03:00
|
|
|
* \param len_ctx Length conversion context
|
2013-01-02 22:02:15 +04:00
|
|
|
* \param ctx current redraw context
|
|
|
|
* \return true if successful, false otherwise
|
|
|
|
*/
|
|
|
|
|
|
|
|
static bool html_redraw_file(int x, int y, int width, int height,
|
|
|
|
struct box *box, float scale, colour background_colour,
|
2018-01-04 02:58:18 +03:00
|
|
|
const nscss_len_ctx *len_ctx,
|
2013-01-02 22:02:15 +04:00
|
|
|
const struct redraw_context *ctx)
|
|
|
|
{
|
|
|
|
int text_width;
|
|
|
|
const char *text;
|
|
|
|
size_t length;
|
|
|
|
plot_font_style_t fstyle;
|
2016-04-24 01:32:21 +03:00
|
|
|
nserror res;
|
2009-07-24 03:05:34 +04:00
|
|
|
|
2018-01-04 02:58:18 +03:00
|
|
|
font_plot_style_from_css(len_ctx, box->style, &fstyle);
|
2013-01-02 22:02:15 +04:00
|
|
|
fstyle.background = background_colour;
|
2009-07-24 03:05:34 +04:00
|
|
|
|
2017-02-11 16:54:08 +03:00
|
|
|
if (box->gadget->value) {
|
2013-01-02 22:02:15 +04:00
|
|
|
text = box->gadget->value;
|
2017-02-11 16:54:08 +03:00
|
|
|
} else {
|
2013-01-02 22:02:15 +04:00
|
|
|
text = messages_get("Form_Drop");
|
2017-02-11 16:54:08 +03:00
|
|
|
}
|
2013-01-02 22:02:15 +04:00
|
|
|
length = strlen(text);
|
2010-08-14 01:07:46 +04:00
|
|
|
|
2016-04-24 01:32:21 +03:00
|
|
|
res = guit->layout->width(&fstyle, text, length, &text_width);
|
|
|
|
if (res != NSERROR_OK) {
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
2016-04-24 01:32:21 +03:00
|
|
|
}
|
2013-01-02 22:02:15 +04:00
|
|
|
text_width *= scale;
|
2016-04-24 01:32:21 +03:00
|
|
|
if (width < text_width + 8) {
|
2013-01-02 22:02:15 +04:00
|
|
|
x = x + width - text_width - 4;
|
2016-04-24 01:32:21 +03:00
|
|
|
} else {
|
2013-01-02 22:02:15 +04:00
|
|
|
x = x + 4;
|
2016-04-24 01:32:21 +03:00
|
|
|
}
|
2010-08-14 14:52:25 +04:00
|
|
|
|
2017-02-11 16:54:08 +03:00
|
|
|
res = ctx->plot->text(ctx, &fstyle, x, y + height * 0.75, text, length);
|
|
|
|
if (res != NSERROR_OK) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2013-01-02 22:02:15 +04:00
|
|
|
}
|
2011-01-29 22:22:12 +03:00
|
|
|
|
2009-07-24 03:05:34 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/**
|
|
|
|
* Plot background images.
|
|
|
|
*
|
2017-02-24 17:02:31 +03:00
|
|
|
* The reason for the presence of \a background is the backwards compatibility
|
|
|
|
* mess that is backgrounds on <body>. The background will be drawn relative
|
|
|
|
* to \a box, using the background information contained within \a background.
|
|
|
|
*
|
2013-01-02 22:02:15 +04:00
|
|
|
* \param x coordinate of box
|
|
|
|
* \param y coordinate of box
|
|
|
|
* \param box box to draw background image of
|
|
|
|
* \param scale scale for redraw
|
|
|
|
* \param clip current clip rectangle
|
|
|
|
* \param background_colour current background colour
|
2016-09-13 11:16:31 +03:00
|
|
|
* \param background box containing background details (usually \a box)
|
2018-01-04 02:58:18 +03:00
|
|
|
* \param len_ctx Length conversion context
|
|
|
|
* \param ctx current redraw context
|
2013-01-02 22:02:15 +04:00
|
|
|
* \return true if successful, false otherwise
|
|
|
|
*/
|
2009-07-24 03:05:34 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
static bool html_redraw_background(int x, int y, struct box *box, float scale,
|
|
|
|
const struct rect *clip, colour *background_colour,
|
2018-01-04 02:58:18 +03:00
|
|
|
struct box *background,
|
|
|
|
const nscss_len_ctx *len_ctx,
|
|
|
|
const struct redraw_context *ctx)
|
2013-01-02 22:02:15 +04:00
|
|
|
{
|
|
|
|
bool repeat_x = false;
|
|
|
|
bool repeat_y = false;
|
|
|
|
bool plot_colour = true;
|
|
|
|
bool plot_content;
|
|
|
|
bool clip_to_children = false;
|
|
|
|
struct box *clip_box = box;
|
|
|
|
int ox = x, oy = y;
|
|
|
|
int width, height;
|
|
|
|
css_fixed hpos = 0, vpos = 0;
|
|
|
|
css_unit hunit = CSS_UNIT_PX, vunit = CSS_UNIT_PX;
|
|
|
|
struct box *parent;
|
|
|
|
struct rect r = *clip;
|
|
|
|
css_color bgcol;
|
|
|
|
plot_style_t pstyle_fill_bg = {
|
|
|
|
.fill_type = PLOT_OP_TYPE_SOLID,
|
|
|
|
.fill_colour = *background_colour,
|
|
|
|
};
|
2017-02-11 16:54:08 +03:00
|
|
|
nserror res;
|
2010-08-14 01:07:46 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
if (ctx->background_images == false)
|
|
|
|
return true;
|
2010-08-14 14:52:25 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
plot_content = (background->background != NULL);
|
2011-01-29 22:22:12 +03:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
if (plot_content) {
|
|
|
|
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];
|
2010-08-14 01:07:46 +04:00
|
|
|
}
|
2013-01-02 22:02:15 +04:00
|
|
|
/* handle background-repeat */
|
|
|
|
switch (css_computed_background_repeat(background->style)) {
|
|
|
|
case CSS_BACKGROUND_REPEAT_REPEAT:
|
|
|
|
repeat_x = repeat_y = true;
|
|
|
|
/* optimisation: only plot the colour if
|
|
|
|
* bitmap is not opaque */
|
|
|
|
plot_colour = !content_get_opaque(background->background);
|
|
|
|
break;
|
2010-08-14 01:07:46 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
case CSS_BACKGROUND_REPEAT_REPEAT_X:
|
|
|
|
repeat_x = true;
|
|
|
|
break;
|
2010-08-14 01:07:46 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
case CSS_BACKGROUND_REPEAT_REPEAT_Y:
|
|
|
|
repeat_y = true;
|
|
|
|
break;
|
2010-08-14 01:07:46 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
case CSS_BACKGROUND_REPEAT_NO_REPEAT:
|
|
|
|
break;
|
2010-08-14 14:52:25 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
default:
|
|
|
|
break;
|
2010-08-14 01:07:46 +04:00
|
|
|
}
|
2011-01-29 22:22:12 +03:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* handle background-position */
|
|
|
|
css_computed_background_position(background->style,
|
|
|
|
&hpos, &hunit, &vpos, &vunit);
|
|
|
|
if (hunit == CSS_UNIT_PCT) {
|
2018-05-10 13:34:26 +03:00
|
|
|
x += (width -
|
2013-01-02 22:02:15 +04:00
|
|
|
content_get_width(background->background)) *
|
|
|
|
scale * FIXTOFLT(hpos) / 100.;
|
|
|
|
} else {
|
2018-01-04 02:58:18 +03:00
|
|
|
x += (int) (FIXTOFLT(nscss_len2px(len_ctx, hpos, hunit,
|
2013-01-02 22:02:15 +04:00
|
|
|
background->style)) * scale);
|
2010-08-14 01:07:46 +04:00
|
|
|
}
|
2009-07-24 03:05:34 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
if (vunit == CSS_UNIT_PCT) {
|
2018-05-10 13:34:26 +03:00
|
|
|
y += (height -
|
2013-01-02 22:02:15 +04:00
|
|
|
content_get_height(background->background)) *
|
|
|
|
scale * FIXTOFLT(vpos) / 100.;
|
|
|
|
} else {
|
2018-01-04 02:58:18 +03:00
|
|
|
y += (int) (FIXTOFLT(nscss_len2px(len_ctx, vpos, vunit,
|
2013-01-02 22:02:15 +04:00
|
|
|
background->style)) * scale);
|
|
|
|
}
|
2009-07-24 03:05:34 +04:00
|
|
|
}
|
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* special case for table rows as their background needs
|
|
|
|
* to be clipped to all the cells */
|
|
|
|
if (box->type == BOX_TABLE_ROW) {
|
|
|
|
css_fixed h = 0, v = 0;
|
|
|
|
css_unit hu = CSS_UNIT_PX, vu = CSS_UNIT_PX;
|
2008-12-21 18:51:23 +03:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
for (parent = box->parent;
|
|
|
|
((parent) && (parent->type != BOX_TABLE));
|
|
|
|
parent = parent->parent);
|
|
|
|
assert(parent && (parent->style));
|
2008-12-21 18:51:23 +03:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
css_computed_border_spacing(parent->style, &h, &hu, &v, &vu);
|
2005-05-24 02:14:09 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
clip_to_children = (h > 0) || (v > 0);
|
2005-05-24 02:14:09 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
if (clip_to_children)
|
|
|
|
clip_box = box->children;
|
|
|
|
}
|
2006-06-30 01:30:05 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
for (; clip_box; clip_box = clip_box->next) {
|
|
|
|
/* clip to child boxes if needed */
|
|
|
|
if (clip_to_children) {
|
|
|
|
assert(clip_box->type == BOX_TABLE_CELL);
|
2009-07-14 14:03:58 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* update clip.* to the child cell */
|
|
|
|
r.x0 = ox + (clip_box->x * scale);
|
|
|
|
r.y0 = oy + (clip_box->y * scale);
|
|
|
|
r.x1 = r.x0 + (clip_box->padding[LEFT] +
|
|
|
|
clip_box->width +
|
|
|
|
clip_box->padding[RIGHT]) * scale;
|
|
|
|
r.y1 = r.y0 + (clip_box->padding[TOP] +
|
|
|
|
clip_box->height +
|
|
|
|
clip_box->padding[BOTTOM]) * scale;
|
2005-05-24 02:14:09 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
if (r.x0 < clip->x0) r.x0 = clip->x0;
|
|
|
|
if (r.y0 < clip->y0) r.y0 = clip->y0;
|
|
|
|
if (r.x1 > clip->x1) r.x1 = clip->x1;
|
|
|
|
if (r.y1 > clip->y1) r.y1 = clip->y1;
|
2005-05-24 02:14:09 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
css_computed_background_color(clip_box->style, &bgcol);
|
2005-05-24 02:14:09 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* <td> attributes override <tr> */
|
|
|
|
/* if the background content is opaque there
|
|
|
|
* is no need to plot underneath it.
|
|
|
|
*/
|
2018-05-10 13:34:26 +03:00
|
|
|
if ((r.x0 >= r.x1) ||
|
2013-01-02 22:02:15 +04:00
|
|
|
(r.y0 >= r.y1) ||
|
|
|
|
(nscss_color_is_transparent(bgcol) == false) ||
|
2018-05-10 13:34:26 +03:00
|
|
|
((clip_box->background != NULL) &&
|
2013-01-02 22:02:15 +04:00
|
|
|
content_get_opaque(clip_box->background)))
|
|
|
|
continue;
|
2009-07-14 14:03:58 +04:00
|
|
|
}
|
2010-08-26 14:01:26 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* plot the background colour */
|
|
|
|
css_computed_background_color(background->style, &bgcol);
|
2010-08-26 14:01:26 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
if (nscss_color_is_transparent(bgcol) == false) {
|
|
|
|
*background_colour = nscss_color_to_ns(bgcol);
|
|
|
|
pstyle_fill_bg.fill_colour = *background_colour;
|
2017-02-11 16:54:08 +03:00
|
|
|
if (plot_colour) {
|
|
|
|
res = ctx->plot->rectangle(ctx, &pstyle_fill_bg, &r);
|
|
|
|
if (res != NSERROR_OK) {
|
2010-08-26 16:30:22 +04:00
|
|
|
return false;
|
2017-02-11 16:54:08 +03:00
|
|
|
}
|
|
|
|
}
|
2013-01-02 22:02:15 +04:00
|
|
|
}
|
|
|
|
/* and plot the image */
|
|
|
|
if (plot_content) {
|
|
|
|
width = content_get_width(background->background);
|
|
|
|
height = content_get_height(background->background);
|
2010-08-26 14:01:26 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* ensure clip area only as large as required */
|
|
|
|
if (!repeat_x) {
|
|
|
|
if (r.x0 < x)
|
|
|
|
r.x0 = x;
|
|
|
|
if (r.x1 > x + width * scale)
|
|
|
|
r.x1 = x + width * scale;
|
2010-08-26 16:30:22 +04:00
|
|
|
}
|
2013-01-02 22:02:15 +04:00
|
|
|
if (!repeat_y) {
|
|
|
|
if (r.y0 < y)
|
|
|
|
r.y0 = y;
|
|
|
|
if (r.y1 > y + height * scale)
|
|
|
|
r.y1 = y + height * scale;
|
|
|
|
}
|
|
|
|
/* valid clipping rectangles only */
|
|
|
|
if ((r.x0 < r.x1) && (r.y0 < r.y1)) {
|
|
|
|
struct content_redraw_data bg_data;
|
|
|
|
|
2017-02-11 16:54:08 +03:00
|
|
|
res = ctx->plot->clip(ctx, &r);
|
|
|
|
if (res != NSERROR_OK) {
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
2017-02-11 16:54:08 +03:00
|
|
|
}
|
2013-01-02 22:02:15 +04:00
|
|
|
|
|
|
|
bg_data.x = x;
|
|
|
|
bg_data.y = y;
|
|
|
|
bg_data.width = ceilf(width * scale);
|
|
|
|
bg_data.height = ceilf(height * scale);
|
|
|
|
bg_data.background_colour = *background_colour;
|
|
|
|
bg_data.scale = scale;
|
|
|
|
bg_data.repeat_x = repeat_x;
|
|
|
|
bg_data.repeat_y = repeat_y;
|
|
|
|
|
2013-04-23 21:34:46 +04:00
|
|
|
/* We just continue if redraw fails */
|
|
|
|
content_redraw(background->background,
|
|
|
|
&bg_data, &r, ctx);
|
2010-08-26 14:01:26 +04:00
|
|
|
}
|
|
|
|
}
|
2005-05-24 02:14:09 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* only <tr> rows being clipped to child boxes loop */
|
|
|
|
if (!clip_to_children)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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 coordinates of clip rectangle
|
|
|
|
* \param b coordinates 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
|
2018-01-04 02:58:18 +03:00
|
|
|
* \param len_ctx Length conversion context
|
|
|
|
* \param ctx current redraw context
|
2013-01-02 22:02:15 +04:00
|
|
|
* \return true if successful, false otherwise
|
|
|
|
*/
|
|
|
|
|
|
|
|
static bool html_redraw_inline_background(int x, int y, struct box *box,
|
|
|
|
float scale, const struct rect *clip, struct rect b,
|
|
|
|
bool first, bool last, colour *background_colour,
|
2018-01-04 02:58:18 +03:00
|
|
|
const nscss_len_ctx *len_ctx,
|
2013-01-02 22:02:15 +04:00
|
|
|
const struct redraw_context *ctx)
|
|
|
|
{
|
|
|
|
struct rect r = *clip;
|
|
|
|
bool repeat_x = false;
|
|
|
|
bool repeat_y = false;
|
|
|
|
bool plot_colour = true;
|
|
|
|
bool plot_content;
|
|
|
|
css_fixed hpos = 0, vpos = 0;
|
|
|
|
css_unit hunit = CSS_UNIT_PX, vunit = CSS_UNIT_PX;
|
|
|
|
css_color bgcol;
|
|
|
|
plot_style_t pstyle_fill_bg = {
|
|
|
|
.fill_type = PLOT_OP_TYPE_SOLID,
|
|
|
|
.fill_colour = *background_colour,
|
|
|
|
};
|
2017-02-11 16:54:08 +03:00
|
|
|
nserror res;
|
2013-01-02 22:02:15 +04:00
|
|
|
|
|
|
|
plot_content = (box->background != NULL);
|
|
|
|
|
|
|
|
if (html_redraw_printing && nsoption_bool(remove_backgrounds))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (plot_content) {
|
|
|
|
/* handle background-repeat */
|
|
|
|
switch (css_computed_background_repeat(box->style)) {
|
|
|
|
case CSS_BACKGROUND_REPEAT_REPEAT:
|
|
|
|
repeat_x = repeat_y = true;
|
|
|
|
/* optimisation: only plot the colour if
|
2018-05-10 13:34:26 +03:00
|
|
|
* bitmap is not opaque
|
2013-01-02 22:02:15 +04:00
|
|
|
*/
|
|
|
|
plot_colour = !content_get_opaque(box->background);
|
2004-10-18 01:05:12 +04:00
|
|
|
break;
|
2013-01-02 22:02:15 +04:00
|
|
|
|
|
|
|
case CSS_BACKGROUND_REPEAT_REPEAT_X:
|
|
|
|
repeat_x = true;
|
2009-07-11 00:38:57 +04:00
|
|
|
break;
|
2013-01-02 22:02:15 +04:00
|
|
|
|
|
|
|
case CSS_BACKGROUND_REPEAT_REPEAT_Y:
|
|
|
|
repeat_y = true;
|
2009-07-14 14:03:58 +04:00
|
|
|
break;
|
2013-01-02 22:02:15 +04:00
|
|
|
|
|
|
|
case CSS_BACKGROUND_REPEAT_NO_REPEAT:
|
2009-07-14 14:03:58 +04:00
|
|
|
break;
|
2013-01-02 22:02:15 +04:00
|
|
|
|
2009-07-14 14:03:58 +04:00
|
|
|
default:
|
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
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* handle background-position */
|
|
|
|
css_computed_background_position(box->style,
|
|
|
|
&hpos, &hunit, &vpos, &vunit);
|
|
|
|
if (hunit == CSS_UNIT_PCT) {
|
|
|
|
x += (b.x1 - b.x0 -
|
2018-05-10 13:34:26 +03:00
|
|
|
content_get_width(box->background) *
|
2013-01-02 22:02:15 +04:00
|
|
|
scale) * FIXTOFLT(hpos) / 100.;
|
2004-10-18 01:05:12 +04:00
|
|
|
|
2018-05-10 13:34:26 +03:00
|
|
|
if (!repeat_x && ((hpos < 2 && !first) ||
|
2013-01-02 22:02:15 +04:00
|
|
|
(hpos > 98 && !last))){
|
|
|
|
plot_content = false;
|
2010-08-26 16:30:22 +04:00
|
|
|
}
|
2013-01-02 22:02:15 +04:00
|
|
|
} else {
|
2018-01-04 02:58:18 +03:00
|
|
|
x += (int) (FIXTOFLT(nscss_len2px(len_ctx, hpos, hunit,
|
2013-01-02 22:02:15 +04:00
|
|
|
box->style)) * scale);
|
|
|
|
}
|
2010-08-14 02:29:49 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
if (vunit == CSS_UNIT_PCT) {
|
|
|
|
y += (b.y1 - b.y0 -
|
|
|
|
content_get_height(box->background) *
|
|
|
|
scale) * FIXTOFLT(vpos) / 100.;
|
2010-08-14 17:03:57 +04:00
|
|
|
} else {
|
2018-01-04 02:58:18 +03:00
|
|
|
y += (int) (FIXTOFLT(nscss_len2px(len_ctx, vpos, vunit,
|
2013-01-02 22:02:15 +04:00
|
|
|
box->style)) * scale);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* plot the background colour */
|
|
|
|
css_computed_background_color(box->style, &bgcol);
|
|
|
|
|
|
|
|
if (nscss_color_is_transparent(bgcol) == false) {
|
|
|
|
*background_colour = nscss_color_to_ns(bgcol);
|
|
|
|
pstyle_fill_bg.fill_colour = *background_colour;
|
|
|
|
|
2017-02-11 16:54:08 +03:00
|
|
|
if (plot_colour) {
|
|
|
|
res = ctx->plot->rectangle(ctx, &pstyle_fill_bg, &r);
|
|
|
|
if (res != NSERROR_OK) {
|
2010-08-26 14:01:26 +04:00
|
|
|
return false;
|
2017-02-11 16:54:08 +03:00
|
|
|
}
|
|
|
|
}
|
2013-01-02 22:02:15 +04:00
|
|
|
}
|
|
|
|
/* and plot the image */
|
|
|
|
if (plot_content) {
|
|
|
|
int width = content_get_width(box->background);
|
|
|
|
int height = content_get_height(box->background);
|
|
|
|
|
|
|
|
if (!repeat_x) {
|
|
|
|
if (r.x0 < x)
|
|
|
|
r.x0 = x;
|
|
|
|
if (r.x1 > x + width * scale)
|
|
|
|
r.x1 = x + width * scale;
|
|
|
|
}
|
|
|
|
if (!repeat_y) {
|
|
|
|
if (r.y0 < y)
|
|
|
|
r.y0 = y;
|
|
|
|
if (r.y1 > y + height * scale)
|
|
|
|
r.y1 = y + height * scale;
|
|
|
|
}
|
|
|
|
/* valid clipping rectangles only */
|
|
|
|
if ((r.x0 < r.x1) && (r.y0 < r.y1)) {
|
|
|
|
struct content_redraw_data bg_data;
|
|
|
|
|
2017-02-11 16:54:08 +03:00
|
|
|
res = ctx->plot->clip(ctx, &r);
|
|
|
|
if (res != NSERROR_OK) {
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
2017-02-11 16:54:08 +03:00
|
|
|
}
|
2013-01-02 22:02:15 +04:00
|
|
|
|
|
|
|
bg_data.x = x;
|
|
|
|
bg_data.y = y;
|
|
|
|
bg_data.width = ceilf(width * scale);
|
|
|
|
bg_data.height = ceilf(height * scale);
|
|
|
|
bg_data.background_colour = *background_colour;
|
|
|
|
bg_data.scale = scale;
|
|
|
|
bg_data.repeat_x = repeat_x;
|
|
|
|
bg_data.repeat_y = repeat_y;
|
|
|
|
|
2013-04-23 21:34:46 +04:00
|
|
|
/* We just continue if redraw fails */
|
|
|
|
content_redraw(box->background, &bg_data, &r, ctx);
|
2010-08-14 17:03:57 +04:00
|
|
|
}
|
2010-08-14 02:29:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-18 01:05:12 +04:00
|
|
|
/**
|
2013-01-02 22:02:15 +04:00
|
|
|
* Plot text decoration for an inline box.
|
2004-10-18 01:05:12 +04:00
|
|
|
*
|
2013-01-02 22:02:15 +04:00
|
|
|
* \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
|
|
|
|
* \param ctx current redraw context
|
2004-10-18 01:05:12 +04:00
|
|
|
* \return true if successful, false otherwise
|
|
|
|
*/
|
|
|
|
|
2017-02-11 16:54:08 +03:00
|
|
|
static bool
|
|
|
|
html_redraw_text_decoration_inline(struct box *box,
|
|
|
|
int x, int y,
|
|
|
|
float scale,
|
|
|
|
colour colour,
|
|
|
|
float ratio,
|
|
|
|
const struct redraw_context *ctx)
|
2004-10-18 01:05:12 +04:00
|
|
|
{
|
2013-01-02 22:02:15 +04:00
|
|
|
struct box *c;
|
|
|
|
plot_style_t plot_style_box = {
|
|
|
|
.stroke_type = PLOT_OP_TYPE_SOLID,
|
|
|
|
.stroke_colour = colour,
|
|
|
|
};
|
2017-02-11 16:54:08 +03:00
|
|
|
nserror res;
|
|
|
|
struct rect rect;
|
2006-03-21 20:22:41 +03:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
for (c = box->next;
|
2017-02-11 16:54:08 +03:00
|
|
|
c && c != box->inline_end;
|
|
|
|
c = c->next) {
|
|
|
|
if (c->type != BOX_TEXT) {
|
2013-01-02 22:02:15 +04:00
|
|
|
continue;
|
2017-02-11 16:54:08 +03:00
|
|
|
}
|
|
|
|
rect.x0 = (x + c->x) * scale;
|
|
|
|
rect.y0 = (y + c->y + c->height * ratio) * scale;
|
|
|
|
rect.x1 = (x + c->x + c->width) * scale;
|
|
|
|
rect.y1 = (y + c->y + c->height * ratio) * scale;
|
|
|
|
res = ctx->plot->line(ctx, &plot_style_box, &rect);
|
|
|
|
if (res != NSERROR_OK) {
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
2017-02-11 16:54:08 +03:00
|
|
|
}
|
2013-01-02 22:02:15 +04:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2006-03-21 20:22:41 +03:00
|
|
|
|
2009-07-10 22:36:49 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
* \param ctx current redraw context
|
|
|
|
* \return true if successful, false otherwise
|
|
|
|
*/
|
|
|
|
|
2017-02-11 16:54:08 +03:00
|
|
|
static bool
|
|
|
|
html_redraw_text_decoration_block(struct box *box,
|
|
|
|
int x, int y,
|
|
|
|
float scale,
|
|
|
|
colour colour,
|
|
|
|
float ratio,
|
|
|
|
const struct redraw_context *ctx)
|
2013-01-02 22:02:15 +04:00
|
|
|
{
|
|
|
|
struct box *c;
|
|
|
|
plot_style_t plot_style_box = {
|
|
|
|
.stroke_type = PLOT_OP_TYPE_SOLID,
|
|
|
|
.stroke_colour = colour,
|
|
|
|
};
|
2017-02-11 16:54:08 +03:00
|
|
|
nserror res;
|
|
|
|
struct rect rect;
|
2013-01-02 22:02:15 +04:00
|
|
|
|
|
|
|
/* draw through text descendants */
|
|
|
|
for (c = box->children; c; c = c->next) {
|
|
|
|
if (c->type == BOX_TEXT) {
|
2017-02-11 16:54:08 +03:00
|
|
|
rect.x0 = (x + c->x) * scale;
|
|
|
|
rect.y0 = (y + c->y + c->height * ratio) * scale;
|
|
|
|
rect.x1 = (x + c->x + c->width) * scale;
|
|
|
|
rect.y1 = (y + c->y + c->height * ratio) * scale;
|
|
|
|
res = ctx->plot->line(ctx, &plot_style_box, &rect);
|
|
|
|
if (res != NSERROR_OK) {
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
2017-02-11 16:54:08 +03:00
|
|
|
}
|
|
|
|
} else if ((c->type == BOX_INLINE_CONTAINER) || (c->type == BOX_BLOCK)) {
|
2013-01-02 22:02:15 +04:00
|
|
|
if (!html_redraw_text_decoration_block(c,
|
|
|
|
x + c->x, y + c->y,
|
|
|
|
scale, colour, ratio, ctx))
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2013-01-02 22:02:15 +04:00
|
|
|
* Plot text decoration for a box.
|
2004-10-18 01:05:12 +04:00
|
|
|
*
|
2013-01-02 22:02:15 +04:00
|
|
|
* \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
|
2011-06-30 19:48:07 +04:00
|
|
|
* \param ctx current redraw context
|
2004-10-18 01:05:12 +04:00
|
|
|
* \return true if successful, false otherwise
|
|
|
|
*/
|
2011-06-30 19:48:07 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
static bool html_redraw_text_decoration(struct box *box,
|
|
|
|
int x_parent, int y_parent, float scale,
|
|
|
|
colour background_colour, const struct redraw_context *ctx)
|
|
|
|
{
|
|
|
|
static const enum css_text_decoration_e decoration[] = {
|
|
|
|
CSS_TEXT_DECORATION_UNDERLINE, CSS_TEXT_DECORATION_OVERLINE,
|
|
|
|
CSS_TEXT_DECORATION_LINE_THROUGH };
|
|
|
|
static const float line_ratio[] = { 0.9, 0.1, 0.5 };
|
|
|
|
colour fgcol;
|
|
|
|
unsigned int i;
|
|
|
|
css_color col;
|
2006-03-21 20:22:41 +03:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
css_computed_color(box->style, &col);
|
|
|
|
fgcol = nscss_color_to_ns(col);
|
2006-06-30 01:30:05 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* antialias colour for under/overline */
|
|
|
|
if (html_redraw_printing == false)
|
|
|
|
fgcol = blend_colour(background_colour, fgcol);
|
2006-03-21 20:22:41 +03:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
if (box->type == BOX_INLINE) {
|
|
|
|
if (!box->inline_end)
|
|
|
|
return true;
|
|
|
|
for (i = 0; i != NOF_ELEMENTS(decoration); i++)
|
2018-05-10 13:34:26 +03:00
|
|
|
if (css_computed_text_decoration(box->style) &
|
2013-01-02 22:02:15 +04:00
|
|
|
decoration[i])
|
|
|
|
if (!html_redraw_text_decoration_inline(box,
|
|
|
|
x_parent, y_parent, scale,
|
|
|
|
fgcol, line_ratio[i], ctx))
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
for (i = 0; i != NOF_ELEMENTS(decoration); i++)
|
2018-05-10 13:34:26 +03:00
|
|
|
if (css_computed_text_decoration(box->style) &
|
2013-01-02 22:02:15 +04:00
|
|
|
decoration[i])
|
|
|
|
if (!html_redraw_text_decoration_block(box,
|
|
|
|
x_parent + box->x,
|
|
|
|
y_parent + box->y,
|
|
|
|
scale,
|
|
|
|
fgcol, line_ratio[i], ctx))
|
|
|
|
return false;
|
2006-03-21 20:22:41 +03:00
|
|
|
}
|
2004-10-18 01:05:12 +04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2013-01-02 22:02:15 +04:00
|
|
|
* Redraw the text content of a box, possibly partially highlighted
|
|
|
|
* because the text has been selected, or matches a search operation.
|
2004-10-18 01:05:12 +04:00
|
|
|
*
|
2014-11-12 22:31:39 +03:00
|
|
|
* \param html The html content to redraw text within.
|
2013-01-02 22:02:15 +04:00
|
|
|
* \param box box with text content
|
|
|
|
* \param x x co-ord of box
|
|
|
|
* \param y y co-ord of box
|
|
|
|
* \param clip current clip rectangle
|
|
|
|
* \param scale current scale setting (1.0 = 100%)
|
|
|
|
* \param current_background_color
|
|
|
|
* \param ctx current redraw context
|
|
|
|
* \return true iff successful and redraw should proceed
|
|
|
|
*/
|
|
|
|
|
|
|
|
static bool html_redraw_text_box(const html_content *html, struct box *box,
|
|
|
|
int x, int y, const struct rect *clip, float scale,
|
|
|
|
colour current_background_color,
|
|
|
|
const struct redraw_context *ctx)
|
|
|
|
{
|
|
|
|
bool excluded = (box->object != NULL);
|
|
|
|
plot_font_style_t fstyle;
|
|
|
|
|
2018-01-04 02:58:18 +03:00
|
|
|
font_plot_style_from_css(&html->len_ctx, box->style, &fstyle);
|
2013-01-02 22:02:15 +04:00
|
|
|
fstyle.background = current_background_color;
|
|
|
|
|
|
|
|
if (!text_redraw(box->text, box->length, box->byte_offset,
|
|
|
|
box->space, &fstyle, x, y,
|
|
|
|
clip, box->height, scale, excluded,
|
|
|
|
(struct content *)html, &html->sel,
|
|
|
|
html->search, ctx))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool html_redraw_box(const html_content *html, struct box *box,
|
|
|
|
int x_parent, int y_parent,
|
|
|
|
const struct rect *clip, float scale,
|
|
|
|
colour current_background_color,
|
|
|
|
const struct redraw_context *ctx);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Draw the various children of a box.
|
|
|
|
*
|
|
|
|
* \param html html content
|
|
|
|
* \param box box to draw children of
|
|
|
|
* \param x_parent coordinate of parent box
|
|
|
|
* \param y_parent coordinate of parent box
|
|
|
|
* \param clip clip rectangle
|
2004-10-18 01:05:12 +04:00
|
|
|
* \param scale scale for redraw
|
2013-01-02 22:02:15 +04:00
|
|
|
* \param current_background_color background colour under this box
|
2011-06-30 19:48:07 +04:00
|
|
|
* \param ctx current redraw context
|
2004-10-18 01:05:12 +04:00
|
|
|
* \return true if successful, false otherwise
|
|
|
|
*/
|
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
static bool html_redraw_box_children(const html_content *html, struct box *box,
|
|
|
|
int x_parent, int y_parent,
|
|
|
|
const struct rect *clip, float scale,
|
|
|
|
colour current_background_color,
|
2011-06-30 19:48:07 +04:00
|
|
|
const struct redraw_context *ctx)
|
2004-10-18 01:05:12 +04:00
|
|
|
{
|
2013-01-02 22:02:15 +04:00
|
|
|
struct box *c;
|
2004-10-18 01:05:12 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
for (c = box->children; c; c = c->next) {
|
2004-10-18 01:05:12 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
if (c->type != BOX_FLOAT_LEFT && c->type != BOX_FLOAT_RIGHT)
|
|
|
|
if (!html_redraw_box(html, c,
|
|
|
|
x_parent + box->x -
|
|
|
|
scrollbar_get_offset(box->scroll_x),
|
|
|
|
y_parent + box->y -
|
|
|
|
scrollbar_get_offset(box->scroll_y),
|
|
|
|
clip, scale, current_background_color,
|
|
|
|
ctx))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
for (c = box->float_children; c; c = c->next_float)
|
|
|
|
if (!html_redraw_box(html, c,
|
|
|
|
x_parent + box->x -
|
|
|
|
scrollbar_get_offset(box->scroll_x),
|
|
|
|
y_parent + box->y -
|
|
|
|
scrollbar_get_offset(box->scroll_y),
|
|
|
|
clip, scale, current_background_color,
|
|
|
|
ctx))
|
|
|
|
return false;
|
2004-10-18 01:05:12 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
return true;
|
2004-10-18 01:05:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-01-02 22:02:15 +04:00
|
|
|
* Recursively draw a box.
|
2004-10-18 01:05:12 +04:00
|
|
|
*
|
2013-01-02 22:02:15 +04:00
|
|
|
* \param html html content
|
|
|
|
* \param box box to draw
|
|
|
|
* \param x_parent coordinate of parent box
|
|
|
|
* \param y_parent coordinate of parent box
|
|
|
|
* \param clip clip rectangle
|
|
|
|
* \param scale scale for redraw
|
|
|
|
* \param current_background_color background colour under this box
|
|
|
|
* \param ctx current redraw context
|
2004-10-18 01:05:12 +04:00
|
|
|
* \return true if successful, false otherwise
|
2007-09-17 18:53:02 +04:00
|
|
|
*
|
2013-01-02 22:02:15 +04:00
|
|
|
* x, y, clip_[xy][01] are in target coordinates.
|
2004-10-18 01:05:12 +04:00
|
|
|
*/
|
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
bool html_redraw_box(const html_content *html, struct box *box,
|
|
|
|
int x_parent, int y_parent,
|
2013-01-02 22:44:08 +04:00
|
|
|
const struct rect *clip, const float scale,
|
2013-01-02 22:02:15 +04:00
|
|
|
colour current_background_color,
|
|
|
|
const struct redraw_context *ctx)
|
2004-10-18 01:05:12 +04:00
|
|
|
{
|
2011-06-30 19:48:07 +04:00
|
|
|
const struct plotter_table *plot = ctx->plot;
|
2013-01-02 22:02:15 +04:00
|
|
|
int x, y;
|
2008-12-27 03:08:25 +03:00
|
|
|
int width, height;
|
2013-01-02 22:02:15 +04:00
|
|
|
int padding_left, padding_top, padding_width, padding_height;
|
|
|
|
int border_left, border_top, border_right, border_bottom;
|
|
|
|
struct rect r;
|
2017-02-11 16:54:08 +03:00
|
|
|
struct rect rect;
|
2013-01-02 22:02:15 +04:00
|
|
|
int x_scrolled, y_scrolled;
|
|
|
|
struct box *bg_box = NULL;
|
|
|
|
bool has_x_scroll, has_y_scroll;
|
|
|
|
css_computed_clip_rect css_rect;
|
2014-06-01 21:36:22 +04:00
|
|
|
enum css_overflow_e overflow_x = CSS_OVERFLOW_VISIBLE;
|
|
|
|
enum css_overflow_e overflow_y = CSS_OVERFLOW_VISIBLE;
|
2005-04-29 05:34:19 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
if (html_redraw_printing && (box->flags & PRINTED))
|
2009-01-17 22:39:38 +03:00
|
|
|
return true;
|
|
|
|
|
2014-06-01 21:36:22 +04:00
|
|
|
if (box->style != NULL) {
|
|
|
|
overflow_x = css_computed_overflow_x(box->style);
|
|
|
|
overflow_y = css_computed_overflow_y(box->style);
|
|
|
|
}
|
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* avoid trivial FP maths */
|
|
|
|
if (scale == 1.0) {
|
|
|
|
x = x_parent + box->x;
|
|
|
|
y = y_parent + box->y;
|
|
|
|
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];
|
|
|
|
padding_height = padding_top + box->height +
|
|
|
|
box->padding[BOTTOM];
|
|
|
|
border_left = box->border[LEFT].width;
|
|
|
|
border_top = box->border[TOP].width;
|
|
|
|
border_right = box->border[RIGHT].width;
|
|
|
|
border_bottom = box->border[BOTTOM].width;
|
|
|
|
} else {
|
|
|
|
x = (x_parent + box->x) * scale;
|
|
|
|
y = (y_parent + box->y) * scale;
|
|
|
|
width = box->width * scale;
|
|
|
|
height = box->height * scale;
|
|
|
|
/* 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;
|
|
|
|
padding_width = (box->padding[LEFT] + box->width +
|
|
|
|
box->padding[RIGHT]) * scale;
|
|
|
|
padding_height = (box->padding[TOP] + box->height +
|
|
|
|
box->padding[BOTTOM]) * scale;
|
|
|
|
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;
|
|
|
|
}
|
2007-09-17 18:53:02 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* calculate rectangle covering this box and descendants */
|
2014-07-18 23:09:20 +04:00
|
|
|
if (box->style && overflow_x != CSS_OVERFLOW_VISIBLE &&
|
|
|
|
box->parent != NULL) {
|
2013-01-02 22:02:15 +04:00
|
|
|
/* box contents clipped to box size */
|
|
|
|
r.x0 = x - border_left;
|
|
|
|
r.x1 = x + padding_width + border_right;
|
|
|
|
} else {
|
|
|
|
/* box contents can hang out of the box; use descendant box */
|
|
|
|
if (scale == 1.0) {
|
|
|
|
r.x0 = x + box->descendant_x0;
|
|
|
|
r.x1 = x + box->descendant_x1 + 1;
|
2008-12-27 03:08:25 +03:00
|
|
|
} else {
|
2013-01-02 22:02:15 +04:00
|
|
|
r.x0 = x + box->descendant_x0 * scale;
|
|
|
|
r.x1 = x + box->descendant_x1 * scale + 1;
|
2008-12-27 03:08:25 +03:00
|
|
|
}
|
2013-01-02 22:02:15 +04:00
|
|
|
if (!box->parent) {
|
|
|
|
/* root element */
|
|
|
|
int margin_left, margin_right;
|
|
|
|
if (scale == 1.0) {
|
|
|
|
margin_left = box->margin[LEFT];
|
|
|
|
margin_right = box->margin[RIGHT];
|
|
|
|
} else {
|
|
|
|
margin_left = box->margin[LEFT] * scale;
|
|
|
|
margin_right = box->margin[RIGHT] * scale;
|
|
|
|
}
|
|
|
|
r.x0 = x - border_left - margin_left < r.x0 ?
|
|
|
|
x - border_left - margin_left : r.x0;
|
|
|
|
r.x1 = x + padding_width + border_right +
|
|
|
|
margin_right > r.x1 ?
|
|
|
|
x + padding_width + border_right +
|
|
|
|
margin_right : r.x1;
|
2014-06-01 21:36:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* calculate rectangle covering this box and descendants */
|
2014-07-18 23:09:20 +04:00
|
|
|
if (box->style && overflow_y != CSS_OVERFLOW_VISIBLE &&
|
|
|
|
box->parent != NULL) {
|
2014-06-01 21:36:22 +04:00
|
|
|
/* box contents clipped to box size */
|
|
|
|
r.y0 = y - border_top;
|
|
|
|
r.y1 = y + padding_height + border_bottom;
|
|
|
|
} else {
|
|
|
|
/* box contents can hang out of the box; use descendant box */
|
|
|
|
if (scale == 1.0) {
|
|
|
|
r.y0 = y + box->descendant_y0;
|
|
|
|
r.y1 = y + box->descendant_y1 + 1;
|
|
|
|
} else {
|
|
|
|
r.y0 = y + box->descendant_y0 * scale;
|
|
|
|
r.y1 = y + box->descendant_y1 * scale + 1;
|
|
|
|
}
|
|
|
|
if (!box->parent) {
|
|
|
|
/* root element */
|
|
|
|
int margin_top, margin_bottom;
|
|
|
|
if (scale == 1.0) {
|
|
|
|
margin_top = box->margin[TOP];
|
|
|
|
margin_bottom = box->margin[BOTTOM];
|
|
|
|
} else {
|
|
|
|
margin_top = box->margin[TOP] * scale;
|
|
|
|
margin_bottom = box->margin[BOTTOM] * scale;
|
|
|
|
}
|
|
|
|
r.y0 = y - border_top - margin_top < r.y0 ?
|
|
|
|
y - border_top - margin_top : r.y0;
|
2013-01-02 22:02:15 +04:00
|
|
|
r.y1 = y + padding_height + border_bottom +
|
|
|
|
margin_bottom > r.y1 ?
|
|
|
|
y + padding_height + border_bottom +
|
|
|
|
margin_bottom : r.y1;
|
2005-04-29 05:34:19 +04:00
|
|
|
}
|
2013-01-02 22:02:15 +04:00
|
|
|
}
|
2004-10-18 01:05:12 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* return if the rectangle is completely outside the clip rectangle */
|
|
|
|
if (clip->y1 < r.y0 || r.y1 < clip->y0 ||
|
|
|
|
clip->x1 < r.x0 || r.x1 < clip->x0)
|
|
|
|
return true;
|
2004-10-18 01:05:12 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/*if the rectangle is under the page bottom but it can fit in a page,
|
|
|
|
don't print it now*/
|
|
|
|
if (html_redraw_printing) {
|
|
|
|
if (r.y1 > html_redraw_printing_border) {
|
|
|
|
if (r.y1 - r.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 (r.y0 < html_redraw_printing_top_cropped)
|
|
|
|
html_redraw_printing_top_cropped = r.y0;
|
|
|
|
return true;
|
|
|
|
}
|
2005-04-29 05:34:19 +04:00
|
|
|
}
|
2013-01-02 22:02:15 +04:00
|
|
|
else box->flags |= PRINTED; /*it won't be printed anymore*/
|
2004-10-18 01:05:12 +04:00
|
|
|
}
|
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* if visibility is hidden render children only */
|
2018-05-10 13:34:26 +03:00
|
|
|
if (box->style && css_computed_visibility(box->style) ==
|
2013-01-02 22:02:15 +04:00
|
|
|
CSS_VISIBILITY_HIDDEN) {
|
2017-02-11 16:54:08 +03:00
|
|
|
if ((ctx->plot->group_start) &&
|
|
|
|
(ctx->plot->group_start(ctx, "hidden box") != NSERROR_OK))
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
|
|
|
if (!html_redraw_box_children(html, box, x_parent, y_parent,
|
|
|
|
&r, scale, current_background_color, ctx))
|
|
|
|
return false;
|
2017-02-11 16:54:08 +03:00
|
|
|
return ((!ctx->plot->group_end) || (ctx->plot->group_end(ctx) == NSERROR_OK));
|
2004-10-18 01:05:12 +04:00
|
|
|
}
|
|
|
|
|
2017-02-11 16:54:08 +03:00
|
|
|
if ((ctx->plot->group_start) &&
|
|
|
|
(ctx->plot->group_start(ctx,"vis box") != NSERROR_OK)) {
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
2017-02-11 16:54:08 +03:00
|
|
|
}
|
2007-09-17 18:53:02 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
if (box->style != NULL &&
|
|
|
|
css_computed_position(box->style) ==
|
|
|
|
CSS_POSITION_ABSOLUTE &&
|
|
|
|
css_computed_clip(box->style, &css_rect) ==
|
|
|
|
CSS_CLIP_RECT) {
|
|
|
|
/* We have an absolutly positioned box with a clip rect */
|
|
|
|
if (css_rect.left_auto == false)
|
|
|
|
r.x0 = x - border_left + FIXTOINT(nscss_len2px(
|
2018-01-04 02:58:18 +03:00
|
|
|
&html->len_ctx,
|
2013-01-02 22:02:15 +04:00
|
|
|
css_rect.left, css_rect.lunit,
|
|
|
|
box->style));
|
2005-05-23 01:50:14 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
if (css_rect.top_auto == false)
|
|
|
|
r.y0 = y - border_top + FIXTOINT(nscss_len2px(
|
2018-01-04 02:58:18 +03:00
|
|
|
&html->len_ctx,
|
2013-01-02 22:02:15 +04:00
|
|
|
css_rect.top, css_rect.tunit,
|
|
|
|
box->style));
|
2011-01-29 22:22:12 +03:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
if (css_rect.right_auto == false)
|
|
|
|
r.x1 = x - border_left + FIXTOINT(nscss_len2px(
|
2018-01-04 02:58:18 +03:00
|
|
|
&html->len_ctx,
|
2013-01-02 22:02:15 +04:00
|
|
|
css_rect.right, css_rect.runit,
|
|
|
|
box->style));
|
2005-04-29 05:34:19 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
if (css_rect.bottom_auto == false)
|
|
|
|
r.y1 = y - border_top + FIXTOINT(nscss_len2px(
|
2018-01-04 02:58:18 +03:00
|
|
|
&html->len_ctx,
|
2013-01-02 22:02:15 +04:00
|
|
|
css_rect.bottom, css_rect.bunit,
|
|
|
|
box->style));
|
2011-01-29 22:22:12 +03:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* find intersection of clip rectangle and box */
|
|
|
|
if (r.x0 < clip->x0) r.x0 = clip->x0;
|
|
|
|
if (r.y0 < clip->y0) r.y0 = clip->y0;
|
|
|
|
if (clip->x1 < r.x1) r.x1 = clip->x1;
|
|
|
|
if (clip->y1 < r.y1) r.y1 = clip->y1;
|
2013-05-28 15:47:20 +04:00
|
|
|
/* Nothing to do for invalid rectangles */
|
|
|
|
if (r.x0 >= r.x1 || r.y0 >= r.y1)
|
2013-01-02 22:02:15 +04:00
|
|
|
/* not an error */
|
2017-02-11 16:54:08 +03:00
|
|
|
return ((!ctx->plot->group_end) ||
|
|
|
|
(ctx->plot->group_end(ctx) == NSERROR_OK));
|
2013-01-02 22:02:15 +04:00
|
|
|
/* clip to it */
|
2017-02-11 16:54:08 +03:00
|
|
|
if (ctx->plot->clip(ctx, &r) != NSERROR_OK)
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
2010-03-28 16:56:39 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
} else 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 (r.x0 < clip->x0) r.x0 = clip->x0;
|
|
|
|
if (r.y0 < clip->y0) r.y0 = clip->y0;
|
|
|
|
if (clip->x1 < r.x1) r.x1 = clip->x1;
|
|
|
|
if (clip->y1 < r.y1) r.y1 = clip->y1;
|
|
|
|
/* no point trying to draw 0-width/height boxes */
|
|
|
|
if (r.x0 == r.x1 || r.y0 == r.y1)
|
|
|
|
/* not an error */
|
2017-02-11 16:54:08 +03:00
|
|
|
return ((!ctx->plot->group_end) ||
|
|
|
|
(ctx->plot->group_end(ctx) == NSERROR_OK));
|
2013-01-02 22:02:15 +04:00
|
|
|
/* clip to it */
|
2017-02-11 16:54:08 +03:00
|
|
|
if (ctx->plot->clip(ctx, &r) != NSERROR_OK)
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
/* clip box is fine, clip to it */
|
|
|
|
r = *clip;
|
2017-02-11 16:54:08 +03:00
|
|
|
if (ctx->plot->clip(ctx, &r) != NSERROR_OK)
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
|
|
|
}
|
2011-06-29 00:17:39 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* background colour and image for block level content and replaced
|
|
|
|
* inlines */
|
2011-06-29 00:17:39 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
bg_box = html_redraw_find_bg_box(box);
|
2011-06-29 00:17:39 +04:00
|
|
|
|
2013-01-02 22:02:15 +04: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 */
|
|
|
|
if (bg_box && bg_box->type != BOX_BR &&
|
|
|
|
bg_box->type != BOX_TEXT &&
|
|
|
|
bg_box->type != BOX_INLINE_END &&
|
|
|
|
(bg_box->type != BOX_INLINE || bg_box->object ||
|
2013-02-07 02:39:45 +04:00
|
|
|
bg_box->flags & IFRAME || box->flags & REPLACE_DIM ||
|
|
|
|
(bg_box->gadget != NULL &&
|
|
|
|
(bg_box->gadget->type == GADGET_TEXTAREA ||
|
|
|
|
bg_box->gadget->type == GADGET_TEXTBOX ||
|
|
|
|
bg_box->gadget->type == GADGET_PASSWORD)))) {
|
2013-01-02 22:02:15 +04:00
|
|
|
/* find intersection of clip box and border edge */
|
|
|
|
struct rect p;
|
|
|
|
p.x0 = x - border_left < r.x0 ? r.x0 : x - border_left;
|
|
|
|
p.y0 = y - border_top < r.y0 ? r.y0 : y - border_top;
|
|
|
|
p.x1 = x + padding_width + border_right < r.x1 ?
|
|
|
|
x + padding_width + border_right : r.x1;
|
|
|
|
p.y1 = y + padding_height + border_bottom < r.y1 ?
|
|
|
|
y + padding_height + border_bottom : r.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;
|
2008-07-19 04:50:41 +04:00
|
|
|
}
|
2013-01-02 22:02:15 +04:00
|
|
|
p.x0 = p.x0 - m_left < r.x0 ? r.x0 : p.x0 - m_left;
|
|
|
|
p.y0 = p.y0 - m_top < r.y0 ? r.y0 : p.y0 - m_top;
|
|
|
|
p.x1 = p.x1 + m_right < r.x1 ? p.x1 + m_right : r.x1;
|
|
|
|
p.y1 = p.y1 + m_bottom < r.y1 ? p.y1 + m_bottom : r.y1;
|
|
|
|
}
|
|
|
|
/* valid clipping rectangles only */
|
|
|
|
if ((p.x0 < p.x1) && (p.y0 < p.y1)) {
|
|
|
|
/* plot background */
|
|
|
|
if (!html_redraw_background(x, y, box, scale, &p,
|
2018-01-04 02:58:18 +03:00
|
|
|
¤t_background_color, bg_box,
|
|
|
|
&html->len_ctx, ctx))
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
|
|
|
/* restore previous graphics window */
|
2017-02-11 16:54:08 +03:00
|
|
|
if (ctx->plot->clip(ctx, &r) != NSERROR_OK)
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
2005-04-29 05:34:19 +04:00
|
|
|
}
|
2006-01-02 02:55:24 +03:00
|
|
|
}
|
2004-10-18 01:05:12 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* borders for block level content and replaced inlines */
|
2017-02-11 16:54:08 +03:00
|
|
|
if (box->style &&
|
|
|
|
box->type != BOX_TEXT &&
|
|
|
|
box->type != BOX_INLINE_END &&
|
|
|
|
(box->type != BOX_INLINE || box->object ||
|
|
|
|
box->flags & IFRAME || box->flags & REPLACE_DIM ||
|
|
|
|
(box->gadget != NULL &&
|
|
|
|
(box->gadget->type == GADGET_TEXTAREA ||
|
|
|
|
box->gadget->type == GADGET_TEXTBOX ||
|
|
|
|
box->gadget->type == GADGET_PASSWORD))) &&
|
|
|
|
(border_top || border_right || border_bottom || border_left)) {
|
2013-01-02 22:02:15 +04:00
|
|
|
if (!html_redraw_borders(box, x_parent, y_parent,
|
|
|
|
padding_width, padding_height, &r,
|
|
|
|
scale, ctx))
|
|
|
|
return false;
|
|
|
|
}
|
2004-10-18 01:05:12 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* backgrounds and borders for non-replaced inlines */
|
|
|
|
if (box->style && box->type == BOX_INLINE && box->inline_end &&
|
|
|
|
(html_redraw_box_has_background(box) ||
|
|
|
|
border_top || border_right ||
|
|
|
|
border_bottom || border_left)) {
|
|
|
|
/* inline backgrounds and borders span other boxes and may
|
|
|
|
* wrap onto separate lines */
|
|
|
|
struct box *ib;
|
|
|
|
struct rect b; /* border edge rectangle */
|
|
|
|
struct rect p; /* clipped rect */
|
|
|
|
bool first = true;
|
|
|
|
int ib_x;
|
|
|
|
int ib_y = y;
|
|
|
|
int ib_p_width;
|
|
|
|
int ib_b_left, ib_b_right;
|
2008-12-21 18:51:23 +03:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
b.x0 = x - border_left;
|
|
|
|
b.x1 = x + padding_width + border_right;
|
|
|
|
b.y0 = y - border_top;
|
|
|
|
b.y1 = y + padding_height + border_bottom;
|
2008-12-21 18:51:23 +03:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
p.x0 = b.x0 < r.x0 ? r.x0 : b.x0;
|
|
|
|
p.x1 = b.x1 < r.x1 ? b.x1 : r.x1;
|
|
|
|
p.y0 = b.y0 < r.y0 ? r.y0 : b.y0;
|
|
|
|
p.y1 = b.y1 < r.y1 ? b.y1 : r.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;
|
|
|
|
ib_p_width = ib->padding[LEFT] + ib->width +
|
|
|
|
ib->padding[RIGHT];
|
|
|
|
ib_b_left = ib->border[LEFT].width;
|
|
|
|
ib_b_right = ib->border[RIGHT].width;
|
|
|
|
} 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;
|
|
|
|
ib_b_left = ib->border[LEFT].width * scale;
|
|
|
|
ib_b_right = ib->border[RIGHT].width * scale;
|
|
|
|
}
|
2009-01-17 22:39:38 +03:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
if ((ib->flags & NEW_LINE) && ib != box) {
|
|
|
|
/* inline element has wrapped, plot background
|
|
|
|
* and borders */
|
|
|
|
if (!html_redraw_inline_background(
|
|
|
|
x, y, box, scale, &p, b,
|
|
|
|
first, false,
|
2018-01-04 02:58:18 +03:00
|
|
|
¤t_background_color,
|
|
|
|
&html->len_ctx, ctx))
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
|
|
|
/* restore previous graphics window */
|
2017-02-11 16:54:08 +03:00
|
|
|
if (ctx->plot->clip(ctx, &r) != NSERROR_OK)
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
|
|
|
if (!html_redraw_inline_borders(box, b, &r,
|
|
|
|
scale, first, false, ctx))
|
|
|
|
return false;
|
|
|
|
/* reset coords */
|
|
|
|
b.x0 = ib_x - ib_b_left;
|
|
|
|
b.y0 = ib_y - border_top - padding_top;
|
|
|
|
b.y1 = ib_y + padding_height - padding_top +
|
|
|
|
border_bottom;
|
2011-08-31 16:12:41 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
p.x0 = b.x0 < r.x0 ? r.x0 : b.x0;
|
|
|
|
p.y0 = b.y0 < r.y0 ? r.y0 : b.y0;
|
|
|
|
p.y1 = b.y1 < r.y1 ? b.y1 : r.y1;
|
2011-08-31 16:12:41 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
first = false;
|
|
|
|
}
|
2011-08-31 16:12:41 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* increase width for current box */
|
|
|
|
b.x1 = ib_x + ib_p_width + ib_b_right;
|
|
|
|
p.x1 = b.x1 < r.x1 ? b.x1 : r.x1;
|
2011-08-31 16:12:41 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
if (ib == box->inline_end)
|
|
|
|
/* reached end of BOX_INLINE span */
|
|
|
|
break;
|
2008-12-21 18:51:23 +03:00
|
|
|
}
|
2013-01-02 22:02:15 +04:00
|
|
|
/* plot background and borders for last rectangle of
|
|
|
|
* the inline */
|
|
|
|
if (!html_redraw_inline_background(x, ib_y, box, scale, &p, b,
|
2018-01-04 02:58:18 +03:00
|
|
|
first, true, ¤t_background_color,
|
|
|
|
&html->len_ctx, ctx))
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
|
|
|
/* restore previous graphics window */
|
2017-02-11 16:54:08 +03:00
|
|
|
if (ctx->plot->clip(ctx, &r) != NSERROR_OK)
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
|
|
|
if (!html_redraw_inline_borders(box, b, &r, scale, first, true,
|
|
|
|
ctx))
|
|
|
|
return false;
|
2008-12-21 18:51:23 +03:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
}
|
2009-07-24 03:05:34 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* Debug outlines */
|
|
|
|
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];
|
2009-07-24 03:05:34 +04:00
|
|
|
} else {
|
2013-01-02 22:02:15 +04:00
|
|
|
margin_left = box->margin[LEFT] * scale;
|
|
|
|
margin_top = box->margin[TOP] * scale;
|
|
|
|
margin_right = box->margin[RIGHT] * scale;
|
|
|
|
margin_bottom = box->margin[BOTTOM] * scale;
|
2008-12-21 18:51:23 +03:00
|
|
|
}
|
2013-01-02 22:02:15 +04:00
|
|
|
/* Content edge -- blue */
|
2017-02-11 16:54:08 +03:00
|
|
|
rect.x0 = x + padding_left;
|
|
|
|
rect.y0 = y + padding_top;
|
|
|
|
rect.x1 = x + padding_left + width;
|
|
|
|
rect.y1 = y + padding_top + height;
|
|
|
|
if (ctx->plot->rectangle(ctx, plot_style_content_edge, &rect) != NSERROR_OK)
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
2017-02-11 16:54:08 +03:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* Padding edge -- red */
|
2017-02-11 16:54:08 +03:00
|
|
|
rect.x0 = x;
|
|
|
|
rect.y0 = y;
|
|
|
|
rect.x1 = x + padding_width;
|
|
|
|
rect.y1 = y + padding_height;
|
|
|
|
if (ctx->plot->rectangle(ctx, plot_style_padding_edge, &rect) != NSERROR_OK)
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
2017-02-11 16:54:08 +03:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* Margin edge -- yellow */
|
2017-02-11 16:54:08 +03:00
|
|
|
rect.x0 = x - border_left - margin_left;
|
|
|
|
rect.y0 = y - border_top - margin_top;
|
|
|
|
rect.x1 = x + padding_width + border_right + margin_right;
|
|
|
|
rect.y1 = y + padding_height + border_bottom + margin_bottom;
|
|
|
|
if (ctx->plot->rectangle(ctx, plot_style_margin_edge, &rect) != NSERROR_OK)
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
|
|
|
}
|
2008-12-21 18:51:23 +03:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* clip to the padding edge for objects, or boxes with overflow hidden
|
2014-07-18 23:09:20 +04:00
|
|
|
* or scroll, unless it's the root element */
|
|
|
|
if (box->parent != NULL) {
|
|
|
|
bool need_clip = false;
|
|
|
|
if (box->object || box->flags & IFRAME ||
|
|
|
|
(overflow_x != CSS_OVERFLOW_VISIBLE &&
|
|
|
|
overflow_y != CSS_OVERFLOW_VISIBLE)) {
|
|
|
|
r.x0 = x;
|
|
|
|
r.y0 = y;
|
|
|
|
r.x1 = x + padding_width;
|
|
|
|
r.y1 = y + padding_height;
|
|
|
|
if (r.x0 < clip->x0) r.x0 = clip->x0;
|
|
|
|
if (r.y0 < clip->y0) r.y0 = clip->y0;
|
|
|
|
if (clip->x1 < r.x1) r.x1 = clip->x1;
|
|
|
|
if (clip->y1 < r.y1) r.y1 = clip->y1;
|
2017-02-11 16:54:08 +03:00
|
|
|
if (r.x1 <= r.x0 || r.y1 <= r.y0) {
|
|
|
|
return (!ctx->plot->group_end ||
|
|
|
|
(ctx->plot->group_end(ctx) == NSERROR_OK));
|
|
|
|
}
|
2014-07-18 23:09:20 +04:00
|
|
|
need_clip = true;
|
|
|
|
|
|
|
|
} else if (overflow_x != CSS_OVERFLOW_VISIBLE) {
|
|
|
|
r.x0 = x;
|
|
|
|
r.y0 = clip->y0;
|
|
|
|
r.x1 = x + padding_width;
|
|
|
|
r.y1 = clip->y1;
|
|
|
|
if (r.x0 < clip->x0) r.x0 = clip->x0;
|
|
|
|
if (clip->x1 < r.x1) r.x1 = clip->x1;
|
2017-02-11 16:54:08 +03:00
|
|
|
if (r.x1 <= r.x0) {
|
|
|
|
return (!ctx->plot->group_end ||
|
|
|
|
(ctx->plot->group_end(ctx) == NSERROR_OK));
|
|
|
|
}
|
2014-07-18 23:09:20 +04:00
|
|
|
need_clip = true;
|
|
|
|
|
|
|
|
} else if (overflow_y != CSS_OVERFLOW_VISIBLE) {
|
|
|
|
r.x0 = clip->x0;
|
|
|
|
r.y0 = y;
|
|
|
|
r.x1 = clip->x1;
|
|
|
|
r.y1 = y + padding_height;
|
|
|
|
if (r.y0 < clip->y0) r.y0 = clip->y0;
|
|
|
|
if (clip->y1 < r.y1) r.y1 = clip->y1;
|
2017-02-11 16:54:08 +03:00
|
|
|
if (r.y1 <= r.y0) {
|
|
|
|
return (!ctx->plot->group_end ||
|
|
|
|
(ctx->plot->group_end(ctx) == NSERROR_OK));
|
|
|
|
}
|
2014-07-18 23:09:20 +04:00
|
|
|
need_clip = true;
|
|
|
|
}
|
2014-06-01 21:36:22 +04:00
|
|
|
|
2017-02-11 16:54:08 +03:00
|
|
|
if (need_clip &&
|
|
|
|
(box->type == BOX_BLOCK ||
|
|
|
|
box->type == BOX_INLINE_BLOCK ||
|
|
|
|
box->type == BOX_TABLE_CELL || box->object)) {
|
|
|
|
if (ctx->plot->clip(ctx, &r) != NSERROR_OK)
|
2014-07-18 23:09:20 +04:00
|
|
|
return false;
|
|
|
|
}
|
2008-12-21 18:51:23 +03:00
|
|
|
}
|
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* text decoration */
|
2017-02-11 16:54:08 +03:00
|
|
|
if ((box->type != BOX_TEXT) &&
|
|
|
|
box->style &&
|
|
|
|
css_computed_text_decoration(box->style) != CSS_TEXT_DECORATION_NONE) {
|
2013-01-02 22:02:15 +04:00
|
|
|
if (!html_redraw_text_decoration(box, x_parent, y_parent,
|
|
|
|
scale, current_background_color, ctx))
|
|
|
|
return false;
|
2017-02-11 16:54:08 +03:00
|
|
|
}
|
2011-01-29 22:22:12 +03:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
if (box->object && width != 0 && height != 0) {
|
|
|
|
struct content_redraw_data obj_data;
|
2009-07-06 00:10:17 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
x_scrolled = x - scrollbar_get_offset(box->scroll_x) * scale;
|
|
|
|
y_scrolled = y - scrollbar_get_offset(box->scroll_y) * scale;
|
2010-03-28 16:56:39 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
obj_data.x = x_scrolled + padding_left;
|
|
|
|
obj_data.y = y_scrolled + padding_top;
|
|
|
|
obj_data.width = width;
|
|
|
|
obj_data.height = height;
|
|
|
|
obj_data.background_colour = current_background_color;
|
|
|
|
obj_data.scale = scale;
|
|
|
|
obj_data.repeat_x = false;
|
|
|
|
obj_data.repeat_y = false;
|
|
|
|
|
|
|
|
if (content_get_type(box->object) == CONTENT_HTML) {
|
|
|
|
obj_data.x /= scale;
|
|
|
|
obj_data.y /= scale;
|
2008-12-21 18:51:23 +03:00
|
|
|
}
|
2011-06-29 00:17:39 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
if (!content_redraw(box->object, &obj_data, &r, ctx)) {
|
|
|
|
/* Show image fail */
|
|
|
|
/* Unicode (U+FFFC) 'OBJECT REPLACEMENT CHARACTER' */
|
|
|
|
const char *obj = "\xef\xbf\xbc";
|
|
|
|
int obj_width;
|
|
|
|
int obj_x = x + padding_left;
|
2016-04-24 01:32:21 +03:00
|
|
|
nserror res;
|
|
|
|
|
2017-02-11 16:54:08 +03:00
|
|
|
rect.x0 = x + padding_left;
|
|
|
|
rect.y0 = y + padding_top;
|
|
|
|
rect.x1 = x + padding_left + width - 1;
|
|
|
|
rect.y1 = y + padding_top + height - 1;
|
|
|
|
res = ctx->plot->rectangle(ctx, plot_style_broken_object, &rect);
|
|
|
|
if (res != NSERROR_OK) {
|
2008-12-21 18:51:23 +03:00
|
|
|
return false;
|
2016-04-24 01:32:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
res = guit->layout->width(plot_fstyle_broken_object,
|
|
|
|
obj,
|
|
|
|
sizeof(obj) - 1,
|
|
|
|
&obj_width);
|
|
|
|
if (res != NSERROR_OK) {
|
2013-01-02 22:02:15 +04:00
|
|
|
obj_x += 1;
|
2016-04-24 01:32:21 +03:00
|
|
|
} else {
|
2013-01-02 22:02:15 +04:00
|
|
|
obj_x += width / 2 - obj_width / 2;
|
2016-04-24 01:32:21 +03:00
|
|
|
}
|
2011-06-29 00:17:39 +04:00
|
|
|
|
2017-02-11 16:54:08 +03:00
|
|
|
if (ctx->plot->text(ctx,
|
|
|
|
plot_fstyle_broken_object,
|
|
|
|
obj_x, y + padding_top + (int)(height * 0.75),
|
|
|
|
obj, sizeof(obj) - 1) != NSERROR_OK)
|
2008-12-21 18:51:23 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
} else if (box->iframe) {
|
|
|
|
/* Offset is passed to browser window redraw unscaled */
|
|
|
|
browser_window_redraw(box->iframe,
|
|
|
|
(x + padding_left) / scale,
|
|
|
|
(y + padding_top) / scale, &r, ctx);
|
2008-12-21 18:51:23 +03:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
} else if (box->gadget && box->gadget->type == GADGET_CHECKBOX) {
|
|
|
|
if (!html_redraw_checkbox(x + padding_left, y + padding_top,
|
|
|
|
width, height, box->gadget->selected, ctx))
|
|
|
|
return false;
|
2005-05-23 01:50:14 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
} else if (box->gadget && box->gadget->type == GADGET_RADIO) {
|
|
|
|
if (!html_redraw_radio(x + padding_left, y + padding_top,
|
|
|
|
width, height, box->gadget->selected, ctx))
|
|
|
|
return false;
|
2009-07-24 03:05:34 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
} else if (box->gadget && box->gadget->type == GADGET_FILE) {
|
|
|
|
if (!html_redraw_file(x + padding_left, y + padding_top,
|
|
|
|
width, height, box, scale,
|
2018-01-04 02:58:18 +03:00
|
|
|
current_background_color, &html->len_ctx, ctx))
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
2005-05-23 01:50:14 +04:00
|
|
|
|
2013-02-07 02:39:45 +04:00
|
|
|
} else if (box->gadget &&
|
|
|
|
(box->gadget->type == GADGET_TEXTAREA ||
|
|
|
|
box->gadget->type == GADGET_PASSWORD ||
|
|
|
|
box->gadget->type == GADGET_TEXTBOX)) {
|
2013-02-09 03:25:40 +04:00
|
|
|
textarea_redraw(box->gadget->data.text.ta, x, y,
|
|
|
|
current_background_color, scale, &r, ctx);
|
2013-02-07 02:39:45 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
} else if (box->text) {
|
|
|
|
if (!html_redraw_text_box(html, box, x, y, &r, scale,
|
|
|
|
current_background_color, ctx))
|
|
|
|
return false;
|
2005-05-23 01:50:14 +04:00
|
|
|
|
|
|
|
} else {
|
2013-01-02 22:02:15 +04:00
|
|
|
if (!html_redraw_box_children(html, box, x_parent, y_parent, &r,
|
|
|
|
scale, current_background_color, ctx))
|
|
|
|
return false;
|
2005-05-23 01:50:14 +04:00
|
|
|
}
|
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
if (box->type == BOX_BLOCK || box->type == BOX_INLINE_BLOCK ||
|
|
|
|
box->type == BOX_TABLE_CELL || box->type == BOX_INLINE)
|
2017-02-11 16:54:08 +03:00
|
|
|
if (ctx->plot->clip(ctx, clip) != NSERROR_OK)
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
2005-05-23 01:50:14 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* list marker */
|
2017-02-11 16:54:08 +03:00
|
|
|
if (box->list_marker) {
|
2013-01-02 22:02:15 +04:00
|
|
|
if (!html_redraw_box(html, box->list_marker,
|
|
|
|
x_parent + box->x -
|
|
|
|
scrollbar_get_offset(box->scroll_x),
|
|
|
|
y_parent + box->y -
|
|
|
|
scrollbar_get_offset(box->scroll_y),
|
|
|
|
clip, scale, current_background_color, ctx))
|
|
|
|
return false;
|
2017-02-11 16:54:08 +03:00
|
|
|
}
|
2005-05-23 01:50:14 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
/* scrollbars */
|
|
|
|
if (((box->style && box->type != BOX_BR &&
|
|
|
|
box->type != BOX_TABLE && box->type != BOX_INLINE &&
|
2014-06-01 21:36:22 +04:00
|
|
|
(overflow_x == CSS_OVERFLOW_SCROLL ||
|
|
|
|
overflow_x == CSS_OVERFLOW_AUTO ||
|
|
|
|
overflow_y == CSS_OVERFLOW_SCROLL ||
|
|
|
|
overflow_y == CSS_OVERFLOW_AUTO)) ||
|
|
|
|
(box->object && content_get_type(box->object) ==
|
|
|
|
CONTENT_HTML)) && box->parent != NULL) {
|
2005-05-23 01:50:14 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
has_x_scroll = box_hscrollbar_present(box);
|
|
|
|
has_y_scroll = box_vscrollbar_present(box);
|
2009-07-10 22:36:49 +04:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
if (!box_handle_scrollbars((struct content *)html,
|
|
|
|
box, has_x_scroll, has_y_scroll))
|
2005-05-23 01:50:14 +04:00
|
|
|
return false;
|
2018-05-10 13:34:26 +03:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
if (box->scroll_x != NULL)
|
|
|
|
scrollbar_redraw(box->scroll_x,
|
|
|
|
x_parent + box->x,
|
2018-05-10 13:34:26 +03:00
|
|
|
y_parent + box->y + box->padding[TOP] +
|
2013-01-02 22:02:15 +04:00
|
|
|
box->height + box->padding[BOTTOM] -
|
|
|
|
SCROLLBAR_WIDTH, clip, scale, ctx);
|
|
|
|
if (box->scroll_y != NULL)
|
|
|
|
scrollbar_redraw(box->scroll_y,
|
|
|
|
x_parent + box->x + box->padding[LEFT] +
|
|
|
|
box->width + box->padding[RIGHT] -
|
|
|
|
SCROLLBAR_WIDTH,
|
|
|
|
y_parent + box->y, clip, scale, ctx);
|
2005-05-23 01:50:14 +04:00
|
|
|
}
|
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
if (box->type == BOX_BLOCK || box->type == BOX_INLINE_BLOCK ||
|
2017-02-11 16:54:08 +03:00
|
|
|
box->type == BOX_TABLE_CELL || box->type == BOX_INLINE) {
|
|
|
|
if (ctx->plot->clip(ctx, clip) != NSERROR_OK)
|
2013-01-02 22:02:15 +04:00
|
|
|
return false;
|
2017-02-11 16:54:08 +03:00
|
|
|
}
|
2013-01-02 22:02:15 +04:00
|
|
|
|
2017-02-11 16:54:08 +03:00
|
|
|
return ((!plot->group_end) || (ctx->plot->group_end(ctx) == NSERROR_OK));
|
2013-01-02 22:02:15 +04:00
|
|
|
}
|
2005-05-23 01:50:14 +04:00
|
|
|
|
|
|
|
/**
|
2013-01-02 22:02:15 +04:00
|
|
|
* Draw a CONTENT_HTML using the current set of plotters (plot).
|
2005-05-23 01:50:14 +04:00
|
|
|
*
|
2013-01-02 22:02:15 +04:00
|
|
|
* \param c content of type CONTENT_HTML
|
|
|
|
* \param data redraw data for this content redraw
|
|
|
|
* \param clip current clip region
|
|
|
|
* \param ctx current redraw context
|
2005-05-23 01:50:14 +04:00
|
|
|
* \return true if successful, false otherwise
|
2013-01-02 22:02:15 +04:00
|
|
|
*
|
|
|
|
* x, y, clip_[xy][01] are in target coordinates.
|
2005-05-23 01:50:14 +04:00
|
|
|
*/
|
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
bool html_redraw(struct content *c, struct content_redraw_data *data,
|
|
|
|
const struct rect *clip, const struct redraw_context *ctx)
|
2005-05-23 01:50:14 +04:00
|
|
|
{
|
2013-01-02 22:02:15 +04:00
|
|
|
html_content *html = (html_content *) c;
|
|
|
|
struct box *box;
|
|
|
|
bool result = true;
|
|
|
|
bool select, select_only;
|
|
|
|
plot_style_t pstyle_fill_bg = {
|
|
|
|
.fill_type = PLOT_OP_TYPE_SOLID,
|
|
|
|
.fill_colour = data->background_colour,
|
2009-07-10 22:36:49 +04:00
|
|
|
};
|
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
box = html->layout;
|
|
|
|
assert(box);
|
|
|
|
|
|
|
|
/* The select menu needs special treating because, when opened, it
|
|
|
|
* reaches beyond its layout box.
|
|
|
|
*/
|
|
|
|
select = false;
|
|
|
|
select_only = false;
|
|
|
|
if (ctx->interactive && html->visible_select_menu != NULL) {
|
|
|
|
struct form_control *control = html->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,
|
|
|
|
data->scale, clip);
|
2005-05-23 01:50:14 +04:00
|
|
|
}
|
2018-05-10 13:34:26 +03:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
if (!select_only) {
|
|
|
|
/* clear to background colour */
|
2017-02-11 16:54:08 +03:00
|
|
|
result = (ctx->plot->clip(ctx, clip) == NSERROR_OK);
|
2018-05-10 13:34:26 +03:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
if (html->background_colour != NS_TRANSPARENT)
|
|
|
|
pstyle_fill_bg.fill_colour = html->background_colour;
|
2017-02-11 16:54:08 +03:00
|
|
|
|
|
|
|
result &= (ctx->plot->rectangle(ctx, &pstyle_fill_bg, clip) == NSERROR_OK);
|
2018-05-10 13:34:26 +03:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
result &= html_redraw_box(html, box, data->x, data->y, clip,
|
|
|
|
data->scale, pstyle_fill_bg.fill_colour, ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (select) {
|
|
|
|
int menu_x, menu_y;
|
|
|
|
box = html->visible_select_menu->box;
|
|
|
|
box_coords(box, &menu_x, &menu_y);
|
2018-05-10 13:34:26 +03:00
|
|
|
|
2013-01-02 22:02:15 +04:00
|
|
|
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(html->visible_select_menu,
|
|
|
|
data->x + menu_x, data->y + menu_y,
|
|
|
|
data->scale, clip, ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
2005-05-23 01:50:14 +04:00
|
|
|
}
|