mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
css: Refactor StyleSheetInDocument
owner (#38136)
Refactor `documentotshadowroot::StyleSheetInDocument`, renaming it into `ServoStylesheetInDocument` to avoid confusion with Stylo's `StylesheetInDocument` trait. To support constructed stylesheet. The `ServoStylesheetInDocument.owner` would contains enum of: - `Dom<Element>` - for stylesheet parsed from an element. - `Dom<CSSStylesheet>` - for constructed stylesheet. Testing: No WPT regression. Fixes: #38133 --------- Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
This commit is contained in:
parent
d671f58078
commit
bbed6cddcd
6 changed files with 112 additions and 57 deletions
|
@ -11,7 +11,7 @@ use crate::dom::bindings::reflector::{Reflector, reflect_dom_object};
|
|||
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||
use crate::dom::cssstylesheet::CSSStyleSheet;
|
||||
use crate::dom::document::Document;
|
||||
use crate::dom::element::Element;
|
||||
use crate::dom::documentorshadowroot::StylesheetSource;
|
||||
use crate::dom::shadowroot::ShadowRoot;
|
||||
use crate::dom::stylesheet::StyleSheet;
|
||||
use crate::dom::window::Window;
|
||||
|
@ -39,7 +39,8 @@ impl StyleSheetListOwner {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn add_stylesheet(&self, owner: &Element, sheet: Arc<Stylesheet>) {
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))] // Owner needs to be rooted already necessarily.
|
||||
pub(crate) fn add_stylesheet(&self, owner: StylesheetSource, sheet: Arc<Stylesheet>) {
|
||||
match *self {
|
||||
StyleSheetListOwner::Document(ref doc) => doc.add_stylesheet(owner, sheet),
|
||||
StyleSheetListOwner::ShadowRoot(ref shadow_root) => {
|
||||
|
@ -48,7 +49,8 @@ impl StyleSheetListOwner {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn remove_stylesheet(&self, owner: &Element, s: &Arc<Stylesheet>) {
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))] // Owner needs to be rooted already necessarily.
|
||||
pub(crate) fn remove_stylesheet(&self, owner: StylesheetSource, s: &Arc<Stylesheet>) {
|
||||
match *self {
|
||||
StyleSheetListOwner::Document(ref doc) => doc.remove_stylesheet(owner, s),
|
||||
StyleSheetListOwner::ShadowRoot(ref shadow_root) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue