Closed Bug 340835 Opened 18 years ago Closed 12 years ago

Allow new-world SVG data types to be stored in nsAttrValue

Categories

(Core :: SVG, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 629200
Tracking Status
status2.0 --- wanted

People

(Reporter: tor, Unassigned)

References

Details

Attachments

(2 files)

The previous heavyweight SVG data types stored a nsISupports based object in nsAttrValue with the nsISVGValue interface.  We would like to do the same for the redone versions to allow us to avoid always storing the string of an attribute value.  As the new data types are members of the parent element rather than dynamically allocated, we need to store a pointer to this in nsAttrValue.  Jonas, is it a safe assumption that nsAttrValues will not outlive the corresponding element, or do they have sharing or other complications?
Attachment #224870 - Flags: review?(bugmail)
Comment on attachment 224870 [details] [diff] [review]
store new svg data types in nsAttrValue

Yes, that is a safe assumption. The nsAttrValue lifetime is decided by the nsAttrAndChildArray, which has the same lifetime as the element (the array dies first).

However, why do we need two svg types? Could nsSVGValue2 replace nsISVGValue entierly, or at least in nsAttrValue?

r=me
Eventually we want to reach one svg type, but at the moment we have a mix in the tree.
Comment on attachment 224870 [details] [diff] [review]
store new svg data types in nsAttrValue

Ok, cool
Attachment #224870 - Flags: review?(bugmail) → review+
Attachment #224870 - Flags: superreview?(roc)
This will make nsSVGLength2 grow one vtable pointer. I don't like that.

If we always know the element and attribute name for the nsAttrValue we're looking at, nsAttrValue doesn't need anything other than the type "I'm the SVG data!" and then we can get ask the SVG element to give us the string value from its internal data.
Comment on attachment 226159 [details] [diff] [review]
alternate approach by overloading GetAttr

I don't like this. First of all I think it'll break cloning, and there are probably other things that go directly to the nsAttrAndChildArray. Mutation events is another thing that comes to mind.

In general we've gone down the path of unserializable nsAttrValues before, and it was very nice to get rid of that.

Could you subclass nsSVGLength2 specifically for when they need to be put in nsAttrValue?
Attachment #226159 - Flags: review-
Another approach would be to add the new types directly to nsAttrValue, avoiding the need to add a virtual method.

We need to decide whether it's worthwhile doing this mild normalization of attributes, which gives us a benefit in terms of memory footprint, but breaks DOM round-tripping of attribute values.
(In reply to comment #8)
> We need to decide whether it's worthwhile doing this mild normalization of
> attributes, which gives us a benefit in terms of memory footprint, but breaks
> DOM round-tripping of attribute values.

This is really an independent question. I think you should take it up with the SVG WG.
Well, I guess it's not independent in the sense that if the WG says "you have to be able to round-trip 100% accurately" then we don't need to resolve this bug.
Attachment #224870 - Flags: superreview?(roc)
QA Contact: ian → general
Under nsSVGElement::DidChangeXxx 
we currently serialize the internal structure, then pass the serialization to SettAttr, which parses it, then repopulates the internal structures. That's pretty bad, especially in the case of list types such as SVGAnimatedLengthList and SVGAnimatedPathSegList. I'd really like to have an nsAttrValue type that, when the internal objects change, we can tell "throw away the string and, if someone asks for it later, serialize on demand".

I think that we do still want to keep the original strings unless the SVG DOM structure is changed, since content authors don't like attributes to be normalized unnecessarily.
Assignee: tor → nobody
I think we do something very similar for style attributes. For the exact same reason.
Thanks for the tip.
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: