Open Bug 614154 Opened 14 years ago Updated 2 years ago

Don't change selected attribute when moving tab

Categories

(Firefox :: Tabbed Browser, defect)

defect

Tracking

()

UNCONFIRMED

People

(Reporter: tabutils+bugzilla, Unassigned)

References

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12 (.NET CLR 3.5.30729)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12 (.NET CLR 3.5.30729)

In gBrowser.moveTabTo, it set _selected to false for each tab. It sets/unsets first-tab/last-tab/beforeselected/afterselected attributes. This is no problem. But there is no need to set/unset "selected" attribute. Moving a tab won't change the selected state.
Please make _selected setter changes first-tab/last-tab/beforeselected/afterselected attributes only, and add another selected setter if necessary which will change "selected" attribute and call _selected setter.

Reproducible: Always
Sorry, but this behavior is intentional.
Status: UNCONFIRMED → RESOLVED
Closed: 14 years ago
Resolution: --- → DUPLICATE
And set "selected" attribute to "true" or "false" in selected setter, but don't remove it. Thus a tab could be easily identified whether it has been visited.
Status: RESOLVED → UNCONFIRMED
Resolution: DUPLICATE → ---
(In reply to comment #1)
> Sorry, but this behavior is intentional.

Please make it intentional to differentiate a tab selected, visited or unvisited.
I have just read bug 296970. It tells an entirely different story.
As you can read, in gBrowser.mTabContainer.selectedIndex setter, it checks whether a tab is already selected before setting selected to false. gBrowser.moveTabTo's behavior , which sets each tab's selected to false without checking, is unreasonable.
Version: unspecified → Trunk
Why exactly is the current behavior a problem for you?
Version: Trunk → unspecified
moveTabTo does an unnecessary unreasonable action. That's the problem. 
You may say "selected" is not for unread state. That's OK. But moveTabTo should not set each tab without checking. It should behave like gBrowser.mTabContainer.selectedIndex setter.
So we set the 'selected' attribute when it's already there and try to remove it when it shouldn't be there -- while unnecessary, why is that a problem?

The selectedIndex setter seems to set _selected just like moveTabTo:

http://mxr.mozilla.org/mozilla-central/source/toolkit/content/widgets/tabbox.xml

384             Array.forEach(this.childNodes, function (aTab) {
385               if (aTab.selected && aTab != tab)
386                 aTab._selected = false;
387             });
388             tab._selected = true;
The selectedIndex setter checks aTab.selected, as you see, while moveTabTo doesn't. Why need moveTabTo set each tab's selected to false?
(In reply to comment #8)
> So we set the 'selected' attribute when it's already there and try to remove it
> when it shouldn't be there -- while unnecessary, why is that a problem?

Its being a problem is that it breaks some existing user styles, and there may be some other potential impacts. It can be done better, can't it?
So rather than setting _selected = false in a loop, moveTabTo should set _selected = false on the selected tab, move aTab, and set _selected = true on the selected tab. Is that what you're asking for?
Yes, and that has been there. I guess the looped _selected = false is to set "beforeselected"/"afterselected"/etc., but I'm not sure.
I correct myself. The looped _selected = false is probably to set "first-tab"/"last-tab" attributes, as "beforeselected"/"afterselected" have been correctly set with setting _selected on the selected tab.
By the way, how can I upload a proposed patch? The "instructions on how to submit a patch"(http://developer.mozilla.org/en/docs/Getting_your_patch_in_the_tree) page seems broken.
(In reply to comment #14)
> By the way, how can I upload a proposed patch? The "instructions on how to
> submit a
> patch"(http://developer.mozilla.org/en/docs/Getting_your_patch_in_the_tree)
> page seems broken.

That page appears to have moved here: https://developer.mozilla.org/En/Developer_Guide/How_to_Submit_a_Patch
(In reply to comment #15)
> That page appears to have moved here:
> https://developer.mozilla.org/En/Developer_Guide/How_to_Submit_a_Patch

Thanks. It seems I need some software to checkout the code, which I'm not familiar with yet. So I give up.

My proposal is to separate the current "_selected" setter into several parts. 
One is still named "_selected" setter, which handles "beforeselected"/"afterselected" attributes only. 
Another is "selected" setter which handles "selected" attribute only and calls "_selected" setter. The selectedIndex setter will call "selected" setter instead of "_selected" setter.
The 3rd is "_first" setter and the 4th "_last", which will be called by addTab/removeTab/moveTabTo. Maybe these setters are not necessary. We can set/remove "first-tab"/"last-tab" attributes directly. These two attributes are not related to selected state.

Besides, after the landing of Panorama, some logic might need improving?
http://mxr.mozilla.org/mozilla-central/source/toolkit/content/widgets/tabbox.xml#740

The first-tab/last-tab/beforeselected/afterselected attributes are now entirely broken by Panorama.
Version: unspecified → Trunk
The _selected = false looping should be removed once "first-tab"/"last-tab" attributes are obsolete.

http://mxr.mozilla.org/mozilla-central/source/browser/base/content/tabbrowser.xml#2219
Depends on: 480813
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.