Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / devtools / front_end / layers / LayerPaintProfilerView.js
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
3 // found in the LICENSE file.
4
5 /**
6  * @constructor
7  * @param {function(!WebInspector.Layer, string=)} showImageForLayerCallback
8  * @extends {WebInspector.SplitView}
9  */
10 WebInspector.LayerPaintProfilerView = function(showImageForLayerCallback)
11 {
12     WebInspector.SplitView.call(this, true, false);
13
14     this._showImageForLayerCallback = showImageForLayerCallback;
15     this._logTreeView = new WebInspector.PaintProfilerCommandLogView();
16     this._logTreeView.show(this.sidebarElement());
17     this._paintProfilerView = new WebInspector.PaintProfilerView(this._showImage.bind(this));
18     this._paintProfilerView.show(this.mainElement());
19
20     this._paintProfilerView.addEventListener(WebInspector.PaintProfilerView.Events.WindowChanged, this._onWindowChanged, this);
21 }
22
23 WebInspector.LayerPaintProfilerView.prototype = {
24     /**
25      * @param {!WebInspector.Layer} layer
26      */
27     profileLayer: function(layer)
28     {
29         this._logTreeView.setCommandLog(null, []);
30         this._paintProfilerView.setSnapshotAndLog(null, []);
31         layer.requestSnapshot(onSnapshotDone.bind(this));
32
33         /**
34          * @param {!WebInspector.PaintProfilerSnapshot=} snapshot
35          * @this {WebInspector.LayerPaintProfilerView}
36          */
37         function onSnapshotDone(snapshot)
38         {
39             this._layer = layer;
40             snapshot.commandLog(onCommandLogDone.bind(this, snapshot));
41         }
42
43         /**
44          * @param {!WebInspector.PaintProfilerSnapshot=} snapshot
45          * @param {!Array.<!Object>=} log
46          * @this {WebInspector.LayerPaintProfilerView}
47          */
48         function onCommandLogDone(snapshot, log)
49         {
50             this._logTreeView.setCommandLog(snapshot.target(), log);
51             this._paintProfilerView.setSnapshotAndLog(snapshot || null, log || []);
52         }
53     },
54
55     _onWindowChanged: function()
56     {
57         var window = this._paintProfilerView.windowBoundaries();
58         this._logTreeView.updateWindow(window.left, window.right);
59     },
60
61     /**
62      * @param {string=} imageURL
63      */
64     _showImage: function(imageURL)
65     {
66         this._showImageForLayerCallback(this._layer, imageURL);
67     },
68
69     __proto__: WebInspector.SplitView.prototype
70 };
71