mirror of
https://github.com/servo/servo.git
synced 2025-08-09 15:35:34 +01:00
Bug 1535084 - Cleanup contain property. r=dholbert
Now that cbindgen supports bitflags, this is trivial. Differential Revision: https://phabricator.services.mozilla.com/D23371
This commit is contained in:
parent
0cb87cca13
commit
8dbf9b1da9
3 changed files with 10 additions and 91 deletions
|
@ -103,6 +103,7 @@ include = [
|
|||
"ZIndex",
|
||||
"TransformOrigin",
|
||||
"WordBreak",
|
||||
"Contain",
|
||||
]
|
||||
item_types = ["enums", "structs", "typedefs"]
|
||||
|
||||
|
|
|
@ -2751,7 +2751,7 @@ fn static_assert() {
|
|||
transform-style
|
||||
rotate scroll-snap-points-x scroll-snap-points-y
|
||||
scroll-snap-coordinate -moz-binding will-change
|
||||
offset-path shape-outside contain touch-action
|
||||
offset-path shape-outside touch-action
|
||||
translate scale""" %>
|
||||
<%self:impl_trait style_struct_name="Box" skip_longhands="${skip_box_longhands}">
|
||||
#[inline]
|
||||
|
@ -3171,91 +3171,6 @@ fn static_assert() {
|
|||
|
||||
<% impl_shape_source("shape_outside", "mShapeOutside") %>
|
||||
|
||||
pub fn set_contain(&mut self, v: longhands::contain::computed_value::T) {
|
||||
use crate::gecko_bindings::structs::NS_STYLE_CONTAIN_NONE;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_CONTAIN_STRICT;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_CONTAIN_CONTENT;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_CONTAIN_SIZE;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_CONTAIN_LAYOUT;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_CONTAIN_PAINT;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_CONTAIN_ALL_BITS;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_CONTAIN_CONTENT_BITS;
|
||||
use crate::properties::longhands::contain::SpecifiedValue;
|
||||
|
||||
if v.is_empty() {
|
||||
self.gecko.mContain = NS_STYLE_CONTAIN_NONE as u8;
|
||||
return;
|
||||
}
|
||||
|
||||
if v.contains(SpecifiedValue::STRICT) {
|
||||
self.gecko.mContain = (NS_STYLE_CONTAIN_STRICT | NS_STYLE_CONTAIN_ALL_BITS) as u8;
|
||||
return;
|
||||
}
|
||||
if v.contains(SpecifiedValue::CONTENT) {
|
||||
self.gecko.mContain = (NS_STYLE_CONTAIN_CONTENT | NS_STYLE_CONTAIN_CONTENT_BITS) as u8;
|
||||
return;
|
||||
}
|
||||
|
||||
let mut bitfield = 0;
|
||||
if v.contains(SpecifiedValue::LAYOUT) {
|
||||
bitfield |= NS_STYLE_CONTAIN_LAYOUT;
|
||||
}
|
||||
if v.contains(SpecifiedValue::PAINT) {
|
||||
bitfield |= NS_STYLE_CONTAIN_PAINT;
|
||||
}
|
||||
if v.contains(SpecifiedValue::SIZE) {
|
||||
bitfield |= NS_STYLE_CONTAIN_SIZE;
|
||||
}
|
||||
|
||||
self.gecko.mContain = bitfield as u8;
|
||||
}
|
||||
|
||||
pub fn clone_contain(&self) -> longhands::contain::computed_value::T {
|
||||
use crate::gecko_bindings::structs::NS_STYLE_CONTAIN_STRICT;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_CONTAIN_CONTENT;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_CONTAIN_SIZE;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_CONTAIN_LAYOUT;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_CONTAIN_PAINT;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_CONTAIN_ALL_BITS;
|
||||
use crate::gecko_bindings::structs::NS_STYLE_CONTAIN_CONTENT_BITS;
|
||||
use crate::properties::longhands::contain::{self, SpecifiedValue};
|
||||
|
||||
let mut servo_flags = contain::computed_value::T::empty();
|
||||
let gecko_flags = self.gecko.mContain;
|
||||
|
||||
if gecko_flags & (NS_STYLE_CONTAIN_STRICT as u8) != 0 {
|
||||
debug_assert_eq!(
|
||||
gecko_flags & (NS_STYLE_CONTAIN_ALL_BITS as u8),
|
||||
NS_STYLE_CONTAIN_ALL_BITS as u8,
|
||||
"When strict is specified, ALL_BITS should be specified as well"
|
||||
);
|
||||
servo_flags.insert(SpecifiedValue::STRICT | SpecifiedValue::STRICT_BITS);
|
||||
return servo_flags;
|
||||
}
|
||||
if gecko_flags & (NS_STYLE_CONTAIN_CONTENT as u8) != 0 {
|
||||
debug_assert_eq!(
|
||||
gecko_flags & (NS_STYLE_CONTAIN_CONTENT_BITS as u8),
|
||||
NS_STYLE_CONTAIN_CONTENT_BITS as u8,
|
||||
"When content is specified, CONTENT_BITS should be specified as well"
|
||||
);
|
||||
servo_flags.insert(SpecifiedValue::CONTENT | SpecifiedValue::CONTENT_BITS);
|
||||
return servo_flags;
|
||||
}
|
||||
if gecko_flags & (NS_STYLE_CONTAIN_LAYOUT as u8) != 0 {
|
||||
servo_flags.insert(SpecifiedValue::LAYOUT);
|
||||
}
|
||||
if gecko_flags & (NS_STYLE_CONTAIN_PAINT as u8) != 0 {
|
||||
servo_flags.insert(SpecifiedValue::PAINT);
|
||||
}
|
||||
if gecko_flags & (NS_STYLE_CONTAIN_SIZE as u8) != 0 {
|
||||
servo_flags.insert(SpecifiedValue::SIZE);
|
||||
}
|
||||
|
||||
return servo_flags;
|
||||
}
|
||||
|
||||
${impl_simple_copy("contain", "mContain")}
|
||||
|
||||
${impl_simple_type_with_conversion("touch_action")}
|
||||
|
||||
pub fn set_offset_path(&mut self, v: longhands::offset_path::computed_value::T) {
|
||||
|
|
|
@ -753,18 +753,21 @@ pub fn assert_touch_action_matches() {
|
|||
bitflags! {
|
||||
#[derive(MallocSizeOf, SpecifiedValueInfo, ToComputedValue)]
|
||||
#[value_info(other_values = "none,strict,content,size,layout,paint")]
|
||||
#[repr(C)]
|
||||
/// Constants for contain: https://drafts.csswg.org/css-contain/#contain-property
|
||||
pub struct Contain: u8 {
|
||||
/// `none` variant, just for convenience.
|
||||
const NONE = 0;
|
||||
/// 'size' variant, turns on size containment
|
||||
const SIZE = 0x01;
|
||||
const SIZE = 1 << 0;
|
||||
/// `layout` variant, turns on layout containment
|
||||
const LAYOUT = 0x02;
|
||||
const LAYOUT = 1 << 1;
|
||||
/// `paint` variant, turns on paint containment
|
||||
const PAINT = 0x04;
|
||||
const PAINT = 1 << 2;
|
||||
/// `strict` variant, turns on all types of containment
|
||||
const STRICT = 0x08;
|
||||
const STRICT = 1 << 3;
|
||||
/// 'content' variant, turns on layout and paint containment
|
||||
const CONTENT = 0x10;
|
||||
const CONTENT = 1 << 4;
|
||||
/// variant with all the bits that contain: strict turns on
|
||||
const STRICT_BITS = Contain::LAYOUT.bits | Contain::PAINT.bits | Contain::SIZE.bits;
|
||||
/// variant with all the bits that contain: content turns on
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue