Auto merge of #26477 - mrobinson:layout-2020-get-computed-value, r=jdm

Add support for getComputedStyle() to layout_2020

These changes add support for `getComputedStyle()` to layout_2020.

---
<!-- 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] There are tests for these changes

<!-- 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. -->
This commit is contained in:
bors-servo 2020-05-11 15:57:25 -04:00 committed by GitHub
commit aa9f16ce45
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
188 changed files with 16312 additions and 15198 deletions

View file

@ -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,
};