| 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 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 Loading... |
| 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()]) |
| 239 this._scrollRectElementsByLayerId[layer.id()] = []; |
| 240 var newScrollRects = layer.scrollRects(), |
| 241 scrollRectElements = this._scrollRectElementsByLayerId[layer.id()]; |
| 242 for (var i = 0; i < newScrollRects.length; ++i) { |
| 243 if (i >= scrollRectElements.length) { |
| 244 scrollRectElements.push(this._createScrollRectElement(newScrollR
ects[i], layer)); |
| 245 } else if (newScrollRects[i] != scrollRectElements[i].__scrollRect)
{ |
| 246 scrollRectElements[i].remove(); |
| 247 scrollRectElements[i] = this._createScrollRectElement(newScrollR
ects[i], layer); |
| 248 } |
| 249 } |
| 250 scrollRectElements.splice(newScrollRects.length).forEach(this._removeEle
ment); |
| 251 }, |
| 252 |
| 184 _update: function() | 253 _update: function() |
| 185 { | 254 { |
| 186 if (!this.isShowing()) { | 255 if (!this.isShowing()) { |
| 187 this._needsUpdate = true; | 256 this._needsUpdate = true; |
| 188 return; | 257 return; |
| 189 } | 258 } |
| 190 if (!this._model.contentRoot()) { | 259 if (!this._model.contentRoot()) { |
| 191 this._emptyView.show(this.element); | 260 this._emptyView.show(this.element); |
| 192 this._rotatingContainerElement.removeChildren(); | 261 this._rotatingContainerElement.removeChildren(); |
| 193 return; | 262 return; |
| 194 } | 263 } |
| 195 this._emptyView.detach(); | 264 this._emptyView.detach(); |
| 196 | 265 |
| 197 /** | 266 /** |
| 198 * @this {WebInspector.Layers3DView} | 267 * @this {WebInspector.Layers3DView} |
| 199 */ | 268 */ |
| 200 function updateLayer(layer) | 269 function updateLayer(layer) |
| 201 { | 270 { |
| 202 this._updateLayerElement(this._elementForLayer(layer)); | 271 this._updateLayerElement(this._elementForLayer(layer)); |
| 203 } | 272 } |
| 204 this._clientWidth = this.element.clientWidth; | 273 this._clientWidth = this.element.clientWidth; |
| 205 this._clientHeight = this.element.clientHeight; | 274 this._clientHeight = this.element.clientHeight; |
| 206 for (var layerId in this._elementsByLayerId) { | 275 for (var layerId in this._elementsByLayerId) { |
| 207 if (this._model.layerById(layerId)) | 276 if (this._model.layerById(layerId)) |
| 208 continue; | 277 continue; |
| 209 this._elementsByLayerId[layerId].remove(); | 278 this._elementsByLayerId[layerId].remove(); |
| 210 delete this._elementsByLayerId[layerId]; | 279 delete this._elementsByLayerId[layerId]; |
| 280 this._removeScrollRects(layerId); |
| 211 } | 281 } |
| 212 this._scaleToFit(); | 282 this._scaleToFit(); |
| 213 this._model.forEachLayer(updateLayer.bind(this), this._model.contentRoot
()); | 283 this._model.forEachLayer(updateLayer.bind(this), this._model.contentRoot
()); |
| 284 this._model.forEachLayer(this._updateScrollRectsForLayer.bind(this)); |
| 214 this._needsUpdate = false; | 285 this._needsUpdate = false; |
| 215 }, | 286 }, |
| 216 | 287 |
| 217 /** | 288 /** |
| 218 * @param {!WebInspector.Event} event | 289 * @param {!WebInspector.Event} event |
| 219 */ | 290 */ |
| 220 _onLayerPainted: function(event) | 291 _onLayerPainted: function(event) |
| 221 { | 292 { |
| 222 var layer = /** @type {!WebInspector.Layer} */ (event.data); | 293 var layer = /** @type {!WebInspector.Layer} */ (event.data); |
| 223 this._updatePaintRect(this._elementForLayer(layer)); | 294 this._updatePaintRect(this._elementForLayer(layer)); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 style.webkitTransform = ""; | 348 style.webkitTransform = ""; |
| 278 style.webkitTransformOrigin = ""; | 349 style.webkitTransformOrigin = ""; |
| 279 } | 350 } |
| 280 | 351 |
| 281 function toFixed5(x) | 352 function toFixed5(x) |
| 282 { | 353 { |
| 283 return x.toFixed(5); | 354 return x.toFixed(5); |
| 284 } | 355 } |
| 285 }, | 356 }, |
| 286 | 357 |
| 358 /** |
| 359 * @param {!Element} element |
| 360 */ |
| 287 _updatePaintRect: function(element) | 361 _updatePaintRect: function(element) |
| 288 { | 362 { |
| 289 var details = element.__layerDetails; | 363 var details = element.__layerDetails; |
| 290 var paintRect = details.layer.lastPaintRect(); | 364 var paintRect = details.layer.lastPaintRect(); |
| 291 var paintRectElement = details.paintRectElement; | 365 var paintRectElement = details.paintRectElement; |
| 292 if (!paintRect || !WebInspector.settings.showPaintRects.get()) { | 366 if (!paintRect || !WebInspector.settings.showPaintRects.get()) { |
| 293 paintRectElement.classList.add("hidden"); | 367 paintRectElement.classList.add("hidden"); |
| 294 return; | 368 return; |
| 295 } | 369 } |
| 296 paintRectElement.classList.remove("hidden"); | 370 paintRectElement.classList.remove("hidden"); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 * @param {!WebInspector.Layer} layer | 514 * @param {!WebInspector.Layer} layer |
| 441 * @param {!Element} paintRectElement | 515 * @param {!Element} paintRectElement |
| 442 */ | 516 */ |
| 443 WebInspector.LayerDetails = function(layer, paintRectElement) | 517 WebInspector.LayerDetails = function(layer, paintRectElement) |
| 444 { | 518 { |
| 445 this.layer = layer; | 519 this.layer = layer; |
| 446 this.depth = 0; | 520 this.depth = 0; |
| 447 this.paintRectElement = paintRectElement; | 521 this.paintRectElement = paintRectElement; |
| 448 this.paintCount = 0; | 522 this.paintCount = 0; |
| 449 } | 523 } |
| OLD | NEW |