Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix nbagg in Chrome 84 #18142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions lib/matplotlib/backends/web_backend/js/mpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,37 @@ mpl.figure.prototype._init_canvas = function () {
var entry = entries[i];
var width, height;
if (entry.contentBoxSize) {
width = entry.contentBoxSize.inlineSize;
height = entry.contentBoxSize.blockSize;
if (entry.contentBoxSize instanceof Array) {
// Chrome 84 implements new version of spec.
width = entry.contentBoxSize[0].inlineSize;
height = entry.contentBoxSize[0].blockSize;
} else {
// Firefox implements old version of spec.
width = entry.contentBoxSize.inlineSize;
height = entry.contentBoxSize.blockSize;
}
} else {
// Chrome <84 implements even older version of spec.
width = entry.contentRect.width;
height = entry.contentRect.height;
}

// Keep the size of the canvas and rubber band canvas in sync with
// the canvas container.
canvas.setAttribute('width', width * mpl.ratio);
canvas.setAttribute('height', height * mpl.ratio);
if (entry.devicePixelContentBoxSize) {
// Chrome 84 implements new version of spec.
canvas.setAttribute(
'width',
entry.devicePixelContentBoxSize[0].inlineSize
);
canvas.setAttribute(
'height',
entry.devicePixelContentBoxSize[0].blockSize
);
} else {
canvas.setAttribute('width', width * mpl.ratio);
canvas.setAttribute('height', height * mpl.ratio);
}
canvas.setAttribute(
'style',
'width: ' + width + 'px; height: ' + height + 'px;'
Expand Down Expand Up @@ -254,6 +274,7 @@ mpl.figure.prototype._init_canvas = function () {

// Disable right mouse context menu.
this.rubberband_canvas.addEventListener('contextmenu', function (_e) {
event.preventDefault();
return false;
});

Expand Down