mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Replace boolean parameters by a new ContentSizesRequest
enum
This commit is contained in:
parent
6763e7e4ae
commit
38e8fd1e99
6 changed files with 92 additions and 62 deletions
|
@ -9,6 +9,37 @@ use style::properties::ComputedValues;
|
|||
use style::values::computed::{Length, LengthPercentage, Percentage};
|
||||
use style::Zero;
|
||||
|
||||
/// Which min/max-content values should be computed during box construction
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub(crate) enum ContentSizesRequest {
|
||||
Inline,
|
||||
None,
|
||||
}
|
||||
|
||||
impl ContentSizesRequest {
|
||||
pub fn inline_if(condition: bool) -> Self {
|
||||
if condition {
|
||||
Self::Inline
|
||||
} else {
|
||||
Self::None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn requests_inline(self) -> bool {
|
||||
match self {
|
||||
Self::Inline => true,
|
||||
Self::None => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn if_requests_inline<T>(self, f: impl FnOnce() -> T) -> Option<T> {
|
||||
match self {
|
||||
Self::Inline => Some(f()),
|
||||
Self::None => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub(crate) struct ContentSizes {
|
||||
pub min_content: Length,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue