mirror of
https://github.com/servo/servo.git
synced 2025-07-25 16:20:36 +01:00
Pass a LayoutContext to TextRun::layout in 2020
This commit is contained in:
parent
ea32495504
commit
1446756774
7 changed files with 94 additions and 23 deletions
|
@ -3,7 +3,9 @@
|
||||||
* 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 gfx::font_cache_thread::FontCacheThread;
|
use gfx::font_cache_thread::FontCacheThread;
|
||||||
|
use gfx::font_context::FontContext;
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
|
use std::cell::{RefCell, RefMut};
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
use style::context::SharedStyleContext;
|
use style::context::SharedStyleContext;
|
||||||
|
|
||||||
|
@ -19,3 +21,18 @@ impl<'a> LayoutContext<'a> {
|
||||||
&self.style_context
|
&self.style_context
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) type LayoutFontContext = FontContext<FontCacheThread>;
|
||||||
|
|
||||||
|
thread_local!(static FONT_CONTEXT: RefCell<Option<LayoutFontContext>> = RefCell::new(None));
|
||||||
|
|
||||||
|
pub(crate) fn with_thread_local_font_context<F, R>(layout_context: &LayoutContext, f: F) -> R
|
||||||
|
where
|
||||||
|
F: FnOnce(&mut LayoutFontContext) -> R,
|
||||||
|
{
|
||||||
|
FONT_CONTEXT.with(|font_context| {
|
||||||
|
f(font_context.borrow_mut().get_or_insert_with(|| {
|
||||||
|
FontContext::new(layout_context.font_cache_thread.lock().unwrap().clone())
|
||||||
|
}))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
use crate::context::LayoutContext;
|
||||||
use crate::flow::float::FloatBox;
|
use crate::flow::float::FloatBox;
|
||||||
use crate::flow::FlowChildren;
|
use crate::flow::FlowChildren;
|
||||||
use crate::fragments::{AnonymousFragment, BoxFragment, CollapsedBlockMargins, Fragment};
|
use crate::fragments::{AnonymousFragment, BoxFragment, CollapsedBlockMargins, Fragment};
|
||||||
|
@ -81,6 +82,7 @@ struct LinesBoxes {
|
||||||
impl InlineFormattingContext {
|
impl InlineFormattingContext {
|
||||||
pub(super) fn layout<'a>(
|
pub(super) fn layout<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
|
layout_context: &LayoutContext,
|
||||||
containing_block: &ContainingBlock,
|
containing_block: &ContainingBlock,
|
||||||
tree_rank: usize,
|
tree_rank: usize,
|
||||||
absolutely_positioned_fragments: &mut Vec<AbsolutelyPositionedFragment<'a>>,
|
absolutely_positioned_fragments: &mut Vec<AbsolutelyPositionedFragment<'a>>,
|
||||||
|
@ -107,7 +109,7 @@ impl InlineFormattingContext {
|
||||||
let partial = inline.start_layout(&mut ifc);
|
let partial = inline.start_layout(&mut ifc);
|
||||||
ifc.partial_inline_boxes_stack.push(partial)
|
ifc.partial_inline_boxes_stack.push(partial)
|
||||||
},
|
},
|
||||||
InlineLevelBox::TextRun(run) => run.layout(&mut ifc),
|
InlineLevelBox::TextRun(run) => run.layout(layout_context, &mut ifc),
|
||||||
InlineLevelBox::Atomic { style: _, contents } => {
|
InlineLevelBox::Atomic { style: _, contents } => {
|
||||||
// FIXME
|
// FIXME
|
||||||
match *contents {}
|
match *contents {}
|
||||||
|
@ -284,7 +286,7 @@ impl<'box_tree> PartialInlineBoxFragment<'box_tree> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TextRun {
|
impl TextRun {
|
||||||
fn layout(&self, _ifc: &mut InlineFormattingContextState) {
|
fn layout(&self, _layout_context: &LayoutContext, _ifc: &mut InlineFormattingContextState) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
//! Flow layout, also known as block-and-inline layout.
|
//! Flow layout, also known as block-and-inline layout.
|
||||||
|
|
||||||
|
use crate::context::LayoutContext;
|
||||||
use crate::flow::float::{FloatBox, FloatContext};
|
use crate::flow::float::{FloatBox, FloatContext};
|
||||||
use crate::flow::inline::InlineFormattingContext;
|
use crate::flow::inline::InlineFormattingContext;
|
||||||
use crate::fragments::{
|
use crate::fragments::{
|
||||||
|
@ -67,6 +68,7 @@ struct CollapsibleWithParentStartMargin(bool);
|
||||||
impl BlockFormattingContext {
|
impl BlockFormattingContext {
|
||||||
pub(super) fn layout<'a>(
|
pub(super) fn layout<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
|
layout_context: &LayoutContext,
|
||||||
containing_block: &ContainingBlock,
|
containing_block: &ContainingBlock,
|
||||||
tree_rank: usize,
|
tree_rank: usize,
|
||||||
absolutely_positioned_fragments: &mut Vec<AbsolutelyPositionedFragment<'a>>,
|
absolutely_positioned_fragments: &mut Vec<AbsolutelyPositionedFragment<'a>>,
|
||||||
|
@ -79,6 +81,7 @@ impl BlockFormattingContext {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
let mut flow_children = self.contents.layout(
|
let mut flow_children = self.contents.layout(
|
||||||
|
layout_context,
|
||||||
containing_block,
|
containing_block,
|
||||||
tree_rank,
|
tree_rank,
|
||||||
absolutely_positioned_fragments,
|
absolutely_positioned_fragments,
|
||||||
|
@ -97,6 +100,7 @@ impl BlockFormattingContext {
|
||||||
impl BlockContainer {
|
impl BlockContainer {
|
||||||
fn layout<'a>(
|
fn layout<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
|
layout_context: &LayoutContext,
|
||||||
containing_block: &ContainingBlock,
|
containing_block: &ContainingBlock,
|
||||||
tree_rank: usize,
|
tree_rank: usize,
|
||||||
absolutely_positioned_fragments: &mut Vec<AbsolutelyPositionedFragment<'a>>,
|
absolutely_positioned_fragments: &mut Vec<AbsolutelyPositionedFragment<'a>>,
|
||||||
|
@ -105,6 +109,7 @@ impl BlockContainer {
|
||||||
) -> FlowChildren {
|
) -> FlowChildren {
|
||||||
match self {
|
match self {
|
||||||
BlockContainer::BlockLevelBoxes(child_boxes) => layout_block_level_children(
|
BlockContainer::BlockLevelBoxes(child_boxes) => layout_block_level_children(
|
||||||
|
layout_context,
|
||||||
child_boxes,
|
child_boxes,
|
||||||
containing_block,
|
containing_block,
|
||||||
tree_rank,
|
tree_rank,
|
||||||
|
@ -112,14 +117,18 @@ impl BlockContainer {
|
||||||
float_context,
|
float_context,
|
||||||
collapsible_with_parent_start_margin,
|
collapsible_with_parent_start_margin,
|
||||||
),
|
),
|
||||||
BlockContainer::InlineFormattingContext(ifc) => {
|
BlockContainer::InlineFormattingContext(ifc) => ifc.layout(
|
||||||
ifc.layout(containing_block, tree_rank, absolutely_positioned_fragments)
|
layout_context,
|
||||||
},
|
containing_block,
|
||||||
|
tree_rank,
|
||||||
|
absolutely_positioned_fragments,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn layout_block_level_children<'a>(
|
fn layout_block_level_children<'a>(
|
||||||
|
layout_context: &LayoutContext,
|
||||||
child_boxes: &'a [Arc<BlockLevelBox>],
|
child_boxes: &'a [Arc<BlockLevelBox>],
|
||||||
containing_block: &ContainingBlock,
|
containing_block: &ContainingBlock,
|
||||||
tree_rank: usize,
|
tree_rank: usize,
|
||||||
|
@ -201,6 +210,7 @@ fn layout_block_level_children<'a>(
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(tree_rank, box_)| {
|
.map(|(tree_rank, box_)| {
|
||||||
let mut fragment = box_.layout(
|
let mut fragment = box_.layout(
|
||||||
|
layout_context,
|
||||||
containing_block,
|
containing_block,
|
||||||
tree_rank,
|
tree_rank,
|
||||||
absolutely_positioned_fragments,
|
absolutely_positioned_fragments,
|
||||||
|
@ -218,6 +228,7 @@ fn layout_block_level_children<'a>(
|
||||||
absolutely_positioned_fragments,
|
absolutely_positioned_fragments,
|
||||||
|abspos_fragments, (tree_rank, box_)| {
|
|abspos_fragments, (tree_rank, box_)| {
|
||||||
box_.layout(
|
box_.layout(
|
||||||
|
layout_context,
|
||||||
containing_block,
|
containing_block,
|
||||||
tree_rank,
|
tree_rank,
|
||||||
abspos_fragments,
|
abspos_fragments,
|
||||||
|
@ -255,6 +266,7 @@ fn layout_block_level_children<'a>(
|
||||||
impl BlockLevelBox {
|
impl BlockLevelBox {
|
||||||
fn layout<'a>(
|
fn layout<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
|
layout_context: &LayoutContext,
|
||||||
containing_block: &ContainingBlock,
|
containing_block: &ContainingBlock,
|
||||||
tree_rank: usize,
|
tree_rank: usize,
|
||||||
absolutely_positioned_fragments: &mut Vec<AbsolutelyPositionedFragment<'a>>,
|
absolutely_positioned_fragments: &mut Vec<AbsolutelyPositionedFragment<'a>>,
|
||||||
|
@ -263,12 +275,14 @@ impl BlockLevelBox {
|
||||||
match self {
|
match self {
|
||||||
BlockLevelBox::SameFormattingContextBlock { style, contents } => {
|
BlockLevelBox::SameFormattingContextBlock { style, contents } => {
|
||||||
Fragment::Box(layout_in_flow_non_replaced_block_level(
|
Fragment::Box(layout_in_flow_non_replaced_block_level(
|
||||||
|
layout_context,
|
||||||
containing_block,
|
containing_block,
|
||||||
absolutely_positioned_fragments,
|
absolutely_positioned_fragments,
|
||||||
style,
|
style,
|
||||||
BlockLevelKind::SameFormattingContextBlock,
|
BlockLevelKind::SameFormattingContextBlock,
|
||||||
|containing_block, nested_abspos, collapsible_with_parent_start_margin| {
|
|containing_block, nested_abspos, collapsible_with_parent_start_margin| {
|
||||||
contents.layout(
|
contents.layout(
|
||||||
|
layout_context,
|
||||||
containing_block,
|
containing_block,
|
||||||
tree_rank,
|
tree_rank,
|
||||||
nested_abspos,
|
nested_abspos,
|
||||||
|
@ -284,12 +298,13 @@ impl BlockLevelBox {
|
||||||
match *replaced {}
|
match *replaced {}
|
||||||
},
|
},
|
||||||
Err(contents) => Fragment::Box(layout_in_flow_non_replaced_block_level(
|
Err(contents) => Fragment::Box(layout_in_flow_non_replaced_block_level(
|
||||||
|
layout_context,
|
||||||
containing_block,
|
containing_block,
|
||||||
absolutely_positioned_fragments,
|
absolutely_positioned_fragments,
|
||||||
style,
|
style,
|
||||||
BlockLevelKind::EstablishesAnIndependentFormattingContext,
|
BlockLevelKind::EstablishesAnIndependentFormattingContext,
|
||||||
|containing_block, nested_abspos, _| {
|
|containing_block, nested_abspos, _| {
|
||||||
contents.layout(containing_block, tree_rank, nested_abspos)
|
contents.layout(layout_context, containing_block, tree_rank, nested_abspos)
|
||||||
},
|
},
|
||||||
)),
|
)),
|
||||||
},
|
},
|
||||||
|
@ -314,6 +329,7 @@ enum BlockLevelKind {
|
||||||
/// https://drafts.csswg.org/css2/visudet.html#blockwidth
|
/// https://drafts.csswg.org/css2/visudet.html#blockwidth
|
||||||
/// https://drafts.csswg.org/css2/visudet.html#normal-block
|
/// https://drafts.csswg.org/css2/visudet.html#normal-block
|
||||||
fn layout_in_flow_non_replaced_block_level<'a>(
|
fn layout_in_flow_non_replaced_block_level<'a>(
|
||||||
|
layout_context: &LayoutContext,
|
||||||
containing_block: &ContainingBlock,
|
containing_block: &ContainingBlock,
|
||||||
absolutely_positioned_fragments: &mut Vec<AbsolutelyPositionedFragment<'a>>,
|
absolutely_positioned_fragments: &mut Vec<AbsolutelyPositionedFragment<'a>>,
|
||||||
style: &Arc<ComputedValues>,
|
style: &Arc<ComputedValues>,
|
||||||
|
@ -433,6 +449,7 @@ fn layout_in_flow_non_replaced_block_level<'a>(
|
||||||
};
|
};
|
||||||
if style.get_box().position == Position::Relative {
|
if style.get_box().position == Position::Relative {
|
||||||
AbsolutelyPositionedFragment::in_positioned_containing_block(
|
AbsolutelyPositionedFragment::in_positioned_containing_block(
|
||||||
|
layout_context,
|
||||||
&nested_abspos,
|
&nested_abspos,
|
||||||
&mut flow_children.fragments,
|
&mut flow_children.fragments,
|
||||||
&content_rect.size,
|
&content_rect.size,
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
use crate::context::LayoutContext;
|
||||||
use crate::display_list::IsContentful;
|
use crate::display_list::IsContentful;
|
||||||
use crate::dom_traversal::{Contents, NodeExt};
|
use crate::dom_traversal::{Contents, NodeExt};
|
||||||
use crate::flow::construct::ContainsFloats;
|
use crate::flow::construct::ContainsFloats;
|
||||||
|
@ -98,7 +99,11 @@ fn construct_for_root_element<'dom>(
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BoxTreeRoot {
|
impl BoxTreeRoot {
|
||||||
pub fn layout(&self, viewport: geom::Size<CSSPixel>) -> FragmentTreeRoot {
|
pub fn layout(
|
||||||
|
&self,
|
||||||
|
layout_context: &LayoutContext,
|
||||||
|
viewport: geom::Size<CSSPixel>,
|
||||||
|
) -> FragmentTreeRoot {
|
||||||
let initial_containing_block_size = Vec2 {
|
let initial_containing_block_size = Vec2 {
|
||||||
inline: Length::new(viewport.width),
|
inline: Length::new(viewport.width),
|
||||||
block: Length::new(viewport.height),
|
block: Length::new(viewport.height),
|
||||||
|
@ -114,6 +119,7 @@ impl BoxTreeRoot {
|
||||||
let dummy_tree_rank = 0;
|
let dummy_tree_rank = 0;
|
||||||
let mut absolutely_positioned_fragments = vec![];
|
let mut absolutely_positioned_fragments = vec![];
|
||||||
let mut flow_children = self.0.layout(
|
let mut flow_children = self.0.layout(
|
||||||
|
layout_context,
|
||||||
&initial_containing_block,
|
&initial_containing_block,
|
||||||
dummy_tree_rank,
|
dummy_tree_rank,
|
||||||
&mut absolutely_positioned_fragments,
|
&mut absolutely_positioned_fragments,
|
||||||
|
@ -126,7 +132,7 @@ impl BoxTreeRoot {
|
||||||
flow_children.fragments.par_extend(
|
flow_children.fragments.par_extend(
|
||||||
absolutely_positioned_fragments
|
absolutely_positioned_fragments
|
||||||
.par_iter()
|
.par_iter()
|
||||||
.map(|a| a.layout(&initial_containing_block)),
|
.map(|a| a.layout(layout_context, &initial_containing_block)),
|
||||||
);
|
);
|
||||||
FragmentTreeRoot(flow_children.fragments)
|
FragmentTreeRoot(flow_children.fragments)
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ pub mod wrapper;
|
||||||
|
|
||||||
pub use flow::{BoxTreeRoot, FragmentTreeRoot};
|
pub use flow::{BoxTreeRoot, FragmentTreeRoot};
|
||||||
|
|
||||||
|
use crate::context::LayoutContext;
|
||||||
use crate::dom_traversal::{Contents, NodeExt};
|
use crate::dom_traversal::{Contents, NodeExt};
|
||||||
use crate::flow::{BlockFormattingContext, FlowChildren};
|
use crate::flow::{BlockFormattingContext, FlowChildren};
|
||||||
use crate::geom::flow_relative::Vec2;
|
use crate::geom::flow_relative::Vec2;
|
||||||
|
@ -87,13 +88,19 @@ impl IndependentFormattingContext {
|
||||||
|
|
||||||
fn layout<'a>(
|
fn layout<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
|
layout_context: &LayoutContext,
|
||||||
containing_block: &ContainingBlock,
|
containing_block: &ContainingBlock,
|
||||||
tree_rank: usize,
|
tree_rank: usize,
|
||||||
absolutely_positioned_fragments: &mut Vec<AbsolutelyPositionedFragment<'a>>,
|
absolutely_positioned_fragments: &mut Vec<AbsolutelyPositionedFragment<'a>>,
|
||||||
) -> FlowChildren {
|
) -> FlowChildren {
|
||||||
match self.as_replaced() {
|
match self.as_replaced() {
|
||||||
Ok(replaced) => match *replaced {},
|
Ok(replaced) => match *replaced {},
|
||||||
Err(ifc) => ifc.layout(containing_block, tree_rank, absolutely_positioned_fragments),
|
Err(ifc) => ifc.layout(
|
||||||
|
layout_context,
|
||||||
|
containing_block,
|
||||||
|
tree_rank,
|
||||||
|
absolutely_positioned_fragments,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,14 +108,18 @@ impl IndependentFormattingContext {
|
||||||
impl<'a> NonReplacedIFC<'a> {
|
impl<'a> NonReplacedIFC<'a> {
|
||||||
fn layout(
|
fn layout(
|
||||||
&self,
|
&self,
|
||||||
|
layout_context: &LayoutContext,
|
||||||
containing_block: &ContainingBlock,
|
containing_block: &ContainingBlock,
|
||||||
tree_rank: usize,
|
tree_rank: usize,
|
||||||
absolutely_positioned_fragments: &mut Vec<AbsolutelyPositionedFragment<'a>>,
|
absolutely_positioned_fragments: &mut Vec<AbsolutelyPositionedFragment<'a>>,
|
||||||
) -> FlowChildren {
|
) -> FlowChildren {
|
||||||
match self {
|
match self {
|
||||||
NonReplacedIFC::Flow(bfc) => {
|
NonReplacedIFC::Flow(bfc) => bfc.layout(
|
||||||
bfc.layout(containing_block, tree_rank, absolutely_positioned_fragments)
|
layout_context,
|
||||||
},
|
containing_block,
|
||||||
|
tree_rank,
|
||||||
|
absolutely_positioned_fragments,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
use crate::context::LayoutContext;
|
||||||
use crate::fragments::{AnonymousFragment, BoxFragment, CollapsedBlockMargins, Fragment};
|
use crate::fragments::{AnonymousFragment, BoxFragment, CollapsedBlockMargins, Fragment};
|
||||||
use crate::geom::flow_relative::{Rect, Sides, Vec2};
|
use crate::geom::flow_relative::{Rect, Sides, Vec2};
|
||||||
use crate::style_ext::{ComputedValuesExt, Direction, WritingMode};
|
use crate::style_ext::{ComputedValuesExt, Direction, WritingMode};
|
||||||
|
@ -94,6 +95,7 @@ impl AbsolutelyPositionedBox {
|
||||||
|
|
||||||
impl<'a> AbsolutelyPositionedFragment<'a> {
|
impl<'a> AbsolutelyPositionedFragment<'a> {
|
||||||
pub(crate) fn in_positioned_containing_block(
|
pub(crate) fn in_positioned_containing_block(
|
||||||
|
layout_context: &LayoutContext,
|
||||||
absolute: &[Self],
|
absolute: &[Self],
|
||||||
fragments: &mut Vec<Fragment>,
|
fragments: &mut Vec<Fragment>,
|
||||||
content_rect_size: &Vec2<Length>,
|
content_rect_size: &Vec2<Length>,
|
||||||
|
@ -116,14 +118,18 @@ impl<'a> AbsolutelyPositionedFragment<'a> {
|
||||||
fragments.push(Fragment::Anonymous(AnonymousFragment {
|
fragments.push(Fragment::Anonymous(AnonymousFragment {
|
||||||
children: absolute
|
children: absolute
|
||||||
.par_iter()
|
.par_iter()
|
||||||
.map(|a| a.layout(&containing_block))
|
.map(|a| a.layout(layout_context, &containing_block))
|
||||||
.collect(),
|
.collect(),
|
||||||
rect: padding_rect,
|
rect: padding_rect,
|
||||||
mode,
|
mode,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn layout(&self, containing_block: &DefiniteContainingBlock) -> Fragment {
|
pub(crate) fn layout(
|
||||||
|
&self,
|
||||||
|
layout_context: &LayoutContext,
|
||||||
|
containing_block: &DefiniteContainingBlock,
|
||||||
|
) -> Fragment {
|
||||||
let style = &self.absolutely_positioned_box.style;
|
let style = &self.absolutely_positioned_box.style;
|
||||||
let cbis = containing_block.size.inline;
|
let cbis = containing_block.size.inline;
|
||||||
let cbbs = containing_block.size.block;
|
let cbbs = containing_block.size.block;
|
||||||
|
@ -269,6 +275,7 @@ impl<'a> AbsolutelyPositionedFragment<'a> {
|
||||||
let dummy_tree_rank = 0;
|
let dummy_tree_rank = 0;
|
||||||
let mut absolutely_positioned_fragments = vec![];
|
let mut absolutely_positioned_fragments = vec![];
|
||||||
let mut flow_children = self.absolutely_positioned_box.contents.layout(
|
let mut flow_children = self.absolutely_positioned_box.contents.layout(
|
||||||
|
layout_context,
|
||||||
&containing_block_for_children,
|
&containing_block_for_children,
|
||||||
dummy_tree_rank,
|
dummy_tree_rank,
|
||||||
&mut absolutely_positioned_fragments,
|
&mut absolutely_positioned_fragments,
|
||||||
|
@ -297,6 +304,7 @@ impl<'a> AbsolutelyPositionedFragment<'a> {
|
||||||
};
|
};
|
||||||
|
|
||||||
AbsolutelyPositionedFragment::in_positioned_containing_block(
|
AbsolutelyPositionedFragment::in_positioned_containing_block(
|
||||||
|
layout_context,
|
||||||
&absolutely_positioned_fragments,
|
&absolutely_positioned_fragments,
|
||||||
&mut flow_children.fragments,
|
&mut flow_children.fragments,
|
||||||
&content_rect.size,
|
&content_rect.size,
|
||||||
|
|
|
@ -1087,16 +1087,28 @@ impl LayoutThread {
|
||||||
RecalcStyle::pre_traverse(element, shared)
|
RecalcStyle::pre_traverse(element, shared)
|
||||||
};
|
};
|
||||||
|
|
||||||
if token.should_traverse() {
|
let box_tree = if token.should_traverse() {
|
||||||
driver::traverse_dom(&traversal, token, None);
|
driver::traverse_dom(&traversal, token, None);
|
||||||
|
|
||||||
let shared = DomTraversal::<ServoLayoutElement>::shared_context(&traversal);
|
let shared = DomTraversal::<ServoLayoutElement>::shared_context(&traversal);
|
||||||
let box_tree =
|
Some(BoxTreeRoot::construct(
|
||||||
BoxTreeRoot::construct(shared, document.root_element().unwrap().as_node());
|
shared,
|
||||||
let fragment_tree = box_tree.layout(Size2D::new(
|
document.root_element().unwrap().as_node(),
|
||||||
self.viewport_size.width.to_f32_px(),
|
))
|
||||||
self.viewport_size.height.to_f32_px(),
|
} else {
|
||||||
));
|
None
|
||||||
|
};
|
||||||
|
|
||||||
|
layout_context = traversal.destroy();
|
||||||
|
|
||||||
|
if let Some(box_tree) = box_tree {
|
||||||
|
let fragment_tree = box_tree.layout(
|
||||||
|
&layout_context,
|
||||||
|
Size2D::new(
|
||||||
|
self.viewport_size.width.to_f32_px(),
|
||||||
|
self.viewport_size.height.to_f32_px(),
|
||||||
|
),
|
||||||
|
);
|
||||||
*self.box_tree_root.borrow_mut() = Some(box_tree);
|
*self.box_tree_root.borrow_mut() = Some(box_tree);
|
||||||
*self.fragment_tree_root.borrow_mut() = Some(fragment_tree);
|
*self.fragment_tree_root.borrow_mut() = Some(fragment_tree);
|
||||||
}
|
}
|
||||||
|
@ -1105,8 +1117,6 @@ impl LayoutThread {
|
||||||
unsafe { element.unset_snapshot_flags() }
|
unsafe { element.unset_snapshot_flags() }
|
||||||
}
|
}
|
||||||
|
|
||||||
layout_context = traversal.destroy();
|
|
||||||
|
|
||||||
// GC the rule tree if some heuristics are met.
|
// GC the rule tree if some heuristics are met.
|
||||||
unsafe {
|
unsafe {
|
||||||
layout_context.style_context.stylist.rule_tree().maybe_gc();
|
layout_context.style_context.stylist.rule_tree().maybe_gc();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue