| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <!-- | 2 <!-- |
| 3 Copyright (c) 2015 The Chromium Authors. All rights reserved. | 3 Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 4 Use of this source code is governed by a BSD-style license that can be | 4 Use of this source code is governed by a BSD-style license that can be |
| 5 found in the LICENSE file. | 5 found in the LICENSE file. |
| 6 --> | 6 --> |
| 7 | 7 |
| 8 <link rel="import" href="/tracing/base/base.html"> | 8 <link rel="import" href="/tracing/base/base.html"> |
| 9 <link rel="import" href="/tracing/base/rect.html"> | 9 <link rel="import" href="/tracing/base/math/rect.html"> |
| 10 | 10 |
| 11 <script> | 11 <script> |
| 12 'use strict'; | 12 'use strict'; |
| 13 | 13 |
| 14 tr.exportTo('tr.ui.b', function() { | 14 tr.exportTo('tr.ui.b', function() { |
| 15 function instantiateTemplate(selector, doc) { | 15 function instantiateTemplate(selector, doc) { |
| 16 doc = doc || document; | 16 doc = doc || document; |
| 17 var el = Polymer.dom(doc).querySelector(selector); | 17 var el = Polymer.dom(doc).querySelector(selector); |
| 18 if (!el) | 18 if (!el) |
| 19 throw new Error('Element not found'); | 19 throw new Error('Element not found'); |
| 20 return doc.importNode(el.content, true); | 20 return doc.importNode(el.content, true); |
| 21 // return el.createInstance(); | 21 // return el.createInstance(); |
| 22 } | 22 } |
| 23 | 23 |
| 24 function windowRectForElement(element) { | 24 function windowRectForElement(element) { |
| 25 var position = [element.offsetLeft, element.offsetTop]; | 25 var position = [element.offsetLeft, element.offsetTop]; |
| 26 var size = [element.offsetWidth, element.offsetHeight]; | 26 var size = [element.offsetWidth, element.offsetHeight]; |
| 27 var node = element.offsetParent; | 27 var node = element.offsetParent; |
| 28 while (node) { | 28 while (node) { |
| 29 position[0] += node.offsetLeft; | 29 position[0] += node.offsetLeft; |
| 30 position[1] += node.offsetTop; | 30 position[1] += node.offsetTop; |
| 31 node = node.offsetParent; | 31 node = node.offsetParent; |
| 32 } | 32 } |
| 33 return tr.b.Rect.fromXYWH(position[0], position[1], size[0], size[1]); | 33 return tr.b.math.Rect.fromXYWH(position[0], position[1], size[0], size[1]); |
| 34 } | 34 } |
| 35 | 35 |
| 36 function scrollIntoViewIfNeeded(el) { | 36 function scrollIntoViewIfNeeded(el) { |
| 37 var pr = el.parentElement.getBoundingClientRect(); | 37 var pr = el.parentElement.getBoundingClientRect(); |
| 38 var cr = el.getBoundingClientRect(); | 38 var cr = el.getBoundingClientRect(); |
| 39 if (cr.top < pr.top) { | 39 if (cr.top < pr.top) { |
| 40 el.scrollIntoView(true); | 40 el.scrollIntoView(true); |
| 41 } else if (cr.bottom > pr.bottom) { | 41 } else if (cr.bottom > pr.bottom) { |
| 42 el.scrollIntoView(false); | 42 el.scrollIntoView(false); |
| 43 } | 43 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 73 return { | 73 return { |
| 74 isUnknownElementName, | 74 isUnknownElementName, |
| 75 toThreeDigitLocaleString, | 75 toThreeDigitLocaleString, |
| 76 instantiateTemplate, | 76 instantiateTemplate, |
| 77 windowRectForElement, | 77 windowRectForElement, |
| 78 scrollIntoViewIfNeeded, | 78 scrollIntoViewIfNeeded, |
| 79 extractUrlString, | 79 extractUrlString, |
| 80 }; | 80 }; |
| 81 }); | 81 }); |
| 82 </script> | 82 </script> |
| OLD | NEW |