Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 // This should not happen, but we hide previous popup to be on the safe side. | 90 // This should not happen, but we hide previous popup to be on the safe side. |
| 91 if (WebInspector.Popover._popover) | 91 if (WebInspector.Popover._popover) |
| 92 WebInspector.Popover._popover.hide(); | 92 WebInspector.Popover._popover.hide(); |
| 93 WebInspector.Popover._popover = this; | 93 WebInspector.Popover._popover = this; |
| 94 | 94 |
| 95 var document = anchor instanceof Element ? anchor.ownerDocument : conten tElement.ownerDocument; | 95 var document = anchor instanceof Element ? anchor.ownerDocument : conten tElement.ownerDocument; |
| 96 var window = document.defaultView; | 96 var window = document.defaultView; |
| 97 | 97 |
| 98 // Temporarily attach in order to measure preferred dimensions. | 98 // Temporarily attach in order to measure preferred dimensions. |
| 99 var preferredSize = view ? view.measurePreferredSize() : WebInspector.me asurePreferredSize(this._contentElement); | 99 var preferredSize = view ? view.measurePreferredSize() : WebInspector.me asurePreferredSize(this._contentElement); |
| 100 preferredWidth = preferredWidth || preferredSize.width; | 100 this._preferredWidth = preferredWidth || preferredSize.width; |
| 101 preferredHeight = preferredHeight || preferredSize.height; | 101 this._preferredHeight = preferredHeight || preferredSize.height; |
| 102 | 102 |
| 103 window.addEventListener("resize", this._hideBound, false); | 103 window.addEventListener("resize", this._hideBound, false); |
| 104 document.body.appendChild(this._containerElement); | 104 document.body.appendChild(this._containerElement); |
| 105 WebInspector.Widget.prototype.show.call(this, this._containerElement); | 105 WebInspector.Widget.prototype.show.call(this, this._containerElement); |
| 106 | 106 |
| 107 if (view) | 107 if (view) |
| 108 view.show(this._contentDiv); | 108 view.show(this._contentDiv); |
| 109 else | 109 else |
| 110 this._contentDiv.appendChild(this._contentElement); | 110 this._contentDiv.appendChild(this._contentElement); |
| 111 | 111 |
| 112 this._positionElement(anchor, preferredWidth, preferredHeight, arrowDire ction); | 112 this.positionElement(anchor, this._preferredWidth, this._preferredHeight , arrowDirection); |
| 113 | 113 |
| 114 if (this._popoverHelper) { | 114 if (this._popoverHelper) { |
| 115 this._contentDiv.addEventListener("mousemove", this._popoverHelper._ killHidePopoverTimer.bind(this._popoverHelper), true); | 115 this._contentDiv.addEventListener("mousemove", this._popoverHelper._ killHidePopoverTimer.bind(this._popoverHelper), true); |
| 116 this.element.addEventListener("mouseout", this._popoverHelper._popov erMouseOut.bind(this._popoverHelper), true); | 116 this.element.addEventListener("mouseout", this._popoverHelper._popov erMouseOut.bind(this._popoverHelper), true); |
| 117 } | 117 } |
| 118 }, | 118 }, |
| 119 | 119 |
| 120 hide: function() | 120 hide: function() |
| 121 { | 121 { |
| 122 this._containerElement.ownerDocument.defaultView.removeEventListener("re size", this._hideBound, false); | 122 this._containerElement.ownerDocument.defaultView.removeEventListener("re size", this._hideBound, false); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 150 * @param {boolean} noMargins | 150 * @param {boolean} noMargins |
| 151 */ | 151 */ |
| 152 setNoMargins: function(noMargins) | 152 setNoMargins: function(noMargins) |
| 153 { | 153 { |
| 154 this._hasNoMargins = noMargins; | 154 this._hasNoMargins = noMargins; |
| 155 this._contentDiv.classList.toggle("no-margin", this._hasNoMargins); | 155 this._contentDiv.classList.toggle("no-margin", this._hasNoMargins); |
| 156 }, | 156 }, |
| 157 | 157 |
| 158 /** | 158 /** |
| 159 * @param {!Element|!AnchorBox} anchorElement | 159 * @param {!Element|!AnchorBox} anchorElement |
| 160 * @param {number} preferredWidth | 160 * @param {number=} preferredWidth |
| 161 * @param {number} preferredHeight | 161 * @param {number=} preferredHeight |
| 162 * @param {?WebInspector.Popover.Orientation=} arrowDirection | 162 * @param {?WebInspector.Popover.Orientation=} arrowDirection |
| 163 */ | 163 */ |
| 164 _positionElement: function(anchorElement, preferredWidth, preferredHeight, a rrowDirection) | 164 positionElement: function(anchorElement, preferredWidth, preferredHeight, ar rowDirection) |
|
caseq
2015/06/16 14:14:49
Exposing this does not seem to be a good style. Ca
alph
2015/06/17 09:17:08
Could you elaborate. Do you mean make it auto repo
| |
| 165 { | 165 { |
| 166 const borderWidth = this._hasNoMargins ? 0 : 8; | 166 const borderWidth = this._hasNoMargins ? 0 : 8; |
| 167 const scrollerWidth = this._hasFixedHeight ? 0 : 11; | 167 const scrollerWidth = this._hasFixedHeight ? 0 : 11; |
| 168 const arrowHeight = this._hasNoMargins ? 8 : 15; | 168 const arrowHeight = this._hasNoMargins ? 8 : 15; |
| 169 const arrowOffset = 10; | 169 const arrowOffset = 10; |
| 170 const borderRadius = 4; | 170 const borderRadius = 4; |
| 171 const arrowRadius = 6; | 171 const arrowRadius = 6; |
| 172 preferredWidth = preferredWidth || this._preferredWidth; | |
| 173 preferredHeight = preferredHeight || this._preferredHeight; | |
| 172 | 174 |
| 173 // Skinny tooltips are not pretty, their arrow location is not nice. | 175 // Skinny tooltips are not pretty, their arrow location is not nice. |
| 174 preferredWidth = Math.max(preferredWidth, 50); | 176 preferredWidth = Math.max(preferredWidth, 50); |
| 175 // Position relative to main DevTools element. | 177 // Position relative to main DevTools element. |
| 176 const container = WebInspector.Dialog.modalHostView().element; | 178 const container = WebInspector.Dialog.modalHostView().element; |
| 177 const totalWidth = container.offsetWidth; | 179 const totalWidth = container.offsetWidth; |
| 178 const totalHeight = container.offsetHeight; | 180 const totalHeight = container.offsetHeight; |
| 179 | 181 |
| 180 var anchorBox = anchorElement instanceof AnchorBox ? anchorElement : anc horElement.boxInWindow(window); | 182 var anchorBox = anchorElement instanceof AnchorBox ? anchorElement : anc horElement.boxInWindow(window); |
| 181 anchorBox = anchorBox.relativeToElement(container); | 183 anchorBox = anchorBox.relativeToElement(container); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 413 this._resetHoverTimer(); | 415 this._resetHoverTimer(); |
| 414 } | 416 } |
| 415 } | 417 } |
| 416 } | 418 } |
| 417 | 419 |
| 418 /** @enum {string} */ | 420 /** @enum {string} */ |
| 419 WebInspector.Popover.Orientation = { | 421 WebInspector.Popover.Orientation = { |
| 420 Top: "top", | 422 Top: "top", |
| 421 Bottom: "bottom" | 423 Bottom: "bottom" |
| 422 } | 424 } |
| OLD | NEW |