summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--css/select.c163
-rw-r--r--render/layout.c50
2 files changed, 97 insertions, 116 deletions
diff --git a/css/select.c b/css/select.c
index 12e25d536..5f20a30c4 100644
--- a/css/select.c
+++ b/css/select.c
@@ -1762,28 +1762,93 @@ css_error node_presentational_hint(void *pw, void *node,
strcmp((const char *) n->name, "h3") == 0 ||
strcmp((const char *) n->name, "h4") == 0 ||
strcmp((const char *) n->name, "h5") == 0 ||
- strcmp((const char *) n->name, "h6") == 0)
+ strcmp((const char *) n->name, "h6") == 0) {
align = xmlGetProp(n, (const xmlChar *) "align");
- if (align == NULL)
- return CSS_PROPERTY_NOT_SET;
+ if (align == NULL)
+ return CSS_PROPERTY_NOT_SET;
+
+ if (strcmp((const char *) align, "left") == 0) {
+ hint->status = CSS_TEXT_ALIGN_LEFT;
+ } else if (strcmp((const char *) align,
+ "center") == 0) {
+ hint->status = CSS_TEXT_ALIGN_CENTER;
+ } else if (strcmp((const char *) align, "right") == 0) {
+ hint->status = CSS_TEXT_ALIGN_RIGHT;
+ } else if (strcmp((const char *) align,
+ "justify") == 0) {
+ hint->status = CSS_TEXT_ALIGN_JUSTIFY;
+ } else {
+ xmlFree(align);
+ return CSS_PROPERTY_NOT_SET;
+ }
- if (strcmp((const char *) align, "left") == 0) {
- hint->status = CSS_TEXT_ALIGN_LEFT;
- } else if (strcmp((const char *) align, "center") == 0) {
- hint->status = CSS_TEXT_ALIGN_CENTER;
- } else if (strcmp((const char *) align, "right") == 0) {
- hint->status = CSS_TEXT_ALIGN_RIGHT;
- } else if (strcmp((const char *) align, "justify") == 0) {
- hint->status = CSS_TEXT_ALIGN_JUSTIFY;
- } else {
xmlFree(align);
- return CSS_PROPERTY_NOT_SET;
- }
- xmlFree(align);
+ return CSS_OK;
+ } else if (strcmp((const char *) n->name, "center") == 0) {
+ hint->status = CSS_TEXT_ALIGN_LIBCSS_CENTER;
- return CSS_OK;
+ return CSS_OK;
+ } else if (strcmp((const char *) n->name, "caption") == 0) {
+ align = xmlGetProp(n, (const xmlChar *) "align");
+
+ if (align == NULL || strcmp((const char *) align,
+ "center") == 0) {
+ hint->status = CSS_TEXT_ALIGN_LIBCSS_CENTER;
+ } else if (strcmp((const char *) align, "left") == 0) {
+ hint->status = CSS_TEXT_ALIGN_LIBCSS_LEFT;
+ } else if (strcmp((const char *) align, "right") == 0) {
+ hint->status = CSS_TEXT_ALIGN_LIBCSS_RIGHT;
+ } else if (strcmp((const char *) align,
+ "justify") == 0) {
+ hint->status = CSS_TEXT_ALIGN_JUSTIFY;
+ } else {
+ xmlFree(align);
+ return CSS_PROPERTY_NOT_SET;
+ }
+
+ if (align != NULL)
+ xmlFree(align);
+
+ return CSS_OK;
+ } else if (strcmp((const char *) n->name, "div") == 0 ||
+ strcmp((const char *) n->name, "thead") == 0 ||
+ strcmp((const char *) n->name, "tbody") == 0 ||
+ strcmp((const char *) n->name, "tfoot") == 0 ||
+ strcmp((const char *) n->name, "tr") == 0 ||
+ strcmp((const char *) n->name, "td") == 0 ||
+ strcmp((const char *) n->name, "th") == 0) {
+ align = xmlGetProp(n, (const xmlChar *) "align");
+
+ if (align == NULL)
+ return CSS_PROPERTY_NOT_SET;
+
+ if (strcmp((const char *) align, "center") == 0) {
+ hint->status = CSS_TEXT_ALIGN_LIBCSS_CENTER;
+ } else if (strcmp((const char *) align, "left") == 0) {
+ hint->status = CSS_TEXT_ALIGN_LIBCSS_LEFT;
+ } else if (strcmp((const char *) align, "right") == 0) {
+ hint->status = CSS_TEXT_ALIGN_LIBCSS_RIGHT;
+ } else if (strcmp((const char *) align,
+ "justify") == 0) {
+ hint->status = CSS_TEXT_ALIGN_JUSTIFY;
+ } else {
+ xmlFree(align);
+ return CSS_PROPERTY_NOT_SET;
+ }
+
+ xmlFree(align);
+
+ return CSS_OK;
+ } else if (strcmp((const char *) n->name, "table") == 0) {
+ /* Tables reset alignment */
+ hint->status = CSS_TEXT_ALIGN_DEFAULT;
+
+ return CSS_OK;
+ } else {
+ return CSS_PROPERTY_NOT_SET;
+ }
} else if (property == CSS_PROP_VERTICAL_ALIGN) {
xmlChar *valign = NULL;
@@ -1853,72 +1918,6 @@ css_error node_presentational_hint(void *pw, void *node,
return CSS_OK;
}
- } else if (property == CSS_PROP_LIBCSS_ALIGN) {
- xmlChar *align = NULL;
-
- if (strcmp((const char *) n->name, "center") == 0) {
- hint->status = CSS_LIBCSS_ALIGN_CENTER;
-
- return CSS_OK;
- } else if (strcmp((const char *) n->name, "caption") == 0) {
- align = xmlGetProp(n, (const xmlChar *) "align");
-
- if (align == NULL || strcmp((const char *) align,
- "center") == 0) {
- hint->status = CSS_LIBCSS_ALIGN_CENTER;
- } else if (strcmp((const char *) align, "left") == 0) {
- hint->status = CSS_LIBCSS_ALIGN_LEFT;
- } else if (strcmp((const char *) align, "right") == 0) {
- hint->status = CSS_LIBCSS_ALIGN_RIGHT;
- } else if (strcmp((const char *) align,
- "justify") == 0) {
- hint->status = CSS_LIBCSS_ALIGN_JUSTIFY;
- } else {
- xmlFree(align);
- return CSS_PROPERTY_NOT_SET;
- }
-
- if (align != NULL)
- xmlFree(align);
-
- return CSS_OK;
- } else if (strcmp((const char *) n->name, "div") == 0 ||
- strcmp((const char *) n->name, "thead") == 0 ||
- strcmp((const char *) n->name, "tbody") == 0 ||
- strcmp((const char *) n->name, "tfoot") == 0 ||
- strcmp((const char *) n->name, "tr") == 0 ||
- strcmp((const char *) n->name, "td") == 0 ||
- strcmp((const char *) n->name, "th") == 0) {
- align = xmlGetProp(n, (const xmlChar *) "align");
-
- if (align == NULL)
- return CSS_PROPERTY_NOT_SET;
-
- if (strcmp((const char *) align, "center") == 0) {
- hint->status = CSS_LIBCSS_ALIGN_CENTER;
- } else if (strcmp((const char *) align, "left") == 0) {
- hint->status = CSS_LIBCSS_ALIGN_LEFT;
- } else if (strcmp((const char *) align, "right") == 0) {
- hint->status = CSS_LIBCSS_ALIGN_RIGHT;
- } else if (strcmp((const char *) align,
- "justify") == 0) {
- hint->status = CSS_LIBCSS_ALIGN_JUSTIFY;
- } else {
- xmlFree(align);
- return CSS_PROPERTY_NOT_SET;
- }
-
- xmlFree(align);
-
- return CSS_OK;
- } else if (strcmp((const char *) n->name, "table") == 0) {
- /* Tables reset HTML alignment */
- hint->status = CSS_LIBCSS_ALIGN_DEFAULT;
-
- return CSS_OK;
- } else {
- return CSS_PROPERTY_NOT_SET;
- }
}
return CSS_PROPERTY_NOT_SET;
diff --git a/render/layout.c b/render/layout.c
index bd3ba830b..ee24ba0fe 100644
--- a/render/layout.c
+++ b/render/layout.c
@@ -1072,27 +1072,23 @@ int layout_solve_width(struct box *box, int available_width, int width,
/* Width was not auto, or was constrained by min/max width
* Need to compute left/right margins */
- /* HTML alignment (only applies to over-constrained boxes)
- * Additionally, we ignore HTML alignment for any boxes whose
- * parent has non-default text-align. */
+ /* HTML alignment (only applies to over-constrained boxes) */
if (box->margin[LEFT] != AUTO && box->margin[RIGHT] != AUTO &&
- box->parent != NULL && box->parent->style != NULL &&
- css_computed_text_align(box->parent->style) ==
- CSS_TEXT_ALIGN_DEFAULT) {
- switch (css_computed_libcss_align(box->parent->style)) {
- case CSS_LIBCSS_ALIGN_RIGHT:
+ box->parent != NULL && box->parent->style != NULL) {
+ switch (css_computed_text_align(box->parent->style)) {
+ case CSS_TEXT_ALIGN_LIBCSS_RIGHT:
box->margin[LEFT] = AUTO;
box->margin[RIGHT] = 0;
break;
- case CSS_LIBCSS_ALIGN_CENTER:
+ case CSS_TEXT_ALIGN_LIBCSS_CENTER:
box->margin[LEFT] = box->margin[RIGHT] = AUTO;
break;
- case CSS_LIBCSS_ALIGN_LEFT:
- case CSS_LIBCSS_ALIGN_JUSTIFY:
+ case CSS_TEXT_ALIGN_LIBCSS_LEFT:
box->margin[LEFT] = 0;
box->margin[RIGHT] = AUTO;
break;
- case CSS_LIBCSS_ALIGN_DEFAULT:
+ default:
+ /* Leave it alone; no HTML alignment */
break;
}
}
@@ -2449,40 +2445,26 @@ bool layout_line(struct box *first, int *width, int *y,
/* set positions */
switch (css_computed_text_align(first->parent->parent->style)) {
case CSS_TEXT_ALIGN_RIGHT:
+ case CSS_TEXT_ALIGN_LIBCSS_RIGHT:
x0 = x1 - x;
break;
case CSS_TEXT_ALIGN_CENTER:
+ case CSS_TEXT_ALIGN_LIBCSS_CENTER:
x0 = (x0 + (x1 - x)) / 2;
break;
case CSS_TEXT_ALIGN_LEFT:
+ case CSS_TEXT_ALIGN_LIBCSS_LEFT:
case CSS_TEXT_ALIGN_JUSTIFY:
/* leave on left */
break;
case CSS_TEXT_ALIGN_DEFAULT:
- /* No specified text-align; consider html alignment */
- switch (css_computed_libcss_align(
- first->parent->parent->style)) {
- case CSS_LIBCSS_ALIGN_RIGHT:
- x0 = x1 - x;
- break;
- case CSS_LIBCSS_ALIGN_CENTER:
- x0 = (x0 + (x1 - x)) / 2;
- break;
- case CSS_LIBCSS_ALIGN_LEFT:
- case CSS_LIBCSS_ALIGN_JUSTIFY:
+ /* None; consider text direction */
+ switch (css_computed_direction(first->parent->parent->style)) {
+ case CSS_DIRECTION_LTR:
/* leave on left */
break;
- case CSS_LIBCSS_ALIGN_DEFAULT:
- /* None; consider text direction */
- switch (css_computed_direction(
- first->parent->parent->style)) {
- case CSS_DIRECTION_LTR:
- /* leave on left */
- break;
- case CSS_DIRECTION_RTL:
- x0 = x1 - x;
- break;
- }
+ case CSS_DIRECTION_RTL:
+ x0 = x1 - x;
break;
}
break;