mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Upgrade Stylo to 2024-12-04 (#34501)
* Upgrade Stylo to 2024-12-04 Signed-off-by: Oriol Brufau <obrufau@igalia.com> * Fixup for https://phabricator.services.mozilla.com/D229998 Signed-off-by: Oriol Brufau <obrufau@igalia.com> * Update test expectations Signed-off-by: Oriol Brufau <obrufau@igalia.com> --------- Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
3fa1d3d9cf
commit
61ca2dde29
16 changed files with 239 additions and 195 deletions
24
Cargo.lock
generated
24
Cargo.lock
generated
|
@ -1617,7 +1617,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dom"
|
name = "dom"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
source = "git+https://github.com/servo/stylo?branch=2024-11-01#18ca509a7dcfc0f175cddb36b57bc4cd9586f81e"
|
source = "git+https://github.com/servo/stylo?branch=2024-12-04#35e0fa29e93a7e85f44d4ad0610748634f7979b5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.6.0",
|
"bitflags 2.6.0",
|
||||||
"malloc_size_of",
|
"malloc_size_of",
|
||||||
|
@ -4247,7 +4247,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "malloc_size_of"
|
name = "malloc_size_of"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
source = "git+https://github.com/servo/stylo?branch=2024-11-01#18ca509a7dcfc0f175cddb36b57bc4cd9586f81e"
|
source = "git+https://github.com/servo/stylo?branch=2024-12-04#35e0fa29e93a7e85f44d4ad0610748634f7979b5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"app_units",
|
"app_units",
|
||||||
"cssparser",
|
"cssparser",
|
||||||
|
@ -6196,7 +6196,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "selectors"
|
name = "selectors"
|
||||||
version = "0.26.0"
|
version = "0.26.0"
|
||||||
source = "git+https://github.com/servo/stylo?branch=2024-11-01#18ca509a7dcfc0f175cddb36b57bc4cd9586f81e"
|
source = "git+https://github.com/servo/stylo?branch=2024-12-04#35e0fa29e93a7e85f44d4ad0610748634f7979b5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.6.0",
|
"bitflags 2.6.0",
|
||||||
"cssparser",
|
"cssparser",
|
||||||
|
@ -6484,7 +6484,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "servo_arc"
|
name = "servo_arc"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
source = "git+https://github.com/servo/stylo?branch=2024-11-01#18ca509a7dcfc0f175cddb36b57bc4cd9586f81e"
|
source = "git+https://github.com/servo/stylo?branch=2024-12-04#35e0fa29e93a7e85f44d4ad0610748634f7979b5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"stable_deref_trait",
|
"stable_deref_trait",
|
||||||
|
@ -6493,7 +6493,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "servo_atoms"
|
name = "servo_atoms"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
source = "git+https://github.com/servo/stylo?branch=2024-11-01#18ca509a7dcfc0f175cddb36b57bc4cd9586f81e"
|
source = "git+https://github.com/servo/stylo?branch=2024-12-04#35e0fa29e93a7e85f44d4ad0610748634f7979b5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"string_cache",
|
"string_cache",
|
||||||
"string_cache_codegen",
|
"string_cache_codegen",
|
||||||
|
@ -6866,7 +6866,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "static_prefs"
|
name = "static_prefs"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/servo/stylo?branch=2024-11-01#18ca509a7dcfc0f175cddb36b57bc4cd9586f81e"
|
source = "git+https://github.com/servo/stylo?branch=2024-12-04#35e0fa29e93a7e85f44d4ad0610748634f7979b5"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "strck"
|
name = "strck"
|
||||||
|
@ -6925,7 +6925,7 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "style"
|
name = "style"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
source = "git+https://github.com/servo/stylo?branch=2024-11-01#18ca509a7dcfc0f175cddb36b57bc4cd9586f81e"
|
source = "git+https://github.com/servo/stylo?branch=2024-12-04#35e0fa29e93a7e85f44d4ad0610748634f7979b5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"app_units",
|
"app_units",
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
|
@ -6983,7 +6983,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "style_config"
|
name = "style_config"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
source = "git+https://github.com/servo/stylo?branch=2024-11-01#18ca509a7dcfc0f175cddb36b57bc4cd9586f81e"
|
source = "git+https://github.com/servo/stylo?branch=2024-12-04#35e0fa29e93a7e85f44d4ad0610748634f7979b5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
]
|
]
|
||||||
|
@ -6991,7 +6991,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "style_derive"
|
name = "style_derive"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
source = "git+https://github.com/servo/stylo?branch=2024-11-01#18ca509a7dcfc0f175cddb36b57bc4cd9586f81e"
|
source = "git+https://github.com/servo/stylo?branch=2024-12-04#35e0fa29e93a7e85f44d4ad0610748634f7979b5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"darling",
|
"darling",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
|
@ -7021,7 +7021,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "style_traits"
|
name = "style_traits"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
source = "git+https://github.com/servo/stylo?branch=2024-11-01#18ca509a7dcfc0f175cddb36b57bc4cd9586f81e"
|
source = "git+https://github.com/servo/stylo?branch=2024-12-04#35e0fa29e93a7e85f44d4ad0610748634f7979b5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"app_units",
|
"app_units",
|
||||||
"bitflags 2.6.0",
|
"bitflags 2.6.0",
|
||||||
|
@ -7384,7 +7384,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "to_shmem"
|
name = "to_shmem"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/servo/stylo?branch=2024-11-01#18ca509a7dcfc0f175cddb36b57bc4cd9586f81e"
|
source = "git+https://github.com/servo/stylo?branch=2024-12-04#35e0fa29e93a7e85f44d4ad0610748634f7979b5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cssparser",
|
"cssparser",
|
||||||
"servo_arc",
|
"servo_arc",
|
||||||
|
@ -7397,7 +7397,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "to_shmem_derive"
|
name = "to_shmem_derive"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/servo/stylo?branch=2024-11-01#18ca509a7dcfc0f175cddb36b57bc4cd9586f81e"
|
source = "git+https://github.com/servo/stylo?branch=2024-12-04#35e0fa29e93a7e85f44d4ad0610748634f7979b5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"darling",
|
"darling",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
|
|
18
Cargo.toml
18
Cargo.toml
|
@ -107,25 +107,25 @@ rustls = { version = "0.21.12", features = ["dangerous_configuration"] }
|
||||||
rustls-pemfile = "1.0.4"
|
rustls-pemfile = "1.0.4"
|
||||||
script_layout_interface = { path = "components/shared/script_layout" }
|
script_layout_interface = { path = "components/shared/script_layout" }
|
||||||
script_traits = { path = "components/shared/script" }
|
script_traits = { path = "components/shared/script" }
|
||||||
selectors = { git = "https://github.com/servo/stylo", branch = "2024-11-01" }
|
selectors = { git = "https://github.com/servo/stylo", branch = "2024-12-04" }
|
||||||
serde = "1.0.215"
|
serde = "1.0.215"
|
||||||
serde_bytes = "0.11"
|
serde_bytes = "0.11"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
servo-media = { git = "https://github.com/servo/media" }
|
servo-media = { git = "https://github.com/servo/media" }
|
||||||
servo-media-dummy = { git = "https://github.com/servo/media" }
|
servo-media-dummy = { git = "https://github.com/servo/media" }
|
||||||
servo-media-gstreamer = { git = "https://github.com/servo/media" }
|
servo-media-gstreamer = { git = "https://github.com/servo/media" }
|
||||||
servo_arc = { git = "https://github.com/servo/stylo", branch = "2024-11-01", features = ["servo"] }
|
servo_arc = { git = "https://github.com/servo/stylo", branch = "2024-12-04", features = ["servo"] }
|
||||||
servo_atoms = { git = "https://github.com/servo/stylo", branch = "2024-11-01" }
|
servo_atoms = { git = "https://github.com/servo/stylo", branch = "2024-12-04" }
|
||||||
smallbitvec = "2.5.3"
|
smallbitvec = "2.5.3"
|
||||||
smallvec = "1.13"
|
smallvec = "1.13"
|
||||||
static_assertions = "1.1"
|
static_assertions = "1.1"
|
||||||
string_cache = "0.8"
|
string_cache = "0.8"
|
||||||
string_cache_codegen = "0.5"
|
string_cache_codegen = "0.5"
|
||||||
style = { git = "https://github.com/servo/stylo", branch = "2024-11-01", features = ["servo"] }
|
style = { git = "https://github.com/servo/stylo", branch = "2024-12-04", features = ["servo"] }
|
||||||
style_config = { git = "https://github.com/servo/stylo", branch = "2024-11-01" }
|
style_config = { git = "https://github.com/servo/stylo", branch = "2024-12-04" }
|
||||||
style_dom = { git = "https://github.com/servo/stylo", package = "dom", branch = "2024-11-01" }
|
style_dom = { git = "https://github.com/servo/stylo", package = "dom", branch = "2024-12-04" }
|
||||||
style_traits = { git = "https://github.com/servo/stylo", branch = "2024-11-01", features = ["servo"] }
|
style_traits = { git = "https://github.com/servo/stylo", branch = "2024-12-04", features = ["servo"] }
|
||||||
style_malloc_size_of = { package = "malloc_size_of", git = "https://github.com/servo/stylo", branch = "2024-11-01", features = ["servo"] }
|
style_malloc_size_of = { package = "malloc_size_of", git = "https://github.com/servo/stylo", branch = "2024-12-04", features = ["servo"] }
|
||||||
surfman = { git = "https://github.com/servo/surfman", rev = "c8d6b4b65aeab739ee7651602e29c8d58ceee123", features = ["chains"] }
|
surfman = { git = "https://github.com/servo/surfman", rev = "c8d6b4b65aeab739ee7651602e29c8d58ceee123", features = ["chains"] }
|
||||||
syn = { version = "2", default-features = false, features = ["clone-impls", "derive", "parsing"] }
|
syn = { version = "2", default-features = false, features = ["clone-impls", "derive", "parsing"] }
|
||||||
synstructure = "0.13"
|
synstructure = "0.13"
|
||||||
|
@ -134,7 +134,7 @@ thin-vec = "0.2.13"
|
||||||
tikv-jemalloc-sys = "0.6.0"
|
tikv-jemalloc-sys = "0.6.0"
|
||||||
tikv-jemallocator = "0.6.0"
|
tikv-jemallocator = "0.6.0"
|
||||||
time_03 = { package = "time", version = "0.3", features = ["large-dates", "local-offset", "serde"] }
|
time_03 = { package = "time", version = "0.3", features = ["large-dates", "local-offset", "serde"] }
|
||||||
to_shmem = { git = "https://github.com/servo/stylo", branch = "2024-11-01" }
|
to_shmem = { git = "https://github.com/servo/stylo", branch = "2024-12-04" }
|
||||||
tokio = "1"
|
tokio = "1"
|
||||||
tokio-rustls = "0.24"
|
tokio-rustls = "0.24"
|
||||||
tracing = "0.1.41"
|
tracing = "0.1.41"
|
||||||
|
|
|
@ -1927,23 +1927,23 @@ impl BlockFlow {
|
||||||
.flags
|
.flags
|
||||||
.contains(FlowFlags::CONTAINS_TEXT_OR_REPLACED_FRAGMENTS),
|
.contains(FlowFlags::CONTAINS_TEXT_OR_REPLACED_FRAGMENTS),
|
||||||
) {
|
) {
|
||||||
(Float::None, true) => {
|
(None, true) => {
|
||||||
computation.content_intrinsic_sizes.preferred_inline_size = max(
|
computation.content_intrinsic_sizes.preferred_inline_size = max(
|
||||||
computation.content_intrinsic_sizes.preferred_inline_size,
|
computation.content_intrinsic_sizes.preferred_inline_size,
|
||||||
child_base.intrinsic_inline_sizes.preferred_inline_size,
|
child_base.intrinsic_inline_sizes.preferred_inline_size,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
(Float::None, false) => {
|
(None, false) => {
|
||||||
preferred_inline_size_of_children_without_text_or_replaced_fragments = max(
|
preferred_inline_size_of_children_without_text_or_replaced_fragments = max(
|
||||||
preferred_inline_size_of_children_without_text_or_replaced_fragments,
|
preferred_inline_size_of_children_without_text_or_replaced_fragments,
|
||||||
child_base.intrinsic_inline_sizes.preferred_inline_size,
|
child_base.intrinsic_inline_sizes.preferred_inline_size,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
(Float::Left, _) => {
|
(Some(FloatKind::Left), _) => {
|
||||||
left_float_width_accumulator +=
|
left_float_width_accumulator +=
|
||||||
child_base.intrinsic_inline_sizes.preferred_inline_size;
|
child_base.intrinsic_inline_sizes.preferred_inline_size;
|
||||||
},
|
},
|
||||||
(Float::Right, _) => {
|
(Some(FloatKind::Right), _) => {
|
||||||
right_float_width_accumulator +=
|
right_float_width_accumulator +=
|
||||||
child_base.intrinsic_inline_sizes.preferred_inline_size;
|
child_base.intrinsic_inline_sizes.preferred_inline_size;
|
||||||
},
|
},
|
||||||
|
|
|
@ -1372,6 +1372,9 @@ where
|
||||||
&table_style,
|
&table_style,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
// FIXME: this should use the writing mode of the containing block.
|
||||||
|
let wrapper_float_kind =
|
||||||
|
FloatKind::from_property_and_writing_mode(float_value, wrapper_style.writing_mode);
|
||||||
let wrapper_fragment = Fragment::from_opaque_node_and_style(
|
let wrapper_fragment = Fragment::from_opaque_node_and_style(
|
||||||
node.opaque(),
|
node.opaque(),
|
||||||
PseudoElementType::Normal,
|
PseudoElementType::Normal,
|
||||||
|
@ -1380,7 +1383,6 @@ where
|
||||||
node.restyle_damage(),
|
node.restyle_damage(),
|
||||||
SpecificFragmentInfo::TableWrapper,
|
SpecificFragmentInfo::TableWrapper,
|
||||||
);
|
);
|
||||||
let wrapper_float_kind = FloatKind::from_property(float_value);
|
|
||||||
let mut wrapper_flow = FlowRef::new(Arc::new(
|
let mut wrapper_flow = FlowRef::new(Arc::new(
|
||||||
TableWrapperFlow::from_fragment_and_float_kind(wrapper_fragment, wrapper_float_kind),
|
TableWrapperFlow::from_fragment_and_float_kind(wrapper_fragment, wrapper_float_kind),
|
||||||
));
|
));
|
||||||
|
@ -1509,8 +1511,10 @@ where
|
||||||
node: &ConcreteThreadSafeLayoutNode,
|
node: &ConcreteThreadSafeLayoutNode,
|
||||||
flotation: Float,
|
flotation: Float,
|
||||||
) -> ConstructionResult {
|
) -> ConstructionResult {
|
||||||
let flotation = FloatKind::from_property(flotation);
|
// FIXME: this should use the writing mode of the containing block.
|
||||||
let marker_fragments = match node.style(self.style_context()).get_list().list_style_image {
|
let style = node.style(self.style_context());
|
||||||
|
let flotation = FloatKind::from_property_and_writing_mode(flotation, style.writing_mode);
|
||||||
|
let marker_fragments = match style.get_list().list_style_image {
|
||||||
Image::Url(ref url_value) => {
|
Image::Url(ref url_value) => {
|
||||||
let image_info = Box::new(ImageFragmentInfo::new(
|
let image_info = Box::new(ImageFragmentInfo::new(
|
||||||
url_value.url().cloned().map(Into::into),
|
url_value.url().cloned().map(Into::into),
|
||||||
|
@ -1529,9 +1533,8 @@ where
|
||||||
Image::Gradient(..) |
|
Image::Gradient(..) |
|
||||||
Image::PaintWorklet(..) |
|
Image::PaintWorklet(..) |
|
||||||
Image::CrossFade(..) |
|
Image::CrossFade(..) |
|
||||||
Image::None => match ListStyleTypeContent::from_list_style_type(
|
Image::None => {
|
||||||
node.style(self.style_context()).get_list().list_style_type,
|
match ListStyleTypeContent::from_list_style_type(style.get_list().list_style_type) {
|
||||||
) {
|
|
||||||
ListStyleTypeContent::None => Vec::new(),
|
ListStyleTypeContent::None => Vec::new(),
|
||||||
ListStyleTypeContent::StaticText(ch) => {
|
ListStyleTypeContent::StaticText(ch) => {
|
||||||
let text = format!("{}\u{a0}", ch);
|
let text = format!("{}\u{a0}", ch);
|
||||||
|
@ -1554,6 +1557,7 @@ where
|
||||||
SpecificFragmentInfo::GeneratedContent(info),
|
SpecificFragmentInfo::GeneratedContent(info),
|
||||||
self.layout_context,
|
self.layout_context,
|
||||||
)],
|
)],
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1564,11 +1568,7 @@ where
|
||||||
// there.
|
// there.
|
||||||
let mut initial_fragments = IntermediateInlineFragments::new();
|
let mut initial_fragments = IntermediateInlineFragments::new();
|
||||||
let main_fragment = self.build_fragment_for_block(node);
|
let main_fragment = self.build_fragment_for_block(node);
|
||||||
let flow = match node
|
let flow = match style.get_list().list_style_position {
|
||||||
.style(self.style_context())
|
|
||||||
.get_list()
|
|
||||||
.list_style_position
|
|
||||||
{
|
|
||||||
ListStylePosition::Outside => Arc::new(ListItemFlow::from_fragments_and_flotation(
|
ListStylePosition::Outside => Arc::new(ListItemFlow::from_fragments_and_flotation(
|
||||||
main_fragment,
|
main_fragment,
|
||||||
marker_fragments,
|
marker_fragments,
|
||||||
|
@ -1956,7 +1956,9 @@ where
|
||||||
|
|
||||||
// Flex items contribute flex flow construction results.
|
// Flex items contribute flex flow construction results.
|
||||||
(Display::Flex, float_value, _) => {
|
(Display::Flex, float_value, _) => {
|
||||||
let float_kind = FloatKind::from_property(float_value);
|
// FIXME: this should use the writing mode of the containing block.
|
||||||
|
let float_kind =
|
||||||
|
FloatKind::from_property_and_writing_mode(float_value, style.writing_mode);
|
||||||
let construction_result = self.build_flow_for_flex(node, float_kind);
|
let construction_result = self.build_flow_for_flex(node, float_kind);
|
||||||
self.set_flow_construction_result(node, construction_result)
|
self.set_flow_construction_result(node, construction_result)
|
||||||
},
|
},
|
||||||
|
@ -1972,7 +1974,9 @@ where
|
||||||
// TODO(pcwalton): Make this only trigger for blocks and handle the other `display`
|
// TODO(pcwalton): Make this only trigger for blocks and handle the other `display`
|
||||||
// properties separately.
|
// properties separately.
|
||||||
(_, float_value, _) => {
|
(_, float_value, _) => {
|
||||||
let float_kind = FloatKind::from_property(float_value);
|
// FIXME: this should use the writing mode of the containing block.
|
||||||
|
let float_kind =
|
||||||
|
FloatKind::from_property_and_writing_mode(float_value, style.writing_mode);
|
||||||
// List items contribute their own special flows.
|
// List items contribute their own special flows.
|
||||||
let construction_result = if display.is_list_item() {
|
let construction_result = if display.is_list_item() {
|
||||||
self.build_flow_for_list_item(node, float_value)
|
self.build_flow_for_list_item(node, float_value)
|
||||||
|
|
|
@ -8,8 +8,10 @@ use std::fmt;
|
||||||
use app_units::{Au, MAX_AU};
|
use app_units::{Au, MAX_AU};
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
use style::computed_values::clear::T as StyleClear;
|
||||||
use style::computed_values::float::T as StyleFloat;
|
use style::computed_values::float::T as StyleFloat;
|
||||||
use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
|
use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
|
||||||
|
use style::properties::ComputedValues;
|
||||||
|
|
||||||
use crate::block::FormattingContextType;
|
use crate::block::FormattingContextType;
|
||||||
use crate::flow::{Flow, FlowFlags, GetBaseFlow, ImmutableFlowUtils};
|
use crate::flow::{Flow, FlowFlags, GetBaseFlow, ImmutableFlowUtils};
|
||||||
|
@ -23,12 +25,19 @@ pub enum FloatKind {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FloatKind {
|
impl FloatKind {
|
||||||
pub fn from_property(property: StyleFloat) -> Option<FloatKind> {
|
pub fn from_property_and_writing_mode(
|
||||||
match property {
|
property: StyleFloat,
|
||||||
StyleFloat::None => None,
|
writing_mode: WritingMode,
|
||||||
StyleFloat::Left => Some(FloatKind::Left),
|
) -> Option<FloatKind> {
|
||||||
StyleFloat::Right => Some(FloatKind::Right),
|
Some(match property {
|
||||||
}
|
StyleFloat::None => return None,
|
||||||
|
StyleFloat::Left => Self::Left,
|
||||||
|
StyleFloat::Right => Self::Right,
|
||||||
|
StyleFloat::InlineStart if writing_mode.is_bidi_ltr() => Self::Left,
|
||||||
|
StyleFloat::InlineStart => Self::Right,
|
||||||
|
StyleFloat::InlineEnd if writing_mode.is_bidi_ltr() => Self::Right,
|
||||||
|
StyleFloat::InlineEnd => Self::Left,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +49,22 @@ pub enum ClearType {
|
||||||
Both,
|
Both,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ClearType {
|
||||||
|
pub fn from_style(style: &ComputedValues) -> Option<Self> {
|
||||||
|
Some(match style.get_box().clear {
|
||||||
|
StyleClear::None => return None,
|
||||||
|
StyleClear::Left => Self::Left,
|
||||||
|
StyleClear::Right => Self::Right,
|
||||||
|
StyleClear::Both => Self::Both,
|
||||||
|
// FIXME: these should check the writing mode of the containing block.
|
||||||
|
StyleClear::InlineStart if style.writing_mode.is_bidi_ltr() => Self::Left,
|
||||||
|
StyleClear::InlineStart => Self::Right,
|
||||||
|
StyleClear::InlineEnd if style.writing_mode.is_bidi_ltr() => Self::Right,
|
||||||
|
StyleClear::InlineEnd => Self::Left,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Information about a single float.
|
/// Information about a single float.
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
struct Float {
|
struct Float {
|
||||||
|
@ -558,9 +583,9 @@ impl SpeculatedFloatPlacement {
|
||||||
}
|
}
|
||||||
|
|
||||||
match base_flow.flags.float_kind() {
|
match base_flow.flags.float_kind() {
|
||||||
StyleFloat::None => {},
|
None => {},
|
||||||
StyleFloat::Left => self.left += float_inline_size,
|
Some(FloatKind::Left) => self.left += float_inline_size,
|
||||||
StyleFloat::Right => self.right += float_inline_size,
|
Some(FloatKind::Right) => self.right += float_inline_size,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,8 +38,6 @@ use log::debug;
|
||||||
use serde::ser::{SerializeStruct, Serializer};
|
use serde::ser::{SerializeStruct, Serializer};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use servo_geometry::{au_rect_to_f32_rect, f32_rect_to_au_rect, MaxRect};
|
use servo_geometry::{au_rect_to_f32_rect, f32_rect_to_au_rect, MaxRect};
|
||||||
use style::computed_values::clear::T as Clear;
|
|
||||||
use style::computed_values::float::T as Float;
|
|
||||||
use style::computed_values::overflow_x::T as StyleOverflow;
|
use style::computed_values::overflow_x::T as StyleOverflow;
|
||||||
use style::computed_values::position::T as Position;
|
use style::computed_values::position::T as Position;
|
||||||
use style::computed_values::text_align::T as TextAlign;
|
use style::computed_values::text_align::T as TextAlign;
|
||||||
|
@ -57,7 +55,7 @@ use crate::display_list::{
|
||||||
DisplayListBuildState, StackingContextCollectionState, StackingContextId,
|
DisplayListBuildState, StackingContextCollectionState, StackingContextId,
|
||||||
};
|
};
|
||||||
use crate::flex::FlexFlow;
|
use crate::flex::FlexFlow;
|
||||||
use crate::floats::{Floats, SpeculatedFloatPlacement};
|
use crate::floats::{ClearType, FloatKind, Floats, SpeculatedFloatPlacement};
|
||||||
use crate::flow_list::{FlowList, FlowListIterator, MutFlowListIterator};
|
use crate::flow_list::{FlowList, FlowListIterator, MutFlowListIterator};
|
||||||
use crate::flow_ref::{FlowRef, WeakFlowRef};
|
use crate::flow_ref::{FlowRef, WeakFlowRef};
|
||||||
use crate::fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, Overflow};
|
use crate::fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, Overflow};
|
||||||
|
@ -672,13 +670,13 @@ bitflags! {
|
||||||
|
|
||||||
impl FlowFlags {
|
impl FlowFlags {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn float_kind(&self) -> Float {
|
pub fn float_kind(&self) -> Option<FloatKind> {
|
||||||
if self.contains(FlowFlags::FLOATS_LEFT) {
|
if self.contains(FlowFlags::FLOATS_LEFT) {
|
||||||
Float::Left
|
Some(FloatKind::Left)
|
||||||
} else if self.contains(FlowFlags::FLOATS_RIGHT) {
|
} else if self.contains(FlowFlags::FLOATS_RIGHT) {
|
||||||
Float::Right
|
Some(FloatKind::Right)
|
||||||
} else {
|
} else {
|
||||||
Float::None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1070,18 +1068,22 @@ impl BaseFlow {
|
||||||
}
|
}
|
||||||
|
|
||||||
if force_nonfloated == ForceNonfloatedFlag::FloatIfNecessary {
|
if force_nonfloated == ForceNonfloatedFlag::FloatIfNecessary {
|
||||||
match style.get_box().float {
|
// FIXME: this should use the writing mode of the containing block.
|
||||||
Float::None => {},
|
match FloatKind::from_property_and_writing_mode(
|
||||||
Float::Left => flags.insert(FlowFlags::FLOATS_LEFT),
|
style.get_box().float,
|
||||||
Float::Right => flags.insert(FlowFlags::FLOATS_RIGHT),
|
style.writing_mode,
|
||||||
|
) {
|
||||||
|
None => {},
|
||||||
|
Some(FloatKind::Left) => flags.insert(FlowFlags::FLOATS_LEFT),
|
||||||
|
Some(FloatKind::Right) => flags.insert(FlowFlags::FLOATS_RIGHT),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
match style.get_box().clear {
|
match ClearType::from_style(style) {
|
||||||
Clear::None => {},
|
None => {},
|
||||||
Clear::Left => flags.insert(FlowFlags::CLEARS_LEFT),
|
Some(ClearType::Left) => flags.insert(FlowFlags::CLEARS_LEFT),
|
||||||
Clear::Right => flags.insert(FlowFlags::CLEARS_RIGHT),
|
Some(ClearType::Right) => flags.insert(FlowFlags::CLEARS_RIGHT),
|
||||||
Clear::Both => {
|
Some(ClearType::Both) => {
|
||||||
flags.insert(FlowFlags::CLEARS_LEFT);
|
flags.insert(FlowFlags::CLEARS_LEFT);
|
||||||
flags.insert(FlowFlags::CLEARS_RIGHT);
|
flags.insert(FlowFlags::CLEARS_RIGHT);
|
||||||
},
|
},
|
||||||
|
|
|
@ -33,7 +33,6 @@ use serde::ser::{Serialize, SerializeStruct, Serializer};
|
||||||
use servo_url::ServoUrl;
|
use servo_url::ServoUrl;
|
||||||
use style::computed_values::border_collapse::T as BorderCollapse;
|
use style::computed_values::border_collapse::T as BorderCollapse;
|
||||||
use style::computed_values::box_sizing::T as BoxSizing;
|
use style::computed_values::box_sizing::T as BoxSizing;
|
||||||
use style::computed_values::clear::T as Clear;
|
|
||||||
use style::computed_values::color::T as Color;
|
use style::computed_values::color::T as Color;
|
||||||
use style::computed_values::display::T as Display;
|
use style::computed_values::display::T as Display;
|
||||||
use style::computed_values::mix_blend_mode::T as MixBlendMode;
|
use style::computed_values::mix_blend_mode::T as MixBlendMode;
|
||||||
|
@ -1507,13 +1506,7 @@ impl Fragment {
|
||||||
/// FIXME(pcwalton): Just replace with the clear type from the style module for speed?
|
/// FIXME(pcwalton): Just replace with the clear type from the style module for speed?
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn clear(&self) -> Option<ClearType> {
|
pub fn clear(&self) -> Option<ClearType> {
|
||||||
let style = self.style();
|
ClearType::from_style(self.style())
|
||||||
match style.get_box().clear {
|
|
||||||
Clear::None => None,
|
|
||||||
Clear::Left => Some(ClearType::Left),
|
|
||||||
Clear::Right => Some(ClearType::Right),
|
|
||||||
Clear::Both => Some(ClearType::Both),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use bitflags::bitflags;
|
use bitflags::bitflags;
|
||||||
use style::computed_values::float::T as Float;
|
|
||||||
use style::selector_parser::RestyleDamage;
|
use style::selector_parser::RestyleDamage;
|
||||||
use style::servo::restyle_damage::ServoRestyleDamage;
|
use style::servo::restyle_damage::ServoRestyleDamage;
|
||||||
|
|
||||||
|
@ -67,7 +66,7 @@ impl dyn Flow {
|
||||||
}
|
}
|
||||||
|
|
||||||
let self_base = self.mut_base();
|
let self_base = self.mut_base();
|
||||||
if self_base.flags.float_kind() != Float::None &&
|
if self_base.flags.float_kind().is_some() &&
|
||||||
self_base
|
self_base
|
||||||
.restyle_damage
|
.restyle_damage
|
||||||
.intersects(ServoRestyleDamage::REFLOW)
|
.intersects(ServoRestyleDamage::REFLOW)
|
||||||
|
|
|
@ -19,7 +19,7 @@ use style::computed_values::float::T as FloatProperty;
|
||||||
use style::computed_values::position::T as Position;
|
use style::computed_values::position::T as Position;
|
||||||
use style::logical_geometry::WritingMode;
|
use style::logical_geometry::WritingMode;
|
||||||
use style::properties::ComputedValues;
|
use style::properties::ComputedValues;
|
||||||
use style::values::computed::Clear;
|
use style::values::computed::Clear as StyleClear;
|
||||||
use style::values::specified::text::TextDecorationLine;
|
use style::values::specified::text::TextDecorationLine;
|
||||||
|
|
||||||
use crate::context::LayoutContext;
|
use crate::context::LayoutContext;
|
||||||
|
@ -243,8 +243,8 @@ impl<'a> PlacementAmongFloats<'a> {
|
||||||
inline: self.min_inline_start,
|
inline: self.min_inline_start,
|
||||||
block: self
|
block: self
|
||||||
.ceiling
|
.ceiling
|
||||||
.max(self.float_context.clear_left_position)
|
.max(self.float_context.clear_inline_start_position)
|
||||||
.max(self.float_context.clear_right_position),
|
.max(self.float_context.clear_inline_end_position),
|
||||||
},
|
},
|
||||||
size: LogicalVec2 {
|
size: LogicalVec2 {
|
||||||
inline: self.max_inline_end - self.min_inline_start,
|
inline: self.max_inline_end - self.min_inline_start,
|
||||||
|
@ -339,10 +339,10 @@ pub struct FloatContext {
|
||||||
/// independent block formatting context that contains all of the floats
|
/// independent block formatting context that contains all of the floats
|
||||||
/// this `FloatContext` positions.
|
/// this `FloatContext` positions.
|
||||||
pub containing_block_info: ContainingBlockPositionInfo,
|
pub containing_block_info: ContainingBlockPositionInfo,
|
||||||
/// The (logically) lowest margin edge of the last left float.
|
/// The (logically) lowest margin edge of the last inline-start float.
|
||||||
pub clear_left_position: Au,
|
pub clear_inline_start_position: Au,
|
||||||
/// The (logically) lowest margin edge of the last right float.
|
/// The (logically) lowest margin edge of the last inline-end float.
|
||||||
pub clear_right_position: Au,
|
pub clear_inline_end_position: Au,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FloatContext {
|
impl FloatContext {
|
||||||
|
@ -368,8 +368,8 @@ impl FloatContext {
|
||||||
Au::zero(),
|
Au::zero(),
|
||||||
max_inline_size,
|
max_inline_size,
|
||||||
),
|
),
|
||||||
clear_left_position: Au::zero(),
|
clear_inline_start_position: Au::zero(),
|
||||||
clear_right_position: Au::zero(),
|
clear_inline_end_position: Au::zero(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,11 +394,11 @@ impl FloatContext {
|
||||||
pub(crate) fn place_object(&self, object: &PlacementInfo, ceiling: Au) -> LogicalVec2<Au> {
|
pub(crate) fn place_object(&self, object: &PlacementInfo, ceiling: Au) -> LogicalVec2<Au> {
|
||||||
let ceiling = match object.clear {
|
let ceiling = match object.clear {
|
||||||
Clear::None => ceiling,
|
Clear::None => ceiling,
|
||||||
Clear::Left => ceiling.max(self.clear_left_position),
|
Clear::InlineStart => ceiling.max(self.clear_inline_start_position),
|
||||||
Clear::Right => ceiling.max(self.clear_right_position),
|
Clear::InlineEnd => ceiling.max(self.clear_inline_end_position),
|
||||||
Clear::Both => ceiling
|
Clear::Both => ceiling
|
||||||
.max(self.clear_left_position)
|
.max(self.clear_inline_start_position)
|
||||||
.max(self.clear_right_position),
|
.max(self.clear_inline_end_position),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Find the first band this float fits in.
|
// Find the first band this float fits in.
|
||||||
|
@ -461,11 +461,11 @@ impl FloatContext {
|
||||||
// Update clear.
|
// Update clear.
|
||||||
match new_float.side {
|
match new_float.side {
|
||||||
FloatSide::InlineStart => {
|
FloatSide::InlineStart => {
|
||||||
self.clear_left_position
|
self.clear_inline_start_position
|
||||||
.max_assign(new_float_rect.max_block_position());
|
.max_assign(new_float_rect.max_block_position());
|
||||||
},
|
},
|
||||||
FloatSide::InlineEnd => {
|
FloatSide::InlineEnd => {
|
||||||
self.clear_right_position
|
self.clear_inline_end_position
|
||||||
.max_assign(new_float_rect.max_block_position());
|
.max_assign(new_float_rect.max_block_position());
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -498,6 +498,32 @@ impl FloatContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
|
pub enum Clear {
|
||||||
|
None,
|
||||||
|
InlineStart,
|
||||||
|
InlineEnd,
|
||||||
|
Both,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Clear {
|
||||||
|
pub(crate) fn from_style_and_container_writing_mode(
|
||||||
|
style: &ComputedValues,
|
||||||
|
container_writing_mode: WritingMode,
|
||||||
|
) -> Self {
|
||||||
|
match style.get_box().clear {
|
||||||
|
StyleClear::None => Self::None,
|
||||||
|
StyleClear::Both => Self::Both,
|
||||||
|
StyleClear::InlineStart => Self::InlineStart,
|
||||||
|
StyleClear::InlineEnd => Self::InlineEnd,
|
||||||
|
StyleClear::Left if container_writing_mode.is_bidi_ltr() => Self::InlineStart,
|
||||||
|
StyleClear::Left => Self::InlineEnd,
|
||||||
|
StyleClear::Right if container_writing_mode.is_bidi_ltr() => Self::InlineEnd,
|
||||||
|
StyleClear::Right => Self::InlineStart,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Information needed to place an object so that it doesn't collide with existing floats.
|
/// Information needed to place an object so that it doesn't collide with existing floats.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct PlacementInfo {
|
pub struct PlacementInfo {
|
||||||
|
@ -537,19 +563,19 @@ pub struct FloatBand {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FloatSide {
|
impl FloatSide {
|
||||||
fn from_style_and_container_writing_mode(
|
pub(crate) fn from_style_and_container_writing_mode(
|
||||||
style: &ComputedValues,
|
style: &ComputedValues,
|
||||||
container_writing_mode: WritingMode,
|
container_writing_mode: WritingMode,
|
||||||
) -> Option<FloatSide> {
|
) -> Option<FloatSide> {
|
||||||
match (style.get_box().float, container_writing_mode.is_bidi_ltr()) {
|
Some(match style.get_box().float {
|
||||||
(FloatProperty::None, _) => None,
|
FloatProperty::None => return None,
|
||||||
(FloatProperty::Left, true) | (FloatProperty::Right, false) => {
|
FloatProperty::InlineStart => Self::InlineStart,
|
||||||
Some(FloatSide::InlineStart)
|
FloatProperty::InlineEnd => Self::InlineEnd,
|
||||||
},
|
FloatProperty::Left if container_writing_mode.is_bidi_ltr() => Self::InlineStart,
|
||||||
(FloatProperty::Right, true) | (FloatProperty::Left, false) => {
|
FloatProperty::Left => Self::InlineEnd,
|
||||||
Some(FloatSide::InlineEnd)
|
FloatProperty::Right if container_writing_mode.is_bidi_ltr() => Self::InlineEnd,
|
||||||
},
|
FloatProperty::Right => Self::InlineStart,
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1021,12 +1047,12 @@ impl SequentialLayoutState {
|
||||||
// in that case we don't need to add clearance.
|
// in that case we don't need to add clearance.
|
||||||
let clear_position = match clear {
|
let clear_position = match clear {
|
||||||
Clear::None => unreachable!(),
|
Clear::None => unreachable!(),
|
||||||
Clear::Left => self.floats.clear_left_position,
|
Clear::InlineStart => self.floats.clear_inline_start_position,
|
||||||
Clear::Right => self.floats.clear_right_position,
|
Clear::InlineEnd => self.floats.clear_inline_end_position,
|
||||||
Clear::Both => self
|
Clear::Both => self
|
||||||
.floats
|
.floats
|
||||||
.clear_left_position
|
.clear_inline_start_position
|
||||||
.max(self.floats.clear_right_position),
|
.max(self.floats.clear_inline_end_position),
|
||||||
};
|
};
|
||||||
if hypothetical_block_position >= clear_position {
|
if hypothetical_block_position >= clear_position {
|
||||||
None
|
None
|
||||||
|
@ -1133,7 +1159,10 @@ impl SequentialLayoutState {
|
||||||
container_writing_mode,
|
container_writing_mode,
|
||||||
)
|
)
|
||||||
.expect("Float box wasn't floated!"),
|
.expect("Float box wasn't floated!"),
|
||||||
clear: box_fragment.style.get_box().clear,
|
clear: Clear::from_style_and_container_writing_mode(
|
||||||
|
&box_fragment.style,
|
||||||
|
container_writing_mode,
|
||||||
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Re-calculate relative adjustment so that it is not lost when the BoxFragment's
|
// Re-calculate relative adjustment so that it is not lost when the BoxFragment's
|
||||||
|
|
|
@ -96,7 +96,6 @@ use style::computed_values::white_space_collapse::T as WhiteSpaceCollapse;
|
||||||
use style::context::QuirksMode;
|
use style::context::QuirksMode;
|
||||||
use style::properties::style_structs::InheritedText;
|
use style::properties::style_structs::InheritedText;
|
||||||
use style::properties::ComputedValues;
|
use style::properties::ComputedValues;
|
||||||
use style::values::computed::Clear;
|
|
||||||
use style::values::generics::box_::VerticalAlignKeyword;
|
use style::values::generics::box_::VerticalAlignKeyword;
|
||||||
use style::values::generics::font::LineHeight;
|
use style::values::generics::font::LineHeight;
|
||||||
use style::values::specified::box_::BaselineSource;
|
use style::values::specified::box_::BaselineSource;
|
||||||
|
@ -111,7 +110,7 @@ use unicode_bidi::{BidiInfo, Level};
|
||||||
use webrender_api::FontInstanceKey;
|
use webrender_api::FontInstanceKey;
|
||||||
use xi_unicode::linebreak_property;
|
use xi_unicode::linebreak_property;
|
||||||
|
|
||||||
use super::float::PlacementAmongFloats;
|
use super::float::{Clear, PlacementAmongFloats};
|
||||||
use crate::cell::ArcRefCell;
|
use crate::cell::ArcRefCell;
|
||||||
use crate::context::LayoutContext;
|
use crate::context::LayoutContext;
|
||||||
use crate::flow::float::{FloatBox, SequentialLayoutState};
|
use crate::flow::float::{FloatBox, SequentialLayoutState};
|
||||||
|
@ -721,7 +720,10 @@ impl<'layout_dta> InlineFormattingContextLayout<'layout_dta> {
|
||||||
.contains(FragmentFlags::IS_BR_ELEMENT) &&
|
.contains(FragmentFlags::IS_BR_ELEMENT) &&
|
||||||
self.deferred_br_clear == Clear::None
|
self.deferred_br_clear == Clear::None
|
||||||
{
|
{
|
||||||
self.deferred_br_clear = inline_box_state.base.style.clone_clear();
|
self.deferred_br_clear = Clear::from_style_and_container_writing_mode(
|
||||||
|
&inline_box_state.base.style,
|
||||||
|
self.containing_block.style.writing_mode,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if inline_box.is_first_fragment {
|
if inline_box.is_first_fragment {
|
||||||
|
|
|
@ -12,8 +12,7 @@ use inline::InlineFormattingContext;
|
||||||
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
|
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use servo_arc::Arc;
|
use servo_arc::Arc;
|
||||||
use style::computed_values::clear::T as Clear;
|
use style::computed_values::clear::T as StyleClear;
|
||||||
use style::computed_values::float::T as Float;
|
|
||||||
use style::properties::ComputedValues;
|
use style::properties::ComputedValues;
|
||||||
use style::servo::selector_parser::PseudoElement;
|
use style::servo::selector_parser::PseudoElement;
|
||||||
use style::values::computed::Size as StyleSize;
|
use style::values::computed::Size as StyleSize;
|
||||||
|
@ -24,7 +23,8 @@ use style::Zero;
|
||||||
use crate::cell::ArcRefCell;
|
use crate::cell::ArcRefCell;
|
||||||
use crate::context::LayoutContext;
|
use crate::context::LayoutContext;
|
||||||
use crate::flow::float::{
|
use crate::flow::float::{
|
||||||
ContainingBlockPositionInfo, FloatBox, PlacementAmongFloats, SequentialLayoutState,
|
Clear, ContainingBlockPositionInfo, FloatBox, FloatSide, PlacementAmongFloats,
|
||||||
|
SequentialLayoutState,
|
||||||
};
|
};
|
||||||
use crate::formatting_contexts::{
|
use crate::formatting_contexts::{
|
||||||
Baselines, IndependentFormattingContext, IndependentLayout, IndependentLayoutResult,
|
Baselines, IndependentFormattingContext, IndependentLayout, IndependentLayoutResult,
|
||||||
|
@ -120,7 +120,7 @@ impl BlockLevelBox {
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME: This should only return false when 'clear' causes clearance.
|
// FIXME: This should only return false when 'clear' causes clearance.
|
||||||
if style.get_box().clear != Clear::None {
|
if style.get_box().clear != StyleClear::None {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,11 +383,17 @@ fn calculate_inline_content_size_for_block_level_boxes(
|
||||||
&LogicalVec2::zero(),
|
&LogicalVec2::zero(),
|
||||||
false, /* auto_block_size_stretches_to_containing_block */
|
false, /* auto_block_size_stretches_to_containing_block */
|
||||||
);
|
);
|
||||||
let style_box = &float_box.contents.style().get_box();
|
let style = &float_box.contents.style();
|
||||||
Some((
|
Some((
|
||||||
inline_content_sizes_result,
|
inline_content_sizes_result,
|
||||||
style_box.float,
|
FloatSide::from_style_and_container_writing_mode(
|
||||||
style_box.clear,
|
style,
|
||||||
|
containing_block.writing_mode,
|
||||||
|
),
|
||||||
|
Clear::from_style_and_container_writing_mode(
|
||||||
|
style,
|
||||||
|
containing_block.writing_mode,
|
||||||
|
),
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
BlockLevelBox::SameFormattingContextBlock {
|
BlockLevelBox::SameFormattingContextBlock {
|
||||||
|
@ -406,7 +412,7 @@ fn calculate_inline_content_size_for_block_level_boxes(
|
||||||
// A block in the same BFC can overlap floats, it's not moved next to them,
|
// A block in the same BFC can overlap floats, it's not moved next to them,
|
||||||
// so we shouldn't add its size to the size of the floats.
|
// so we shouldn't add its size to the size of the floats.
|
||||||
// Instead, we treat it like an independent block with 'clear: both'.
|
// Instead, we treat it like an independent block with 'clear: both'.
|
||||||
Some((inline_content_sizes_result, Float::None, Clear::Both))
|
Some((inline_content_sizes_result, None, Clear::Both))
|
||||||
},
|
},
|
||||||
BlockLevelBox::Independent(ref independent) => {
|
BlockLevelBox::Independent(ref independent) => {
|
||||||
let inline_content_sizes_result = independent.outer_inline_content_sizes(
|
let inline_content_sizes_result = independent.outer_inline_content_sizes(
|
||||||
|
@ -417,8 +423,11 @@ fn calculate_inline_content_size_for_block_level_boxes(
|
||||||
);
|
);
|
||||||
Some((
|
Some((
|
||||||
inline_content_sizes_result,
|
inline_content_sizes_result,
|
||||||
Float::None,
|
None,
|
||||||
independent.style().get_box().clear,
|
Clear::from_style_and_container_writing_mode(
|
||||||
|
independent.style(),
|
||||||
|
containing_block.writing_mode,
|
||||||
|
),
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -432,31 +441,32 @@ fn calculate_inline_content_size_for_block_level_boxes(
|
||||||
depends_on_block_constraints: bool,
|
depends_on_block_constraints: bool,
|
||||||
/// The maximum size seen so far, not including trailing uncleared floats.
|
/// The maximum size seen so far, not including trailing uncleared floats.
|
||||||
max_size: ContentSizes,
|
max_size: ContentSizes,
|
||||||
/// The size of the trailing uncleared floats with 'float: left'.
|
/// The size of the trailing uncleared floats on the inline-start side
|
||||||
left_floats: ContentSizes,
|
/// of the containing block.
|
||||||
/// The size of the trailing uncleared floats with 'float: right'.
|
start_floats: ContentSizes,
|
||||||
right_floats: ContentSizes,
|
/// The size of the trailing uncleared floats on the inline-end side
|
||||||
|
/// of the containing block.
|
||||||
|
end_floats: ContentSizes,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AccumulatedData {
|
impl AccumulatedData {
|
||||||
fn max_size_including_uncleared_floats(&self) -> ContentSizes {
|
fn max_size_including_uncleared_floats(&self) -> ContentSizes {
|
||||||
self.max_size
|
self.max_size.max(self.start_floats.union(&self.end_floats))
|
||||||
.max(self.left_floats.union(&self.right_floats))
|
|
||||||
}
|
}
|
||||||
fn clear_floats(&mut self, clear: Clear) {
|
fn clear_floats(&mut self, clear: Clear) {
|
||||||
match clear {
|
match clear {
|
||||||
Clear::Left => {
|
Clear::InlineStart => {
|
||||||
self.max_size = self.max_size_including_uncleared_floats();
|
self.max_size = self.max_size_including_uncleared_floats();
|
||||||
self.left_floats = ContentSizes::zero();
|
self.start_floats = ContentSizes::zero();
|
||||||
},
|
},
|
||||||
Clear::Right => {
|
Clear::InlineEnd => {
|
||||||
self.max_size = self.max_size_including_uncleared_floats();
|
self.max_size = self.max_size_including_uncleared_floats();
|
||||||
self.right_floats = ContentSizes::zero();
|
self.end_floats = ContentSizes::zero();
|
||||||
},
|
},
|
||||||
Clear::Both => {
|
Clear::Both => {
|
||||||
self.max_size = self.max_size_including_uncleared_floats();
|
self.max_size = self.max_size_including_uncleared_floats();
|
||||||
self.left_floats = ContentSizes::zero();
|
self.start_floats = ContentSizes::zero();
|
||||||
self.right_floats = ContentSizes::zero();
|
self.end_floats = ContentSizes::zero();
|
||||||
},
|
},
|
||||||
Clear::None => {},
|
Clear::None => {},
|
||||||
};
|
};
|
||||||
|
@ -472,14 +482,14 @@ fn calculate_inline_content_size_for_block_level_boxes(
|
||||||
data.depends_on_block_constraints |= depends_on_block_constraints;
|
data.depends_on_block_constraints |= depends_on_block_constraints;
|
||||||
data.clear_floats(clear);
|
data.clear_floats(clear);
|
||||||
match float {
|
match float {
|
||||||
Float::Left => data.left_floats = data.left_floats.union(&size),
|
Some(FloatSide::InlineStart) => data.start_floats = data.start_floats.union(&size),
|
||||||
Float::Right => data.right_floats = data.right_floats.union(&size),
|
Some(FloatSide::InlineEnd) => data.end_floats = data.end_floats.union(&size),
|
||||||
Float::None => {
|
None => {
|
||||||
data.max_size = data
|
data.max_size = data
|
||||||
.max_size
|
.max_size
|
||||||
.max(data.left_floats.union(&data.right_floats).union(&size));
|
.max(data.start_floats.union(&data.end_floats).union(&size));
|
||||||
data.left_floats = ContentSizes::zero();
|
data.start_floats = ContentSizes::zero();
|
||||||
data.right_floats = ContentSizes::zero();
|
data.end_floats = ContentSizes::zero();
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
data
|
data
|
||||||
|
@ -789,6 +799,7 @@ fn layout_in_flow_non_replaced_block_level_same_formatting_context(
|
||||||
mut sequential_layout_state: Option<&mut SequentialLayoutState>,
|
mut sequential_layout_state: Option<&mut SequentialLayoutState>,
|
||||||
collapsible_with_parent_start_margin: Option<CollapsibleWithParentStartMargin>,
|
collapsible_with_parent_start_margin: Option<CollapsibleWithParentStartMargin>,
|
||||||
) -> BoxFragment {
|
) -> BoxFragment {
|
||||||
|
let containing_block_writing_mode = containing_block.style.writing_mode;
|
||||||
let ContainingBlockPaddingAndBorder {
|
let ContainingBlockPaddingAndBorder {
|
||||||
containing_block: containing_block_for_children,
|
containing_block: containing_block_for_children,
|
||||||
pbm,
|
pbm,
|
||||||
|
@ -815,6 +826,8 @@ fn layout_in_flow_non_replaced_block_level_same_formatting_context(
|
||||||
match sequential_layout_state {
|
match sequential_layout_state {
|
||||||
None => parent_containing_block_position_info = None,
|
None => parent_containing_block_position_info = None,
|
||||||
Some(ref mut sequential_layout_state) => {
|
Some(ref mut sequential_layout_state) => {
|
||||||
|
let clear =
|
||||||
|
Clear::from_style_and_container_writing_mode(style, containing_block_writing_mode);
|
||||||
let mut block_start_margin = CollapsedMargin::new(margin.block_start);
|
let mut block_start_margin = CollapsedMargin::new(margin.block_start);
|
||||||
|
|
||||||
// The block start margin may collapse with content margins,
|
// The block start margin may collapse with content margins,
|
||||||
|
@ -831,7 +844,7 @@ fn layout_in_flow_non_replaced_block_level_same_formatting_context(
|
||||||
let collapsible_with_parent_start_margin = collapsible_with_parent_start_margin.expect(
|
let collapsible_with_parent_start_margin = collapsible_with_parent_start_margin.expect(
|
||||||
"We should know whether we are collapsing the block start margin with the parent \
|
"We should know whether we are collapsing the block start margin with the parent \
|
||||||
when laying out sequentially",
|
when laying out sequentially",
|
||||||
).0 && style.get_box().clear == Clear::None;
|
).0 && clear == Clear::None;
|
||||||
if !collapsible_with_parent_start_margin && start_margin_can_collapse_with_children {
|
if !collapsible_with_parent_start_margin && start_margin_can_collapse_with_children {
|
||||||
if let BlockContainer::BlockLevelBoxes(child_boxes) = contents {
|
if let BlockContainer::BlockLevelBoxes(child_boxes) = contents {
|
||||||
BlockLevelBox::find_block_margin_collapsing_with_parent_from_slice(
|
BlockLevelBox::find_block_margin_collapsing_with_parent_from_slice(
|
||||||
|
@ -843,8 +856,7 @@ fn layout_in_flow_non_replaced_block_level_same_formatting_context(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Introduce clearance if necessary.
|
// Introduce clearance if necessary.
|
||||||
clearance = sequential_layout_state
|
clearance = sequential_layout_state.calculate_clearance(clear, &block_start_margin);
|
||||||
.calculate_clearance(style.get_box().clear, &block_start_margin);
|
|
||||||
if clearance.is_some() {
|
if clearance.is_some() {
|
||||||
sequential_layout_state.collapse_margins();
|
sequential_layout_state.collapse_margins();
|
||||||
}
|
}
|
||||||
|
@ -974,7 +986,6 @@ fn layout_in_flow_non_replaced_block_level_same_formatting_context(
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let containing_block_writing_mode = containing_block.style.writing_mode;
|
|
||||||
if depends_on_block_constraints {
|
if depends_on_block_constraints {
|
||||||
base_fragment_info
|
base_fragment_info
|
||||||
.flags
|
.flags
|
||||||
|
@ -1098,6 +1109,7 @@ impl NonReplacedFormattingContext {
|
||||||
containing_block: &ContainingBlock<'_>,
|
containing_block: &ContainingBlock<'_>,
|
||||||
sequential_layout_state: &mut SequentialLayoutState,
|
sequential_layout_state: &mut SequentialLayoutState,
|
||||||
) -> BoxFragment {
|
) -> BoxFragment {
|
||||||
|
let containing_block_writing_mode = containing_block.style.writing_mode;
|
||||||
let ContentBoxSizesAndPBMDeprecated {
|
let ContentBoxSizesAndPBMDeprecated {
|
||||||
content_box_size,
|
content_box_size,
|
||||||
content_min_box_size,
|
content_min_box_size,
|
||||||
|
@ -1183,7 +1195,10 @@ impl NonReplacedFormattingContext {
|
||||||
// The code below may then add extra clearance when the element can't fit
|
// The code below may then add extra clearance when the element can't fit
|
||||||
// next to floats not covered by 'clear'.
|
// next to floats not covered by 'clear'.
|
||||||
let clear_position = sequential_layout_state.calculate_clear_position(
|
let clear_position = sequential_layout_state.calculate_clear_position(
|
||||||
self.style.get_box().clear,
|
Clear::from_style_and_container_writing_mode(
|
||||||
|
&self.style,
|
||||||
|
containing_block_writing_mode,
|
||||||
|
),
|
||||||
&collapsed_margin_block_start,
|
&collapsed_margin_block_start,
|
||||||
);
|
);
|
||||||
let ceiling = clear_position.unwrap_or_else(|| {
|
let ceiling = clear_position.unwrap_or_else(|| {
|
||||||
|
@ -1339,7 +1354,6 @@ impl NonReplacedFormattingContext {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let containing_block_writing_mode = containing_block.style.writing_mode;
|
|
||||||
BoxFragment::new(
|
BoxFragment::new(
|
||||||
base_fragment_info,
|
base_fragment_info,
|
||||||
self.style.clone(),
|
self.style.clone(),
|
||||||
|
@ -1733,7 +1747,10 @@ fn solve_clearance_and_inline_margins_avoiding_floats(
|
||||||
) -> (Option<Au>, (Au, Au), Au) {
|
) -> (Option<Au>, (Au, Au), Au) {
|
||||||
let (clearance, placement_rect) = sequential_layout_state
|
let (clearance, placement_rect) = sequential_layout_state
|
||||||
.calculate_clearance_and_inline_adjustment(
|
.calculate_clearance_and_inline_adjustment(
|
||||||
style.get_box().clear,
|
Clear::from_style_and_container_writing_mode(
|
||||||
|
style,
|
||||||
|
containing_block.style.writing_mode,
|
||||||
|
),
|
||||||
block_start_margin,
|
block_start_margin,
|
||||||
pbm,
|
pbm,
|
||||||
size,
|
size,
|
||||||
|
|
|
@ -13,12 +13,11 @@ use std::{thread, u32};
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use euclid::num::Zero;
|
use euclid::num::Zero;
|
||||||
use layout_2020::flow::float::{
|
use layout_2020::flow::float::{
|
||||||
ContainingBlockPositionInfo, FloatBand, FloatBandNode, FloatBandTree, FloatContext, FloatSide,
|
Clear, ContainingBlockPositionInfo, FloatBand, FloatBandNode, FloatBandTree, FloatContext,
|
||||||
PlacementInfo,
|
FloatSide, PlacementInfo,
|
||||||
};
|
};
|
||||||
use layout_2020::geom::{LogicalRect, LogicalVec2};
|
use layout_2020::geom::{LogicalRect, LogicalVec2};
|
||||||
use quickcheck::{Arbitrary, Gen};
|
use quickcheck::{Arbitrary, Gen};
|
||||||
use style::values::computed::Clear;
|
|
||||||
|
|
||||||
static PANIC_HOOK_MUTEX: Mutex<()> = Mutex::new(());
|
static PANIC_HOOK_MUTEX: Mutex<()> = Mutex::new(());
|
||||||
|
|
||||||
|
@ -421,8 +420,8 @@ impl Arbitrary for FloatInput {
|
||||||
fn new_clear(value: u8) -> Clear {
|
fn new_clear(value: u8) -> Clear {
|
||||||
match value & 3 {
|
match value & 3 {
|
||||||
0 => Clear::None,
|
0 => Clear::None,
|
||||||
1 => Clear::Left,
|
1 => Clear::InlineStart,
|
||||||
2 => Clear::Right,
|
2 => Clear::InlineEnd,
|
||||||
_ => Clear::Both,
|
_ => Clear::Both,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -739,8 +738,8 @@ fn check_floats_rule_10(placement: &FloatPlacement) {
|
||||||
}
|
}
|
||||||
|
|
||||||
match this_float.info.clear {
|
match this_float.info.clear {
|
||||||
Clear::Left => assert_ne!(other_float.info.side, FloatSide::InlineStart),
|
Clear::InlineStart => assert_ne!(other_float.info.side, FloatSide::InlineStart),
|
||||||
Clear::Right => assert_ne!(other_float.info.side, FloatSide::InlineEnd),
|
Clear::InlineEnd => assert_ne!(other_float.info.side, FloatSide::InlineEnd),
|
||||||
Clear::Both => assert!(false),
|
Clear::Both => assert!(false),
|
||||||
Clear::None => unreachable!(),
|
Clear::None => unreachable!(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
[clear-computed.html]
|
|
||||||
[Property clear value 'inline-start']
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Property clear value 'inline-end']
|
|
||||||
expected: FAIL
|
|
|
@ -1,6 +0,0 @@
|
||||||
[float-computed.html]
|
|
||||||
[Property float value 'inline-start']
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Property float value 'inline-end']
|
|
||||||
expected: FAIL
|
|
|
@ -1,2 +0,0 @@
|
||||||
[logical-values-float-clear-reftest.html]
|
|
||||||
expected: FAIL
|
|
|
@ -1,12 +0,0 @@
|
||||||
[logical-values-float-clear.html]
|
|
||||||
[Test that 'clear: inline-start' is supported.]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Test that 'clear: inline-end' is supported.]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Test that 'float: inline-start' is supported.]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Test that 'float: inline-end' is supported.]
|
|
||||||
expected: FAIL
|
|
Loading…
Add table
Add a link
Reference in a new issue