diff --git a/.gitignore b/.gitignore index 491c72e229b5..9634a3939793 100644 --- a/.gitignore +++ b/.gitignore @@ -102,7 +102,5 @@ lib/z.lib # Vendored dependencies # ######################### - -jquery-ui-*/ lib/matplotlib/backends/web_backend/node_modules/ lib/matplotlib/backends/web_backend/package-lock.json diff --git a/LICENSE/LICENSE_JQUERY b/LICENSE/LICENSE_JQUERY deleted file mode 100644 index f35387a3ab48..000000000000 --- a/LICENSE/LICENSE_JQUERY +++ /dev/null @@ -1,61 +0,0 @@ -Comment found in jQuery source code: - -/*! - * jQuery JavaScript Library v1.11.3 - * http://jquery.com/ - * - * Includes Sizzle.js - * http://sizzlejs.com/ - * - * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors - * Released under the MIT license - * http://jquery.org/license - * - * Date: 2015-04-28T16:19Z - */ - -Comment found in jQuery UI source code: - -/*! jQuery UI - v1.11.4 - 2015-03-11 -* http://jqueryui.com -* Includes: core.js, widget.js, mouse.js, position.js, accordion.js, autocomplete.js, button.js, datepicker.js, dialog.js, draggable.js, droppable.js, effect.js, effect-blind.js, effect-bounce.js, effect-clip.js, effect-drop.js, effect-explode.js, effect-fade.js, effect-fold.js, effect-highlight.js, effect-puff.js, effect-pulsate.js, effect-scale.js, effect-shake.js, effect-size.js, effect-slide.js, effect-transfer.js, menu.js, progressbar.js, resizable.js, selectable.js, selectmenu.js, slider.js, sortable.js, spinner.js, tabs.js, tooltip.js -* Copyright 2015 jQuery Foundation and other contributors; Licensed MIT */ - -Text found at http://jquery.org/license: - - jQuery Foundation projects are released under the terms of the license - specified in the project's repository or if not specified, under the - MIT license. - - The MIT License is simple and easy to understand and it places almost - no restrictions on what you can do with a jQuery Foundation project. - - You are free to use any jQuery Foundation project in any other project - (even commercial projects) as long as the copyright header is left - intact. - -The text links to https://tldrlegal.com/license/mit-license -which includes the following as the "Full License Text": - - The MIT License (MIT) - - Copyright (c) - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/examples/user_interfaces/embedding_webagg_sgskip.py b/examples/user_interfaces/embedding_webagg_sgskip.py index 33cafb860d80..d4c0e7e9e6f2 100644 --- a/examples/user_interfaces/embedding_webagg_sgskip.py +++ b/examples/user_interfaces/embedding_webagg_sgskip.py @@ -60,9 +60,6 @@ def create_figure(): type="text/css" /> - - - - diff --git a/lib/matplotlib/backends/web_backend/css/mpl.css b/lib/matplotlib/backends/web_backend/css/mpl.css index 61ceb7163866..e55733d25ecf 100644 --- a/lib/matplotlib/backends/web_backend/css/mpl.css +++ b/lib/matplotlib/backends/web_backend/css/mpl.css @@ -1,3 +1,24 @@ +/* General styling */ +.ui-helper-clearfix:before, +.ui-helper-clearfix:after { + content: ""; + display: table; + border-collapse: collapse; +} +.ui-helper-clearfix:after { + clear: both; +} + +/* Header */ +.ui-widget-header { + border: 1px solid #dddddd; + border-top-left-radius: 6px; + border-top-right-radius: 6px; + background: #e9e9e9; + color: #333333; + font-weight: bold; +} + /* Toolbar and items */ .mpl-toolbar { width: 100%; diff --git a/lib/matplotlib/backends/web_backend/css/page.css b/lib/matplotlib/backends/web_backend/css/page.css index d284be1f59c4..c380ef0a3ffc 100644 --- a/lib/matplotlib/backends/web_backend/css/page.css +++ b/lib/matplotlib/backends/web_backend/css/page.css @@ -78,5 +78,6 @@ span#login_widget { #figure-div { display: inline-block; margin: 10px; + vertical-align: top; } diff --git a/lib/matplotlib/backends/web_backend/js/mpl.js b/lib/matplotlib/backends/web_backend/js/mpl.js index c1455bbd9c5e..f7ef50dabff0 100644 --- a/lib/matplotlib/backends/web_backend/js/mpl.js +++ b/lib/matplotlib/backends/web_backend/js/mpl.js @@ -46,8 +46,8 @@ mpl.figure = function (figure_id, websocket, ondownload, parent_element) { this.image_mode = 'full'; this.root = document.createElement('div'); - this._root_extra_style(this.root); this.root.setAttribute('style', 'display: inline-block'); + this._root_extra_style(this.root); parent_element.appendChild(this.root); @@ -112,7 +112,15 @@ mpl.figure.prototype._init_canvas = function () { var canvas_div = (this.canvas_div = document.createElement('div')); canvas_div.setAttribute( 'style', - 'position: relative; clear: both; outline: 0' + 'border: 1px solid #ddd;' + + 'box-sizing: content-box;' + + 'clear: both;' + + 'min-height: 1px;' + + 'min-width: 1px;' + + 'outline: 0;' + + 'overflow: hidden;' + + 'position: relative;' + + 'resize: both;' ); function on_keyboard_event_closure(name) { @@ -135,7 +143,7 @@ mpl.figure.prototype._init_canvas = function () { var canvas = (this.canvas = document.createElement('canvas')); canvas.classList.add('mpl-canvas'); - canvas.setAttribute('style', 'left: 0; top: 0; z-index: 0; outline: 0'); + canvas.setAttribute('style', 'box-sizing: content-box;'); this.context = canvas.getContext('2d'); @@ -155,29 +163,47 @@ mpl.figure.prototype._init_canvas = function () { )); rubberband_canvas.setAttribute( 'style', - 'position: absolute; left: 0; top: 0; z-index: 1;' + 'box-sizing: content-box; position: absolute; left: 0; top: 0; z-index: 1;' ); - var pass_mouse_events = true; - - $(canvas_div).resizable({ - start: function (_event, _ui) { - pass_mouse_events = false; - }, - resize: function (_event, ui) { - fig.request_resize(ui.size.width, ui.size.height); - }, - stop: function (_event, ui) { - pass_mouse_events = true; - fig.request_resize(ui.size.width, ui.size.height); - }, + var resizeObserver = new ResizeObserver(function (entries) { + var nentries = entries.length; + for (var i = 0; i < nentries; i++) { + var entry = entries[i]; + var width, height; + if (entry.contentBoxSize) { + width = entry.contentBoxSize.inlineSize; + height = entry.contentBoxSize.blockSize; + } else { + 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); + canvas.setAttribute( + 'style', + 'width: ' + width + 'px; height: ' + height + 'px;' + ); + + rubberband_canvas.setAttribute('width', width); + rubberband_canvas.setAttribute('height', height); + + // And update the size in Python. We ignore the initial 0/0 size + // that occurs as the element is placed into the DOM, which should + // otherwise not happen due to the minimum size styling. + if (width != 0 && height != 0) { + fig.request_resize(width, height); + } + } }); + resizeObserver.observe(canvas_div); function on_mouse_event_closure(name) { return function (event) { - if (pass_mouse_events) { - return fig.mouse_event(event, name); - } + return fig.mouse_event(event, name); }; } @@ -219,27 +245,13 @@ mpl.figure.prototype._init_canvas = function () { this.rubberband_context = rubberband_canvas.getContext('2d'); this.rubberband_context.strokeStyle = '#000000'; - this._resize_canvas = function (width, height) { - // Keep the size of the canvas, canvas container, and rubber band - // canvas in synch. - canvas_div.style.width = width; - canvas_div.style.height = height; - - canvas.setAttribute('width', width * mpl.ratio); - canvas.setAttribute('height', height * mpl.ratio); - canvas.setAttribute( - 'style', - 'width: ' + width + 'px; height: ' + height + 'px;' - ); - - rubberband_canvas.setAttribute('width', width); - rubberband_canvas.setAttribute('height', height); + this._resize_canvas = function (width, height, forward) { + if (forward) { + canvas_div.style.width = width + 'px'; + canvas_div.style.height = height + 'px'; + } }; - // Set the figure to an initial 600x600px, this will subsequently be updated - // upon first draw. - this._resize_canvas(600, 600); - // Disable right mouse context menu. this.rubberband_canvas.addEventListener('contextmenu', function (_e) { return false; @@ -360,7 +372,7 @@ mpl.figure.prototype.handle_save = function (fig, _msg) { mpl.figure.prototype.handle_resize = function (fig, msg) { var size = msg['size']; if (size[0] !== fig.canvas.width || size[1] !== fig.canvas.height) { - fig._resize_canvas(size[0], size[1]); + fig._resize_canvas(size[0], size[1], msg['forward']); fig.send_message('refresh', {}); } }; diff --git a/lib/matplotlib/backends/web_backend/js/nbagg_mpl.js b/lib/matplotlib/backends/web_backend/js/nbagg_mpl.js index 03f46fa6cb98..3d56f1fe8ab9 100644 --- a/lib/matplotlib/backends/web_backend/js/nbagg_mpl.js +++ b/lib/matplotlib/backends/web_backend/js/nbagg_mpl.js @@ -176,6 +176,7 @@ mpl.figure.prototype._remove_fig_handler = function () { }; mpl.figure.prototype._root_extra_style = function (el) { + el.style.boxSizing = 'content-box'; // override notebook setting of border-box. el.addEventListener('remove', this._remove_fig_handler); }; diff --git a/lib/matplotlib/backends/web_backend/single_figure.html b/lib/matplotlib/backends/web_backend/single_figure.html index 664cf57006fa..71fe451f6f14 100644 --- a/lib/matplotlib/backends/web_backend/single_figure.html +++ b/lib/matplotlib/backends/web_backend/single_figure.html @@ -4,9 +4,6 @@ - - -