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

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: Added test. 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..8dc07ba0ea871802f64572d96ad99d7e6f45ece7 100644
--- a/Source/devtools/front_end/LayerTreeModel.js
+++ b/Source/devtools/front_end/LayerTreeModel.js
@@ -36,6 +36,7 @@ WebInspector.LayerTreeModel = function()
{
WebInspector.Object.call(this);
this._layersById = {};
+ this._scrollRectsByLayerId = {};
// We fetch layer tree lazily and get paint events asynchronously, so keep the last painted
// rect separate from layer so we can get it after refreshing the tree.
this._lastPaintRectByLayerId = {};
@@ -48,6 +49,17 @@ WebInspector.LayerTreeModel.Events = {
LayerPainted: "LayerPainted",
}
+/**
+ * @param {!LayerTreeAgent.ScrollRect} first
+ * @param {!LayerTreeAgent.ScrollRect} second
+ */
+WebInspector.LayerTreeModel._scrollRectsEqual = function(first, second)
+{
+ return first.x === second.x && first.y === second.y &&
+ first.width === second.width && first.height === second.height &&
+ first.layerId === second.layerId && first.type === second.type;
+}
+
WebInspector.LayerTreeModel.prototype = {
disable: function()
{
@@ -120,19 +132,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 +167,56 @@ WebInspector.LayerTreeModel.prototype = {
},
/**
- * @param {!Array.<!LayerTreeAgent.Layer>=} payload
+ * @param {!Array.<!LayerTreeAgent.ScrollRect>=} scrollRects
+ */
+ _updateScrollRects: function(scrollRects)
+ {
+ var newScrollRectsByLayerId = {};
+ var i, layerId;
+ for (i = 0; i < scrollRects.length; ++i) {
+ var scrollRect = scrollRects[i];
+ var layer = this._layersById[scrollRect.layerId];
+ // FIXME
caseq 2014/02/24 07:18:06 You can remove this once https://codereview.chromi
malch 2014/02/24 13:59:15 Done.
+ if ((layer.width() !== 0 && layer.height() !== 0) &&
+ (scrollRect.width > layer.width() || scrollRect.height > layer.height()) &&
+ !layer.parent().parent())
+ continue;
+ if (scrollRect.layerId in newScrollRectsByLayerId)
+ newScrollRectsByLayerId[scrollRect.layerId].push(scrollRect);
+ else
+ newScrollRectsByLayerId[scrollRect.layerId] = [scrollRect];
+ }
+ for (layerId in this._scrollRectsByLayerId) {
+ if (!newScrollRectsByLayerId[layerId])
+ delete this._scrollRectsByLayerId[layerId];
+ }
+ for (layerId in newScrollRectsByLayerId) {
+ if (!this._scrollRectsByLayerId[layerId])
+ this._scrollRectsByLayerId[layerId] = [];
+ var oldScrollRects = this._scrollRectsByLayerId[layerId];
+ for (i = 0; i < newScrollRectsByLayerId[layerId].length; ++i) {
+ if (i >= oldScrollRects.length ||
+ !WebInspector.LayerTreeModel._scrollRectsEqual(newScrollRectsByLayerId[layerId][i], oldScrollRects[i])) {
+ oldScrollRects[i] = newScrollRectsByLayerId[layerId][i];
+ }
+ }
+ oldScrollRects.splice(newScrollRectsByLayerId[layerId].length);
+ }
+ },
+
+ /**
+ * @param {!Array.<!LayerTreeAgent.Layer>=} layers
+ * @param {!Array.<!LayerTreeAgent.ScrollRect>=} scrollRects
*/
- _layerTreeChanged: function(payload)
+ _layerTreeChanged: function(layers, scrollRects)
{
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);
+ if (scrollRects)
+ this._updateScrollRects(scrollRects);
this.dispatchEventToListeners(WebInspector.LayerTreeModel.Events.LayerTreeChanged);
},
@@ -402,11 +455,12 @@ WebInspector.LayerTreeDispatcher = function(layerTreeModel)
WebInspector.LayerTreeDispatcher.prototype = {
/**
- * @param {!Array.<!LayerTreeAgent.Layer>=} payload
+ * @param {!Array.<!LayerTreeAgent.Layer>=} layers
+ * @param {!Array.<!LayerTreeAgent.ScrollRect>=} scrollRects
*/
- layerTreeDidChange: function(payload)
+ layerTreeDidChange: function(layers, scrollRects)
{
- this._layerTreeModel._layerTreeChanged(payload);
+ this._layerTreeModel._layerTreeChanged(layers, scrollRects);
},
/**

Powered by Google App Engine
This is Rietveld 408576698