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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/Toolbar.js

Issue 2706293007: [DevTools] Fix Dialog's close button to properly close dialog. (Closed)
Patch Set: test Created 3 years, 10 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) 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } 118 }
119 119
120 mainButtonClone.setToggled(action.toggled()); 120 mainButtonClone.setToggled(action.toggled());
121 buttons.push(mainButtonClone); 121 buttons.push(mainButtonClone);
122 122
123 var document = button.element.ownerDocument; 123 var document = button.element.ownerDocument;
124 document.documentElement.addEventListener('mouseup', mouseUp, false); 124 document.documentElement.addEventListener('mouseup', mouseUp, false);
125 125
126 var optionsGlassPane = new UI.GlassPane(); 126 var optionsGlassPane = new UI.GlassPane();
127 optionsGlassPane.setBlockPointerEvents(true); 127 optionsGlassPane.setBlockPointerEvents(true);
128 optionsGlassPane.showGlassPane(document); 128 optionsGlassPane.show(document);
129 var optionsBar = new UI.Toolbar('fill', optionsGlassPane.contentElement); 129 var optionsBar = new UI.Toolbar('fill', optionsGlassPane.contentElement);
130 optionsBar._contentElement.classList.add('floating'); 130 optionsBar._contentElement.classList.add('floating');
131 const buttonHeight = 26; 131 const buttonHeight = 26;
132 132
133 var hostButtonPosition = button.element.totalOffset(); 133 var hostButtonPosition = button.element.boxInWindow().relativeToElement(UI .GlassPane.container(document));
134 134
135 var topNotBottom = hostButtonPosition.top + buttonHeight * buttons.length < document.documentElement.offsetHeight; 135 var topNotBottom = hostButtonPosition.y + buttonHeight * buttons.length < document.documentElement.offsetHeight;
136 136
137 if (topNotBottom) 137 if (topNotBottom)
138 buttons = buttons.reverse(); 138 buttons = buttons.reverse();
139 139
140 optionsBar.element.style.height = (buttonHeight * buttons.length) + 'px'; 140 optionsBar.element.style.height = (buttonHeight * buttons.length) + 'px';
141 if (topNotBottom) 141 if (topNotBottom)
142 optionsBar.element.style.top = (hostButtonPosition.top + 1) + 'px'; 142 optionsBar.element.style.top = (hostButtonPosition.y - 5) + 'px';
143 else 143 else
144 optionsBar.element.style.top = (hostButtonPosition.top - (buttonHeight * (buttons.length - 1))) + 'px'; 144 optionsBar.element.style.top = (hostButtonPosition.y - (buttonHeight * ( buttons.length - 1)) - 6) + 'px';
145 optionsBar.element.style.left = (hostButtonPosition.left + 1) + 'px'; 145 optionsBar.element.style.left = (hostButtonPosition.x - 5) + 'px';
146 146
147 for (var i = 0; i < buttons.length; ++i) { 147 for (var i = 0; i < buttons.length; ++i) {
148 buttons[i].element.addEventListener('mousemove', mouseOver, false); 148 buttons[i].element.addEventListener('mousemove', mouseOver, false);
149 buttons[i].element.addEventListener('mouseout', mouseOut, false); 149 buttons[i].element.addEventListener('mouseout', mouseOut, false);
150 optionsBar.appendToolbarItem(buttons[i]); 150 optionsBar.appendToolbarItem(buttons[i]);
151 } 151 }
152 var hostButtonIndex = topNotBottom ? 0 : buttons.length - 1; 152 var hostButtonIndex = topNotBottom ? 0 : buttons.length - 1;
153 buttons[hostButtonIndex].element.classList.add('emulate-active'); 153 buttons[hostButtonIndex].element.classList.add('emulate-active');
154 154
155 function mouseOver(e) { 155 function mouseOver(e) {
156 if (e.which !== 1) 156 if (e.which !== 1)
157 return; 157 return;
158 var buttonElement = e.target.enclosingNodeOrSelfWithClass('toolbar-item' ); 158 var buttonElement = e.target.enclosingNodeOrSelfWithClass('toolbar-item' );
159 buttonElement.classList.add('emulate-active'); 159 buttonElement.classList.add('emulate-active');
160 } 160 }
161 161
162 function mouseOut(e) { 162 function mouseOut(e) {
163 if (e.which !== 1) 163 if (e.which !== 1)
164 return; 164 return;
165 var buttonElement = e.target.enclosingNodeOrSelfWithClass('toolbar-item' ); 165 var buttonElement = e.target.enclosingNodeOrSelfWithClass('toolbar-item' );
166 buttonElement.classList.remove('emulate-active'); 166 buttonElement.classList.remove('emulate-active');
167 } 167 }
168 168
169 function mouseUp(e) { 169 function mouseUp(e) {
170 if (e.which !== 1) 170 if (e.which !== 1)
171 return; 171 return;
172 optionsGlassPane.hideGlassPane(); 172 optionsGlassPane.hide();
173 document.documentElement.removeEventListener('mouseup', mouseUp, false); 173 document.documentElement.removeEventListener('mouseup', mouseUp, false);
174 174
175 for (var i = 0; i < buttons.length; ++i) { 175 for (var i = 0; i < buttons.length; ++i) {
176 if (buttons[i].element.classList.contains('emulate-active')) { 176 if (buttons[i].element.classList.contains('emulate-active')) {
177 buttons[i].element.classList.remove('emulate-active'); 177 buttons[i].element.classList.remove('emulate-active');
178 buttons[i]._clicked(e); 178 buttons[i]._clicked(e);
179 break; 179 break;
180 } 180 }
181 } 181 }
182 } 182 }
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 /** 1047 /**
1048 * @param {!Common.Setting} setting 1048 * @param {!Common.Setting} setting
1049 * @param {string=} tooltip 1049 * @param {string=} tooltip
1050 * @param {string=} alternateTitle 1050 * @param {string=} alternateTitle
1051 */ 1051 */
1052 constructor(setting, tooltip, alternateTitle) { 1052 constructor(setting, tooltip, alternateTitle) {
1053 super(alternateTitle || setting.title() || '', tooltip); 1053 super(alternateTitle || setting.title() || '', tooltip);
1054 UI.SettingsUI.bindCheckbox(this.inputElement, setting); 1054 UI.SettingsUI.bindCheckbox(this.inputElement, setting);
1055 } 1055 }
1056 }; 1056 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698