From 798cda4430354143e90fb7ce81c3593a6dc24bc5 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah <> Date: Wed, 13 Jul 2016 08:12:57 +0530 Subject: Propagate changes to object tree with changes in style element (bzr r14949.1.46) --- src/style-internal.cpp | 200 ++++++++++++++++++++++--------------------------- 1 file changed, 90 insertions(+), 110 deletions(-) (limited to 'src/style-internal.cpp') diff --git a/src/style-internal.cpp b/src/style-internal.cpp index 62b0de52d..f25eb730e 100644 --- a/src/style-internal.cpp +++ b/src/style-internal.cpp @@ -58,6 +58,20 @@ using Inkscape::CSSOStringStream; // SPIBase -------------------------------------------------------------- +// Standard criteria for writing a property +// dfp == different from parent +inline bool should_write( guint const flags, bool set, bool dfp, bool src) { + + bool should_write = false; + if ( ((flags & SP_STYLE_FLAG_ALWAYS)) || + ((flags & SP_STYLE_FLAG_IFSET) && set && src) || + ((flags & SP_STYLE_FLAG_IFDIFF) && set && src && dfp)) { + should_write = true; + } + return should_write; +} + + // SPIFloat ------------------------------------------------------------- @@ -80,14 +94,12 @@ SPIFloat::read( gchar const *str ) { } const Glib::ustring -SPIFloat::write( guint const flags, SPIBase const *const base) const { +SPIFloat::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const { SPIFloat const *const my_base = dynamic_cast(base); - if ( (flags & SP_STYLE_FLAG_ALWAYS) || - ((flags & SP_STYLE_FLAG_IFSET) && this->set) || - ((flags & SP_STYLE_FLAG_IFDIFF) && this->set - && (!my_base->set || this != my_base ))) - { + bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent + bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC)); + if (should_write(flags, set, dfp, src)) { if (this->inherit) { return (name + ":inherit;"); } else { @@ -156,14 +168,12 @@ SPIScale24::read( gchar const *str ) { } const Glib::ustring -SPIScale24::write( guint const flags, SPIBase const *const base) const { +SPIScale24::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const { SPIScale24 const *const my_base = dynamic_cast(base); - if ( (flags & SP_STYLE_FLAG_ALWAYS) || - ((flags & SP_STYLE_FLAG_IFSET) && this->set) || - ((flags & SP_STYLE_FLAG_IFDIFF) && this->set - && (!my_base->set || this != my_base ))) - { + bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent + bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC)); + if (should_write(flags, set, dfp, src)) { if (this->inherit) { return (name + ":inherit;"); } else { @@ -308,14 +318,12 @@ SPILength::read( gchar const *str ) { } const Glib::ustring -SPILength::write( guint const flags, SPIBase const *const base) const { +SPILength::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const { SPILength const *const my_base = dynamic_cast(base); - if ( (flags & SP_STYLE_FLAG_ALWAYS) || - ((flags & SP_STYLE_FLAG_IFSET) && this->set) || - ((flags & SP_STYLE_FLAG_IFDIFF) && this->set - && (!my_base->set || this != my_base ))) - { + bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent + bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC)); + if (should_write(flags, set, dfp, src)) { if (this->inherit) { return (name + ":inherit;"); } else { @@ -465,18 +473,16 @@ SPILengthOrNormal::read( gchar const *str ) { }; const Glib::ustring -SPILengthOrNormal::write( guint const flags, SPIBase const *const base) const { +SPILengthOrNormal::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const { SPILength const *const my_base = dynamic_cast(base); - if ( (flags & SP_STYLE_FLAG_ALWAYS) || - ((flags & SP_STYLE_FLAG_IFSET) && this->set) || - ((flags & SP_STYLE_FLAG_IFDIFF) && this->set - && (!my_base->set || this != my_base ))) - { + bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent + bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC)); + if (should_write(flags, set, dfp, src)) { if (this->normal) { return (name + ":normal;"); } else { - return SPILength::write(flags, base); + return SPILength::write(flags, style_src_req, base); } } return Glib::ustring(""); @@ -552,14 +558,12 @@ SPIEnum::read( gchar const *str ) { } const Glib::ustring -SPIEnum::write( guint const flags, SPIBase const *const base) const { +SPIEnum::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const { SPIEnum const *const my_base = dynamic_cast(base); - if ( (flags & SP_STYLE_FLAG_ALWAYS) || - ((flags & SP_STYLE_FLAG_IFSET) && this->set) || - ((flags & SP_STYLE_FLAG_IFDIFF) && this->set - && (!my_base->set || this != my_base ))) - { + bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent + bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC)); + if (should_write(flags, set, dfp, src)) { if (this->inherit) { return (name + ":inherit;"); } @@ -691,14 +695,12 @@ SPIEnumBits::read( gchar const *str ) { } const Glib::ustring -SPIEnumBits::write( guint const flags, SPIBase const *const base) const { +SPIEnumBits::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const { SPIEnum const *const my_base = dynamic_cast(base); - if ( (flags & SP_STYLE_FLAG_ALWAYS) || - ((flags & SP_STYLE_FLAG_IFSET) && this->set) || - ((flags & SP_STYLE_FLAG_IFDIFF) && this->set - && (!my_base->set || this != my_base ))) - { + bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent + bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC)); + if (should_write(flags, set, dfp, src)) { if (this->inherit) { return (name + ":inherit;"); } @@ -762,14 +764,12 @@ SPILigatures::read( gchar const *str ) { } const Glib::ustring -SPILigatures::write( guint const flags, SPIBase const *const base) const { +SPILigatures::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const { SPIEnum const *const my_base = dynamic_cast(base); - if ( (flags & SP_STYLE_FLAG_ALWAYS) || - ((flags & SP_STYLE_FLAG_IFSET) && this->set) || - ((flags & SP_STYLE_FLAG_IFDIFF) && this->set - && (!my_base->set || this != my_base ))) - { + bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent + bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC)); + if (should_write(flags, set, dfp, src)) { if (this->inherit) { return (name + ":inherit;"); } @@ -863,14 +863,12 @@ SPINumeric::read( gchar const *str ) { } const Glib::ustring -SPINumeric::write( guint const flags, SPIBase const *const base) const { +SPINumeric::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const { SPIEnum const *const my_base = dynamic_cast(base); - if ( (flags & SP_STYLE_FLAG_ALWAYS) || - ((flags & SP_STYLE_FLAG_IFSET) && this->set) || - ((flags & SP_STYLE_FLAG_IFDIFF) && this->set - && (!my_base->set || this != my_base ))) - { + bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent + bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC)); + if (should_write(flags, set, dfp, src)) { if (this->inherit) { return (name + ":inherit;"); } @@ -934,14 +932,12 @@ SPIString::read( gchar const *str ) { // This routine is actually rarely used. Writing is done usually // in sp_repr_css_write_string... const Glib::ustring -SPIString::write( guint const flags, SPIBase const *const base) const { +SPIString::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const { SPIString const *const my_base = dynamic_cast(base); - if ( (flags & SP_STYLE_FLAG_ALWAYS) || - ((flags & SP_STYLE_FLAG_IFSET) && this->set) || - ((flags & SP_STYLE_FLAG_IFDIFF) && this->set - && (!my_base->set || this != my_base ))) - { + bool dfp = (!inherits || !my_base || (my_base != this) ); // Different from parent + bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC)); + if (should_write(flags, set, dfp, src)) { if (this->inherit) { return (name + ":inherit;"); } else { @@ -1045,14 +1041,12 @@ void SPIColor::read( gchar const *str ) { } const Glib::ustring -SPIColor::write( guint const flags, SPIBase const *const base) const { +SPIColor::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const { SPIColor const *const my_base = dynamic_cast(base); - if ( (flags & SP_STYLE_FLAG_ALWAYS) || - ((flags & SP_STYLE_FLAG_IFSET) && this->set) || - ((flags & SP_STYLE_FLAG_IFDIFF) && this->set - && (!my_base->set || this != my_base ))) - { + bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent + bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC)); + if (should_write(flags, set, dfp, src)) { CSSOStringStream css; if (this->currentcolor) { @@ -1274,14 +1268,12 @@ SPIPaint::read( gchar const *str, SPStyle &style_in, SPDocument *document_in ) { } const Glib::ustring -SPIPaint::write( guint const flags, SPIBase const *const base) const { +SPIPaint::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const { SPIPaint const *const my_base = dynamic_cast(base); - if ( (flags & SP_STYLE_FLAG_ALWAYS) || - ((flags & SP_STYLE_FLAG_IFSET) && this->set) || - ((flags & SP_STYLE_FLAG_IFDIFF) && this->set - && (!my_base->set || this != my_base ))) - { + bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent + bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC)); + if (should_write(flags, set, dfp, src)) { CSSOStringStream css; if (this->inherit) { @@ -1546,14 +1538,12 @@ SPIPaintOrder::read( gchar const *str ) { } const Glib::ustring -SPIPaintOrder::write( guint const flags, SPIBase const *const base) const { +SPIPaintOrder::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const { SPIPaintOrder const *const my_base = dynamic_cast(base); - if ( (flags & SP_STYLE_FLAG_ALWAYS) || - ((flags & SP_STYLE_FLAG_IFSET) && this->set) || - ((flags & SP_STYLE_FLAG_IFDIFF) && this->set - && (!my_base->set || this != my_base ))) - { + bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent + bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC)); + if (should_write(flags, set, dfp, src)) { CSSOStringStream css; if (this->inherit) { @@ -1694,14 +1684,14 @@ SPIFilter::read( gchar const *str ) { } } -const Glib::ustring SPIFilter::write( guint const flags, SPIBase const *const /*base*/) const +const Glib::ustring SPIFilter::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const /*base*/) const { // TODO: fix base //SPILength const *const my_base = dynamic_cast(base); - if ( (flags & SP_STYLE_FLAG_ALWAYS) || - ((flags & SP_STYLE_FLAG_IFSET) && this->set) || - ((flags & SP_STYLE_FLAG_IFDIFF) && this->set)) - { + // bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent + bool dfp = true; + bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC)); + if (should_write(flags, set, dfp, src)) { if (this->inherit) { return (name + ":inherit;"); } else if(this->href && this->href->getURI()) { @@ -1833,14 +1823,12 @@ SPIDashArray::read( gchar const *str ) { } const Glib::ustring -SPIDashArray::write( guint const flags, SPIBase const *const base) const { +SPIDashArray::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const { SPIDashArray const *const my_base = dynamic_cast(base); - if ( (flags & SP_STYLE_FLAG_ALWAYS) || - ((flags & SP_STYLE_FLAG_IFSET) && this->set) || - ((flags & SP_STYLE_FLAG_IFDIFF) && this->set - && (!my_base->set || this != my_base ))) - { + bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent + bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC)); + if (should_write(flags, set, dfp, src)) { if (this->inherit) { return (name + ":inherit;"); } else if (this->values.empty() ) { @@ -1950,14 +1938,12 @@ SPIFontSize::read( gchar const *str ) { } const Glib::ustring -SPIFontSize::write( guint const flags, SPIBase const *const base) const { +SPIFontSize::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const { SPIFontSize const *const my_base = dynamic_cast(base); - if ( (flags & SP_STYLE_FLAG_ALWAYS) || - ((flags & SP_STYLE_FLAG_IFSET) && this->set) || - ((flags & SP_STYLE_FLAG_IFDIFF) && this->set - && (!my_base->set || this != my_base ))) - { + bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent + bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC)); + if (should_write(flags, set, dfp, src)) { CSSOStringStream css; if (this->inherit) { @@ -2244,7 +2230,7 @@ SPIFont::read( gchar const *str ) { } } -const Glib::ustring SPIFont::write( guint const /*flags*/, SPIBase const *const /*base*/) const +const Glib::ustring SPIFont::write( guint const /*flags*/, SPStyleSrc const & /*style_src_req*/, SPIBase const *const /*base*/) const { // At the moment, do nothing. We could add a preference to write out // 'font' shorthand rather than longhand properties. @@ -2321,14 +2307,12 @@ SPIBaselineShift::read( gchar const *str ) { } const Glib::ustring -SPIBaselineShift::write( guint const flags, SPIBase const *const base) const { +SPIBaselineShift::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const { SPIBaselineShift const *const my_base = dynamic_cast(base); - if ( (flags & SP_STYLE_FLAG_ALWAYS) || - ((flags & SP_STYLE_FLAG_IFSET) && this->set) || - ((flags & SP_STYLE_FLAG_IFDIFF) && this->set - && (!my_base->set || !this->isZero() ))) - { + bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent + bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC)); + if (should_write(flags, set, dfp, src)) { CSSOStringStream css; if (this->inherit) { @@ -2512,13 +2496,11 @@ SPITextDecorationLine::read( gchar const *str ) { } const Glib::ustring -SPITextDecorationLine::write( guint const flags, SPIBase const *const base) const { +SPITextDecorationLine::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const { SPITextDecorationLine const *const my_base = dynamic_cast(base); - if ( (flags & SP_STYLE_FLAG_ALWAYS) || - ((flags & SP_STYLE_FLAG_IFSET) && this->set) || - ((flags & SP_STYLE_FLAG_IFDIFF) && this->set - && (!my_base->set || this != my_base ))) - { + bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent + bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC)); + if (should_write(flags, set, dfp, src)) { Inkscape::CSSOStringStream os; os << name << ":"; if( inherit ) { @@ -2644,13 +2626,11 @@ SPITextDecorationStyle::read( gchar const *str ) { } const Glib::ustring -SPITextDecorationStyle::write( guint const flags, SPIBase const *const base) const { +SPITextDecorationStyle::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const { SPITextDecorationStyle const *const my_base = dynamic_cast(base); - if ( (flags & SP_STYLE_FLAG_ALWAYS) || - ((flags & SP_STYLE_FLAG_IFSET) && this->set) || - ((flags & SP_STYLE_FLAG_IFDIFF) && this->set - && (!my_base->set || this != my_base ))) - { + bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent + bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC)); + if (should_write(flags, set, dfp, src)) { Inkscape::CSSOStringStream os; os << name << ":"; if( inherit ) { @@ -2800,7 +2780,7 @@ SPITextDecoration::read( gchar const *str ) { // Returns CSS2 'text-decoration' (using settings in SPTextDecorationLine) // This is required until all SVG renderers support CSS3 'text-decoration' const Glib::ustring -SPITextDecoration::write( guint const flags, SPIBase const *const base) const { +SPITextDecoration::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const { SPITextDecoration const *const my_base = dynamic_cast(base); if ( (flags & SP_STYLE_FLAG_ALWAYS) || ((flags & SP_STYLE_FLAG_IFSET) && style->text_decoration_line.set) || -- cgit v1.2.3 From f35bb1f74a0ffeb5c6477a25e3c4cde87a97bcf1 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 28 Jul 2016 12:06:06 +0200 Subject: Removed unused includes, decrease compilation time (bzr r15025) --- src/style-internal.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/style-internal.cpp') diff --git a/src/style-internal.cpp b/src/style-internal.cpp index 62b0de52d..136a522f8 100644 --- a/src/style-internal.cpp +++ b/src/style-internal.cpp @@ -23,16 +23,14 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include #endif #include "style-internal.h" -#include "style-enums.h" #include "style.h" #include "svg/svg.h" #include "svg/svg-color.h" -#include "svg/svg-icc-color.h" #include "streq.h" #include "strneq.h" @@ -42,9 +40,6 @@ #include "svg/css-ostringstream.h" #include "util/units.h" -#include -#include - #include // TODO REMOVE OR MAKE MEMBER FUNCTIONS -- cgit v1.2.3 From 43b49e325db73cc19b1731db6c69545664ee8fbe Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 28 Jul 2016 13:26:17 +0200 Subject: Reverted changes to r15024 after many building problems (bzr r15027) --- src/style-internal.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/style-internal.cpp') diff --git a/src/style-internal.cpp b/src/style-internal.cpp index 136a522f8..62b0de52d 100644 --- a/src/style-internal.cpp +++ b/src/style-internal.cpp @@ -23,14 +23,16 @@ */ #ifdef HAVE_CONFIG_H -#include +# include "config.h" #endif #include "style-internal.h" +#include "style-enums.h" #include "style.h" #include "svg/svg.h" #include "svg/svg-color.h" +#include "svg/svg-icc-color.h" #include "streq.h" #include "strneq.h" @@ -40,6 +42,9 @@ #include "svg/css-ostringstream.h" #include "util/units.h" +#include +#include + #include // TODO REMOVE OR MAKE MEMBER FUNCTIONS -- cgit v1.2.3 From 35830f456cadaecf8b8e3944e3031a1a93f6cb41 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Wed, 3 Aug 2016 15:29:38 +0200 Subject: Removed unused includes, decreased compilation time. Once again (bzr r15034) --- src/style-internal.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/style-internal.cpp') diff --git a/src/style-internal.cpp b/src/style-internal.cpp index 62b0de52d..136a522f8 100644 --- a/src/style-internal.cpp +++ b/src/style-internal.cpp @@ -23,16 +23,14 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include #endif #include "style-internal.h" -#include "style-enums.h" #include "style.h" #include "svg/svg.h" #include "svg/svg-color.h" -#include "svg/svg-icc-color.h" #include "streq.h" #include "strneq.h" @@ -42,9 +40,6 @@ #include "svg/css-ostringstream.h" #include "util/units.h" -#include -#include - #include // TODO REMOVE OR MAKE MEMBER FUNCTIONS -- cgit v1.2.3 From 0bceae549cc912f571a2c422fbb3f9764ff2cb1d Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Mon, 5 Sep 2016 12:33:37 +0300 Subject: Refactor == true (bzr r15100.1.16) --- src/style-internal.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/style-internal.cpp') diff --git a/src/style-internal.cpp b/src/style-internal.cpp index 136a522f8..5a2a2f913 100644 --- a/src/style-internal.cpp +++ b/src/style-internal.cpp @@ -1555,7 +1555,7 @@ SPIPaintOrder::write( guint const flags, SPIBase const *const base) const { css << "inherit"; } else { for( unsigned i = 0; i < PAINT_ORDER_LAYERS; ++i ) { - if( this->layer_set[i] == true ) { + if( layer_set[i] ) { switch (this->layer[i]) { case SP_CSS_PAINT_ORDER_NORMAL: css << "normal"; @@ -2787,7 +2787,7 @@ SPITextDecoration::read( gchar const *str ) { } // If we set text_decoration_line, then update style_td (for CSS2 text-decoration) - if( style->text_decoration_line.set == true ) { + if( style->text_decoration_line.set ) { style_td = style; } } -- cgit v1.2.3 From 349536d49558ec5841e799eb33a4cbbb3fa9722d Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 5 Feb 2017 16:04:35 +0000 Subject: Fix C++11 errors and warnings with g++-7 Fixed bugs: - https://launchpad.net/bugs/1660992 (bzr r15477) --- src/style-internal.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/style-internal.cpp') diff --git a/src/style-internal.cpp b/src/style-internal.cpp index a6ccdf376..54d1a0867 100644 --- a/src/style-internal.cpp +++ b/src/style-internal.cpp @@ -27,6 +27,10 @@ #endif #include "style-internal.h" + +#include + +#include "bad-uri-exception.h" #include "style.h" #include "svg/svg.h" @@ -40,8 +44,6 @@ #include "svg/css-ostringstream.h" #include "util/units.h" -#include - // TODO REMOVE OR MAKE MEMBER FUNCTIONS void sp_style_fill_paint_server_ref_changed( SPObject *old_ref, SPObject *ref, SPStyle *style); void sp_style_stroke_paint_server_ref_changed(SPObject *old_ref, SPObject *ref, SPStyle *style); -- cgit v1.2.3