aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/html.cc1
-rw-r--r--src/html_common.hh6
-rw-r--r--src/table.cc34
3 files changed, 38 insertions, 3 deletions
diff --git a/src/html.cc b/src/html.cc
index 8019b4ef..11ad98e3 100644
--- a/src/html.cc
+++ b/src/html.cc
@@ -428,6 +428,7 @@ DilloHtml::DilloHtml(BrowserWindow *p_bw, const DilloUrl *url,
stack->increase();
stack->getRef(0)->parse_mode = DILLO_HTML_PARSE_MODE_INIT;
stack->getRef(0)->table_mode = DILLO_HTML_TABLE_MODE_NONE;
+ stack->getRef(0)->table_border_mode = DILLO_HTML_TABLE_BORDER_SEPARATE;
stack->getRef(0)->cell_text_align_set = false;
stack->getRef(0)->list_type = HTML_LIST_NONE;
stack->getRef(0)->list_number = 0;
diff --git a/src/html_common.hh b/src/html_common.hh
index bfcb8123..cf5c8114 100644
--- a/src/html_common.hh
+++ b/src/html_common.hh
@@ -64,6 +64,11 @@ typedef enum {
} DilloHtmlTableMode;
typedef enum {
+ DILLO_HTML_TABLE_BORDER_SEPARATE,
+ DILLO_HTML_TABLE_BORDER_COLLAPSE
+} DilloHtmlTableBorderMode;
+
+typedef enum {
HTML_LIST_NONE,
HTML_LIST_UNORDERED,
HTML_LIST_ORDERED
@@ -96,6 +101,7 @@ struct _DilloHtmlImage {
struct _DilloHtmlState {
DilloHtmlParseMode parse_mode;
DilloHtmlTableMode table_mode;
+ DilloHtmlTableBorderMode table_border_mode;
bool cell_text_align_set;
DilloHtmlListMode list_type;
diff --git a/src/table.cc b/src/table.cc
index 1029c9f6..d21f8d74 100644
--- a/src/table.cc
+++ b/src/table.cc
@@ -139,6 +139,7 @@ void Html_tag_open_table(DilloHtml *html, const char *tag, int tagsize)
HT2TB(html)->addWidget (table, html->styleEngine->style ());
S_TOP(html)->table_mode = DILLO_HTML_TABLE_MODE_TOP;
+ S_TOP(html)->table_border_mode = DILLO_HTML_TABLE_BORDER_SEPARATE;
S_TOP(html)->cell_text_align_set = FALSE;
S_TOP(html)->table = table;
}
@@ -216,6 +217,34 @@ void Html_tag_open_th(DilloHtml *html, const char *tag, int tagsize)
* Utilities
*/
+/*
+ * The table border model is stored in the table's stack item
+ */
+static int Html_table_get_border_model(DilloHtml *html)
+{
+ static int i_TABLE = -1;
+ if (i_TABLE == -1)
+ i_TABLE = a_Html_tag_index("table");
+
+ int s_idx = html->stack->size();
+ while (--s_idx > 0 && html->stack->getRef(s_idx)->tag_idx != i_TABLE)
+ ;
+ return html->stack->getRef(s_idx)->table_border_mode;
+}
+
+/*
+ * Set current table's border model
+ */
+static void Html_table_set_border_model(DilloHtml *html,
+ DilloHtmlTableBorderMode mode)
+{
+ int s_idx = html->stack->size(), i_TABLE = a_Html_tag_index("table");
+
+ while (--s_idx > 0 && html->stack->getRef(s_idx)->tag_idx != i_TABLE) ;
+ if (s_idx > 0)
+ html->stack->getRef(s_idx)->table_border_mode = mode;
+}
+
/* WORKAROUND: collapsing border model requires moving rendering code from
* the cell to the table, and making table-code aware of each
* cell style.
@@ -243,11 +272,10 @@ static void Html_set_collapsing_border_model(DilloHtml *html, Widget *col_tb)
collapseStyle = Style::create(HT2LT(html), &collapseCellAttrs);
col_tb->setStyle (collapseStyle);
- if (!tableStyle->collapseStyleSet) {
+ if (Html_table_get_border_model(html) != DILLO_HTML_TABLE_BORDER_COLLAPSE) {
+ Html_table_set_border_model(html, DILLO_HTML_TABLE_BORDER_COLLAPSE);
collapseTableAttrs = *tableStyle;
- collapseTableAttrs.collapseStyleSet = true;
collapseTableAttrs.margin.setVal (marginWidth);
- _MSG("COLLAPSING table margin set to %d\n", marginWidth);
collapseTableAttrs.borderWidth.left = borderWidth;
collapseTableAttrs.borderWidth.top = borderWidth;
collapseTableAttrs.borderWidth.right = 0;