| 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..f0795533671943cf0b4493641183b305b6094edd 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,27 @@ WebInspector.LayerTreeModel.prototype = {
|
| },
|
|
|
| /**
|
| - * @param {!Array.<!LayerTreeAgent.Layer>} payload
|
| + * @return {!Object}
|
| + */
|
| + scrollRectsByLayerId: function()
|
| + {
|
| + return this._scrollRectsByLayerId;
|
| + },
|
| +
|
| + /**
|
| + * @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 +175,50 @@ 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];
|
| + 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);
|
| + this._updateScrollRects(scrollRects || []);
|
| this.dispatchEventToListeners(WebInspector.LayerTreeModel.Events.LayerTreeChanged);
|
| },
|
|
|
| @@ -402,11 +457,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);
|
| },
|
|
|
| /**
|
|
|