Closed Bug 813358 Opened 12 years ago Closed 12 years ago

Move nsBoxFrame frame-sorting logic into nsLayoutUtils

Categories

(Core :: Layout, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla20

People

(Reporter: dholbert, Assigned: dholbert)

References

Details

Attachments

(5 files, 1 obsolete file)

nsBoxFrame has code to merge-sort a frame list, and I'd love to use it in bug 811521 for sorting a flex container's children. Filing this bug on moving that frame-list-sorting code into nsLayoutUtils and making it more generic.
Assignee: nobody → dholbert
Status: NEW → ASSIGNED
This patch just removes the (unneeded) nsBoxLayoutState argument from the sorting methods in question (in preparation for ripping them out of nsBoxFrame).
Attachment #683365 - Flags: review?(dbaron)
This patch simplifies the logic for checking if a frame list is already sorted. In particular, this patch just makes us directly compare each pair of adjacent frames, instead of using "maxOrdinal". (This functionality will get separated out into its own templatized function in the next patch, but that patch is simpler if I've paved the way for that in this patch.)
Attachment #683390 - Flags: review?(dbaron)
(forgot a commit message; added one now)
Attachment #683390 - Attachment is obsolete: true
Attachment #683390 - Flags: review?(dbaron)
Attachment #683391 - Flags: review?(dbaron)
This patch splits CheckBoxOrder into two helper-methods -- IsFrameListSorted() and SortFrameList() -- which take a comparison function as a template-argument.
Attachment #683397 - Flags: review?(dbaron)
Attachment #683397 - Attachment description: part 3: Make the comparison function a template parameter → part 3: Split CheckBoxOrder into "IsFrameListSorted" and "SortFrameList", which take comparison function as a template parameter
(part 4 is essentially just a giant cut-and-paste, with a few "nsLayoutUtils::" prefix insertions & removals)
OS: Linux → All
Hardware: x86_64 → All
Attachment #683365 - Attachment description: part 1: remove unneeded state args from sorting method → part 1: remove unneeded state args from sorting methods
Comment on attachment 683365 [details] [diff] [review] part 1: remove unneeded state args from sorting methods r=dbaron
Attachment #683365 - Flags: review?(dbaron) → review+
Comment on attachment 683391 [details] [diff] [review] part 2 v2: Simplify "is frame list already sorted" logic It might be better to have the mFrames.IsEmpty() check before the SupportsOrdinalsInChildren check, just since it might be better to have the early return that doesn't involve a virtual function call before the one that does. I think I slightly preferred the old one-iterator-plus-maxOrdinal approach rather than the two-iterators approach, but I'm ok either way. r=dbaron
Attachment #683391 - Flags: review?(dbaron) → review+
Comment on attachment 683397 [details] [diff] [review] part 3: Split CheckBoxOrder into "IsFrameListSorted" and "SortFrameList", which take comparison function as a template parameter Er, now I see where you were going with the previous patches; I guess you can ignore a bunch of my comments on them.
Attachment #683397 - Flags: review?(dbaron) → review+
(In reply to David Baron [:dbaron] from comment #9) > Er, now I see where you were going with the previous patches; I guess you > can ignore a bunch of my comments on them. Yup -- sorry for not making that clearer. (I'll disregard both points from comment 8, since that code is the way it is for the purpose of splitting out a generic "IsFrameListSorted" function.)
Thanks for the reviews! One more tiny patch here that I forgot to attach -- just adding a sanity-check assertion that after we sort, we satisfy IsFrameListSorted().
Attachment #687281 - Flags: review?(dbaron)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: