Closed Bug 293224 Opened 19 years ago Closed 19 years ago

[FIX]Matrix from getScreenCTM should be to initial viewport space

Categories

(Core :: SVG, defect, P1)

defect

Tracking

()

VERIFIED FIXED
mozilla1.8beta4

People

(Reporter: a.neumann, Assigned: jwatt)

References

()

Details

(Keywords: fixed1.8)

Attachments

(4 files, 10 obsolete files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8b2) Gecko/20050504 Firefox/1.0+
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8b2) Gecko/20050504 Firefox/1.0+

The .getScreenCTM() method of the root element (documentElement) delivers wrong
values when a viewBox is involved.

Please have a look at
http://www.carto.net/neumann/temp/getscreenctm.svg

Clicking on the rectangle should reveal the scale factor and offset values that
should change after each window resize. Unfortunately that does not work on
Mozilla svg. No matter how a resize the window, mozilla svg always displays the
same values. The example works well in ASV6 and Batik.

That method is very important to me since almost all of my more complex examples
build on this method and won't work without it.

Reproducible: Always

Actual Results:  
in Mozilla native SVG the translation values seem to reflect the position of the
browser window within the main screen on the computer, but in fact they should
represent the offset of the viewBox system within the browser window. The scale
values are always at one, but they should reflect the resizing of the viewBox
coordinate system. Please compare with ASV6 or the newest Batik about the behaviour.
Status: UNCONFIRMED → NEW
Depends on: 272630
Ever confirmed: true
any chnace we might see this in 1.5 ?
this is much more important than bug#272630 which this bug depends on.
Attached image testcase (obsolete) —
move your mouse around. the circle should be under the mouse, but it isnt.
Attachment #182880 - Attachment is obsolete: true
Testcase appears to be a different bug.
Attached image testcase (obsolete) —
ohh ! sorry, uploaded the wrong file ! here is the right testcase !
Attachment #192169 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attached patch getScreenCTM changes (obsolete) — Splinter Review
Needs testing for non-<svg:svg> elements.
Attached image test nested g elements (obsolete) —
a more complex testcase
drag around the white rect, it should allways stay under your mouse pointer.
Attached patch a bit more cleanup (obsolete) — Splinter Review
Attachment #192228 - Attachment is obsolete: true
Attachment #192267 - Flags: review?(jonathan.watt)
Holger: Okay, let's fix the bugs in your testcases first.

1) You're mixing up *screen* coordinates with *client* coordinates. You need to
use *screenX* and *screenY* when playing with getScreenCTM, not clientX and clientY.

2) Why are you calling getScreenCTM on the 'circle' element's parentNode? If
you're using the mouse coordinates to set attributes of the 'circle' element
then just call getScreenCTM on it.

I'll attach corrected testcases that should work in firefox shortly.

Andreas:

The SVG file you've linked to doesn't show how you're using getScreenCTM. Are
you also mixing up screen and client coordinates? Under what circumstances are
you finding it necessary to call getScreenCTM on an 'svg' element. I'd be *very*
interested to know of any scenarios where that's really what you want to do.
Holger, if you have any I'd like to hear from you too. :-)
Attached image Holger's first testcase (obsolete) —
Attachment #192199 - Attachment is obsolete: true
Attached image Holger's second testcase (obsolete) —
Attachment #192232 - Attachment is obsolete: true
i didnt know about screenX/Y, and im not sure i understand the difference to
clientX/Y, but it sounds reasonable to use screen coordinates with screenCTM !
unfortunatly using screenX/Y breaks the examples in Batik, but that migth be a
batik bug...
From a quick look at batik it seems it's getScreenCTM is more like what you
might call a getClientCTM method. :-/ Hence why things worked for you when using
the client coordinates.
yeah , but it seems to me that in ASV6 clientX/Y == screenX/Y.
so getScreenCTM() == "getClientCTM" in ASV6 and Batik.
if this is implemented correctly ( i do believe what you say is correct ), i see
no way to script anything like the testcase in a cross viewer manner.
Attachment #192267 - Attachment is obsolete: true
Attachment #192267 - Flags: review?(jonathan.watt)
Actually the fact that ASV6 uses client space for both screenX/Y *and*
getScreenCTM means that this isn't a problem in ASV. They might argue that their
"screen" is the client area, but who cares. As long as they remain consistant
you can use *screen*X/Y and things will work fine.

