[project @ 2005-07-02 18:17:51 by bursa]

Rewrite calculation of box minimum and maximum widths to improve layout of many pages. Move calculation of column types and border collapsing to box tree normalising stage, since they are layout independent. Add window height parameter to layout and make <html> and <body> at least window height.

svn path=/import/netsurf/; revision=1777
This commit is contained in:
James Bursa 2005-07-02 18:17:51 +00:00
parent 894ba8b623
commit 9b78daf135
10 changed files with 570 additions and 735 deletions

View File

@ -213,7 +213,8 @@ void browser_window_go_post(struct browser_window *bw, const char *url,
bw->history_add = history_add;
bw->time0 = clock();
c = fetchcache(url2, browser_window_callback, bw, 0,
gui_window_get_width(bw->window), 0,
gui_window_get_width(bw->window),
gui_window_get_height(bw->window),
false,
post_urlenc, post_multipart, true, download);
free(url2);
@ -235,7 +236,8 @@ void browser_window_go_post(struct browser_window *bw, const char *url,
fetchcache_go(c, option_send_referer ? referer : 0,
browser_window_callback, bw, 0,
gui_window_get_width(bw->window), 0,
gui_window_get_width(bw->window),
gui_window_get_height(bw->window),
post_urlenc, post_multipart, true);
}
@ -738,7 +740,6 @@ void browser_window_mouse_action_html(struct browser_window *bw,
browser_mouse_state mouse, int x, int y)
{
char *base_url = 0;
char *href = 0;
char *title = 0;
char *url = 0;
char status_buffer[200];
@ -774,16 +775,12 @@ void browser_window_mouse_action_html(struct browser_window *bw,
if (box->object)
object = box->object;
if (box->href) {
base_url = content->data.html.base_url;
href = box->href;
}
if (box->href)
url = box->href;
if (box->usemap) {
base_url = content->data.html.base_url;
href = imagemap_get(content, box->usemap,
if (box->usemap)
url = imagemap_get(content, box->usemap,
box_x, box_y, x, y);
}
if (box->gadget) {
gadget_content = content;
@ -802,6 +799,7 @@ void browser_window_mouse_action_html(struct browser_window *bw,
if (box->style && box->type != BOX_BR &&
box->type != BOX_INLINE &&
box->type != BOX_TEXT &&
(box->style->overflow == CSS_OVERFLOW_SCROLL ||
box->style->overflow == CSS_OVERFLOW_AUTO) &&
((box_vscrollbar_present(box) &&
@ -918,14 +916,10 @@ void browser_window_mouse_action_html(struct browser_window *bw,
/* \todo should have a drag-saving object msg */
status = c->status_message;
} else if (href) {
res = url_join(href, base_url, &url);
if (res != URL_FUNC_OK)
return;
} else if (url) {
if (title) {
snprintf(status_buffer, sizeof status_buffer, "%s: %s",
title, url);
url, title);
status = status_buffer;
} else
status = url;
@ -1000,8 +994,6 @@ void browser_window_mouse_action_html(struct browser_window *bw,
browser_window_set_status(bw, status);
browser_window_set_pointer(pointer);
free(url);
}

View File

@ -60,6 +60,7 @@ void gui_window_update_box(struct gui_window *g,
bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy);
void gui_window_set_scroll(struct gui_window *g, int sx, int sy);
int gui_window_get_width(struct gui_window *g);
int gui_window_get_height(struct gui_window *g);
void gui_window_set_extent(struct gui_window *g, int width, int height);
void gui_window_set_status(struct gui_window *g, const char *text);
void gui_window_set_pointer(gui_pointer_shape shape);

View File

@ -20,7 +20,7 @@
OBJECTS_COMMON = content.o fetch.o fetchcache.o url_store.o # content/
OBJECTS_COMMON += css.o css_enum.o parser.o ruleset.o scanner.o # css/
OBJECTS_COMMON += box.o box_construct.o box_normalise.o form.o html.o \
html_redraw.o layout.o list.o textplain.o # render/
html_redraw.o layout.o list.o table.o textplain.o # render/
OBJECTS_COMMON += messages.o talloc.o url.o utf8.o \
utils.o # utils/
OBJECTS_COMMON += imagemap.o loginlist.o options.o tree.o # desktop/

View File

@ -16,6 +16,7 @@
#include <stdbool.h>
#include "netsurf/css/css.h"
#include "netsurf/render/box.h"
#include "netsurf/render/table.h"
#ifdef riscos
#include "netsurf/desktop/gui.h"
#endif
@ -267,8 +268,6 @@ bool box_normalise_table(struct box *table, struct content * c)
table->rows = col_info.num_rows;
free(col_info.spans);
box_normalise_table_spans(table);
if (table->children == 0) {
LOG(("table->children == 0, removing"));
if (table->prev == 0)
@ -278,6 +277,13 @@ bool box_normalise_table(struct box *table, struct content * c)
if (table->next != 0)
table->next->prev = table->prev;
box_free(table);
} else {
box_normalise_table_spans(table);
if (!table_calculate_column_types(table))
return false;
if (table->style->border_collapse ==
CSS_BORDER_COLLAPSE_COLLAPSE)
table_collapse_borders(table);
}
LOG(("table %p done", table));

View File

@ -338,7 +338,7 @@ bool html_convert(struct content *c, int width, int height)
content_set_status(c, messages_get("Formatting"));
content_broadcast(c, CONTENT_MSG_STATUS, msg_data);
LOG(("Layout document"));
layout_document(c, width);
layout_document(c, width, height);
/*box_dump(c->data.html.layout->children, 0);*/
c->width = c->data.html.layout->descendant_x1;
c->height = c->data.html.layout->descendant_y1;
@ -1126,7 +1126,7 @@ void html_stop(struct content *c)
void html_reformat(struct content *c, int width, int height)
{
layout_document(c, width);
layout_document(c, width, height);
c->width = c->data.html.layout->descendant_x1;
c->height = c->data.html.layout->descendant_y1;
}

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,7 @@
struct box;
bool layout_document(struct content *content, int width);
bool layout_document(struct content *content, int width, int height);
bool layout_block_context(struct box *block, struct content *content);
bool layout_inline_container(struct box *box, int width,
struct box *cont, int cx, int cy, struct content *content);

View File

@ -469,7 +469,7 @@ void print_cleanup(void)
bool print_document(struct gui_window *g, const char *filename)
{
int left, right, top, bottom, width, height;
int saved_width;
int saved_width, saved_height;
int yscroll = 0, sheets = print_max_sheets;
struct content *c = g->bw->current_content;
const char *error_message;
@ -506,8 +506,9 @@ bool print_document(struct gui_window *g, const char *filename)
/* layout the document to the correct width */
saved_width = c->width;
saved_height = c->height;
if (c->type == CONTENT_HTML)
layout_document(c, width);
layout_document(c, width, height);
/* open printer file */
error = xosfind_openoutw(osfind_NO_PATH | osfind_ERROR_IF_DIR |
@ -645,7 +646,7 @@ bool print_document(struct gui_window *g, const char *filename)
/* restore document layout */
if (c->type == CONTENT_HTML)
layout_document(c, saved_width);
layout_document(c, saved_width, saved_height);
return true;
@ -663,7 +664,7 @@ error:
/* restore document layout */
if (c->type == CONTENT_HTML)
layout_document(c, saved_width);
layout_document(c, saved_width, saved_height);
return false;
}

View File

@ -146,7 +146,7 @@ bool save_as_draw(struct content *c, const char *path)
memcpy(diagram->source, "NetSurf ", 12);
/* recalculate box widths for an A4 page */
if (!layout_document(c, A4PAGEWIDTH)) {
if (!layout_document(c, A4PAGEWIDTH, A4PAGEWIDTH)) {
warn_user("NoMemory", 0);
goto draw_save_error;
}
@ -185,7 +185,7 @@ bool save_as_draw(struct content *c, const char *path)
drawbuf_free();
/* reset layout to current window width */
if (!layout_document(c, current_width)) {
if (!layout_document(c, current_width, current_width)) {
warn_user("NoMemory", 0);
return false;
}
@ -195,7 +195,7 @@ bool save_as_draw(struct content *c, const char *path)
draw_save_error:
drawbuf_free();
/* attempt to reflow back on failure */
(void)layout_document(c, current_width);
(void)layout_document(c, current_width, current_width);
return false;
}

View File

@ -818,6 +818,32 @@ int gui_window_get_width(struct gui_window *g)
}
/**
* Find the current height of a browser window.
*
* \param g gui_window to measure
* \return height of window
*/
int gui_window_get_height(struct gui_window *g)
{
wimp_window_state state;
os_error *error;
state.w = g->window;
error = xwimp_get_window_state(&state);
if (error) {
LOG(("xwimp_get_window_state: 0x%x: %s",
error->errnum, error->errmess));
warn_user("WimpError", error->errmess);
return 800;
}
return (state.visible.y1 - state.visible.y0 - (g->toolbar ?
ro_gui_theme_toolbar_full_height(g->toolbar) : 0)) /
2 / g->option.scale;
}
/**
* Set the extent of the inside of a browser window.
*
@ -1878,6 +1904,10 @@ bool ro_gui_window_keypress(struct gui_window *g, int key, bool toolbar)
}
return true;
case wimp_KEY_CONTROL + wimp_KEY_SHIFT + wimp_KEY_F9:
talloc_report_full(0, stderr);
return true;
case wimp_KEY_CONTROL + wimp_KEY_F9: /* Dump url_store. */
url_store_dump();
return true;
@ -2259,7 +2289,7 @@ void ro_gui_window_process_reformats(void)
continue;
content_reformat(g->bw->current_content,
g->old_width / 2 / g->option.scale,
1000);
gui_window_get_height(g));
g->reformat_pending = false;
}
gui_reformat_pending = false;