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

Unified Diff: Source/devtools/front_end/LayerTreeModel.js

Issue 166273018: Added showing slow scroll rectangles in Layers panel. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixes. Created 6 years, 10 months 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 side-by-side diff with in-line comments
Download patch
Index: Source/devtools/front_end/LayerTreeModel.js
diff --git a/Source/devtools/front_end/LayerTreeModel.js b/Source/devtools/front_end/LayerTreeModel.js
index 2753e10a1493172ccae296afcab68f86c5819a4f..88065032eda2aaa0dfab1ebc18c82e35ef0deb9e 100644
--- a/Source/devtools/front_end/LayerTreeModel.js
+++ b/Source/devtools/front_end/LayerTreeModel.js
@@ -48,6 +48,17 @@ WebInspector.LayerTreeModel.Events = {
LayerPainted: "LayerPainted",
}
+/**
+ * @param {!LayerTreeAgent.ScrollRect} first
+ * @param {!LayerTreeAgent.ScrollRect} second
+ */
+WebInspector.LayerTreeModel._scrollRectsAreEqual = function(first, second)
+{
+ return first.rect.x === second.rect.x && first.rect.y === second.rect.y &&
+ first.rect.width === second.rect.width && first.rect.height === second.rect.height &&
+ first.type === second.type;
+}
+
WebInspector.LayerTreeModel.prototype = {
disable: function()
{
@@ -97,7 +108,7 @@ WebInspector.LayerTreeModel.prototype = {
/**
* @param {function(!WebInspector.Layer)} callback
- * @param {?WebInspector.Layer} root
+ * @param {?WebInspector.Layer=} root
* @return {boolean}
*/
forEachLayer: function(callback, root)
@@ -120,19 +131,19 @@ WebInspector.LayerTreeModel.prototype = {
},
/**
- * @param {!Array.<!LayerTreeAgent.Layer>} payload
+ * @param {!Array.<!LayerTreeAgent.Layer>} layers
*/
- _repopulate: function(payload)
+ _repopulate: function(layers)
{
var oldLayersById = this._layersById;
this._layersById = {};
- for (var i = 0; i < payload.length; ++i) {
- var layerId = payload[i].layerId;
+ for (var i = 0; i < layers.length; ++i) {
+ var layerId = layers[i].layerId;
var layer = oldLayersById[layerId];
if (layer)
- layer._reset(payload[i]);
+ layer._reset(layers[i]);
else
- layer = new WebInspector.Layer(payload[i]);
+ layer = new WebInspector.Layer(layers[i]);
this._layersById[layerId] = layer;
var parentId = layer.parentId();
if (!this._contentRoot && layer.nodeId())
@@ -155,15 +166,15 @@ WebInspector.LayerTreeModel.prototype = {
},
/**
- * @param {!Array.<!LayerTreeAgent.Layer>=} payload
+ * @param {!Array.<!LayerTreeAgent.Layer>=} layers
*/
- _layerTreeChanged: function(payload)
+ _layerTreeChanged: function(layers)
{
this._root = null;
this._contentRoot = null;
// Payload will be null when not in the composited mode.
- if (payload)
- this._repopulate(payload);
+ if (layers)
+ this._repopulate(layers);
this.dispatchEventToListeners(WebInspector.LayerTreeModel.Events.LayerTreeChanged);
},
@@ -197,6 +208,7 @@ WebInspector.LayerTreeModel.prototype = {
*/
WebInspector.Layer = function(layerPayload)
{
+ this._scrollRects = [];
this._reset(layerPayload);
}
@@ -350,6 +362,14 @@ WebInspector.Layer.prototype = {
},
/**
+ * @return {!Array.<!LayerTreeAgent.ScrollRect>}
+ */
+ scrollRects: function()
+ {
+ return this._scrollRects;
+ },
+
+ /**
* @param {function(!Array.<string>)} callback
*/
requestCompositingReasons: function(callback)
@@ -387,6 +407,19 @@ WebInspector.Layer.prototype = {
this._paintCount = 0;
this._layerPayload = layerPayload;
this._image = null;
+ this._updateScrollRects();
+ },
+
+ _updateScrollRects: function()
+ {
+ var newRects = this._layerPayload.scrollRects || [];
+ for (var i = 0; i < newRects.length; ++i) {
+ if (i >= this._scrollRects.length ||
+ !WebInspector.LayerTreeModel._scrollRectsAreEqual(newRects[i], this._scrollRects[i])) {
+ this._scrollRects[i] = newRects[i];
+ }
+ }
+ this._scrollRects.splice(newRects.length);
}
}
@@ -402,11 +435,11 @@ WebInspector.LayerTreeDispatcher = function(layerTreeModel)
WebInspector.LayerTreeDispatcher.prototype = {
/**
- * @param {!Array.<!LayerTreeAgent.Layer>=} payload
+ * @param {!Array.<!LayerTreeAgent.Layer>=} layers
*/
- layerTreeDidChange: function(payload)
+ layerTreeDidChange: function(layers)
{
- this._layerTreeModel._layerTreeChanged(payload);
+ this._layerTreeModel._layerTreeChanged(layers);
},
/**

Powered by Google App Engine
This is Rietveld 408576698