OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 NonFastScrollable: 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 Loading... | |
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._paintScrollRects(); | |
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 Loading... | |
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) | |
299 { | |
300 var element = document.createElement("div"); | |
301 var style = element.style; | |
302 var parentLayerElement = this._model._layersById[scrollRect.layerId].nod eId() ? this._elementsByLayerId[scrollRect.layerId] : | |
303 this._elementsByLayerId[this._model.contentRoot().id()]; | |
caseq
2014/02/20 16:30:45
Let's split into something like
var parentLayerId
malch
2014/02/21 12:22:15
Done.
| |
304 element.className = "scroll-rect"; | |
305 element.title = WebInspector.Layers3DView.ScrollRectTitles[scrollRect.ty pe]; | |
306 style.width = scrollRect.width + "px"; | |
307 style.height = scrollRect.height + "px"; | |
308 style.left = scrollRect.x + "px"; | |
309 style.top = scrollRect.y + "px"; | |
310 parentLayerElement.appendChild(element); | |
311 element.__scrollRect = scrollRect; | |
312 return element; | |
313 }, | |
314 | |
315 _paintScrollRectsForLayer: function(newScrollRects, oldScrollRects) | |
316 { | |
317 for (var i = 0; i < newScrollRects.length; ++i) { | |
318 if (i >= oldScrollRects.length) { | |
319 oldScrollRects.push(this._createScrollRectElement(newScrollRects [i])); | |
320 } else if (newScrollRects[i] != oldScrollRects[i].__scrollRect) { | |
321 oldScrollRects[i].remove(); | |
322 oldScrollRects[i] = this._createScrollRectElement(newScrollRects [i]); | |
323 } | |
324 } | |
325 }, | |
326 | |
327 _paintScrollRects: function() | |
caseq
2014/02/20 16:30:45
s/paint/update/
malch
2014/02/21 12:22:15
Done.
| |
328 { | |
329 function removeElement(element) | |
330 { | |
331 element.remove() | |
332 } | |
333 | |
334 for (var layerId in this._scrollRectElementsByLayerId) { | |
335 if (!this._model._scrollRectsByLayerId[layerId]) { | |
336 this._scrollRectElementsByLayerId[layerId].forEach(removeElement ); | |
337 delete this._scrollRectElementsByLayerId[layerId]; | |
338 } | |
339 } | |
340 for (var layerId in this._model._scrollRectsByLayerId) { | |
341 if (!this._scrollRectElementsByLayerId[layerId]) | |
342 this._scrollRectElementsByLayerId[layerId] = []; | |
343 this._paintScrollRectsForLayer(this._model._scrollRectsByLayerId[lay erId], | |
344 this._scrollRectElementsByLayerId[layerId]); | |
345 this._scrollRectElementsByLayerId[layerId] | |
346 .splice(this._model._scrollRectsByLayerId[layerId].length) | |
347 .forEach(removeElement); | |
348 } | |
349 }, | |
350 | |
287 _updatePaintRect: function(element) | 351 _updatePaintRect: function(element) |
288 { | 352 { |
289 var details = element.__layerDetails; | 353 var details = element.__layerDetails; |
290 var paintRect = details.layer.lastPaintRect(); | 354 var paintRect = details.layer.lastPaintRect(); |
291 var paintRectElement = details.paintRectElement; | 355 var paintRectElement = details.paintRectElement; |
292 if (!paintRect || !WebInspector.settings.showPaintRects.get()) { | 356 if (!paintRect || !WebInspector.settings.showPaintRects.get()) { |
293 paintRectElement.classList.add("hidden"); | 357 paintRectElement.classList.add("hidden"); |
294 return; | 358 return; |
295 } | 359 } |
296 paintRectElement.classList.remove("hidden"); | 360 paintRectElement.classList.remove("hidden"); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
440 * @param {!WebInspector.Layer} layer | 504 * @param {!WebInspector.Layer} layer |
441 * @param {!Element} paintRectElement | 505 * @param {!Element} paintRectElement |
442 */ | 506 */ |
443 WebInspector.LayerDetails = function(layer, paintRectElement) | 507 WebInspector.LayerDetails = function(layer, paintRectElement) |
444 { | 508 { |
445 this.layer = layer; | 509 this.layer = layer; |
446 this.depth = 0; | 510 this.depth = 0; |
447 this.paintRectElement = paintRectElement; | 511 this.paintRectElement = paintRectElement; |
448 this.paintCount = 0; | 512 this.paintCount = 0; |
449 } | 513 } |
OLD | NEW |