Closed Bug 825810 Opened 12 years ago Closed 11 years ago

"Assertion failure: aFrame (why do we have an anonymous box without any children?)" with flexbox

Categories

(Core :: Layout, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla24

People

(Reporter: jruderman, Assigned: dholbert)

References

Details

(Keywords: assertion, testcase)

Attachments

(3 files, 1 obsolete file)

Attached file testcase
Assertion failure: aFrame (why do we have an anonymous box without any children?), at layout/generic/nsFlexContainerFrame.cpp:480
Blocks: 811521
We're failing to walk from the (anonymous-box) nsTableFrame to its (non-anonymous-box) column frame descendant.

What happens is this: GetFirstPrincipalChild() on the table frame ends up returning null, because our non-anonymous descendant isn't stored in the principal child list -- it's in kColGroupList.
Attached patch fix v1 (obsolete) — Splinter Review
The idea of this fix is as follows:
When we're descending through anonymous box frames to find the non-anonymous frame buried in there somewhere, we'll now check anonymous table frames for a colgroup list -- and if they have one, then that must mean there's something non-anonymous there, so we descend into that instead of the principal list. We do the same for caption lists on table-outer frames, since they trigger this bug equally well.  (crashtests included for both of those cases.)

I *think* those are the only two situations where a non-anonymous frame can end up in a non-principal-child-list subtree with an anonymous-box root...  (bz, if you know of any others, let me know; or, we can add additional special cases for them here as we discover them.)

(This patch stacks on top of my patch for bug 873172, BTW, so you probably want to look at that bug first.)
Assignee: nobody → dholbert
Status: NEW → ASSIGNED
Attachment #750801 - Flags: review?(bzbarsky)
Flags: in-testsuite?
OS: Mac OS X → All
Hardware: x86_64 → All
Comment on attachment 750801 [details] [diff] [review]
fix v1

I think you're right.  Ruby, if we ever do it, would add more cases, but that's for then to worry about.

Please fix the indent like so:

+    } else if (MOZ_UNLIKELY(aFrame->GetType() == nsGkAtoms::tableFrame) &&
+               !aFrame->GetChildList(kColGroupList).IsEmpty()) {

and r=me
Attachment #750801 - Flags: review?(bzbarsky) → review+
(In reply to Boris Zbarsky (:bz) from comment #3)
> Please fix the indent like so:

Oops; copypaste failure.  Thanks for catching -- fixed locally.

Try run (not including the indentation fix):
 https://tbpl.mozilla.org/?tree=Try&rev=21312c3ec51b
This caused some assertion failures on Try, from descending into a column-group list that's *only* has anonymous boxes (which sets off alarm bells, since we're looking for something non-anonymous). Turns out we create a (fully-anonymous) column group list even when there aren't any explicit column in the document.

So instead of taking "there's a list" to mean "there's something non-anonymous in the list", we instead need to make a recursive call into the list, and if that call return null, then we take that to mean that the list has only anonymous descendants (or it isn't there) and we can forget about it.

Try run, following that strategy: https://tbpl.mozilla.org/?tree=Try&rev=66f9e4e57c9d
Yay, Try server is green! Attaching the updated patch in a minute, but first here's a helper-patch.

In order to let ourselves make the recursive call mentioned in the previous comment, we need GetFirstNonAnonBoxDescendant to deal with null pointers gracefully. So, this "part 1" patch is just a logic-shifting patch, moving the sanity null-checks out of GetFirstNonAnonBoxDescendant() to its caller, IsOrderLEQWithDOMFallback.

This makes GetFirstNonAnonBoxDescendant itself now OK with handling null pointers, which will be useful in the next part. (coming up)
Attachment #750801 - Attachment is obsolete: true
Attachment #751459 - Flags: review?(bzbarsky)
Here's the updated "real" patch for this bug.

To recap: the old patch assumed that the presence of a caption/column child list meant that the list must have something non-anonymous in it [which turned out to be false].  This new patch is more sensitive -- it makes a recursive call to the list's first frame (if any) to dig for the first non-anonymous descendant in the list, and if that fails, then we fall back to digging through the principal child list.
Attachment #751460 - Flags: review?(bzbarsky)
Comment on attachment 751459 [details] [diff] [review]
part 1: Shift null-check out of GetFirstNonAnonBoxDescendant

r=me
Attachment #751459 - Flags: review?(bzbarsky) → review+
Comment on attachment 751460 [details] [diff] [review]
part 2:  Make recursive call to GetFirstNonAnonBoxDescendant for caption & colgroup lists

r=me, but I just realized something: if the anon table has both a non-anon col and a non-anon cell, we will now find the col.  I guess it doesn't matter too much, since they must be adjacent-ish in the DOM and we only use this for sorting?  Might be worth a comment, though.
Attachment #751460 - Flags: review?(bzbarsky) → review+
Exactly, yeah -- shouldn't cause any problems, since this is just for sorting and if they're in the same anonymous table box, then they'll always sort identically since they'll be part of the same flex item.

(We have the same sort of thing if you have a jumble of non-anon table-rows and/or table-cells -- we'll just grab whichever one we hit first.)

I'll add a comment clarifying that before landing. Thanks for the review!
FWIW, the comment I added was:
+    // (Note: For anonymous tables that have a non-anon cell *and* a non-anon
+    // column, we'll always return the column. This is fine; we're really just
+    // looking for a handle to *anything* with a meaningful content node inside
+    // the table, for use in DOM comparisons to things outside of the table.)
https://hg.mozilla.org/mozilla-central/rev/05a73d83e05f
https://hg.mozilla.org/mozilla-central/rev/91a48bb34e1c
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla24
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: