Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6a6c6d1

Browse filesBrowse files
authored
Merge pull request #18153 from meeseeksmachine/auto-backport-of-pr-18142-on-v3.3.x
Backport PR #18142 on branch v3.3.x (Fix nbagg in Chrome 84)
2 parents 6cfbb4c + 77062a7 commit 6a6c6d1
Copy full SHA for 6a6c6d1

File tree

Expand file treeCollapse file tree

1 file changed

+25
-4
lines changed
Filter options
  • lib/matplotlib/backends/web_backend/js
Expand file treeCollapse file tree

1 file changed

+25
-4
lines changed

‎lib/matplotlib/backends/web_backend/js/mpl.js

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/web_backend/js/mpl.js
+25-4Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,37 @@ mpl.figure.prototype._init_canvas = function () {
172172
var entry = entries[i];
173173
var width, height;
174174
if (entry.contentBoxSize) {
175-
width = entry.contentBoxSize.inlineSize;
176-
height = entry.contentBoxSize.blockSize;
175+
if (entry.contentBoxSize instanceof Array) {
176+
// Chrome 84 implements new version of spec.
177+
width = entry.contentBoxSize[0].inlineSize;
178+
height = entry.contentBoxSize[0].blockSize;
179+
} else {
180+
// Firefox implements old version of spec.
181+
width = entry.contentBoxSize.inlineSize;
182+
height = entry.contentBoxSize.blockSize;
183+
}
177184
} else {
185+
// Chrome <84 implements even older version of spec.
178186
width = entry.contentRect.width;
179187
height = entry.contentRect.height;
180188
}
181189

182190
// Keep the size of the canvas and rubber band canvas in sync with
183191
// the canvas container.
184-
canvas.setAttribute('width', width * mpl.ratio);
185-
canvas.setAttribute('height', height * mpl.ratio);
192+
if (entry.devicePixelContentBoxSize) {
193+
// Chrome 84 implements new version of spec.
194+
canvas.setAttribute(
195+
'width',
196+
entry.devicePixelContentBoxSize[0].inlineSize
197+
);
198+
canvas.setAttribute(
199+
'height',
200+
entry.devicePixelContentBoxSize[0].blockSize
201+
);
202+
} else {
203+
canvas.setAttribute('width', width * mpl.ratio);
204+
canvas.setAttribute('height', height * mpl.ratio);
205+
}
186206
canvas.setAttribute(
187207
'style',
188208
'width: ' + width + 'px; height: ' + height + 'px;'
@@ -254,6 +274,7 @@ mpl.figure.prototype._init_canvas = function () {
254274

255275
// Disable right mouse context menu.
256276
this.rubberband_canvas.addEventListener('contextmenu', function (_e) {
277+
event.preventDefault();
257278
return false;
258279
});
259280

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.