| 1 |
define( [ |
| 2 |
"../core", |
| 3 |
"../var/document", |
| 4 |
"../var/documentElement", |
| 5 |
"../var/support" |
| 6 |
], function( jQuery, document, documentElement, support ) { |
| 7 |
|
| 8 |
"use strict"; |
| 9 |
|
| 10 |
( function() { |
| 11 |
|
| 12 |
// Executing both pixelPosition & boxSizingReliable tests require only one layout |
| 13 |
// so they're executed at the same time to save the second computation. |
| 14 |
function computeStyleTests() { |
| 15 |
|
| 16 |
// This is a singleton, we need to execute it only once |
| 17 |
if ( !div ) { |
| 18 |
return; |
| 19 |
} |
| 20 |
|
| 21 |
container.style.cssText = "position:absolute;left:-11111px;width:60px;" + |
| 22 |
"margin-top:1px;padding:0;border:0"; |
| 23 |
div.style.cssText = |
| 24 |
"position:relative;display:block;box-sizing:border-box;overflow:scroll;" + |
| 25 |
"margin:auto;border:1px;padding:1px;" + |
| 26 |
"width:60%;top:1%"; |
| 27 |
documentElement.appendChild( container ).appendChild( div ); |
| 28 |
|
| 29 |
var divStyle = window.getComputedStyle( div ); |
| 30 |
pixelPositionVal = divStyle.top !== "1%"; |
| 31 |
|
| 32 |
// Support: Android 4.0 - 4.3 only, Firefox <=3 - 44 |
| 33 |
reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12; |
| 34 |
|
| 35 |
// Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3 |
| 36 |
// Some styles come back with percentage values, even though they shouldn't |
| 37 |
div.style.right = "60%"; |
| 38 |
pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36; |
| 39 |
|
| 40 |
// Support: IE 9 - 11 only |
| 41 |
// Detect misreporting of content dimensions for box-sizing:border-box elements |
| 42 |
boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36; |
| 43 |
|
| 44 |
// Support: IE 9 only |
| 45 |
// Detect overflow:scroll screwiness (gh-3699) |
| 46 |
// Support: Chrome <=64 |
| 47 |
// Don't get tricked when zoom affects offsetWidth (gh-4029) |
| 48 |
div.style.position = "absolute"; |
| 49 |
scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12; |
| 50 |
|
| 51 |
documentElement.removeChild( container ); |
| 52 |
|
| 53 |
// Nullify the div so it wouldn't be stored in the memory and |
| 54 |
// it will also be a sign that checks already performed |
| 55 |
div = null; |
| 56 |
} |
| 57 |
|
| 58 |
function roundPixelMeasures( measure ) { |
| 59 |
return Math.round( parseFloat( measure ) ); |
| 60 |
} |
| 61 |
|
| 62 |
var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal, |
| 63 |
reliableTrDimensionsVal, reliableMarginLeftVal, |
| 64 |
container = document.createElement( "div" ), |
| 65 |
div = document.createElement( "div" ); |
| 66 |
|
| 67 |
// Finish early in limited (non-browser) environments |
| 68 |
if ( !div.style ) { |
| 69 |
return; |
| 70 |
} |
| 71 |
|
| 72 |
// Support: IE <=9 - 11 only |
| 73 |
// Style of cloned element affects source element cloned (trac-8908) |
| 74 |
div.style.backgroundClip = "content-box"; |
| 75 |
div.cloneNode( true ).style.backgroundClip = ""; |
| 76 |
support.clearCloneStyle = div.style.backgroundClip === "content-box"; |
| 77 |
|
| 78 |
jQuery.extend( support, { |
| 79 |
boxSizingReliable: function() { |
| 80 |
computeStyleTests(); |
| 81 |
return boxSizingReliableVal; |
| 82 |
}, |
| 83 |
pixelBoxStyles: function() { |
| 84 |
computeStyleTests(); |
| 85 |
return pixelBoxStylesVal; |
| 86 |
}, |
| 87 |
pixelPosition: function() { |
| 88 |
computeStyleTests(); |
| 89 |
return pixelPositionVal; |
| 90 |
}, |
| 91 |
reliableMarginLeft: function() { |
| 92 |
computeStyleTests(); |
| 93 |
return reliableMarginLeftVal; |
| 94 |
}, |
| 95 |
scrollboxSize: function() { |
| 96 |
computeStyleTests(); |
| 97 |
return scrollboxSizeVal; |
| 98 |
}, |
| 99 |
|
| 100 |
// Support: IE 9 - 11+, Edge 15 - 18+ |
| 101 |
// IE/Edge misreport `getComputedStyle` of table rows with width/height |
| 102 |
// set in CSS while `offset*` properties report correct values. |
| 103 |
// Behavior in IE 9 is more subtle than in newer versions & it passes |
| 104 |
// some versions of this test; make sure not to make it pass there! |
| 105 |
// |
| 106 |
// Support: Firefox 70+ |
| 107 |
// Only Firefox includes border widths |
| 108 |
// in computed dimensions. (gh-4529) |
| 109 |
reliableTrDimensions: function() { |
| 110 |
var table, tr, trChild, trStyle; |
| 111 |
if ( reliableTrDimensionsVal == null ) { |
| 112 |
table = document.createElement( "table" ); |
| 113 |
tr = document.createElement( "tr" ); |
| 114 |
trChild = document.createElement( "div" ); |
| 115 |
|
| 116 |
table.style.cssText = "position:absolute;left:-11111px;border-collapse:separate"; |
| 117 |
tr.style.cssText = "border:1px solid"; |
| 118 |
|
| 119 |
// Support: Chrome 86+ |
| 120 |
// Height set through cssText does not get applied. |
| 121 |
// Computed height then comes back as 0. |
| 122 |
tr.style.height = "1px"; |
| 123 |
trChild.style.height = "9px"; |
| 124 |
|
| 125 |
// Support: Android 8 Chrome 86+ |
| 126 |
// In our bodyBackground.html iframe, |
| 127 |
// display for all div elements is set to "inline", |
| 128 |
// which causes a problem only in Android 8 Chrome 86. |
| 129 |
// Ensuring the div is display: block |
| 130 |
// gets around this issue. |
| 131 |
trChild.style.display = "block"; |
| 132 |
|
| 133 |
documentElement |
| 134 |
.appendChild( table ) |
| 135 |
.appendChild( tr ) |
| 136 |
.appendChild( trChild ); |
| 137 |
|
| 138 |
trStyle = window.getComputedStyle( tr ); |
| 139 |
reliableTrDimensionsVal = ( parseInt( trStyle.height, 10 ) + |
| 140 |
parseInt( trStyle.borderTopWidth, 10 ) + |
| 141 |
parseInt( trStyle.borderBottomWidth, 10 ) ) === tr.offsetHeight; |
| 142 |
|
| 143 |
documentElement.removeChild( table ); |
| 144 |
} |
| 145 |
return reliableTrDimensionsVal; |
| 146 |
} |
| 147 |
} ); |
| 148 |
} )(); |
| 149 |
|
| 150 |
return support; |
| 151 |
|
| 152 |
} ); |