diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2014-12-25 16:05:40 +0000 |
|---|---|---|
| committer | tavmjong-free <tavmjong@free.fr> | 2014-12-25 16:05:40 +0000 |
| commit | 3598d85ed64693808296324289a2d6e5284d486e (patch) | |
| tree | 41d6829e1d3eecdf03c276b868e725c644312628 /src | |
| parent | Remove sp_style_write_string() and sp_style_write_difference(). (diff) | |
| download | inkscape-3598d85ed64693808296324289a2d6e5284d486e.tar.gz inkscape-3598d85ed64693808296324289a2d6e5284d486e.zip | |
Remove sp_style_merge_from_parent() and sp_style_merge_from_dying_parent().
(bzr r13822.1.5)
Diffstat (limited to 'src')
| -rw-r--r-- | src/sp-item-group.cpp | 7 | ||||
| -rw-r--r-- | src/sp-object.cpp | 2 | ||||
| -rw-r--r-- | src/sp-tref.cpp | 8 | ||||
| -rw-r--r-- | src/sp-use.cpp | 7 | ||||
| -rw-r--r-- | src/style.cpp | 81 | ||||
| -rw-r--r-- | src/style.h | 4 |
6 files changed, 36 insertions, 73 deletions
diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 45e5747d6..acf8b2012 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -444,7 +444,7 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) // it here _before_ the new transform is set, so as to use the pre-transform bbox citem->adjust_paint_recursive (Geom::identity(), Geom::identity(), false); - sp_style_merge_from_dying_parent(child->style, group->style); + child->style->merge( group->style ); /* * fixme: We currently make no allowance for the case where child is cloned * and the group has any style settings. @@ -453,9 +453,8 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) * version of inkscape without using the XML editor: we usually apply group * style changes to children rather than to the group itself.) * - * If the group has no style settings, then - * sp_style_merge_from_dying_parent should be a no-op. Otherwise (i.e. if - * we change the child's style to compensate for its parent going away) + * If the group has no style settings, then style->merge() should be a no-op. Otherwise + * (i.e. if we change the child's style to compensate for its parent going away) * then those changes will typically be reflected in any clones of child, * whereas we'd prefer for Ungroup not to affect the visual appearance. * diff --git a/src/sp-object.cpp b/src/sp-object.cpp index d492e7817..af8855562 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -1145,7 +1145,7 @@ void SPObject::updateDisplay(SPCtx *ctx, unsigned int flags) */ if ((flags & SP_OBJECT_STYLE_MODIFIED_FLAG) && (flags & SP_OBJECT_PARENT_MODIFIED_FLAG)) { if (this->style && this->parent) { - sp_style_merge_from_parent(this->style, this->parent->style); + style->cascade( this->parent->style ); } } diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index 0f6eb106f..6a229e170 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -492,12 +492,8 @@ sp_tref_convert_to_tspan(SPObject *obj) //SPObject * new_string_child = document->getObjectByRepr(new_string_repr); // Merge style from the tref - SPStyle *new_tspan_sty = new_tspan->style; - SPStyle const *tref_sty = tref->style; - sp_style_merge_from_dying_parent(new_tspan_sty, tref_sty); - sp_style_merge_from_parent(new_tspan_sty, new_tspan->parent->style); - - + new_tspan->style->merge( tref->style ); + new_tspan->style->cascade( new_tspan->parent->style ); new_tspan->updateRepr(); // Hold onto our SPObject and repr for now. diff --git a/src/sp-use.cpp b/src/sp-use.cpp index ba3f4a9d7..9b38a91c5 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -664,11 +664,8 @@ SPItem *SPUse::unlink() { SPObject *unlinked = document->getObjectByRepr(copy); // Merge style from the use. - SPStyle *unli_sty = unlinked->style; - SPStyle const *use_sty = this->style; - sp_style_merge_from_dying_parent(unli_sty, use_sty); - sp_style_merge_from_parent(unli_sty, unlinked->parent->style); - + unlinked->style->merge( this->style ); + unlinked->style->cascade( unlinked->parent->style ); unlinked->updateRepr(); // Hold onto our SPObject and repr for now. diff --git a/src/style.cpp b/src/style.cpp index a26c92e48..739c7bdb5 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -947,6 +947,17 @@ SPStyle::write( guint const flags, SPStyle const *const base ) const { } // Corresponds to sp_style_merge_from_parent() +/** + * Sets computed values in \a style, which may involve inheriting from (or in some other way + * calculating from) corresponding computed values of \a parent. + * + * References: http://www.w3.org/TR/SVG11/propidx.html shows what properties inherit by default. + * http://www.w3.org/TR/SVG11/styling.html#Inheritance gives general rules as to what it means to + * inherit a value. http://www.w3.org/TR/REC-CSS2/cascade.html#computed-value is more precise + * about what the computed value is (not obvious for lengths). + * + * \pre \a parent's computed values are already up-to-date. + */ void SPStyle::cascade( SPStyle const *const parent ) { // std::cout << "SPStyle::cascade: " << (object->getId()?object->getId():"null") << std::endl; @@ -959,6 +970,23 @@ SPStyle::cascade( SPStyle const *const parent ) { } // Corresponds to sp_style_merge_from_dying_parent() +/** + * Combine \a style and \a parent style specifications into a single style specification that + * preserves (as much as possible) the effect of the existing \a style being a child of \a parent. + * + * Called when the parent repr is to be removed (e.g. the parent is a \<use\> element that is being + * unlinked), in which case we copy/adapt property values that are explicitly set in \a parent, + * trying to retain the same visual appearance once the parent is removed. Interesting cases are + * when there is unusual interaction with the parent's value (opacity, display) or when the value + * can be specified as relative to the parent computed value (font-size, font-weight etc.). + * + * Doesn't update computed values of \a style. For correctness, you should subsequently call + * sp_style_merge_from_parent against the new parent (presumably \a parent's parent) even if \a + * style was previously up-to-date wrt \a parent. + * + * \pre \a parent's computed values are already up-to-date. + * (\a style's computed values needn't be up-to-date.) + */ void SPStyle::merge( SPStyle const *const parent ) { // std::cout << "SPStyle::merge" << std::endl; @@ -1268,62 +1296,9 @@ sp_repr_sel_eng() return ret; } - -// Called in text-editting.cpp, ui/tools/frehand-base.cpp, ui/widget/style-swatch.cpp - /** Indexed by SP_CSS_FONT_SIZE_blah. These seem a bit small */ static float const font_size_table[] = {6.0, 8.0, 10.0, 12.0, 14.0, 18.0, 24.0}; -// Called in sp-object.cpp, sp-tref.cpp, sp-use.cpp -/** - * Sets computed values in \a style, which may involve inheriting from (or in some other way - * calculating from) corresponding computed values of \a parent. - * - * References: http://www.w3.org/TR/SVG11/propidx.html shows what properties inherit by default. - * http://www.w3.org/TR/SVG11/styling.html#Inheritance gives general rules as to what it means to - * inherit a value. http://www.w3.org/TR/REC-CSS2/cascade.html#computed-value is more precise - * about what the computed value is (not obvious for lengths). - * - * \pre \a parent's computed values are already up-to-date. - */ -void -sp_style_merge_from_parent(SPStyle *const style, SPStyle const *const parent) -{ - // std::cout << "sp_style_merge_from_parent" << std::endl; - g_return_if_fail(style != NULL); - - if (!parent) - return; - - style->cascade( parent ); - return; -} - -// Called in: sp-use.cpp, sp-tref.cpp, sp-item.cpp -/** - * Combine \a style and \a parent style specifications into a single style specification that - * preserves (as much as possible) the effect of the existing \a style being a child of \a parent. - * - * Called when the parent repr is to be removed (e.g. the parent is a \<use\> element that is being - * unlinked), in which case we copy/adapt property values that are explicitly set in \a parent, - * trying to retain the same visual appearance once the parent is removed. Interesting cases are - * when there is unusual interaction with the parent's value (opacity, display) or when the value - * can be specified as relative to the parent computed value (font-size, font-weight etc.). - * - * Doesn't update computed values of \a style. For correctness, you should subsequently call - * sp_style_merge_from_parent against the new parent (presumably \a parent's parent) even if \a - * style was previously up-to-date wrt \a parent. - * - * \pre \a parent's computed values are already up-to-date. - * (\a style's computed values needn't be up-to-date.) - */ -void -sp_style_merge_from_dying_parent(SPStyle *const style, SPStyle const *const parent) -{ - // std::cout << "sp_style_merge_from_dying_parent" << std::endl; - style->merge( parent ); -} - // The following functions should be incorporated into SPIPaint. FIXME // Called in: style.cpp, style-internal.cpp void diff --git a/src/style.h b/src/style.h index 324b30523..c987a084a 100644 --- a/src/style.h +++ b/src/style.h @@ -288,10 +288,6 @@ SPStyle *sp_style_ref(SPStyle *style); // SPStyle::ref(); SPStyle *sp_style_unref(SPStyle *style); // SPStyle::unref(); -void sp_style_merge_from_parent(SPStyle *style, SPStyle const *parent); // SPStyle::cascade( ... ); - -void sp_style_merge_from_dying_parent(SPStyle *style, SPStyle const *parent); // SPStyle::merge( ... ) - void sp_style_set_to_uri_string (SPStyle *style, bool isfill, const char *uri); // ? char const *sp_style_get_css_unit_string(int unit); // No change? |
