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

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: Fixes and updates. 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 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 this._clientWidth = this.element.clientWidth; 214 this._clientWidth = this.element.clientWidth;
205 this._clientHeight = this.element.clientHeight; 215 this._clientHeight = this.element.clientHeight;
206 for (var layerId in this._elementsByLayerId) { 216 for (var layerId in this._elementsByLayerId) {
207 if (this._model.layerById(layerId)) 217 if (this._model.layerById(layerId))
208 continue; 218 continue;
209 this._elementsByLayerId[layerId].remove(); 219 this._elementsByLayerId[layerId].remove();
210 delete this._elementsByLayerId[layerId]; 220 delete this._elementsByLayerId[layerId];
211 } 221 }
212 this._scaleToFit(); 222 this._scaleToFit();
213 this._model.forEachLayer(updateLayer.bind(this), this._model.contentRoot ()); 223 this._model.forEachLayer(updateLayer.bind(this), this._model.contentRoot ());
224 this._updateScrollRects();
214 this._needsUpdate = false; 225 this._needsUpdate = false;
215 }, 226 },
216 227
217 /** 228 /**
218 * @param {!WebInspector.Event} event 229 * @param {!WebInspector.Event} event
219 */ 230 */
220 _onLayerPainted: function(event) 231 _onLayerPainted: function(event)
221 { 232 {
222 var layer = /** @type {!WebInspector.Layer} */ (event.data); 233 var layer = /** @type {!WebInspector.Layer} */ (event.data);
223 this._updatePaintRect(this._elementForLayer(layer)); 234 this._updatePaintRect(this._elementForLayer(layer));
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 style.webkitTransform = ""; 288 style.webkitTransform = "";
278 style.webkitTransformOrigin = ""; 289 style.webkitTransformOrigin = "";
279 } 290 }
280 291
281 function toFixed5(x) 292 function toFixed5(x)
282 { 293 {
283 return x.toFixed(5); 294 return x.toFixed(5);
284 } 295 }
285 }, 296 },
286 297
298 _createScrollRectElement: function(scrollRect)
caseq 2014/02/25 16:38:41 Please annotate.
malch 2014/02/26 07:28:21 Done.
299 {
300 var element = document.createElement("div");
301 var style = element.style;
302 var parentLayerid =
caseq 2014/02/25 16:38:41 parentLayerId
malch 2014/02/26 07:28:21 Done.
303 this._model._layersById[scrollRect.layerId].nodeId() ? scrollRect.la yerId : this._model.contentRoot().id();
304 var parentLayerElement = this._elementsByLayerId[parentLayerid];
305 element.className = "scroll-rect";
306 element.title = WebInspector.Layers3DView.ScrollRectTitles[scrollRect.ty pe];
307 style.width = scrollRect.width + "px";
308 style.height = scrollRect.height + "px";
309 style.left = scrollRect.x + "px";
310 style.top = scrollRect.y + "px";
311 parentLayerElement.appendChild(element);
312 element.__scrollRect = scrollRect;
313 return element;
314 },
315
316 _updateScrollRectsForLayer: function(newScrollRects, oldScrollRects)
caseq 2014/02/25 16:38:41 Ditto.
malch 2014/02/26 07:28:21 Done.
317 {
318 for (var i = 0; i < newScrollRects.length; ++i) {
319 if (i >= oldScrollRects.length) {
320 oldScrollRects.push(this._createScrollRectElement(newScrollRects [i]));
321 } else if (newScrollRects[i] != oldScrollRects[i].__scrollRect) {
322 oldScrollRects[i].remove();
323 oldScrollRects[i] = this._createScrollRectElement(newScrollRects [i]);
caseq 2014/02/25 16:38:41 oldScrollRects is a poor choice of name -- it cont
malch 2014/02/26 07:28:21 Done.
324 }
325 }
326 },
327
328 _updateScrollRects: function()
329 {
330 function removeElement(element)
331 {
332 element.remove()
333 }
334
335 for (var layerId in this._scrollRectElementsByLayerId) {
336 if (!this._model.scrollRectsByLayerId()[layerId]) {
337 this._scrollRectElementsByLayerId[layerId].forEach(removeElement );
338 delete this._scrollRectElementsByLayerId[layerId];
339 }
340 }
341 for (var layerId in this._model.scrollRectsByLayerId()) {
342 if (!this._scrollRectElementsByLayerId[layerId])
343 this._scrollRectElementsByLayerId[layerId] = [];
344 var scrollRects = this._model.scrollRectsByLayerId()[layerId];
345 this._updateScrollRectsForLayer(scrollRects, this._scrollRectElement sByLayerId[layerId]);
346 this._scrollRectElementsByLayerId[layerId]
caseq 2014/02/25 16:38:41 Why is this line not a part of _updateScrollRectsF
malch 2014/02/26 07:28:21 Done.
347 .splice(scrollRects.length)
348 .forEach(removeElement);
349 }
350 },
351
287 _updatePaintRect: function(element) 352 _updatePaintRect: function(element)
288 { 353 {
289 var details = element.__layerDetails; 354 var details = element.__layerDetails;
290 var paintRect = details.layer.lastPaintRect(); 355 var paintRect = details.layer.lastPaintRect();
291 var paintRectElement = details.paintRectElement; 356 var paintRectElement = details.paintRectElement;
292 if (!paintRect || !WebInspector.settings.showPaintRects.get()) { 357 if (!paintRect || !WebInspector.settings.showPaintRects.get()) {
293 paintRectElement.classList.add("hidden"); 358 paintRectElement.classList.add("hidden");
294 return; 359 return;
295 } 360 }
296 paintRectElement.classList.remove("hidden"); 361 paintRectElement.classList.remove("hidden");
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 * @param {!WebInspector.Layer} layer 505 * @param {!WebInspector.Layer} layer
441 * @param {!Element} paintRectElement 506 * @param {!Element} paintRectElement
442 */ 507 */
443 WebInspector.LayerDetails = function(layer, paintRectElement) 508 WebInspector.LayerDetails = function(layer, paintRectElement)
444 { 509 {
445 this.layer = layer; 510 this.layer = layer;
446 this.depth = 0; 511 this.depth = 0;
447 this.paintRectElement = paintRectElement; 512 this.paintRectElement = paintRectElement;
448 this.paintCount = 0; 513 this.paintCount = 0;
449 } 514 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698