mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
layout_2020: Add initial support for getComputedStyle
This implementation is more-or-less on par with the one from layout_2013 and in some cases better. There are still some cases where we don't return the correct "resolved value," but this is enough to test animations and transitions.
This commit is contained in:
parent
4d541e8e38
commit
9c7b1ae715
188 changed files with 16312 additions and 15198 deletions
|
@ -237,7 +237,7 @@ impl FragmentTreeRoot {
|
|||
))
|
||||
}
|
||||
|
||||
fn find<T>(
|
||||
pub(crate) fn find<T>(
|
||||
&self,
|
||||
mut process_func: impl FnMut(&Fragment, &PhysicalRect<Length>) -> Option<T>,
|
||||
) -> Option<T> {
|
||||
|
@ -251,16 +251,18 @@ impl FragmentTreeRoot {
|
|||
pub fn get_content_box_for_node(&self, requested_node: OpaqueNode) -> Rect<Au> {
|
||||
let mut bounding_box = PhysicalRect::zero();
|
||||
self.find(|fragment, containing_block| {
|
||||
if fragment.tag() != Some(requested_node) {
|
||||
return None::<()>;
|
||||
}
|
||||
|
||||
let fragment_relative_rect = match fragment {
|
||||
Fragment::Box(fragment) if fragment.tag == requested_node => fragment
|
||||
Fragment::Box(fragment) => fragment
|
||||
.border_rect()
|
||||
.to_physical(fragment.style.writing_mode, &containing_block),
|
||||
Fragment::AbsoluteOrFixedPositioned(_) => PhysicalRect::zero(),
|
||||
Fragment::Text(fragment) if fragment.tag == requested_node => fragment
|
||||
Fragment::Text(fragment) => fragment
|
||||
.rect
|
||||
.to_physical(fragment.parent_style.writing_mode, &containing_block),
|
||||
Fragment::Box(_) |
|
||||
Fragment::Text(_) |
|
||||
Fragment::AbsoluteOrFixedPositioned(_) |
|
||||
Fragment::Image(_) |
|
||||
Fragment::Anonymous(_) => return None,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue