OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @constructor | 6 * @constructor |
7 * @extends {WebInspector.SplitView} | 7 * @extends {WebInspector.SplitView} |
8 */ | 8 */ |
9 WebInspector.TimelinePaintProfilerView = function() | 9 WebInspector.TimelinePaintProfilerView = function() |
10 { | 10 { |
11 WebInspector.SplitView.call(this, false, false); | 11 WebInspector.SplitView.call(this, false, false); |
12 this.element.classList.add("timeline-paint-profiler-view"); | 12 this.element.classList.add("timeline-paint-profiler-view"); |
13 | 13 |
14 this.setSidebarSize(60); | 14 this.setSidebarSize(60); |
15 this.setResizable(false); | 15 this.setResizable(false); |
16 this._logAndImageSplitView = new WebInspector.SplitView(true, false); | 16 this._logAndImageSplitView = new WebInspector.SplitView(true, false); |
17 this._logAndImageSplitView.show(this.mainElement()); | 17 this._logAndImageSplitView.show(this.mainElement()); |
18 this._imageContainerElement = this._logAndImageSplitView.mainElement().creat
eChild("div", "fill paint-profiler-image-view"); | 18 this._imageView = new WebInspector.TimelinePaintImageView(); |
19 this._imageElement = this._imageContainerElement.createChild("img"); | 19 this._imageView.show(this._logAndImageSplitView.mainElement()); |
20 this._imageElement.addEventListener("load", this._updateImagePosition.bind(t
his), false); | |
21 | 20 |
22 this._paintProfilerView = new WebInspector.PaintProfilerView(this._showImage
.bind(this)); | 21 this._paintProfilerView = new WebInspector.PaintProfilerView(this._imageView
.showImage.bind(this._imageView)); |
23 this._paintProfilerView.addEventListener(WebInspector.PaintProfilerView.Even
ts.WindowChanged, this._onWindowChanged, this); | 22 this._paintProfilerView.addEventListener(WebInspector.PaintProfilerView.Even
ts.WindowChanged, this._onWindowChanged, this); |
24 this._paintProfilerView.show(this.sidebarElement()); | 23 this._paintProfilerView.show(this.sidebarElement()); |
25 | 24 |
26 this._logTreeView = new WebInspector.PaintProfilerCommandLogView(); | 25 this._logTreeView = new WebInspector.PaintProfilerCommandLogView(); |
27 this._logTreeView.show(this._logAndImageSplitView.sidebarElement()); | 26 this._logTreeView.show(this._logAndImageSplitView.sidebarElement()); |
28 | |
29 this._transformController = new WebInspector.TransformController(this._image
ContainerElement, true); | |
30 this._transformController.addEventListener(WebInspector.TransformController.
Events.TransformChanged, this._updateImagePosition, this); | |
31 } | 27 } |
32 | 28 |
33 WebInspector.TimelinePaintProfilerView.prototype = { | 29 WebInspector.TimelinePaintProfilerView.prototype = { |
34 wasShown: function() | 30 wasShown: function() |
35 { | 31 { |
36 this._innerSetPicture(this._picture); | 32 this._innerSetPicture(this._picture); |
37 }, | 33 }, |
38 | 34 |
39 /** | 35 /** |
40 * @param {string} encodedPicture | 36 * @param {string} encodedPicture |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 * @param {!Array.<!Object>=} log | 68 * @param {!Array.<!Object>=} log |
73 * @this {WebInspector.TimelinePaintProfilerView} | 69 * @this {WebInspector.TimelinePaintProfilerView} |
74 */ | 70 */ |
75 function onCommandLogDone(snapshot, log) | 71 function onCommandLogDone(snapshot, log) |
76 { | 72 { |
77 this._logTreeView.setCommandLog(log); | 73 this._logTreeView.setCommandLog(log); |
78 this._paintProfilerView.setSnapshotAndLog(snapshot || null, log || [
]); | 74 this._paintProfilerView.setSnapshotAndLog(snapshot || null, log || [
]); |
79 } | 75 } |
80 }, | 76 }, |
81 | 77 |
82 _updateImagePosition: function() | |
83 { | |
84 var width = this._imageElement.width; | |
85 var height = this._imageElement.height; | |
86 | |
87 var container = this._logAndImageSplitView.mainElement(); | |
88 var paddingFactor = 1.1; | |
89 var scaleX = container.clientWidth / width / paddingFactor; | |
90 var scaleY = container.clientHeight / height / paddingFactor; | |
91 var scale = Math.min(scaleX, scaleY); | |
92 | |
93 var matrix = new WebKitCSSMatrix() | |
94 .translate(this._transformController.offsetX(), this._transformContr
oller.offsetY()) | |
95 .scale(this._transformController.scale(), this._transformController.
scale()) | |
96 .translate(container.clientWidth / 2, container.clientHeight / 2) | |
97 .scale(scale, scale) | |
98 .translate(-width / 2, -height / 2); | |
99 | |
100 this._imageElement.style.webkitTransform = matrix.toString(); | |
101 }, | |
102 | |
103 _onWindowChanged: function() | 78 _onWindowChanged: function() |
104 { | 79 { |
105 var window = this._paintProfilerView.windowBoundaries(); | 80 var window = this._paintProfilerView.windowBoundaries(); |
106 this._logTreeView.updateWindow(window.left, window.right); | 81 this._logTreeView.updateWindow(window.left, window.right); |
107 }, | 82 }, |
108 | 83 |
| 84 __proto__: WebInspector.SplitView.prototype |
| 85 }; |
| 86 |
| 87 /** |
| 88 * @constructor |
| 89 * @extends {WebInspector.View} |
| 90 */ |
| 91 WebInspector.TimelinePaintImageView = function() |
| 92 { |
| 93 WebInspector.View.call(this); |
| 94 this.element.classList.add("fill", "paint-profiler-image-view"); |
| 95 this._imageElement = this.element.createChild("img"); |
| 96 this._imageElement.addEventListener("load", this._updateImagePosition.bind(t
his), false); |
| 97 |
| 98 this._transformController = new WebInspector.TransformController(this.elemen
t, true); |
| 99 this._transformController.addEventListener(WebInspector.TransformController.
Events.TransformChanged, this._updateImagePosition, this); |
| 100 } |
| 101 |
| 102 WebInspector.TimelinePaintImageView.prototype = { |
| 103 onResize: function() |
| 104 { |
| 105 this._updateImagePosition(); |
| 106 }, |
| 107 |
| 108 _updateImagePosition: function() |
| 109 { |
| 110 var width = this._imageElement.width; |
| 111 var height = this._imageElement.height; |
| 112 |
| 113 var paddingFactor = 1.1; |
| 114 var scaleX = this.element.clientWidth / width / paddingFactor; |
| 115 var scaleY = this.element.clientHeight / height / paddingFactor; |
| 116 var scale = Math.min(scaleX, scaleY); |
| 117 |
| 118 var matrix = new WebKitCSSMatrix() |
| 119 .translate(this._transformController.offsetX(), this._transformContr
oller.offsetY()) |
| 120 .scale(this._transformController.scale(), this._transformController.
scale()) |
| 121 .translate(this.element.clientWidth / 2, this.element.clientHeight /
2) |
| 122 .scale(scale, scale) |
| 123 .translate(-width / 2, -height / 2); |
| 124 |
| 125 this._imageElement.style.webkitTransform = matrix.toString(); |
| 126 }, |
| 127 |
109 /** | 128 /** |
110 * @param {string=} imageURL | 129 * @param {string=} imageURL |
111 */ | 130 */ |
112 _showImage: function(imageURL) | 131 showImage: function(imageURL) |
113 { | 132 { |
114 this._imageElement.classList.toggle("hidden", !imageURL); | 133 this._imageElement.classList.toggle("hidden", !imageURL); |
115 this._imageElement.src = imageURL; | 134 this._imageElement.src = imageURL; |
116 }, | 135 }, |
117 | 136 |
118 __proto__: WebInspector.SplitView.prototype | 137 __proto__: WebInspector.View.prototype |
119 }; | 138 }; |
120 | |
OLD | NEW |