Fix a dozen compiler warnings.

This commit is contained in:
Neil Fraser
2019-05-17 16:23:18 -07:00
committed by Neil Fraser
parent acd96aa2c5
commit 5cf52c566a
11 changed files with 64 additions and 20 deletions

View File

@@ -629,7 +629,7 @@ Blockly.BlockSvg.prototype.onMouseDown_ = function(e) {
Blockly.BlockSvg.prototype.showHelp_ = function() {
var url = (typeof this.helpUrl == 'function') ? this.helpUrl() : this.helpUrl;
if (url) {
open(url);
window.open(url);
}
};

View File

@@ -411,7 +411,8 @@ Blockly.Events.disableOrphans = function(event) {
var workspace = Blockly.Workspace.getById(event.workspaceId);
var block = workspace.getBlockById(event.blockId);
if (block) {
if (block.getParent() && !block.getParent().disabled) {
var parent = block.getParent()
if (parent && parent.isEnabled()) {
var children = block.getDescendants(false);
for (var i = 0, child; child = children[i]; i++) {
child.setEnabled(true);

View File

@@ -455,7 +455,7 @@ Blockly.Flyout.prototype.show = function(xmlList) {
switch (xml.tagName.toUpperCase()) {
case 'BLOCK':
var curBlock = Blockly.Xml.domToBlock(xml, this.workspace_);
if (curBlock.disabled) {
if (!curBlock.isEnabled()) {
// Record blocks that were initially disabled.
// Do not enable these blocks as a result of capacity filtering.
this.permanentlyDisabled_.push(curBlock);
@@ -612,7 +612,7 @@ Blockly.Flyout.prototype.onMouseDown_ = function(e) {
* @package
*/
Blockly.Flyout.prototype.isBlockCreatable_ = function(block) {
return !block.disabled;
return block.isEnabled();
};
/**

View File

@@ -182,7 +182,7 @@ Blockly.Generator.prototype.blockToCode = function(block, opt_thisOnly) {
if (!block) {
return '';
}
if (block.disabled) {
if (!block.isEnabled()) {
// Skip past this block if it is disabled.
return opt_thisOnly ? '' : this.blockToCode(block.getNextBlock());
}

View File

@@ -734,7 +734,7 @@ Blockly.Gesture.prototype.doFieldClick_ = function() {
Blockly.Gesture.prototype.doBlockClick_ = function() {
// Block click in an autoclosing flyout.
if (this.flyout_ && this.flyout_.autoClose) {
if (!this.targetBlock_.disabled) {
if (this.targetBlock_.isEnabled()) {
if (!Blockly.Events.getGroup()) {
Blockly.Events.setGroup(true);
}

View File

@@ -272,6 +272,21 @@ Blockly.WorkspaceSvg.prototype.trashcan = null;
*/
Blockly.WorkspaceSvg.prototype.scrollbar = null;
/**
* Fixed flyout providing blocks which may be dragged into this workspace.
* @type {Blockly.Flyout}
* @private
*/
Blockly.WorkspaceSvg.prototype.flyout_ = null;
/**
* Category-based toolbox providing blocks which may be dragged into this
* workspace.
* @type {Blockly.Toolbox}
* @private
*/
Blockly.WorkspaceSvg.prototype.toolbox_ = null;
/**
* The current gesture in progress on this workspace, if any.
* @type {Blockly.TouchGesture}
@@ -533,10 +548,6 @@ Blockly.WorkspaceSvg.prototype.createDom = function(opt_backgroundClass) {
// Determine if there needs to be a category tree, or a simple list of
// blocks. This cannot be changed later, since the UI is very different.
if (this.options.hasCategories) {
/**
* @type {Blockly.Toolbox}
* @private
*/
this.toolbox_ = new Blockly.Toolbox(this);
}
if (this.grid_) {
@@ -660,11 +671,6 @@ Blockly.WorkspaceSvg.prototype.addFlyout_ = function(tagName) {
horizontalLayout: this.horizontalLayout,
toolboxPosition: this.options.toolboxPosition
};
/**
* @type {!Blockly.Flyout}
* @private
*/
this.flyout_ = null;
if (this.horizontalLayout) {
this.flyout_ = new Blockly.HorizontalFlyout(workspaceOptions);
} else {
@@ -672,7 +678,7 @@ Blockly.WorkspaceSvg.prototype.addFlyout_ = function(tagName) {
}
this.flyout_.autoClose = false;
// Return the element so that callers can place it in their desired
// Return the element so that callers can place it in their desired
// spot in the DOM. For example, mutator flyouts do not go in the same place
// as main workspace flyouts.
return this.flyout_.createDom(tagName);

View File

@@ -206,7 +206,7 @@ Blockly.Xml.blockToDom = function(block, opt_noId) {
if (block.isCollapsed()) {
element.setAttribute('collapsed', true);
}
if (block.disabled) {
if (!block.isEnabled()) {
element.setAttribute('disabled', true);
}
if (!block.isDeletable() && !block.isShadow()) {
@@ -350,11 +350,13 @@ Blockly.Xml.clearWorkspaceAndLoadFromXml = function(xml, workspace) {
* Decode an XML DOM and create blocks on the workspace.
* @param {!Element} xml XML DOM.
* @param {!Blockly.Workspace} workspace The workspace.
* @return {Array.<string>} An array containing new block IDs.
* @return {!Array.<string>} An array containing new block IDs.
*/
Blockly.Xml.domToWorkspace = function(xml, workspace) {
if (xml instanceof Blockly.Workspace) {
var swap = xml;
// Closure Compiler complains here because the arguments are reversed.
/** @suppress {checkTypes} */
xml = workspace;
workspace = swap;
console.warn('Deprecated call to Blockly.Xml.domToWorkspace, ' +
@@ -498,6 +500,8 @@ Blockly.Xml.appendDomToWorkspace = function(xml, workspace) {
Blockly.Xml.domToBlock = function(xmlBlock, workspace) {
if (xmlBlock instanceof Blockly.Workspace) {
var swap = xmlBlock;
// Closure Compiler complains here because the arguments are reversed.
/** @suppress {checkTypes} */
xmlBlock = workspace;
workspace = swap;
console.warn('Deprecated call to Blockly.Xml.domToBlock, ' +

View File

@@ -58,7 +58,7 @@ Blockly.Xml.utils.createTextNode = function(text) {
* Converts an XML string into a DOM tree. This method will be overridden in
* the Node.js build of Blockly. See gulpfile.js, blockly_javascript_en task.
* @param {string} text XML string.
* @return {!Element} The DOM document.
* @return {Document} The DOM document.
* @throws if XML doesn't parse.
* @package
*/

View File

@@ -0,0 +1,32 @@
/**
* @license
* Visual Blocks Editor
*
* Copyright 2019 Google Inc.
* https://developers.google.com/blockly/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview Property definitions in browsers that Closure Compiler is
* unaware of.
* @author fraser@google.com (Neil Fraser)
*
* @externs
*/
'use strict';
Element.ELEMENT_NODE = 1;
Element.TEXT_NODE = 3;

View File

@@ -82,6 +82,7 @@ COMPILATION_COMMAND="java -jar $COMPILER --js='$BLOCKLY_ROOT/tests/compile/main.
--js='$CLOSURE_LIB_ROOT/closure/goog/**.js' \
--js='$CLOSURE_LIB_ROOT/third_party/closure/goog/**.js' \
--generate_exports \
--externs $BLOCKLY_ROOT/externs/browser-externs.js \
--externs $BLOCKLY_ROOT/externs/svg-externs.js \
--compilation_level ADVANCED_OPTIMIZATIONS \
--dependency_mode=STRICT --entry_point=Main \

View File

@@ -20,7 +20,7 @@
<p>To run this test manually, download
<a href="https://dl.google.com/closure-compiler/compiler-latest.zip">closure-compiler-vxxxxxxxx.jar</a>,
place it in this directory, then run compile.js from the command line.</p>
place it in this directory, then run compile.sh from the command line.</p>
<p>Measure the size of main_compressed.js (295kb as of October 2017), then reload
this page and see if Blockly works.</p>