Skip to content

Commit 25feb10

Browse files
authored
Remove checks for window.scrollX / window.scrollY (#26702)
The last time these checks were needed was back in the IE 8 days AFAICT.
1 parent 722a1b7 commit 25feb10

File tree

3 files changed

+6
-26
lines changed

3 files changed

+6
-26
lines changed

src/lib/libbrowser.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -397,18 +397,8 @@ var LibraryBrowser = {
397397
var canvas = Browser.getCanvas();
398398
var rect = canvas.getBoundingClientRect();
399399

400-
// Neither .scrollX or .pageXOffset are defined in a spec, but
401-
// we prefer .scrollX because it is currently in a spec draft.
402-
// (see: http://www.w3.org/TR/2013/WD-cssom-view-20131217/)
403-
var scrollX = ((typeof window.scrollX != 'undefined') ? window.scrollX : window.pageXOffset);
404-
var scrollY = ((typeof window.scrollY != 'undefined') ? window.scrollY : window.pageYOffset);
405-
#if ASSERTIONS
406-
// If this assert lands, it's likely because the browser doesn't support scrollX or pageXOffset
407-
// and we have no viable fallback.
408-
assert((typeof scrollX != 'undefined') && (typeof scrollY != 'undefined'), 'Unable to retrieve scroll position, mouse positions likely broken.');
409-
#endif
410-
var adjustedX = pageX - (scrollX + rect.left);
411-
var adjustedY = pageY - (scrollY + rect.top);
400+
var adjustedX = pageX - (window.scrollX + rect.left);
401+
var adjustedY = pageY - (window.scrollY + rect.top);
412402

413403
// the canvas might be CSS-scaled compared to its backbuffer;
414404
// SDL-using content will want mouse coordinates in terms

src/lib/libglfw.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,18 +1320,8 @@ var LibraryGLFW = {
13201320
// in the coordinates.
13211321
const rect = Browser.getCanvas().getBoundingClientRect();
13221322

1323-
// Neither .scrollX or .pageXOffset are defined in a spec, but
1324-
// we prefer .scrollX because it is currently in a spec draft.
1325-
// (see: http://www.w3.org/TR/2013/WD-cssom-view-20131217/)
1326-
var scrollX = ((typeof window.scrollX != 'undefined') ? window.scrollX : window.pageXOffset);
1327-
var scrollY = ((typeof window.scrollY != 'undefined') ? window.scrollY : window.pageYOffset);
1328-
#if ASSERTIONS
1329-
// If this assert lands, it's likely because the browser doesn't support scrollX or pageXOffset
1330-
// and we have no viable fallback.
1331-
assert((typeof scrollX != 'undefined') && (typeof scrollY != 'undefined'), 'Unable to retrieve scroll position, mouse positions likely broken.');
1332-
#endif
1333-
var adjustedX = pageX - (scrollX + rect.left);
1334-
var adjustedY = pageY - (scrollY + rect.top);
1323+
var adjustedX = pageX - (window.scrollX + rect.left);
1324+
var adjustedY = pageY - (window.scrollY + rect.top);
13351325

13361326
// getBoundingClientRect() returns dimension affected by CSS, so as a result:
13371327
// - when CSS scaling is enabled, this will fix the mouse coordinates to match the width/height of the window

test/codesize/test_codesize_hello_dylink_all.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"a.out.js": 244303,
2+
"a.out.js": 244191,
33
"a.out.nodebug.wasm": 577664,
4-
"total": 821967,
4+
"total": 821855,
55
"sent": [
66
"IMG_Init",
77
"IMG_Load",

0 commit comments

Comments
 (0)