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

Unified Diff: third_party/WebKit/Source/devtools/front_end/sources/JavaScriptSourceFrame.js

Issue 2745903003: [DevTools] Do not inherit ObjectPopoverHelper from PopoverHelper. (Closed)
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/sources/JavaScriptSourceFrame.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sources/JavaScriptSourceFrame.js b/third_party/WebKit/Source/devtools/front_end/sources/JavaScriptSourceFrame.js
index 265139b8b5ed9b1381d9e6a67942c229eb092e6c..c90d613ecabbce335e9224ad0efbe77f0287ed61 100644
--- a/third_party/WebKit/Source/devtools/front_end/sources/JavaScriptSourceFrame.js
+++ b/third_party/WebKit/Source/devtools/front_end/sources/JavaScriptSourceFrame.js
@@ -44,10 +44,14 @@ Sources.JavaScriptSourceFrame = class extends SourceFrame.UISourceCodeFrame {
if (uiSourceCode.project().type() === Workspace.projectTypes.Debugger)
this.element.classList.add('source-frame-debugger-script');
- this._popoverHelper = new ObjectUI.ObjectPopoverHelper(
- this._scriptsPanel.element, this._getPopoverAnchor.bind(this), this._resolveObjectForPopover.bind(this),
- this._onHidePopover.bind(this), true);
+ this._popoverHelper = new UI.PopoverHelper(this._scriptsPanel.element, true);
+ this._popoverHelper.initializeCallbacks(
+ this._getPopoverAnchor.bind(this), this._showObjectPopover.bind(this), this._onHidePopover.bind(this));
this._popoverHelper.setTimeout(250, 250);
+ this._popoverHelper.setHasPadding(true);
+ this._objectPopoverHelper = new ObjectUI.ObjectPopoverHelper();
+ this._scriptsPanel.element.addEventListener(
+ 'scroll', this._popoverHelper.hidePopover.bind(this._popoverHelper), true);
this.textEditor.element.addEventListener('keydown', this._onKeyDown.bind(this), true);
@@ -422,12 +426,14 @@ Sources.JavaScriptSourceFrame = class extends SourceFrame.UISourceCodeFrame {
return anchorBox;
}
- _resolveObjectForPopover(anchorBox, showCallback, objectGroupName) {
+ /**
+ * @param {!AnchorBox} anchorBox
+ * @return {!Promise<?SDK.RemoteObject>}
+ */
+ _resolveObjectForPopover(anchorBox) {
var selectedCallFrame = UI.context.flavor(SDK.DebuggerModel.CallFrame);
- if (!selectedCallFrame) {
- this._popoverHelper.hidePopover();
- return;
- }
+ if (!selectedCallFrame)
+ return Promise.resolve(/** @type {?SDK.RemoteObject} */ (null));
var lineNumber = anchorBox.highlight.lineNumber;
var startHighlight = anchorBox.highlight.startColumn;
var endHighlight = anchorBox.highlight.endColumn;
@@ -435,43 +441,47 @@ Sources.JavaScriptSourceFrame = class extends SourceFrame.UISourceCodeFrame {
if (!anchorBox.forSelection) {
while (startHighlight > 1 && line.charAt(startHighlight - 1) === '.') {
var token = this.textEditor.tokenAtTextPosition(lineNumber, startHighlight - 2);
- if (!token || !token.type) {
- this._popoverHelper.hidePopover();
- return;
- }
+ if (!token || !token.type)
+ return Promise.resolve(/** @type {?SDK.RemoteObject} */ (null));
startHighlight = token.startColumn;
}
}
var evaluationText = line.substring(startHighlight, endHighlight + 1);
- Sources.SourceMapNamesResolver
+ return Sources.SourceMapNamesResolver
.resolveExpression(
selectedCallFrame, evaluationText, this._debuggerSourceCode, lineNumber, startHighlight, endHighlight)
.then(onResolve.bind(this));
/**
* @param {?string=} text
+ * @return {!Promise<?SDK.RemoteObject>}
* @this {Sources.JavaScriptSourceFrame}
*/
function onResolve(text) {
+ var fulfill;
+ var promise = new Promise(x => fulfill = x);
selectedCallFrame.evaluate(
- text || evaluationText, objectGroupName, false, true, false, false, showObjectPopover.bind(this));
+ text || evaluationText, 'popover', false, true, false, false, showObjectPopover.bind(this, fulfill));
+ return promise;
}
/**
+ * @param {function(?SDK.RemoteObject)} fulfill
* @param {?Protocol.Runtime.RemoteObject} result
* @param {!Protocol.Runtime.ExceptionDetails=} exceptionDetails
* @this {Sources.JavaScriptSourceFrame}
*/
- function showObjectPopover(result, exceptionDetails) {
+ function showObjectPopover(fulfill, result, exceptionDetails) {
var target = UI.context.flavor(SDK.Target);
var potentiallyUpdatedCallFrame = UI.context.flavor(SDK.DebuggerModel.CallFrame);
- if (selectedCallFrame !== potentiallyUpdatedCallFrame || !result) {
- this._popoverHelper.hidePopover();
+ if (selectedCallFrame !== potentiallyUpdatedCallFrame || !result || exceptionDetails) {
+ fulfill(null);
return;
}
this._popoverAnchorBox = anchorBox;
- showCallback(target.runtimeModel.createRemoteObject(result), !!exceptionDetails, this._popoverAnchorBox);
- // Popover may have been removed by showCallback().
+ this._popoverTarget = target;
+ fulfill(target.runtimeModel.createRemoteObject(result));
+ // Popover may have been removed by callback().
lushnikov 2017/03/13 17:55:02 since with your change the callback will run in a
dgozman 2017/03/13 19:57:24 Done.
if (this._popoverAnchorBox) {
var highlightRange = new Common.TextRange(lineNumber, startHighlight, lineNumber, endHighlight);
this._popoverAnchorBox._highlightDescriptor =
@@ -480,7 +490,25 @@ Sources.JavaScriptSourceFrame = class extends SourceFrame.UISourceCodeFrame {
}
}
+ /**
+ * @param {!AnchorBox|!Element} anchorBox
+ * @param {!UI.GlassPane} popover
+ * @return {!Promise<boolean>}
+ */
+ _showObjectPopover(anchorBox, popover) {
+ return this._resolveObjectForPopover(/** @type {!AnchorBox} */ (anchorBox)).then(object => {
+ if (!object)
+ return false;
+ return this._objectPopoverHelper.buildObjectPopover(object, popover);
+ });
+ }
+
_onHidePopover() {
+ this._objectPopoverHelper.dispose();
lushnikov 2017/03/13 17:55:02 the this._objectPopoverHelper is created in the JS
dgozman 2017/03/13 19:57:24 Done.
+ if (this._popoverTarget) {
+ this._popoverTarget.runtimeModel.releaseObjectGroup('popover');
+ delete this._popoverTarget;
+ }
if (!this._popoverAnchorBox)
return;
if (this._popoverAnchorBox._highlightDescriptor)

Powered by Google App Engine
This is Rietveld 408576698