compute-kind-widget-no-fallback-props-001.html (3869B)
1 <!DOCTYPE html> 2 <meta name=fuzzy content="maxDifference=0-65; totalPixels=0-100"> 3 <meta charset="utf-8"> 4 <title>CSS Basic User Interface Test: Compute kind of widget: properties that DO NOT disable native appearance for widgets</title> 5 <link rel="help" href="https://drafts.csswg.org/css-ui-4/#appearance-disabling-properties"> 6 <link rel="help" href="https://html.spec.whatwg.org/#widgets"> 7 <meta name="assert" content="appropriate widget is used for properties that don't disable native appearance."> 8 <link rel="match" href="compute-kind-widget-no-fallback-ref.html"> 9 10 <style> 11 #container { width: 500px; } 12 #container > #search-text-input { appearance: textfield; } 13 #container > #select-menulist-button { appearance: none; appearance: menulist-button; } 14 </style> 15 16 <div id="container"> 17 <a>a</a> 18 <button id="button">button</button> 19 <input id="button-input" type="button" value="input-button"> 20 <input id="submit-input" type="submit" value="input-submit"> 21 <input id="reset-input" type="reset" value="input-reset"> 22 23 <input id="text-input" type="text" value="input-text"> 24 <input id="search-text-input" type="search" value="input-search-text"> 25 <input id="search-input" type="search" value="input-search"> 26 27 <input id="range-input" type="range"> 28 <input id="checkbox-input" type="checkbox"> 29 <input id="radio-input" type="radio"> 30 <input id="color-input" type="color"> 31 32 <textarea id="textarea">textarea</textarea> 33 <select multiple id="select-listbox"><option>select-listbox</option></select> 34 <select id="select-dropdown-box"><option>select-dropdown-box</option></select> 35 <select id="select-menulist-button"><option>select-menulist-button</option></select> 36 <meter id="meter" value=0.5></meter> 37 <progress id="progress" value=0.5></progress> 38 </div> 39 40 <script> 41 // Set author-level CSS that matches UA style, but don't use the 'revert' value. 42 const elements = document.querySelectorAll('#container > *'); 43 const fallbackProps = new Set([ 44 'background-color', 45 'border-top-color', 46 'border-top-style', 47 'border-top-width', 48 'border-right-color', 49 'border-right-style', 50 'border-right-width', 51 'border-bottom-color', 52 'border-bottom-style', 53 'border-bottom-width', 54 'border-left-color', 55 'border-left-style', 56 'border-left-width', 57 'border-block-start-color', 58 'border-block-end-color', 59 'border-inline-start-color', 60 'border-inline-end-color', 61 'border-block-start-style', 62 'border-block-end-style', 63 'border-inline-start-style', 64 'border-inline-end-style', 65 'border-block-start-width', 66 'border-block-end-width', 67 'border-inline-start-width', 68 'border-inline-end-width', 69 'background-image', 70 'background-attachment', 71 'background-position', 72 'background-position-x', 73 'background-position-y', 74 'background-clip', 75 'background-origin', 76 'background-size', 77 'border-image-source', 78 'border-image-slice', 79 'border-image-width', 80 'border-image-outset', 81 'border-image-repeat', 82 'border-top-left-radius', 83 'border-top-right-radius', 84 'border-bottom-right-radius', 85 'border-bottom-left-radius', 86 'border-start-start-radius', 87 'border-start-end-radius', 88 'border-end-start-radius', 89 'border-end-end-radius', 90 ]); 91 92 let mutations = [] 93 94 // Make sure that any supported property that is not in the above list 95 // does not affect the widget type. 96 const declarations = getComputedStyle(document.documentElement); 97 98 for (const prop of declarations) { 99 if (fallbackProps.has(prop)) { 100 continue; 101 } 102 for (const el of elements) { 103 mutations.push([el, prop, getComputedStyle(el).getPropertyValue(prop)]); 104 } 105 } 106 107 // Batch all setProperty calls together (without calling gCS().getPropertyValue 108 // for each mutation) to avoid excessive style recalcs. 109 for (let mutation of mutations) { 110 const [el, prop, value] = mutation; 111 el.style.setProperty(prop, value); 112 } 113 </script>