summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5b85d3a)
raw | patch | inline | side by side (parent: 5b85d3a)
author | tavmjong-free <tavmjong@free.fr> | |
Sat, 5 Jun 2010 14:09:41 +0000 (16:09 +0200) | ||
committer | tavmjong-free <tavmjong@free.fr> | |
Sat, 5 Jun 2010 14:09:41 +0000 (16:09 +0200) |
baseline-shift.
src/style.cpp | patch | blob | history |
diff --git a/src/style.cpp b/src/style.cpp
index f2686287184228017fadde3950814b4bd8024321..9c82b1b7a3bcbb60edb132dcf20e0c9c141c51ff 100644 (file)
--- a/src/style.cpp
+++ b/src/style.cpp
}
-/**
- *
+/*
+ * baseline-shift is relative to parent. The only time it should
+ * not be written out is if it is zero (or not set).
*/
static bool
-sp_baseline_shift_differ(SPIBaselineShift const *const a, SPIBaselineShift const *const b)
+sp_baseline_shift_notzero(SPIBaselineShift const *const a )
{
- if (a->type != b->type)
- return true;
- if (a->type == SP_BASELINE_SHIFT_LITERAL ) {
- if (a->literal != b->literal)
- return true;
- }
- if (a->type == SP_BASELINE_SHIFT_LENGTH) {
- if (a->unit == SP_CSS_UNIT_EM || a->unit == SP_CSS_UNIT_EX ) {
- if( a->value != b->value )
- return true;
- } else {
- if (a->computed != b->computed)
- return true;
+ if( a->type == SP_BASELINE_SHIFT_LITERAL ) {
+ if( a->literal == SP_CSS_BASELINE_SHIFT_BASELINE ) {
+ return false;
+ }
+ } else {
+ if( a->value == 0.0 ) {
+ return false;
}
}
- if (a->type == SP_BASELINE_SHIFT_PERCENTAGE) {
- if (a->value != b->value)
- return true;
- }
- return false;
+ return true;
}
-
/**
* Write SPIBaselineShift object into string.
*/
if ((flags & SP_STYLE_FLAG_ALWAYS)
|| ((flags & SP_STYLE_FLAG_IFSET) && val->set)
|| ((flags & SP_STYLE_FLAG_IFDIFF) && val->set
- && (!base->set || sp_baseline_shift_differ(val, base))))
+ && (!base->set || sp_baseline_shift_notzero(val) )))
{
if (val->inherit) {
return g_snprintf(p, len, "%s:inherit;", key);
} else if (val->type == SP_BASELINE_SHIFT_LITERAL) {
for (unsigned i = 0; enum_baseline_shift[i].key; i++) {
- if (enum_baseline_shift[i].value == static_cast< gint > (val->value) ) {
+ if (enum_baseline_shift[i].value == static_cast< gint > (val->literal) ) {
return g_snprintf(p, len, "%s:%s;", key, enum_baseline_shift[i].key);
}
}