Closed Bug 261826 Opened 20 years ago Closed 15 years ago

XUL tabs appear in wrong order, if a tab's HIDDEN attribute is set to TRUE then later revealed by either setting HIDDEN to FALSE or removing the HIDDEN attribute entirely.

Categories

(Core :: Layout, defect)

x86
All
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: agilmore, Assigned: bzbarsky)

References

Details

Attachments

(2 files)

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040626 Firefox/0.9.1
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040626 Firefox/0.9.1

The following XUL demonstrates the problem.  The tabs will appear in the
incorrect order : first, second, fourth, third.

<!-- XML  Start here -->
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="MyWindow"
	title=""
	xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
	width="800"
	height="600"
	onload="revealTab()">

<script type="application/x-javascript">
	function revealTab(){
		document.getElementById("fourthTab").setAttribute("hidden", "false");
		}
</script>

<tabbox>
	<tabs>
		<tab label="first"/>
		<tab label="second"/>
		<tab label="third"/>
		<tab id="fourthTab" label="fourth" hidden="true"/>
	</tabs>
	<tabpanels>
		<tabpanel>
			<label value="First page"/>
		</tabpanel>
		<tabpanel>
			<label value="second page"/>
		</tabpanel>
		<tabpanel>
			<label value="third page"/>
		</tabpanel>
		<tabpanel>
			<label value="fourth page"/>
		</tabpanel>
	</tabpanels>
</tabbox>
</window>
<!-- XML End -->

Reproducible: Always
Steps to Reproduce:
1. View code placed in 'Details' in mozilla browser
2. 
3.

Actual Results:  
Third tab appears after the Fourth tab, rather then where it should appear, before.

Expected Results:  
Display the tabs in the order they are defined in the XUL - First, Second,
Third, Fourth.

This bug occurs at least in FF 9.x, 1.0PR and Mozilla Navigator, on OSes Win98,
Win2000 and Debian Linux.
Assignee: general → nobody
Component: GFX → XP Toolkit/Widgets: XUL
QA Contact: ian
Attached file The testcase
Looks like frame construction gets confused about where the frame for the
tabpanel goes....

In particular, the problem is that the XBL inserts a spacer at the beginning of
the child list of the <tabs> and that in nsCSSFrameConstructor::ContentInserted
we call nsCSSFrameConstructor::FindPreviousSibling to find the previous sibling.
 But we use aIndexInContainer as the place to start looking, and our index in
the content iterator is actually one larger (because of the anonymous content
XBL inserted).

See the XXX comment before the FindPreviousSibling() call in ContentInserted();
that's biting us here, basically.
I think the best thing to do here would be to make GetInsertionPoint() return
not only the insertion point but also the index of the content in the insertion
point....  That would replace aIndexInContainer for the following manipulations,
then.

Alternately, we need to fix FindPreviousSibling() to not start with
aIndexInContainer, since that can end up bogus.

Thoughts?
Status: UNCONFIRMED → NEW
Component: XP Toolkit/Widgets: XUL → Layout: Misc Code
Ever confirmed: true
QA Contact: core.layout.misc-code
Depends on: 272646
Depends on: 307394
Blocks: 307085
A hack(?) would be to wrap the tabs <children> with <hbox>, which has the added side-effect of making ordinal on <tab>s work as expected (since consumers don't have to understand the spacers on the ends of the <tabs>).  Of course, doing that causes crashes (why wouldn't it?  eXtremely Unstable Languages are the best!), so I'm not going to pursue cleaning up the theme to look right.
(In reply to comment #6)
>A hack(?) would be to wrap the tabs <children> with <hbox>
Unfortunately this stops the tabs from flexing properly, so it's no use.
I'm pretty sure setting .collapsed instead should mitigate these problems (at least some of them).
Fixed by checkin for bug 307394.  Checked in test.
Status: NEW → RESOLVED
Closed: 15 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Assignee: nobody → bzbarsky
Product: Core → Core Graveyard
Component: Layout: Misc Code → Layout
Product: Core Graveyard → Core
You need to log in before you can comment on or make changes to this bug.