Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/layer_viewer/Layers3DView.js

Issue 2358253002: DevTools: extract a component for layer viewer (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 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 18 matching lines...) Expand all
29 */ 29 */
30 30
31 /** 31 /**
32 * @constructor 32 * @constructor
33 * @extends {WebInspector.VBox} 33 * @extends {WebInspector.VBox}
34 * @param {!WebInspector.LayerViewHost} layerViewHost 34 * @param {!WebInspector.LayerViewHost} layerViewHost
35 * @implements {WebInspector.LayerView} 35 * @implements {WebInspector.LayerView}
36 */ 36 */
37 WebInspector.Layers3DView = function(layerViewHost) 37 WebInspector.Layers3DView = function(layerViewHost)
38 { 38 {
39 WebInspector.VBox.call(this); 39 WebInspector.VBox.call(this, true);
40 this.element.classList.add("layers-3d-view"); 40 this.registerRequiredCSS("layer_viewer/layers3DView.css");
41 this.contentElement.classList.add("layers-3d-view");
41 this._failBanner = new WebInspector.VBox(); 42 this._failBanner = new WebInspector.VBox();
42 this._failBanner.element.classList.add("banner"); 43 this._failBanner.element.classList.add("banner");
43 this._failBanner.element.createTextChild(WebInspector.UIString("Layer inform ation is not yet available.")); 44 this._failBanner.element.createTextChild(WebInspector.UIString("Layer inform ation is not yet available."));
44 45
45 this._layerViewHost = layerViewHost; 46 this._layerViewHost = layerViewHost;
46 this._layerViewHost.registerView(this); 47 this._layerViewHost.registerView(this);
47 48
48 this._transformController = new WebInspector.TransformController(this.elemen t); 49 this._transformController = new WebInspector.TransformController(this.conten tElement);
49 this._transformController.addEventListener(WebInspector.TransformController. Events.TransformChanged, this._update, this); 50 this._transformController.addEventListener(WebInspector.TransformController. Events.TransformChanged, this._update, this);
50 this._initToolbar(); 51 this._initToolbar();
51 52
52 this._canvasElement = this.element.createChild("canvas"); 53 this._canvasElement = this.contentElement.createChild("canvas");
53 this._canvasElement.tabIndex = 0; 54 this._canvasElement.tabIndex = 0;
54 this._canvasElement.addEventListener("dblclick", this._onDoubleClick.bind(th is), false); 55 this._canvasElement.addEventListener("dblclick", this._onDoubleClick.bind(th is), false);
55 this._canvasElement.addEventListener("mousedown", this._onMouseDown.bind(thi s), false); 56 this._canvasElement.addEventListener("mousedown", this._onMouseDown.bind(thi s), false);
56 this._canvasElement.addEventListener("mouseup", this._onMouseUp.bind(this), false); 57 this._canvasElement.addEventListener("mouseup", this._onMouseUp.bind(this), false);
57 this._canvasElement.addEventListener("mouseleave", this._onMouseMove.bind(th is), false); 58 this._canvasElement.addEventListener("mouseleave", this._onMouseMove.bind(th is), false);
58 this._canvasElement.addEventListener("mousemove", this._onMouseMove.bind(thi s), false); 59 this._canvasElement.addEventListener("mousemove", this._onMouseMove.bind(thi s), false);
59 this._canvasElement.addEventListener("contextmenu", this._onContextMenu.bind (this), false); 60 this._canvasElement.addEventListener("contextmenu", this._onContextMenu.bind (this), false);
60 61
61 this._lastSelection = {}; 62 this._lastSelection = {};
62 this._layerTree = null; 63 this._layerTree = null;
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 this._drawRectangle(vertices, this._gl.LINE_LOOP, rect.borderColor); 640 this._drawRectangle(vertices, this._gl.LINE_LOOP, rect.borderColor);
640 }, 641 },
641 642
642 _update: function() 643 _update: function()
643 { 644 {
644 if (!this.isShowing()) { 645 if (!this.isShowing()) {
645 this._needsUpdate = true; 646 this._needsUpdate = true;
646 return; 647 return;
647 } 648 }
648 if (!this._layerTree || !this._layerTree.root()) { 649 if (!this._layerTree || !this._layerTree.root()) {
649 this._failBanner.show(this.element); 650 this._failBanner.show(this.contentElement);
650 return; 651 return;
651 } 652 }
652 var gl = this._initGLIfNecessary(); 653 var gl = this._initGLIfNecessary();
653 if (!gl) { 654 if (!gl) {
654 this._failBanner.element.removeChildren(); 655 this._failBanner.element.removeChildren();
655 this._failBanner.element.appendChild(this._webglDisabledBanner()); 656 this._failBanner.element.appendChild(this._webglDisabledBanner());
656 this._failBanner.show(this.element); 657 this._failBanner.show(this.contentElement);
657 return; 658 return;
658 } 659 }
659 this._failBanner.detach(); 660 this._failBanner.detach();
660 this._gl.viewportWidth = this._canvasElement.width; 661 this._gl.viewportWidth = this._canvasElement.width;
661 this._gl.viewportHeight = this._canvasElement.height; 662 this._gl.viewportHeight = this._canvasElement.height;
662 663
663 this._calculateDepthsAndVisibility(); 664 this._calculateDepthsAndVisibility();
664 this._calculateRects(); 665 this._calculateRects();
665 this._updateTransformAndConstraints(); 666 this._updateTransformAndConstraints();
666 667
667 this._textureManager.setScale(Number.constrain(0.1, 1, this._scale)); 668 this._textureManager.setScale(Number.constrain(0.1, 1, this._scale));
668 gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight); 669 gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight);
669 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); 670 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
670 671
671 this._rects.forEach(this._drawViewRect.bind(this)); 672 this._rects.forEach(this._drawViewRect.bind(this));
672 this._drawViewportAndChrome(); 673 this._drawViewportAndChrome();
673 }, 674 },
674 675
675 /** 676 /**
676 * @return {!Node} 677 * @return {!Node}
677 */ 678 */
678 _webglDisabledBanner: function() 679 _webglDisabledBanner: function()
679 { 680 {
680 var fragment = this.element.ownerDocument.createDocumentFragment(); 681 var fragment = this.contentElement.ownerDocument.createDocumentFragment( );
681 fragment.createChild("div").textContent = WebInspector.UIString("Can't d isplay layers,"); 682 fragment.createChild("div").textContent = WebInspector.UIString("Can't d isplay layers,");
682 fragment.createChild("div").textContent = WebInspector.UIString("WebGL s upport is disabled in your browser."); 683 fragment.createChild("div").textContent = WebInspector.UIString("WebGL s upport is disabled in your browser.");
683 fragment.appendChild(WebInspector.formatLocalized("Check %s for possible reasons.", [WebInspector.linkifyURLAsNode("about:gpu", undefined, undefined, tr ue)])); 684 fragment.appendChild(WebInspector.formatLocalized("Check %s for possible reasons.", [WebInspector.linkifyURLAsNode("about:gpu", undefined, undefined, tr ue)]));
684 return fragment; 685 return fragment;
685 }, 686 },
686 687
687 /** 688 /**
688 * @param {!Event} event 689 * @param {!Event} event
689 * @return {?WebInspector.LayerView.Selection} 690 * @return {?WebInspector.LayerView.Selection}
690 */ 691 */
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 toolbar.appendToolbarItem(checkbox); 730 toolbar.appendToolbarItem(checkbox);
730 var setting = WebInspector.settings.createSetting(name, value); 731 var setting = WebInspector.settings.createSetting(name, value);
731 WebInspector.SettingsUI.bindCheckbox(checkbox.inputElement, setting); 732 WebInspector.SettingsUI.bindCheckbox(checkbox.inputElement, setting);
732 setting.addChangeListener(this._update, this); 733 setting.addChangeListener(this._update, this);
733 return setting; 734 return setting;
734 }, 735 },
735 736
736 _initToolbar: function() 737 _initToolbar: function()
737 { 738 {
738 this._panelToolbar = this._transformController.toolbar(); 739 this._panelToolbar = this._transformController.toolbar();
739 this.element.appendChild(this._panelToolbar.element); 740 this.contentElement.appendChild(this._panelToolbar.element);
740 this._showSlowScrollRectsSetting = this._createVisibilitySetting("Slow s croll rects", "frameViewerShowSlowScrollRects", true, this._panelToolbar); 741 this._showSlowScrollRectsSetting = this._createVisibilitySetting("Slow s croll rects", "frameViewerShowSlowScrollRects", true, this._panelToolbar);
741 this._showPaintsSetting = this._createVisibilitySetting("Paints", "frame ViewerShowPaints", true, this._panelToolbar); 742 this._showPaintsSetting = this._createVisibilitySetting("Paints", "frame ViewerShowPaints", true, this._panelToolbar);
742 WebInspector.moduleSetting("frameViewerHideChromeWindow").addChangeListe ner(this._update, this); 743 WebInspector.moduleSetting("frameViewerHideChromeWindow").addChangeListe ner(this._update, this);
743 }, 744 },
744 745
745 /** 746 /**
746 * @param {!Event} event 747 * @param {!Event} event
747 */ 748 */
748 _onContextMenu: function(event) 749 _onContextMenu: function(event)
749 { 750 {
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 */ 1092 */
1092 WebInspector.LayerTextureManager.Tile = function(snapshot, rect, traceEvent) 1093 WebInspector.LayerTextureManager.Tile = function(snapshot, rect, traceEvent)
1093 { 1094 {
1094 this.snapshot = snapshot; 1095 this.snapshot = snapshot;
1095 this.rect = rect; 1096 this.rect = rect;
1096 this.traceEvent = traceEvent; 1097 this.traceEvent = traceEvent;
1097 this.scale = 0; 1098 this.scale = 0;
1098 /** @type {?WebGLTexture} */ 1099 /** @type {?WebGLTexture} */
1099 this.texture = null; 1100 this.texture = null;
1100 } 1101 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698