Open Bug 1482514 Opened 7 years ago Updated 3 years ago

Move CSSPixel and AppUnit conversion functions to layout/base/Units.h

Categories

(Core :: Layout, enhancement, P4)

enhancement

Tracking

()

People

(Reporter: TYLin, Unassigned)

References

(Blocks 1 open bug)

Details

The links in comment 0 are pointing to e.g. CSSPixelsToAppUnits(), AppUnitsPerCSSPixel(), etc. I'm not sure we should move these.... The "DevPixel" versions of these functions must necessarily live on nsPresContext/nsDeviceContext because they depend on your full-page-zoom factor (and maybe other doc-specific things). The CSSPixel versions don't have that per-document dependence, but they're conceptually similar, so it's convenient for them to live in the same place and have a similar function signature. If we moved the static (i.e. "CSSPixel"-flavored) functions to Units.h, then we'd lose that.
Units.h introduce those DevPixel (LayoutDevicePixel) versions of the functions in [1], which have extra "aAppUnitsPerDevPixel" arugement for them to depend on the nsDeviceContext. So it's possible to rewrite existing code using them. I'm not sure how much work for now, but the interface should be easier to understand if they live in one place. Perhaps at least we can gid of nsPresContext::AppUnitsPerCSSPixel(), nsPresContext::AppUnitsPerCSSInch(), nsDeviceContext::AppUnitsPerCSSPixel(), and nsDeviceContext()::AppUnitsPerAppUnitsPerCSSInch() because they're equivalent to those defined in gfx/src/AppUnits.h. Some of the layout code like [2] strives to get it, which isn't really necessary. [1] https://dxr.mozilla.org/mozilla-central/rev/4e56a2f51ad739ca52046723448f3129a58f1666/layout/base/Units.h#295-303 [2] https://dxr.mozilla.org/mozilla-central/rev/4e56a2f51ad739ca52046723448f3129a58f1666/layout/svg/nsSVGOuterSVGFrame.cpp#588
Depends on: 1482665
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.