Closed Bug 1521604 Opened 5 years ago Closed 5 years ago

Add parentFlexElement property to HTML elements

Categories

(Core :: CSS Parsing and Computation, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
mozilla67
Tracking Status
firefox67 --- fixed

People

(Reporter: miker, Assigned: bradwerth)

References

Details

Attachments

(3 files)

Martin pointed out that since landing the combined highlighter (flexbox + box model) the highlighter itself has become laggy.

This is because for each node that is selected we need to walk up the DOM tree to see if a node is inside a flexbox container.

We should add a chromeOnly property to flex items that will give us their container.

This should be as performant as possible.

Component: Inspector → CSS Parsing and Computation
Product: DevTools → Core

@Brad Is this something you could do?

Flags: needinfo?(bwerth)

This should be straightforward. (Editing) Hmmm... less so. If we need to retrieve this for all HTML elements, then we don't have a good existing hook for this. The way we get "extra" information for grid and flex containers is to do a reflow that generates that extra data when needed. For grid and flex, we only do this when the relevant element is selected in by the inspector. In this case, we would be doing a reflow of the whole document as soon as we open the highlighter, which could be a bad user experience. I'll thikn on this and see if I can come up with a better solution.

Assignee: nobody → bwerth
Flags: needinfo?(bwerth)

(In reply to Mike Ratcliffe [:miker] [:mratcliffe] [:mikeratcliffe] from comment #0)

This is because for each node that is selected we need to walk up the DOM tree to see if a node is inside a flexbox container.

Mike, would you please link to the JS implementation of the walk up the DOM tree so I can replicate the algorithm correctly?

Flags: needinfo?(mratcliffe)

The attachment 9038403 [details] provides a method of doing a very short DOM walk in the platform code to return the parent flex element, if any. If this works and is performant enough, then there's no need to do a decorating reflow of the document to cache pointers to the flex parents.

Flags: needinfo?(mratcliffe)
Summary: Add getContainerForFlexitem() to HTML elements → Add getFlexParent() to HTML elements

Depends on D17308

Attachment #9038403 - Attachment description: Bug 1521604 Part 1: Create a Element::GetFlexParent method. → Bug 1521604 Part 1: Create a Node chrome-only parentFlexElement property, for use by devtools.
Attachment #9038701 - Attachment description: Bug 1521604 Part 2: Add a test of getFlexParent(). → Bug 1521604 Part 2: Add a test of parentFlexElement.
Attachment #9038403 - Attachment description: Bug 1521604 Part 1: Create a Node chrome-only parentFlexElement property, for use by devtools. → Bug 1521604 Part 2: Create a Node chrome-only parentFlexElement property, for use by devtools.
Attachment #9038701 - Attachment description: Bug 1521604 Part 2: Add a test of parentFlexElement. → Bug 1521604 Part 3: Add a test of parentFlexElement.
Pushed by bwerth@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/6d3b8198f399
Part 1: Hoist the flushing version of GetPrimaryFrame from Element to nsIContent. r=bzbarsky
https://hg.mozilla.org/integration/autoland/rev/e23801bb3b78
Part 2: Create a Node chrome-only parentFlexElement property, for use by devtools. r=dholbert,bzbarsky
https://hg.mozilla.org/integration/autoland/rev/d39849743a9c
Part 3: Add a test of parentFlexElement. r=dholbert
Summary: Add getFlexParent() to HTML elements → Add parentFlexElement property to HTML elements
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: