OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /* | 5 /* |
6 Exported functions: | 6 Exported functions: |
7 assertCSSResponsive | 7 assertCSSResponsive |
8 assertSVGResponsive | 8 assertSVGResponsive |
9 | 9 |
10 Exported objects: | 10 Exported objects: |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 var pendingResponsiveTests = []; | 44 var pendingResponsiveTests = []; |
45 var htmlNamespace = 'http://www.w3.org/1999/xhtml'; | 45 var htmlNamespace = 'http://www.w3.org/1999/xhtml'; |
46 var svgNamespace = 'http://www.w3.org/2000/svg'; | 46 var svgNamespace = 'http://www.w3.org/2000/svg'; |
47 var neutralKeyframe = {}; | 47 var neutralKeyframe = {}; |
48 | 48 |
49 function assertCSSResponsive(options) { | 49 function assertCSSResponsive(options) { |
50 pendingResponsiveTests.push({ | 50 pendingResponsiveTests.push({ |
51 options, | 51 options, |
52 bindings: { | 52 bindings: { |
53 prefixProperty(property) { | 53 prefixProperty(property) { |
54 return property; | 54 return toCamelCase(property); |
55 }, | 55 }, |
56 createTargetContainer(container) { | 56 createTargetContainer(container) { |
57 if (options.targetTag) { | 57 if (options.targetTag) { |
58 var svgRoot = createElement('svg', container, 'svg-root', svgNamespace
); | 58 var svgRoot = createElement('svg', container, 'svg-root', svgNamespace
); |
59 svgRoot.setAttribute('width', 0); | 59 svgRoot.setAttribute('width', 0); |
60 svgRoot.setAttribute('height', 0); | 60 svgRoot.setAttribute('height', 0); |
61 return svgRoot; | 61 return svgRoot; |
62 } | 62 } |
63 | 63 |
64 return createElement('div', container); | 64 return createElement('div', container); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 } | 156 } |
157 | 157 |
158 function isNeutralKeyframe(keyframe) { | 158 function isNeutralKeyframe(keyframe) { |
159 return keyframe === neutralKeyframe; | 159 return keyframe === neutralKeyframe; |
160 } | 160 } |
161 | 161 |
162 function keyframeText(keyframe) { | 162 function keyframeText(keyframe) { |
163 return isNeutralKeyframe(keyframe) ? 'neutral' : `[${keyframe}]`; | 163 return isNeutralKeyframe(keyframe) ? 'neutral' : `[${keyframe}]`; |
164 } | 164 } |
165 | 165 |
| 166 function toCamelCase(property) { |
| 167 for (var i = property.length - 2; i > 0; --i) { |
| 168 if (property[i] === '-') { |
| 169 property = property.substring(0, i) + property[i + 1].toUpperCase() + prop
erty.substring(i + 2); |
| 170 } |
| 171 } |
| 172 return property; |
| 173 } |
| 174 |
166 function createKeyframes(prefixedProperty, from, to) { | 175 function createKeyframes(prefixedProperty, from, to) { |
167 var keyframes = []; | 176 var keyframes = []; |
168 if (!isNeutralKeyframe(from)) { | 177 if (!isNeutralKeyframe(from)) { |
169 keyframes.push({ | 178 keyframes.push({ |
170 offset: 0, | 179 offset: 0, |
171 [prefixedProperty]: from, | 180 [prefixedProperty]: from, |
172 }); | 181 }); |
173 } | 182 } |
174 if (!isNeutralKeyframe(to)) { | 183 if (!isNeutralKeyframe(to)) { |
175 keyframes.push({ | 184 keyframes.push({ |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 asyncHandle.done(); | 277 asyncHandle.done(); |
269 }); | 278 }); |
270 }); | 279 }); |
271 | 280 |
272 | 281 |
273 window.assertCSSResponsive = assertCSSResponsive; | 282 window.assertCSSResponsive = assertCSSResponsive; |
274 window.assertSVGResponsive = assertSVGResponsive; | 283 window.assertSVGResponsive = assertSVGResponsive; |
275 window.neutralKeyframe = neutralKeyframe; | 284 window.neutralKeyframe = neutralKeyframe; |
276 | 285 |
277 })(); | 286 })(); |
OLD | NEW |