mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-31 09:01:56 +01:00
DOMRect: further performance improvements
Total improvement compared to 0.5.8: 7.2 (For #253)
This commit is contained in:
parent
82ba61095a
commit
587bd5bca8
@ -4,7 +4,7 @@
|
||||
(function(){
|
||||
"use strict";
|
||||
|
||||
var scope;
|
||||
let scope;
|
||||
if ((typeof exports) !== "undefined"){
|
||||
scope = exports;
|
||||
}
|
||||
@ -16,7 +16,7 @@
|
||||
const {byteArrayToString: hash} = require("./hash");
|
||||
|
||||
|
||||
var randomSupply = null;
|
||||
let randomSupply = null;
|
||||
scope.setRandomSupply = function(supply){
|
||||
randomSupply = supply;
|
||||
};
|
||||
@ -93,8 +93,8 @@
|
||||
fakeGenerator: function(checker){
|
||||
return function getClientRects(){
|
||||
return checkerWrapper(checker, this, arguments, function(args, check){
|
||||
var {prefs, notify, window, original} = check;
|
||||
var ret = original.apply(this, window.Array.from(args));
|
||||
const {prefs, notify, window, original} = check;
|
||||
const ret = args.length? original.apply(this, window.Array.from(args)): original.call(this);
|
||||
for (let i = 0; i < ret.length; i += 1){
|
||||
registerDOMRect(ret[i], notify, window, prefs);
|
||||
}
|
||||
@ -108,8 +108,8 @@
|
||||
fakeGenerator: function(checker){
|
||||
return function getBoundingClientRect(){
|
||||
return checkerWrapper(checker, this, arguments, function(args, check){
|
||||
var {prefs, notify, window, original} = check;
|
||||
var ret = original.apply(this, window.Array.from(args));
|
||||
const {prefs, notify, window, original} = check;
|
||||
const ret = args.length? original.apply(this, window.Array.from(args)): original.call(this);
|
||||
registerDOMRect(ret, notify, window, prefs);
|
||||
return ret;
|
||||
});
|
||||
@ -122,8 +122,8 @@
|
||||
fakeGenerator: function(checker){
|
||||
return function getBounds(){
|
||||
return checkerWrapper(checker, this, arguments, function(args, check){
|
||||
var {prefs, notify, window, original} = check;
|
||||
var ret = original.apply(this, window.Array.from(args));
|
||||
const {prefs, notify, window, original} = check;
|
||||
const ret = args.length? original.apply(this, window.Array.from(args)): original.call(this);
|
||||
registerDOMRect(ret, notify, window, prefs);
|
||||
return ret;
|
||||
});
|
||||
@ -135,8 +135,8 @@
|
||||
fakeGenerator: function(checker){
|
||||
return function getBBox(){
|
||||
return checkerWrapper(checker, this, arguments, function(args, check){
|
||||
var {prefs, notify, window, original} = check;
|
||||
var ret = original.apply(this, window.Array.from(args));
|
||||
const {prefs, notify, window, original} = check;
|
||||
const ret = args.length? original.apply(this, window.Array.from(args)): original.call(this);
|
||||
registerDOMRect(ret, notify, window, prefs);
|
||||
return ret;
|
||||
});
|
||||
@ -148,8 +148,8 @@
|
||||
fakeGenerator: function(checker){
|
||||
return function getBBox(){
|
||||
return checkerWrapper(checker, this, arguments, function(args, check){
|
||||
var {prefs, notify, window, original} = check;
|
||||
var ret = original.apply(this, window.Array.from(args));
|
||||
const {prefs, notify, window, original} = check;
|
||||
const ret = args.length? original.apply(this, window.Array.from(args)): original.call(this);
|
||||
registerDOMRect(ret, notify, window, prefs);
|
||||
return ret;
|
||||
});
|
||||
@ -236,7 +236,9 @@
|
||||
get intersectionRect(){
|
||||
return checkerWrapper(checker, this, arguments, function(args, check){
|
||||
const {prefs, notify, window, original} = check;
|
||||
const originalValue = original.apply(this, window.Array.from(args));
|
||||
const originalValue = args.length?
|
||||
original.apply(this, window.Array.from(args)):
|
||||
original.call(this);
|
||||
registerDOMRect(originalValue, notify, window, prefs);
|
||||
return originalValue;
|
||||
});
|
||||
@ -257,7 +259,9 @@
|
||||
get boundingClientRect(){
|
||||
return checkerWrapper(checker, this, arguments, function(args, check){
|
||||
const {prefs, notify, window, original} = check;
|
||||
const originalValue = original.apply(this, window.Array.from(args));
|
||||
const originalValue = args.length?
|
||||
original.apply(this, window.Array.from(args)):
|
||||
original.call(this);
|
||||
registerDOMRect(originalValue, notify, window, prefs);
|
||||
return originalValue;
|
||||
});
|
||||
@ -278,7 +282,9 @@
|
||||
get rootBounds(){
|
||||
return checkerWrapper(checker, this, arguments, function(args, check){
|
||||
const {prefs, notify, window, original} = check;
|
||||
const originalValue = original.apply(this, window.Array.from(args));
|
||||
const originalValue = args.length?
|
||||
original.apply(this, window.Array.from(args)):
|
||||
original.call(this);
|
||||
registerDOMRect(originalValue, notify, window, prefs);
|
||||
return originalValue;
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user