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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/source_frame/UISourceCodeFrame.js

Issue 2747553002: [DevTools] Rework Popover API (Closed)
Patch Set: await 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 10 *
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 65
66 this.textEditor.addEventListener( 66 this.textEditor.addEventListener(
67 SourceFrame.SourcesTextEditor.Events.EditorBlurred, 67 SourceFrame.SourcesTextEditor.Events.EditorBlurred,
68 () => UI.context.setFlavor(SourceFrame.UISourceCodeFrame, null)); 68 () => UI.context.setFlavor(SourceFrame.UISourceCodeFrame, null));
69 this.textEditor.addEventListener( 69 this.textEditor.addEventListener(
70 SourceFrame.SourcesTextEditor.Events.EditorFocused, 70 SourceFrame.SourcesTextEditor.Events.EditorFocused,
71 () => UI.context.setFlavor(SourceFrame.UISourceCodeFrame, this)); 71 () => UI.context.setFlavor(SourceFrame.UISourceCodeFrame, this));
72 72
73 this._updateStyle(); 73 this._updateStyle();
74 74
75 this._errorPopoverHelper = new UI.PopoverHelper(this.element); 75 this._errorPopoverHelper = new UI.PopoverHelper(this.element, false, this._g etErrorPopoverContent.bind(this));
76 this._errorPopoverHelper.initializeCallbacks(this._getErrorAnchor.bind(this) , this._showErrorPopover.bind(this));
77 this._errorPopoverHelper.setHasPadding(true); 76 this._errorPopoverHelper.setHasPadding(true);
78 77
79 this._errorPopoverHelper.setTimeout(100, 100); 78 this._errorPopoverHelper.setTimeout(100, 100);
80 79
81 /** 80 /**
82 * @return {!Promise<?string>} 81 * @return {!Promise<?string>}
83 */ 82 */
84 function workingCopy() { 83 function workingCopy() {
85 if (uiSourceCode.isDirty()) 84 if (uiSourceCode.isDirty())
86 return /** @type {!Promise<?string>} */ (Promise.resolve(uiSourceCode.wo rkingCopy())); 85 return /** @type {!Promise<?string>} */ (Promise.resolve(uiSourceCode.wo rkingCopy()));
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 if (!messageBucket) 378 if (!messageBucket)
380 return; 379 return;
381 messageBucket.removeMessage(message); 380 messageBucket.removeMessage(message);
382 if (!messageBucket.uniqueMessagesCount()) { 381 if (!messageBucket.uniqueMessagesCount()) {
383 messageBucket.detachFromEditor(); 382 messageBucket.detachFromEditor();
384 this._rowMessageBuckets.delete(lineNumber); 383 this._rowMessageBuckets.delete(lineNumber);
385 } 384 }
386 } 385 }
387 386
388 /** 387 /**
389 * @param {!Element} target
390 * @param {!Event} event 388 * @param {!Event} event
391 * @return {(!Element|undefined)} 389 * @return {?UI.PopoverContent}
lushnikov 2017/03/14 01:44:04 It feels like client should create actual popover
dgozman 2017/03/14 21:34:01 Done.
392 */ 390 */
393 _getErrorAnchor(target, event) { 391 _getErrorPopoverContent(event) {
lushnikov 2017/03/14 01:44:04 _maybeShowErrorPopover?
394 var element = target.enclosingNodeOrSelfWithClass('text-editor-line-decorati on-icon') || 392 var element = event.target.enclosingNodeOrSelfWithClass('text-editor-line-de coration-icon') ||
395 target.enclosingNodeOrSelfWithClass('text-editor-line-decoration-wave'); 393 event.target.enclosingNodeOrSelfWithClass('text-editor-line-decoration-w ave');
396 if (!element) 394 if (!element)
397 return; 395 return null;
398 this._errorWavePopoverAnchor = new AnchorBox(event.clientX, event.clientY, 1 , 1); 396 var anchor = element.enclosingNodeOrSelfWithClass('text-editor-line-decorati on-icon') ?
399 return element; 397 element.boxInWindow() :
400 } 398 new AnchorBox(event.clientX, event.clientY, 1, 1);
401 399 return {
402 /** 400 box: anchor,
403 * @param {!Element|!AnchorBox} anchor 401 show: popover => {
404 * @param {!UI.GlassPane} popover 402 var messageBucket = element.enclosingNodeOrSelfWithClass('text-editor-li ne-decoration')._messageBucket;
405 * @return {!Promise<boolean>} 403 var messagesOutline = messageBucket.messagesDescription();
406 */ 404 popover.contentElement.appendChild(messagesOutline);
407 _showErrorPopover(anchor, popover) { 405 return Promise.resolve(true);
408 var element = /** @type {!Element} */ (anchor); 406 }
409 var messageBucket = element.enclosingNodeOrSelfWithClass('text-editor-line-d ecoration')._messageBucket; 407 };
410 var messagesOutline = messageBucket.messagesDescription();
411 popover.setContentAnchorBox(
412 element.enclosingNodeOrSelfWithClass('text-editor-line-decoration-icon') ? element.boxInWindow() :
413 this._errorWavePopoverAnchor);
414 popover.contentElement.appendChild(messagesOutline);
415 return Promise.resolve(true);
416 } 408 }
417 409
418 _updateBucketDecorations() { 410 _updateBucketDecorations() {
419 for (var bucket of this._rowMessageBuckets.values()) 411 for (var bucket of this._rowMessageBuckets.values())
420 bucket._updateDecoration(); 412 bucket._updateDecoration();
421 } 413 }
422 414
423 /** 415 /**
424 * @param {!Common.Event} event 416 * @param {!Common.Event} event
425 */ 417 */
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 675
684 /** 676 /**
685 * @param {!Workspace.UISourceCode.Message} a 677 * @param {!Workspace.UISourceCode.Message} a
686 * @param {!Workspace.UISourceCode.Message} b 678 * @param {!Workspace.UISourceCode.Message} b
687 * @return {number} 679 * @return {number}
688 */ 680 */
689 Workspace.UISourceCode.Message.messageLevelComparator = function(a, b) { 681 Workspace.UISourceCode.Message.messageLevelComparator = function(a, b) {
690 return Workspace.UISourceCode.Message._messageLevelPriority[a.level()] - 682 return Workspace.UISourceCode.Message._messageLevelPriority[a.level()] -
691 Workspace.UISourceCode.Message._messageLevelPriority[b.level()]; 683 Workspace.UISourceCode.Message._messageLevelPriority[b.level()];
692 }; 684 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698