Closed Bug 367994 Opened 18 years ago Closed 2 years ago

Centralize SVG presentation attribute mapping

Categories

(Core :: SVG, defect)

x86
Linux
defect

Tracking

()

RESOLVED FIXED
113 Branch
Tracking Status
firefox113 --- fixed

People

(Reporter: tor, Assigned: longsonr)

References

(Blocks 1 open bug, )

Details

Attachments

(1 file, 7 obsolete files)

Currently we maintain the presentation attribute mapping at each SVG element implementation, in a overridden IsAttributeMapped. These maps have had maintenance problems, and are the inverse of the mapping tables in the specification. Moving all the mapping to nsSVGElement allows us to use the specification directly and should make for easier updates if we ever go to SVG 1.1+.
Attached patch central SVG IsAttributeMapped (obsolete) — Splinter Review
Attached patch remove colorProfile atom (obsolete) — Splinter Review
Attachment #252536 - Attachment is obsolete: true
Attachment #252537 - Attachment is obsolete: true
Attached patch update to tip (obsolete) — Splinter Review
Attachment #252614 - Attachment is obsolete: true
Attached patch missing atom changes in diff (obsolete) — Splinter Review
Attachment #253369 - Attachment is obsolete: true
Comment on attachment 253388 [details] [diff] [review] missing atom changes in diff >Index: content/base/src/nsGkAtomList.h >=================================================================== >RCS file: /cvsroot/mozilla/content/base/src/nsGkAtomList.h,v >retrieving revision 3.50 >diff -u -8 -p -r3.50 nsGkAtomList.h >--- content/base/src/nsGkAtomList.h 30 Jan 2007 13:19:53 -0000 3.50 >+++ content/base/src/nsGkAtomList.h 30 Jan 2007 21:38:55 -0000 >@@ -903,19 +903,20 @@ GK_ATOM(arithmetic, "arithmetic") > GK_ATOM(cm, "cm") >-GK_ATOM(colorInterpolation, "color-interpolation") >-GK_ATOM(colorInterpolationFilters, "color-interpolation-filters") >-GK_ATOM(colorProfile, "color-profile") >+GK_ATOM(color_interpolation,"color-interpolation") >+GK_ATOM(color_interpolation_filters,"color-interpolation-filters") >+GK_ATOM(color_profile,"color-profile") >+GK_ATOM(color_rendering,"color-rendering") Why move to underscores rather than camel case for some atom names? From my examination of this file, camel case is slightly more prevalent, though that's not much to go on. I do see that in layout\style we're mandated to use underscores. If underscores are the way to go then shouldn't you have a separate fix and make all SVG atom names consistent than picking some out? +static PRBool +CheckClass(nsIAtom *aTag, nsIAtom **aElements[]) Could you make the arguments const? I think I mean nsIAtom * const * in the second case as the elements are not modified. >+ * Centralized presentation attribute mapping for SVG. This allows us >+ * to use the tables from Appendex M of the SVG specification >+ * directly, instead of trying to maintain the inverse mapping. >+ * >+ * http://www.w3.org/TR/SVG11/attindex.html >+ * >+ * If this starts to show up in performance profiles, bits can be >+ * switched over to using hashtables. >+ */ >+ >+NS_IMETHODIMP_(PRBool) >+nsSVGElement::IsAttributeMapped(const nsIAtom* name) const >+{ >+ >+ static AttribMap presentationAttrib[] = { Could be const too I think. >+ static nsIAtom **elementsAll[] = { And nsIAtom * const * here? + for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(presentationAttrib); i++) { + if (name == *(presentationAttrib[i].mAtom)) + attribClass = presentationAttrib[i].mClass; break once you've got a match? + }
Attached patch add consts and break (obsolete) — Splinter Review
dbaron, could you review this from a style point of view? I'm adding all the svg presentation attributes to the internal lists, including a number which we don't implement yet. Will the style system cope with being sent svg style rules that it doesn't know about, or should I remove them from the mapping for now?
Attachment #253388 - Attachment is obsolete: true
Attachment #253525 - Flags: review?(dbaron)
(In reply to comment #7) > dbaron, could you review this from a style point of view? I'm adding all the > svg presentation attributes to the internal lists, including a number which we > don't implement yet. Will the style system cope with being sent svg style > rules that it doesn't know about, or should I remove them from the mapping for > now? Sorry, what do you mean by "being sent", "don't know about", and "don't implement yet"?
(In reply to comment #8) > Sorry, what do you mean by "being sent", "don't know about", and "don't > implement yet"? "being sent" ~= NS_NewCSSStyleRule(..., GetOwnerDoc()->CSSLoader()->GetParserFor()->ParseProperty(...)) "doesn't know about" = property not in nsCSSPropList, nsCSSParser, nsRuleNode, nsStyleStruct "don't implement yet" = see above, plus functionality missing in layout/svg
I've just found that the http://www.w3.org/Graphics/SVG/Test/20061213/htmlObjectHarness/full-painting-marker-03-f.html does not show markers because nsSVGGElement::IsAttributeMapped does not have sMarkersMap in it. I could do a one line patch that but if this patch fixes it anyway as I suspect it does should we wait for it to land instead?
(In reply to comment #10) > I've just found that the > http://www.w3.org/Graphics/SVG/Test/20061213/htmlObjectHarness/full-painting-marker-03-f.html > does not show markers because nsSVGGElement::IsAttributeMapped does not have > sMarkersMap in it. I could do a one line patch that but if this patch fixes it > anyway as I suspect it does should we wait for it to land instead? It seems it might take some time to get reviews on this bug, so you should probably patch missing mappings as you see them.
Attached patch update to tip (obsolete) — Splinter Review
Attachment #253525 - Attachment is obsolete: true
Attachment #262812 - Flags: review?
Attachment #253525 - Flags: review?(dbaron)
Attachment #262812 - Flags: review? → review?(dbaron)
Comment on attachment 262812 [details] [diff] [review] update to tip Saying that an attribute is mapped but then not doing anything with it is harmless. For what it's worth, given that SVG doesn't implement SetMappedAttribute, what you return from IsAttributeMapped doesn't actually affect anything outside of the SVG code. If what you're asking is whether it's ok that you're sending them through to the CSS parser -- you'll probably end up with parser errors on the error console if you do so. As far as the performance concerns, probably the biggest way to improve the performance would be to implement SetMappedAttribute (and make the objects unique per set of attributes specified, like HTML does). I'm also concerned (if you don't do the above) that you don't cache the fact that UpdateContentStyleRule sometimes leaves mContentStyleRule null, so you'll call it repeatedly in that case. If you implemented SetMappedAttribute like HTML and had a unique rule for every set of attributes, saying unimplemented attributes were mapped would lead to occasional reduction in the benefits of using unique rules if the unimplemented attributes varied.
(In reply to comment #13) > (From update of attachment 262812 [details] [diff] [review]) > Saying that an attribute is mapped but then not doing anything with it is > harmless. For what it's worth, given that SVG doesn't implement > SetMappedAttribute, what you return from IsAttributeMapped doesn't actually > affect anything outside of the SVG code. Er, sorry, that's not true, since nsHTMLStyleSheet::HasAttributeDependentStyle matters.
Comment on attachment 262812 [details] [diff] [review] update to tip r=dbaron; I couldn't make sense of Appendix M after a few minutes of reading. (It looks like somebody turned a DTD into a table, but I'm not quite sure how.) If you feel you need an SVG peer to look over the correspondence with it, it might not be a bad idea (not sure if longsonr did already), but it's ok without. Sorry I took so long to get to this.
Attachment #262812 - Flags: review?(dbaron) → review+
QA Contact: ian → general

The bug assignee didn't login in Bugzilla in the last 7 months.
:jwatt, could you have a look please?
For more information, please visit auto_nag documentation.

Assignee: tor → nobody
Flags: needinfo?(jwatt)
Severity: normal → S3
Flags: needinfo?(jwatt)
Assignee: nobody → longsonr
Status: NEW → ASSIGNED
Attachment #262812 - Attachment is obsolete: true
Pushed by longsonr@gmail.com: https://hg.mozilla.org/integration/autoland/rev/77efe6b04864 Map all SVG styles to all non-animation SVG elements r=emilio

The rect has a font-size attribute. We now map that attribute so we pass the test.

Flags: needinfo?(longsonr)
Pushed by longsonr@gmail.com: https://hg.mozilla.org/integration/autoland/rev/b72e8e592e81 Map all SVG styles to all non-animation SVG elements r=emilio
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 113 Branch
Blocks: 1802090
Duplicate of this bug: 1457360
See Also: → 878346
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: