2013-04-06 03:31:01 +04:00
|
|
|
|
/* 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 http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
2014-05-29 04:34:06 +04:00
|
|
|
|
//! Servo's experimental layout system builds a tree of `Flow` and `Fragment` objects and solves
|
2013-12-06 05:44:24 +04:00
|
|
|
|
//! layout constraints to obtain positions and display attributes of tree nodes. Positions are
|
|
|
|
|
//! computed in several tree traversals driven by the fundamental data dependencies required by
|
2015-08-04 01:46:12 +03:00
|
|
|
|
//! inline and block layout.
|
|
|
|
|
//!
|
|
|
|
|
//! Flows are interior nodes in the layout tree and correspond closely to *flow contexts* in the
|
|
|
|
|
//! CSS specification. Flows are responsible for positioning their child flow contexts and
|
|
|
|
|
//! fragments. Flows have purpose-specific fields, such as auxiliary line structs, out-of-flow
|
|
|
|
|
//! child lists, and so on.
|
|
|
|
|
//!
|
|
|
|
|
//! Currently, the important types of flows are:
|
|
|
|
|
//!
|
|
|
|
|
//! * `BlockFlow`: A flow that establishes a block context. It has several child flows, each of
|
|
|
|
|
//! which are positioned according to block formatting context rules (CSS block boxes). Block
|
|
|
|
|
//! flows also contain a single box to represent their rendered borders, padding, etc.
|
|
|
|
|
//! The BlockFlow at the root of the tree has special behavior: it stretches to the boundaries of
|
|
|
|
|
//! the viewport.
|
|
|
|
|
//!
|
|
|
|
|
//! * `InlineFlow`: A flow that establishes an inline context. It has a flat list of child
|
|
|
|
|
//! fragments/flows that are subject to inline layout and line breaking and structs to represent
|
|
|
|
|
//! line breaks and mapping to CSS boxes, for the purpose of handling `getClientRects()` and
|
|
|
|
|
//! similar methods.
|
2013-05-03 06:37:36 +04:00
|
|
|
|
|
2015-10-01 00:19:33 +03:00
|
|
|
|
use app_units::Au;
|
2016-03-26 04:38:41 +03:00
|
|
|
|
use block::{BlockFlow, FormattingContextType};
|
2017-02-08 04:16:05 +03:00
|
|
|
|
use context::LayoutContext;
|
2018-01-07 17:53:18 +03:00
|
|
|
|
use display_list::{DisplayListBuildState, StackingContextCollectionState};
|
2018-02-24 18:06:16 +03:00
|
|
|
|
use euclid::{Point2D, Vector2D, Rect, Size2D};
|
2016-11-09 12:59:22 +03:00
|
|
|
|
use flex::FlexFlow;
|
2016-03-26 04:38:41 +03:00
|
|
|
|
use floats::{Floats, SpeculatedFloatPlacement};
|
2017-10-13 20:26:39 +03:00
|
|
|
|
use flow_list::{FlowList, FlowListIterator, MutFlowListIterator};
|
2016-11-05 00:53:38 +03:00
|
|
|
|
use flow_ref::{FlowRef, WeakFlowRef};
|
2017-04-18 00:08:00 +03:00
|
|
|
|
use fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, Overflow};
|
2017-10-24 17:46:08 +03:00
|
|
|
|
use gfx::display_list::ClippingAndScrolling;
|
2017-04-20 09:55:33 +03:00
|
|
|
|
use gfx_traits::StackingContextId;
|
2016-09-09 06:19:19 +03:00
|
|
|
|
use gfx_traits::print_tree::PrintTree;
|
2014-07-01 16:02:50 +04:00
|
|
|
|
use inline::InlineFlow;
|
2015-03-10 08:24:47 +03:00
|
|
|
|
use model::{CollapsibleMargins, IntrinsicISizes, MarginCollapseInfo};
|
2015-09-19 22:34:51 +03:00
|
|
|
|
use multicol::MulticolFlow;
|
|
|
|
|
use parallel::FlowParallelInfo;
|
2017-02-18 23:10:26 +03:00
|
|
|
|
use serde::ser::{Serialize, SerializeStruct, Serializer};
|
2018-01-18 14:42:52 +03:00
|
|
|
|
use servo_geometry::{au_rect_to_f32_rect, f32_rect_to_au_rect, MaxRect};
|
2017-10-14 05:43:09 +03:00
|
|
|
|
use std::fmt;
|
2014-04-04 05:01:48 +04:00
|
|
|
|
use std::iter::Zip;
|
2015-01-28 04:15:50 +03:00
|
|
|
|
use std::slice::IterMut;
|
2015-04-15 02:14:11 +03:00
|
|
|
|
use std::sync::Arc;
|
2015-08-22 00:29:35 +03:00
|
|
|
|
use std::sync::atomic::Ordering;
|
2017-12-06 04:35:25 +03:00
|
|
|
|
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::position::T as Position;
|
|
|
|
|
use style::computed_values::text_align::T as TextAlign;
|
servo: Merge #12515 - Make the style crate more concrete (from servo:concrete-style); r=bholley
Background:
The changes to Servo code to support Stylo began in the `selectors` crate with making pseudo-elements generic, defined be the user, so that different users (such as Servo and Gecko/Stylo) could have a different set of pseudo-elements supported and parsed. Adding a trait makes sense there since `selectors` is in its own repository and has others users (or at least [one](https://github.com/SimonSapin/kuchiki)).
Then we kind of kept going with the same pattern and added a bunch of traits in the `style` crate to make everything generic, allowing Servo and Gecko/Stylo to do things differently. But we’ve also added a `gecko` Cargo feature to do conditional compilation, at first to enable or disable some CSS properties and values in the Mako templates. Since we’re doing conditional compilation anyway, it’s often easier and simpler to do it more (with `#[cfg(feature = "gecko")]` and `#[cfg(feature = "servo")]`) that to keep adding traits and making everything generic. When a type is generic, any method that we want to call on it needs to be part of some trait.
----
The first several commits move some code around, mostly from `geckolib` to `style` (with `#[cfg(feature = "gecko")]`) but otherwise don’t change much.
The following commits remove some traits and many type parameters through the `style` crate, replacing them with pairs of conditionally-compiled API-compatible items (types, methods, …).
Simplifying code is nice to make it more maintainable, but this is motivated by another change described in https://github.com/servo/servo/pull/12391#issuecomment-232183942. (Porting Servo for that change proved difficult because some code in the `style` crate was becoming generic over `String` vs `Atom`, and this PR will help make that concrete. That change, in turn, is motivated by removing geckolib’s `[replace]` override for string-cache, in order to enable using a single Cargo "workspace" in this repository.)
r? @bholley
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #__ (github issue number if applicable).
<!-- Either: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require new tests because refactoring
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Source-Repo: https://github.com/servo/servo
Source-Revision: 2d01d41a506bcbc7f26a2284b9f42390d6ef96ab
--HG--
rename : servo/ports/geckolib/selector_impl.rs => servo/components/style/gecko_selector_impl.rs
rename : servo/ports/geckolib/values.rs => servo/components/style/gecko_values.rs
rename : servo/ports/geckolib/properties.mako.rs => servo/components/style/properties/gecko.mako.rs
2016-07-20 10:58:34 +03:00
|
|
|
|
use style::context::SharedStyleContext;
|
2016-02-18 12:21:29 +03:00
|
|
|
|
use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
|
2017-07-18 05:44:25 +03:00
|
|
|
|
use style::properties::ComputedValues;
|
2016-11-20 18:21:52 +03:00
|
|
|
|
use style::selector_parser::RestyleDamage;
|
2017-10-31 02:25:45 +03:00
|
|
|
|
use style::servo::restyle_damage::ServoRestyleDamage;
|
2015-04-15 02:14:11 +03:00
|
|
|
|
use style::values::computed::LengthOrPercentageOrAuto;
|
2016-12-01 10:36:46 +03:00
|
|
|
|
use table::TableFlow;
|
2015-09-19 22:34:51 +03:00
|
|
|
|
use table_caption::TableCaptionFlow;
|
|
|
|
|
use table_cell::TableCellFlow;
|
|
|
|
|
use table_colgroup::TableColGroupFlow;
|
|
|
|
|
use table_row::TableRowFlow;
|
|
|
|
|
use table_rowgroup::TableRowGroupFlow;
|
|
|
|
|
use table_wrapper::TableWrapperFlow;
|
2018-02-24 18:06:16 +03:00
|
|
|
|
use webrender_api::LayoutTransform;
|
2012-11-12 07:42:44 +04:00
|
|
|
|
|
2017-10-14 05:43:09 +03:00
|
|
|
|
/// This marker trait indicates that a type is a struct with `#[repr(C)]` whose first field
|
|
|
|
|
/// is of type `BaseFlow` or some type that also implements this trait.
|
|
|
|
|
///
|
|
|
|
|
/// In other words, the memory representation of `BaseFlow` must be a prefix
|
|
|
|
|
/// of the memory representation of types implementing `HasBaseFlow`.
|
|
|
|
|
#[allow(unsafe_code)]
|
|
|
|
|
pub unsafe trait HasBaseFlow {}
|
|
|
|
|
|
2017-12-15 21:44:50 +03:00
|
|
|
|
/// Methods to get the `BaseFlow` from any `HasBaseFlow` type.
|
|
|
|
|
pub trait GetBaseFlow {
|
|
|
|
|
fn base(&self) -> &BaseFlow;
|
|
|
|
|
fn mut_base(&mut self) -> &mut BaseFlow;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<T: HasBaseFlow + ?Sized> GetBaseFlow for T {
|
|
|
|
|
#[inline(always)]
|
|
|
|
|
#[allow(unsafe_code)]
|
|
|
|
|
fn base(&self) -> &BaseFlow {
|
|
|
|
|
let ptr: *const Self = self;
|
|
|
|
|
let ptr = ptr as *const BaseFlow;
|
|
|
|
|
unsafe { &*ptr }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[inline(always)]
|
|
|
|
|
#[allow(unsafe_code)]
|
|
|
|
|
fn mut_base(&mut self) -> &mut BaseFlow {
|
|
|
|
|
let ptr: *mut Self = self;
|
|
|
|
|
let ptr = ptr as *mut BaseFlow;
|
|
|
|
|
unsafe { &mut *ptr }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 00:31:44 +04:00
|
|
|
|
/// Virtual methods that make up a float context.
|
|
|
|
|
///
|
|
|
|
|
/// Note that virtual methods have a cost; we should not overuse them in Servo. Consider adding
|
|
|
|
|
/// methods to `ImmutableFlowUtils` or `MutableFlowUtils` before adding more methods here.
|
2017-10-14 05:43:09 +03:00
|
|
|
|
pub trait Flow: HasBaseFlow + fmt::Debug + Sync + Send + 'static {
|
2013-10-29 00:31:44 +04:00
|
|
|
|
// RTTI
|
|
|
|
|
//
|
|
|
|
|
// TODO(pcwalton): Use Rust's RTTI, once that works.
|
2012-09-22 03:23:30 +04:00
|
|
|
|
|
2013-10-29 00:31:44 +04:00
|
|
|
|
/// Returns the class of flow that this is.
|
|
|
|
|
fn class(&self) -> FlowClass;
|
2012-09-22 03:23:30 +04:00
|
|
|
|
|
2013-10-29 00:31:44 +04:00
|
|
|
|
/// If this is a block flow, returns the underlying object. Fails otherwise.
|
2015-09-04 16:59:04 +03:00
|
|
|
|
fn as_block(&self) -> &BlockFlow {
|
2014-11-13 06:48:31 +03:00
|
|
|
|
panic!("called as_block() on a non-block flow")
|
2013-10-29 00:31:44 +04:00
|
|
|
|
}
|
2013-08-20 23:03:52 +04:00
|
|
|
|
|
2015-08-18 16:31:57 +03:00
|
|
|
|
/// If this is a block flow, returns the underlying object, borrowed mutably. Fails otherwise.
|
2015-09-04 16:59:04 +03:00
|
|
|
|
fn as_mut_block(&mut self) -> &mut BlockFlow {
|
2015-08-18 16:31:57 +03:00
|
|
|
|
debug!("called as_mut_block() on a flow of type {:?}", self.class());
|
|
|
|
|
panic!("called as_mut_block() on a non-block flow")
|
2013-05-22 23:57:28 +04:00
|
|
|
|
}
|
2013-07-16 05:03:27 +04:00
|
|
|
|
|
2016-11-09 12:59:22 +03:00
|
|
|
|
/// If this is a flex flow, returns the underlying object. Fails otherwise.
|
|
|
|
|
fn as_flex(&self) -> &FlexFlow {
|
|
|
|
|
panic!("called as_flex() on a non-flex flow")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// If this is a flex flow, returns the underlying object, borrowed mutably. Fails otherwise.
|
|
|
|
|
fn as_mut_flex(&mut self) -> &mut FlexFlow {
|
|
|
|
|
panic!("called as_mut_flex() on a non-flex flow")
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 00:31:44 +04:00
|
|
|
|
/// If this is an inline flow, returns the underlying object. Fails otherwise.
|
2015-09-04 16:59:04 +03:00
|
|
|
|
fn as_inline(&self) -> &InlineFlow {
|
2014-11-13 06:48:31 +03:00
|
|
|
|
panic!("called as_inline() on a non-inline flow")
|
2013-10-29 00:31:44 +04:00
|
|
|
|
}
|
2013-07-16 05:03:27 +04:00
|
|
|
|
|
2015-08-18 16:31:57 +03:00
|
|
|
|
/// If this is an inline flow, returns the underlying object, borrowed mutably. Fails
|
|
|
|
|
/// otherwise.
|
2015-09-04 16:59:04 +03:00
|
|
|
|
fn as_mut_inline(&mut self) -> &mut InlineFlow {
|
2015-08-18 16:31:57 +03:00
|
|
|
|
panic!("called as_mut_inline() on a non-inline flow")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// If this is a table wrapper flow, returns the underlying object, borrowed mutably. Fails
|
|
|
|
|
/// otherwise.
|
2015-09-04 16:59:04 +03:00
|
|
|
|
fn as_mut_table_wrapper(&mut self) -> &mut TableWrapperFlow {
|
2015-08-18 16:31:57 +03:00
|
|
|
|
panic!("called as_mut_table_wrapper() on a non-tablewrapper flow")
|
|
|
|
|
}
|
|
|
|
|
|
servo: Merge #1973 - Support fixed-layout table and a part of anonymous table object (from june0cho:table_rebase); r=larsbergstrom,metajack
This is a rebase of #1548 on recent master.
There have been many changes since #1548 is first uploaded, so I'm creating new PR.
This PR includes:
- construction of table-* flows (table-wrapper, table-caption, table, table-rowgroup, table-row, table-cell)
- fixed-layout table calculation
- a part of anonymous table object implementation
[CSS 2.1, 17.2.1](http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes) (Step 1-1, 1-2, Step 2)
Source-Repo: https://github.com/servo/servo
Source-Revision: fd5e5cd18b41f0ce2b33fb97fb4e3d75ddbbbceb
2014-03-25 21:40:47 +04:00
|
|
|
|
/// If this is a table wrapper flow, returns the underlying object. Fails otherwise.
|
2015-09-04 16:59:04 +03:00
|
|
|
|
fn as_table_wrapper(&self) -> &TableWrapperFlow {
|
2014-11-13 06:48:31 +03:00
|
|
|
|
panic!("called as_table_wrapper() on a non-tablewrapper flow")
|
servo: Merge #1973 - Support fixed-layout table and a part of anonymous table object (from june0cho:table_rebase); r=larsbergstrom,metajack
This is a rebase of #1548 on recent master.
There have been many changes since #1548 is first uploaded, so I'm creating new PR.
This PR includes:
- construction of table-* flows (table-wrapper, table-caption, table, table-rowgroup, table-row, table-cell)
- fixed-layout table calculation
- a part of anonymous table object implementation
[CSS 2.1, 17.2.1](http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes) (Step 1-1, 1-2, Step 2)
Source-Repo: https://github.com/servo/servo
Source-Revision: fd5e5cd18b41f0ce2b33fb97fb4e3d75ddbbbceb
2014-03-25 21:40:47 +04:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-18 16:31:57 +03:00
|
|
|
|
/// If this is a table flow, returns the underlying object, borrowed mutably. Fails otherwise.
|
2015-09-04 16:59:04 +03:00
|
|
|
|
fn as_mut_table(&mut self) -> &mut TableFlow {
|
2015-08-18 16:31:57 +03:00
|
|
|
|
panic!("called as_mut_table() on a non-table flow")
|
2014-09-20 06:50:47 +04:00
|
|
|
|
}
|
|
|
|
|
|
servo: Merge #1973 - Support fixed-layout table and a part of anonymous table object (from june0cho:table_rebase); r=larsbergstrom,metajack
This is a rebase of #1548 on recent master.
There have been many changes since #1548 is first uploaded, so I'm creating new PR.
This PR includes:
- construction of table-* flows (table-wrapper, table-caption, table, table-rowgroup, table-row, table-cell)
- fixed-layout table calculation
- a part of anonymous table object implementation
[CSS 2.1, 17.2.1](http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes) (Step 1-1, 1-2, Step 2)
Source-Repo: https://github.com/servo/servo
Source-Revision: fd5e5cd18b41f0ce2b33fb97fb4e3d75ddbbbceb
2014-03-25 21:40:47 +04:00
|
|
|
|
/// If this is a table flow, returns the underlying object. Fails otherwise.
|
2015-09-04 16:59:04 +03:00
|
|
|
|
fn as_table(&self) -> &TableFlow {
|
2014-11-13 06:48:31 +03:00
|
|
|
|
panic!("called as_table() on a non-table flow")
|
servo: Merge #1973 - Support fixed-layout table and a part of anonymous table object (from june0cho:table_rebase); r=larsbergstrom,metajack
This is a rebase of #1548 on recent master.
There have been many changes since #1548 is first uploaded, so I'm creating new PR.
This PR includes:
- construction of table-* flows (table-wrapper, table-caption, table, table-rowgroup, table-row, table-cell)
- fixed-layout table calculation
- a part of anonymous table object implementation
[CSS 2.1, 17.2.1](http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes) (Step 1-1, 1-2, Step 2)
Source-Repo: https://github.com/servo/servo
Source-Revision: fd5e5cd18b41f0ce2b33fb97fb4e3d75ddbbbceb
2014-03-25 21:40:47 +04:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-18 16:31:57 +03:00
|
|
|
|
/// If this is a table colgroup flow, returns the underlying object, borrowed mutably. Fails
|
|
|
|
|
/// otherwise.
|
2015-09-04 16:59:04 +03:00
|
|
|
|
fn as_mut_table_colgroup(&mut self) -> &mut TableColGroupFlow {
|
2015-08-18 16:31:57 +03:00
|
|
|
|
panic!("called as_mut_table_colgroup() on a non-tablecolgroup flow")
|
2014-09-20 06:50:47 +04:00
|
|
|
|
}
|
|
|
|
|
|
2018-02-21 20:00:03 +03:00
|
|
|
|
/// If this is a table colgroup flow, returns the underlying object. Fails
|
|
|
|
|
/// otherwise.
|
|
|
|
|
fn as_table_colgroup(&self) -> &TableColGroupFlow {
|
|
|
|
|
panic!("called as_table_colgroup() on a non-tablecolgroup flow")
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-18 16:31:57 +03:00
|
|
|
|
/// If this is a table rowgroup flow, returns the underlying object, borrowed mutably. Fails
|
|
|
|
|
/// otherwise.
|
2015-09-04 16:59:04 +03:00
|
|
|
|
fn as_mut_table_rowgroup(&mut self) -> &mut TableRowGroupFlow {
|
2015-08-18 16:31:57 +03:00
|
|
|
|
panic!("called as_mut_table_rowgroup() on a non-tablerowgroup flow")
|
servo: Merge #1973 - Support fixed-layout table and a part of anonymous table object (from june0cho:table_rebase); r=larsbergstrom,metajack
This is a rebase of #1548 on recent master.
There have been many changes since #1548 is first uploaded, so I'm creating new PR.
This PR includes:
- construction of table-* flows (table-wrapper, table-caption, table, table-rowgroup, table-row, table-cell)
- fixed-layout table calculation
- a part of anonymous table object implementation
[CSS 2.1, 17.2.1](http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes) (Step 1-1, 1-2, Step 2)
Source-Repo: https://github.com/servo/servo
Source-Revision: fd5e5cd18b41f0ce2b33fb97fb4e3d75ddbbbceb
2014-03-25 21:40:47 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// If this is a table rowgroup flow, returns the underlying object. Fails otherwise.
|
2015-09-04 16:59:04 +03:00
|
|
|
|
fn as_table_rowgroup(&self) -> &TableRowGroupFlow {
|
2014-11-13 06:48:31 +03:00
|
|
|
|
panic!("called as_table_rowgroup() on a non-tablerowgroup flow")
|
servo: Merge #1973 - Support fixed-layout table and a part of anonymous table object (from june0cho:table_rebase); r=larsbergstrom,metajack
This is a rebase of #1548 on recent master.
There have been many changes since #1548 is first uploaded, so I'm creating new PR.
This PR includes:
- construction of table-* flows (table-wrapper, table-caption, table, table-rowgroup, table-row, table-cell)
- fixed-layout table calculation
- a part of anonymous table object implementation
[CSS 2.1, 17.2.1](http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes) (Step 1-1, 1-2, Step 2)
Source-Repo: https://github.com/servo/servo
Source-Revision: fd5e5cd18b41f0ce2b33fb97fb4e3d75ddbbbceb
2014-03-25 21:40:47 +04:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-18 16:31:57 +03:00
|
|
|
|
/// If this is a table row flow, returns the underlying object, borrowed mutably. Fails
|
2014-09-20 06:50:47 +04:00
|
|
|
|
/// otherwise.
|
2015-09-04 16:59:04 +03:00
|
|
|
|
fn as_mut_table_row(&mut self) -> &mut TableRowFlow {
|
2015-08-18 16:31:57 +03:00
|
|
|
|
panic!("called as_mut_table_row() on a non-tablerow flow")
|
2014-09-20 06:50:47 +04:00
|
|
|
|
}
|
|
|
|
|
|
servo: Merge #1973 - Support fixed-layout table and a part of anonymous table object (from june0cho:table_rebase); r=larsbergstrom,metajack
This is a rebase of #1548 on recent master.
There have been many changes since #1548 is first uploaded, so I'm creating new PR.
This PR includes:
- construction of table-* flows (table-wrapper, table-caption, table, table-rowgroup, table-row, table-cell)
- fixed-layout table calculation
- a part of anonymous table object implementation
[CSS 2.1, 17.2.1](http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes) (Step 1-1, 1-2, Step 2)
Source-Repo: https://github.com/servo/servo
Source-Revision: fd5e5cd18b41f0ce2b33fb97fb4e3d75ddbbbceb
2014-03-25 21:40:47 +04:00
|
|
|
|
/// If this is a table row flow, returns the underlying object. Fails otherwise.
|
2015-09-04 16:59:04 +03:00
|
|
|
|
fn as_table_row(&self) -> &TableRowFlow {
|
2014-11-13 06:48:31 +03:00
|
|
|
|
panic!("called as_table_row() on a non-tablerow flow")
|
servo: Merge #1973 - Support fixed-layout table and a part of anonymous table object (from june0cho:table_rebase); r=larsbergstrom,metajack
This is a rebase of #1548 on recent master.
There have been many changes since #1548 is first uploaded, so I'm creating new PR.
This PR includes:
- construction of table-* flows (table-wrapper, table-caption, table, table-rowgroup, table-row, table-cell)
- fixed-layout table calculation
- a part of anonymous table object implementation
[CSS 2.1, 17.2.1](http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes) (Step 1-1, 1-2, Step 2)
Source-Repo: https://github.com/servo/servo
Source-Revision: fd5e5cd18b41f0ce2b33fb97fb4e3d75ddbbbceb
2014-03-25 21:40:47 +04:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-18 16:31:57 +03:00
|
|
|
|
/// If this is a table cell flow, returns the underlying object, borrowed mutably. Fails
|
2014-09-20 06:50:47 +04:00
|
|
|
|
/// otherwise.
|
2015-09-04 16:59:04 +03:00
|
|
|
|
fn as_mut_table_caption(&mut self) -> &mut TableCaptionFlow {
|
2015-08-18 16:31:57 +03:00
|
|
|
|
panic!("called as_mut_table_caption() on a non-tablecaption flow")
|
servo: Merge #1973 - Support fixed-layout table and a part of anonymous table object (from june0cho:table_rebase); r=larsbergstrom,metajack
This is a rebase of #1548 on recent master.
There have been many changes since #1548 is first uploaded, so I'm creating new PR.
This PR includes:
- construction of table-* flows (table-wrapper, table-caption, table, table-rowgroup, table-row, table-cell)
- fixed-layout table calculation
- a part of anonymous table object implementation
[CSS 2.1, 17.2.1](http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes) (Step 1-1, 1-2, Step 2)
Source-Repo: https://github.com/servo/servo
Source-Revision: fd5e5cd18b41f0ce2b33fb97fb4e3d75ddbbbceb
2014-03-25 21:40:47 +04:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-18 16:31:57 +03:00
|
|
|
|
/// If this is a table cell flow, returns the underlying object, borrowed mutably. Fails
|
|
|
|
|
/// otherwise.
|
2015-09-04 16:59:04 +03:00
|
|
|
|
fn as_mut_table_cell(&mut self) -> &mut TableCellFlow {
|
2015-08-18 16:31:57 +03:00
|
|
|
|
panic!("called as_mut_table_cell() on a non-tablecell flow")
|
servo: Merge #1973 - Support fixed-layout table and a part of anonymous table object (from june0cho:table_rebase); r=larsbergstrom,metajack
This is a rebase of #1548 on recent master.
There have been many changes since #1548 is first uploaded, so I'm creating new PR.
This PR includes:
- construction of table-* flows (table-wrapper, table-caption, table, table-rowgroup, table-row, table-cell)
- fixed-layout table calculation
- a part of anonymous table object implementation
[CSS 2.1, 17.2.1](http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes) (Step 1-1, 1-2, Step 2)
Source-Repo: https://github.com/servo/servo
Source-Revision: fd5e5cd18b41f0ce2b33fb97fb4e3d75ddbbbceb
2014-03-25 21:40:47 +04:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-18 16:31:57 +03:00
|
|
|
|
/// If this is a multicol flow, returns the underlying object, borrowed mutably. Fails
|
|
|
|
|
/// otherwise.
|
2015-09-04 16:59:04 +03:00
|
|
|
|
fn as_mut_multicol(&mut self) -> &mut MulticolFlow {
|
2015-08-18 16:31:57 +03:00
|
|
|
|
panic!("called as_mut_multicol() on a non-multicol flow")
|
2015-04-29 03:48:45 +03:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-18 16:31:57 +03:00
|
|
|
|
/// If this is a table cell flow, returns the underlying object. Fails otherwise.
|
2015-09-04 16:59:04 +03:00
|
|
|
|
fn as_table_cell(&self) -> &TableCellFlow {
|
2014-11-13 06:48:31 +03:00
|
|
|
|
panic!("called as_table_cell() on a non-tablecell flow")
|
2014-09-20 06:50:47 +04:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 00:31:44 +04:00
|
|
|
|
// Main methods
|
2013-08-09 20:42:36 +04:00
|
|
|
|
|
2014-07-19 00:27:23 +04:00
|
|
|
|
/// Pass 1 of reflow: computes minimum and preferred inline-sizes.
|
2014-05-03 03:10:20 +04:00
|
|
|
|
///
|
2014-10-14 04:03:40 +04:00
|
|
|
|
/// Recursively (bottom-up) determine the flow's minimum and preferred inline-sizes. When
|
|
|
|
|
/// called on this flow, all child flows have had their minimum and preferred inline-sizes set.
|
|
|
|
|
/// This function must decide minimum/preferred inline-sizes based on its children's inline-
|
|
|
|
|
/// sizes and the dimensions of any boxes it is responsible for flowing.
|
2014-10-15 00:06:36 +04:00
|
|
|
|
fn bubble_inline_sizes(&mut self) {
|
2014-11-13 06:48:31 +03:00
|
|
|
|
panic!("bubble_inline_sizes not yet implemented")
|
2013-08-09 20:42:36 +04:00
|
|
|
|
}
|
2013-05-22 23:57:28 +04:00
|
|
|
|
|
2014-07-19 00:27:23 +04:00
|
|
|
|
/// Pass 2 of reflow: computes inline-size.
|
2017-02-08 04:16:05 +03:00
|
|
|
|
fn assign_inline_sizes(&mut self, _ctx: &LayoutContext) {
|
2014-11-13 06:48:31 +03:00
|
|
|
|
panic!("assign_inline_sizes not yet implemented")
|
2013-10-29 00:31:44 +04:00
|
|
|
|
}
|
2013-05-22 23:57:28 +04:00
|
|
|
|
|
2014-07-19 00:27:23 +04:00
|
|
|
|
/// Pass 3a of reflow: computes block-size.
|
2017-02-08 04:16:05 +03:00
|
|
|
|
fn assign_block_size(&mut self, _ctx: &LayoutContext) {
|
2014-11-13 06:48:31 +03:00
|
|
|
|
panic!("assign_block_size not yet implemented")
|
2013-10-29 00:31:44 +04:00
|
|
|
|
}
|
2013-05-22 23:57:28 +04:00
|
|
|
|
|
2016-01-29 22:19:14 +03:00
|
|
|
|
/// Like `assign_block_size`, but is recurses explicitly into descendants.
|
|
|
|
|
/// Fit as much content as possible within `available_block_size`.
|
|
|
|
|
/// If that’s not all of it, truncate the contents of `self`
|
|
|
|
|
/// and return a new flow similar to `self` with the rest of the content.
|
|
|
|
|
///
|
|
|
|
|
/// The default is to make a flow "atomic": it can not be fragmented.
|
|
|
|
|
fn fragment(&mut self,
|
|
|
|
|
layout_context: &LayoutContext,
|
|
|
|
|
_fragmentation_context: Option<FragmentationContext>)
|
2016-11-05 00:53:38 +03:00
|
|
|
|
-> Option<Arc<Flow>> {
|
2017-12-15 21:44:50 +03:00
|
|
|
|
fn recursive_assign_block_size<F: ?Sized + Flow + GetBaseFlow>(flow: &mut F, ctx: &LayoutContext) {
|
|
|
|
|
for child in flow.mut_base().child_iter_mut() {
|
2016-01-29 22:19:14 +03:00
|
|
|
|
recursive_assign_block_size(child, ctx)
|
|
|
|
|
}
|
|
|
|
|
flow.assign_block_size(ctx);
|
|
|
|
|
}
|
|
|
|
|
recursive_assign_block_size(self, layout_context);
|
|
|
|
|
None
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-15 22:43:40 +03:00
|
|
|
|
fn collect_stacking_contexts(&mut self, state: &mut StackingContextCollectionState);
|
2016-03-02 03:51:08 +03:00
|
|
|
|
|
2014-11-19 02:39:25 +03:00
|
|
|
|
/// If this is a float, places it. The default implementation does nothing.
|
2016-06-20 16:17:13 +03:00
|
|
|
|
fn place_float_if_applicable<'a>(&mut self) {}
|
2014-11-19 02:39:25 +03:00
|
|
|
|
|
2014-07-19 00:27:23 +04:00
|
|
|
|
/// Assigns block-sizes in-order; or, if this is a float, places the float. The default
|
2016-03-26 04:38:41 +03:00
|
|
|
|
/// implementation simply assigns block-sizes if this flow might have floats in. Returns true
|
|
|
|
|
/// if it was determined that this child might have had floats in or false otherwise.
|
2015-02-21 09:06:48 +03:00
|
|
|
|
///
|
|
|
|
|
/// `parent_thread_id` is the thread ID of the parent. This is used for the layout tinting
|
|
|
|
|
/// debug mode; if the block size of this flow was determined by its parent, we should treat
|
|
|
|
|
/// it as laid out by its parent.
|
2017-02-08 04:16:05 +03:00
|
|
|
|
fn assign_block_size_for_inorder_child_if_necessary(&mut self,
|
|
|
|
|
layout_context: &LayoutContext,
|
|
|
|
|
parent_thread_id: u8,
|
|
|
|
|
_content_box: LogicalRect<Au>)
|
|
|
|
|
-> bool {
|
2017-12-15 21:44:50 +03:00
|
|
|
|
let might_have_floats_in_or_out = self.base().might_have_floats_in() ||
|
|
|
|
|
self.base().might_have_floats_out();
|
2016-03-26 04:38:41 +03:00
|
|
|
|
if might_have_floats_in_or_out {
|
2017-12-15 21:44:50 +03:00
|
|
|
|
self.mut_base().thread_id = parent_thread_id;
|
2014-07-19 00:27:23 +04:00
|
|
|
|
self.assign_block_size(layout_context);
|
2017-12-15 21:44:50 +03:00
|
|
|
|
self.mut_base().restyle_damage.remove(ServoRestyleDamage::REFLOW_OUT_OF_FLOW | ServoRestyleDamage::REFLOW);
|
2014-05-03 03:10:20 +04:00
|
|
|
|
}
|
2016-03-26 04:38:41 +03:00
|
|
|
|
might_have_floats_in_or_out
|
2014-05-03 03:10:20 +04:00
|
|
|
|
}
|
|
|
|
|
|
2017-01-17 18:18:42 +03:00
|
|
|
|
fn get_overflow_in_parent_coordinates(&self) -> Overflow {
|
|
|
|
|
// FIXME(#2795): Get the real container size.
|
|
|
|
|
let container_size = Size2D::zero();
|
2017-12-15 21:44:50 +03:00
|
|
|
|
let position = self.base().position.to_physical(self.base().writing_mode, container_size);
|
2017-01-17 18:18:42 +03:00
|
|
|
|
|
2017-12-15 21:44:50 +03:00
|
|
|
|
let mut overflow = self.base().overflow;
|
2017-01-17 18:18:42 +03:00
|
|
|
|
|
|
|
|
|
match self.class() {
|
|
|
|
|
FlowClass::Block | FlowClass::TableCaption | FlowClass::TableCell => {}
|
|
|
|
|
_ => {
|
2017-06-14 17:25:05 +03:00
|
|
|
|
overflow.translate(&position.origin.to_vector());
|
2017-01-17 18:18:42 +03:00
|
|
|
|
return overflow;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-18 00:08:00 +03:00
|
|
|
|
let border_box = self.as_block().fragment.stacking_relative_border_box(
|
2017-12-15 21:44:50 +03:00
|
|
|
|
&self.base().stacking_relative_position,
|
|
|
|
|
&self.base().early_absolute_position_info.relative_containing_block_size,
|
|
|
|
|
self.base().early_absolute_position_info.relative_containing_block_mode,
|
2017-04-18 00:08:00 +03:00
|
|
|
|
CoordinateSystem::Own);
|
2017-12-06 04:35:25 +03:00
|
|
|
|
if StyleOverflow::Visible != self.as_block().fragment.style.get_box().overflow_x {
|
2017-04-18 00:08:00 +03:00
|
|
|
|
overflow.paint.origin.x = Au(0);
|
|
|
|
|
overflow.paint.size.width = border_box.size.width;
|
|
|
|
|
overflow.scroll.origin.x = Au(0);
|
|
|
|
|
overflow.scroll.size.width = border_box.size.width;
|
|
|
|
|
}
|
2017-12-06 04:35:25 +03:00
|
|
|
|
if StyleOverflow::Visible != self.as_block().fragment.style.get_box().overflow_y {
|
2017-04-18 00:08:00 +03:00
|
|
|
|
overflow.paint.origin.y = Au(0);
|
|
|
|
|
overflow.paint.size.height = border_box.size.height;
|
|
|
|
|
overflow.scroll.origin.y = Au(0);
|
|
|
|
|
overflow.scroll.size.height = border_box.size.height;
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-17 18:18:42 +03:00
|
|
|
|
if !self.as_block().fragment.establishes_stacking_context() ||
|
2017-11-03 01:02:07 +03:00
|
|
|
|
self.as_block().fragment.style.get_box().transform.0.is_empty() {
|
2017-06-14 17:25:05 +03:00
|
|
|
|
overflow.translate(&position.origin.to_vector());
|
2017-01-17 18:18:42 +03:00
|
|
|
|
return overflow;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO: Take into account 3d transforms, even though it's a fairly
|
|
|
|
|
// uncommon case.
|
2017-03-03 04:02:26 +03:00
|
|
|
|
let transform_2d = self.as_block()
|
|
|
|
|
.fragment
|
|
|
|
|
.transform_matrix(&position)
|
2018-02-24 18:06:16 +03:00
|
|
|
|
.unwrap_or(LayoutTransform::identity())
|
|
|
|
|
.to_2d().to_untyped();
|
2017-01-17 18:18:42 +03:00
|
|
|
|
let transformed_overflow = Overflow {
|
|
|
|
|
paint: f32_rect_to_au_rect(transform_2d.transform_rect(
|
|
|
|
|
&au_rect_to_f32_rect(overflow.paint))),
|
|
|
|
|
scroll: f32_rect_to_au_rect(transform_2d.transform_rect(
|
|
|
|
|
&au_rect_to_f32_rect(overflow.scroll))),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// TODO: We are taking the union of the overflow and transformed overflow here, which
|
|
|
|
|
// happened implicitly in the previous version of this code. This will probably be
|
|
|
|
|
// unnecessary once we are taking into account 3D transformations above.
|
|
|
|
|
overflow.union(&transformed_overflow);
|
|
|
|
|
|
2017-06-14 17:25:05 +03:00
|
|
|
|
overflow.translate(&position.origin.to_vector());
|
2017-01-17 18:18:42 +03:00
|
|
|
|
overflow
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-12 00:08:46 +03:00
|
|
|
|
///
|
|
|
|
|
/// CSS Section 11.1
|
|
|
|
|
/// This is the union of rectangles of the flows for which we define the
|
|
|
|
|
/// Containing Block.
|
|
|
|
|
///
|
|
|
|
|
/// FIXME(pcwalton): This should not be a virtual method, but currently is due to a compiler
|
|
|
|
|
/// bug ("the trait `Sized` is not implemented for `self`").
|
|
|
|
|
///
|
|
|
|
|
/// Assumption: This is called in a bottom-up traversal, so kids' overflows have
|
|
|
|
|
/// already been set.
|
|
|
|
|
/// Assumption: Absolute descendants have had their overflow calculated.
|
|
|
|
|
fn store_overflow(&mut self, _: &LayoutContext) {
|
|
|
|
|
// Calculate overflow on a per-fragment basis.
|
|
|
|
|
let mut overflow = self.compute_overflow();
|
|
|
|
|
match self.class() {
|
|
|
|
|
FlowClass::Block |
|
|
|
|
|
FlowClass::TableCaption |
|
2015-09-01 21:33:07 +03:00
|
|
|
|
FlowClass::TableCell => {
|
2017-12-15 21:44:50 +03:00
|
|
|
|
for kid in self.mut_base().children.iter_mut() {
|
2017-04-18 00:08:00 +03:00
|
|
|
|
overflow.union(&kid.get_overflow_in_parent_coordinates());
|
2015-05-12 00:08:46 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_ => {}
|
|
|
|
|
}
|
2017-12-15 21:44:50 +03:00
|
|
|
|
self.mut_base().overflow = overflow
|
2015-05-12 00:08:46 +03:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-08 22:04:23 +03:00
|
|
|
|
/// Phase 4 of reflow: Compute the stacking-relative position (origin of the content box,
|
|
|
|
|
/// in coordinates relative to the nearest ancestor stacking context).
|
|
|
|
|
fn compute_stacking_relative_position(&mut self, _: &LayoutContext) {
|
2014-05-03 03:10:20 +04:00
|
|
|
|
// The default implementation is a no-op.
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-22 20:54:35 +04:00
|
|
|
|
/// Phase 5 of reflow: builds display lists.
|
2016-03-02 03:51:08 +03:00
|
|
|
|
fn build_display_list(&mut self, state: &mut DisplayListBuildState);
|
2014-10-22 20:54:35 +04:00
|
|
|
|
|
2015-01-05 04:51:48 +03:00
|
|
|
|
/// Returns the union of all overflow rects of all of this flow's fragments.
|
2016-02-05 08:28:50 +03:00
|
|
|
|
fn compute_overflow(&self) -> Overflow;
|
2015-01-05 04:51:48 +03:00
|
|
|
|
|
|
|
|
|
/// Iterates through border boxes of all of this flow's fragments.
|
2015-08-04 03:39:43 +03:00
|
|
|
|
/// Level provides a zero based index indicating the current
|
|
|
|
|
/// depth of the flow tree during fragment iteration.
|
2015-01-05 04:51:48 +03:00
|
|
|
|
fn iterate_through_fragment_border_boxes(&self,
|
|
|
|
|
iterator: &mut FragmentBorderBoxIterator,
|
2015-08-04 03:39:43 +03:00
|
|
|
|
level: i32,
|
2015-01-05 04:51:48 +03:00
|
|
|
|
stacking_context_position: &Point2D<Au>);
|
2014-11-03 22:03:37 +03:00
|
|
|
|
|
2015-03-10 08:24:47 +03:00
|
|
|
|
/// Mutably iterates through fragments in this flow.
|
|
|
|
|
fn mutate_fragments(&mut self, mutator: &mut FnMut(&mut Fragment));
|
|
|
|
|
|
|
|
|
|
fn compute_collapsible_block_start_margin(&mut self,
|
|
|
|
|
_layout_context: &mut LayoutContext,
|
|
|
|
|
_margin_collapse_info: &mut MarginCollapseInfo) {
|
|
|
|
|
// The default implementation is a no-op.
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-18 23:54:00 +04:00
|
|
|
|
/// Marks this flow as the root flow. The default implementation is a no-op.
|
2015-07-31 11:10:40 +03:00
|
|
|
|
fn mark_as_root(&mut self) {
|
|
|
|
|
debug!("called mark_as_root() on a flow of type {:?}", self.class());
|
|
|
|
|
panic!("called mark_as_root() on an unhandled flow");
|
|
|
|
|
}
|
2013-11-18 23:54:00 +04:00
|
|
|
|
|
2014-03-03 22:37:33 +04:00
|
|
|
|
// Note that the following functions are mostly called using static method
|
|
|
|
|
// dispatch, so it's ok to have them in this trait. Plus, they have
|
|
|
|
|
// different behaviour for different types of Flow, so they can't go into
|
|
|
|
|
// the Immutable / Mutable Flow Utils traits without additional casts.
|
|
|
|
|
|
|
|
|
|
fn is_root(&self) -> bool {
|
|
|
|
|
false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// The 'position' property of this flow.
|
2017-12-06 04:35:25 +03:00
|
|
|
|
fn positioning(&self) -> Position {
|
|
|
|
|
Position::Static
|
2014-03-03 22:37:33 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Return true if this flow has position 'fixed'.
|
|
|
|
|
fn is_fixed(&self) -> bool {
|
2017-12-06 04:35:25 +03:00
|
|
|
|
self.positioning() == Position::Fixed
|
2014-03-03 22:37:33 +04:00
|
|
|
|
}
|
|
|
|
|
|
2015-05-13 22:27:21 +03:00
|
|
|
|
fn contains_positioned_fragments(&self) -> bool {
|
|
|
|
|
self.contains_relatively_positioned_fragments() ||
|
2017-12-15 21:44:50 +03:00
|
|
|
|
self.base().flags.contains(FlowFlags::IS_ABSOLUTELY_POSITIONED)
|
2014-03-03 22:37:33 +04:00
|
|
|
|
}
|
|
|
|
|
|
2015-05-13 22:27:21 +03:00
|
|
|
|
fn contains_relatively_positioned_fragments(&self) -> bool {
|
2017-12-06 04:35:25 +03:00
|
|
|
|
self.positioning() == Position::Relative
|
2014-03-03 22:37:33 +04:00
|
|
|
|
}
|
|
|
|
|
|
2014-04-04 05:01:48 +04:00
|
|
|
|
/// Returns true if this is an absolute containing block.
|
|
|
|
|
fn is_absolute_containing_block(&self) -> bool {
|
2017-08-17 03:18:48 +03:00
|
|
|
|
self.contains_positioned_fragments()
|
2014-04-04 05:01:48 +04:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-18 03:42:20 +03:00
|
|
|
|
/// Returns true if this flow contains fragments that are roots of an absolute flow tree.
|
|
|
|
|
fn contains_roots_of_absolute_flow_tree(&self) -> bool {
|
|
|
|
|
self.contains_relatively_positioned_fragments() || self.is_root()
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-02 05:36:25 +04:00
|
|
|
|
/// Updates the inline position of a child flow during the assign-height traversal. At present,
|
|
|
|
|
/// this is only used for absolutely-positioned inline-blocks.
|
|
|
|
|
fn update_late_computed_inline_position_if_necessary(&mut self, inline_position: Au);
|
|
|
|
|
|
|
|
|
|
/// Updates the block position of a child flow during the assign-height traversal. At present,
|
|
|
|
|
/// this is only used for absolutely-positioned inline-blocks.
|
|
|
|
|
fn update_late_computed_block_position_if_necessary(&mut self, block_position: Au);
|
|
|
|
|
|
2015-05-13 22:27:21 +03:00
|
|
|
|
/// Return the size of the containing block generated by this flow for the absolutely-
|
|
|
|
|
/// positioned descendant referenced by `for_flow`. For block flows, this is the padding box.
|
2014-12-13 01:57:46 +03:00
|
|
|
|
///
|
|
|
|
|
/// NB: Do not change this `&self` to `&mut self` under any circumstances! It has security
|
|
|
|
|
/// implications because this can be called on parents concurrently from descendants!
|
2015-05-13 22:27:21 +03:00
|
|
|
|
fn generated_containing_block_size(&self, _: OpaqueFlow) -> LogicalSize<Au>;
|
2014-03-03 22:37:33 +04:00
|
|
|
|
|
2014-10-31 23:39:34 +03:00
|
|
|
|
/// Attempts to perform incremental fixup of this flow by replacing its fragment's style with
|
|
|
|
|
/// the new style. This can only succeed if the flow has exactly one fragment.
|
2017-07-19 16:03:17 +03:00
|
|
|
|
fn repair_style(&mut self, new_style: &::ServoArc<ComputedValues>);
|
2015-11-24 05:19:07 +03:00
|
|
|
|
|
|
|
|
|
/// Print any extra children (such as fragments) contained in this Flow
|
|
|
|
|
/// for debugging purposes. Any items inserted into the tree will become
|
|
|
|
|
/// children of this flow.
|
2016-12-07 01:42:00 +03:00
|
|
|
|
fn print_extra_flow_children(&self, _: &mut PrintTree) { }
|
|
|
|
|
|
2017-10-24 17:46:08 +03:00
|
|
|
|
fn clipping_and_scrolling(&self) -> ClippingAndScrolling {
|
2017-12-15 21:44:50 +03:00
|
|
|
|
match self.base().clipping_and_scrolling {
|
2017-08-04 19:17:24 +03:00
|
|
|
|
Some(info) => info,
|
2017-10-24 17:46:08 +03:00
|
|
|
|
None => unreachable!("Tried to access scroll root id on Flow before assignment"),
|
2017-04-20 09:55:33 +03:00
|
|
|
|
}
|
2015-11-24 05:19:07 +03:00
|
|
|
|
}
|
2013-05-22 23:57:28 +04:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 00:31:44 +04:00
|
|
|
|
pub trait ImmutableFlowUtils {
|
|
|
|
|
// Convenience functions
|
|
|
|
|
|
2015-04-27 20:29:15 +03:00
|
|
|
|
/// Returns true if this flow is a block flow or subclass thereof.
|
2013-10-29 00:31:44 +04:00
|
|
|
|
fn is_block_like(self) -> bool;
|
|
|
|
|
|
servo: Merge #1973 - Support fixed-layout table and a part of anonymous table object (from june0cho:table_rebase); r=larsbergstrom,metajack
This is a rebase of #1548 on recent master.
There have been many changes since #1548 is first uploaded, so I'm creating new PR.
This PR includes:
- construction of table-* flows (table-wrapper, table-caption, table, table-rowgroup, table-row, table-cell)
- fixed-layout table calculation
- a part of anonymous table object implementation
[CSS 2.1, 17.2.1](http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes) (Step 1-1, 1-2, Step 2)
Source-Repo: https://github.com/servo/servo
Source-Revision: fd5e5cd18b41f0ce2b33fb97fb4e3d75ddbbbceb
2014-03-25 21:40:47 +04:00
|
|
|
|
/// Returns true if this flow is a table flow.
|
|
|
|
|
fn is_table(self) -> bool;
|
|
|
|
|
|
|
|
|
|
/// Returns true if this flow is a table caption flow.
|
|
|
|
|
fn is_table_caption(self) -> bool;
|
|
|
|
|
|
|
|
|
|
/// Returns true if this flow is a proper table child.
|
|
|
|
|
fn is_proper_table_child(self) -> bool;
|
|
|
|
|
|
|
|
|
|
/// Returns true if this flow is a table row flow.
|
|
|
|
|
fn is_table_row(self) -> bool;
|
|
|
|
|
|
|
|
|
|
/// Returns true if this flow is a table cell flow.
|
|
|
|
|
fn is_table_cell(self) -> bool;
|
|
|
|
|
|
|
|
|
|
/// Returns true if this flow is a table colgroup flow.
|
|
|
|
|
fn is_table_colgroup(self) -> bool;
|
|
|
|
|
|
|
|
|
|
/// Returns true if this flow is a table rowgroup flow.
|
|
|
|
|
fn is_table_rowgroup(self) -> bool;
|
|
|
|
|
|
|
|
|
|
/// Returns true if this flow is one of table-related flows.
|
|
|
|
|
fn is_table_kind(self) -> bool;
|
|
|
|
|
|
2013-10-29 00:31:44 +04:00
|
|
|
|
/// Returns true if this flow has no children.
|
|
|
|
|
fn is_leaf(self) -> bool;
|
|
|
|
|
|
2014-01-23 04:04:08 +04:00
|
|
|
|
/// Returns the number of children that this flow possesses.
|
2015-04-02 17:06:41 +03:00
|
|
|
|
fn child_count(self) -> usize;
|
2014-01-23 04:04:08 +04:00
|
|
|
|
|
2014-02-05 02:52:39 +04:00
|
|
|
|
/// Return true if this flow is a Block Container.
|
|
|
|
|
fn is_block_container(self) -> bool;
|
|
|
|
|
|
2014-02-19 01:17:07 +04:00
|
|
|
|
/// Returns true if this flow is a block flow.
|
|
|
|
|
fn is_block_flow(self) -> bool;
|
2013-10-29 00:31:44 +04:00
|
|
|
|
|
|
|
|
|
/// Returns true if this flow is an inline flow.
|
2014-02-19 01:17:07 +04:00
|
|
|
|
fn is_inline_flow(self) -> bool;
|
2013-10-29 00:31:44 +04:00
|
|
|
|
|
|
|
|
|
/// Dumps the flow tree for debugging.
|
2015-11-24 05:19:07 +03:00
|
|
|
|
fn print(self, title: String);
|
2013-11-11 11:07:23 +04:00
|
|
|
|
|
2015-11-24 05:19:07 +03:00
|
|
|
|
/// Dumps the flow tree for debugging into the given PrintTree.
|
|
|
|
|
fn print_with_tree(self, print_tree: &mut PrintTree);
|
2016-03-26 04:38:41 +03:00
|
|
|
|
|
|
|
|
|
/// Returns true if floats might flow through this flow, as determined by the float placement
|
|
|
|
|
/// speculation pass.
|
|
|
|
|
fn floats_might_flow_through(self) -> bool;
|
2016-05-04 23:49:23 +03:00
|
|
|
|
|
|
|
|
|
fn baseline_offset_of_last_line_box_in_flow(self) -> Option<Au>;
|
2013-10-29 00:31:44 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub trait MutableFlowUtils {
|
2015-04-01 21:03:45 +03:00
|
|
|
|
/// Calls `repair_style` and `bubble_inline_sizes`. You should use this method instead of
|
|
|
|
|
/// calling them individually, since there is no reason not to perform both operations.
|
2017-07-19 16:03:17 +03:00
|
|
|
|
fn repair_style_and_bubble_inline_sizes(self, style: &::ServoArc<ComputedValues>);
|
2013-10-29 00:31:44 +04:00
|
|
|
|
}
|
|
|
|
|
|
2014-01-23 04:04:08 +04:00
|
|
|
|
pub trait MutableOwnedFlowUtils {
|
2014-03-03 22:37:33 +04:00
|
|
|
|
/// Set absolute descendants for this flow.
|
|
|
|
|
///
|
|
|
|
|
/// Set this flow as the Containing Block for all the absolute descendants.
|
2015-08-17 22:56:53 +03:00
|
|
|
|
fn set_absolute_descendants(&mut self, abs_descendants: AbsoluteDescendants);
|
2015-09-02 01:36:58 +03:00
|
|
|
|
|
|
|
|
|
/// Sets the flow as the containing block for all absolute descendants that have been marked
|
|
|
|
|
/// as having reached their containing block. This is needed in order to handle cases like:
|
|
|
|
|
///
|
2018-01-20 17:51:27 +03:00
|
|
|
|
/// ```html
|
|
|
|
|
/// <div>
|
|
|
|
|
/// <span style="position: relative">
|
|
|
|
|
/// <span style="position: absolute; ..."></span>
|
|
|
|
|
/// </span>
|
|
|
|
|
/// </div>
|
|
|
|
|
/// ```
|
2015-09-02 01:36:58 +03:00
|
|
|
|
fn take_applicable_absolute_descendants(&mut self,
|
|
|
|
|
absolute_descendants: &mut AbsoluteDescendants);
|
2014-01-23 04:04:08 +04:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-24 01:18:31 +03:00
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Serialize)]
|
2013-10-29 00:31:44 +04:00
|
|
|
|
pub enum FlowClass {
|
2014-12-18 04:45:49 +03:00
|
|
|
|
Block,
|
|
|
|
|
Inline,
|
|
|
|
|
ListItem,
|
|
|
|
|
TableWrapper,
|
|
|
|
|
Table,
|
|
|
|
|
TableColGroup,
|
|
|
|
|
TableRowGroup,
|
|
|
|
|
TableRow,
|
|
|
|
|
TableCaption,
|
|
|
|
|
TableCell,
|
2015-04-29 03:48:45 +03:00
|
|
|
|
Multicol,
|
2016-01-29 22:19:14 +03:00
|
|
|
|
MulticolColumn,
|
2015-08-22 02:19:20 +03:00
|
|
|
|
Flex,
|
2013-08-20 23:03:52 +04:00
|
|
|
|
}
|
2013-08-17 02:46:03 +04:00
|
|
|
|
|
2016-03-26 04:38:41 +03:00
|
|
|
|
impl FlowClass {
|
|
|
|
|
fn is_block_like(self) -> bool {
|
|
|
|
|
match self {
|
|
|
|
|
FlowClass::Block | FlowClass::ListItem | FlowClass::Table | FlowClass::TableRowGroup |
|
|
|
|
|
FlowClass::TableRow | FlowClass::TableCaption | FlowClass::TableCell |
|
2016-07-11 19:31:03 +03:00
|
|
|
|
FlowClass::TableWrapper | FlowClass::Flex => true,
|
2016-03-26 04:38:41 +03:00
|
|
|
|
_ => false,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-18 21:42:32 +03:00
|
|
|
|
bitflags! {
|
|
|
|
|
#[doc = "Flags used in flows."]
|
2017-10-31 02:25:45 +03:00
|
|
|
|
pub struct FlowFlags: u32 {
|
2014-11-18 21:42:32 +03:00
|
|
|
|
// text align flags
|
|
|
|
|
#[doc = "Whether this flow is absolutely positioned. This is checked all over layout, so a"]
|
|
|
|
|
#[doc = "virtual call is too expensive."]
|
2017-10-31 02:25:45 +03:00
|
|
|
|
const IS_ABSOLUTELY_POSITIONED = 0b0000_0000_0000_0000_0100_0000;
|
2014-11-18 21:42:32 +03:00
|
|
|
|
#[doc = "Whether this flow clears to the left. This is checked all over layout, so a"]
|
|
|
|
|
#[doc = "virtual call is too expensive."]
|
2017-10-31 02:25:45 +03:00
|
|
|
|
const CLEARS_LEFT = 0b0000_0000_0000_0000_1000_0000;
|
2014-11-18 21:42:32 +03:00
|
|
|
|
#[doc = "Whether this flow clears to the right. This is checked all over layout, so a"]
|
|
|
|
|
#[doc = "virtual call is too expensive."]
|
2017-10-31 02:25:45 +03:00
|
|
|
|
const CLEARS_RIGHT = 0b0000_0000_0000_0001_0000_0000;
|
2014-11-18 21:42:32 +03:00
|
|
|
|
#[doc = "Whether this flow is left-floated. This is checked all over layout, so a"]
|
|
|
|
|
#[doc = "virtual call is too expensive."]
|
2017-10-31 02:25:45 +03:00
|
|
|
|
const FLOATS_LEFT = 0b0000_0000_0000_0010_0000_0000;
|
2014-11-18 21:42:32 +03:00
|
|
|
|
#[doc = "Whether this flow is right-floated. This is checked all over layout, so a"]
|
|
|
|
|
#[doc = "virtual call is too expensive."]
|
2017-10-31 02:25:45 +03:00
|
|
|
|
const FLOATS_RIGHT = 0b0000_0000_0000_0100_0000_0000;
|
2014-12-01 22:12:55 +03:00
|
|
|
|
#[doc = "Text alignment. \
|
|
|
|
|
|
|
|
|
|
NB: If you update this, update `TEXT_ALIGN_SHIFT` below."]
|
2017-10-31 02:25:45 +03:00
|
|
|
|
const TEXT_ALIGN = 0b0000_0000_0111_1000_0000_0000;
|
2015-03-10 08:24:47 +03:00
|
|
|
|
#[doc = "Whether this flow has a fragment with `counter-reset` or `counter-increment` \
|
|
|
|
|
styles."]
|
2017-10-31 02:25:45 +03:00
|
|
|
|
const AFFECTS_COUNTERS = 0b0000_0000_1000_0000_0000_0000;
|
2015-03-10 08:24:47 +03:00
|
|
|
|
#[doc = "Whether this flow's descendants have fragments that affect `counter-reset` or \
|
|
|
|
|
`counter-increment` styles."]
|
2017-10-31 02:25:45 +03:00
|
|
|
|
const HAS_COUNTER_AFFECTING_CHILDREN = 0b0000_0001_0000_0000_0000_0000;
|
2015-04-15 02:14:11 +03:00
|
|
|
|
#[doc = "Whether this flow behaves as though it had `position: static` for the purposes \
|
|
|
|
|
of positioning in the inline direction. This is set for flows with `position: \
|
|
|
|
|
static` and `position: relative` as well as absolutely-positioned flows with \
|
|
|
|
|
unconstrained positions in the inline direction."]
|
2017-10-31 02:25:45 +03:00
|
|
|
|
const INLINE_POSITION_IS_STATIC = 0b0000_0010_0000_0000_0000_0000;
|
2015-04-15 02:14:11 +03:00
|
|
|
|
#[doc = "Whether this flow behaves as though it had `position: static` for the purposes \
|
|
|
|
|
of positioning in the block direction. This is set for flows with `position: \
|
|
|
|
|
static` and `position: relative` as well as absolutely-positioned flows with \
|
|
|
|
|
unconstrained positions in the block direction."]
|
2017-10-31 02:25:45 +03:00
|
|
|
|
const BLOCK_POSITION_IS_STATIC = 0b0000_0100_0000_0000_0000_0000;
|
2016-01-29 22:19:14 +03:00
|
|
|
|
|
|
|
|
|
/// Whether any ancestor is a fragmentation container
|
2017-10-31 02:25:45 +03:00
|
|
|
|
const CAN_BE_FRAGMENTED = 0b0000_1000_0000_0000_0000_0000;
|
2016-05-04 23:49:23 +03:00
|
|
|
|
|
|
|
|
|
/// Whether this flow contains any text and/or replaced fragments.
|
2017-10-31 02:25:45 +03:00
|
|
|
|
const CONTAINS_TEXT_OR_REPLACED_FRAGMENTS = 0b0001_0000_0000_0000_0000_0000;
|
2016-10-27 04:14:04 +03:00
|
|
|
|
|
|
|
|
|
/// Whether margins are prohibited from collapsing with this flow.
|
2017-10-31 02:25:45 +03:00
|
|
|
|
const MARGINS_CANNOT_COLLAPSE = 0b0010_0000_0000_0000_0000_0000;
|
2014-11-18 21:42:32 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-12-13 05:58:21 +04:00
|
|
|
|
|
2013-12-17 03:25:12 +04:00
|
|
|
|
/// The number of bits we must shift off to handle the text alignment field.
|
2014-12-01 22:12:55 +03:00
|
|
|
|
///
|
|
|
|
|
/// NB: If you update this, update `TEXT_ALIGN` above.
|
2015-04-02 17:06:41 +03:00
|
|
|
|
static TEXT_ALIGN_SHIFT: usize = 11;
|
2014-04-04 05:01:48 +04:00
|
|
|
|
|
2013-12-17 03:25:12 +04:00
|
|
|
|
impl FlowFlags {
|
|
|
|
|
#[inline]
|
2017-12-06 04:35:25 +03:00
|
|
|
|
pub fn text_align(self) -> TextAlign {
|
|
|
|
|
TextAlign::from_u32((self & FlowFlags::TEXT_ALIGN).bits() >> TEXT_ALIGN_SHIFT).unwrap()
|
2013-12-17 03:25:12 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[inline]
|
2017-12-06 04:35:25 +03:00
|
|
|
|
pub fn set_text_align(&mut self, value: TextAlign) {
|
2017-10-31 02:25:45 +03:00
|
|
|
|
*self = (*self & !FlowFlags::TEXT_ALIGN) |
|
2017-12-18 21:12:52 +03:00
|
|
|
|
FlowFlags::from_bits((value as u32) << TEXT_ALIGN_SHIFT).unwrap();
|
2013-12-17 03:25:12 +04:00
|
|
|
|
}
|
2014-01-23 05:13:03 +04:00
|
|
|
|
|
2014-10-29 05:42:38 +03:00
|
|
|
|
#[inline]
|
2017-12-06 04:35:25 +03:00
|
|
|
|
pub fn float_kind(&self) -> Float {
|
2017-10-31 02:25:45 +03:00
|
|
|
|
if self.contains(FlowFlags::FLOATS_LEFT) {
|
2017-12-06 04:35:25 +03:00
|
|
|
|
Float::Left
|
2017-10-31 02:25:45 +03:00
|
|
|
|
} else if self.contains(FlowFlags::FLOATS_RIGHT) {
|
2017-12-06 04:35:25 +03:00
|
|
|
|
Float::Right
|
2014-10-29 05:42:38 +03:00
|
|
|
|
} else {
|
2017-12-06 04:35:25 +03:00
|
|
|
|
Float::None
|
2014-10-29 05:42:38 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-19 02:39:25 +03:00
|
|
|
|
#[inline]
|
|
|
|
|
pub fn is_float(&self) -> bool {
|
2017-10-31 02:25:45 +03:00
|
|
|
|
self.contains(FlowFlags::FLOATS_LEFT) || self.contains(FlowFlags::FLOATS_RIGHT)
|
2014-11-19 02:39:25 +03:00
|
|
|
|
}
|
|
|
|
|
|
2014-10-29 05:42:38 +03:00
|
|
|
|
#[inline]
|
|
|
|
|
pub fn clears_floats(&self) -> bool {
|
2017-10-31 02:25:45 +03:00
|
|
|
|
self.contains(FlowFlags::CLEARS_LEFT) || self.contains(FlowFlags::CLEARS_RIGHT)
|
2014-10-29 05:42:38 +03:00
|
|
|
|
}
|
2013-12-17 03:25:12 +04:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-17 22:56:53 +03:00
|
|
|
|
/// Absolutely-positioned descendants of this flow.
|
2015-01-28 04:15:50 +03:00
|
|
|
|
#[derive(Clone)]
|
2015-08-17 22:56:53 +03:00
|
|
|
|
pub struct AbsoluteDescendants {
|
2014-06-04 09:25:28 +04:00
|
|
|
|
/// Links to every descendant. This must be private because it is unsafe to leak `FlowRef`s to
|
|
|
|
|
/// layout.
|
2015-08-17 22:56:53 +03:00
|
|
|
|
descendant_links: Vec<AbsoluteDescendantInfo>,
|
2014-03-03 22:37:33 +04:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-17 22:56:53 +03:00
|
|
|
|
impl AbsoluteDescendants {
|
|
|
|
|
pub fn new() -> AbsoluteDescendants {
|
|
|
|
|
AbsoluteDescendants {
|
2014-05-06 05:01:24 +04:00
|
|
|
|
descendant_links: Vec::new(),
|
2014-03-03 22:37:33 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-02 17:06:41 +03:00
|
|
|
|
pub fn len(&self) -> usize {
|
2014-03-03 22:37:33 +04:00
|
|
|
|
self.descendant_links.len()
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-23 04:48:31 +04:00
|
|
|
|
pub fn is_empty(&self) -> bool {
|
|
|
|
|
self.descendant_links.is_empty()
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-04 09:25:28 +04:00
|
|
|
|
pub fn push(&mut self, given_descendant: FlowRef) {
|
2015-08-17 22:56:53 +03:00
|
|
|
|
self.descendant_links.push(AbsoluteDescendantInfo {
|
|
|
|
|
flow: given_descendant,
|
2015-09-02 01:36:58 +03:00
|
|
|
|
has_reached_containing_block: false,
|
2015-08-17 22:56:53 +03:00
|
|
|
|
});
|
2014-03-03 22:37:33 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Push the given descendants on to the existing descendants.
|
|
|
|
|
///
|
|
|
|
|
/// Ignore any static y offsets, because they are None before layout.
|
2015-08-17 22:56:53 +03:00
|
|
|
|
pub fn push_descendants(&mut self, given_descendants: AbsoluteDescendants) {
|
2015-08-18 11:46:46 +03:00
|
|
|
|
for elem in given_descendants.descendant_links {
|
2014-03-03 22:37:33 +04:00
|
|
|
|
self.descendant_links.push(elem);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Return an iterator over the descendant flows.
|
2015-09-04 16:59:04 +03:00
|
|
|
|
pub fn iter(&mut self) -> AbsoluteDescendantIter {
|
2015-08-17 22:56:53 +03:00
|
|
|
|
AbsoluteDescendantIter {
|
2015-02-12 21:06:50 +03:00
|
|
|
|
iter: self.descendant_links.iter_mut(),
|
2014-06-04 09:25:28 +04:00
|
|
|
|
}
|
2014-03-03 22:37:33 +04:00
|
|
|
|
}
|
2015-09-02 01:36:58 +03:00
|
|
|
|
|
|
|
|
|
/// Mark these descendants as having reached their containing block.
|
|
|
|
|
pub fn mark_as_having_reached_containing_block(&mut self) {
|
|
|
|
|
for descendant_info in self.descendant_links.iter_mut() {
|
|
|
|
|
descendant_info.has_reached_containing_block = true
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-03-03 22:37:33 +04:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-02 01:36:58 +03:00
|
|
|
|
/// Information about each absolutely-positioned descendant of the given flow.
|
2015-08-17 22:56:53 +03:00
|
|
|
|
#[derive(Clone)]
|
|
|
|
|
pub struct AbsoluteDescendantInfo {
|
|
|
|
|
/// The absolute descendant flow in question.
|
|
|
|
|
flow: FlowRef,
|
2015-09-02 01:36:58 +03:00
|
|
|
|
|
|
|
|
|
/// Whether the absolute descendant has reached its containing block. This exists so that we
|
|
|
|
|
/// can handle cases like the following:
|
|
|
|
|
///
|
2018-01-20 17:51:27 +03:00
|
|
|
|
/// ```html
|
|
|
|
|
/// <div>
|
|
|
|
|
/// <span id=a style="position: absolute; ...">foo</span>
|
|
|
|
|
/// <span style="position: relative">
|
|
|
|
|
/// <span id=b style="position: absolute; ...">bar</span>
|
|
|
|
|
/// </span>
|
|
|
|
|
/// </div>
|
|
|
|
|
/// ```
|
2015-09-02 01:36:58 +03:00
|
|
|
|
///
|
|
|
|
|
/// When we go to create the `InlineFlow` for the outer `div`, our absolute descendants will
|
|
|
|
|
/// be `a` and `b`. At this point, we need a way to distinguish between the two, because the
|
|
|
|
|
/// containing block for `a` will be different from the containing block for `b`. Specifically,
|
|
|
|
|
/// the latter's containing block is the inline flow itself, while the former's containing
|
|
|
|
|
/// block is going to be some parent of the outer `div`. Hence we need this flag as a way to
|
|
|
|
|
/// distinguish the two; it will be false for `a` and true for `b`.
|
|
|
|
|
has_reached_containing_block: bool,
|
2015-08-17 22:56:53 +03:00
|
|
|
|
}
|
2014-03-03 22:37:33 +04:00
|
|
|
|
|
2015-08-17 22:56:53 +03:00
|
|
|
|
pub struct AbsoluteDescendantIter<'a> {
|
|
|
|
|
iter: IterMut<'a, AbsoluteDescendantInfo>,
|
2014-06-04 09:25:28 +04:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-17 22:56:53 +03:00
|
|
|
|
impl<'a> Iterator for AbsoluteDescendantIter<'a> {
|
2015-08-22 00:29:35 +03:00
|
|
|
|
type Item = &'a mut Flow;
|
|
|
|
|
fn next(&mut self) -> Option<&'a mut Flow> {
|
2016-11-05 00:53:38 +03:00
|
|
|
|
self.iter.next().map(|info| FlowRef::deref_mut(&mut info.flow))
|
2014-06-04 09:25:28 +04:00
|
|
|
|
}
|
2017-09-14 03:38:32 +03:00
|
|
|
|
|
|
|
|
|
fn size_hint(&self) -> (usize, Option<usize>) {
|
|
|
|
|
self.iter.size_hint()
|
|
|
|
|
}
|
2014-06-04 09:25:28 +04:00
|
|
|
|
}
|
2014-03-03 22:37:33 +04:00
|
|
|
|
|
2015-08-17 22:56:53 +03:00
|
|
|
|
pub type AbsoluteDescendantOffsetIter<'a> = Zip<AbsoluteDescendantIter<'a>, IterMut<'a, Au>>;
|
2014-03-03 22:37:33 +04:00
|
|
|
|
|
2014-05-03 03:10:20 +04:00
|
|
|
|
/// Information needed to compute absolute (i.e. viewport-relative) flow positions (not to be
|
2015-09-01 21:33:07 +03:00
|
|
|
|
/// confused with absolutely-positioned flows) that is computed during block-size assignment.
|
2017-08-24 01:18:31 +03:00
|
|
|
|
#[derive(Clone, Copy)]
|
2015-09-01 21:33:07 +03:00
|
|
|
|
pub struct EarlyAbsolutePositionInfo {
|
2014-05-03 03:10:20 +04:00
|
|
|
|
/// The size of the containing block for relatively-positioned descendants.
|
2014-07-19 00:27:23 +04:00
|
|
|
|
pub relative_containing_block_size: LogicalSize<Au>,
|
2014-10-14 10:42:35 +04:00
|
|
|
|
|
2015-03-10 00:54:51 +03:00
|
|
|
|
/// The writing mode for `relative_containing_block_size`.
|
|
|
|
|
pub relative_containing_block_mode: WritingMode,
|
2015-09-01 21:33:07 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl EarlyAbsolutePositionInfo {
|
|
|
|
|
pub fn new(writing_mode: WritingMode) -> EarlyAbsolutePositionInfo {
|
|
|
|
|
// FIXME(pcwalton): The initial relative containing block-size should be equal to the size
|
|
|
|
|
// of the root layer.
|
|
|
|
|
EarlyAbsolutePositionInfo {
|
|
|
|
|
relative_containing_block_size: LogicalSize::zero(writing_mode),
|
|
|
|
|
relative_containing_block_mode: writing_mode,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-03-10 00:54:51 +03:00
|
|
|
|
|
2015-09-01 21:33:07 +03:00
|
|
|
|
/// Information needed to compute absolute (i.e. viewport-relative) flow positions (not to be
|
|
|
|
|
/// confused with absolutely-positioned flows) that is computed during final position assignment.
|
2017-08-24 01:18:31 +03:00
|
|
|
|
#[derive(Clone, Copy, Serialize)]
|
2015-09-01 21:33:07 +03:00
|
|
|
|
pub struct LateAbsolutePositionInfo {
|
2014-11-17 02:39:27 +03:00
|
|
|
|
/// The position of the absolute containing block relative to the nearest ancestor stacking
|
|
|
|
|
/// context. If the absolute containing block establishes the stacking context for this flow,
|
|
|
|
|
/// and this flow is not itself absolutely-positioned, then this is (0, 0).
|
|
|
|
|
pub stacking_relative_position_of_absolute_containing_block: Point2D<Au>,
|
2014-05-03 03:10:20 +04:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-01 21:33:07 +03:00
|
|
|
|
impl LateAbsolutePositionInfo {
|
|
|
|
|
pub fn new() -> LateAbsolutePositionInfo {
|
|
|
|
|
LateAbsolutePositionInfo {
|
2014-12-18 14:42:50 +03:00
|
|
|
|
stacking_relative_position_of_absolute_containing_block: Point2D::zero(),
|
2014-05-03 03:10:20 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-24 01:18:31 +03:00
|
|
|
|
#[derive(Clone, Copy, Debug)]
|
2016-01-29 22:19:14 +03:00
|
|
|
|
pub struct FragmentationContext {
|
|
|
|
|
pub available_block_size: Au,
|
|
|
|
|
pub this_fragment_is_empty: bool,
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-08 00:44:45 +04:00
|
|
|
|
/// Data common to all flows.
|
2014-01-14 02:43:05 +04:00
|
|
|
|
pub struct BaseFlow {
|
2014-04-28 02:52:39 +04:00
|
|
|
|
pub restyle_damage: RestyleDamage,
|
2013-05-03 06:37:36 +04:00
|
|
|
|
|
2013-12-13 05:58:21 +04:00
|
|
|
|
/// The children of this flow.
|
2014-04-28 02:52:39 +04:00
|
|
|
|
pub children: FlowList,
|
2014-09-19 18:51:02 +04:00
|
|
|
|
|
2014-09-26 03:48:35 +04:00
|
|
|
|
/// Intrinsic inline sizes for this flow.
|
2014-07-19 00:27:23 +04:00
|
|
|
|
pub intrinsic_inline_sizes: IntrinsicISizes,
|
2013-10-31 23:10:32 +04:00
|
|
|
|
|
2014-04-04 05:01:48 +04:00
|
|
|
|
/// The upper left corner of the box representing this flow, relative to the box representing
|
|
|
|
|
/// its parent flow.
|
|
|
|
|
///
|
|
|
|
|
/// For absolute flows, this represents the position with respect to its *containing block*.
|
|
|
|
|
///
|
|
|
|
|
/// This does not include margins in the block flow direction, because those can collapse. So
|
|
|
|
|
/// for the block direction (usually vertical), this represents the *border box*. For the
|
|
|
|
|
/// inline direction (usually horizontal), this represents the *margin box*.
|
2014-07-19 00:27:23 +04:00
|
|
|
|
pub position: LogicalRect<Au>,
|
2013-10-31 23:10:32 +04:00
|
|
|
|
|
|
|
|
|
/// The amount of overflow of this flow, relative to the containing block. Must include all the
|
|
|
|
|
/// pixels of all the display list items for correct invalidation.
|
2016-02-05 08:28:50 +03:00
|
|
|
|
pub overflow: Overflow,
|
2013-10-31 23:10:32 +04:00
|
|
|
|
|
2014-01-23 04:04:08 +04:00
|
|
|
|
/// Data used during parallel traversals.
|
|
|
|
|
///
|
|
|
|
|
/// TODO(pcwalton): Group with other transient data to save space.
|
2014-04-28 02:52:39 +04:00
|
|
|
|
pub parallel: FlowParallelInfo,
|
2014-01-23 04:04:08 +04:00
|
|
|
|
|
2014-02-28 00:01:49 +04:00
|
|
|
|
/// The floats next to this flow.
|
2014-04-28 02:52:39 +04:00
|
|
|
|
pub floats: Floats,
|
2014-02-28 00:01:49 +04:00
|
|
|
|
|
2016-03-26 04:38:41 +03:00
|
|
|
|
/// Metrics for floats in computed during the float metrics speculation phase.
|
|
|
|
|
pub speculated_float_placement_in: SpeculatedFloatPlacement,
|
|
|
|
|
|
|
|
|
|
/// Metrics for floats out computed during the float metrics speculation phase.
|
|
|
|
|
pub speculated_float_placement_out: SpeculatedFloatPlacement,
|
|
|
|
|
|
2014-04-04 05:01:48 +04:00
|
|
|
|
/// The collapsible margins for this flow, if any.
|
2014-04-28 02:52:39 +04:00
|
|
|
|
pub collapsible_margins: CollapsibleMargins,
|
2014-04-04 05:01:48 +04:00
|
|
|
|
|
2014-11-17 02:39:27 +03:00
|
|
|
|
/// The position of this flow relative to the start of the nearest ancestor stacking context.
|
|
|
|
|
/// This is computed during the top-down pass of display list construction.
|
2017-06-14 17:25:05 +03:00
|
|
|
|
pub stacking_relative_position: Vector2D<Au>,
|
2013-12-13 05:58:21 +04:00
|
|
|
|
|
2014-04-04 05:01:48 +04:00
|
|
|
|
/// Details about descendants with position 'absolute' or 'fixed' for which we are the
|
|
|
|
|
/// containing block. This is in tree order. This includes any direct children.
|
2015-08-17 22:56:53 +03:00
|
|
|
|
pub abs_descendants: AbsoluteDescendants,
|
2014-03-03 22:37:33 +04:00
|
|
|
|
|
2014-10-14 04:03:40 +04:00
|
|
|
|
/// The inline-size of the block container of this flow. Used for computing percentage and
|
|
|
|
|
/// automatic values for `width`.
|
|
|
|
|
pub block_container_inline_size: Au,
|
|
|
|
|
|
2015-03-10 00:54:51 +03:00
|
|
|
|
/// The writing mode of the block container of this flow.
|
|
|
|
|
///
|
|
|
|
|
/// FIXME (mbrubeck): Combine this and block_container_inline_size and maybe
|
|
|
|
|
/// block_container_explicit_block_size into a struct, to guarantee they are set at the same
|
|
|
|
|
/// time? Or just store a link to the containing block flow.
|
|
|
|
|
pub block_container_writing_mode: WritingMode,
|
|
|
|
|
|
2014-09-20 10:05:55 +04:00
|
|
|
|
/// The block-size of the block container of this flow, if it is an explicit size (does not
|
|
|
|
|
/// depend on content heights). Used for computing percentage values for `height`.
|
|
|
|
|
pub block_container_explicit_block_size: Option<Au>,
|
|
|
|
|
|
2014-03-03 22:37:33 +04:00
|
|
|
|
/// Reference to the Containing Block, if this flow is absolutely positioned.
|
2014-05-02 22:58:29 +04:00
|
|
|
|
pub absolute_cb: ContainingBlockLink,
|
2014-03-03 22:37:33 +04:00
|
|
|
|
|
2014-05-03 03:10:20 +04:00
|
|
|
|
/// Information needed to compute absolute (i.e. viewport-relative) flow positions (not to be
|
2015-09-01 21:33:07 +03:00
|
|
|
|
/// confused with absolutely-positioned flows) that is computed during block-size assignment.
|
|
|
|
|
pub early_absolute_position_info: EarlyAbsolutePositionInfo,
|
|
|
|
|
|
|
|
|
|
/// Information needed to compute absolute (i.e. viewport-relative) flow positions (not to be
|
|
|
|
|
/// confused with absolutely-positioned flows) that is computed during final position
|
|
|
|
|
/// assignment.
|
|
|
|
|
pub late_absolute_position_info: LateAbsolutePositionInfo,
|
2014-05-03 03:10:20 +04:00
|
|
|
|
|
2017-04-18 00:08:00 +03:00
|
|
|
|
/// The clipping rectangle for this flow and its descendants, in the coordinate system of the
|
2016-10-16 00:19:10 +03:00
|
|
|
|
/// nearest ancestor stacking context. If this flow itself represents a stacking context, then
|
|
|
|
|
/// this is in the flow's own coordinate system.
|
2017-04-18 00:08:00 +03:00
|
|
|
|
pub clip: Rect<Au>,
|
2014-10-14 10:42:35 +04:00
|
|
|
|
|
2014-10-29 02:21:48 +03:00
|
|
|
|
/// The writing mode for this flow.
|
|
|
|
|
pub writing_mode: WritingMode,
|
|
|
|
|
|
2015-02-21 09:06:48 +03:00
|
|
|
|
/// For debugging and profiling, the identifier of the thread that laid out this fragment.
|
|
|
|
|
pub thread_id: u8,
|
|
|
|
|
|
2014-05-02 22:58:29 +04:00
|
|
|
|
/// Various flags for flows, tightly packed to save space.
|
|
|
|
|
pub flags: FlowFlags,
|
2016-03-02 03:51:08 +03:00
|
|
|
|
|
|
|
|
|
/// The ID of the StackingContext that contains this flow. This is initialized
|
|
|
|
|
/// to 0, but it assigned during the collect_stacking_contexts phase of display
|
|
|
|
|
/// list construction.
|
|
|
|
|
pub stacking_context_id: StackingContextId,
|
2016-10-30 23:27:56 +03:00
|
|
|
|
|
2017-10-24 17:46:08 +03:00
|
|
|
|
/// The indices of this Flow's ClipScrollNode. This is used to place the node's
|
|
|
|
|
/// display items into scrolling frames and clipping nodes.
|
|
|
|
|
pub clipping_and_scrolling: Option<ClippingAndScrolling>,
|
2012-10-10 20:39:40 +04:00
|
|
|
|
}
|
|
|
|
|
|
2015-02-12 03:24:45 +03:00
|
|
|
|
impl fmt::Debug for BaseFlow {
|
2014-10-02 05:36:25 +04:00
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
2015-11-24 05:19:07 +03:00
|
|
|
|
let child_count = self.parallel.children_count.load(Ordering::SeqCst);
|
|
|
|
|
let child_count_string = if child_count > 0 {
|
servo: Merge #19622 - pretty print tree (from tigercosmos:x2); r=shinglyu
<!-- Please describe your changes on the following line: -->
```
│ │ │ │ │ │ │ floatspec-out=L 0px R 0px
│ │ │ │ │ │ │ overflow=Overflow { scroll: TypedRect(0px×0px at (0px,0px)), paint: TypedRect(0px×0px at (0px,0px)) }
│ │ │ │ │ │ │ damage=BUBBLE_ISIZES
│ │ │ │ │ │ │ └─ ↑↑ Fragment for block:
│ │ │ │ │ │ │ │ SpecificFragmentInfo::Table(2671) []
│ │ │ │ │ │ │ │ border_box=LogicalRect(H LTR, i0px×b0px, @ (i0px,b0px))
│ │ │ │ │ │ │ │ damage=REPOSITION | STORE_OVERFLOW | BUBBLE_ISIZES | REFLOW_OUT_OF_FLOW | REFLOW
│ │ │ │ ├─ Block(1268a9710)
│ │ │ │ │ sc=StackingContextId(0)
│ │ │ │ │ pos=LogicalRect(H LTR, i720px×b36px, @ (i152px,b2636.883333333333px))
│ │ │ │ │ floatspec-in=L 0px R 0px
│ │ │ │ │ floatspec-out=L 0px R 0px
│ │ │ │ │ overflow=Overflow { scroll: TypedRect(750px×36px at (-15px,0px)), paint: TypedRect(750px×36px at (-15px,0px)) }
│ │ │ │ │ children=1
│ │ │ │ │ damage=BUBBLE_ISIZES
│ │ │ │ │ ├─ ↑↑ Fragment for block:
│ │ │ │ │ │ SpecificFragmentInfo::Generic(2673) []
│ │ │ │ │ │ border_box=LogicalRect(H LTR, i720px×b36px, @ (i0px,b0px))
│ │ │ │ │ │ border_padding=LogicalMargin(H LTR, i:0px..0px b:6px..0px)
│ │ │ │ │ │ damage=REPOSITION | STORE_OVERFLOW
│ │ │ │ │ ├─ Block(128554f10)
│ │ │ │ │ │ sc=StackingContextId(0)
│ │ │ │ │ │ pos=LogicalRect(H LTR, i750px×b30px, @ (i0px,b6px))
│ │ │ │ │ │ floatspec-in=L 0px R 0px
│ │ │ │ │ │ floatspec-out=L 0px R 0px
│ │ │ │ │ │ overflow=Overflow { scroll: TypedRect(750px×30px at (-15px,0px)), paint: TypedRect(750px×30px at (-15px,0px)) }
│ │ │ │ │ │ children=6
│ │ │ │ │ │ damage=BUBBLE_ISIZES
│ │ │ │ │ │ ├─ ↑↑ Fragment for block:
│ │ │ │ │ │ │ SpecificFragmentInfo::Generic(2361) []
│ │ │ │ │ │ │ border_box=LogicalRect(H LTR, i750px×b30px, @ (i-15px,b0px))
│ │ │ │ │ │ │ margin=LogicalMargin(H LTR, i:-15px..-15px b:0px..0px)
│ │ │ │ │ │ │ damage=REPOSITION | STORE_OVERFLOW
│ │ │ │ │ │ ├─ TableWrapperFlow: Block(128555410)
│ │ │ │ │ │ │ sc=StackingContextId(0)
│ │ │ │ │ │ │ pos=LogicalRect(H LTR, i750px×b0px, @ (i-15px,b0px))
│ │ │ │ │ │ │ floatspec-in=L 0px R 0px
│ │ │ │ │ │ │ floatspec-out=L 0px R 0px
│ │ │ │ │ │ │ overflow=Overflow { scroll: TypedRect(0px×0px at (0px,0px)), paint: TypedRect(0px×0px at (0px,0px)) }
│ │ │ │ │ │ │ children=1
│ │ │ │ │ │ │ damage=BUBBLE_ISIZES
```
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #12675 (github issue number if applicable).
<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Source-Repo: https://github.com/servo/servo
Source-Revision: 7aae164fcdb8ab308bfa0806e1123e9b7eb73a7c
--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : ce4a8508aef07608aa4f7c7a530c422a7acccbf2
2017-12-25 16:56:42 +03:00
|
|
|
|
format!("\nchildren={}", child_count)
|
2015-11-24 05:19:07 +03:00
|
|
|
|
} else {
|
|
|
|
|
"".to_owned()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let absolute_descendants_string = if self.abs_descendants.len() > 0 {
|
servo: Merge #19622 - pretty print tree (from tigercosmos:x2); r=shinglyu
<!-- Please describe your changes on the following line: -->
```
│ │ │ │ │ │ │ floatspec-out=L 0px R 0px
│ │ │ │ │ │ │ overflow=Overflow { scroll: TypedRect(0px×0px at (0px,0px)), paint: TypedRect(0px×0px at (0px,0px)) }
│ │ │ │ │ │ │ damage=BUBBLE_ISIZES
│ │ │ │ │ │ │ └─ ↑↑ Fragment for block:
│ │ │ │ │ │ │ │ SpecificFragmentInfo::Table(2671) []
│ │ │ │ │ │ │ │ border_box=LogicalRect(H LTR, i0px×b0px, @ (i0px,b0px))
│ │ │ │ │ │ │ │ damage=REPOSITION | STORE_OVERFLOW | BUBBLE_ISIZES | REFLOW_OUT_OF_FLOW | REFLOW
│ │ │ │ ├─ Block(1268a9710)
│ │ │ │ │ sc=StackingContextId(0)
│ │ │ │ │ pos=LogicalRect(H LTR, i720px×b36px, @ (i152px,b2636.883333333333px))
│ │ │ │ │ floatspec-in=L 0px R 0px
│ │ │ │ │ floatspec-out=L 0px R 0px
│ │ │ │ │ overflow=Overflow { scroll: TypedRect(750px×36px at (-15px,0px)), paint: TypedRect(750px×36px at (-15px,0px)) }
│ │ │ │ │ children=1
│ │ │ │ │ damage=BUBBLE_ISIZES
│ │ │ │ │ ├─ ↑↑ Fragment for block:
│ │ │ │ │ │ SpecificFragmentInfo::Generic(2673) []
│ │ │ │ │ │ border_box=LogicalRect(H LTR, i720px×b36px, @ (i0px,b0px))
│ │ │ │ │ │ border_padding=LogicalMargin(H LTR, i:0px..0px b:6px..0px)
│ │ │ │ │ │ damage=REPOSITION | STORE_OVERFLOW
│ │ │ │ │ ├─ Block(128554f10)
│ │ │ │ │ │ sc=StackingContextId(0)
│ │ │ │ │ │ pos=LogicalRect(H LTR, i750px×b30px, @ (i0px,b6px))
│ │ │ │ │ │ floatspec-in=L 0px R 0px
│ │ │ │ │ │ floatspec-out=L 0px R 0px
│ │ │ │ │ │ overflow=Overflow { scroll: TypedRect(750px×30px at (-15px,0px)), paint: TypedRect(750px×30px at (-15px,0px)) }
│ │ │ │ │ │ children=6
│ │ │ │ │ │ damage=BUBBLE_ISIZES
│ │ │ │ │ │ ├─ ↑↑ Fragment for block:
│ │ │ │ │ │ │ SpecificFragmentInfo::Generic(2361) []
│ │ │ │ │ │ │ border_box=LogicalRect(H LTR, i750px×b30px, @ (i-15px,b0px))
│ │ │ │ │ │ │ margin=LogicalMargin(H LTR, i:-15px..-15px b:0px..0px)
│ │ │ │ │ │ │ damage=REPOSITION | STORE_OVERFLOW
│ │ │ │ │ │ ├─ TableWrapperFlow: Block(128555410)
│ │ │ │ │ │ │ sc=StackingContextId(0)
│ │ │ │ │ │ │ pos=LogicalRect(H LTR, i750px×b0px, @ (i-15px,b0px))
│ │ │ │ │ │ │ floatspec-in=L 0px R 0px
│ │ │ │ │ │ │ floatspec-out=L 0px R 0px
│ │ │ │ │ │ │ overflow=Overflow { scroll: TypedRect(0px×0px at (0px,0px)), paint: TypedRect(0px×0px at (0px,0px)) }
│ │ │ │ │ │ │ children=1
│ │ │ │ │ │ │ damage=BUBBLE_ISIZES
```
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #12675 (github issue number if applicable).
<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Source-Repo: https://github.com/servo/servo
Source-Revision: 7aae164fcdb8ab308bfa0806e1123e9b7eb73a7c
--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : ce4a8508aef07608aa4f7c7a530c422a7acccbf2
2017-12-25 16:56:42 +03:00
|
|
|
|
format!("\nabs-descendents={}", self.abs_descendants.len())
|
2015-11-24 05:19:07 +03:00
|
|
|
|
} else {
|
|
|
|
|
"".to_owned()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let damage_string = if self.restyle_damage != RestyleDamage::empty() {
|
servo: Merge #19622 - pretty print tree (from tigercosmos:x2); r=shinglyu
<!-- Please describe your changes on the following line: -->
```
│ │ │ │ │ │ │ floatspec-out=L 0px R 0px
│ │ │ │ │ │ │ overflow=Overflow { scroll: TypedRect(0px×0px at (0px,0px)), paint: TypedRect(0px×0px at (0px,0px)) }
│ │ │ │ │ │ │ damage=BUBBLE_ISIZES
│ │ │ │ │ │ │ └─ ↑↑ Fragment for block:
│ │ │ │ │ │ │ │ SpecificFragmentInfo::Table(2671) []
│ │ │ │ │ │ │ │ border_box=LogicalRect(H LTR, i0px×b0px, @ (i0px,b0px))
│ │ │ │ │ │ │ │ damage=REPOSITION | STORE_OVERFLOW | BUBBLE_ISIZES | REFLOW_OUT_OF_FLOW | REFLOW
│ │ │ │ ├─ Block(1268a9710)
│ │ │ │ │ sc=StackingContextId(0)
│ │ │ │ │ pos=LogicalRect(H LTR, i720px×b36px, @ (i152px,b2636.883333333333px))
│ │ │ │ │ floatspec-in=L 0px R 0px
│ │ │ │ │ floatspec-out=L 0px R 0px
│ │ │ │ │ overflow=Overflow { scroll: TypedRect(750px×36px at (-15px,0px)), paint: TypedRect(750px×36px at (-15px,0px)) }
│ │ │ │ │ children=1
│ │ │ │ │ damage=BUBBLE_ISIZES
│ │ │ │ │ ├─ ↑↑ Fragment for block:
│ │ │ │ │ │ SpecificFragmentInfo::Generic(2673) []
│ │ │ │ │ │ border_box=LogicalRect(H LTR, i720px×b36px, @ (i0px,b0px))
│ │ │ │ │ │ border_padding=LogicalMargin(H LTR, i:0px..0px b:6px..0px)
│ │ │ │ │ │ damage=REPOSITION | STORE_OVERFLOW
│ │ │ │ │ ├─ Block(128554f10)
│ │ │ │ │ │ sc=StackingContextId(0)
│ │ │ │ │ │ pos=LogicalRect(H LTR, i750px×b30px, @ (i0px,b6px))
│ │ │ │ │ │ floatspec-in=L 0px R 0px
│ │ │ │ │ │ floatspec-out=L 0px R 0px
│ │ │ │ │ │ overflow=Overflow { scroll: TypedRect(750px×30px at (-15px,0px)), paint: TypedRect(750px×30px at (-15px,0px)) }
│ │ │ │ │ │ children=6
│ │ │ │ │ │ damage=BUBBLE_ISIZES
│ │ │ │ │ │ ├─ ↑↑ Fragment for block:
│ │ │ │ │ │ │ SpecificFragmentInfo::Generic(2361) []
│ │ │ │ │ │ │ border_box=LogicalRect(H LTR, i750px×b30px, @ (i-15px,b0px))
│ │ │ │ │ │ │ margin=LogicalMargin(H LTR, i:-15px..-15px b:0px..0px)
│ │ │ │ │ │ │ damage=REPOSITION | STORE_OVERFLOW
│ │ │ │ │ │ ├─ TableWrapperFlow: Block(128555410)
│ │ │ │ │ │ │ sc=StackingContextId(0)
│ │ │ │ │ │ │ pos=LogicalRect(H LTR, i750px×b0px, @ (i-15px,b0px))
│ │ │ │ │ │ │ floatspec-in=L 0px R 0px
│ │ │ │ │ │ │ floatspec-out=L 0px R 0px
│ │ │ │ │ │ │ overflow=Overflow { scroll: TypedRect(0px×0px at (0px,0px)), paint: TypedRect(0px×0px at (0px,0px)) }
│ │ │ │ │ │ │ children=1
│ │ │ │ │ │ │ damage=BUBBLE_ISIZES
```
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #12675 (github issue number if applicable).
<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Source-Repo: https://github.com/servo/servo
Source-Revision: 7aae164fcdb8ab308bfa0806e1123e9b7eb73a7c
--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : ce4a8508aef07608aa4f7c7a530c422a7acccbf2
2017-12-25 16:56:42 +03:00
|
|
|
|
format!("\ndamage={:?}", self.restyle_damage)
|
2015-11-24 05:19:07 +03:00
|
|
|
|
} else {
|
|
|
|
|
"".to_owned()
|
|
|
|
|
};
|
|
|
|
|
|
2014-10-02 05:36:25 +04:00
|
|
|
|
write!(f,
|
servo: Merge #19622 - pretty print tree (from tigercosmos:x2); r=shinglyu
<!-- Please describe your changes on the following line: -->
```
│ │ │ │ │ │ │ floatspec-out=L 0px R 0px
│ │ │ │ │ │ │ overflow=Overflow { scroll: TypedRect(0px×0px at (0px,0px)), paint: TypedRect(0px×0px at (0px,0px)) }
│ │ │ │ │ │ │ damage=BUBBLE_ISIZES
│ │ │ │ │ │ │ └─ ↑↑ Fragment for block:
│ │ │ │ │ │ │ │ SpecificFragmentInfo::Table(2671) []
│ │ │ │ │ │ │ │ border_box=LogicalRect(H LTR, i0px×b0px, @ (i0px,b0px))
│ │ │ │ │ │ │ │ damage=REPOSITION | STORE_OVERFLOW | BUBBLE_ISIZES | REFLOW_OUT_OF_FLOW | REFLOW
│ │ │ │ ├─ Block(1268a9710)
│ │ │ │ │ sc=StackingContextId(0)
│ │ │ │ │ pos=LogicalRect(H LTR, i720px×b36px, @ (i152px,b2636.883333333333px))
│ │ │ │ │ floatspec-in=L 0px R 0px
│ │ │ │ │ floatspec-out=L 0px R 0px
│ │ │ │ │ overflow=Overflow { scroll: TypedRect(750px×36px at (-15px,0px)), paint: TypedRect(750px×36px at (-15px,0px)) }
│ │ │ │ │ children=1
│ │ │ │ │ damage=BUBBLE_ISIZES
│ │ │ │ │ ├─ ↑↑ Fragment for block:
│ │ │ │ │ │ SpecificFragmentInfo::Generic(2673) []
│ │ │ │ │ │ border_box=LogicalRect(H LTR, i720px×b36px, @ (i0px,b0px))
│ │ │ │ │ │ border_padding=LogicalMargin(H LTR, i:0px..0px b:6px..0px)
│ │ │ │ │ │ damage=REPOSITION | STORE_OVERFLOW
│ │ │ │ │ ├─ Block(128554f10)
│ │ │ │ │ │ sc=StackingContextId(0)
│ │ │ │ │ │ pos=LogicalRect(H LTR, i750px×b30px, @ (i0px,b6px))
│ │ │ │ │ │ floatspec-in=L 0px R 0px
│ │ │ │ │ │ floatspec-out=L 0px R 0px
│ │ │ │ │ │ overflow=Overflow { scroll: TypedRect(750px×30px at (-15px,0px)), paint: TypedRect(750px×30px at (-15px,0px)) }
│ │ │ │ │ │ children=6
│ │ │ │ │ │ damage=BUBBLE_ISIZES
│ │ │ │ │ │ ├─ ↑↑ Fragment for block:
│ │ │ │ │ │ │ SpecificFragmentInfo::Generic(2361) []
│ │ │ │ │ │ │ border_box=LogicalRect(H LTR, i750px×b30px, @ (i-15px,b0px))
│ │ │ │ │ │ │ margin=LogicalMargin(H LTR, i:-15px..-15px b:0px..0px)
│ │ │ │ │ │ │ damage=REPOSITION | STORE_OVERFLOW
│ │ │ │ │ │ ├─ TableWrapperFlow: Block(128555410)
│ │ │ │ │ │ │ sc=StackingContextId(0)
│ │ │ │ │ │ │ pos=LogicalRect(H LTR, i750px×b0px, @ (i-15px,b0px))
│ │ │ │ │ │ │ floatspec-in=L 0px R 0px
│ │ │ │ │ │ │ floatspec-out=L 0px R 0px
│ │ │ │ │ │ │ overflow=Overflow { scroll: TypedRect(0px×0px at (0px,0px)), paint: TypedRect(0px×0px at (0px,0px)) }
│ │ │ │ │ │ │ children=1
│ │ │ │ │ │ │ damage=BUBBLE_ISIZES
```
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #12675 (github issue number if applicable).
<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Source-Repo: https://github.com/servo/servo
Source-Revision: 7aae164fcdb8ab308bfa0806e1123e9b7eb73a7c
--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : ce4a8508aef07608aa4f7c7a530c422a7acccbf2
2017-12-25 16:56:42 +03:00
|
|
|
|
"\nsc={:?}\
|
|
|
|
|
\npos={:?}{}{}\
|
|
|
|
|
\nfloatspec-in={:?}\
|
|
|
|
|
\nfloatspec-out={:?}\
|
|
|
|
|
\noverflow={:?}{}{}{}",
|
2016-03-02 03:51:08 +03:00
|
|
|
|
self.stacking_context_id,
|
2014-10-14 04:03:40 +04:00
|
|
|
|
self.position,
|
2017-10-31 02:25:45 +03:00
|
|
|
|
if self.flags.contains(FlowFlags::FLOATS_LEFT) { "FL" } else { "" },
|
|
|
|
|
if self.flags.contains(FlowFlags::FLOATS_RIGHT) { "FR" } else { "" },
|
2016-03-26 04:38:41 +03:00
|
|
|
|
self.speculated_float_placement_in,
|
|
|
|
|
self.speculated_float_placement_out,
|
2015-11-04 03:58:46 +03:00
|
|
|
|
self.overflow,
|
2015-11-24 05:19:07 +03:00
|
|
|
|
child_count_string,
|
|
|
|
|
absolute_descendants_string,
|
|
|
|
|
damage_string)
|
2014-10-02 05:36:25 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-07 11:15:03 +03:00
|
|
|
|
impl Serialize for BaseFlow {
|
2017-02-18 23:10:26 +03:00
|
|
|
|
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
2017-06-18 15:55:11 +03:00
|
|
|
|
let mut serializer = serializer.serialize_struct("base", 5)?;
|
|
|
|
|
serializer.serialize_field("id", &self.debug_id())?;
|
|
|
|
|
serializer.serialize_field("stacking_relative_position", &self.stacking_relative_position)?;
|
|
|
|
|
serializer.serialize_field("intrinsic_inline_sizes", &self.intrinsic_inline_sizes)?;
|
|
|
|
|
serializer.serialize_field("position", &self.position)?;
|
|
|
|
|
serializer.serialize_field("children", &self.children)?;
|
2017-02-18 23:10:26 +03:00
|
|
|
|
serializer.end()
|
2014-09-08 10:33:09 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-19 02:39:25 +03:00
|
|
|
|
/// Whether a base flow should be forced to be nonfloated. This can affect e.g. `TableFlow`, which
|
|
|
|
|
/// is never floated because the table wrapper flow is the floated one.
|
2015-01-28 04:15:50 +03:00
|
|
|
|
#[derive(Clone, PartialEq)]
|
2014-11-19 02:39:25 +03:00
|
|
|
|
pub enum ForceNonfloatedFlag {
|
|
|
|
|
/// The flow should be floated if the node has a `float` property.
|
|
|
|
|
FloatIfNecessary,
|
|
|
|
|
/// The flow should be forced to be nonfloated.
|
|
|
|
|
ForceNonfloated,
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-14 02:43:05 +04:00
|
|
|
|
impl BaseFlow {
|
2013-11-18 23:54:00 +04:00
|
|
|
|
#[inline]
|
2017-07-18 05:44:25 +03:00
|
|
|
|
pub fn new(style: Option<&ComputedValues>,
|
2014-11-19 02:39:25 +03:00
|
|
|
|
writing_mode: WritingMode,
|
|
|
|
|
force_nonfloated: ForceNonfloatedFlag)
|
|
|
|
|
-> BaseFlow {
|
2014-11-18 21:42:32 +03:00
|
|
|
|
let mut flags = FlowFlags::empty();
|
2015-08-07 07:11:04 +03:00
|
|
|
|
match style {
|
|
|
|
|
Some(style) => {
|
2018-01-05 14:11:00 +03:00
|
|
|
|
if style.can_be_fragmented() {
|
|
|
|
|
flags.insert(FlowFlags::CAN_BE_FRAGMENTED);
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-07 07:11:04 +03:00
|
|
|
|
match style.get_box().position {
|
2017-12-06 04:35:25 +03:00
|
|
|
|
Position::Absolute | Position::Fixed => {
|
2017-10-31 02:25:45 +03:00
|
|
|
|
flags.insert(FlowFlags::IS_ABSOLUTELY_POSITIONED);
|
2015-04-15 02:14:11 +03:00
|
|
|
|
|
2015-08-07 07:11:04 +03:00
|
|
|
|
let logical_position = style.logical_position();
|
2015-04-15 02:14:11 +03:00
|
|
|
|
if logical_position.inline_start == LengthOrPercentageOrAuto::Auto &&
|
|
|
|
|
logical_position.inline_end == LengthOrPercentageOrAuto::Auto {
|
2017-10-31 02:25:45 +03:00
|
|
|
|
flags.insert(FlowFlags::INLINE_POSITION_IS_STATIC);
|
2015-04-15 02:14:11 +03:00
|
|
|
|
}
|
|
|
|
|
if logical_position.block_start == LengthOrPercentageOrAuto::Auto &&
|
|
|
|
|
logical_position.block_end == LengthOrPercentageOrAuto::Auto {
|
2017-10-31 02:25:45 +03:00
|
|
|
|
flags.insert(FlowFlags::BLOCK_POSITION_IS_STATIC);
|
2015-04-15 02:14:11 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-10-31 02:25:45 +03:00
|
|
|
|
_ => flags.insert(FlowFlags::BLOCK_POSITION_IS_STATIC | FlowFlags::INLINE_POSITION_IS_STATIC),
|
2014-10-29 05:42:38 +03:00
|
|
|
|
}
|
2014-11-19 02:39:25 +03:00
|
|
|
|
|
2015-04-15 02:14:11 +03:00
|
|
|
|
if force_nonfloated == ForceNonfloatedFlag::FloatIfNecessary {
|
2015-08-07 07:11:04 +03:00
|
|
|
|
match style.get_box().float {
|
2017-12-06 04:35:25 +03:00
|
|
|
|
Float::None => {}
|
|
|
|
|
Float::Left => flags.insert(FlowFlags::FLOATS_LEFT),
|
|
|
|
|
Float::Right => flags.insert(FlowFlags::FLOATS_RIGHT),
|
2015-04-15 02:14:11 +03:00
|
|
|
|
}
|
2014-10-29 05:42:38 +03:00
|
|
|
|
}
|
2014-11-19 02:39:25 +03:00
|
|
|
|
|
2015-08-07 07:11:04 +03:00
|
|
|
|
match style.get_box().clear {
|
2017-12-06 04:35:25 +03:00
|
|
|
|
Clear::None => {}
|
|
|
|
|
Clear::Left => flags.insert(FlowFlags::CLEARS_LEFT),
|
|
|
|
|
Clear::Right => flags.insert(FlowFlags::CLEARS_RIGHT),
|
|
|
|
|
Clear::Both => {
|
2017-10-31 02:25:45 +03:00
|
|
|
|
flags.insert(FlowFlags::CLEARS_LEFT);
|
|
|
|
|
flags.insert(FlowFlags::CLEARS_RIGHT);
|
2015-04-15 02:14:11 +03:00
|
|
|
|
}
|
2014-10-29 05:42:38 +03:00
|
|
|
|
}
|
2015-03-10 08:24:47 +03:00
|
|
|
|
|
2018-02-04 17:11:05 +03:00
|
|
|
|
if !style.get_counters().counter_reset.is_empty() ||
|
|
|
|
|
!style.get_counters().counter_increment.is_empty() {
|
2017-10-31 02:25:45 +03:00
|
|
|
|
flags.insert(FlowFlags::AFFECTS_COUNTERS)
|
2015-04-15 02:14:11 +03:00
|
|
|
|
}
|
2015-03-10 08:24:47 +03:00
|
|
|
|
}
|
2017-10-31 02:25:45 +03:00
|
|
|
|
None => flags.insert(FlowFlags::BLOCK_POSITION_IS_STATIC | FlowFlags::INLINE_POSITION_IS_STATIC),
|
2014-10-29 05:42:38 +03:00
|
|
|
|
}
|
|
|
|
|
|
2014-10-31 23:39:34 +03:00
|
|
|
|
// New flows start out as fully damaged.
|
2016-01-04 21:04:35 +03:00
|
|
|
|
let mut damage = RestyleDamage::rebuild_and_reflow();
|
2017-10-31 02:25:45 +03:00
|
|
|
|
damage.remove(ServoRestyleDamage::RECONSTRUCT_FLOW);
|
2014-10-31 23:39:34 +03:00
|
|
|
|
|
2014-01-14 02:43:05 +04:00
|
|
|
|
BaseFlow {
|
2014-10-31 23:39:34 +03:00
|
|
|
|
restyle_damage: damage,
|
2014-02-06 07:19:43 +04:00
|
|
|
|
children: FlowList::new(),
|
2014-07-19 00:27:23 +04:00
|
|
|
|
intrinsic_inline_sizes: IntrinsicISizes::new(),
|
|
|
|
|
position: LogicalRect::zero(writing_mode),
|
2016-02-05 08:28:50 +03:00
|
|
|
|
overflow: Overflow::new(),
|
2014-01-23 04:04:08 +04:00
|
|
|
|
parallel: FlowParallelInfo::new(),
|
2014-07-19 00:27:23 +04:00
|
|
|
|
floats: Floats::new(writing_mode),
|
2014-04-04 05:01:48 +04:00
|
|
|
|
collapsible_margins: CollapsibleMargins::new(),
|
2017-06-14 17:25:05 +03:00
|
|
|
|
stacking_relative_position: Vector2D::zero(),
|
2015-08-17 22:56:53 +03:00
|
|
|
|
abs_descendants: AbsoluteDescendants::new(),
|
2016-03-26 04:38:41 +03:00
|
|
|
|
speculated_float_placement_in: SpeculatedFloatPlacement::zero(),
|
|
|
|
|
speculated_float_placement_out: SpeculatedFloatPlacement::zero(),
|
2014-10-14 04:03:40 +04:00
|
|
|
|
block_container_inline_size: Au(0),
|
2015-03-10 00:54:51 +03:00
|
|
|
|
block_container_writing_mode: writing_mode,
|
2014-09-20 10:05:55 +04:00
|
|
|
|
block_container_explicit_block_size: None,
|
2014-05-02 22:58:29 +04:00
|
|
|
|
absolute_cb: ContainingBlockLink::new(),
|
2015-09-01 21:33:07 +03:00
|
|
|
|
early_absolute_position_info: EarlyAbsolutePositionInfo::new(writing_mode),
|
|
|
|
|
late_absolute_position_info: LateAbsolutePositionInfo::new(),
|
2018-01-18 14:42:52 +03:00
|
|
|
|
clip: MaxRect::max_rect(),
|
2014-10-29 05:42:38 +03:00
|
|
|
|
flags: flags,
|
2014-07-19 00:27:23 +04:00
|
|
|
|
writing_mode: writing_mode,
|
2015-02-21 09:06:48 +03:00
|
|
|
|
thread_id: 0,
|
2017-04-20 09:55:33 +03:00
|
|
|
|
stacking_context_id: StackingContextId::root(),
|
2017-10-24 17:46:08 +03:00
|
|
|
|
clipping_and_scrolling: None,
|
2013-05-03 06:37:36 +04:00
|
|
|
|
}
|
2012-10-10 20:39:40 +04:00
|
|
|
|
}
|
2013-08-20 23:03:52 +04:00
|
|
|
|
|
2017-07-01 08:15:26 +03:00
|
|
|
|
/// Update the 'flags' field when computed styles have changed.
|
|
|
|
|
///
|
|
|
|
|
/// These flags are initially set during flow construction. They only need to be updated here
|
|
|
|
|
/// if they are based on properties that can change without triggering `RECONSTRUCT_FLOW`.
|
2017-07-18 05:44:25 +03:00
|
|
|
|
pub fn update_flags_if_needed(&mut self, style: &ComputedValues) {
|
2017-07-01 08:15:26 +03:00
|
|
|
|
// For absolutely-positioned flows, changes to top/bottom/left/right can cause these flags
|
|
|
|
|
// to get out of date:
|
2017-10-31 02:25:45 +03:00
|
|
|
|
if self.restyle_damage.contains(ServoRestyleDamage::REFLOW_OUT_OF_FLOW) {
|
2017-07-01 08:15:26 +03:00
|
|
|
|
// Note: We don't need to check whether IS_ABSOLUTELY_POSITIONED has changed, because
|
|
|
|
|
// changes to the 'position' property trigger flow reconstruction.
|
2017-10-31 02:25:45 +03:00
|
|
|
|
if self.flags.contains(FlowFlags::IS_ABSOLUTELY_POSITIONED) {
|
2017-07-01 08:15:26 +03:00
|
|
|
|
let logical_position = style.logical_position();
|
2017-10-31 02:25:45 +03:00
|
|
|
|
self.flags.set(FlowFlags::INLINE_POSITION_IS_STATIC,
|
2017-07-01 08:15:26 +03:00
|
|
|
|
logical_position.inline_start == LengthOrPercentageOrAuto::Auto &&
|
|
|
|
|
logical_position.inline_end == LengthOrPercentageOrAuto::Auto);
|
2017-10-31 02:25:45 +03:00
|
|
|
|
self.flags.set(FlowFlags::BLOCK_POSITION_IS_STATIC,
|
2017-07-01 08:15:26 +03:00
|
|
|
|
logical_position.block_start == LengthOrPercentageOrAuto::Auto &&
|
|
|
|
|
logical_position.block_end == LengthOrPercentageOrAuto::Auto);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-29 22:19:14 +03:00
|
|
|
|
/// Return a new BaseFlow like this one but with the given children list
|
|
|
|
|
pub fn clone_with_children(&self, children: FlowList) -> BaseFlow {
|
|
|
|
|
BaseFlow {
|
|
|
|
|
children: children,
|
2017-10-31 02:25:45 +03:00
|
|
|
|
restyle_damage: self.restyle_damage | ServoRestyleDamage::REPAINT |
|
|
|
|
|
ServoRestyleDamage::REFLOW_OUT_OF_FLOW | ServoRestyleDamage::REFLOW,
|
2016-01-29 22:19:14 +03:00
|
|
|
|
parallel: FlowParallelInfo::new(),
|
|
|
|
|
floats: self.floats.clone(),
|
|
|
|
|
abs_descendants: self.abs_descendants.clone(),
|
|
|
|
|
absolute_cb: self.absolute_cb.clone(),
|
|
|
|
|
clip: self.clip.clone(),
|
|
|
|
|
|
|
|
|
|
..*self
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-15 21:44:50 +03:00
|
|
|
|
/// Iterates over the children of this immutable flow.
|
|
|
|
|
pub fn child_iter(&self) -> FlowListIterator {
|
|
|
|
|
self.children.iter()
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-09 01:24:40 +03:00
|
|
|
|
pub fn child_iter_mut(&mut self) -> MutFlowListIterator {
|
2014-09-21 02:35:08 +04:00
|
|
|
|
self.children.iter_mut()
|
2013-08-20 23:03:52 +04:00
|
|
|
|
}
|
2014-06-04 09:25:28 +04:00
|
|
|
|
|
2015-03-29 12:49:01 +03:00
|
|
|
|
pub fn debug_id(&self) -> usize {
|
2014-10-17 22:15:23 +04:00
|
|
|
|
let p = self as *const _;
|
2015-03-29 12:49:01 +03:00
|
|
|
|
p as usize
|
2014-09-08 10:33:09 +04:00
|
|
|
|
}
|
2014-10-22 20:54:35 +04:00
|
|
|
|
|
2016-03-02 03:51:08 +03:00
|
|
|
|
pub fn flow_id(&self) -> usize {
|
|
|
|
|
return self as *const BaseFlow as usize;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-15 22:43:40 +03:00
|
|
|
|
pub fn collect_stacking_contexts_for_children(&mut self,
|
|
|
|
|
state: &mut StackingContextCollectionState) {
|
2016-03-02 03:51:08 +03:00
|
|
|
|
for kid in self.children.iter_mut() {
|
2017-01-10 15:48:31 +03:00
|
|
|
|
kid.collect_stacking_contexts(state);
|
2016-03-02 03:51:08 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-03-26 04:38:41 +03:00
|
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
|
pub fn might_have_floats_in(&self) -> bool {
|
|
|
|
|
self.speculated_float_placement_in.left > Au(0) ||
|
|
|
|
|
self.speculated_float_placement_in.right > Au(0)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
|
pub fn might_have_floats_out(&self) -> bool {
|
|
|
|
|
self.speculated_float_placement_out.left > Au(0) ||
|
|
|
|
|
self.speculated_float_placement_out.right > Au(0)
|
|
|
|
|
}
|
2018-02-21 20:00:03 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Compute the fragment position relative to the parent stacking context. If the fragment
|
|
|
|
|
/// itself establishes a stacking context, then the origin of its position will be (0, 0)
|
|
|
|
|
/// for the purposes of this computation.
|
|
|
|
|
pub fn stacking_relative_border_box_for_display_list(&self, fragment: &Fragment) -> Rect<Au> {
|
|
|
|
|
fragment.stacking_relative_border_box(
|
|
|
|
|
&self.stacking_relative_position,
|
|
|
|
|
&self.early_absolute_position_info.relative_containing_block_size,
|
|
|
|
|
self.early_absolute_position_info.relative_containing_block_mode,
|
|
|
|
|
CoordinateSystem::Own,
|
|
|
|
|
)
|
|
|
|
|
}
|
2012-10-10 20:39:40 +04:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-22 00:29:35 +03:00
|
|
|
|
impl<'a> ImmutableFlowUtils for &'a Flow {
|
2015-03-10 08:24:47 +03:00
|
|
|
|
/// Returns true if this flow is a block flow or subclass thereof.
|
2013-10-29 00:31:44 +04:00
|
|
|
|
fn is_block_like(self) -> bool {
|
2016-03-26 04:38:41 +03:00
|
|
|
|
self.class().is_block_like()
|
servo: Merge #1973 - Support fixed-layout table and a part of anonymous table object (from june0cho:table_rebase); r=larsbergstrom,metajack
This is a rebase of #1548 on recent master.
There have been many changes since #1548 is first uploaded, so I'm creating new PR.
This PR includes:
- construction of table-* flows (table-wrapper, table-caption, table, table-rowgroup, table-row, table-cell)
- fixed-layout table calculation
- a part of anonymous table object implementation
[CSS 2.1, 17.2.1](http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes) (Step 1-1, 1-2, Step 2)
Source-Repo: https://github.com/servo/servo
Source-Revision: fd5e5cd18b41f0ce2b33fb97fb4e3d75ddbbbceb
2014-03-25 21:40:47 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Returns true if this flow is a proper table child.
|
|
|
|
|
/// 'Proper table child' is defined as table-row flow, table-rowgroup flow,
|
|
|
|
|
/// table-column-group flow, or table-caption flow.
|
|
|
|
|
fn is_proper_table_child(self) -> bool {
|
|
|
|
|
match self.class() {
|
2014-12-18 04:45:49 +03:00
|
|
|
|
FlowClass::TableRow | FlowClass::TableRowGroup |
|
|
|
|
|
FlowClass::TableColGroup | FlowClass::TableCaption => true,
|
servo: Merge #1973 - Support fixed-layout table and a part of anonymous table object (from june0cho:table_rebase); r=larsbergstrom,metajack
This is a rebase of #1548 on recent master.
There have been many changes since #1548 is first uploaded, so I'm creating new PR.
This PR includes:
- construction of table-* flows (table-wrapper, table-caption, table, table-rowgroup, table-row, table-cell)
- fixed-layout table calculation
- a part of anonymous table object implementation
[CSS 2.1, 17.2.1](http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes) (Step 1-1, 1-2, Step 2)
Source-Repo: https://github.com/servo/servo
Source-Revision: fd5e5cd18b41f0ce2b33fb97fb4e3d75ddbbbceb
2014-03-25 21:40:47 +04:00
|
|
|
|
_ => false,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Returns true if this flow is a table row flow.
|
|
|
|
|
fn is_table_row(self) -> bool {
|
|
|
|
|
match self.class() {
|
2014-12-18 04:45:49 +03:00
|
|
|
|
FlowClass::TableRow => true,
|
servo: Merge #1973 - Support fixed-layout table and a part of anonymous table object (from june0cho:table_rebase); r=larsbergstrom,metajack
This is a rebase of #1548 on recent master.
There have been many changes since #1548 is first uploaded, so I'm creating new PR.
This PR includes:
- construction of table-* flows (table-wrapper, table-caption, table, table-rowgroup, table-row, table-cell)
- fixed-layout table calculation
- a part of anonymous table object implementation
[CSS 2.1, 17.2.1](http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes) (Step 1-1, 1-2, Step 2)
Source-Repo: https://github.com/servo/servo
Source-Revision: fd5e5cd18b41f0ce2b33fb97fb4e3d75ddbbbceb
2014-03-25 21:40:47 +04:00
|
|
|
|
_ => false,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Returns true if this flow is a table cell flow.
|
|
|
|
|
fn is_table_cell(self) -> bool {
|
|
|
|
|
match self.class() {
|
2014-12-18 04:45:49 +03:00
|
|
|
|
FlowClass::TableCell => true,
|
servo: Merge #1973 - Support fixed-layout table and a part of anonymous table object (from june0cho:table_rebase); r=larsbergstrom,metajack
This is a rebase of #1548 on recent master.
There have been many changes since #1548 is first uploaded, so I'm creating new PR.
This PR includes:
- construction of table-* flows (table-wrapper, table-caption, table, table-rowgroup, table-row, table-cell)
- fixed-layout table calculation
- a part of anonymous table object implementation
[CSS 2.1, 17.2.1](http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes) (Step 1-1, 1-2, Step 2)
Source-Repo: https://github.com/servo/servo
Source-Revision: fd5e5cd18b41f0ce2b33fb97fb4e3d75ddbbbceb
2014-03-25 21:40:47 +04:00
|
|
|
|
_ => false,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Returns true if this flow is a table colgroup flow.
|
|
|
|
|
fn is_table_colgroup(self) -> bool {
|
|
|
|
|
match self.class() {
|
2014-12-18 04:45:49 +03:00
|
|
|
|
FlowClass::TableColGroup => true,
|
servo: Merge #1973 - Support fixed-layout table and a part of anonymous table object (from june0cho:table_rebase); r=larsbergstrom,metajack
This is a rebase of #1548 on recent master.
There have been many changes since #1548 is first uploaded, so I'm creating new PR.
This PR includes:
- construction of table-* flows (table-wrapper, table-caption, table, table-rowgroup, table-row, table-cell)
- fixed-layout table calculation
- a part of anonymous table object implementation
[CSS 2.1, 17.2.1](http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes) (Step 1-1, 1-2, Step 2)
Source-Repo: https://github.com/servo/servo
Source-Revision: fd5e5cd18b41f0ce2b33fb97fb4e3d75ddbbbceb
2014-03-25 21:40:47 +04:00
|
|
|
|
_ => false,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Returns true if this flow is a table flow.
|
|
|
|
|
fn is_table(self) -> bool {
|
|
|
|
|
match self.class() {
|
2014-12-18 04:45:49 +03:00
|
|
|
|
FlowClass::Table => true,
|
servo: Merge #1973 - Support fixed-layout table and a part of anonymous table object (from june0cho:table_rebase); r=larsbergstrom,metajack
This is a rebase of #1548 on recent master.
There have been many changes since #1548 is first uploaded, so I'm creating new PR.
This PR includes:
- construction of table-* flows (table-wrapper, table-caption, table, table-rowgroup, table-row, table-cell)
- fixed-layout table calculation
- a part of anonymous table object implementation
[CSS 2.1, 17.2.1](http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes) (Step 1-1, 1-2, Step 2)
Source-Repo: https://github.com/servo/servo
Source-Revision: fd5e5cd18b41f0ce2b33fb97fb4e3d75ddbbbceb
2014-03-25 21:40:47 +04:00
|
|
|
|
_ => false,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Returns true if this flow is a table caption flow.
|
|
|
|
|
fn is_table_caption(self) -> bool {
|
|
|
|
|
match self.class() {
|
2014-12-18 04:45:49 +03:00
|
|
|
|
FlowClass::TableCaption => true,
|
servo: Merge #1973 - Support fixed-layout table and a part of anonymous table object (from june0cho:table_rebase); r=larsbergstrom,metajack
This is a rebase of #1548 on recent master.
There have been many changes since #1548 is first uploaded, so I'm creating new PR.
This PR includes:
- construction of table-* flows (table-wrapper, table-caption, table, table-rowgroup, table-row, table-cell)
- fixed-layout table calculation
- a part of anonymous table object implementation
[CSS 2.1, 17.2.1](http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes) (Step 1-1, 1-2, Step 2)
Source-Repo: https://github.com/servo/servo
Source-Revision: fd5e5cd18b41f0ce2b33fb97fb4e3d75ddbbbceb
2014-03-25 21:40:47 +04:00
|
|
|
|
_ => false,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Returns true if this flow is a table rowgroup flow.
|
|
|
|
|
fn is_table_rowgroup(self) -> bool {
|
|
|
|
|
match self.class() {
|
2014-12-18 04:45:49 +03:00
|
|
|
|
FlowClass::TableRowGroup => true,
|
servo: Merge #1973 - Support fixed-layout table and a part of anonymous table object (from june0cho:table_rebase); r=larsbergstrom,metajack
This is a rebase of #1548 on recent master.
There have been many changes since #1548 is first uploaded, so I'm creating new PR.
This PR includes:
- construction of table-* flows (table-wrapper, table-caption, table, table-rowgroup, table-row, table-cell)
- fixed-layout table calculation
- a part of anonymous table object implementation
[CSS 2.1, 17.2.1](http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes) (Step 1-1, 1-2, Step 2)
Source-Repo: https://github.com/servo/servo
Source-Revision: fd5e5cd18b41f0ce2b33fb97fb4e3d75ddbbbceb
2014-03-25 21:40:47 +04:00
|
|
|
|
_ => false,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Returns true if this flow is one of table-related flows.
|
|
|
|
|
fn is_table_kind(self) -> bool {
|
|
|
|
|
match self.class() {
|
2014-12-18 04:45:49 +03:00
|
|
|
|
FlowClass::TableWrapper | FlowClass::Table |
|
|
|
|
|
FlowClass::TableColGroup | FlowClass::TableRowGroup |
|
|
|
|
|
FlowClass::TableRow | FlowClass::TableCaption | FlowClass::TableCell => true,
|
servo: Merge #1973 - Support fixed-layout table and a part of anonymous table object (from june0cho:table_rebase); r=larsbergstrom,metajack
This is a rebase of #1548 on recent master.
There have been many changes since #1548 is first uploaded, so I'm creating new PR.
This PR includes:
- construction of table-* flows (table-wrapper, table-caption, table, table-rowgroup, table-row, table-cell)
- fixed-layout table calculation
- a part of anonymous table object implementation
[CSS 2.1, 17.2.1](http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes) (Step 1-1, 1-2, Step 2)
Source-Repo: https://github.com/servo/servo
Source-Revision: fd5e5cd18b41f0ce2b33fb97fb4e3d75ddbbbceb
2014-03-25 21:40:47 +04:00
|
|
|
|
_ => false,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 00:31:44 +04:00
|
|
|
|
/// Returns true if this flow has no children.
|
|
|
|
|
fn is_leaf(self) -> bool {
|
2017-12-15 21:44:50 +03:00
|
|
|
|
self.base().children.is_empty()
|
2012-09-27 05:17:44 +04:00
|
|
|
|
}
|
|
|
|
|
|
2014-01-23 04:04:08 +04:00
|
|
|
|
/// Returns the number of children that this flow possesses.
|
2015-04-02 17:06:41 +03:00
|
|
|
|
fn child_count(self) -> usize {
|
2017-12-15 21:44:50 +03:00
|
|
|
|
self.base().children.len()
|
2014-01-23 04:04:08 +04:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-05 02:52:39 +04:00
|
|
|
|
/// Return true if this flow is a Block Container.
|
|
|
|
|
///
|
2014-05-29 04:34:06 +04:00
|
|
|
|
/// Except for table fragments and replaced elements, block-level fragments (`BlockFlow`) are
|
|
|
|
|
/// also block container fragments.
|
2014-02-05 02:52:39 +04:00
|
|
|
|
/// Non-replaced inline blocks and non-replaced table cells are also block
|
|
|
|
|
/// containers.
|
|
|
|
|
fn is_block_container(self) -> bool {
|
|
|
|
|
match self.class() {
|
|
|
|
|
// TODO: Change this when inline-blocks are supported.
|
2014-12-18 04:45:49 +03:00
|
|
|
|
FlowClass::Block | FlowClass::TableCaption | FlowClass::TableCell => {
|
2014-02-05 02:52:39 +04:00
|
|
|
|
// FIXME: Actually check the type of the node
|
|
|
|
|
self.child_count() != 0
|
|
|
|
|
}
|
servo: Merge #1973 - Support fixed-layout table and a part of anonymous table object (from june0cho:table_rebase); r=larsbergstrom,metajack
This is a rebase of #1548 on recent master.
There have been many changes since #1548 is first uploaded, so I'm creating new PR.
This PR includes:
- construction of table-* flows (table-wrapper, table-caption, table, table-rowgroup, table-row, table-cell)
- fixed-layout table calculation
- a part of anonymous table object implementation
[CSS 2.1, 17.2.1](http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes) (Step 1-1, 1-2, Step 2)
Source-Repo: https://github.com/servo/servo
Source-Revision: fd5e5cd18b41f0ce2b33fb97fb4e3d75ddbbbceb
2014-03-25 21:40:47 +04:00
|
|
|
|
_ => false,
|
2014-02-05 02:52:39 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-19 01:17:07 +04:00
|
|
|
|
/// Returns true if this flow is a block flow.
|
|
|
|
|
fn is_block_flow(self) -> bool {
|
2013-10-29 00:31:44 +04:00
|
|
|
|
match self.class() {
|
2014-12-18 04:45:49 +03:00
|
|
|
|
FlowClass::Block => true,
|
servo: Merge #1973 - Support fixed-layout table and a part of anonymous table object (from june0cho:table_rebase); r=larsbergstrom,metajack
This is a rebase of #1548 on recent master.
There have been many changes since #1548 is first uploaded, so I'm creating new PR.
This PR includes:
- construction of table-* flows (table-wrapper, table-caption, table, table-rowgroup, table-row, table-cell)
- fixed-layout table calculation
- a part of anonymous table object implementation
[CSS 2.1, 17.2.1](http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes) (Step 1-1, 1-2, Step 2)
Source-Repo: https://github.com/servo/servo
Source-Revision: fd5e5cd18b41f0ce2b33fb97fb4e3d75ddbbbceb
2014-03-25 21:40:47 +04:00
|
|
|
|
_ => false,
|
2013-08-20 23:03:52 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-08-02 02:42:26 +04:00
|
|
|
|
|
2014-02-19 01:17:07 +04:00
|
|
|
|
/// Returns true if this flow is an inline flow.
|
|
|
|
|
fn is_inline_flow(self) -> bool {
|
2013-10-29 00:31:44 +04:00
|
|
|
|
match self.class() {
|
2014-12-18 04:45:49 +03:00
|
|
|
|
FlowClass::Inline => true,
|
servo: Merge #1973 - Support fixed-layout table and a part of anonymous table object (from june0cho:table_rebase); r=larsbergstrom,metajack
This is a rebase of #1548 on recent master.
There have been many changes since #1548 is first uploaded, so I'm creating new PR.
This PR includes:
- construction of table-* flows (table-wrapper, table-caption, table, table-rowgroup, table-row, table-cell)
- fixed-layout table calculation
- a part of anonymous table object implementation
[CSS 2.1, 17.2.1](http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes) (Step 1-1, 1-2, Step 2)
Source-Repo: https://github.com/servo/servo
Source-Revision: fd5e5cd18b41f0ce2b33fb97fb4e3d75ddbbbceb
2014-03-25 21:40:47 +04:00
|
|
|
|
_ => false,
|
2013-05-03 06:37:36 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 00:31:44 +04:00
|
|
|
|
/// Dumps the flow tree for debugging.
|
2015-11-24 05:19:07 +03:00
|
|
|
|
fn print(self, title: String) {
|
|
|
|
|
let mut print_tree = PrintTree::new(title);
|
|
|
|
|
self.print_with_tree(&mut print_tree);
|
2013-11-11 11:07:23 +04:00
|
|
|
|
}
|
|
|
|
|
|
2015-11-24 05:19:07 +03:00
|
|
|
|
/// Dumps the flow tree for debugging into the given PrintTree.
|
|
|
|
|
fn print_with_tree(self, print_tree: &mut PrintTree) {
|
|
|
|
|
print_tree.new_level(format!("{:?}", self));
|
|
|
|
|
self.print_extra_flow_children(print_tree);
|
2017-12-15 21:44:50 +03:00
|
|
|
|
for kid in self.base().child_iter() {
|
2015-11-24 05:19:07 +03:00
|
|
|
|
kid.print_with_tree(print_tree);
|
2013-11-11 11:07:23 +04:00
|
|
|
|
}
|
2015-11-24 05:19:07 +03:00
|
|
|
|
print_tree.end_level();
|
2012-09-27 05:17:44 +04:00
|
|
|
|
}
|
2016-03-26 04:38:41 +03:00
|
|
|
|
|
|
|
|
|
fn floats_might_flow_through(self) -> bool {
|
2017-12-15 21:44:50 +03:00
|
|
|
|
if !self.base().might_have_floats_in() && !self.base().might_have_floats_out() {
|
2016-03-26 04:38:41 +03:00
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
if self.is_root() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
if !self.is_block_like() {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
self.as_block().formatting_context_type() == FormattingContextType::None
|
|
|
|
|
}
|
2016-05-04 23:49:23 +03:00
|
|
|
|
|
|
|
|
|
fn baseline_offset_of_last_line_box_in_flow(self) -> Option<Au> {
|
2017-12-15 21:44:50 +03:00
|
|
|
|
for kid in self.base().children.iter().rev() {
|
2016-05-04 23:49:23 +03:00
|
|
|
|
if kid.is_inline_flow() {
|
2016-09-29 08:11:33 +03:00
|
|
|
|
if let Some(baseline_offset) = kid.as_inline().baseline_offset_of_last_line() {
|
2017-12-15 21:44:50 +03:00
|
|
|
|
return Some(kid.base().position.start.b + baseline_offset)
|
2016-09-29 08:11:33 +03:00
|
|
|
|
}
|
2016-05-04 23:49:23 +03:00
|
|
|
|
}
|
2017-12-15 21:44:50 +03:00
|
|
|
|
if kid.is_block_like() && !kid.base().flags.contains(FlowFlags::IS_ABSOLUTELY_POSITIONED) {
|
2016-05-04 23:49:23 +03:00
|
|
|
|
if let Some(baseline_offset) = kid.baseline_offset_of_last_line_box_in_flow() {
|
2017-12-15 21:44:50 +03:00
|
|
|
|
return Some(kid.base().position.start.b + baseline_offset)
|
2016-05-04 23:49:23 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
None
|
|
|
|
|
}
|
2013-10-29 00:31:44 +04:00
|
|
|
|
}
|
2012-09-27 05:17:44 +04:00
|
|
|
|
|
2015-08-22 00:29:35 +03:00
|
|
|
|
impl<'a> MutableFlowUtils for &'a mut Flow {
|
2015-04-01 21:03:45 +03:00
|
|
|
|
/// Calls `repair_style` and `bubble_inline_sizes`. You should use this method instead of
|
|
|
|
|
/// calling them individually, since there is no reason not to perform both operations.
|
2017-07-19 16:03:17 +03:00
|
|
|
|
fn repair_style_and_bubble_inline_sizes(self, style: &::ServoArc<ComputedValues>) {
|
2015-04-01 21:03:45 +03:00
|
|
|
|
self.repair_style(style);
|
2017-12-15 21:44:50 +03:00
|
|
|
|
self.mut_base().update_flags_if_needed(style);
|
2015-04-01 21:03:45 +03:00
|
|
|
|
self.bubble_inline_sizes();
|
|
|
|
|
}
|
2012-09-22 03:23:30 +04:00
|
|
|
|
}
|
2013-05-03 06:37:36 +04:00
|
|
|
|
|
2014-06-04 09:25:28 +04:00
|
|
|
|
impl MutableOwnedFlowUtils for FlowRef {
|
2014-03-03 22:37:33 +04:00
|
|
|
|
/// Set absolute descendants for this flow.
|
|
|
|
|
///
|
|
|
|
|
/// Set yourself as the Containing Block for all the absolute descendants.
|
|
|
|
|
///
|
2014-06-04 09:25:28 +04:00
|
|
|
|
/// This is called during flow construction, so nothing else can be accessing the descendant
|
|
|
|
|
/// flows. This is enforced by the fact that we have a mutable `FlowRef`, which only flow
|
|
|
|
|
/// construction is allowed to possess.
|
2015-08-17 22:56:53 +03:00
|
|
|
|
fn set_absolute_descendants(&mut self, abs_descendants: AbsoluteDescendants) {
|
2014-06-04 09:25:28 +04:00
|
|
|
|
let this = self.clone();
|
2017-12-15 21:44:50 +03:00
|
|
|
|
let base = FlowRef::deref_mut(self).mut_base();
|
2015-05-13 22:27:21 +03:00
|
|
|
|
base.abs_descendants = abs_descendants;
|
2015-09-02 01:36:58 +03:00
|
|
|
|
for descendant_link in base.abs_descendants.descendant_links.iter_mut() {
|
|
|
|
|
debug_assert!(!descendant_link.has_reached_containing_block);
|
2017-12-15 21:44:50 +03:00
|
|
|
|
let descendant_base = FlowRef::deref_mut(&mut descendant_link.flow).mut_base();
|
2015-09-02 01:36:58 +03:00
|
|
|
|
descendant_base.absolute_cb.set(this.clone());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Sets the flow as the containing block for all absolute descendants that have been marked
|
|
|
|
|
/// as having reached their containing block. This is needed in order to handle cases like:
|
|
|
|
|
///
|
2018-01-20 17:51:27 +03:00
|
|
|
|
/// ```html
|
|
|
|
|
/// <div>
|
|
|
|
|
/// <span style="position: relative">
|
|
|
|
|
/// <span style="position: absolute; ..."></span>
|
|
|
|
|
/// </span>
|
|
|
|
|
/// </div>
|
|
|
|
|
/// ```
|
2015-09-02 01:36:58 +03:00
|
|
|
|
fn take_applicable_absolute_descendants(&mut self,
|
|
|
|
|
absolute_descendants: &mut AbsoluteDescendants) {
|
|
|
|
|
let mut applicable_absolute_descendants = AbsoluteDescendants::new();
|
|
|
|
|
for absolute_descendant in absolute_descendants.descendant_links.iter() {
|
|
|
|
|
if absolute_descendant.has_reached_containing_block {
|
|
|
|
|
applicable_absolute_descendants.push(absolute_descendant.flow.clone());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
absolute_descendants.descendant_links.retain(|descendant| {
|
|
|
|
|
!descendant.has_reached_containing_block
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
let this = self.clone();
|
2017-12-15 21:44:50 +03:00
|
|
|
|
let base = FlowRef::deref_mut(self).mut_base();
|
2015-09-02 01:36:58 +03:00
|
|
|
|
base.abs_descendants = applicable_absolute_descendants;
|
2015-05-13 22:27:21 +03:00
|
|
|
|
for descendant_link in base.abs_descendants.iter() {
|
2017-12-15 21:44:50 +03:00
|
|
|
|
let descendant_base = descendant_link.mut_base();
|
2015-05-13 22:27:21 +03:00
|
|
|
|
descendant_base.absolute_cb.set(this.clone());
|
2014-03-03 22:37:33 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-01-23 04:04:08 +04:00
|
|
|
|
}
|
2014-05-02 22:58:29 +04:00
|
|
|
|
|
|
|
|
|
/// A link to a flow's containing block.
|
|
|
|
|
///
|
|
|
|
|
/// This cannot safely be a `Flow` pointer because this is a pointer *up* the tree, not *down* the
|
|
|
|
|
/// tree. A pointer up the tree is unsafe during layout because it can be used to access a node
|
|
|
|
|
/// with an immutable reference while that same node is being laid out, causing possible iterator
|
|
|
|
|
/// invalidation and use-after-free.
|
2014-06-04 09:25:28 +04:00
|
|
|
|
///
|
|
|
|
|
/// FIXME(pcwalton): I think this would be better with a borrow flag instead of `unsafe`.
|
2016-01-29 22:19:14 +03:00
|
|
|
|
#[derive(Clone)]
|
2014-05-02 22:58:29 +04:00
|
|
|
|
pub struct ContainingBlockLink {
|
2014-06-04 09:25:28 +04:00
|
|
|
|
/// The pointer up to the containing block.
|
2015-03-16 22:16:03 +03:00
|
|
|
|
link: Option<WeakFlowRef>,
|
2014-05-02 22:58:29 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl ContainingBlockLink {
|
|
|
|
|
fn new() -> ContainingBlockLink {
|
|
|
|
|
ContainingBlockLink {
|
2014-06-04 09:25:28 +04:00
|
|
|
|
link: None,
|
2014-05-02 22:58:29 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-04 09:25:28 +04:00
|
|
|
|
fn set(&mut self, link: FlowRef) {
|
2016-11-05 00:53:38 +03:00
|
|
|
|
self.link = Some(FlowRef::downgrade(&link))
|
2014-05-02 22:58:29 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[inline]
|
2015-08-03 19:38:21 +03:00
|
|
|
|
pub fn generated_containing_block_size(&self, for_flow: OpaqueFlow) -> LogicalSize<Au> {
|
2014-06-04 09:25:28 +04:00
|
|
|
|
match self.link {
|
2015-05-13 22:27:21 +03:00
|
|
|
|
None => {
|
|
|
|
|
panic!("Link to containing block not established; perhaps you forgot to call \
|
|
|
|
|
`set_absolute_descendants`?")
|
|
|
|
|
}
|
2015-08-17 22:56:53 +03:00
|
|
|
|
Some(ref link) => {
|
|
|
|
|
let flow = link.upgrade().unwrap();
|
|
|
|
|
flow.generated_containing_block_size(for_flow)
|
|
|
|
|
}
|
2014-06-04 09:25:28 +04:00
|
|
|
|
}
|
2014-05-02 22:58:29 +04:00
|
|
|
|
}
|
2015-08-03 19:38:21 +03:00
|
|
|
|
|
|
|
|
|
#[inline]
|
2016-06-23 11:03:02 +03:00
|
|
|
|
pub fn explicit_block_containing_size(&self, shared_context: &SharedStyleContext) -> Option<Au> {
|
2015-08-03 19:38:21 +03:00
|
|
|
|
match self.link {
|
|
|
|
|
None => {
|
|
|
|
|
panic!("Link to containing block not established; perhaps you forgot to call \
|
|
|
|
|
`set_absolute_descendants`?")
|
|
|
|
|
}
|
|
|
|
|
Some(ref link) => {
|
|
|
|
|
let flow = link.upgrade().unwrap();
|
|
|
|
|
if flow.is_block_like() {
|
2016-06-23 11:03:02 +03:00
|
|
|
|
flow.as_block().explicit_block_containing_size(shared_context)
|
2015-08-17 22:56:53 +03:00
|
|
|
|
} else if flow.is_inline_flow() {
|
2016-10-11 23:33:47 +03:00
|
|
|
|
Some(flow.as_inline().minimum_line_metrics.space_above_baseline)
|
2015-08-03 19:38:21 +03:00
|
|
|
|
} else {
|
|
|
|
|
None
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-05-02 22:58:29 +04:00
|
|
|
|
}
|
2015-05-13 22:27:21 +03:00
|
|
|
|
|
|
|
|
|
/// A wrapper for the pointer address of a flow. These pointer addresses may only be compared for
|
|
|
|
|
/// equality with other such pointer addresses, never dereferenced.
|
2017-08-24 01:18:31 +03:00
|
|
|
|
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
2015-05-13 22:27:21 +03:00
|
|
|
|
pub struct OpaqueFlow(pub usize);
|
|
|
|
|
|
|
|
|
|
impl OpaqueFlow {
|
|
|
|
|
pub fn from_flow(flow: &Flow) -> OpaqueFlow {
|
2017-10-14 05:43:09 +03:00
|
|
|
|
let object_ptr: *const Flow = flow;
|
|
|
|
|
let data_ptr = object_ptr as *const ();
|
|
|
|
|
OpaqueFlow(data_ptr as usize)
|
2015-05-13 22:27:21 +03:00
|
|
|
|
}
|
|
|
|
|
}
|