PSA: Length::Fixed(x) is the new black

7 views
Skip to first unread message

Daniel Bratell

unread,
Feb 13, 2019, 9:44:48 AM2/13/19
to layou...@chromium.org, styl...@chromium.org
As part of a task to move kAuto and kFixed (from enum LengthType) out of
the blink namespace where they clash or get shadowed by many other kAuto
and kFixed, I've just added wrapper methods for creating various flavours
of Length.

Yesterday:
return Length(CalculateFoo(x) + 10.0 + SomePaddingMaybe(y, and, stuff),
kFixed);

Now:
return Length::Fixed(CalculateFoo(x) + 10.0 + SomePaddingMaybe(y, and,
stuff));

This is slightly more readable (IMHO), but more importantly it will allow
kFixed to move into some tighter namespace/scope without making the code
more verbose.

The same change was done to kAuto (Length::Auto()), kPercent
(Length::Percent(x)) and all the others.

The old constructor is still available for those cases where you
programmatically need to set a type, though I'm not sure that constructor
is actually needed anymore.

/Daniel

--
/* Opera Software, Linköping, Sweden: CET (UTC+1) */
Reply all
Reply to author
Forward
0 new messages