mirror of
https://github.com/google/blockly.git
synced 2026-05-10 14:10:11 +02:00
b0475b0c68
* fix: Remove spurious blank lines Remove extraneous blank lines introduced by deletion of 'use strict'; pragmas. Also fix the location of the goog.declareModuleId call in core/utils/array.ts. * fix: Add missing double-blank-line before body of modules Our convention is to have two blank lines between the imports (or module ID, if there are no imports) and the beginning of the body of the module. Enforce this. * fix: one addition format error for PR #6243
52 lines
1.2 KiB
TypeScript
52 lines
1.2 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright 2019 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
/**
|
|
* @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.
|
|
*/
|
|
|
|
/**
|
|
* Utility methods for size calculation.
|
|
* These methods are not specific to Blockly, and could be factored out into
|
|
* a JavaScript framework such as Closure.
|
|
* @class
|
|
*/
|
|
import * as goog from '../../closure/goog/goog.js';
|
|
goog.declareModuleId('Blockly.utils.Size');
|
|
|
|
|
|
/**
|
|
* Class for representing sizes consisting of a width and height.
|
|
* @alias Blockly.utils.Size
|
|
*/
|
|
export class Size {
|
|
/**
|
|
* @param width Width.
|
|
* @param height Height.
|
|
* @struct
|
|
*/
|
|
constructor(public width: number, public height: number) {}
|
|
|
|
/**
|
|
* Compares sizes for equality.
|
|
* @param a A Size.
|
|
* @param b A Size.
|
|
* @return True iff the sizes have equal widths and equal heights, or if both
|
|
* are null.
|
|
*/
|
|
static equals(a: Size|null, b: Size|null): boolean {
|
|
if (a === b) {
|
|
return true;
|
|
}
|
|
if (!a || !b) {
|
|
return false;
|
|
}
|
|
return a.width === b.width && a.height === b.height;
|
|
}
|
|
}
|