Add RB.ContentViewport for managing safe content areas.

Review Request #13228 — Created Aug. 22, 2023 and submitted — Latest diff uploaded

Information

Review Board
release-6.x

Reviewers

This introduces a new RB.ContentViewport class and
RB.contentViewport global that's used for tracking offsets into the
main browwser viewport that are safe for content. Its primarily useful
for helping dock content and align elements.

Elements can be registered for tracking, ensuring that any element
resizes automatically update the content area. The machinery for
tracking is only enabled when first used, to save on memory in places
where nothing is docked.

All tracking is done with a WeakMap. If the element disappears, it
will be untracked automatically. Worth noting, though, that the viewport
won't automatically adjust until another resize event occurs. We could
track removals down the road, but currently, it's not necessary.

The Unified Banner is registered as a tracked item on instantiation
during construction.

This will be used in an upcoming change to help properly center the
collapse button for diffs.

Unit tests pass.

Tested with upcoming changes for the diff collapse button, and
verified that any resizes to the Unified Banner were factored in
for positioning.

Commits

Files

    Loading...