Remove calls to goog.dom.getViewportSize

document.documentElement.clientWidth/clientHeight seems to work everywhere Blockly works.  Closure’s functions are mind-numbingly complex due to IE5, old WebKit, Opera 8, and others.
This commit is contained in:
Neil Fraser
2019-05-15 15:01:44 -07:00
committed by Neil Fraser
parent ed0b5adcd1
commit 49954e0cec
4 changed files with 9 additions and 14 deletions

View File

@@ -30,9 +30,9 @@ goog.provide('Blockly.DropDownDiv');
goog.require('Blockly.utils');
goog.require('goog.dom');
goog.require('goog.style');
/**
* Class for drop-down div.
* @constructor

View File

@@ -37,8 +37,6 @@ goog.provide('Blockly.Tooltip');
goog.require('Blockly.utils');
goog.require('goog.dom');
/**
* Is a tooltip currently showing?
@@ -303,7 +301,8 @@ Blockly.Tooltip.show_ = function() {
Blockly.Tooltip.DIV.appendChild(div);
}
var rtl = Blockly.Tooltip.element_.RTL;
var windowSize = goog.dom.getViewportSize();
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
// Display the tooltip.
Blockly.Tooltip.DIV.style.direction = rtl ? 'rtl' : 'ltr';
Blockly.Tooltip.DIV.style.display = 'block';
@@ -318,7 +317,7 @@ Blockly.Tooltip.show_ = function() {
var anchorY = Blockly.Tooltip.lastY_ + Blockly.Tooltip.OFFSET_Y;
if (anchorY + Blockly.Tooltip.DIV.offsetHeight >
windowSize.height + window.scrollY) {
windowHeight + window.scrollY) {
// Falling off the bottom of the screen; shift the tooltip up.
anchorY -= Blockly.Tooltip.DIV.offsetHeight + 2 * Blockly.Tooltip.OFFSET_Y;
}
@@ -327,10 +326,10 @@ Blockly.Tooltip.show_ = function() {
anchorX = Math.max(Blockly.Tooltip.MARGINS - window.scrollX, anchorX);
} else {
if (anchorX + Blockly.Tooltip.DIV.offsetWidth >
windowSize.width + window.scrollX - 2 * Blockly.Tooltip.MARGINS) {
windowWidth + window.scrollX - 2 * Blockly.Tooltip.MARGINS) {
// Falling off the right edge of the screen;
// clamp the tooltip on the edge.
anchorX = windowSize.width - Blockly.Tooltip.DIV.offsetWidth -
anchorX = windowWidth - Blockly.Tooltip.DIV.offsetWidth -
2 * Blockly.Tooltip.MARGINS;
}
}

View File

@@ -34,7 +34,6 @@ goog.provide('Blockly.utils');
goog.require('Blockly.userAgent');
goog.require('goog.dom');
goog.require('goog.math.Coordinate');
@@ -909,13 +908,11 @@ Blockly.utils.setCssTransform = function(node, transform) {
* @package
*/
Blockly.utils.getViewportBBox = function() {
// Pixels.
var windowSize = goog.dom.getViewportSize();
// Pixels, in window coordinates.
var scrollOffset = goog.style.getViewportPageOffset(document);
return {
right: windowSize.width + scrollOffset.x,
bottom: windowSize.height + scrollOffset.y,
right: document.documentElement.clientWidth + scrollOffset.x,
bottom: document.documentElement.clientHeight + scrollOffset.y,
top: scrollOffset.y,
left: scrollOffset.x
};

View File

@@ -767,8 +767,7 @@ Blockly.WorkspaceSvg.prototype.updateScreenCalculationsIfScrolled =
function() {
/* eslint-disable indent */
var currScroll = goog.dom.getDocumentScroll();
if (!goog.math.Coordinate.equals(this.lastRecordedPageScroll_,
currScroll)) {
if (!goog.math.Coordinate.equals(this.lastRecordedPageScroll_, currScroll)) {
this.lastRecordedPageScroll_ = currScroll;
this.updateScreenCalculations_();
}