mirror of
https://github.com/servo/servo
synced 2026-04-27 18:07:52 +02:00
script: Remove layout helper traits (#44092)
Servo has lots of `LayoutXYZHelper` traits that are used to define additional methods on `LayoutDom<XYZ>`. We can replace them with `impl LayoutDom<XYZ>` blocks, reducing the number of LoC and making it easier to add or modify methods. Testing: These should be covered by existing tests Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
@@ -17,9 +17,7 @@ use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::root::{DomRoot, LayoutDom};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::document::Document;
|
||||
use crate::dom::element::{
|
||||
CustomElementCreationMode, Element, ElementCreator, LayoutElementHelpers,
|
||||
};
|
||||
use crate::dom::element::{CustomElementCreationMode, Element, ElementCreator};
|
||||
use crate::dom::html::htmlcollection::HTMLCollection;
|
||||
use crate::dom::html::htmlelement::HTMLElement;
|
||||
use crate::dom::html::htmltablerowelement::HTMLTableRowElement;
|
||||
@@ -107,20 +105,15 @@ impl HTMLTableSectionElementMethods<crate::DomTypeHolder> for HTMLTableSectionEl
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) trait HTMLTableSectionElementLayoutHelpers {
|
||||
fn get_background_color(self) -> Option<AbsoluteColor>;
|
||||
fn get_height(self) -> LengthOrPercentageOrAuto;
|
||||
}
|
||||
|
||||
impl HTMLTableSectionElementLayoutHelpers for LayoutDom<'_, HTMLTableSectionElement> {
|
||||
fn get_background_color(self) -> Option<AbsoluteColor> {
|
||||
impl LayoutDom<'_, HTMLTableSectionElement> {
|
||||
pub(crate) fn get_background_color(self) -> Option<AbsoluteColor> {
|
||||
self.upcast::<Element>()
|
||||
.get_attr_for_layout(&ns!(), &local_name!("bgcolor"))
|
||||
.and_then(AttrValue::as_color)
|
||||
.cloned()
|
||||
}
|
||||
|
||||
fn get_height(self) -> LengthOrPercentageOrAuto {
|
||||
pub(crate) fn get_height(self) -> LengthOrPercentageOrAuto {
|
||||
self.upcast::<Element>()
|
||||
.get_attr_for_layout(&ns!(), &local_name!("height"))
|
||||
.map(AttrValue::as_dimension)
|
||||
|
||||
Reference in New Issue
Block a user