Skip to content

Commit 2778616

Browse files
committed
Adjust for firefox, which supports foreignObjects
1 parent b91adad commit 2778616

File tree

2 files changed

+13
-27
lines changed

2 files changed

+13
-27
lines changed

scripts/JSRoot3DPainter.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,6 @@
318318
// renderer.setClearColor(0x0, 0);
319319
this.renderer.setSize(this.scene_width, this.scene_height);
320320

321-
console.log('ADD canvas size ' + JSON.stringify(size));
322-
323321
this.add_3d_canvas(size, this.renderer.domElement);
324322

325323
this['DrawXYZ'] = JSROOT.Painter.HPainter_DrawXYZ;
@@ -687,8 +685,6 @@
687685

688686
if ((size3d.width<10) || (size3d.height<10)) return;
689687

690-
console.log('size3d = ' + JSON.stringify(size3d));
691-
692688
this.scene_width = size3d.width;
693689
this.scene_height = size3d.height;
694690

scripts/JSRootPainter.js

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,22 +1347,25 @@
13471347

13481348
elem = this.svg_pad().select(".special_layer").select("." + size.clname);
13491349
if (elem.empty())
1350-
elem = this.svg_pad().select(".special_layer").append("foreignObject");
1350+
elem = this.svg_pad().select(".special_layer")
1351+
.append("foreignObject").attr("class", size.clname);
13511352

1352-
elem.attr('width', size.width)
1353+
elem.attr('x', size.x)
1354+
.attr('y', size.y)
1355+
.attr('width', size.width)
13531356
.attr('height', size.height)
13541357
.attr('viewBox', "0 0 " + size.width + " " + size.height)
13551358
.attr('preserveAspectRatio','xMidYMid');
13561359

1357-
this.SetForeignObjectPosition(elem, size);
1358-
13591360
} else {
13601361
// force redraw by resize
13611362
this.svg_canvas().property('redraw_by_resize', true);
13621363

13631364
elem = d3.select(this.svg_canvas().node().parentNode).select("." + size.clname);
1364-
if (elem.empty())
1365-
elem = d3.select(this.svg_canvas().node().parentNode).append('div');
1365+
if (elem.empty()) {
1366+
elem = d3.select(this.svg_canvas().node().parentNode)
1367+
.append('div').attr("class", size.clname);
1368+
}
13661369

13671370
elem.style('position','absolute')
13681371
.style('left', size.x + 'px')
@@ -1461,21 +1464,6 @@
14611464
return pos;
14621465
}
14631466

1464-
JSROOT.TObjectPainter.prototype.SetForeignObjectPosition = function(fo, pos) {
1465-
// method used to set absolute coordinates for foreignObject
1466-
// it is known problem of WebKit http://bit.ly/1wjqCQ9
1467-
1468-
if (!pos) pos = { x: 0, y: 0 };
1469-
1470-
if (JSROOT.browser.isWebKit) {
1471-
// force canvas redraw when foreign object used - it is not correctly scaled
1472-
this.svg_canvas().property('redraw_by_resize', true);
1473-
pos = this.CalcAbsolutePosition(fo, pos);
1474-
}
1475-
1476-
fo.attr("x",pos.x).attr("y",pos.y);
1477-
}
1478-
14791467

14801468
JSROOT.TObjectPainter.prototype.createAttFill = function(attfill, pattern, color) {
14811469

@@ -2302,6 +2290,8 @@
23022290
// simple way to access painter via frame container
23032291
this.draw_g.property('frame_painter', this);
23042292

2293+
console.log('frame ' + lm + "," + tm + " " + w + "," + h);
2294+
23052295
this.draw_g.attr("x", lm)
23062296
.attr("y", tm)
23072297
.attr("width", w)
@@ -3090,6 +3080,7 @@
30903080
.property('pad_painter', this) // this is custom property
30913081
.property('mainpainter', null) // this is custom property
30923082
.property('current_pad', "") // this is custom property
3083+
.property('redraw_by_resize', false); // could be enabled to force redraw by each resize
30933084

30943085
svg.append("svg:title").text("ROOT canvas");
30953086
svg.append("svg:g").attr("class","root_frame");
@@ -3115,8 +3106,7 @@
31153106
.property('draw_x', 0)
31163107
.property('draw_y', 0)
31173108
.property('draw_width', w)
3118-
.property('draw_height', h)
3119-
.property('redraw_by_resize', false);
3109+
.property('draw_height', h);
31203110

31213111
return true;
31223112
}

0 commit comments

Comments
 (0)