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

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

Issue 2747553002: [DevTools] Rework Popover API (Closed)
Patch Set: rebased 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 this.textEditor.addEventListener( 67 this.textEditor.addEventListener(
68 SourceFrame.SourcesTextEditor.Events.EditorBlurred, 68 SourceFrame.SourcesTextEditor.Events.EditorBlurred,
69 () => UI.context.setFlavor(SourceFrame.UISourceCodeFrame, null)); 69 () => UI.context.setFlavor(SourceFrame.UISourceCodeFrame, null));
70 this.textEditor.addEventListener( 70 this.textEditor.addEventListener(
71 SourceFrame.SourcesTextEditor.Events.EditorFocused, 71 SourceFrame.SourcesTextEditor.Events.EditorFocused,
72 () => UI.context.setFlavor(SourceFrame.UISourceCodeFrame, this)); 72 () => UI.context.setFlavor(SourceFrame.UISourceCodeFrame, this));
73 73
74 this._updateStyle(); 74 this._updateStyle();
75 this._updateDiffUISourceCode(); 75 this._updateDiffUISourceCode();
76 76
77 this._errorPopoverHelper = new UI.PopoverHelper(this.element); 77 this._errorPopoverHelper = new UI.PopoverHelper(this.element, this._getError PopoverContent.bind(this));
78 this._errorPopoverHelper.initializeCallbacks(this._getErrorAnchor.bind(this) , this._showErrorPopover.bind(this));
79 this._errorPopoverHelper.setHasPadding(true); 78 this._errorPopoverHelper.setHasPadding(true);
80 79
81 this._errorPopoverHelper.setTimeout(100, 100); 80 this._errorPopoverHelper.setTimeout(100, 100);
82 81
83 /** 82 /**
84 * @return {!Promise<?string>} 83 * @return {!Promise<?string>}
85 */ 84 */
86 function workingCopy() { 85 function workingCopy() {
87 if (uiSourceCode.isDirty()) 86 if (uiSourceCode.isDirty())
88 return /** @type {!Promise<?string>} */ (Promise.resolve(uiSourceCode.wo rkingCopy())); 87 return /** @type {!Promise<?string>} */ (Promise.resolve(uiSourceCode.wo rkingCopy()));
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 if (!messageBucket) 393 if (!messageBucket)
395 return; 394 return;
396 messageBucket.removeMessage(message); 395 messageBucket.removeMessage(message);
397 if (!messageBucket.uniqueMessagesCount()) { 396 if (!messageBucket.uniqueMessagesCount()) {
398 messageBucket.detachFromEditor(); 397 messageBucket.detachFromEditor();
399 this._rowMessageBuckets.delete(lineNumber); 398 this._rowMessageBuckets.delete(lineNumber);
400 } 399 }
401 } 400 }
402 401
403 /** 402 /**
404 * @param {!Element} target
405 * @param {!Event} event 403 * @param {!Event} event
406 * @return {(!Element|undefined)} 404 * @return {?UI.PopoverRequest}
407 */ 405 */
408 _getErrorAnchor(target, event) { 406 _getErrorPopoverContent(event) {
409 var element = target.enclosingNodeOrSelfWithClass('text-editor-line-decorati on-icon') || 407 var element = event.target.enclosingNodeOrSelfWithClass('text-editor-line-de coration-icon') ||
410 target.enclosingNodeOrSelfWithClass('text-editor-line-decoration-wave'); 408 event.target.enclosingNodeOrSelfWithClass('text-editor-line-decoration-w ave');
411 if (!element) 409 if (!element)
412 return; 410 return null;
413 this._errorWavePopoverAnchor = new AnchorBox(event.clientX, event.clientY, 1 , 1); 411 var anchor = element.enclosingNodeOrSelfWithClass('text-editor-line-decorati on-icon') ?
414 return element; 412 element.boxInWindow() :
415 } 413 new AnchorBox(event.clientX, event.clientY, 1, 1);
416 414 return {
417 /** 415 box: anchor,
418 * @param {!Element|!AnchorBox} anchor 416 show: popover => {
419 * @param {!UI.GlassPane} popover 417 var messageBucket = element.enclosingNodeOrSelfWithClass('text-editor-li ne-decoration')._messageBucket;
420 * @return {!Promise<boolean>} 418 var messagesOutline = messageBucket.messagesDescription();
421 */ 419 popover.contentElement.appendChild(messagesOutline);
422 _showErrorPopover(anchor, popover) { 420 return Promise.resolve(true);
423 var element = /** @type {!Element} */ (anchor); 421 }
424 var messageBucket = element.enclosingNodeOrSelfWithClass('text-editor-line-d ecoration')._messageBucket; 422 };
425 var messagesOutline = messageBucket.messagesDescription();
426 popover.setContentAnchorBox(
427 element.enclosingNodeOrSelfWithClass('text-editor-line-decoration-icon') ? element.boxInWindow() :
428 this._errorWavePopoverAnchor);
429 popover.contentElement.appendChild(messagesOutline);
430 return Promise.resolve(true);
431 } 423 }
432 424
433 _updateBucketDecorations() { 425 _updateBucketDecorations() {
434 for (var bucket of this._rowMessageBuckets.values()) 426 for (var bucket of this._rowMessageBuckets.values())
435 bucket._updateDecoration(); 427 bucket._updateDecoration();
436 } 428 }
437 429
438 /** 430 /**
439 * @param {!Common.Event} event 431 * @param {!Common.Event} event
440 */ 432 */
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 690
699 /** 691 /**
700 * @param {!Workspace.UISourceCode.Message} a 692 * @param {!Workspace.UISourceCode.Message} a
701 * @param {!Workspace.UISourceCode.Message} b 693 * @param {!Workspace.UISourceCode.Message} b
702 * @return {number} 694 * @return {number}
703 */ 695 */
704 Workspace.UISourceCode.Message.messageLevelComparator = function(a, b) { 696 Workspace.UISourceCode.Message.messageLevelComparator = function(a, b) {
705 return Workspace.UISourceCode.Message._messageLevelPriority[a.level()] - 697 return Workspace.UISourceCode.Message._messageLevelPriority[a.level()] -
706 Workspace.UISourceCode.Message._messageLevelPriority[b.level()]; 698 Workspace.UISourceCode.Message._messageLevelPriority[b.level()];
707 }; 699 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698