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

Side by Side Diff: Source/devtools/front_end/ui/Popover.js

Issue 671463002: DevTools: make flame chart a web component. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 20 matching lines...) Expand all
31 /** 31 /**
32 * @constructor 32 * @constructor
33 * @extends {WebInspector.View} 33 * @extends {WebInspector.View}
34 * @param {!WebInspector.PopoverHelper=} popoverHelper 34 * @param {!WebInspector.PopoverHelper=} popoverHelper
35 */ 35 */
36 WebInspector.Popover = function(popoverHelper) 36 WebInspector.Popover = function(popoverHelper)
37 { 37 {
38 WebInspector.View.call(this); 38 WebInspector.View.call(this);
39 this.markAsRoot(); 39 this.markAsRoot();
40 this.element.className = WebInspector.Popover._classNamePrefix; // Override 40 this.element.className = WebInspector.Popover._classNamePrefix; // Override
41 WebInspector.installComponentRootStyles(this.element);
41 this._containerElement = createElementWithClass("div", "fill popover-contain er"); 42 this._containerElement = createElementWithClass("div", "fill popover-contain er");
42 43
43 this._popupArrowElement = this.element.createChild("div", "arrow"); 44 this._popupArrowElement = this.element.createChild("div", "arrow");
44 this._contentDiv = this.element.createChild("div", "content"); 45 this._contentDiv = this.element.createChild("div", "content");
45 46
46 this._popoverHelper = popoverHelper; 47 this._popoverHelper = popoverHelper;
47 this._hideBound = this.hide.bind(this); 48 this._hideBound = this.hide.bind(this);
48 } 49 }
49 50
50 WebInspector.Popover._classNamePrefix = "popover component-root custom-popup-ver tical-scroll custom-popup-horizontal-scroll"; 51 WebInspector.Popover._classNamePrefix = "popover custom-popup-vertical-scroll cu stom-popup-horizontal-scroll";
51 52
52 WebInspector.Popover.prototype = { 53 WebInspector.Popover.prototype = {
53 /** 54 /**
54 * @param {!Element} element 55 * @param {!Element} element
55 * @param {!Element|!AnchorBox} anchor 56 * @param {!Element|!AnchorBox} anchor
56 * @param {?number=} preferredWidth 57 * @param {?number=} preferredWidth
57 * @param {?number=} preferredHeight 58 * @param {?number=} preferredHeight
58 * @param {?WebInspector.Popover.Orientation=} arrowDirection 59 * @param {?WebInspector.Popover.Orientation=} arrowDirection
59 */ 60 */
60 show: function(element, anchor, preferredWidth, preferredHeight, arrowDirect ion) 61 show: function(element, anchor, preferredWidth, preferredHeight, arrowDirect ion)
(...skipping 17 matching lines...) Expand all
78 * @param {!Element} contentElement 79 * @param {!Element} contentElement
79 * @param {!Element|!AnchorBox} anchor 80 * @param {!Element|!AnchorBox} anchor
80 * @param {?number=} preferredWidth 81 * @param {?number=} preferredWidth
81 * @param {?number=} preferredHeight 82 * @param {?number=} preferredHeight
82 * @param {?WebInspector.Popover.Orientation=} arrowDirection 83 * @param {?WebInspector.Popover.Orientation=} arrowDirection
83 */ 84 */
84 _innerShow: function(view, contentElement, anchor, preferredWidth, preferred Height, arrowDirection) 85 _innerShow: function(view, contentElement, anchor, preferredWidth, preferred Height, arrowDirection)
85 { 86 {
86 if (this._disposed) 87 if (this._disposed)
87 return; 88 return;
88 this.contentElement = contentElement; 89 this._contentElement = contentElement;
89 90
90 // This should not happen, but we hide previous popup to be on the safe side. 91 // This should not happen, but we hide previous popup to be on the safe side.
91 if (WebInspector.Popover._popover) 92 if (WebInspector.Popover._popover)
92 WebInspector.Popover._popover.hide(); 93 WebInspector.Popover._popover.hide();
93 WebInspector.Popover._popover = this; 94 WebInspector.Popover._popover = this;
94 95
95 // Temporarily attach in order to measure preferred dimensions. 96 // Temporarily attach in order to measure preferred dimensions.
96 var preferredSize = view ? view.measurePreferredSize() : this.contentEle ment.measurePreferredSize(); 97 var preferredSize = view ? view.measurePreferredSize() : this._contentEl ement.measurePreferredSize();
97 preferredWidth = preferredWidth || preferredSize.width; 98 preferredWidth = preferredWidth || preferredSize.width;
98 preferredHeight = preferredHeight || preferredSize.height; 99 preferredHeight = preferredHeight || preferredSize.height;
99 100
100 window.addEventListener("resize", this._hideBound, false); 101 window.addEventListener("resize", this._hideBound, false);
101 document.body.appendChild(this._containerElement); 102 document.body.appendChild(this._containerElement);
102 WebInspector.View.prototype.show.call(this, this._containerElement); 103 WebInspector.View.prototype.show.call(this, this._containerElement);
103 104
104 if (view) 105 if (view)
105 view.show(this._contentDiv); 106 view.show(this._contentDiv);
106 else 107 else
107 this._contentDiv.appendChild(this.contentElement); 108 this._contentDiv.appendChild(this._contentElement);
108 109
109 this._positionElement(anchor, preferredWidth, preferredHeight, arrowDire ction); 110 this._positionElement(anchor, preferredWidth, preferredHeight, arrowDire ction);
110 111
111 if (this._popoverHelper) { 112 if (this._popoverHelper) {
112 this._contentDiv.addEventListener("mousemove", this._popoverHelper._ killHidePopoverTimer.bind(this._popoverHelper), true); 113 this._contentDiv.addEventListener("mousemove", this._popoverHelper._ killHidePopoverTimer.bind(this._popoverHelper), true);
113 this.element.addEventListener("mouseout", this._popoverHelper._popov erMouseOut.bind(this._popoverHelper), true); 114 this.element.addEventListener("mouseout", this._popoverHelper._popov erMouseOut.bind(this._popoverHelper), true);
114 } 115 }
115 }, 116 },
116 117
117 hide: function() 118 hide: function()
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 newElementPosition.height += scrollerWidth; 215 newElementPosition.height += scrollerWidth;
215 horizontalAlignment = "left"; 216 horizontalAlignment = "left";
216 if (verticalAlignment === WebInspector.Popover.Orientation.Bottom) 217 if (verticalAlignment === WebInspector.Popover.Orientation.Bottom)
217 newElementPosition.y -= scrollerWidth; 218 newElementPosition.y -= scrollerWidth;
218 // Position arrow accurately. 219 // Position arrow accurately.
219 this._popupArrowElement.style.left = Math.max(0, anchorBox.x - borde rRadius * 2 - arrowOffset) + "px"; 220 this._popupArrowElement.style.left = Math.max(0, anchorBox.x - borde rRadius * 2 - arrowOffset) + "px";
220 this._popupArrowElement.style.left += anchorBox.width / 2; 221 this._popupArrowElement.style.left += anchorBox.width / 2;
221 } 222 }
222 223
223 this.element.className = WebInspector.Popover._classNamePrefix + " " + v erticalAlignment + "-" + horizontalAlignment + "-arrow"; 224 this.element.className = WebInspector.Popover._classNamePrefix + " " + v erticalAlignment + "-" + horizontalAlignment + "-arrow";
225 WebInspector.installComponentRootStyles(this.element);
224 this.element.positionAt(newElementPosition.x - borderWidth, newElementPo sition.y - borderWidth, container); 226 this.element.positionAt(newElementPosition.x - borderWidth, newElementPo sition.y - borderWidth, container);
225 this.element.style.width = newElementPosition.width + borderWidth * 2 + "px"; 227 this.element.style.width = newElementPosition.width + borderWidth * 2 + "px";
226 this.element.style.height = newElementPosition.height + borderWidth * 2 + "px"; 228 this.element.style.height = newElementPosition.height + borderWidth * 2 + "px";
227 }, 229 },
228 230
229 __proto__: WebInspector.View.prototype 231 __proto__: WebInspector.View.prototype
230 } 232 }
231 233
232 /** 234 /**
233 * @constructor 235 * @constructor
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 this._resetHoverTimer(); 399 this._resetHoverTimer();
398 } 400 }
399 } 401 }
400 } 402 }
401 403
402 /** @enum {string} */ 404 /** @enum {string} */
403 WebInspector.Popover.Orientation = { 405 WebInspector.Popover.Orientation = {
404 Top: "top", 406 Top: "top",
405 Bottom: "bottom" 407 Bottom: "bottom"
406 } 408 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698