aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJorge Arellano Cid <jcid@dillo.org>2010-11-15 17:07:15 -0300
committerJorge Arellano Cid <jcid@dillo.org>2010-11-15 17:07:15 -0300
commitf83d4156fb156e73340e116360cfc3a9c1b3bd73 (patch)
treef05bb007528f8a9b2ae7669d01b5f12f7b3b5fa3
parent415a9c17ea71a0b4b53bbda1c39e495cf7ae2d1b (diff)
Moved the table border model flag from style to DilloHtmlState (i.e. stack)
-rw-r--r--dw/style.cc4
-rw-r--r--dw/style.hh1
-rw-r--r--src/html.cc1
-rw-r--r--src/html_common.hh6
-rw-r--r--src/table.cc34
5 files changed, 38 insertions, 8 deletions
diff --git a/dw/style.cc b/dw/style.cc
index 319ad239..011f5225 100644
--- a/dw/style.cc
+++ b/dw/style.cc
@@ -51,7 +51,6 @@ void StyleAttrs::initValues ()
borderWidth.setVal (0);
padding.setVal (0);
borderCollapse = BORDER_MODEL_SEPARATE;
- collapseStyleSet = false;
setBorderColor (NULL);
setBorderStyle (BORDER_NONE);
hBorderSpacing = 0;
@@ -127,7 +126,6 @@ bool StyleAttrs::equals (object::Object *other) {
borderWidth.equals (&otherAttrs->borderWidth) &&
padding.equals (&otherAttrs->padding) &&
borderCollapse == otherAttrs->borderCollapse &&
- collapseStyleSet == otherAttrs->collapseStyleSet &&
borderColor.top == otherAttrs->borderColor.top &&
borderColor.right == otherAttrs->borderColor.right &&
borderColor.bottom == otherAttrs->borderColor.bottom &&
@@ -164,7 +162,6 @@ int StyleAttrs::hashValue () {
borderWidth.hashValue () +
padding.hashValue () +
borderCollapse +
- collapseStyleSet +
(intptr_t) borderColor.top +
(intptr_t) borderColor.right +
(intptr_t) borderColor.bottom +
@@ -254,7 +251,6 @@ void Style::copyAttrs (StyleAttrs *attrs)
borderWidth = attrs->borderWidth;
padding = attrs->padding;
borderCollapse = attrs->borderCollapse;
- collapseStyleSet = attrs->collapseStyleSet;
borderColor = attrs->borderColor;
borderStyle = attrs->borderStyle;
display = attrs->display;
diff --git a/dw/style.hh b/dw/style.hh
index 2f6a98fc..36db0ab8 100644
--- a/dw/style.hh
+++ b/dw/style.hh
@@ -447,7 +447,6 @@ public:
Box margin, borderWidth, padding;
BorderCollapse borderCollapse;
- bool collapseStyleSet;
struct { Color *top, *right, *bottom, *left; } borderColor;
struct { BorderStyle top, right, bottom, left; } borderStyle;
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;