@@ -0,0 +1,104 @@
4+ <meta charset="UTF-8" />
5+ <title>Rendering Benchmark Viewer</title>
6+ <script type="text/javascript" src="./elm.js"></script>
9+ <body id="root"></body>
11+ <script type="text/javascript">
12+ var app = Elm.InFrontSize.init();
14+ var test_results = "waiting..";
16+ app.ports.report.subscribe(function (results) {
17+ test_results = results;
20+ app.ports.analyze.subscribe(function (ids) {
22+ var idsLength = ids.length;
24+ for (var i = 0; i < idsLength; i++) {
26+ var element = document.getElementById(id);
27+ if (element == null) {
28+ console.log("id " + id + " not found");
30+ var style = getStyle(element);
31+ var bbox = getBoundingBox(element);
33+ var visible = isVisible(id, bbox);
35+ var result = { bbox: bbox, style: style, id: id, isVisible: visible };
36+ results.push(result);
38+ app.ports.styles.send(results);
41+ function isVisible(id, bbox) {
42+ var current = document.getElementById(id);
44+ if (current == document.elementFromPoint(bbox["left"], bbox["top"])) {
48+ current == document.elementFromPoint(bbox["left"], bbox["bottom"] - 1)
53+ current == document.elementFromPoint(bbox["right"] - 1, bbox["top"])
59+ document.elementFromPoint(bbox["right"] - 1, bbox["bottom"] - 1)
71+ function getStyle(element) {
73+ var style = window.getComputedStyle(element);
74+ for (var i = style.length; i--; ) {
75+ var name = style.item(i);
76+ var value = style.getPropertyValue(name);
77+ props.push([name, value]);
82+ function getBoundingBox(element) {
83+ var bbox = element.getBoundingClientRect();
84+ var style = window.getComputedStyle(element, null);
87+ top: parseFloat(style.getPropertyValue("padding-top")),
88+ bottom: parseFloat(style.getPropertyValue("padding-bottom")),
89+ left: parseFloat(style.getPropertyValue("padding-left")),
90+ right: parseFloat(style.getPropertyValue("padding-right")),