mirror of
https://github.com/google/blockly.git
synced 2026-01-11 10:57:07 +01:00
* Google changed from an Inc to an LLC. This happened back in 2017 but we didn’t notice. Officially we should update files from Inc to LLC when they are changed as part of regular edits, but this is a nightmare to remember for the next decade. * Remove project description/titles from licenses This is no longer part of Google’s header requirements. Our existing descriptions were useless (“Visual Blocks Editor”) or grossly obselete (“Visual Blocks Language”). * License no longer requires URL. * Fix license regexps.
70 lines
1.7 KiB
JavaScript
70 lines
1.7 KiB
JavaScript
/**
|
|
* @license
|
|
* Copyright 2019 Google LLC
|
|
*
|
|
* 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 Utility methods for size calculation.
|
|
* These methods are not specific to Blockly, and could be factored out into
|
|
* a JavaScript framework such as Closure.
|
|
* @author samelh@google.com (Sam El-Husseini)
|
|
*/
|
|
'use strict';
|
|
|
|
/**
|
|
* @name Blockly.utils.Size
|
|
* @namespace
|
|
*/
|
|
goog.provide('Blockly.utils.Size');
|
|
|
|
|
|
/**
|
|
* Class for representing sizes consisting of a width and height.
|
|
* @param {number} width Width.
|
|
* @param {number} height Height.
|
|
* @struct
|
|
* @constructor
|
|
*/
|
|
Blockly.utils.Size = function(width, height) {
|
|
/**
|
|
* Width
|
|
* @type {number}
|
|
*/
|
|
this.width = width;
|
|
|
|
/**
|
|
* Height
|
|
* @type {number}
|
|
*/
|
|
this.height = height;
|
|
};
|
|
|
|
/**
|
|
* Compares sizes for equality.
|
|
* @param {Blockly.utils.Size} a A Size.
|
|
* @param {Blockly.utils.Size} b A Size.
|
|
* @return {boolean} True iff the sizes have equal widths and equal
|
|
* heights, or if both are null.
|
|
*/
|
|
Blockly.utils.Size.equals = function(a, b) {
|
|
if (a == b) {
|
|
return true;
|
|
}
|
|
if (!a || !b) {
|
|
return false;
|
|
}
|
|
return a.width == b.width && a.height == b.height;
|
|
};
|