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 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._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 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 /** |
| 299 * @param {!LayerTreeAgent.ScrollRect} scrollRect |
| 300 * @return {!Element} |
| 301 */ |
| 302 _createScrollRectElement: function(scrollRect) |
| 303 { |
| 304 var element = document.createElement("div"); |
| 305 var style = element.style; |
| 306 var parentLayerId = |
| 307 this._model._layersById[scrollRect.layerId].nodeId() ? scrollRect.la
yerId : this._model.contentRoot().id(); |
| 308 var parentLayerElement = this._elementsByLayerId[parentLayerId]; |
| 309 element.className = "scroll-rect"; |
| 310 element.title = WebInspector.Layers3DView.ScrollRectTitles[scrollRect.ty
pe]; |
| 311 style.width = scrollRect.width + "px"; |
| 312 style.height = scrollRect.height + "px"; |
| 313 style.left = scrollRect.x + "px"; |
| 314 style.top = scrollRect.y + "px"; |
| 315 parentLayerElement.appendChild(element); |
| 316 element.__scrollRect = scrollRect; |
| 317 return element; |
| 318 }, |
| 319 |
| 320 /** |
| 321 * @param {!Element} element |
| 322 */ |
| 323 _removeElement: function(element) |
| 324 { |
| 325 element.remove() |
| 326 }, |
| 327 |
| 328 /** |
| 329 * @param {!Array.<!LayerTreeAgent.ScrollRect>=} newScrollRects |
| 330 * @param {!Array.<!Element>=} scrollRectElements |
| 331 */ |
| 332 _updateScrollRectsForLayer: function(newScrollRects, scrollRectElements) |
| 333 { |
| 334 for (var i = 0; i < newScrollRects.length; ++i) { |
| 335 if (i >= scrollRectElements.length) { |
| 336 scrollRectElements.push(this._createScrollRectElement(newScrollR
ects[i])); |
| 337 } else if (newScrollRects[i] != scrollRectElements[i].__scrollRect)
{ |
| 338 scrollRectElements[i].remove(); |
| 339 scrollRectElements[i] = this._createScrollRectElement(newScrollR
ects[i]); |
| 340 } |
| 341 } |
| 342 scrollRectElements.splice(newScrollRects.length).forEach(this._removeEle
ment); |
| 343 }, |
| 344 |
| 345 _updateScrollRects: function() |
| 346 { |
| 347 for (var layerId in this._scrollRectElementsByLayerId) { |
| 348 if (!this._model.scrollRectsByLayerId()[layerId]) { |
| 349 this._scrollRectElementsByLayerId[layerId].forEach(this._removeE
lement); |
| 350 delete this._scrollRectElementsByLayerId[layerId]; |
| 351 } |
| 352 } |
| 353 for (var layerId in this._model.scrollRectsByLayerId()) { |
| 354 if (!this._scrollRectElementsByLayerId[layerId]) |
| 355 this._scrollRectElementsByLayerId[layerId] = []; |
| 356 var scrollRects = this._model.scrollRectsByLayerId()[layerId]; |
| 357 this._updateScrollRectsForLayer(scrollRects, this._scrollRectElement
sByLayerId[layerId]); |
| 358 } |
| 359 }, |
| 360 |
| 361 /** |
| 362 * @param {!Element} element |
| 363 */ |
287 _updatePaintRect: function(element) | 364 _updatePaintRect: function(element) |
288 { | 365 { |
289 var details = element.__layerDetails; | 366 var details = element.__layerDetails; |
290 var paintRect = details.layer.lastPaintRect(); | 367 var paintRect = details.layer.lastPaintRect(); |
291 var paintRectElement = details.paintRectElement; | 368 var paintRectElement = details.paintRectElement; |
292 if (!paintRect || !WebInspector.settings.showPaintRects.get()) { | 369 if (!paintRect || !WebInspector.settings.showPaintRects.get()) { |
293 paintRectElement.classList.add("hidden"); | 370 paintRectElement.classList.add("hidden"); |
294 return; | 371 return; |
295 } | 372 } |
296 paintRectElement.classList.remove("hidden"); | 373 paintRectElement.classList.remove("hidden"); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 * @param {!WebInspector.Layer} layer | 517 * @param {!WebInspector.Layer} layer |
441 * @param {!Element} paintRectElement | 518 * @param {!Element} paintRectElement |
442 */ | 519 */ |
443 WebInspector.LayerDetails = function(layer, paintRectElement) | 520 WebInspector.LayerDetails = function(layer, paintRectElement) |
444 { | 521 { |
445 this.layer = layer; | 522 this.layer = layer; |
446 this.depth = 0; | 523 this.depth = 0; |
447 this.paintRectElement = paintRectElement; | 524 this.paintRectElement = paintRectElement; |
448 this.paintCount = 0; | 525 this.paintCount = 0; |
449 } | 526 } |
OLD | NEW |