Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Side by Side Diff: chrome/browser/resources/tracing/measuring_stick.js

Issue 8359025: Tons of timeline tweaks (Closed)
Patch Set: Disable eliding due to perf issues Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 cr.define('tracing', function() {
6 /**
7 * Uses an embedded iframe to measure provided elements without forcing layout
8 * on the main document.
9 * @constructor
10 * @extends {Object}
11 */
12 function MeasuringStick() {
13 var iframe = document.createElement('iframe');
14 iframe.style.cssText = 'width:100%;height:0;border:0;visibility:hidden';
15 document.body.appendChild(iframe);
16 this._doc = iframe.contentDocument;
17 this._window = iframe.contentWindow;
18 this._doc.body.style.cssText = 'padding:0;margin:0;overflow:hidden';
19
20 var stylesheets = document.querySelectorAll('link[rel=stylesheet]');
21 for (var i = 0; i < stylesheets.length; i++) {
22 var stylesheet = stylesheets[i];
23 var link = this._doc.createElement('link');
24 link.rel = 'stylesheet';
25 link.href = stylesheet.href;
26 this._doc.head.appendChild(link);
27 }
28 }
29
30 MeasuringStick.prototype = {
31 __proto__: Object.prototype,
32
33 /**
34 * Measures the provided element without forcing layout on the main
35 * document.
36 */
37 measure: function(element) {
38 this._doc.body.appendChild(element);
39 var style = this._window.getComputedStyle(element);
40 var width = parseInt(style.width, 10);
41 var height = parseInt(style.height, 10);
42 this._doc.body.removeChild(element);
43 return { width: width, height: height };
44 }
45 };
46
47 return {
48 MeasuringStick: MeasuringStick
49 };
50 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698