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

Side by Side Diff: Source/devtools/front_end/sources/FilteredItemSelectionDialog.js

Issue 1356363002: [DevTools] Remove relativeToElement from Dialog. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 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) 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 * * 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 this._delegate = delegate; 58 this._delegate = delegate;
59 this._delegate.setRefreshCallback(this._itemsLoaded.bind(this)); 59 this._delegate.setRefreshCallback(this._itemsLoaded.bind(this));
60 this._itemsLoaded(); 60 this._itemsLoaded();
61 } 61 }
62 62
63 WebInspector.FilteredItemSelectionDialog.prototype = { 63 WebInspector.FilteredItemSelectionDialog.prototype = {
64 /** 64 /**
65 * @override 65 * @override
66 * @param {!Element} element 66 * @param {!Element} element
67 * @param {!Element} relativeToElement 67 * @param {!Element} container
68 */ 68 */
69 position: function(element, relativeToElement) 69 position: function(element, container)
70 { 70 {
71 const shadow = 10; 71 const shadow = 10;
72 const shadowPadding = 20; // shadow + padding 72 const shadowPadding = 20; // shadow + padding
73 var container = WebInspector.Dialog.modalHostView().element; 73 var preferredWidth = Math.max(container.offsetWidth * 2 / 3, 500);
74 var preferredWidth = Math.max(relativeToElement.offsetWidth * 2 / 3, 500 );
75 var width = Math.min(preferredWidth, container.offsetWidth - 2 * shadowP adding); 74 var width = Math.min(preferredWidth, container.offsetWidth - 2 * shadowP adding);
76 var preferredHeight = Math.max(relativeToElement.offsetHeight * 2 / 3, 2 04); 75 var preferredHeight = Math.max(container.offsetHeight * 2 / 3, 204);
77 var height = Math.min(preferredHeight, container.offsetHeight - 2 * shad owPadding); 76 var height = Math.min(preferredHeight, container.offsetHeight - 2 * shad owPadding);
78 77
79 this.element.style.width = width + "px"; 78 this.element.style.width = width + "px";
80 var box = relativeToElement.boxInWindow(window).relativeToElement(contai ner); 79 var box = container.boxInWindow(window);
81 var positionX = box.x + Math.max((box.width - width - 2 * shadowPadding) / 2, shadow); 80 var positionX = Math.max((box.width - width - 2 * shadowPadding) / 2, sh adow);
82 positionX = Math.max(shadow, Math.min(container.offsetWidth - width - 2 * shadowPadding, positionX)); 81 positionX = Math.max(shadow, Math.min(container.offsetWidth - width - 2 * shadowPadding, positionX));
83 var positionY = box.y + Math.max((box.height - height - 2 * shadowPaddin g) / 2, shadow); 82 var positionY = Math.max((box.height - height - 2 * shadowPadding) / 2, shadow);
84 positionY = Math.max(shadow, Math.min(container.offsetHeight - height - 2 * shadowPadding, positionY)); 83 positionY = Math.max(shadow, Math.min(container.offsetHeight - height - 2 * shadowPadding, positionY));
85 element.positionAt(positionX, positionY, container); 84 element.positionAt(positionX, positionY, container);
86 this._dialogHeight = height; 85 this._dialogHeight = height;
87 86
88 this._updateShowMatchingItems(); 87 this._updateShowMatchingItems();
89 this._viewportControl.refresh(); 88 this._viewportControl.refresh();
90 }, 89 },
91 90
92 focus: function() 91 focus: function()
93 { 92 {
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 WebInspector.SelectionDialogContentProvider.call(this); 529 WebInspector.SelectionDialogContentProvider.call(this);
531 530
532 this._functionItems = []; 531 this._functionItems = [];
533 this._selectItemCallback = selectItemCallback; 532 this._selectItemCallback = selectItemCallback;
534 this._outlineWorker = new WorkerRuntime.Worker("script_formatter_worker"); 533 this._outlineWorker = new WorkerRuntime.Worker("script_formatter_worker");
535 this._outlineWorker.onmessage = this._didBuildOutlineChunk.bind(this); 534 this._outlineWorker.onmessage = this._didBuildOutlineChunk.bind(this);
536 this._outlineWorker.postMessage({ method: "javaScriptOutline", params: { con tent: uiSourceCode.workingCopy() } }); 535 this._outlineWorker.postMessage({ method: "javaScriptOutline", params: { con tent: uiSourceCode.workingCopy() } });
537 } 536 }
538 537
539 /** 538 /**
540 * @param {!WebInspector.Widget} view
541 * @param {!WebInspector.UISourceCode} uiSourceCode 539 * @param {!WebInspector.UISourceCode} uiSourceCode
542 * @param {function(number, number)} selectItemCallback 540 * @param {function(number, number)} selectItemCallback
543 */ 541 */
544 WebInspector.JavaScriptOutlineDialog.show = function(view, uiSourceCode, selectI temCallback) 542 WebInspector.JavaScriptOutlineDialog.show = function(uiSourceCode, selectItemCal lback)
545 { 543 {
546 if (WebInspector.Dialog.currentInstance()) 544 if (WebInspector.Dialog.currentInstance())
547 return; 545 return;
548 var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDial og(new WebInspector.JavaScriptOutlineDialog(uiSourceCode, selectItemCallback)); 546 var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDial og(new WebInspector.JavaScriptOutlineDialog(uiSourceCode, selectItemCallback));
549 WebInspector.Dialog.show(view.element, filteredItemSelectionDialog); 547 WebInspector.Dialog.show(filteredItemSelectionDialog);
550 } 548 }
551 549
552 WebInspector.JavaScriptOutlineDialog.prototype = { 550 WebInspector.JavaScriptOutlineDialog.prototype = {
553 /** 551 /**
554 * @param {!MessageEvent} event 552 * @param {!MessageEvent} event
555 */ 553 */
556 _didBuildOutlineChunk: function(event) 554 _didBuildOutlineChunk: function(event)
557 { 555 {
558 var data = /** @type {!WebInspector.JavaScriptOutlineDialog.MessageEvent Data} */ (event.data); 556 var data = /** @type {!WebInspector.JavaScriptOutlineDialog.MessageEvent Data} */ (event.data);
559 var chunk = data.chunk; 557 var chunk = data.chunk;
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 filterProject: function(project) 873 filterProject: function(project)
876 { 874 {
877 return !project.isServiceProject(); 875 return !project.isServiceProject();
878 }, 876 },
879 877
880 __proto__: WebInspector.SelectUISourceCodeDialog.prototype 878 __proto__: WebInspector.SelectUISourceCodeDialog.prototype
881 } 879 }
882 880
883 /** 881 /**
884 * @param {!WebInspector.SourcesView} sourcesView 882 * @param {!WebInspector.SourcesView} sourcesView
885 * @param {!Element} relativeToElement
886 * @param {string=} query 883 * @param {string=} query
887 * @param {!Map.<!WebInspector.UISourceCode, number>=} defaultScores 884 * @param {!Map.<!WebInspector.UISourceCode, number>=} defaultScores
888 */ 885 */
889 WebInspector.OpenResourceDialog.show = function(sourcesView, relativeToElement, query, defaultScores) 886 WebInspector.OpenResourceDialog.show = function(sourcesView, query, defaultScore s)
890 { 887 {
891 if (WebInspector.Dialog.currentInstance()) 888 if (WebInspector.Dialog.currentInstance())
892 return; 889 return;
893 890
894 var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDial og(new WebInspector.OpenResourceDialog(sourcesView, defaultScores)); 891 var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDial og(new WebInspector.OpenResourceDialog(sourcesView, defaultScores));
895 filteredItemSelectionDialog.renderAsTwoRows(); 892 filteredItemSelectionDialog.renderAsTwoRows();
896 WebInspector.Dialog.show(relativeToElement, filteredItemSelectionDialog); 893 WebInspector.Dialog.show(filteredItemSelectionDialog);
897 if (query) 894 if (query)
898 filteredItemSelectionDialog.setQuery(query); 895 filteredItemSelectionDialog.setQuery(query);
899 } 896 }
900 897
901 /** 898 /**
902 * @constructor 899 * @constructor
903 * @extends {WebInspector.SelectUISourceCodeDialog} 900 * @extends {WebInspector.SelectUISourceCodeDialog}
904 * @param {!Array.<string>} types 901 * @param {!Array.<string>} types
905 * @param {function(?WebInspector.UISourceCode)} callback 902 * @param {function(?WebInspector.UISourceCode)} callback
906 */ 903 */
(...skipping 26 matching lines...) Expand all
933 return this._types.indexOf(project.type()) !== -1; 930 return this._types.indexOf(project.type()) !== -1;
934 }, 931 },
935 932
936 __proto__: WebInspector.SelectUISourceCodeDialog.prototype 933 __proto__: WebInspector.SelectUISourceCodeDialog.prototype
937 } 934 }
938 935
939 /** 936 /**
940 * @param {string} name 937 * @param {string} name
941 * @param {!Array.<string>} types 938 * @param {!Array.<string>} types
942 * @param {function(?WebInspector.UISourceCode)} callback 939 * @param {function(?WebInspector.UISourceCode)} callback
943 * @param {!Element} relativeToElement
944 */ 940 */
945 WebInspector.SelectUISourceCodeForProjectTypesDialog.show = function(name, types , callback, relativeToElement) 941 WebInspector.SelectUISourceCodeForProjectTypesDialog.show = function(name, types , callback)
946 { 942 {
947 if (WebInspector.Dialog.currentInstance()) 943 if (WebInspector.Dialog.currentInstance())
948 return; 944 return;
949 945
950 var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDial og(new WebInspector.SelectUISourceCodeForProjectTypesDialog(types, callback)); 946 var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDial og(new WebInspector.SelectUISourceCodeForProjectTypesDialog(types, callback));
951 filteredItemSelectionDialog.setQuery(name); 947 filteredItemSelectionDialog.setQuery(name);
952 filteredItemSelectionDialog.renderAsTwoRows(); 948 filteredItemSelectionDialog.renderAsTwoRows();
953 WebInspector.Dialog.show(relativeToElement, filteredItemSelectionDialog); 949 WebInspector.Dialog.show(filteredItemSelectionDialog);
954 } 950 }
955 951
956 /** 952 /**
957 * @typedef {{isLastChunk: boolean, chunk: !Array.<!{selectorText: string, lineN umber: number, columnNumber: number}>}} 953 * @typedef {{isLastChunk: boolean, chunk: !Array.<!{selectorText: string, lineN umber: number, columnNumber: number}>}}
958 */ 954 */
959 WebInspector.JavaScriptOutlineDialog.MessageEventData; 955 WebInspector.JavaScriptOutlineDialog.MessageEventData;
OLDNEW
« no previous file with comments | « Source/devtools/front_end/sources/AddSourceMapURLDialog.js ('k') | Source/devtools/front_end/sources/JavaScriptSourceFrame.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698