Bug 1338899 - Part 1 - Use getter/setter for accessing/modifying a tab's parent ID in Gecko. r=sebastian

This should be more foolproof than having to remember to use the dedicated setParentId() function when writing to that variable from outside of the tab constructor.

MozReview-Commit-ID: 1KlXf60VsoF

--HG--
extra : rebase_source : 3ae5234a0113b6077a91e873c7a5e5919b162af3
This commit is contained in:
Jan Henning 2017-02-12 15:34:00 +01:00
Родитель c298244987
Коммит cc94d60ffc
2 изменённых файлов: 9 добавлений и 4 удалений

Просмотреть файл

@ -3428,6 +3428,7 @@ function Tab(aURL, aParams) {
this.filter = null;
this.browser = null;
this.id = 0;
this._parentId = -1;
this.lastTouchedAt = Date.now();
this._zoom = 1.0;
this._drawZoom = 1.0;
@ -3555,7 +3556,7 @@ Tab.prototype = {
}
this.desktopMode = ("desktopMode" in aParams) ? aParams.desktopMode : false;
this.parentId = ("parentId" in aParams && typeof aParams.parentId == "number")
this._parentId = ("parentId" in aParams && typeof aParams.parentId == "number")
? aParams.parentId : -1;
let message = {
@ -3959,9 +3960,13 @@ Tab.prototype = {
}
},
setParentId: function(aParentId) {
get parentId() {
return this._parentId;
},
set parentId(aParentId) {
let newParentId = (typeof aParentId == "number") ? aParentId : -1;
this.parentId = newParentId;
this._parentId = newParentId;
GlobalEventDispatcher.sendRequest({
type: "Tab:SetParentId",
tabID: this.id,

Просмотреть файл

@ -1640,7 +1640,7 @@ SessionStore.prototype = {
let parentId = tabData.parentId;
if (parentId > -1) {
tab.setParentId(parentId);
tab.parentId = parentId;
}
tab.browser.__SS_data = tabData;