Closed Bug 483389 Opened 15 years ago Closed 15 years ago

viewportElement methods return the wrong element sometimes

Categories

(Core :: SVG, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: longsonr, Assigned: longsonr)

Details

Attachments

(1 file, 2 obsolete files)

a) getting the viewportElement or nearestViewportElement of an element should start looking from the element's parent and should not consider the element itself.
b) getting the viewportElement should not just consider svg elements symbols etc can establish viewports.
c)if a foreignObject ancestor is present it should not stop viewportElement finding the viewport
Attached patch patch (obsolete) — Splinter Review
Attachment #367372 - Flags: superreview?(roc)
Attachment #367372 - Flags: review?(roc)
+  var root = doc.getElementById("root");

You could just use doc.documentElement

+  is(root.farthestViewportElement, null, "root.farthestViewportElement");
+  is(root.nearestViewportElement, null, "root.nearestViewportElement");
+  is(root.viewportElement, null, "root.viewportElement");

are you sure this is supposed to return null? I can't find where this is documented...
http://www.w3.org/TR/SVG/types.html#InterfaceSVGLocatable and http://www.w3.org/TR/SVG/types.html#InterfaceSVGElement say in all cases

Null if the current element is the outermost 'svg' element.
The only thing I'm not totally sure on is whether I've made the right decision for foreignObject.

<svg id="svg1">
  <foreignObject>
     <svg id="svg2">
         <g id="g"/>
     </svg>
  </foreignObject>
</svg>

What's the farthestViewport of g? We give svg2 an outer SVG frame so is it that? Or is it svg1? Batik (and this patch) goes for svg1. Opera goes for svg2 I think, although if you ask for the farthestViewport for svg2 you get the foreignObject in Opera and I don't see that that makes sense so I'm not sure I trust Opera. On the other hand Batik doesn't really support foreignObject. As usual the spec is no help at all as far as I can tell.
I would say 'null'. Chances are people are expecting it to return the nearest ancestor which doesn't have an SVG parent.
BTW your foreignObject test is not valid, since the <g> lacks an <svg> parent, right?
(In reply to comment #5)
You are talking about the farthestViewport of svg2 (rather than g) in that answer aren't you?
Sorry yes. The farthest viewport of "svg2" would be null, and the farthest viewport of "g" would be svg2.
(In reply to comment #8)
The idea was to have a test with invalid markup and determine what we should do with it since the spec says the methods don't throw. I'm going to go with returning null for all viewports in that case.
Attachment #367372 - Flags: superreview?(roc)
Attachment #367372 - Flags: review?(roc)
I'll do a new patch to take foreignObject into account properly.
Attached patch address review comments (obsolete) — Splinter Review
Attachment #367372 - Attachment is obsolete: true
Attachment #367518 - Flags: superreview?(roc)
Attachment #367518 - Flags: review?(roc)
+  if (element) {
+    element.swap(*aFarthestViewportElement);
   }

Is this 'if' needed?
+<svg xmlns="http://www.w3.org/2000/svg" width="750"
+     xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="root">

Nit: You don't need the 'id' anymore.
Attachment #367518 - Attachment is obsolete: true
Attachment #367566 - Flags: superreview?(roc)
Attachment #367566 - Flags: review?(roc)
Attachment #367518 - Flags: superreview?(roc)
Attachment #367518 - Flags: review?(roc)
Attachment #367566 - Flags: superreview?(roc)
Attachment #367566 - Flags: superreview+
Attachment #367566 - Flags: review?(roc)
Attachment #367566 - Flags: review+
checked in http://hg.mozilla.org/mozilla-central/rev/7cb9b924b8de
Status: NEW → RESOLVED
Closed: 15 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: