It would be nice if we lived in a world without MSIE (Microsoft Internet Explorer) In particular, it would be nice if we lived in a world without MSIE's broken CSS. For example, there is a wonderful CSS attribute, called max-width, that lets a user specify the maximum width for a given element. Should the user have a narrow window (can you say 640x480), the element in question will just become narrower to fit this window. However, MSIE does not have support for this attribute. This is a feature that only 10% of the browsing population can make use of. The workaround looks like this: <table><tr> <td width=700> The content of a web site. </td></tr></table> The way all the mainstream browsers (MSIE, Opera, Konqueror/Safari, and all the Gecko browsers) handle this is as follows: * They consider the <td width=123> to be a suggestion. This is the maximum possible width for the element in question, as long as the table cell does not have any single elements (such as very long words) that are wider. * If the browser window (viewport) is wide enough to fit this element with the suggested width, the width is unchanged. * If the browser window is not wide enough to fit this element, the table cell will be made narrower to accomodate the narrow browser window. Dillo, however, does not support this /de facto/ standard. The following patch gives Dillo support for this standard. This patch doesn't do the rendering the correct way (which is to make sure all such TDs are not wider than the browser viewport window, barring long table elements), but it does make sure that a single table cell will not be wider than the Dillo browser window. This patch does not handle dynamic resizing, but will ensure that the TD hack will render (mostly) correctly in Dillo. - Sam --- dillo-0.8.4.orig/src/dw_gtk_viewport.c 2004-10-21 15:35:00.000000000 -0700 +++ dillo-0.8.4/src/dw_gtk_viewport.c 2005-03-02 19:04:07.954913184 -0800 @@ -56,6 +56,8 @@ static void Dw_gtk_viewport_adj_changed (GtkAdjustment *adj, GtkDwViewport *viewport); +int ext_window_width = -1; + /* * Standard Gtk+ function */ @@ -302,6 +304,7 @@ widget->allocation.height, viewport->depth); viewport->back_width = widget->allocation.width; + ext_window_width = viewport->back_width; viewport->back_height = widget->allocation.height; DEBUG_MSG (1, " Creating new pixmap, size = %d x %d\n", widget->allocation.width, widget->allocation.height); @@ -1165,6 +1168,7 @@ viewport_area.x = gtk_layout_get_hadjustment(layout)->value; viewport_area.y = gtk_layout_get_vadjustment(layout)->value;; viewport_area.width = widget->allocation.width; + ext_window_width = viewport_area.width; viewport_area.height = widget->allocation.height; if (p_Dw_rectangle_intersect (&viewport->draw_areas[i], --- dillo-0.8.4.orig/src/html.c 2005-01-05 13:01:00.000000000 -0800 +++ dillo-0.8.4/src/html.c 2005-03-02 19:25:16.673038712 -0800 @@ -132,6 +132,8 @@ } TagInfo; static const TagInfo Tags[]; +extern int ext_window_width; + /* * Return the line number of the tag being processed by the parser. */ @@ -1837,6 +1839,22 @@ if ((attrbuf = Html_get_attr(html, tag, tagsize, "width"))) { style_attrs.width = Html_parse_length (html, attrbuf); + /* In Netscape 4/MSIE/Gecko there is a complicated algorithm + * that makes sure all of the td widths are no wider than the + * screen; since MSIE 5/6 doesn't have the CSS max_width + * attribute, web designers still use td width=whatever to specify + * a maximum width. The following makes sure a single table cell + * is no wider than the browser window */ + if(DW_STYLE_IS_ABS_LENGTH(style_attrs.width)) { + int wide; + wide = DW_STYLE_ABS_LENGTH_VAL(style_attrs.width); + printf("------------%d %d\n",wide,ext_window_width); + if(wide > ext_window_width - 10 && + ext_window_width > 300) { + wide = ext_window_width - 10; + style_attrs.width = DW_STYLE_CREATE_ABS_LENGTH(wide); + } + } new_style = TRUE; }