Batik on the other hand is a problem since screenX/Y isn't in the same space as
getScreenCTM. I've filed a bug for that.

http://issues.apache.org/bugzilla/show_bug.cgi?id=36165
The SVG WG are going to discuss this at their face-to-face next week, and Chris
is going to get back to me with their conclusion. I'd recommend you don't go to
a lot of effort to change any of your existing scripts until then.
(In reply to comment #9)

> use *screenX* and *screenY* when playing with getScreenCTM, not clientX and
clientY.

on further testing, i just realized, that this proposal still does not work
correctly, it seem getScreenCTM does not take currentTranslate/Scale into account. 
Attached image another testcase (obsolete) —
the first testcase with currentScale set to 0.5
Attachment #192502 - Attachment is obsolete: true
Attached image Holger's first testcase
Attachment #192503 - Attachment is obsolete: true
Attachment #194830 - Attachment is obsolete: true
Attached image Holger's third testcase
Summary: method .getScreenCTM on the root element not implemented correctly → Matrix from getScreenCTM should be to initial viewport space
Attached patch patch (obsolete) — Splinter Review
Please ignore comment 9, apparently the use of "screen" in getScreenCTM is just
unfortunate naming. getScreenCTM should return the transformation matrix from
current user units to the initial viewport coordinate system. In other words,
you should use clientX and clientY in conjunction with getScreenCTM to
transform cursor coordinates to user space, and not screenX and screenY as I
asserted. (This should be publicly clarified by the W3C at a later date.) I've
updated the bug summary and testcases.

This patch makes our implementation of getScreenCTM return a transform to the
same coordinate system as other implementations, and as the spec. was intended
to say it should.
Assignee: general → jonathan.watt
Attachment #194938 - Flags: superreview?(tor)
Attachment #194938 - Flags: review?(tor)
Requesting blocking1.8b4. Sorry this is so late in the game, but we were waiting
on WG clarification. Fixing this is very important for compatibility between SVG
implementations. The change is SVG only and should be safe since GetScreenCTM is
only used recursively by itself in our code. In other words content is it's only
consumer. I'd like to get the patch in for b4 though to get it properly tested.
No longer depends on: 272630
Flags: blocking1.8b4?
Priority: -- → P1
Summary: Matrix from getScreenCTM should be to initial viewport space → [FIX]Matrix from getScreenCTM should be to initial viewport space
Target Milestone: --- → mozilla1.8beta4
(In reply to comment #17)
> it seem getScreenCTM does not take currentTranslate/Scale into account. 

BTW, good catch Holger, and yes, this patch fixes that too.
Attachment #194938 - Flags: superreview?(tor)
Attachment #194938 - Flags: review?(tor)
Attachment #194938 - Attachment is obsolete: true
Attachment #194961 - Flags: superreview?(tor)
Attachment #194961 - Flags: review?(tor)
Attachment #194961 - Flags: superreview?(tor)
Attachment #194961 - Flags: superreview+
Attachment #194961 - Flags: review?(tor)
Attachment #194961 - Flags: review+
Comment on attachment 194961 [details] [diff] [review]
patch - include currentScale and Translate for <svg><svg></svg></svg>

requesting approval1.8b4. see comment 23 for risk.
Attachment #194961 - Flags: approval1.8b4?
checked in on trunk
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
We should take this if possible for 1.8b4 - it fixes a specification compliance
problem that we've been discussing with the SVG WG.
Status: RESOLVED → VERIFIED
verifying fix. works great, thanks Jonathan, this was just in time ;-)
QA Contact: ian → holger
Attachment #194961 - Flags: approval1.8b4? → approval1.8b4+
Flags: blocking1.8b4? → blocking1.8b4+
checked in on branch
Keywords: fixed1.8
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: