OLD | NEW |
(Empty) | |
| 1 (function() { |
| 2 var templateParagraph = null; |
| 3 var templateFloatingNode = null; |
| 4 var DEFAULT_SHAPE_OBJECT_COUNT = 100; |
| 5 |
| 6 function createParagraphNode() { |
| 7 if (!templateParagraph) { |
| 8 templateParagraph = document.createElement("p"); |
| 9 templateParagraph.innerHTML = "Lorem ipsum dolor sit amet, consectet
ur adipiscing elit. Etiam at turpis placerat sapien congue viverra nec sed felis
.\ |
| 10 Aenean aliquam, justo eu condimentum pharetra, arcu eros blandit
metus, nec lacinia nisi orci vitae nunc.\ |
| 11 Proin orci libero, accumsan non dignissim at, sodales in sapien.
Curabitur dui nibh, venenatis vel tempus vel, accumsan nec velit.\ |
| 12 Nam sit amet tempor lacus. Sed mollis dolor nibh, non tempus leo
. Donec magna odio, commodo id porta in, aliquam mollis eros.\ |
| 13 Pellentesque vulputate gravida ligula in elementum. Fusce lacini
a massa justo, at porttitor orci.\ |
| 14 Vestibulum ante ipsum primis in faucibus orci luctus et ultrices
posuere cubilia Curae; Donec odio quam, pulvinar ut porttitor ac, tempor vitae
ligula.\ |
| 15 Cras aliquet sapien id sapien mollis nec pulvinar mauris adipisc
ing. Praesent porttitor consequat augue, sit amet mollis justo condimentum eu.\ |
| 16 Etiam ut erat pellentesque orci congue interdum. Nulla eu eros m
i.\ |
| 17 Curabitur rutrum, lorem ac malesuada pellentesque, sapien risus
consequat massa, eget pellentesque nunc nulla vel sem."; |
| 18 templateParagraph.className = "contentParagraph"; |
| 19 } |
| 20 |
| 21 var paragraph = templateParagraph.cloneNode(true); |
| 22 return paragraph; |
| 23 } |
| 24 |
| 25 function createFloatingNode(properties) { |
| 26 if (!templateFloatingNode) { |
| 27 templateFloatingNode = document.createElement("div"); |
| 28 templateFloatingNode.className = "floatingObject"; |
| 29 } |
| 30 |
| 31 var float = templateFloatingNode.cloneNode(false); |
| 32 for (prop in properties) { |
| 33 float.style[prop] = properties[prop]; |
| 34 } |
| 35 return float; |
| 36 } |
| 37 |
| 38 function addArticles(floatingObjects, paragraphCount) { |
| 39 for (var i = 0; i < paragraphCount; ++i) { |
| 40 floatingObjects.appendChild(createParagraphNode()); |
| 41 } |
| 42 } |
| 43 |
| 44 function createFloatingObjects(properties, floatingObjectCount) { |
| 45 var testBox = document.createElement("div"); |
| 46 for (var i = 0; i < floatingObjectCount; ++i) { |
| 47 testBox.appendChild(createFloatingNode(properties)); |
| 48 testBox.appendChild(createParagraphNode()) |
| 49 } |
| 50 testBox.className = "testBox"; |
| 51 return testBox; |
| 52 } |
| 53 |
| 54 function applyFloating() { |
| 55 var floatingObjects = document.getElementsByClassName('floatingObject'); |
| 56 for (i = 0; i < floatingObjects.length; ++i) { |
| 57 floatingObjects[i].style.cssFloat = 'left'; |
| 58 } |
| 59 } |
| 60 |
| 61 function createShapeOutsideTest(properties, shapeObjectCount) { |
| 62 shapeObjectCount = shapeObjectCount || DEFAULT_SHAPE_OBJECT_COUNT; |
| 63 |
| 64 var floatingObjects = createFloatingObjects(properties, shapeObjectCount
); |
| 65 document.body.appendChild(floatingObjects); |
| 66 return { |
| 67 description: "Testing shapes with " + properties['webkitShapeOutside
'] +" using " + shapeObjectCount + " shapes.", |
| 68 run: function() { |
| 69 applyFloating(); |
| 70 document.body.offsetTop; |
| 71 }, |
| 72 setup: function() { |
| 73 PerfTestRunner.resetRandomSeed(); |
| 74 document.body.offsetTop; |
| 75 }, |
| 76 done: function() { |
| 77 document.body.removeChild(floatingObjects); |
| 78 templateParagraph = null; |
| 79 } |
| 80 }; |
| 81 } |
| 82 |
| 83 window.createShapeOutsideTest = createShapeOutsideTest; |
| 84 |
| 85 })(); |
OLD | NEW |