OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
315 | 315 |
316 /** | 316 /** |
317 * @param {string} id | 317 * @param {string} id |
318 * @param {boolean=} userGesture | 318 * @param {boolean=} userGesture |
319 * @return {boolean} | 319 * @return {boolean} |
320 */ | 320 */ |
321 selectTab: function(id, userGesture) | 321 selectTab: function(id, userGesture) |
322 { | 322 { |
323 if (this._currentTabLocked) | 323 if (this._currentTabLocked) |
324 return false; | 324 return false; |
325 var focused = this.hasFocus(); | 325 var shouldFocus = this.hasFocus() || !WebInspector.currentFocusElement() ; |
dgozman
2016/05/27 01:05:59
This looks strange. The logic here was preserving
lushnikov
2016/05/27 01:14:44
maybe focusing iff userGesture would work as well
luoe
2016/05/27 23:20:40
Almost, but it didn't cover all the cases.
luoe
2016/05/27 23:20:40
Yeah, it is strange. The condition has been rever
| |
326 var tab = this._tabsById[id]; | 326 var tab = this._tabsById[id]; |
327 if (!tab) | 327 if (!tab) |
328 return false; | 328 return false; |
329 if (this._currentTab && this._currentTab.id === id) | 329 if (this._currentTab && this._currentTab.id === id) |
330 return true; | 330 return true; |
331 | 331 |
332 this._hideCurrentTab(); | 332 this._hideCurrentTab(); |
333 this._showTab(tab); | 333 this._showTab(tab); |
334 this._currentTab = tab; | 334 this._currentTab = tab; |
335 | 335 |
336 this._tabsHistory.splice(this._tabsHistory.indexOf(tab), 1); | 336 this._tabsHistory.splice(this._tabsHistory.indexOf(tab), 1); |
337 this._tabsHistory.splice(0, 0, tab); | 337 this._tabsHistory.splice(0, 0, tab); |
338 | 338 |
339 this._updateTabElements(); | 339 this._updateTabElements(); |
340 if (focused) | 340 if (shouldFocus) |
341 this.focus(); | 341 this.focus(); |
342 | 342 |
343 var eventData = { tabId: id, view: tab.view, isUserGesture: userGesture }; | 343 var eventData = { tabId: id, view: tab.view, isUserGesture: userGesture }; |
344 this.dispatchEventToListeners(WebInspector.TabbedPane.EventTypes.TabSele cted, eventData); | 344 this.dispatchEventToListeners(WebInspector.TabbedPane.EventTypes.TabSele cted, eventData); |
345 return true; | 345 return true; |
346 }, | 346 }, |
347 | 347 |
348 /** | 348 /** |
349 * @param {number} tabsCount | 349 * @param {number} tabsCount |
350 * @return {!Array.<string>} | 350 * @return {!Array.<string>} |
(...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1430 if (this._viewCallback && view) | 1430 if (this._viewCallback && view) |
1431 this._viewCallback(id, view); | 1431 this._viewCallback(id, view); |
1432 var shouldFocus = this._tabbedPane.visibleView.element.isSelfOrAnces tor(WebInspector.currentFocusElement()); | 1432 var shouldFocus = this._tabbedPane.visibleView.element.isSelfOrAnces tor(WebInspector.currentFocusElement()); |
1433 this._tabbedPane.changeTabView(id, view); | 1433 this._tabbedPane.changeTabView(id, view); |
1434 if (shouldFocus) | 1434 if (shouldFocus) |
1435 view.focus(); | 1435 view.focus(); |
1436 return view; | 1436 return view; |
1437 } | 1437 } |
1438 } | 1438 } |
1439 } | 1439 } |
OLD | NEW |