@@ -839,7 +839,7 @@ const get_scr_pixels = (METRIC) => new Promise(resolve => {
839
839
- our div element should always have a height of 96
840
840
- regardless of zoom + system scaling + layout.css.devPixelsPerPx (which combined == devicePixelRatio)
841
841
- but IDK about e.g. QLED/Quantum "dots" and other emerging standards
842
- // tested with zooming levels: it's always 96
842
+ // tested with zooming levels: it's always 96 (domrect, offset, client)
843
843
- system scaling 100% | 125%
844
844
- layout.css.devPixelsPerPx 1.1 (equivalent to 110% zoom)
845
845
- system scaling 125% + layout.css.devPixelsPerPx 1.1 combined
@@ -945,150 +945,6 @@ const get_scr_positions = (METRIC) => new Promise(resolve => {
945
945
return resolve ( )
946
946
} )
947
947
948
- const get_scr_scrollbar = ( METRIC , runtype ) => new Promise ( resolve => {
949
- // ui.useOverlayScrollbars: 0 = no, 1 = yes
950
- // https://bugzilla.mozilla.org/show_bug.cgi?id=1786665
951
- // widget.non-native-theme.scrollbar.style = values 1 to 5
952
- // widget.non-native-theme.scrollbar.size.override <-- non-overlay only
953
- Promise . all ( [
954
- // get the viewport width: we only return zErr or a number
955
- get_scr_viewport ( runtype )
956
- ] ) . then ( function ( res ) {
957
- let oData = { 'auto' : { } , 'thin' : { } }
958
- let aAuto = [ ] , aThin = [ ] , aWindow = [ ]
959
- let list = [ 'auto' , 'thin' ]
960
- let vpData = res [ 0 ]
961
- // NOTE: values are all widths and have been type checked
962
- // desktop: document, element, visualViewport, svw
963
- // "element" is the window size using an element - we used the name "element" in viewport sizes
964
- // but here "element" is the an element (such as a test field) scrollbar, so we call it "window"
965
- // visualViewport = visualViewport.width
966
- // svw is small viewport unit which is a css way of getting visualViewport.width: so a different method
967
-
968
- // scrollWidth
969
- function get_scroll ( ) {
970
- let element
971
- list . forEach ( function ( p ) {
972
- // element
973
- let value , item = 'element'
974
- try {
975
- element = dom . tzpScroll
976
- element . style [ 'scrollbar-width' ] = p
977
- let target = element . children [ 0 ]
978
- let range , width
979
- if ( isDomRect == - 1 ) {
980
- width = target . offsetWidth
981
- } else {
982
- if ( isDomRect > 1 ) {
983
- range = document . createRange ( )
984
- range . selectNode ( target )
985
- }
986
- if ( isDomRect < 1 ) { width = target . getBoundingClientRect ( ) . width
987
- } else if ( isDomRect == 1 ) { width = target . getClientRects ( ) [ 0 ] . width
988
- } else if ( isDomRect == 2 ) { width = range . getBoundingClientRect ( ) . width
989
- } else if ( isDomRect > 2 ) { width = range . getClientRects ( ) [ 0 ] . width
990
- }
991
- }
992
- if ( runST ) { width = NaN } else if ( runSI ) { width = 101 }
993
- let typeCheck = typeFn ( width )
994
- if ( 'number' !== typeCheck ) { throw zErrType + typeCheck }
995
- value = 100 - width // 100 set in html, not affected by zoom
996
- if ( value < 0 ) { throw zErrInvalid + '< 0' }
997
- } catch ( e ) {
998
- value = zErr
999
- log_error ( 1 , METRIC + '_' + p + '_' + item , e )
1000
- }
1001
- oData [ p ] [ item ] = value
1002
- if ( 'auto' == p ) { aAuto . push ( value ) } else { aThin . push ( value ) }
1003
-
1004
- // scrollWidth
1005
- value = undefined , item = 'scrollWidth'
1006
- try {
1007
- element . style [ 'scrollbar-width' ] = p
1008
- value = 100 - element . scrollWidth
1009
- if ( runST ) { value = NaN } else if ( runSI ) { value = - 1 }
1010
- let typeCheck = typeFn ( value )
1011
- if ( 'number' !== typeCheck ) { throw zErrType + typeCheck }
1012
- if ( value < 0 ) { throw zErrInvalid + '< 0' }
1013
- } catch ( e ) {
1014
- value = zErr
1015
- log_error ( 1 , METRIC + '_' + p + '_' + item , e )
1016
- }
1017
- oData [ p ] [ item ] = value
1018
- if ( 'auto' == p ) { aAuto . push ( value ) } else { aThin . push ( value ) }
1019
- } )
1020
- }
1021
-
1022
- // oDataWindow items
1023
- function get_viewport ( item ) {
1024
- let viewport = item == 'element' ? vpData . width . element : vpData . width [ item ]
1025
- let value
1026
- try {
1027
- // on desktop our integer base value is window.inner
1028
- let iwidth = window . innerWidth
1029
- //iwidth = 9000 // test cssW fallback
1030
- value = ( iwidth - viewport )
1031
- if ( runSI ) { value = - 1.333 } // runST: we already return viewport as NaN
1032
- let typeCheck = typeFn ( value )
1033
- if ( 'number' !== typeCheck ) { throw zErrType + typeCheck }
1034
- if ( value < - 1 ) { throw zErrInvalid + '< -1' }
1035
- // leverage css inner width
1036
- let cssW = getElementProp ( 1 , '#D' , METRIC + '_' + item + '_css' , ':before' )
1037
- if ( cssW !== '?' && cssW !== zErr ) {
1038
- if ( cssW * 1 == iwidth - 1 ) { cssW = iwidth } // round up: i.e allow for min-
1039
- value = cssW - viewport
1040
- }
1041
- } catch ( e ) {
1042
- value = zErr
1043
- log_error ( 1 , METRIC + '_window_' + item , e )
1044
- }
1045
- oData . window [ item ] = value
1046
- aWindow . push ( value )
1047
- }
1048
-
1049
- function tidySB ( array ) {
1050
- let str = array . join ( ', ' )
1051
- array = array . filter ( function ( item , position ) { return array . indexOf ( item ) === position } )
1052
- if ( 1 == array . length ) { str = array [ 0 ] }
1053
- return str
1054
- }
1055
-
1056
- get_scroll ( )
1057
- addDisplay ( 1 , METRIC , tidySB ( aAuto ) + ' | ' + tidySB ( aThin ) )
1058
- /* health example if we go overlays
1059
- // if the diff is between 0 and 1, this entropy is already in the window measurement data: so round down for health
1060
- let isScrollbarOverlay = false
1061
- array.forEach(function(item) {if (0 !== Math.floor(Math.abs(item))) {isScrollbarOverlay = true}})
1062
- */
1063
-
1064
-
1065
- /* android
1066
- - visualViewport.width changes with pinch-zoom
1067
- - window (which is a full width element + domrect) is almost stable but pull to refresh and pinch-zoom can cause slight variation
1068
- - svw has nothing to compare to: since we don't have a stable window.inner due to dynamic toolbar
1069
- - nothimg we can measure against
1070
- */
1071
- /* window scrollbar [desktop only]
1072
- - we are using high precision measurments (viewport or a fullsize element) vs window (integer)
1073
- - if an overlay, this = diff reflects devicePixelRatio/zoom etc
1074
- - and this entropy is already in the window measurement data
1075
- - if not an overlay: the diff will reflect the scrollbar width more accurately and well as subpixel issues
1076
- - IDK if this is added entropy
1077
- */
1078
- if ( 'android' !== isOS ) {
1079
- oData [ 'window' ] = { }
1080
- // in alphabetical order
1081
- get_viewport ( 'document' )
1082
- get_viewport ( 'element' ) // full-size element
1083
- get_viewport ( 'visualViewport' )
1084
- addDisplay ( 1 , METRIC + '_window' , tidySB ( aWindow ) )
1085
- }
1086
-
1087
- addData ( 1 , METRIC , oData , mini ( oData ) )
1088
- return resolve ( )
1089
- } )
1090
- } )
1091
-
1092
948
function get_scr_viewport_units ( ) {
1093
949
// desktop + android use small in inner section
1094
950
// android uses large as a standalone
@@ -1673,7 +1529,7 @@ const outputScreen = (isResize = false) => new Promise(resolve => {
1673
1529
get_scr_fullscreen ( 'fullscreen' ) ,
1674
1530
get_scr_positions ( 'positions' ) ,
1675
1531
get_scr_pixels ( 'pixels' ) ,
1676
- get_scr_scrollbar ( 'scrollbars' , runtype ) , // gets viewport + viewport units
1532
+ get_scr_viewport ( runtype ) , // gets viewport units
1677
1533
get_scr_orientation ( 'orientation' ) ,
1678
1534
get_scr_measure ( ) ,
1679
1535
] ) . then ( function ( ) {
0 commit comments