| 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", |
| 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]); |
| 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 return element; |
| 317 }, |
| 318 |
| 319 _paintScrollRects: function() |
| 320 { |
| 321 var i, layerId; |
| 322 for (layerId in this._scrollRectElementsByLayerId) { |
| 323 if (!this._model._scrollRectsByLayerId[layerId]) { |
| 324 for (i = 0; i < this._scrollRectElementsByLayerId[layerId].lengt
h; ++i) { |
| 325 this._scrollRectElementsByLayerId[layerId][i].remove(); |
| 326 } |
| 327 delete this._scrollRectElementsByLayerId[layerId]; |
| 328 } |
| 329 } |
| 330 for (layerId in this._model._scrollRectsByLayerId) { |
| 331 if (!this._scrollRectElementsByLayerId[layerId]) |
| 332 this._scrollRectElementsByLayerId[layerId] = []; |
| 333 for (i = 0; i < this._model._scrollRectsByLayerId[layerId].length; +
+i) { |
| 334 if (i >= this._scrollRectElementsByLayerId[layerId].length) { |
| 335 this._scrollRectElementsByLayerId[layerId].push( |
| 336 this._createScrollRectElement(this._model._scrollRectsBy
LayerId[layerId][i])); |
| 337 } else if (this._model._scrollRectsByLayerId[layerId][i].needsUp
date) { |
| 338 this._scrollRectElementsByLayerId[layerId][i].remove(); |
| 339 this._scrollRectElementsByLayerId[layerId][i] = |
| 340 this._createScrollRectElement(this._model._scrollRectsBy
LayerId[layerId][i]); |
| 341 } |
| 342 } |
| 343 if (this._scrollRectElementsByLayerId[layerId].length > this._model.
_scrollRectsByLayerId[layerId].length) { |
| 344 this._scrollRectElementsByLayerId[layerId].splice(this._model._s
crollRectsByLayerId[layerId].length, |
| 345 this._scrollRectElementsByLayerId[layerId].length - this._mo
del._scrollRectsByLayerId[layerId].length); |
| 346 } |
| 347 } |
| 348 }, |
| 349 |
| 287 _updatePaintRect: function(element) | 350 _updatePaintRect: function(element) |
| 288 { | 351 { |
| 289 var details = element.__layerDetails; | 352 var details = element.__layerDetails; |
| 290 var paintRect = details.layer.lastPaintRect(); | 353 var paintRect = details.layer.lastPaintRect(); |
| 291 var paintRectElement = details.paintRectElement; | 354 var paintRectElement = details.paintRectElement; |
| 292 if (!paintRect || !WebInspector.settings.showPaintRects.get()) { | 355 if (!paintRect || !WebInspector.settings.showPaintRects.get()) { |
| 293 paintRectElement.classList.add("hidden"); | 356 paintRectElement.classList.add("hidden"); |
| 294 return; | 357 return; |
| 295 } | 358 } |
| 296 paintRectElement.classList.remove("hidden"); | 359 paintRectElement.classList.remove("hidden"); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 * @param {!WebInspector.Layer} layer | 503 * @param {!WebInspector.Layer} layer |
| 441 * @param {!Element} paintRectElement | 504 * @param {!Element} paintRectElement |
| 442 */ | 505 */ |
| 443 WebInspector.LayerDetails = function(layer, paintRectElement) | 506 WebInspector.LayerDetails = function(layer, paintRectElement) |
| 444 { | 507 { |
| 445 this.layer = layer; | 508 this.layer = layer; |
| 446 this.depth = 0; | 509 this.depth = 0; |
| 447 this.paintRectElement = paintRectElement; | 510 this.paintRectElement = paintRectElement; |
| 448 this.paintCount = 0; | 511 this.paintCount = 0; |
| 449 } | 512 } |
| OLD | NEW |