mirror of
https://github.com/google/blockly.git
synced 2026-01-10 18:37:09 +01:00
Fix 8 warnings related to utils. (#3294)
This commit is contained in:
@@ -31,7 +31,7 @@ goog.provide('Blockly.Cursor');
|
||||
* @constructor
|
||||
*/
|
||||
Blockly.Cursor = function() {
|
||||
/*
|
||||
/**
|
||||
* The current location of the cursor.
|
||||
* @type {Blockly.ASTNode}
|
||||
* @private
|
||||
|
||||
@@ -39,7 +39,7 @@ goog.require('Blockly.utils.style');
|
||||
*/
|
||||
Blockly.utils.uiMenu.getSize = function(menu) {
|
||||
var menuDom = menu.getElement();
|
||||
var menuSize = Blockly.utils.style.getSize(menuDom);
|
||||
var menuSize = Blockly.utils.style.getSize(/** @type {!Element} */ (menuDom));
|
||||
// Recalculate height for the total content, not only box height.
|
||||
menuSize.height = menuDom.scrollHeight;
|
||||
return menuSize;
|
||||
|
||||
@@ -121,7 +121,7 @@ Blockly.utils.getInjectionDivXY_ = function(element) {
|
||||
if ((' ' + classes + ' ').indexOf(' injectionDiv ') != -1) {
|
||||
break;
|
||||
}
|
||||
element = element.parentNode;
|
||||
element = /** @type {!Element} */ (element.parentNode);
|
||||
}
|
||||
return new Blockly.utils.Coordinate(x, y);
|
||||
};
|
||||
@@ -190,6 +190,7 @@ Blockly.utils.mouseToSvg = function(e, svg, matrix) {
|
||||
Blockly.utils.getScrollDeltaPixels = function(e) {
|
||||
switch (e.deltaMode) {
|
||||
case 0x00: // Pixel mode.
|
||||
default:
|
||||
return {
|
||||
x: e.deltaX,
|
||||
y: e.deltaY
|
||||
@@ -236,7 +237,7 @@ Blockly.utils.replaceMessageReferences = function(message) {
|
||||
var interpolatedResult = Blockly.utils.tokenizeInterpolation_(message, false);
|
||||
// When parseInterpolationTokens == false, interpolatedResult should be at
|
||||
// most length 1.
|
||||
return interpolatedResult.length ? interpolatedResult[0] : '';
|
||||
return interpolatedResult.length ? String(interpolatedResult[0]) : '';
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,8 +38,8 @@ goog.require('Blockly.utils');
|
||||
* .parse('#f00') -> '#ff0000'
|
||||
* .parse('#ff0000') -> '#ff0000'
|
||||
* .parse('rgb(255, 0, 0)') -> '#ff0000'
|
||||
* @param {string} str Colour in some CSS format.
|
||||
* @return {string|null} A string containing a hex representation of the colour,
|
||||
* @param {string|number} str Colour in some CSS format.
|
||||
* @return {?string} A string containing a hex representation of the colour,
|
||||
* or null if can't be parsed.
|
||||
*/
|
||||
Blockly.utils.colour.parse = function(str) {
|
||||
@@ -166,11 +166,19 @@ Blockly.utils.colour.hsvToHex = function(h, s, v) {
|
||||
* @param {string} colour2 Second colour.
|
||||
* @param {number} factor The weight to be given to colour1 over colour2.
|
||||
* Values should be in the range [0, 1].
|
||||
* @return {string} Combined colour represented in hex.
|
||||
* @return {?string} Combined colour represented in hex.
|
||||
*/
|
||||
Blockly.utils.colour.blend = function(colour1, colour2, factor) {
|
||||
var rgb1 = Blockly.utils.colour.hexToRgb(Blockly.utils.colour.parse(colour1));
|
||||
var rgb2 = Blockly.utils.colour.hexToRgb(Blockly.utils.colour.parse(colour2));
|
||||
var hex1 = Blockly.utils.colour.parse(colour1);
|
||||
if (!hex1) {
|
||||
return null;
|
||||
}
|
||||
var hex2 = Blockly.utils.colour.parse(colour2);
|
||||
if (!hex2) {
|
||||
return null;
|
||||
}
|
||||
var rgb1 = Blockly.utils.colour.hexToRgb(hex1);
|
||||
var rgb2 = Blockly.utils.colour.hexToRgb(hex2);
|
||||
var r = Math.round(rgb2[0] + factor * (rgb1[0] - rgb2[0]));
|
||||
var g = Math.round(rgb2[1] + factor * (rgb1[1] - rgb2[1]));
|
||||
var b = Math.round(rgb2[2] + factor * (rgb1[2] - rgb2[2]));
|
||||
|
||||
Reference in New Issue
Block a user