From 096959fde9d43fe2dbda039353daab456c088214 Mon Sep 17 00:00:00 2001 From: Neil Fraser Date: Mon, 19 Aug 2019 14:07:48 -0700 Subject: [PATCH 1/3] =?UTF-8?q?Cleanup=20of=20last=20fortnight=E2=80=99s?= =?UTF-8?q?=20commits.=20(#2865)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No functional changes. --- core/block_svg.js | 2 +- core/comment.js | 4 +- core/components/component.js | 1 + core/components/menu/menuitem.js | 8 +-- core/components/tree/basenode.js | 8 +-- core/components/tree/treecontrol.js | 9 ++- core/css.js | 20 +++---- core/dropdowndiv.js | 12 ++-- core/field_colour.js | 10 ++-- core/field_label.js | 2 +- core/field_label_serializable.js | 2 +- core/field_registry.js | 5 +- core/field_textinput.js | 10 +--- core/keyboard_nav/action.js | 1 + core/keyboard_nav/cursor_svg.js | 12 ++-- core/keyboard_nav/key_map.js | 3 +- .../block_render_draw.js | 41 +++++++------ .../block_render_draw_debug.js | 23 ++++---- .../block_render_draw_highlight.js | 28 ++++----- .../block_render_info.js | 58 ++++++++----------- .../block_rendering.js | 2 +- .../block_rendering_constants.js | 2 +- .../highlight_constants.js | 3 +- core/toolbox.js | 2 +- core/utils/aria.js | 1 - core/utils/idgenerator.js | 7 +-- core/utils/keycodes.js | 1 + core/utils/style.js | 28 ++++----- core/zoom_controls.js | 4 +- 29 files changed, 147 insertions(+), 162 deletions(-) diff --git a/core/block_svg.js b/core/block_svg.js index 4c22e0fbe..c6d5b261d 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -646,7 +646,7 @@ Blockly.BlockSvg.prototype.showHelp_ = function() { /** * Generate the context menu for this block. * @protected - * @returns {Array.} Context menu options + * @return {Array.} Context menu options */ Blockly.BlockSvg.prototype.generateContextMenu = function() { if (this.workspace.options.readOnly || !this.contextMenu) { diff --git a/core/comment.js b/core/comment.js index 80e4ed1d1..f3b8d608b 100644 --- a/core/comment.js +++ b/core/comment.js @@ -137,9 +137,7 @@ Blockly.Comment.prototype.createEditor_ = function() { this.text_ = textarea.value; } }); - setTimeout(function() { - textarea.focus(); - }, 0); + setTimeout(textarea.focus.bind(textarea), 0); return this.foreignObject_; }; diff --git a/core/components/component.js b/core/components/component.js index 2024a5fc8..6661187b2 100644 --- a/core/components/component.js +++ b/core/components/component.js @@ -26,6 +26,7 @@ 'use strict'; goog.provide('Blockly.Component'); + goog.provide('Blockly.Component.Error'); goog.require('Blockly.utils.dom'); goog.require('Blockly.utils.IdGenerator'); diff --git a/core/components/menu/menuitem.js b/core/components/menu/menuitem.js index bb5702215..de92e9c38 100644 --- a/core/components/menu/menuitem.js +++ b/core/components/menu/menuitem.js @@ -103,7 +103,7 @@ Blockly.MenuItem.prototype.createDom = function() { }; /** - * @return {Element} The html element for the checkbox. + * @return {Element} The HTML element for the checkbox. * @protected */ Blockly.MenuItem.prototype.getCheckboxDom = function() { @@ -117,7 +117,7 @@ Blockly.MenuItem.prototype.getCheckboxDom = function() { }; /** - * @return {!Element} The html for the content. + * @return {!Element} The HTML for the content. * @protected */ Blockly.MenuItem.prototype.getContentDom = function() { @@ -129,7 +129,7 @@ Blockly.MenuItem.prototype.getContentDom = function() { }; /** - * @return {!Element} The html for the content wrapper. + * @return {!Element} The HTML for the content wrapper. * @protected */ Blockly.MenuItem.prototype.getContentWrapperDom = function() { @@ -160,7 +160,7 @@ Blockly.MenuItem.prototype.setValue = function(value) { /** * Gets the value associated with the menu item. - * @returns {*} value Value associated with the menu item. + * @return {*} value Value associated with the menu item. * @package */ Blockly.MenuItem.prototype.getValue = function() { diff --git a/core/components/tree/basenode.js b/core/components/tree/basenode.js index e353318e9..0505c0d87 100644 --- a/core/components/tree/basenode.js +++ b/core/components/tree/basenode.js @@ -691,7 +691,7 @@ Blockly.tree.BaseNode.prototype.isUserCollapsible = function() { /** * Creates HTML Element for the node. - * @return {!Element} html element + * @return {!Element} HTML element * @protected */ Blockly.tree.BaseNode.prototype.toDom = function() { @@ -727,7 +727,7 @@ Blockly.tree.BaseNode.prototype.getPixelIndent_ = function() { }; /** - * @return {!Element} The html element for the row. + * @return {!Element} The HTML element for the row. * @protected */ Blockly.tree.BaseNode.prototype.getRowDom = function() { @@ -758,7 +758,7 @@ Blockly.tree.BaseNode.prototype.getRowClassName = function() { }; /** - * @return {!Element} The html element for the label. + * @return {!Element} The HTML element for the label. * @protected */ Blockly.tree.BaseNode.prototype.getLabelDom = function() { @@ -770,7 +770,7 @@ Blockly.tree.BaseNode.prototype.getLabelDom = function() { }; /** - * @return {!Element} The html for the icon. + * @return {!Element} The HTML for the icon. * @protected */ Blockly.tree.BaseNode.prototype.getIconDom = function() { diff --git a/core/components/tree/treecontrol.js b/core/components/tree/treecontrol.js index c8766a8cc..dea08f25b 100644 --- a/core/components/tree/treecontrol.js +++ b/core/components/tree/treecontrol.js @@ -197,7 +197,7 @@ Blockly.tree.TreeControl.prototype.setSelectedItem = function(node) { if (node == this.selectedItem_) { return; } - + if (this.onBeforeSelected_ && !this.onBeforeSelected_.call(this.toolbox_, node)) { return; @@ -327,7 +327,7 @@ Blockly.tree.TreeControl.prototype.attachEvents_ = function() { 'mousedown', this, this.handleMouseEvent_); this.onClickWrapper_ = Blockly.bindEventWithChecks_(el, 'click', this, this.handleMouseEvent_); - + this.onKeydownWrapper_ = Blockly.bindEvent_(el, 'keydown', this, this.handleKeyEvent_); @@ -381,9 +381,8 @@ Blockly.tree.TreeControl.prototype.handleTouchEvent_ = function(e) { if (node && e.type === 'touchend') { // Fire asynchronously since onMouseDown takes long enough that the browser // would fire the default mouse event before this method returns. - setTimeout(function() { - node.onClick_(e); // Same behaviour for click and touch. - }, 1); + // Same behaviour for click and touch. + setTimeout(node.onClick_.bind(node, e), 1); } }; diff --git a/core/css.js b/core/css.js index b9ecc102c..fa4b6bd68 100644 --- a/core/css.js +++ b/core/css.js @@ -194,11 +194,11 @@ Blockly.Css.CONTENT = [ 'border-radius: 2px;', 'padding: 4px;', '-webkit-user-select: none;', - 'box-shadow: 0px 0px 3px 1px rgba(0, 0, 0, .3);', + 'box-shadow: 0px 0px 3px 1px rgba(0,0,0,.3);', '}', '.blocklyDropDownDiv.focused {', - 'box-shadow: 0px 0px 6px 1px rgba(0, 0, 0, .3);', + 'box-shadow: 0px 0px 6px 1px rgba(0,0,0,.3);', '}', '.blocklyDropDownContent {', @@ -353,7 +353,7 @@ Blockly.Css.CONTENT = [ '}', '.blocklyReplaceable .blocklyPath {', - 'fill-opacity: 0.5;', + 'fill-opacity: .5;', '}', '.blocklyReplaceable .blocklyPathLight,', @@ -671,7 +671,7 @@ Blockly.Css.CONTENT = [ '.blocklyVerticalCursor {', 'stroke-width: 3px;', - 'fill: rgba(255,255,255,0.5);', + 'fill: rgba(255,255,255,.5);', '}', '.blocklyWidgetDiv .goog-option-selected .goog-menuitem-checkbox,', @@ -806,7 +806,7 @@ Blockly.Css.CONTENT = [ '.blocklyColourTable>tr>td {', 'padding: 0;', 'cursor: pointer;', - 'border: 0.5px solid transparent;', + 'border: .5px solid transparent;', 'height: 25px;', 'width: 25px;', 'box-sizing: border-box;', @@ -816,7 +816,7 @@ Blockly.Css.CONTENT = [ '.blocklyColourTable>tr>td.blocklyColourHighlighted {', 'border-color: #eee;', 'position: relative;', - 'box-shadow: 2px 2px 7px 2px rgba(0, 0, 0, 0.3);', + 'box-shadow: 2px 2px 7px 2px rgba(0,0,0,.3);', '}', '.blocklyColourSelected, .blocklyColourSelected:hover {', @@ -854,11 +854,11 @@ Blockly.Css.CONTENT = [ 'overflow-x: hidden;', 'max-height: 100%;', 'z-index: 20000;', /* Arbitrary, but some apps depend on it... */ - 'box-shadow: 0px 0px 3px 1px rgba(0, 0, 0, .3);', + 'box-shadow: 0px 0px 3px 1px rgba(0,0,0,.3);', '}', '.blocklyWidgetDiv .goog-menu.focused {', - 'box-shadow: 0px 0px 6px 1px rgba(0, 0, 0, .3);', + 'box-shadow: 0px 0px 6px 1px rgba(0,0,0,.3);', '}', '.blocklyDropDownDiv .goog-menu {', @@ -957,7 +957,7 @@ Blockly.Css.CONTENT = [ '.blocklyWidgetDiv .goog-menuitem-disabled .goog-menuitem-icon, ', '.blocklyDropDownDiv .goog-menuitem-disabled .goog-menuitem-icon {', - 'opacity: 0.3;', + 'opacity: .3;', 'filter: alpha(opacity=30);', '}', @@ -969,7 +969,7 @@ Blockly.Css.CONTENT = [ '.blocklyDropDownDiv .goog-menuitem-highlight, ', '.blocklyDropDownDiv .goog-menuitem-hover {', - 'background-color: rgba(0, 0, 0, 0.2);', + 'background-color: rgba(0,0,0,.2);', '}', /* State: selected/checked. */ diff --git a/core/dropdowndiv.js b/core/dropdowndiv.js index 60ccf076e..747a6c983 100644 --- a/core/dropdowndiv.js +++ b/core/dropdowndiv.js @@ -540,12 +540,12 @@ Blockly.DropDownDiv.hide = function() { // Start the animation by setting the translation and fading out. var div = Blockly.DropDownDiv.DIV_; // Reset to (initialX, initialY) - i.e., no translation. - div.style.transform = 'translate(0px, 0px)'; + div.style.transform = 'translate(0, 0)'; div.style.opacity = 0; - Blockly.DropDownDiv.animateOutTimer_ = setTimeout(function() { - // Finish animation - reset all values to default. - Blockly.DropDownDiv.hideWithoutAnimation(); - }, Blockly.DropDownDiv.ANIMATION_TIME * 1000); + // Finish animation - reset all values to default. + Blockly.DropDownDiv.animateOutTimer_ = + setTimeout(Blockly.DropDownDiv.hideWithoutAnimation, + Blockly.DropDownDiv.ANIMATION_TIME * 1000); if (Blockly.DropDownDiv.onHide_) { Blockly.DropDownDiv.onHide_(); Blockly.DropDownDiv.onHide_ = null; @@ -616,7 +616,7 @@ Blockly.DropDownDiv.positionInternal_ = function(initialX, initialY, finalX, fin /** * Repositions the dropdownDiv on window resize. If it doesn't know how to - * calculate the new position, it wll just hide it instead. + * calculate the new position, it will just hide it instead. */ Blockly.DropDownDiv.repositionForWindowResize = function() { // This condition mainly catches the dropdown div when it is being used as a diff --git a/core/field_colour.js b/core/field_colour.js index 78f4b36a4..e79ffb362 100644 --- a/core/field_colour.js +++ b/core/field_colour.js @@ -285,7 +285,7 @@ Blockly.FieldColour.prototype.showEditor_ = function() { Blockly.DropDownDiv.showPositionedByField( this, this.dropdownDispose_.bind(this)); - + // Focus so we can start receiving keyboard events. this.picker_.focus(); }; @@ -426,17 +426,17 @@ Blockly.FieldColour.prototype.getHighlighted_ = function() { * @private */ Blockly.FieldColour.prototype.setHighlightedCell_ = function(cell, index) { - // Unhighlight the current item + // Unhighlight the current item. var highlighted = this.getHighlighted_(); if (highlighted) { Blockly.utils.dom.removeClass(highlighted, 'blocklyColourHighlighted'); } - // Highight new item + // Highight new item. Blockly.utils.dom.addClass(cell, 'blocklyColourHighlighted'); - // Set new highlighted index + // Set new highlighted index. this.highlightedIndex_ = index; - // Update accessibility roles + // Update accessibility roles. Blockly.utils.aria.setState(this.picker_, Blockly.utils.aria.State.ACTIVEDESCENDANT, cell.getAttribute('id')); }; diff --git a/core/field_label.js b/core/field_label.js index c89b574d0..feb28ea96 100644 --- a/core/field_label.js +++ b/core/field_label.js @@ -80,7 +80,7 @@ Blockly.FieldLabel.prototype.EDITABLE = false; */ Blockly.FieldLabel.prototype.initView = function() { this.createTextElement_(); - // The y attribute of an svg text element is the baseline. + // The y attribute of an SVG text element is the baseline. this.textElement_.setAttribute('y', this.size_.height); if (this.class_) { Blockly.utils.dom.addClass(this.textElement_, this.class_); diff --git a/core/field_label_serializable.js b/core/field_label_serializable.js index f6fa0ee33..d6ece9b8e 100644 --- a/core/field_label_serializable.js +++ b/core/field_label_serializable.js @@ -51,7 +51,7 @@ goog.inherits(Blockly.FieldLabelSerializable, Blockly.FieldLabel); * Construct a FieldLabelSerializable from a JSON arg object, * dereferencing any string table references. * @param {!Object} options A JSON object with options (text, and class). - * @returns {!Blockly.FieldLabelSerializable} The new field instance. + * @return {!Blockly.FieldLabelSerializable} The new field instance. * @package * @nocollapse */ diff --git a/core/field_registry.js b/core/field_registry.js index 114b89f9f..3bc0c549d 100644 --- a/core/field_registry.js +++ b/core/field_registry.js @@ -77,9 +77,8 @@ Blockly.fieldRegistry.fromJson = function(options) { if (!fieldClass) { console.warn('Blockly could not create a field of type ' + options['type'] + '. The field is probably not being registered. This could be because' + - ' the file is not loaded, the field does not register itself (See:' + - ' github.com/google/blockly/issues/1584), or the registration is not' + - ' being reached.'); + ' the file is not loaded, the field does not register itself (Issue' + + ' #1584), or the registration is not being reached.'); return null; } diff --git a/core/field_textinput.js b/core/field_textinput.js index a08df12ca..5adc88734 100644 --- a/core/field_textinput.js +++ b/core/field_textinput.js @@ -172,10 +172,7 @@ Blockly.FieldTextInput.prototype.render_ = function() { // in RTL, we need to let the browser reflow before resizing // in order to get the correct bounding box of the borderRect // avoiding issue #2777. - var field = this; - setTimeout(function() { - field.resizeEditor_(); - }, 0); + setTimeout(this.resizeEditor_.bind(this), 0); } else { this.resizeEditor_(); } @@ -270,10 +267,7 @@ Blockly.FieldTextInput.prototype.widgetCreate_ = function() { htmlInput.untypedDefaultValue_ = this.value_; htmlInput.oldValue_ = null; // Ensure the browser reflows before resizing to avoid issue #2777. - var field = this; - setTimeout(function() { - field.resizeEditor_(); - }, 0); + setTimeout(this.resizeEditor_.bind(this), 0); this.bindInputEvents_(htmlInput); diff --git a/core/keyboard_nav/action.js b/core/keyboard_nav/action.js index 5914c6f44..e5896565e 100644 --- a/core/keyboard_nav/action.js +++ b/core/keyboard_nav/action.js @@ -26,6 +26,7 @@ goog.provide('Blockly.Action'); + /** * Class for a single action. * An action describes user intent. (ex go to next or go to previous) diff --git a/core/keyboard_nav/cursor_svg.js b/core/keyboard_nav/cursor_svg.js index 0bb7a3904..90ae5268d 100644 --- a/core/keyboard_nav/cursor_svg.js +++ b/core/keyboard_nav/cursor_svg.js @@ -165,7 +165,8 @@ Blockly.CursorSvg.prototype.showWithCoordinates_ = function() { var wsCoordinate = workspaceNode.getWsCoordinate(); this.currentCursorSvg = this.cursorSvgLine_; this.setParent_(this.workspace_.svgBlockCanvas_); - this.positionLine_(wsCoordinate.x, wsCoordinate.y, Blockly.CursorSvg.CURSOR_WIDTH); + this.positionLine_(wsCoordinate.x, wsCoordinate.y, + Blockly.CursorSvg.CURSOR_WIDTH); this.showCurrent_(); }; @@ -191,8 +192,8 @@ Blockly.CursorSvg.prototype.showWithInputOutput_ = function() { var connection = /** @type {Blockly.Connection} */ (this.getCurNode().getLocation()); this.currentCursorSvg = this.cursorInputOutput_; - var path = Blockly.utils.svgPaths.moveTo(0,0) + - Blockly.blockRendering.constants.PUZZLE_TAB.pathDown; + var path = Blockly.utils.svgPaths.moveTo(0, 0) + + Blockly.blockRendering.constants.PUZZLE_TAB.pathDown; this.cursorInputOutput_.setAttribute('d', path); this.setParent_(connection.getSourceBlock().getSvgRoot()); this.positionInputOutput_(connection); @@ -313,8 +314,9 @@ Blockly.CursorSvg.prototype.positionInputOutput_ = function(connection) { var x = connection.getOffsetInBlock().x; var y = connection.getOffsetInBlock().y; - this.cursorInputOutput_.setAttribute('transform', 'translate(' + x + ',' + y + ')' + - (connection.getSourceBlock().RTL ? ' scale(-1 1)' : '')); + this.cursorInputOutput_.setAttribute('transform', + 'translate(' + x + ',' + y + ')' + + (connection.getSourceBlock().RTL ? ' scale(-1 1)' : '')); }; /** diff --git a/core/keyboard_nav/key_map.js b/core/keyboard_nav/key_map.js index c61a42737..6672ab1f7 100644 --- a/core/keyboard_nav/key_map.js +++ b/core/keyboard_nav/key_map.js @@ -29,6 +29,7 @@ goog.provide('Blockly.user.keyMap'); goog.require('Blockly.utils.KeyCodes'); + /** * Holds the serialized key to key action mapping. * @type {Object} @@ -39,7 +40,7 @@ Blockly.user.keyMap.map_ = {}; * List of modifier keys checked when serializing the key event. * @type {Array} */ -Blockly.user.keyMap.modifierKeys = ['Shift','Control','Alt','Meta']; +Blockly.user.keyMap.modifierKeys = ['Shift', 'Control', 'Alt', 'Meta']; /** * Update the key map to contain the new action. diff --git a/core/renderers/block_rendering_rewrite/block_render_draw.js b/core/renderers/block_rendering_rewrite/block_render_draw.js index a806459ac..901b419b7 100644 --- a/core/renderers/block_rendering_rewrite/block_render_draw.js +++ b/core/renderers/block_rendering_rewrite/block_render_draw.js @@ -22,8 +22,8 @@ * @fileoverview Methods for graphically rendering a block as SVG. * @author fenichel@google.com (Rachel Fenichel) */ - 'use strict'; + goog.provide('Blockly.blockRendering.Drawer'); goog.require('Blockly.blockRendering.constants'); @@ -37,9 +37,10 @@ goog.require('Blockly.blockRendering.Row'); goog.require('Blockly.blockRendering.SpacerRow'); goog.require('Blockly.blockRendering.TopRow'); + /** * An object that draws a block based on the given rendering information. - * @param {!Blockly.BlockSvg} block The block to render + * @param {!Blockly.BlockSvg} block The block to render. * @param {!Blockly.blockRendering.RenderInfo} info An object containing all * information needed to render this block. * @package @@ -52,7 +53,8 @@ Blockly.blockRendering.Drawer = function(block, info) { this.outlinePath_ = ''; this.inlinePath_ = ''; this.pathObject_ = new Blockly.BlockSvg.PathObject(); - this.highlighter_ = new Blockly.blockRendering.Highlighter(this.info_, this.pathObject_); + this.highlighter_ = + new Blockly.blockRendering.Highlighter(this.info_, this.pathObject_); }; /** @@ -88,7 +90,8 @@ Blockly.blockRendering.Drawer.prototype.draw_ = function() { Blockly.blockRendering.Drawer.prototype.recordSizeOnBlock_ = function() { // This is used when the block is reporting its size to anyone else. // The dark path adds to the size of the block in both X and Y. - this.block_.height = this.info_.height + Blockly.blockRendering.constants.DARK_PATH_OFFSET; + this.block_.height = this.info_.height + + Blockly.blockRendering.constants.DARK_PATH_OFFSET; this.block_.width = this.info_.widthWithChildren + Blockly.blockRendering.constants.DARK_PATH_OFFSET; }; @@ -98,8 +101,7 @@ Blockly.blockRendering.Drawer.prototype.recordSizeOnBlock_ = function() { * @private */ Blockly.blockRendering.Drawer.prototype.hideHiddenIcons_ = function() { - for (var i = 0; i < this.info_.hiddenIcons.length; i++) { - var iconInfo = this.info_.hiddenIcons[i]; + for (var i = 0, iconInfo; iconInfo = this.info_.hiddenIcons[i]; i++) { iconInfo.icon.iconGroup_.setAttribute('display', 'none'); } }; @@ -141,14 +143,15 @@ Blockly.blockRendering.Drawer.prototype.drawTop_ = function() { this.highlighter_.drawRightSideRow(topRow); } this.positionPreviousConnection_(); - this.outlinePath_ += Blockly.utils.svgPaths.moveBy(topRow.xPos, this.info_.startY); - for (var i = 0, elem; i < elements.length; i++) { - elem = elements[i]; - if (elem.type === 'round corner') { - this.outlinePath_ += Blockly.blockRendering.constants.OUTSIDE_CORNERS.topLeft; - } else if (elem.type === 'previous connection') { + this.outlinePath_ += + Blockly.utils.svgPaths.moveBy(topRow.xPos, this.info_.startY); + for (var i = 0, elem; elem = elements[i]; i++) { + if (elem.type == 'round corner') { + this.outlinePath_ += + Blockly.blockRendering.constants.OUTSIDE_CORNERS.topLeft; + } else if (elem.type == 'previous connection') { this.outlinePath_ += topRow.notchShape.pathLeft; - } else if (elem.type === 'hat') { + } else if (elem.type == 'hat') { this.outlinePath_ += Blockly.blockRendering.constants.START_HAT.path; } else if (elem.isSpacer()) { this.outlinePath_ += Blockly.utils.svgPaths.lineOnAxis('h', elem.width); @@ -284,7 +287,8 @@ Blockly.blockRendering.Drawer.prototype.drawLeft_ = function() { this.positionOutputConnection_(); if (outputConnection) { - var tabBottom = outputConnection.connectionOffsetY + outputConnection.height; + var tabBottom = outputConnection.connectionOffsetY + + outputConnection.height; // Draw a line up to the bottom of the tab. this.outlinePath_ += Blockly.utils.svgPaths.lineOnAxis('V', tabBottom) + @@ -301,9 +305,8 @@ Blockly.blockRendering.Drawer.prototype.drawLeft_ = function() { * @private */ Blockly.blockRendering.Drawer.prototype.drawInternals_ = function() { - for (var r = 0; r < this.info_.rows.length; r++) { - var row = this.info_.rows[r]; - for (var e = 0; e < row.elements.length; e++) { + for (var i = 0, row; row = this.info_.rows[i]; i++) { + for (var j = 0, elem; elem = row.elements[j]; j++) { var elem = row.elements[e]; if (elem.isInlineInput()) { this.drawInlineInput_(elem); @@ -380,7 +383,6 @@ Blockly.blockRendering.Drawer.prototype.drawInlineInput_ = function(input) { 'z'; this.positionInlineInputConnection_(input); - }; /** @@ -438,7 +440,8 @@ Blockly.blockRendering.Drawer.prototype.positionStatementInputConnection_ = func Blockly.blockRendering.Drawer.prototype.positionExternalValueConnection_ = function(row) { var input = row.getLastInput(); if (input.connection) { - var connX = row.xPos + row.width + Blockly.blockRendering.constants.DARK_PATH_OFFSET; + var connX = row.xPos + row.width + + Blockly.blockRendering.constants.DARK_PATH_OFFSET; if (this.info_.RTL) { connX *= -1; } diff --git a/core/renderers/block_rendering_rewrite/block_render_draw_debug.js b/core/renderers/block_rendering_rewrite/block_render_draw_debug.js index 62721fa66..b76ba1a32 100644 --- a/core/renderers/block_rendering_rewrite/block_render_draw_debug.js +++ b/core/renderers/block_rendering_rewrite/block_render_draw_debug.js @@ -22,9 +22,10 @@ * @fileoverview Methods for graphically rendering a block as SVG. * @author fenichel@google.com (Rachel Fenichel) */ - 'use strict'; + goog.provide('Blockly.blockRendering.Debug'); + goog.require('Blockly.blockRendering.RenderInfo'); goog.require('Blockly.blockRendering.Highlighter'); goog.require('Blockly.blockRendering.constants'); @@ -35,6 +36,7 @@ goog.require('Blockly.blockRendering.Row'); goog.require('Blockly.blockRendering.SpacerRow'); goog.require('Blockly.blockRendering.TopRow'); + /** * An object that renders rectangles and dots for debugging rendering code. * @package @@ -74,8 +76,7 @@ Blockly.blockRendering.Debug = function() { * @package */ Blockly.blockRendering.Debug.prototype.clearElems = function() { - for (var i = 0, elem; i < this.debugElements_.length; i++) { - elem = this.debugElements_[i]; + for (var i = 0, elem; elem = this.debugElements_[i]; i++) { Blockly.utils.dom.removeNode(elem); } @@ -84,7 +85,7 @@ Blockly.blockRendering.Debug.prototype.clearElems = function() { /** * Draw a debug rectangle for a spacer (empty) row. - * @param {!Blockly.blockRendering.Row} row The row to render + * @param {!Blockly.blockRendering.Row} row The row to render. * @param {number} cursorY The y position of the top of the row. * @param {boolean} isRtl Whether the block is rendered RTL. * @package @@ -107,7 +108,7 @@ Blockly.blockRendering.Debug.prototype.drawSpacerRow = function(row, cursorY, is /** * Draw a debug rectangle for a horizontal spacer. - * @param {!Blockly.BlockSvg.InRowSpacer} elem The spacer to render + * @param {!Blockly.BlockSvg.InRowSpacer} elem The spacer to render. * @param {number} rowHeight The height of the container row. * @param {boolean} isRtl Whether the block is rendered RTL. * @package @@ -136,7 +137,7 @@ Blockly.blockRendering.Debug.prototype.drawSpacerElem = function(elem, rowHeight /** * Draw a debug rectangle for an in-row element. - * @param {!Blockly.BlockSvg.Measurable} elem The element to render + * @param {!Blockly.BlockSvg.Measurable} elem The element to render. * @param {boolean} isRtl Whether the block is rendered RTL. * @package */ @@ -225,7 +226,7 @@ Blockly.blockRendering.Debug.prototype.drawRenderedRow = function(row, cursorY, { 'class': 'elemRenderingRect blockRenderDebug', 'x': isRtl ? -(row.xPos + row.width) : row.xPos, - 'y': cursorY , + 'y': cursorY, 'width': row.width, 'height': row.height, }, @@ -238,7 +239,7 @@ Blockly.blockRendering.Debug.prototype.drawRenderedRow = function(row, cursorY, { 'class': 'blockRenderDebug', 'x': isRtl ? -(row.xPos + row.widthWithConnectedBlocks) : row.xPos, - 'y': cursorY , + 'y': cursorY, 'width': row.widthWithConnectedBlocks, 'height': row.height, 'stroke': this.randomColour_, @@ -257,8 +258,7 @@ Blockly.blockRendering.Debug.prototype.drawRenderedRow = function(row, cursorY, * @package */ Blockly.blockRendering.Debug.prototype.drawRowWithElements = function(row, cursorY, isRtl) { - for (var e = 0; e < row.elements.length; e++) { - var elem = row.elements[e]; + for (var i = 0, elem; elem = row.elements[i]; i++) { if (elem.isSpacer()) { this.drawSpacerElem(elem, row.height, isRtl); } else { @@ -325,8 +325,7 @@ Blockly.blockRendering.Debug.prototype.drawDebug = function(block, info) { this.randomColour_ = '#' + Math.floor(Math.random() * 16777215).toString(16); var cursorY = 0; - for (var r = 0; r < info.rows.length; r++) { - var row = info.rows[r]; + for (var i = 0, row; row = info.rows[i]; i++) { if (row.type == 'between-row spacer') { this.drawSpacerRow(row, cursorY, info.RTL); } else { diff --git a/core/renderers/block_rendering_rewrite/block_render_draw_highlight.js b/core/renderers/block_rendering_rewrite/block_render_draw_highlight.js index 66f22bcf0..413eae58f 100644 --- a/core/renderers/block_rendering_rewrite/block_render_draw_highlight.js +++ b/core/renderers/block_rendering_rewrite/block_render_draw_highlight.js @@ -22,8 +22,8 @@ * @fileoverview Methods for graphically rendering a block as SVG. * @author fenichel@google.com (Rachel Fenichel) */ - 'use strict'; + goog.provide('Blockly.blockRendering.Highlighter'); goog.require('Blockly.blockRendering.highlightConstants'); @@ -35,6 +35,7 @@ goog.require('Blockly.blockRendering.Row'); goog.require('Blockly.blockRendering.SpacerRow'); goog.require('Blockly.blockRendering.TopRow'); + /** * An object that adds highlights to a block based on the given rendering * information. @@ -81,14 +82,14 @@ Blockly.blockRendering.Highlighter.prototype.drawTopCorner = function(row) { this.steps_.push( Blockly.utils.svgPaths.moveBy(row.xPos, this.info_.startY)); for (var i = 0, elem; elem = row.elements[i]; i++) { - if (elem.type === 'square corner') { + if (elem.type == 'square corner') { this.steps_.push(Blockly.blockRendering.highlightConstants.START_POINT); - } else if (elem.type === 'round corner') { + } else if (elem.type == 'round corner') { this.steps_.push( this.outsideCornerPaths_.topLeft(this.RTL_)); - } else if (elem.type === 'previous connection') { + } else if (elem.type == 'previous connection') { this.steps_.push(this.notchPaths_.pathLeft); - } else if (elem.type === 'hat') { + } else if (elem.type == 'hat') { this.steps_.push(this.startPaths_.path(this.RTL_)); } else if (elem.isSpacer() && elem.width != 0) { // The end point of the spacer needs to be offset by the highlight amount. @@ -172,12 +173,12 @@ Blockly.blockRendering.Highlighter.prototype.drawBottomRow = function(row) { this.steps_.push('V', height - this.highlightOffset_); } else { var cornerElem = this.info_.bottomRow.elements[0]; - if (cornerElem.type === 'square corner') { + if (cornerElem.type == 'square corner') { this.steps_.push( Blockly.utils.svgPaths.moveTo( row.xPos + this.highlightOffset_, height - this.highlightOffset_)); - } else if (cornerElem.type === 'round corner') { + } else if (cornerElem.type == 'round corner') { this.steps_.push(Blockly.utils.svgPaths.moveTo(row.xPos, height)); this.steps_.push(this.outsideCornerPaths_.bottomLeft()); } @@ -190,16 +191,15 @@ Blockly.blockRendering.Highlighter.prototype.drawLeft = function() { var tabBottom = outputConnection.connectionOffsetY + outputConnection.height; // Draw a line up to the bottom of the tab. - if (!this.RTL_) { + if (this.RTL_) { + this.steps_.push(Blockly.utils.svgPaths.moveTo(this.info_.startX, tabBottom)); + } else { var left = this.info_.startX + this.highlightOffset_; var bottom = this.info_.height - this.highlightOffset_; this.steps_.push(Blockly.utils.svgPaths.moveTo(left, bottom)); this.steps_.push('V', tabBottom); - } else { - this.steps_.push(Blockly.utils.svgPaths.moveTo(this.info_.startX, tabBottom)); } - this.steps_.push( - this.puzzleTabPaths_.pathUp(this.RTL_)); + this.steps_.push(this.puzzleTabPaths_.pathUp(this.RTL_)); } if (!this.RTL_) { @@ -224,8 +224,8 @@ Blockly.blockRendering.Highlighter.prototype.drawInlineInput = function(input) { if (this.RTL_) { // TODO: Check if this is different when the inline input is populated. var aboveTabHeight = input.connectionOffsetY - offset; - var belowTabHeight = - input.height - (input.connectionOffsetY + input.connectionHeight) + offset; + var belowTabHeight = input.height - + (input.connectionOffsetY + input.connectionHeight) + offset; var startX = connectionRight - offset; diff --git a/core/renderers/block_rendering_rewrite/block_render_info.js b/core/renderers/block_rendering_rewrite/block_render_info.js index 1c89663ee..cffb0c529 100644 --- a/core/renderers/block_rendering_rewrite/block_render_info.js +++ b/core/renderers/block_rendering_rewrite/block_render_info.js @@ -22,7 +22,6 @@ * @fileoverview Methods for graphically rendering a block as SVG. * @author fenichel@google.com (Rachel Fenichel) */ - 'use strict'; goog.provide('Blockly.blockRendering.RenderInfo'); @@ -35,6 +34,7 @@ goog.require('Blockly.blockRendering.Row'); goog.require('Blockly.blockRendering.SpacerRow'); goog.require('Blockly.blockRendering.TopRow'); + /** * An object containing all sizing information needed to draw this block. * @@ -115,7 +115,7 @@ Blockly.blockRendering.RenderInfo = function(block) { this.rows = []; /** - * An array of measureable objects containing hidden icons. + * An array of measurable objects containing hidden icons. * @type {!Array.} */ this.hiddenIcons = []; @@ -175,8 +175,7 @@ Blockly.blockRendering.RenderInfo.prototype.createRows_ = function() { // Icons always go on the first row, before anything else. var icons = this.block_.getIcons(); if (icons.length) { - for (var i = 0; i < icons.length; i++) { - var icon = icons[i]; + for (var i = 0, icon; icon = icons[i]; i++) { var iconInfo = new Blockly.blockRendering.Icon(icon); if (this.isCollapsed && icon.collapseHidden) { this.hiddenIcons.push(iconInfo); @@ -189,8 +188,7 @@ Blockly.blockRendering.RenderInfo.prototype.createRows_ = function() { var lastInput = undefined; // Loop across all of the inputs on the block, creating objects for anything // that needs to be rendered and breaking the block up into visual rows. - for (var i = 0; i < this.block_.inputList.length; i++) { - var input = this.block_.inputList[i]; + for (var i = 0, input; input = this.block_.inputList[i]; i++) { if (!input.isVisible()) { continue; } @@ -201,8 +199,7 @@ Blockly.blockRendering.RenderInfo.prototype.createRows_ = function() { } // All of the fields in an input go on the same row. - for (var f = 0; f < input.fieldRow.length; f++) { - var field = input.fieldRow[f]; + for (var j = 0, field; field = input.fieldRow[j]; j++) { activeRow.elements.push(new Blockly.blockRendering.Field(field, input)); } this.addInput_(input, activeRow); @@ -226,11 +223,11 @@ Blockly.blockRendering.RenderInfo.prototype.createRows_ = function() { * created. */ Blockly.blockRendering.RenderInfo.prototype.populateTopRow_ = function() { - var hasHat = this.block_.hat ? this.block_.hat === 'cap' : Blockly.BlockSvg.START_HAT; + var hasHat = this.block_.hat ? this.block_.hat == 'cap' : Blockly.BlockSvg.START_HAT; var hasPrevious = !!this.block_.previousConnection; var prevBlock = this.block_.getPreviousBlock(); - var squareCorner = !!this.block_.outputConnection || - hasHat || (prevBlock && prevBlock.getNextBlock() == this.block_); + var squareCorner = !!this.block_.outputConnection || hasHat || + (prevBlock && prevBlock.getNextBlock() == this.block_); if (squareCorner) { this.topRow.elements.push(new Blockly.blockRendering.SquareCorner()); @@ -265,7 +262,6 @@ Blockly.blockRendering.RenderInfo.prototype.populateBottomRow_ = function() { } }; - /** * Add an input element to the active row, if needed, and record the type of the * input on the row. @@ -321,8 +317,7 @@ Blockly.blockRendering.RenderInfo.prototype.shouldStartNewRow_ = function(input, * @private */ Blockly.blockRendering.RenderInfo.prototype.addElemSpacing_ = function() { - for (var r = 0; r < this.rows.length; r++) { - var row = this.rows[r]; + for (var i = 0, row; row = this.rows[i]; i++) { var oldElems = row.elements; row.elements = []; // No spacing needed before the corner on the top row or the bottom row. @@ -496,8 +491,7 @@ Blockly.blockRendering.RenderInfo.prototype.computeBounds_ = function() { var widestStatementRowFields = 0; var blockWidth = 0; var widestRowWithConnectedBlocks = 0; - for (var r = 0; r < this.rows.length; r++) { - var row = this.rows[r]; + for (var i = 0, row; row = this.rows[i]; i++) { row.measure(); blockWidth = Math.max(blockWidth, row.width); if (row.hasStatement) { @@ -514,15 +508,13 @@ Blockly.blockRendering.RenderInfo.prototype.computeBounds_ = function() { this.width = blockWidth; - for (var r = 0; r < this.rows.length; r++) { - var row = this.rows[r]; + for (var i = 0, row; row = this.rows[i]; i++) { if (row.hasStatement) { row.statementEdge = this.statementEdge; } } - this.widthWithChildren = - Math.max(blockWidth, widestRowWithConnectedBlocks); + this.widthWithChildren = Math.max(blockWidth, widestRowWithConnectedBlocks); if (this.outputConnection) { this.startX = this.outputConnection.width; @@ -538,8 +530,7 @@ Blockly.blockRendering.RenderInfo.prototype.computeBounds_ = function() { * @private */ Blockly.blockRendering.RenderInfo.prototype.alignRowElements_ = function() { - for (var r = 0; r < this.rows.length; r++) { - var row = this.rows[r]; + for (var i = 0, row; row = this.rows[i]; i++) { if (!row.hasInlineInput) { if (row.hasStatement) { var statementInput = row.getLastInput(); @@ -549,7 +540,7 @@ Blockly.blockRendering.RenderInfo.prototype.alignRowElements_ = function() { var currentWidth = row.width; var desiredWidth = this.width - this.startX; } - if (row.type === 'bottom row' && row.hasFixedWidth) { + if (row.type == 'bottom row' && row.hasFixedWidth) { desiredWidth = Blockly.blockRendering.constants.MAX_BOTTOM_WIDTH; } var missingSpace = desiredWidth - currentWidth; @@ -593,7 +584,7 @@ Blockly.blockRendering.RenderInfo.prototype.addAlignmentPadding_ = function(row, } row.width += missingSpace; // Top and bottom rows are always left aligned. - } else if (row.type === 'top row' || row.type === 'bottom row') { + } else if (row.type == 'top row' || row.type == 'bottom row') { row.getLastSpacer().width += missingSpace; row.width += missingSpace; } @@ -609,7 +600,7 @@ Blockly.blockRendering.RenderInfo.prototype.addRowSpacing_ = function() { for (var r = 0; r < oldRows.length; r++) { this.rows.push(oldRows[r]); - if (r !== oldRows.length - 1) { + if (r != oldRows.length - 1) { this.rows.push(this.makeSpacerRow_(oldRows[r], oldRows[r + 1])); } } @@ -644,7 +635,7 @@ Blockly.blockRendering.RenderInfo.prototype.makeSpacerRow_ = function(prev, next Blockly.blockRendering.RenderInfo.prototype.getSpacerRowWidth_ = function(prev, next) { // The width of the spacer before the bottom row should be the same as the // bottom row. - if (next.type === 'bottom row' && next.hasFixedWidth) { + if (next.type == 'bottom row' && next.hasFixedWidth) { return next.width; } return this.width - this.startX; @@ -658,12 +649,12 @@ Blockly.blockRendering.RenderInfo.prototype.getSpacerRowWidth_ = function(prev, * @private */ Blockly.blockRendering.RenderInfo.prototype.getSpacerRowHeight_ = function(prev, next) { - // If we have an empty block add a spacer to increase the height - if (prev.type === 'top row' && next.type === 'bottom row') { + // If we have an empty block add a spacer to increase the height. + if (prev.type == 'top row' && next.type == 'bottom row') { return Blockly.blockRendering.constants.EMPTY_BLOCK_SPACER_HEIGHT; } - // Top and bottom rows act as a spacer so we don't need any extra padding - if (prev.type === 'top row' || next.type === 'bottom row') { + // Top and bottom rows act as a spacer so we don't need any extra padding. + if (prev.type == 'top row' || next.type == 'bottom row') { return Blockly.blockRendering.constants.NO_PADDING; } if (prev.hasExternalInput && next.hasExternalInput) { @@ -702,6 +693,7 @@ Blockly.blockRendering.RenderInfo.prototype.getElemCenterline_ = function(row, e } return result; }; + /** * Make any final changes to the rendering information object. In particular, * store the y position of each row, and record the height of the full block. @@ -713,8 +705,7 @@ Blockly.blockRendering.RenderInfo.prototype.finalize_ = function() { // accesses and sets properties that already exist on the objects. var widestRowWithConnectedBlocks = 0; var yCursor = 0; - for (var r = 0; r < this.rows.length; r++) { - var row = this.rows[r]; + for (var i = 0, row; row = this.rows[i]; i++) { row.yPos = yCursor; row.xPos = this.startX; yCursor += row.height; @@ -731,8 +722,7 @@ Blockly.blockRendering.RenderInfo.prototype.finalize_ = function() { yCursor += diff; } var xCursor = row.xPos; - for (var e = 0; e < row.elements.length; e++) { - var elem = row.elements[e]; + for (var j = 0, elem; elem = row.elements[j]; j++) { elem.xPos = xCursor; elem.centerline = this.getElemCenterline_(row, elem); xCursor += elem.width; diff --git a/core/renderers/block_rendering_rewrite/block_rendering.js b/core/renderers/block_rendering_rewrite/block_rendering.js index 705d7d16f..2f0cd1b9d 100644 --- a/core/renderers/block_rendering_rewrite/block_rendering.js +++ b/core/renderers/block_rendering_rewrite/block_rendering.js @@ -22,7 +22,6 @@ * @fileoverview Namespace for block rendering functionality. * @author fenichel@google.com (Rachel Fenichel) */ - 'use strict'; /** @@ -35,6 +34,7 @@ goog.require('Blockly.blockRendering.Debug'); goog.require('Blockly.blockRendering.Drawer'); goog.require('Blockly.blockRendering.RenderInfo'); + /** * Render the given block, using the new rendering. * Developers should not call this directly. Instead, call block.render(). diff --git a/core/renderers/block_rendering_rewrite/block_rendering_constants.js b/core/renderers/block_rendering_rewrite/block_rendering_constants.js index 5f84019cf..76a5e3072 100644 --- a/core/renderers/block_rendering_rewrite/block_rendering_constants.js +++ b/core/renderers/block_rendering_rewrite/block_rendering_constants.js @@ -22,8 +22,8 @@ * @fileoverview Methods for graphically rendering a block as SVG. * @author fenichel@google.com (Rachel Fenichel) */ - 'use strict'; + goog.provide('Blockly.blockRendering.constants'); goog.require('Blockly.utils.svgPaths'); diff --git a/core/renderers/block_rendering_rewrite/highlight_constants.js b/core/renderers/block_rendering_rewrite/highlight_constants.js index ea42cbe53..0b461f0c1 100644 --- a/core/renderers/block_rendering_rewrite/highlight_constants.js +++ b/core/renderers/block_rendering_rewrite/highlight_constants.js @@ -22,13 +22,14 @@ * @fileoverview Objects for rendering highlights on blocks. * @author fenichel@google.com (Rachel Fenichel) */ - 'use strict'; + goog.provide('Blockly.blockRendering.highlightConstants'); goog.require('Blockly.blockRendering.constants'); goog.require('Blockly.utils.svgPaths'); + /** * Some highlights are simple offsets of the parent paths and can be generated * programmatically. Others, especially on curves, are just made out of piles diff --git a/core/toolbox.js b/core/toolbox.js index f4c0e5f0c..62bb673ba 100644 --- a/core/toolbox.js +++ b/core/toolbox.js @@ -220,7 +220,7 @@ Blockly.Toolbox.prototype.init = function() { /** * Handle the before tree item selected action. * @param {Blockly.tree.BaseNode} node The newly selected node. - * @returns {boolean} Whether or not to cancel selecting the node. + * @return {boolean} Whether or not to cancel selecting the node. * @private */ Blockly.Toolbox.prototype.handleBeforeTreeSelected_ = function(node) { diff --git a/core/utils/aria.js b/core/utils/aria.js index 478984066..84b67b72a 100644 --- a/core/utils/aria.js +++ b/core/utils/aria.js @@ -26,7 +26,6 @@ */ 'use strict'; - goog.provide('Blockly.utils.aria'); diff --git a/core/utils/idgenerator.js b/core/utils/idgenerator.js index befe53070..71a02b976 100644 --- a/core/utils/idgenerator.js +++ b/core/utils/idgenerator.js @@ -26,12 +26,11 @@ */ 'use strict'; - goog.provide('Blockly.utils.IdGenerator'); /** - * Creates a new id generator. + * Creates a new ID generator. * @constructor * @final */ @@ -39,7 +38,7 @@ Blockly.utils.IdGenerator = function() {}; /** * Get the singleton instance of Blockly.utils.IdGenerator. - * @returns {Blockly.utils.IdGenerator} singleton instance + * @return {Blockly.utils.IdGenerator} singleton instance */ Blockly.utils.IdGenerator.getInstance = function() { if (!Blockly.utils.IdGenerator.instance_) { @@ -49,7 +48,7 @@ Blockly.utils.IdGenerator.getInstance = function() { }; /** - * Next unique ID to use + * Next unique ID to use. * @type {number} * @private */ diff --git a/core/utils/keycodes.js b/core/utils/keycodes.js index dc8337f0b..51a8b2a65 100644 --- a/core/utils/keycodes.js +++ b/core/utils/keycodes.js @@ -28,6 +28,7 @@ goog.provide('Blockly.utils.KeyCodes'); + /** * Key codes for common characters. * diff --git a/core/utils/style.js b/core/utils/style.js index fc86e89f8..bdcf290c2 100644 --- a/core/utils/style.js +++ b/core/utils/style.js @@ -39,7 +39,7 @@ goog.require('Blockly.utils.Size'); /** * Gets the height and width of an element. * Similar to Closure's goog.style.getSize - * @param {Element} element Element to get size of. + * @param {!Element} element Element to get size of. * @return {!Blockly.utils.Size} Object with width/height properties. */ Blockly.utils.style.getSize = function(element) { @@ -69,7 +69,7 @@ Blockly.utils.style.getSize = function(element) { /** * Gets the height and width of an element when the display is not none. - * @param {Element} element Element to get size of. + * @param {!Element} element Element to get size of. * @return {!goog.math.Size} Object with width/height properties. * @private */ @@ -88,7 +88,7 @@ Blockly.utils.style.getSizeWithDisplay_ = function(element) { * * Copied from Closure's goog.style.getStyle_ * - * @param {Element} element Element to get style of. + * @param {!Element} element Element to get style of. * @param {string} style Property to get (must be camelCase, not css-style.). * @return {string} Style value. * @private @@ -107,7 +107,7 @@ Blockly.utils.style.getStyle_ = function(element, style) { * * Copied from Closure's goog.style.getComputedStyle * - * @param {Element} element Element to get style of. + * @param {!Element} element Element to get style of. * @param {string} property Property to get (camel-case). * @return {string} Style value. */ @@ -130,7 +130,7 @@ Blockly.utils.style.getComputedStyle = function(element, property) { * * Copied from Closure's goog.style.getCascadedStyle * - * @param {Element} element Element to get style of. + * @param {!Element} element Element to get style of. * @param {string} style Property to get (camel-case). * @return {string} Style value. */ @@ -142,7 +142,7 @@ Blockly.utils.style.getCascadedStyle = function(element, style) { /** * Returns a Coordinate object relative to the top-left of the HTML document. * Similar to Closure's goog.style.getPageOffset - * @param {Element} el Element to get the page offset for. + * @param {!Element} el Element to get the page offset for. * @return {!Blockly.utils.Coordinate} The page offset. */ Blockly.utils.style.getPageOffset = function(el) { @@ -182,7 +182,7 @@ Blockly.utils.style.getViewportPageOffset = function() { * the browser's default style rules). * Copied from Closure's goog.style.getViewportPageOffset * - * @param {Element} el Element to show or hide. + * @param {!Element} el Element to show or hide. * @param {*} isShown True to render the element in its default style, * false to disable rendering the element. */ @@ -191,10 +191,10 @@ Blockly.utils.style.setElementShown = function(el, isShown) { }; /** - * Returns true if the element is using right to left (rtl) direction. + * Returns true if the element is using right to left (RTL) direction. * Copied from Closure's goog.style.isRightToLeft * - * @param {Element} el The element to test. + * @param {!Element} el The element to test. * @return {boolean} True for right to left, false for left to right. */ Blockly.utils.style.isRightToLeft = function(el) { @@ -204,7 +204,7 @@ Blockly.utils.style.isRightToLeft = function(el) { /** * Gets the computed border widths (on all sides) in pixels * Copied from Closure's goog.style.getBorderBox - * @param {Element} element The element to get the border widths for. + * @param {!Element} element The element to get the border widths for. * @return {!Object} The computed border widths. */ Blockly.utils.style.getBorderBox = function(element) { @@ -228,8 +228,8 @@ Blockly.utils.style.getBorderBox = function(element) { * aligned as close to the container's top left corner as possible. * Copied from Closure's goog.style.scrollIntoContainerView * - * @param {Element} element The element to make visible. - * @param {Element} container The container to scroll. If not set, then the + * @param {!Element} element The element to make visible. + * @param {!Element} container The container to scroll. If not set, then the * document scroll element will be used. * @param {boolean=} opt_center Whether to center the element in the container. * Defaults to false. @@ -250,8 +250,8 @@ Blockly.utils.style.scrollIntoContainerView = function( * aligned as close to the container's top left corner as possible. * Copied from Closure's goog.style.getContainerOffsetToScrollInto * - * @param {Element} element The element to make visible. - * @param {Element} container The container to scroll. If not set, then the + * @param {!Element} element The element to make visible. + * @param {!Element} container The container to scroll. If not set, then the * document scroll element will be used. * @param {boolean=} opt_center Whether to center the element in the container. * Defaults to false. diff --git a/core/zoom_controls.js b/core/zoom_controls.js index 46566b441..a0c541909 100644 --- a/core/zoom_controls.js +++ b/core/zoom_controls.js @@ -330,9 +330,7 @@ Blockly.ZoomControls.prototype.createZoomResetSvg_ = function(rnd) { ws.setScale(ws.options.zoomOptions.startScale); ws.beginCanvasTransition(); ws.scrollCenter(); - setTimeout(function() { - ws.endCanvasTransition(); - }, 500); + setTimeout(ws.endCanvasTransition.bind(ws), 500); Blockly.Touch.clearTouchIdentifier(); // Don't block future drags. e.stopPropagation(); // Don't start a workspace scroll. e.preventDefault(); // Stop double-clicking from selecting text. From 4b4b50d76f1e0a321da2d7da010557add672bf74 Mon Sep 17 00:00:00 2001 From: Sam El-Husseini <16690124+samelhusseini@users.noreply.github.com> Date: Mon, 19 Aug 2019 14:50:46 -0700 Subject: [PATCH 2/3] Fix drawInternals crash (#2867) --- core/renderers/block_rendering_rewrite/block_render_draw.js | 1 - 1 file changed, 1 deletion(-) diff --git a/core/renderers/block_rendering_rewrite/block_render_draw.js b/core/renderers/block_rendering_rewrite/block_render_draw.js index 901b419b7..f229717d5 100644 --- a/core/renderers/block_rendering_rewrite/block_render_draw.js +++ b/core/renderers/block_rendering_rewrite/block_render_draw.js @@ -307,7 +307,6 @@ Blockly.blockRendering.Drawer.prototype.drawLeft_ = function() { Blockly.blockRendering.Drawer.prototype.drawInternals_ = function() { for (var i = 0, row; row = this.info_.rows[i]; i++) { for (var j = 0, elem; elem = row.elements[j]; j++) { - var elem = row.elements[e]; if (elem.isInlineInput()) { this.drawInlineInput_(elem); } else if (elem.isIcon() || elem.isField()) { From 54ef08ea04049ff6a9907d9dd5d39a6604775b9c Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Mon, 19 Aug 2019 14:57:13 -0700 Subject: [PATCH 3/3] Fix some annotations --- .../block_rendering_rewrite/block_render_draw_debug.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/renderers/block_rendering_rewrite/block_render_draw_debug.js b/core/renderers/block_rendering_rewrite/block_render_draw_debug.js index b76ba1a32..1278ac3eb 100644 --- a/core/renderers/block_rendering_rewrite/block_render_draw_debug.js +++ b/core/renderers/block_rendering_rewrite/block_render_draw_debug.js @@ -108,7 +108,7 @@ Blockly.blockRendering.Debug.prototype.drawSpacerRow = function(row, cursorY, is /** * Draw a debug rectangle for a horizontal spacer. - * @param {!Blockly.BlockSvg.InRowSpacer} elem The spacer to render. + * @param {!Blockly.blockRendering.InRowSpacer} elem The spacer to render. * @param {number} rowHeight The height of the container row. * @param {boolean} isRtl Whether the block is rendered RTL. * @package @@ -137,7 +137,7 @@ Blockly.blockRendering.Debug.prototype.drawSpacerElem = function(elem, rowHeight /** * Draw a debug rectangle for an in-row element. - * @param {!Blockly.BlockSvg.Measurable} elem The element to render. + * @param {!Blockly.blockRendering.Measurable} elem The element to render. * @param {boolean} isRtl Whether the block is rendered RTL. * @package */ @@ -212,7 +212,7 @@ Blockly.blockRendering.Debug.prototype.drawConnection = function(conn) { /** * Draw a debug rectangle for a non-empty row. - * @param {!Blockly.BlockSvg.Row} row The non-empty row to render. + * @param {!Blockly.blockRendering.Row} row The non-empty row to render. * @param {number} cursorY The y position of the top of the row. * @param {boolean} isRtl Whether the block is rendered RTL. * @package @@ -252,7 +252,7 @@ Blockly.blockRendering.Debug.prototype.drawRenderedRow = function(row, cursorY, /** * Draw debug rectangles for a non-empty row and all of its subcomponents. - * @param {!Blockly.BlockSvg.Row} row The non-empty row to render. + * @param {!Blockly.blockRendering.Row} row The non-empty row to render. * @param {number} cursorY The y position of the top of the row. * @param {boolean} isRtl Whether the block is rendered RTL. * @package