e2b66fd76893dc1aacc18a72ce8d9a970dcf98257f4856ad753846086c51e82922bb4390cce32c7335443f6e8d71c24b794a48889d6e5a2410fee3789bc349 4.7 KB

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