OLD | NEW |
1 function createRectangleTest(elementId, stylesheetId, bounds, shapeBounds, units
, content) { | 1 function createRectangleTest(elementId, stylesheetId, bounds, shapeBounds, units
, content) { |
2 var elem; | 2 var elem; |
3 if (elementId) | 3 if (elementId) |
4 elem = document.getElementById(elementId); | 4 elem = document.getElementById(elementId); |
5 else { | 5 else { |
6 elem = document.createElement('div'); | 6 elem = document.createElement('div'); |
7 elem.setAttribute('id', elementId); | 7 elem.setAttribute('id', elementId); |
8 document.appendChild(elem); | 8 document.appendChild(elem); |
9 } | 9 } |
10 | 10 |
11 var stylesheet = document.getElementById(stylesheetId).sheet; | 11 var stylesheet = document.getElementById(stylesheetId).sheet; |
12 var rules = []; | 12 var rules = []; |
13 for (var i in bounds) | 13 for (var i in bounds) |
14 rules.push(i + ':' + bounds[i] + units); | 14 rules.push(i + ':' + bounds[i] + units); |
15 var rectangleBounds = [shapeBounds.x + units, shapeBounds.y + units, shapeBo
unds.width + units, shapeBounds.height + units]; | 15 var rectangleBounds = { |
16 rules.push('shape-inside: rectangle(' + rectangleBounds.join(',') + ')'); | 16 top: shapeBounds.x + units, |
| 17 left: shapeBounds.y + units, |
| 18 bottom: (shapeBounds.y + shapeBounds.height) + units, |
| 19 right: (shapeBounds.x + shapeBounds.width) + units |
| 20 }; |
| 21 rules.push('-webkit-shape-inside: polygon(' + |
| 22 rectangleBounds.left + " " + rectangleBounds.top + "," + |
| 23 rectangleBounds.right + " " + rectangleBounds.top + "," + |
| 24 rectangleBounds.right + " " + rectangleBounds.bottom + "," + |
| 25 rectangleBounds.left + " " + rectangleBounds.bottom + ')'); |
17 rules.push('position: relative'); | 26 rules.push('position: relative'); |
18 rules.push('overflow-wrap: break-word'); | 27 rules.push('overflow-wrap: break-word'); |
19 stylesheet.insertRule('#' + elementId + '{' + rules.join(';') + '}', 0); | 28 stylesheet.insertRule('#' + elementId + '{' + rules.join(';') + '}', 0); |
20 | 29 |
21 rules = []; | 30 rules = []; |
22 rules.push('left: ' + (shapeBounds.x - 1) + units, 'top: ' + (shapeBounds.y
- 1) + units, 'width: ' + rectangleBounds[2], 'height: ' + rectangleBounds[3]); | 31 rules.push('left: ' + (shapeBounds.x - 1) + units, 'top: ' + (shapeBounds.y
- 1) + units, 'width: ' + shapeBounds.width + units, 'height: ' + shapeBounds.he
ight + units); |
23 rules.push('position: absolute', 'display: block', 'content: \' \''); | 32 rules.push('position: absolute', 'display: block', 'content: \' \''); |
24 rules.push('border: 1px solid blue'); | 33 rules.push('border: 1px solid blue'); |
25 stylesheet.insertRule('#' + elementId + ':before{' + rules.join(';') + '}',
0); | 34 stylesheet.insertRule('#' + elementId + ':before{' + rules.join(';') + '}',
0); |
26 if (content) | 35 if (content) |
27 elem.innerHTML = content; | 36 elem.innerHTML = content; |
28 } | 37 } |
29 | 38 |
30 function createRectangleTestResult(elementId, stylesheetId, bounds, shapeBounds,
units, content) { | 39 function createRectangleTestResult(elementId, stylesheetId, bounds, shapeBounds,
units, content) { |
31 var elem; | 40 var elem; |
32 if (elementId) | 41 if (elementId) |
(...skipping 14 matching lines...) Expand all Loading... |
47 stylesheet.insertRule('#' + elementId + '{' + rules.join(';') + '}', 0); | 56 stylesheet.insertRule('#' + elementId + '{' + rules.join(';') + '}', 0); |
48 | 57 |
49 rules = []; | 58 rules = []; |
50 rules.push('left: ' + (shapeBounds.x - 1) + units, 'top: ' + (shapeBounds.y
- 1) + units, 'width: ' + shapeBounds.width + units, 'height: ' + shapeBounds.he
ight + units); | 59 rules.push('left: ' + (shapeBounds.x - 1) + units, 'top: ' + (shapeBounds.y
- 1) + units, 'width: ' + shapeBounds.width + units, 'height: ' + shapeBounds.he
ight + units); |
51 rules.push('position: absolute', 'display: block', 'content: \' \''); | 60 rules.push('position: absolute', 'display: block', 'content: \' \''); |
52 rules.push('border: 1px solid blue'); | 61 rules.push('border: 1px solid blue'); |
53 stylesheet.insertRule('#' + elementId + ':before{' + rules.join(';') + '}',
0); | 62 stylesheet.insertRule('#' + elementId + ':before{' + rules.join(';') + '}',
0); |
54 if (content) | 63 if (content) |
55 elem.innerHTML = content; | 64 elem.innerHTML = content; |
56 } | 65 } |
OLD | NEW |