Closed
Bug 397916
Opened 17 years ago
Closed 17 years ago
Simplify nsSVGLength2
Categories
(Core :: SVG, defect)
Core
SVG
Tracking
()
RESOLVED
FIXED
People
(Reporter: longsonr, Assigned: longsonr)
Details
Attachments
(1 file, 3 obsolete files)
19.65 KB,
patch
|
Details | Diff | Splinter Review |
create some helper functions. Make the code more compatible with future SMIL work and similar to the new nsSVGAngle code.
Attachment #282712 -
Flags: review?(tor)
I'm not sure I see how this is a simplification. You've moved some methods around in the file which makes the diff a bit hard to read, but the code seems pretty much the same before and after.
Assignee | ||
Comment 2•17 years ago
|
||
I tried to make it look more like the SMIL version and also abstract out the parts which make nsSVGAngle different to nsSVGLength2 so that its easier to fix them in the future. Some of the methods that were public are not used outside the class so I made them private and moved the implementation so the private methods are together. Would you rather I left the order as it was?
(In reply to comment #2) > I tried to make it look more like the SMIL version and also abstract out the > parts which make nsSVGAngle different to nsSVGLength2 so that its easier to fix > them in the future. What do you mean by "look more like the SMIL version"? This is an animatable length value.
Assignee | ||
Comment 4•17 years ago
|
||
I mean look more like the version you would get if bug 216462 was applied.
Assignee | ||
Comment 5•17 years ago
|
||
bug 216462 adds a SetAnimValue to nsSVGLength2 and so abstracts out the implementation of SetBaseValue into a helper that can be called for that function too. This patch implements that small part of bug 216462 and also gives you the ConvertToUserUnits method that bug 216462 wants.
Comment on attachment 282712 [details] [diff] [review] patch >+static nsresult >+GetValueFromString(const nsAString &aValueAsString, >+ float *aValue, >+ PRUint16 *aUnitType) >+{ >+ char *str = ToNewCString(aValueAsString); >+ if (!str) >+ return NS_ERROR_OUT_OF_MEMORY; >+ >+ char* number = str; >+ while (*number && isspace(*number)) >+ ++number; strtod can handle leading whitespace by itself. >+ nsresult rv = NS_ERROR_FAILURE; >+ >+ if (*number) { >+ char *rest; >+ *aValue = static_cast<float>(PR_strtod(number, &rest)); >+ if (rest != number) { >+ *aUnitType = GetUnitTypeForString(nsCRT::strtok(rest, >+ "\x20\x9\xD\xA", >+ &rest)); Shouldn't you check for an invalid unit return and report an error?
Assignee | ||
Comment 7•17 years ago
|
||
(In reply to comment #6) > Shouldn't you check for an invalid unit return and report an error? > Yes.
Assignee | ||
Comment 8•17 years ago
|
||
Attachment #282712 -
Attachment is obsolete: true
Attachment #283029 -
Flags: review?(tor)
Attachment #282712 -
Flags: review?(tor)
Attachment #283029 -
Flags: review?(tor) → review+
Assignee | ||
Updated•17 years ago
|
Attachment #283029 -
Flags: superreview?(roc)
+GetUnitString(nsAString& unit, PRUint16 unitType) +{ Why not just have an array of atoms indexed by unitType? +static PRUint16 +GetUnitTypeForString(const char* unitStr) You could then implement this function by iterating through the same array. +nsSVGLength2::ConvertToUserUnits(float aValue, nsSVGElement *aSVGElement) +nsSVGLength2::ConvertToUserUnits(float aValue, nsSVGSVGElement *aCtx) How about having a single helper function that returns a scale factor, that the caller can then multiply by or divide by?
Assignee | ||
Comment 10•17 years ago
|
||
Attachment #283029 -
Attachment is obsolete: true
Attachment #283169 -
Flags: superreview?(roc)
Attachment #283029 -
Flags: superreview?(roc)
Comment on attachment 283169 [details] [diff] [review] address sr comments + mSpecifiedUnitType = static_cast<PRUint8>(unitType); constructor-style cast (3 occurrences)
Attachment #283169 -
Flags: superreview?(roc)
Attachment #283169 -
Flags: superreview+
Attachment #283169 -
Flags: approval1.9+
Assignee | ||
Comment 12•17 years ago
|
||
Attachment #283169 -
Attachment is obsolete: true
Assignee | ||
Comment 13•17 years ago
|
||
checked in.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•