mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Kill fragments
This commit is contained in:
parent
5bcb1b579c
commit
d0d4bb7c99
4 changed files with 0 additions and 107 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -2334,7 +2334,6 @@ dependencies = [
|
||||||
"script_layout_interface 0.0.1",
|
"script_layout_interface 0.0.1",
|
||||||
"script_traits 0.0.1",
|
"script_traits 0.0.1",
|
||||||
"serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"servo_arc 0.1.1",
|
|
||||||
"servo_url 0.0.1",
|
"servo_url 0.0.1",
|
||||||
"style 0.0.1",
|
"style 0.0.1",
|
||||||
"style_traits 0.0.1",
|
"style_traits 0.0.1",
|
||||||
|
|
|
@ -27,7 +27,6 @@ rayon = "1"
|
||||||
script_layout_interface = {path = "../script_layout_interface"}
|
script_layout_interface = {path = "../script_layout_interface"}
|
||||||
script_traits = {path = "../script_traits"}
|
script_traits = {path = "../script_traits"}
|
||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
servo_arc = {path = "../servo_arc"}
|
|
||||||
servo_url = {path = "../url"}
|
servo_url = {path = "../url"}
|
||||||
style = {path = "../style", features = ["servo", "servo-layout-2020"]}
|
style = {path = "../style", features = ["servo", "servo-layout-2020"]}
|
||||||
style_traits = {path = "../style_traits"}
|
style_traits = {path = "../style_traits"}
|
||||||
|
|
|
@ -1,99 +0,0 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
//! The `Fragment` type, which represents the leaves of the layout tree.
|
|
||||||
|
|
||||||
use crate::context::LayoutContext;
|
|
||||||
use crate::ServoArc;
|
|
||||||
use app_units::Au;
|
|
||||||
use script_layout_interface::wrapper_traits::{PseudoElementType, ThreadSafeLayoutNode};
|
|
||||||
use serde::ser::{Serialize, SerializeStruct, Serializer};
|
|
||||||
use style::dom::OpaqueNode;
|
|
||||||
use style::logical_geometry::{LogicalMargin, LogicalRect};
|
|
||||||
use style::properties::ComputedValues;
|
|
||||||
use style::selector_parser::RestyleDamage;
|
|
||||||
use style::servo::restyle_damage::ServoRestyleDamage;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct Fragment {
|
|
||||||
pub node: OpaqueNode,
|
|
||||||
pub style: ServoArc<ComputedValues>,
|
|
||||||
pub border_box: LogicalRect<Au>,
|
|
||||||
pub border_padding: LogicalMargin<Au>,
|
|
||||||
pub margin: LogicalMargin<Au>,
|
|
||||||
pub specific: SpecificFragmentInfo,
|
|
||||||
pub restyle_damage: RestyleDamage,
|
|
||||||
pub pseudo: PseudoElementType,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Serialize for Fragment {
|
|
||||||
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
|
||||||
let mut serializer = serializer.serialize_struct("fragment", 3)?;
|
|
||||||
serializer.serialize_field("border_box", &self.border_box)?;
|
|
||||||
serializer.serialize_field("margin", &self.margin)?;
|
|
||||||
serializer.end()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub enum SpecificFragmentInfo {
|
|
||||||
Generic,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl SpecificFragmentInfo {
|
|
||||||
fn restyle_damage(&self) -> RestyleDamage {
|
|
||||||
RestyleDamage::empty()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Fragment {
|
|
||||||
/// Constructs a new `Fragment` instance.
|
|
||||||
pub fn new<N: ThreadSafeLayoutNode>(
|
|
||||||
node: &N,
|
|
||||||
specific: SpecificFragmentInfo,
|
|
||||||
ctx: &LayoutContext,
|
|
||||||
) -> Fragment {
|
|
||||||
let shared_context = ctx.shared_context();
|
|
||||||
let style = node.style(shared_context);
|
|
||||||
let writing_mode = style.writing_mode;
|
|
||||||
|
|
||||||
let mut restyle_damage = RestyleDamage::rebuild_and_reflow();
|
|
||||||
restyle_damage.remove(ServoRestyleDamage::RECONSTRUCT_FLOW);
|
|
||||||
|
|
||||||
Fragment {
|
|
||||||
node: node.opaque(),
|
|
||||||
style: style,
|
|
||||||
restyle_damage: restyle_damage,
|
|
||||||
border_box: LogicalRect::zero(writing_mode),
|
|
||||||
border_padding: LogicalMargin::zero(writing_mode),
|
|
||||||
margin: LogicalMargin::zero(writing_mode),
|
|
||||||
specific: specific,
|
|
||||||
pseudo: node.get_pseudo_element_type(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn restyle_damage(&self) -> RestyleDamage {
|
|
||||||
self.restyle_damage | self.specific.restyle_damage()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn contains_node(&self, node_address: OpaqueNode) -> bool {
|
|
||||||
node_address == self.node
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the sum of the inline-sizes of all the borders of this fragment. Note that this
|
|
||||||
/// can be expensive to compute, so if possible use the `border_padding` field instead.
|
|
||||||
#[inline]
|
|
||||||
pub fn border_width(&self) -> LogicalMargin<Au> {
|
|
||||||
self.style().logical_border_width()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
pub fn style(&self) -> &ComputedValues {
|
|
||||||
&*self.style
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn is_primary_fragment(&self) -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -6,13 +6,7 @@
|
||||||
|
|
||||||
pub mod context;
|
pub mod context;
|
||||||
pub mod data;
|
pub mod data;
|
||||||
mod fragment;
|
|
||||||
pub mod opaque_node;
|
pub mod opaque_node;
|
||||||
pub mod query;
|
pub mod query;
|
||||||
pub mod traversal;
|
pub mod traversal;
|
||||||
pub mod wrapper;
|
pub mod wrapper;
|
||||||
|
|
||||||
// For unit tests:
|
|
||||||
pub use crate::fragment::Fragment;
|
|
||||||
|
|
||||||
use servo_arc::Arc as ServoArc;
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue