DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42014>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42014





------- Additional Comments From [EMAIL PROTECTED]  2007-04-03 13:20 -------
Looked at the source. The whole process of setting a value doesn't make
sense to me. It is as follows:

- AbstractSVGLength.setValue() calls
  AbstractSVGAnimatedLength$BaseSVGLength.revalidate() to validate the *old*
  value of the corresponding attribute

- If I remove the revalidate(), AbstractSVGLength.setValue() sets the value

- Then it calls AbstractSVGAnimatedLength$BaseSVGLength.reset(), which calls
  AbstractSVGLength.getValueAsString()

- AbstractSVGLength.getValueAsString() calls
  AbstractSVGAnimatedLength$BaseSVGLength.revalidate() to validate the *old*
  value of the corresponding attribute

- If I remove the revalidate(),
  AbstractSVGAnimatedLength$BaseSVGLength.reset() finally sets the
  corresponding attribute to the new value (without validation)

- The bridge is notified about the new element when it is put into the
  document

- SVGRectElementBridge.buildShape() calls AbstractSVGLength.getValue()

- AbstractSVGLength.getValue() calls
  AbstractSVGAnimatedLength$BaseSVGLength.revalidate() to validate the value
  of the corresponding attribute (i.e. parses it and calculates the value)

Note that the final validation will be bypassed if the *old* value was valid
(reset() inhibits the call of invalidate() in attrChanged()), i.e. this does
not throw an exception:

  var root= document.rootElement;
  var elt= document.createElementNS( root.namespaceURI, "rect" );
  elt.setAttribute( "width", 1 );
  elt.setAttribute( "height", 1 );
  elt.width.baseVal.value= -1;
  root.appendChild( elt );

IMHO, validation should happen explicitly in SVG*ElementBridge.buildShape()
and nowhere else. Synching of XML attribute and SVG DOM values should be
separate from this. Also consider code like this, which should work if the
element isn't attached to the document yet:

  myWidth.value= someFunctionThatMayReturnNegativeValues();
  if ( myWidth.value < minimumWidth ) myWidth.value= minimumWidth;

The SVG 1.1 spec says in B.7:

  If a script sets a DOM attribute to an invalid value (e.g., a negative
  number for an attribute that requires a non-negative number or an
  out-of-range value for an enumeration), unless this specification
  indicates otherwise, no exception shall be raised on setting, but the
  given document fragment shall become technically in error as described in
  Error processing.

And in F.2:

  Because of situations where a block of scripting changes might cause a
  given SVG document fragment to go into and out of error, error processing
  shall occur only at times when document presentation (e.g., rendering to
  the display device) is updated. In particular, error processing shall be
  disabled whenever redraw has been suspended via DOM calls to
  suspendRedraw().

BTW, AbstractSVGLength.parse() catches ParseException and sets the length to
0 unknown units. AbstractSVGLength.getValue() then returns 0 with this
comment:

            // XXX Should we throw an exception here when the length
            //     type is unknown?

The answer is "no", but validation at rendering time should check for
invalid units.


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to