Repository: servo/servo
File: components/script/dom/shadowroot.rs (Rust)

Code before:
            can_gc,
        );
    }

    /// <https://drafts.csswg.org/cssom/#dom-documentorshadowroot-adoptedstylesheets>
    fn SetAdoptedStyleSheets(
        &self,
        context: JSContext,
        val: HandleValue,
        can_gc: CanGc,
    ) -> ErrorResult {
        let result = DocumentOrShadowRoot::set_adopted_stylesheet_from_jsval(
            context,
            self.adopted_stylesheets.borrow_mut().as_mut(),
            val,
            &StyleSheetListOwner::ShadowRoot(Dom::from_ref(self)),
            can_gc,
        );

        // If update is successful, clear the FrozenArray cache.
        if result.is_ok() {
            self.adopted_stylesheets_frozen_types.clear();
        }

        result
    }

    /// <https://fullscreen.spec.whatwg.org/#dom-document-fullscreenelement>
    fn GetFullscreenElement(&self) -> Option<DomRoot<Element>> {
        DocumentOrShadowRoot::get_fullscreen_element(
            self.upcast::<Node>(),
            self.fullscreen_element.get(),
        )
    }
}

impl VirtualMethods for ShadowRoot {
    fn super_type(&self) -> Option<&dyn VirtualMethods> {
        Some(self.upcast::<DocumentFragment>() as &dyn VirtualMethods)
    }

    fn bind_to_tree(&self, context: &BindContext, can_gc: CanGc) {
        if let Some(s) = self.super_type() {
            s.bind_to_tree(context, can_gc);
        }

        // TODO(stevennovaryo): Handle adoptedStylesheet to deal with different
        //                      constructor document.
        if context.tree_connected {
            let document = self.owner_document();
            document.register_shadow_root(self);

Review comment (suggestion):
```suggestion
    /// <https://fullscreen.spec.whatwg.org/#dom-document-fullscreenelement>
    fn GetFullscreenElement(&self) -> Option<DomRoot<Element>> {
        DocumentOrShadowRoot::get_fullscreen_element(
            self.upcast::<Node>(),
            self.document.fullscreen_element(),
        )
    }
```

Code after:
        val: HandleValue,
        can_gc: CanGc,
    ) -> ErrorResult {
        let result = DocumentOrShadowRoot::set_adopted_stylesheet_from_jsval(
            context,
            self.adopted_stylesheets.borrow_mut().as_mut(),
            val,
            &StyleSheetListOwner::ShadowRoot(Dom::from_ref(self)),
            can_gc,
        );

        // If update is successful, clear the FrozenArray cache.
        if result.is_ok() {
            self.adopted_stylesheets_frozen_types.clear();
        }

        result
    }

    /// <https://fullscreen.spec.whatwg.org/#dom-document-fullscreenelement>
    fn GetFullscreenElement(&self) -> Option<DomRoot<Element>> {
        DocumentOrShadowRoot::get_fullscreen_element(
            self.upcast::<Node>(),
            self.document.fullscreen_element(),
        )
    }
}

impl VirtualMethods for ShadowRoot {
    fn super_type(&self) -> Option<&dyn VirtualMethods> {
        Some(self.upcast::<DocumentFragment>() as &dyn VirtualMethods)
    }

    fn bind_to_tree(&self, context: &BindContext, can_gc: CanGc) {
        if let Some(s) = self.super_type() {
            s.bind_to_tree(context, can_gc);
        }

        // TODO(stevennovaryo): Handle adoptedStylesheet to deal with different
        //                      constructor document.
        if context.tree_connected {
            let document = self.owner_document();
            document.register_shadow_root(self);
        }

        let shadow_root = self.upcast::<Node>();

        shadow_root.set_flag(NodeFlags::IS_CONNECTED, context.tree_connected);

        let context = BindContext::new(shadow_root, IsShadowTree::Yes);