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

Side by Side Diff: Source/devtools/front_end/Layers3DView.js

Issue 166273018: Added showing slow scroll rectangles in Layers panel. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Moved ScrollRects into Layer structure. Created 6 years, 9 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 this._model.addEventListener(WebInspector.LayerTreeModel.Events.LayerPainted , this._onLayerPainted, this); 43 this._model.addEventListener(WebInspector.LayerTreeModel.Events.LayerPainted , this._onLayerPainted, this);
44 this._rotatingContainerElement = this.element.createChild("div", "fill rotat ing-container"); 44 this._rotatingContainerElement = this.element.createChild("div", "fill rotat ing-container");
45 this.element.addEventListener("mousemove", this._onMouseMove.bind(this), fal se); 45 this.element.addEventListener("mousemove", this._onMouseMove.bind(this), fal se);
46 this.element.addEventListener("mouseout", this._onMouseMove.bind(this), fals e); 46 this.element.addEventListener("mouseout", this._onMouseMove.bind(this), fals e);
47 this.element.addEventListener("mousedown", this._onMouseDown.bind(this), fal se); 47 this.element.addEventListener("mousedown", this._onMouseDown.bind(this), fal se);
48 this.element.addEventListener("mouseup", this._onMouseUp.bind(this), false); 48 this.element.addEventListener("mouseup", this._onMouseUp.bind(this), false);
49 this.element.addEventListener("contextmenu", this._onContextMenu.bind(this), false); 49 this.element.addEventListener("contextmenu", this._onContextMenu.bind(this), false);
50 this.element.addEventListener("dblclick", this._onDoubleClick.bind(this), fa lse); 50 this.element.addEventListener("dblclick", this._onDoubleClick.bind(this), fa lse);
51 this.element.addEventListener("click", this._onClick.bind(this), false); 51 this.element.addEventListener("click", this._onClick.bind(this), false);
52 this._elementsByLayerId = {}; 52 this._elementsByLayerId = {};
53 this._scrollRectElementsByLayerId = {}
53 this._rotateX = 0; 54 this._rotateX = 0;
54 this._rotateY = 0; 55 this._rotateY = 0;
55 this._scaleAdjustmentStylesheet = this.element.ownerDocument.head.createChil d("style"); 56 this._scaleAdjustmentStylesheet = this.element.ownerDocument.head.createChil d("style");
56 this._scaleAdjustmentStylesheet.disabled = true; 57 this._scaleAdjustmentStylesheet.disabled = true;
57 this._lastOutlinedElement = {}; 58 this._lastOutlinedElement = {};
58 this._layerImage = document.createElement("img"); 59 this._layerImage = document.createElement("img");
59 WebInspector.settings.showPaintRects.addChangeListener(this._update, this); 60 WebInspector.settings.showPaintRects.addChangeListener(this._update, this);
60 } 61 }
61 62
62 /** 63 /**
(...skipping 12 matching lines...) Expand all
75 LayerSelected: "LayerSelected", 76 LayerSelected: "LayerSelected",
76 LayerSnapshotRequested: "LayerSnapshotRequested" 77 LayerSnapshotRequested: "LayerSnapshotRequested"
77 } 78 }
78 79
79 WebInspector.Layers3DView.PaintRectColors = [ 80 WebInspector.Layers3DView.PaintRectColors = [
80 WebInspector.Color.fromRGBA([0, 0x5F, 0, 0x3F]), 81 WebInspector.Color.fromRGBA([0, 0x5F, 0, 0x3F]),
81 WebInspector.Color.fromRGBA([0, 0xAF, 0, 0x3F]), 82 WebInspector.Color.fromRGBA([0, 0xAF, 0, 0x3F]),
82 WebInspector.Color.fromRGBA([0, 0xFF, 0, 0x3F]) 83 WebInspector.Color.fromRGBA([0, 0xFF, 0, 0x3F])
83 ] 84 ]
84 85
86 /**
87 * @enum {string}
88 */
89 WebInspector.Layers3DView.ScrollRectTitles = {
90 RepaintsOnScroll: WebInspector.UIString("repaints on scroll"),
91 TouchEventHandler: WebInspector.UIString("touch event listener"),
92 WheelEventHandler: WebInspector.UIString("mousewheel event listener")
93 }
94
85 WebInspector.Layers3DView.prototype = { 95 WebInspector.Layers3DView.prototype = {
86 onResize: function() 96 onResize: function()
87 { 97 {
88 this._update(); 98 this._update();
89 }, 99 },
90 100
91 willHide: function() 101 willHide: function()
92 { 102 {
93 this._scaleAdjustmentStylesheet.disabled = true; 103 this._scaleAdjustmentStylesheet.disabled = true;
94 }, 104 },
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 this._scaleAdjustmentStylesheet.textContent = stylesheetContent; 184 this._scaleAdjustmentStylesheet.textContent = stylesheetContent;
175 else 185 else
176 stylesheetTextNode.nodeValue = stylesheetContent; 186 stylesheetTextNode.nodeValue = stylesheetContent;
177 var element = this._elementForLayer(root); 187 var element = this._elementForLayer(root);
178 element.style.webkitTransform = "scale3d(" + this._scale + "," + this._s cale + "," + this._scale + ")"; 188 element.style.webkitTransform = "scale3d(" + this._scale + "," + this._s cale + "," + this._scale + ")";
179 element.style.webkitTransformOrigin = ""; 189 element.style.webkitTransformOrigin = "";
180 element.style.left = ((this._clientWidth - root.width() * this._scale) > > 1) + "px"; 190 element.style.left = ((this._clientWidth - root.width() * this._scale) > > 1) + "px";
181 element.style.top = ((this._clientHeight - root.height() * this._scale) >> 1) + "px"; 191 element.style.top = ((this._clientHeight - root.height() * this._scale) >> 1) + "px";
182 }, 192 },
183 193
194 /**
195 * @param {!Element} element
196 */
197 _removeElement: function(element)
198 {
199 element.remove()
200 },
201
202 /**
203 * @param {!string} layerId
204 */
205 _removeScrollRects: function(layerId)
206 {
207 this._scrollRectElementsByLayerId[layerId].forEach(this._removeElement);
208 delete this._scrollRectElementsByLayerId[layerId];
209 },
210
211 /**
212 * @param {!LayerTreeAgent.ScrollRect} scrollRect
213 * @param {!WebInspector.Layer} layer
214 * @return {!Element}
215 */
216 _createScrollRectElement: function(scrollRect, layer)
217 {
218 var element = document.createElement("div");
219 var style = element.style;
220 var parentLayerId = layer.nodeId() ? layer.id() : this._model.contentRoo t().id();
221 var parentLayerElement = this._elementsByLayerId[parentLayerId];
222 element.className = "scroll-rect";
223 element.title = WebInspector.Layers3DView.ScrollRectTitles[scrollRect.ty pe];
224 style.width = scrollRect.rect.width + "px";
225 style.height = scrollRect.rect.height + "px";
226 style.left = scrollRect.rect.x + "px";
227 style.top = scrollRect.rect.y + "px";
228 parentLayerElement.appendChild(element);
229 element.__scrollRect = scrollRect;
230 return element;
231 },
232
233 /**
234 * @param {!WebInspector.Layer} layer
235 */
236 _updateScrollRectsForLayer: function(layer)
237 {
238 if (!this._scrollRectElementsByLayerId[layer.id()])
caseq 2014/02/27 13:46:55 weird indent
malch 2014/02/27 14:58:59 Done.
239 this._scrollRectElementsByLayerId[layer.id()] = [];
240 var newScrollRects = layer.scrollRects(), scrollRectElements = this. _scrollRectElementsByLayerId[layer.id()];
caseq 2014/02/27 13:46:55 please split into two lines
malch 2014/02/27 14:58:59 Done.
241 for (var i = 0; i < newScrollRects.length; ++i) {
242 if (i >= scrollRectElements.length) {
243 scrollRectElements.push(this._createScrollRectElement(newScr ollRects[i], layer));
244 } else if (newScrollRects[i] != scrollRectElements[i].__scrollRe ct) {
245 scrollRectElements[i].remove();
246 scrollRectElements[i] = this._createScrollRectElement(newScr ollRects[i], layer);
247 }
248 }
249 scrollRectElements.splice(newScrollRects.length).forEach(this._remov eElement);
250 },
251
184 _update: function() 252 _update: function()
185 { 253 {
186 if (!this.isShowing()) { 254 if (!this.isShowing()) {
187 this._needsUpdate = true; 255 this._needsUpdate = true;
188 return; 256 return;
189 } 257 }
190 if (!this._model.contentRoot()) { 258 if (!this._model.contentRoot()) {
191 this._emptyView.show(this.element); 259 this._emptyView.show(this.element);
192 this._rotatingContainerElement.removeChildren(); 260 this._rotatingContainerElement.removeChildren();
193 return; 261 return;
194 } 262 }
195 this._emptyView.detach(); 263 this._emptyView.detach();
196 264
197 /** 265 /**
198 * @this {WebInspector.Layers3DView} 266 * @this {WebInspector.Layers3DView}
199 */ 267 */
200 function updateLayer(layer) 268 function updateLayer(layer)
201 { 269 {
202 this._updateLayerElement(this._elementForLayer(layer)); 270 this._updateLayerElement(this._elementForLayer(layer));
203 } 271 }
204 this._clientWidth = this.element.clientWidth; 272 this._clientWidth = this.element.clientWidth;
205 this._clientHeight = this.element.clientHeight; 273 this._clientHeight = this.element.clientHeight;
206 for (var layerId in this._elementsByLayerId) { 274 for (var layerId in this._elementsByLayerId) {
207 if (this._model.layerById(layerId)) 275 if (this._model.layerById(layerId))
208 continue; 276 continue;
209 this._elementsByLayerId[layerId].remove(); 277 this._elementsByLayerId[layerId].remove();
210 delete this._elementsByLayerId[layerId]; 278 delete this._elementsByLayerId[layerId];
279 this._removeScrollRects(layerId);
211 } 280 }
212 this._scaleToFit(); 281 this._scaleToFit();
213 this._model.forEachLayer(updateLayer.bind(this), this._model.contentRoot ()); 282 this._model.forEachLayer(updateLayer.bind(this), this._model.contentRoot ());
283 this._model.forEachLayer(this._updateScrollRectsForLayer.bind(this));
214 this._needsUpdate = false; 284 this._needsUpdate = false;
215 }, 285 },
216 286
217 /** 287 /**
218 * @param {!WebInspector.Event} event 288 * @param {!WebInspector.Event} event
219 */ 289 */
220 _onLayerPainted: function(event) 290 _onLayerPainted: function(event)
221 { 291 {
222 var layer = /** @type {!WebInspector.Layer} */ (event.data); 292 var layer = /** @type {!WebInspector.Layer} */ (event.data);
223 this._updatePaintRect(this._elementForLayer(layer)); 293 this._updatePaintRect(this._elementForLayer(layer));
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 style.webkitTransform = ""; 347 style.webkitTransform = "";
278 style.webkitTransformOrigin = ""; 348 style.webkitTransformOrigin = "";
279 } 349 }
280 350
281 function toFixed5(x) 351 function toFixed5(x)
282 { 352 {
283 return x.toFixed(5); 353 return x.toFixed(5);
284 } 354 }
285 }, 355 },
286 356
357 /**
358 * @param {!Element} element
359 */
287 _updatePaintRect: function(element) 360 _updatePaintRect: function(element)
288 { 361 {
289 var details = element.__layerDetails; 362 var details = element.__layerDetails;
290 var paintRect = details.layer.lastPaintRect(); 363 var paintRect = details.layer.lastPaintRect();
291 var paintRectElement = details.paintRectElement; 364 var paintRectElement = details.paintRectElement;
292 if (!paintRect || !WebInspector.settings.showPaintRects.get()) { 365 if (!paintRect || !WebInspector.settings.showPaintRects.get()) {
293 paintRectElement.classList.add("hidden"); 366 paintRectElement.classList.add("hidden");
294 return; 367 return;
295 } 368 }
296 paintRectElement.classList.remove("hidden"); 369 paintRectElement.classList.remove("hidden");
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 * @param {!WebInspector.Layer} layer 513 * @param {!WebInspector.Layer} layer
441 * @param {!Element} paintRectElement 514 * @param {!Element} paintRectElement
442 */ 515 */
443 WebInspector.LayerDetails = function(layer, paintRectElement) 516 WebInspector.LayerDetails = function(layer, paintRectElement)
444 { 517 {
445 this.layer = layer; 518 this.layer = layer;
446 this.depth = 0; 519 this.depth = 0;
447 this.paintRectElement = paintRectElement; 520 this.paintRectElement = paintRectElement;
448 this.paintCount = 0; 521 this.paintCount = 0;
449 } 522 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698