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: "repaints on scroll", | |
caseq
2014/02/20 09:34:06
Use WebInspector.UIString()
| |
91 TouchEventHandler: "touch event listener", | |
92 WheelEventHandler: "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()]; | |
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 var color = WebInspector.Color.fromRGBA([0xB2, 0, 0, 0.2]); | |
caseq
2014/02/20 09:34:06
Do this as part of scroll-rect CSS class instead.
| |
311 style.backgroundColor = color.toString(WebInspector.Color.Format.RGBA) | | ""; | |
312 color = WebInspector.Color.fromRGBA([0xB2, 0, 0, 1]); | |
313 style.borderColor = color.toString(WebInspector.Color.Format.RGBA) || "" ; | |
314 style.borderWidth = "1px"; | |
315 parentLayerElement.appendChild(element); | |
316 element._scrollRect = scrollRect; | |
317 return element; | |
318 }, | |
319 | |
320 _paintScrollRects: function() | |
321 { | |
322 var i, layerId; | |
323 for (layerId in this._scrollRectElementsByLayerId) { | |
324 if (!this._model._scrollRectsByLayerId[layerId]) { | |
325 for (i = 0; i < this._scrollRectElementsByLayerId[layerId].lengt h; ++i) { | |
326 this._scrollRectElementsByLayerId[layerId][i].remove(); | |
327 } | |
328 delete this._scrollRectElementsByLayerId[layerId]; | |
329 } | |
330 } | |
331 for (layerId in this._model._scrollRectsByLayerId) { | |
332 if (!this._scrollRectElementsByLayerId[layerId]) | |
333 this._scrollRectElementsByLayerId[layerId] = []; | |
334 for (i = 0; i < this._model._scrollRectsByLayerId[layerId].length; + +i) { | |
335 if (i >= this._scrollRectElementsByLayerId[layerId].length) { | |
336 this._scrollRectElementsByLayerId[layerId].push( | |
337 this._createScrollRectElement(this._model._scrollRectsBy LayerId[layerId][i])); | |
338 } else if (this._model._scrollRectsByLayerId[layerId][i] != this ._scrollRectElementsByLayerId[layerId][i]) { | |
339 this._scrollRectElementsByLayerId[layerId][i].remove(); | |
340 this._scrollRectElementsByLayerId[layerId][i] = | |
341 this._createScrollRectElement(this._model._scrollRectsBy LayerId[layerId][i]); | |
342 } | |
343 } | |
344 if (this._scrollRectElementsByLayerId[layerId].length > this._model. _scrollRectsByLayerId[layerId].length) { | |
caseq
2014/02/20 09:34:06
No need for this if.
| |
345 for (i = this._model._scrollRectsByLayerId[layerId].length; i < this._scrollRectElementsByLayerId[layerId].length; ++i) | |
346 this._scrollRectElementsByLayerId[layerId][i].remove(); | |
347 this._scrollRectElementsByLayerId[layerId].splice(this._model._s crollRectsByLayerId[layerId].length, | |
caseq
2014/02/20 09:34:06
How about
this._scrollRectElementsByLayerId[layer
| |
348 this._scrollRectElementsByLayerId[layerId].length - this._mo del._scrollRectsByLayerId[layerId].length); | |
349 } | |
350 } | |
351 }, | |
352 | |
287 _updatePaintRect: function(element) | 353 _updatePaintRect: function(element) |
288 { | 354 { |
289 var details = element.__layerDetails; | 355 var details = element.__layerDetails; |
290 var paintRect = details.layer.lastPaintRect(); | 356 var paintRect = details.layer.lastPaintRect(); |
291 var paintRectElement = details.paintRectElement; | 357 var paintRectElement = details.paintRectElement; |
292 if (!paintRect || !WebInspector.settings.showPaintRects.get()) { | 358 if (!paintRect || !WebInspector.settings.showPaintRects.get()) { |
293 paintRectElement.classList.add("hidden"); | 359 paintRectElement.classList.add("hidden"); |
294 return; | 360 return; |
295 } | 361 } |
296 paintRectElement.classList.remove("hidden"); | 362 paintRectElement.classList.remove("hidden"); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
440 * @param {!WebInspector.Layer} layer | 506 * @param {!WebInspector.Layer} layer |
441 * @param {!Element} paintRectElement | 507 * @param {!Element} paintRectElement |
442 */ | 508 */ |
443 WebInspector.LayerDetails = function(layer, paintRectElement) | 509 WebInspector.LayerDetails = function(layer, paintRectElement) |
444 { | 510 { |
445 this.layer = layer; | 511 this.layer = layer; |
446 this.depth = 0; | 512 this.depth = 0; |
447 this.paintRectElement = paintRectElement; | 513 this.paintRectElement = paintRectElement; |
448 this.paintCount = 0; | 514 this.paintCount = 0; |
449 } | 515 } |
OLD | NEW |