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)
Core
Layout
Tracking
()
NEW
People
(Reporter: TYLin, Unassigned)
References
(Blocks 1 open bug)
Details
We have a bunch of static units conversion functions in nsPresContext [1] and nsDeviceContext [2], which might be better move to layout/base/Units.h.
[1] https://dxr.mozilla.org/mozilla-central/rev/4e56a2f51ad739ca52046723448f3129a58f1666/layout/base/nsPresContext.h#661-708
[2] https://dxr.mozilla.org/mozilla-central/rev/4e56a2f51ad739ca52046723448f3129a58f1666/gfx/src/nsDeviceContext.h#88,121
Comment 1•7 years ago
|
||
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.
Reporter | ||
Comment 2•7 years ago
|
||
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
Updated•3 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•