Code

optimization: do not notify any listeners if attributes' new value is the same as old
[inkscape.git] / src / sp-item.cpp
index 7339160c7cb0351cb4a3f12e1cce9240257fb556..ab241a0cde9f32b7c0f4fe997992fadd74918548 100644 (file)
@@ -455,11 +455,15 @@ sp_item_set(SPObject *object, unsigned key, gchar const *value)
         case SP_ATTR_TRANSFORM_CENTER_X:
             if (value) {
                 item->transform_center_x = g_strtod(value, NULL);
+            } else {
+                item->transform_center_x = 0;
             }
             break;
         case SP_ATTR_TRANSFORM_CENTER_Y:
             if (value) {
                 item->transform_center_y = g_strtod(value, NULL);
+            } else {
+                item->transform_center_y = 0;
             }
             break;
         default:
@@ -499,6 +503,7 @@ clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item)
             nr_arena_item_set_clip(v->arenaitem, ai);
             nr_arena_item_unref(ai);
             sp_clippath_set_bbox(SP_CLIPPATH(clip), NR_ARENA_ITEM_GET_KEY(v->arenaitem), &bbox);
+            SP_OBJECT(clip)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
         }
     }
 }
@@ -674,6 +679,13 @@ sp_item_invoke_bbox_full(SPItem const *item, NRRect *bbox, NR::Matrix const &tra
     if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->bbox) {
         ((SPItemClass *) G_OBJECT_GET_CLASS(item))->bbox(item, bbox, transform, flags);
     }
+
+    // crop the bbox by clip path, if any
+    if (item->clip_ref->getObject()) {
+        NRRect b;
+        sp_clippath_get_bbox(SP_CLIPPATH(item->clip_ref->getObject()), &b, transform, flags);
+        nr_rect_d_intersect (bbox, bbox, &b);
+    }
 }
 
 unsigned sp_item_pos_in_parent(SPItem *item)