| OLD | NEW |
| (Empty) |
| 1 function createRectangleTest(elementId, stylesheetId, bounds, shapeBounds, units
, content) { | |
| 2 var elem; | |
| 3 if (elementId) | |
| 4 elem = document.getElementById(elementId); | |
| 5 else { | |
| 6 elem = document.createElement('div'); | |
| 7 elem.setAttribute('id', elementId); | |
| 8 document.appendChild(elem); | |
| 9 } | |
| 10 | |
| 11 var stylesheet = document.getElementById(stylesheetId).sheet; | |
| 12 var rules = []; | |
| 13 for (var i in bounds) | |
| 14 rules.push(i + ':' + bounds[i] + units); | |
| 15 var rectangleBounds = { | |
| 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 + ')'); | |
| 26 rules.push('position: relative'); | |
| 27 rules.push('overflow-wrap: break-word'); | |
| 28 stylesheet.insertRule('#' + elementId + '{' + rules.join(';') + '}', 0); | |
| 29 | |
| 30 rules = []; | |
| 31 rules.push('left: ' + (shapeBounds.x - 1) + units, 'top: ' + (shapeBounds.y
- 1) + units, 'width: ' + shapeBounds.width + units, 'height: ' + shapeBounds.he
ight + units); | |
| 32 rules.push('position: absolute', 'display: block', 'content: \' \''); | |
| 33 rules.push('border: 1px solid blue'); | |
| 34 stylesheet.insertRule('#' + elementId + ':before{' + rules.join(';') + '}',
0); | |
| 35 if (content) | |
| 36 elem.innerHTML = content; | |
| 37 } | |
| 38 | |
| 39 function createRectangleTestResult(elementId, stylesheetId, bounds, shapeBounds,
units, content) { | |
| 40 var elem; | |
| 41 if (elementId) | |
| 42 elem = document.getElementById(elementId); | |
| 43 else { | |
| 44 elem = document.createElement('div'); | |
| 45 elem.setAttribute('id', elementId); | |
| 46 document.appendChild(elem); | |
| 47 } | |
| 48 | |
| 49 var stylesheet = document.getElementById(stylesheetId).sheet; | |
| 50 var rules = []; | |
| 51 rules.push('width: ' + shapeBounds.width + units, 'height: ' + shapeBounds.h
eight + units); | |
| 52 rules.push('padding-left: ' + shapeBounds.x + units, 'padding-right: ' + (bo
unds.width - shapeBounds.width - shapeBounds.x) + units); | |
| 53 rules.push('padding-top: ' + shapeBounds.y + units, 'padding-bottom: ' + (bo
unds.height - shapeBounds.height - shapeBounds.y) + units); | |
| 54 rules.push('position: relative'); | |
| 55 rules.push('overflow-wrap: break-word'); | |
| 56 stylesheet.insertRule('#' + elementId + '{' + rules.join(';') + '}', 0); | |
| 57 | |
| 58 rules = []; | |
| 59 rules.push('left: ' + (shapeBounds.x - 1) + units, 'top: ' + (shapeBounds.y
- 1) + units, 'width: ' + shapeBounds.width + units, 'height: ' + shapeBounds.he
ight + units); | |
| 60 rules.push('position: absolute', 'display: block', 'content: \' \''); | |
| 61 rules.push('border: 1px solid blue'); | |
| 62 stylesheet.insertRule('#' + elementId + ':before{' + rules.join(';') + '}',
0); | |
| 63 if (content) | |
| 64 elem.innerHTML = content; | |
| 65 } | |
| OLD | NEW |