summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2014-05-13 13:21:10 +0000
committertavmjong-free <tavmjong@free.fr>2014-05-13 13:21:10 +0000
commitb15c7af34a2c4e440211006b4ea9d687be754525 (patch)
tree369ea189baf9454aa7ec0f6fb9821a7429743139 /src
parentextensions. guides_creator. scale units (Bug 1318532) (diff)
downloadinkscape-b15c7af34a2c4e440211006b4ea9d687be754525.tar.gz
inkscape-b15c7af34a2c4e440211006b4ea9d687be754525.zip
Style rewrite: prevent CSS2 'text-decoration' from overwriting CSS3 'text-decoration-xxx' values.
Fix some unused variable warnings. (bzr r13371)
Diffstat (limited to 'src')
-rw-r--r--src/style-internal.cpp55
-rw-r--r--src/style-internal.h10
2 files changed, 46 insertions, 19 deletions
diff --git a/src/style-internal.cpp b/src/style-internal.cpp
index 508fb677c..2c488105b 100644
--- a/src/style-internal.cpp
+++ b/src/style-internal.cpp
@@ -2405,27 +2405,47 @@ SPITextDecoration::read( gchar const *str ) {
if( !str ) return;
- style->text_decoration_line.read( str );
- style->text_decoration_style.read( str );
+ bool is_css3 = false;
+
+ SPITextDecorationLine test_line;
+ test_line.read( str );
+ if( test_line.set ) {
+ style->text_decoration_line = test_line;
+ }
+
+ SPITextDecorationStyle test_style;
+ test_style.read( str );
+ if( test_style.set ) {
+ style->text_decoration_style = test_style;
+ is_css3 = true;
+ }
+
// the color routine must be fed one token at a time - if multiple colors are found the LAST
// one is used ???? then why break on set?
- const gchar *hstr = str;
- style->text_decoration_color.read( "currentColor" ); // Default value
- style->text_decoration_color.set = false;
+ // This could certainly be designed better
+ SPIColor test_color("text-decoration-color");
+ test_color.setStylePointer( style );
+ test_color.read( "currentColor" ); // Default value
+ test_color.set = false;
+ const gchar *hstr = str;
while (1) {
if (*str == ' ' || *str == ',' || *str == '\0'){
int slen = str - hstr;
gchar *frag = g_strndup(hstr,slen+1); // only send one piece at a time, since keywords may be intermixed
if( strcmp( frag, "none" ) != 0 ) { // 'none' not allowed
- style->text_decoration_color.read( frag );
+ test_color.read( frag );
}
free(frag);
- if( style->text_decoration_color.set ) break;
- style->text_decoration_color.read( "currentColor" ); // Default value
- style->text_decoration_color.set = false;
+ if( test_color.set ) {
+ style->text_decoration_color = test_color;
+ is_css3 = true;
+ break;
+ }
+ test_color.read( "currentColor" ); // Default value
+ test_color.set = false;
if( *str == '\0' )break;
hstr = str + 1;
}
@@ -2434,8 +2454,7 @@ SPITextDecoration::read( gchar const *str ) {
// If we read a style or color then we have CSS3 which require any non-set values to be
// set to their default values.
- if( style->text_decoration_style.set == true ||
- style->text_decoration_style.set == true ) {
+ if( is_css3 ) {
style->text_decoration_line.set = true;
style->text_decoration_style.set = true;
style->text_decoration_color.set = true;
@@ -2491,9 +2510,17 @@ SPITextDecoration::cascade( const SPIBase* const parent ) {
}
-// void
-// SPITextDecoration::merge( const SPIBase* const parent ) {
-// }
+void
+SPITextDecoration::merge( const SPIBase* const parent ) {
+ if( const SPITextDecoration* p = dynamic_cast<const SPITextDecoration*>(parent) ) {
+ if( style_td == NULL ) {
+ style_td = p->style_td;
+ }
+ } else {
+ std::cerr << "SPITextDecoration::merge(): Incorrect parent type" << std::endl;
+ }
+
+}
// Use CSS2 value
bool
diff --git a/src/style-internal.h b/src/style-internal.h
index a806afc81..e76f9faaf 100644
--- a/src/style-internal.h
+++ b/src/style-internal.h
@@ -116,8 +116,8 @@ class SPIBase {
virtual const Glib::ustring write( guint const flags = SP_STYLE_FLAG_IFSET,
SPIBase const *const base = NULL ) const = 0;
virtual void clear() { set = false, inherit = false; };
- virtual void cascade( const SPIBase* const parent ) {};
- virtual void merge( const SPIBase* const parent ) {}; // To do: Set to 0
+ virtual void cascade( const SPIBase* const parent ) = 0;
+ virtual void merge( const SPIBase* const parent ) = 0;
virtual void setStylePointer( SPStyle *style_in ) { style = style_in; };
@@ -698,8 +698,8 @@ class SPIFont : public SPIBase {
virtual void clear() {
SPIBase::clear();
};
- virtual void cascade( const SPIBase* const parent ) {}; // Done in dependent properties
- virtual void merge( const SPIBase* const parent ) {};
+ virtual void cascade( const SPIBase* const parent ) { (void)parent; }; // Done in dependent properties
+ virtual void merge( const SPIBase* const parent ) { (void)parent; };
SPIFont& operator=(const SPIFont& rhs) {
SPIBase::operator=(rhs);
@@ -850,7 +850,7 @@ class SPITextDecoration : public SPIBase {
style_td = NULL;
};
virtual void cascade( const SPIBase* const parent );
- virtual void merge( const SPIBase* const parent ) {}; // FIX ME
+ virtual void merge( const SPIBase* const parent );
SPITextDecoration& operator=(const SPITextDecoration& rhs) {
SPIBase::operator=(rhs);