Hi all,
I've finally gone through the core changes Adam has made. I've not looked
in detail at the printing and pdf generation stuff itself -- I'll assume
that John T has done/will do that :)
Overall, the quality of this code is pretty good. Most of my comments
address stylistic issues. My comments are prefixed *jmb* for ease of
searching.
I've no real bright ideas about the font function issue. What's currently
there is ok for the timebeing, however.
J.
Index: render/loosen.c
===================================================================
--- render/loosen.c (.../trunk/netsurf) (revision 0)
+++ render/loosen.c (.../branches/adamblokus/netsurf) (revision 4686)
@@ -0,0 +1,399 @@
+/*
+ * Copyright 2008 Adam Blokus <[EMAIL PROTECTED]>
+ *
+ * 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/>.
+ */
+
+#include <stdbool.h>
+#include <assert.h>
+
+#include "render/box.h"
+#include "render/font.h"
+
+#include "content/content.h"
+
*jmb* This should probably be above box.h.
+#include "utils/log.h"
+#include "utils/talloc.h"
+
+#define AUTO INT_MIN
+
+bool loosen_document_layout(struct content *content, struct box *layout,
+ int width, int height);
*jmb* Is this meant to be static? If not, it should be defined in a header
+static bool loosen_text(struct box *text, int width, struct content* content);
+
+static bool loosen_table(struct box *box, int available_width,
+ struct content *content);
+
+static bool loosen_make_block_element(struct box *box, int width, int cx,
+ struct content *content);
+
+static bool loosen_shrink_object(struct box* box, int width);
+
+static bool loosen_all_first_pass(struct box* box, int width, int cx,
+ struct content* content);
+static bool loosen_all_second_pass(struct box* box, int width, int cx,
+ struct content* content);
+static bool loosen_all_third_pass(struct box* box, int width, int cx,
+ struct content* content);
+
*jmb* struct box *box here, please.
+/**
+ * Main loosing procedure
+ * \param content Reformated content - talloc memory pool for new boxes
+ * \param layout Root of the loosened box tree
+ * \param width Width the content is intended to fit
+ * \param height Height of a single page - to be taken into consideration for \
+ * preventing elements for being cropped at top/bottom edges of pages.
+ * \return true if successful, false otherwise (lack of memory)
+*/
+bool loosen_document_layout(struct content *content, struct box *layout,
+ int width, int height)
*jmb* Style: two-tab indent
+{
+ /* Optional try - if the current layout is not more than xx% too wide,
+ * maybe we scale the content to preserve the original layout?
+ */
+
+ if (!loosen_all_first_pass(layout, width, 0, content))
+ return false;
+ layout->min_width = 0;
+ layout->max_width = UNKNOWN_MAX_WIDTH;
+ content_reformat(content, width, 0);
+
+ /*Check if pass 1 was enough - if re-layouting doesn't give
+ *us the right width, go on to pass 2. And again - if pass 2 was not
+ *enough - go on to pass 3
+ */
+
+ if (content->width > width) {
+ if( !loosen_all_second_pass(layout, width, 0, content))
+ return false;
*jmb* Style: space before the bracket, not after it
+ layout->min_width = 0;
+ layout->max_width = UNKNOWN_MAX_WIDTH;
+ content_reformat(content, width, 0);
+ }
+
+ if (content->width > width) {
+ if( !loosen_all_third_pass(layout, width, 0, content))
+ return false;
*jmb* as above
+ layout->min_width = 0;
+ layout->max_width = UNKNOWN_MAX_WIDTH;
+ content_reformat(content, width, 0);
+ }
+
+ return true;
+}
+
+/** Primarily - break too wide words into pieces.
+ * \param text - the box that contains text to be broken
+ * \param width Width the content is intended to fit
+ * \param content talloc memory pool for new boxes
+ * \return true if successful, false otherwise
+*/
+bool loosen_text(struct box *text, int width, struct content *content)
+{
+ unsigned int offset;
+ int actual_x;
+
+ int *breaks;
+ int break_count;
+
+ int position, i;
+ struct font_functions * font_func;
+
*jmb* Style: lose the space after *
+ if (content->type == CONTENT_HTML)
+ font_func = content->data.html.font_func;
+ else
+ return false;
+
+ if (text->width <= width) {
+ LOG(("loosen_text called unnecessary?"));
+ /*Still - not an error for this function*/
+ return true;
+ }
+
+ breaks = (int*)malloc( sizeof(int) * text->length);
*jmb* The cast to int* is unnecessary -- it's implicit.
+ if (breaks == NULL)
+ return false;
+
+ break_count = 0;
+ position = 0;
+
+ while (position < text->length) {
+ font_func->font_position_in_string(text->style,
+ text->text + position,
+ text->length - position,
+ width, &offset, &actual_x);
*jmb* Style: Use 2 tabs for indent here.
+
+ if (offset < text->length - position) {
+ /*Another break*/
+ LOG(("Current text broken at offset %d", position +
offset));
*jmb* Style: wrap this
+ breaks[break_count++] = position + offset-1;
+ }
+
+ position+=offset;
*jmb* Style: spaces either side of +=
+ }
+
+ text->text = talloc_realloc(content, text->text, char, text->length + break_count);
+
*jmb* Style: wrap this
+ i=text->length-1;
*jmb* Style: spaces either side of =
+ text->length = text->length + break_count;
+
+ for (; i>=0; i--) {
+ text->text[i + break_count] = text->text[i];
+ if (i == breaks[break_count - 1]){
*jmb* Style: space before brace
+ break_count--;
+ text->text[i + break_count] = ' ';
+ }
+ }
+
+ free(breaks);
+
+ return true;
+}
+
+/**
+ * Changing table layout and structure to fit the contents width.
+ * In the most extreme case - the table has no influence on the width
+ * (each row is broken into one-cell rows).
+ * \param table - the box that contains table to be broken
+ * \param width Width the content is intended to fit
+ * \param content talloc memory pool for new boxes
+ * \return true if successful, false otherwise
+ */
+bool loosen_table(struct box *table, int width,
+ struct content *content)
*jmb* Style: this can all be one line
+{
+
+ struct box *row_group, *row, *cell, *br, *prev, *inline_container;
+ unsigned int row_sum;
+ bool first_cell_in_row;
+
+ if (table->min_width <= width)
+ return true;
+
+ inline_container = box_create(0, 0, 0, 0, 0, content);
+ inline_container->type = BOX_INLINE_CONTAINER;
+ inline_container->parent = table;
+ inline_container->style = talloc_memdup(content, table->style, sizeof
*table->style);
+
*jmb* Style: wrap this
+ prev = NULL;
+
+ for (row_group = table->children; row_group; row_group =row_group->next)
*jmb* Style: space after =.
This loop's body should probably be inside braces
The entire loop below should be indented one tab.
+ for (row = row_group->children; row; row = row->next) {
+
+ for (cell = row->children; cell; cell = cell->next) {
+ cell->type = BOX_INLINE_BLOCK;
+ cell->prev = prev;
+ cell->parent = inline_container;
+ cell->max_width = width;
+ cell->min_width = 0;
+
+ if (prev!=NULL)
*jmb* Style: spaces around !=
+ prev->next = cell;
+ else
+ inline_container->children = cell;
+
+ prev = cell;
+ }
+
+ br = box_create(0, 0, 0, 0, 0, content);
+ br->type = BOX_BR;
+ br->parent = inline_container;
+ br->prev = prev;
+ br->style = talloc_memdup(content, table->style, sizeof
*table->style);
*jmb* Style: wrap this
+ br->style->clear = CSS_CLEAR_BOTH;
+
+ if (prev!=NULL)
*jmb* Style: spaces around !=
+ prev->next = br;
+ else
+ inline_container->children = br;
+
+ prev = br;
+ }
+
+ inline_container->last = prev;
+
+ table->type = BOX_BLOCK;
+ table->children = table->last = inline_container;
+ table->col = NULL; //we can 'forget' this pointer thanks to talloc,
right?
*jmb* This should be safe, yes.
+ return true;
+}
+
+
+/**
+ * Change absolute and relative positioned elements into block elements
+ * in case they are positioned to far to the rigth
+ * \param box - the box that should be changed
+ * \param width Width the content is intended to fit
+ * \param cx current x - not yet in use
+ * \param content talloc memory pool for new boxes
+ * \return true if successful, false otherwise
+ */
+bool loosen_make_block_element(struct box *box, int width, int cx,
+ struct content *content)
*jmb* This probably wants to be called something like layout_position_static
Style: 2 tab indent
+{
+ assert(box->style);
+
+ if(box->style->position == CSS_POSITION_ABSOLUTE /*&&
*jmb* Style: space after if
+ box->x + box->width > width*/){
*jmb* Space before brace
+ box->style->position = CSS_POSITION_NOT_SET;
+ }
+
+ return true;
+}
+
+/**
+ * Shrink an object (esp. an image) to fit the page-width
+ * \note Not sure wheter it won't be better for images to be cropped
+ * \param box - the box that should be changed
+ * \param width Width the content is intended to fit
+ * \return true if successful, false otherwise
+*/
+bool loosen_shrink_object(struct box* box, int width)
+{
+ assert(box->object != NULL);
+
+ box->height = AUTO;
+ box->width = width;
+
+ if (box->style) {
+ box->style->width.width = CSS_WIDTH_PERCENT;
+ box->style->width.value.percent = 100;
+ box->style->height.height= CSS_HEIGHT_AUTO;
+ }
+
+ return true;
+}
+/*pass 1 -
+ */
+/**
+ * Pass 1 of loosening - do such obvious changes as: breaking too long words,
+ * moving absolute positioned objects into the visibile scope of width.
+ * \param box - the box that should be changed
+ * \param width Width the content is intended to fit
+ * \param cx current x - not yet in use
+ * \param content talloc memory pool for new boxes
+ * \return true if successful, false otherwise
+*/
+bool loosen_all_first_pass(struct box* box, int width, int cx, struct content*
content)
*jmb* Style: wrap this
+{
+ struct box* c;
+ int got_width;
+ int x;
+
+ for (c = box->children; c ; c = c->next) {
+ x = cx + c->x;
+ if (c->children != NULL)
+ loosen_all_first_pass(c, width, x, content);
+
+ if (c->style) {
+ if (c->style->position == CSS_POSITION_RELATIVE ||
+ c->style->position ==
CSS_POSITION_ABSOLUTE )
+ loosen_make_block_element(c, width, cx,
content);
+ if ( c->style->width.width == CSS_WIDTH_LENGTH &&
+ css_len2px(&c->style->width.value.length,
c->style) > width)
+ c->style->width.width = CSS_WIDTH_NOT_SET;
+ }
+
+ if (c->object && c->width > width)
+ loosen_shrink_object(c, width);
+
+ switch (c->type) {
+ case BOX_TEXT:
+ loosen_text(c, width, content);
+ break;
+ }
+
+ c->min_width = 0;
+ c->max_width = UNKNOWN_MAX_WIDTH;
+
+ }
*jmb* Where's the return statement? Also, you need to check for any of
the functions you're calling returning failure, then act
appropriately.
+}
+
+/**
+ * Pass 2 of loosening - break tables
+ * \param box - the box that should be changed
+ * \param width Width the content is intended to fit
+ * \param cx current x - not yet in use
+ * \param content talloc memory pool for new boxes
+ * \return true if successful, false otherwise
+ */
+bool loosen_all_second_pass(struct box* box, int width, int cx, struct
content* content)
*jmb* Style: wrap this
+{
+ struct box* c;
*jmb* struct box *c, please
+ int got_width;
+ int x;
+
+ for (c = box->children; c ; c = c->next) {
*jmb* Style: no space before semicolon
+ x = cx + c->x;
+ if (c->children != NULL)
+ loosen_all_second_pass(c, width, x, content);
+
+ switch (c->type) {
+ case BOX_TABLE:
+ loosen_table(c, width, content);
+ break;
+ }
+
+ c->min_width = 0;
+ c->max_width = UNKNOWN_MAX_WIDTH;
+ }
*jmb* Where's the return statement? Again, error checking.
+}
+
+
+/**
+ * Pass 3 of loosening -zero all margins and paddings
+ * \param box - the box that should be changed
+ * \param width Width the content is intended to fit
+ * \param cx current x - not yet in use
+ * \param content talloc memory pool for new boxes
+ * \return true if successful, false otherwise
+ */
+bool loosen_all_third_pass(struct box* box, int width, int cx, struct content*
content)
*jmb* Style: wrap this.
+{
+ struct box* c;
*jmb* See above
+ int got_width;
+ int x;
+
+ for (c = box->children; c ; c = c->next) {
+ x = cx + c->x;
+ if (c->children != NULL)
+ loosen_all_third_pass(c, width, x, content);
+
+ c->padding[LEFT] = c->padding[RIGHT] = 0;
+ c->margin[LEFT] = c->margin[RIGHT] = 0;
+
+ if (c->style) {
+ c->style->margin[LEFT].margin = CSS_MARGIN_PERCENT;
+ c->style->margin[LEFT].value.percent = 0;
+
+ c->style->margin[RIGHT].margin = CSS_MARGIN_PERCENT;
+ c->style->margin[RIGHT].value.percent = 0;
+
+ c->style->padding[LEFT].padding = CSS_PADDING_PERCENT;
+ c->style->padding[LEFT].value.percent = 0;
+
+ c->style->padding[RIGHT].padding = CSS_PADDING_PERCENT;
+ c->style->padding[RIGHT].value.percent = 0;
+
+ }
+
+ c->min_width = 0;
+ c->max_width = UNKNOWN_MAX_WIDTH;
+
+ }
*jmb* Missing return. Error checking.
+}
+
Index: render/html.c
===================================================================
--- render/html.c (.../trunk/netsurf) (revision 4686)
+++ render/html.c (.../branches/adamblokus/netsurf) (revision 4686)
*jmb* Fine.
Index: render/loosen.h
===================================================================
--- render/loosen.h (.../trunk/netsurf) (revision 0)
+++ render/loosen.h (.../branches/adamblokus/netsurf) (revision 4686)
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2008 Adam Blokus <[EMAIL PROTECTED]>
+ *
+ * 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/>.
+ */
+
+/**
+\file
+General idea - a set of routines working themselves recursively through
+the box tree and trying to change the layout of the document as little
+as possible to acquire the desired width ( - to make it fit in a printed
+page ), where possible - also taking the dividing height into consideration,
+to prevent objects being cut by ends of pages.
+*/
+
+#ifndef NETSURF_RENDER_LOOSEN_H
+#define NETSURF_RENDER_LOOSEN_H
+#include <stdbool.h>
+
+bool loosen_document_layout(struct content *content, struct box *layout,
+ int width, int height);
*jmb* Style: 2 tab indent
+
+#endif
Index: render/html_redraw.c
===================================================================
--- render/html_redraw.c (.../trunk/netsurf) (revision 4686)
+++ render/html_redraw.c (.../branches/adamblokus/netsurf)
(revision 4686)
*jmb* Style: wrap to 80 columns. Otherwise fine.
Index: render/textplain.c
===================================================================
--- render/textplain.c (.../trunk/netsurf) (revision 4686)
+++ render/textplain.c (.../branches/adamblokus/netsurf) (revision 4686)
*jmb* Style: wrapping. Otherwise fine
Index: render/html.h
===================================================================
--- render/html.h (.../trunk/netsurf) (revision 4686)
+++ render/html.h (.../branches/adamblokus/netsurf) (revision 4686)
*jmb* Fine.
Index: render/font.h
===================================================================
--- render/font.h (.../trunk/netsurf) (revision 4686)
+++ render/font.h (.../branches/adamblokus/netsurf) (revision 4686)
@@ -39,14 +39,19 @@
struct css_style;
-bool nsfont_width(const struct css_style *style,
+struct font_functions
+{
+bool (*font_width)(const struct css_style *style,
const char *string, size_t length,
int *width);
-bool nsfont_position_in_string(const struct css_style *style,
+bool (*font_position_in_string)(const struct css_style *style,
const char *string, size_t length,
int x, size_t *char_offset, int *actual_x);
-bool nsfont_split(const struct css_style *style,
+bool (*font_split)(const struct css_style *style,
const char *string, size_t length,
int x, size_t *char_offset, int *actual_x);
+};
*jmb* Style: indent struct members 1 tab.
+extern const struct font_functions nsfont;
+
#endif
Index: render/layout.c
===================================================================
--- render/layout.c (.../trunk/netsurf) (revision 4686)
+++ render/layout.c (.../branches/adamblokus/netsurf) (revision 4686)
*jmb* Style: wrapping, and 2 tab indents. Otherwise fine
Index: render/box.c
===================================================================
--- render/box.c (.../trunk/netsurf) (revision 4686)
+++ render/box.c (.../branches/adamblokus/netsurf) (revision 4686)
@@ -33,7 +33,6 @@
#include "utils/log.h"
#include "utils/talloc.h"
-
static bool box_contains_point(struct box *box, int x, int y);
#define box_is_float(box) (box->type == BOX_FLOAT_LEFT || \
@@ -545,6 +544,10 @@
fprintf(stream, "(%i %i %i %i) ",
box->descendant_x0, box->descendant_y0,
box->descendant_x1, box->descendant_y1);
+
+ fprintf(stream, "m(%i %i %i %i) ",
+ box->margin[TOP], box->margin[LEFT],
+ box->margin[BOTTOM], box->margin[RIGHT]);
switch (box->type) {
case BOX_BLOCK: fprintf(stream, "BLOCK "); break;
@@ -638,3 +641,196 @@
box_dump(stream, c, depth + 1);
}
}
+
+/* Box tree duplication below
+*/
+
+/** structure for translating addresses in the box tree */
+struct box_dict_element{
+ struct box *old, *new;
+};
+
+static bool box_duplicate_main_tree(struct box* box, struct content* c, int
*count);
+static void box_duplicate_create_dict(struct box* old_box, struct box* new_box,
+ struct box_dict_element **dict);
+static void box_duplicate_update( struct box* box, struct box_dict_element*
dict, int n);
+
+static int box_compare_dict_elements(struct box_dict_element* a,
+ struct box_dict_element* b);
+
+int box_compare_dict_elements(struct box_dict_element* a,
+ struct box_dict_element* b){
+ return (int)((*a).old) - (int)((*b).old);
+}
+
*jmb* Style: 2 tab indent & wrapping
+/** Duplication of a box tree. We assume that all the content is fetched,
+fallbacks have been applied where necessary and we reuse a lot of content
+like strings, fetched objects etc - just replicating all we need to create
+two different layouts.
+\return true on success, false on lack of memory
+*/
+struct box* box_duplicate_tree(struct box* root, struct content* c)
+{
+ struct box *new_root;/**< Root of the new box tree*/
+ int box_number = 0;
+ struct box *old_addr, *new_addr;
+ struct box_dict_element *box_dict, *box_dict_end;
+
+ /* 1. Duplicate parent - children structure, list_markers*/
+ new_root = talloc_memdup(c, root, sizeof (struct box));
+ if( !box_duplicate_main_tree(new_root, c, &box_number))
+ return NULL;
+
*jmb* Style: space after if, not bracket
+ /* 2. Create address translation dictionary*/
+ /*TODO: dont save unnecessary addresses*/
+
+ box_dict_end = box_dict =
+ (struct box_dict_element*)malloc(box_number *
+ sizeof(struct box_dict_element));
+
*jmb* This case is unnecessary
+ if (box_dict == NULL)
+ return NULL;
*jmb* Should the duplicate tree get cleaned up here?
+ box_duplicate_create_dict(root, new_root, &box_dict_end);
+
+ assert((box_dict_end - box_dict) == box_number);
+
+ /*3. Sort it*/
+
+ qsort(box_dict, (box_dict_end - box_dict), sizeof(struct box_dict_element),
+ (int (*)(const void *, const void *))box_compare_dict_elements);
+
+ /* 4. Update inline_end and float_children pointers */
+
+ box_duplicate_update(new_root, box_dict, (box_dict_end - box_dict));
+
+ free(box_dict);
+
+ return new_root;
+}
+
+/**
+ * Recursively duplicates children of an element, and also if present - its
+ * list_marker, style and text.
+ * \param box Current box to duplicate its children
+ * \param c talloc memory pool
+ * \param count number of boxes seen so far
+ * \return true if successful, false otherwise (lack of memory)
+*/
+bool box_duplicate_main_tree(struct box* box, struct content* c, int *count)
*jmb* Style: struct box *box, etc.
+{
+
+ struct box *b, *prev, *copy;
+
+ prev = NULL;
+
+ for (b = box->children; b; b = b->next){
+ /*Copy child*/
+ copy = talloc_memdup(c, b, sizeof (struct box));
+ if (copy == NULL)
+ return false;
+
+ copy->parent = box;
+
+ if (prev != NULL)
+ prev->next = copy;
+ else
+ box->children = copy;
+
+ /* Recursively visit child */
+ box_duplicate_main_tree(copy, c, count);
+
+ prev = copy;
+ }
+
+ box->last = prev;
+
+ if (box->list_marker){
*jmb* Style: space before brace
+ box->list_marker = talloc_memdup(c, box->list_marker,
+ sizeof *box->list_marker);
+ if (box->list_marker == NULL)
+ return false;
+ box->list_marker->parent = box;
+ }
+
+ if (box->text){
*jmb* as above
+ box->text = talloc_memdup(c, box->text, box->length);
+ if (box->text == NULL)
+ return false;
+ }
+
+ if (box->style){
*jmb* as above
+ box->style = talloc_memdup(c, box->style, sizeof *box->style);
+ if (box->style == NULL)
+ return false;
+ }
+
+ /*Make layout calculate the size of this element later
+ (might change because of font change etc.) */
+ box->width = UNKNOWN_WIDTH;
+ box->min_width = 0;
+ box->max_width = UNKNOWN_MAX_WIDTH;
+
+ (*count)++;
+
+ return true;
+}
+
+/**
+ * Recursively creates a dictionary of addresses - binding the address of a box
+ * with its copy.
+ * \param old_box original box
+ * \param new_box copy of the original box
+ * \param dict pointer to a pointer to the current position in the dictionary
+ */
+void box_duplicate_create_dict(struct box* old_box, struct box* new_box,
+ struct box_dict_element **dict)
+{
+ /**Children of the old and new boxes*/
+ struct box *b_old, *b_new;
+
+ for (b_old = old_box->children, b_new = new_box->children;
+ b_old != NULL && b_new != NULL;
+ b_old = b_old->next, b_new = b_new->next)
+ box_duplicate_create_dict(b_old, b_new, dict);
*jmb* Style: 2 tab indent
+
+ /*The new tree should be a exact copy*/
+ assert(b_old == NULL && b_new == NULL);
+
+ (**dict).old = old_box;
+ (**dict).new = new_box;
+ (*dict)++;
+}
+
+/**
+ * Recursively updates pointers in box tree.
+ * \param box current box in the new box tree
+ * \param box_dict box pointers dictionary
+ * \param n number of memory addresses in the dictionary
+ */
+void box_duplicate_update(struct box* box, struct box_dict_element* box_dict,
int n)
*jmb* Style: wrapping
+{
+ struct box_dict_element* box_dict_element;
+ struct box* b;
+ struct box_dict_element element;
+
+ for (b = box->children; b; b = b->next)
+ box_duplicate_update(b, box_dict, n);
+
+ if (box->float_children){
+ element.old = box->float_children;
+ box_dict_element = bsearch(&element,
+ box_dict, n,
+ sizeof(struct box_dict_element),
+ (int (*)(const void *, const void
*))box_compare_dict_elements);
+ box->float_children = box_dict_element->new;
+ }
+
+ if (box->next_float){
+ element.old = box->next_float;
+ box_dict_element = bsearch(&element,
+ box_dict, n,
+ sizeof(struct box_dict_element),
+ (int (*)(const void *, const void
*))box_compare_dict_elements);
+ box->next_float = box_dict_element->new;
+ }
+}
*jmb* Style: spaces before brace, etc.
Index: render/box.h
===================================================================
--- render/box.h (.../trunk/netsurf) (revision 4686)
+++ render/box.h (.../branches/adamblokus/netsurf) (revision 4686)
@@ -311,4 +311,6 @@
bool box_normalise_block(struct box *block, struct content *c);
+struct box* box_duplicate_tree(struct box* root, struct content* c);
+
*jmb* Style: struct box *box, etc.
#endif
Index: image/gif.c
Index: image/nssprite.c
Index: image/ico.c
Index: image/bmp.c
Index: image/mng.c
Index: image/rsvg.c
Index: image/jpeg.c
*jmb* fine
Index: Docs/Doxyfile
===================================================================
--- Docs/Doxyfile (.../trunk/netsurf) (revision 4686)
+++ Docs/Doxyfile (.../branches/adamblokus/netsurf) (revision 4686)
@@ -97,7 +97,7 @@
# (but less readable) file names. This can be useful is your file systems
# doesn't support long names like on DOS, Mac, or CD-ROM.
-SHORT_NAMES = NO
+SHORT_NAMES = YES
*jmb* Is this change needed?
Index: riscos/save_draw.c
===================================================================
--- riscos/save_draw.c (.../trunk/netsurf) (revision 4686)
+++ riscos/save_draw.c (.../branches/adamblokus/netsurf) (revision 4686)
*jmb* Fine.
Index: riscos/save.c
===================================================================
--- riscos/save.c (.../trunk/netsurf) (revision 4686)
+++ riscos/save.c (.../branches/adamblokus/netsurf) (revision 4686)
@@ -28,13 +28,13 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "oslib/dragasprite.h"
-#include "oslib/osbyte.h"
-#include "oslib/osfile.h"
-#include "oslib/osmodule.h"
+#include <oslib/dragasprite.h>
+#include <oslib/osbyte.h>
+#include <oslib/osfile.h>
+#include <oslib/osmodule.h>
#include <oslib/osspriteop.h>
-#include "oslib/wimp.h"
-#include "oslib/wimpspriteop.h"
+#include <oslib/wimp.h>
+#include <oslib/wimpspriteop.h>
#include "desktop/netsurf.h"
#include "desktop/save_text.h"
#include "desktop/selection.h"
@@ -47,6 +47,7 @@
#include "riscos/save.h"
#include "riscos/save_complete.h"
#include "riscos/save_draw.h"
+#include "riscos/save_pdf.h"
#include "riscos/textselection.h"
#include "riscos/thumbnail.h"
#include "riscos/wimp.h"
@@ -92,10 +93,12 @@
/** Table of filetypes and default filenames. Must be in sync with
* gui_save_type (riscos/gui.h). A filetype of 0 indicates the content should
- * be used. */
-struct gui_save_table_entry gui_save_table[] = {
+ * be used.
+ */
+static const struct gui_save_table_entry gui_save_table[] = {
/* GUI_SAVE_SOURCE, */ { 0, "SaveSource" },
/* GUI_SAVE_DRAW, */ { 0xaff, "SaveDraw" },
+ /* GUI_SAVE_PDF, */ { 0xadf, "SavePDF" },
/* GUI_SAVE_TEXT, */ { 0xfff, "SaveText" },
/* GUI_SAVE_COMPLETE, */ { 0xfaf, "SaveComplete" },
/* GUI_SAVE_OBJECT_ORIG, */ { 0, "SaveObject" },
@@ -633,7 +636,7 @@
/**
* Does the actual saving
*
- * \param c content to save (or 0 for other)
+ * \param c content to save (or NULL for other)
* \param path path to save as
* \return true on success, false on error and error reported
*/
@@ -647,6 +650,10 @@
case GUI_SAVE_DRAW:
return save_as_draw(c, path);
#endif
+#ifdef WITH_DRAW_EXPORT
*jmb* WITH_PDF_EXPORT?
+ case GUI_SAVE_PDF:
+ return save_as_pdf(c, path);
+#endif
case GUI_SAVE_TEXT:
save_as_text(c, path);
xosfile_set_type(path, 0xfff);
Index: riscos/plotters.c
===================================================================
--- riscos/plotters.c (.../trunk/netsurf) (revision 4686)
+++ riscos/plotters.c (.../branches/adamblokus/netsurf) (revision 4686)
*jmb* Fine
Index: desktop/history_core.c
===================================================================
--- desktop/history_core.c (.../trunk/netsurf) (revision 4686)
+++ desktop/history_core.c (.../branches/adamblokus/netsurf)
(revision 4686)
@@ -597,13 +597,13 @@
int tailsize = 5;
if (!plot.bitmap(entry->x, entry->y, WIDTH, HEIGHT,
- entry->bitmap, 0xffffff))
+ entry->bitmap, 0xffffff,NULL))
*jmb* Style: space before NULL
return false;
if (!plot.rectangle(entry->x - 1, entry->y - 1, WIDTH + 1, HEIGHT + 1,
entry == history->current ? 2 : 1, c, false, false))
return false;
- if (!nsfont_position_in_string(&css_base_style, entry->page.title,
+ if (!nsfont.font_position_in_string(&css_base_style, entry->page.title,
strlen(entry->page.title), WIDTH,
&char_offset, &actual_x))
return false;
Index: desktop/plotters.h
===================================================================
--- desktop/plotters.h (.../trunk/netsurf) (revision 4686)
+++ desktop/plotters.h (.../branches/adamblokus/netsurf) (revision 4686)
@@ -25,6 +25,7 @@
#include <stdbool.h>
#include "css/css.h"
+#include "content/content.h"
struct bitmap;
@@ -46,10 +47,10 @@
bool (*arc)(int x, int y, int radius, int angle1, int angle2,
colour c);
bool (*bitmap)(int x, int y, int width, int height,
- struct bitmap *bitmap, colour bg);
+ struct bitmap *bitmap, colour bg, struct content
*content);
*jmb* Style: wrapping
bool (*bitmap_tile)(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
- bool repeat_x, bool repeat_y);
+ bool repeat_x, bool repeat_y, struct content *content);
bool (*group_start)(const char *name); /** optional */
bool (*group_end)(void); /** optional */
bool (*flush)(void);
Index: desktop/browser.c
===================================================================
--- desktop/browser.c (.../trunk/netsurf) (revision 4686)
+++ desktop/browser.c (.../branches/adamblokus/netsurf) (revision 4686)
*jmb* Fine.
Index: desktop/knockout.c
===================================================================
--- desktop/knockout.c (.../trunk/netsurf) (revision 4686)
+++ desktop/knockout.c (.../branches/adamblokus/netsurf) (revision 4686)
*jmb* Fine.