New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement stylesheet.ownerNode #23096
Changes from all commits
File filter...
Jump to…
| @@ -62,6 +62,12 @@ impl HTMLStyleElement { | ||
| } | ||
| } | ||
|
|
||
| fn stylesheet_owner_cleanup(&self) { | ||
| if let Some(cssom_stylesheet) = self.cssom_stylesheet.get() { | ||
| cssom_stylesheet.set_owner(None); | ||
| } | ||
| } | ||
|
|
||
| #[allow(unrooted_must_root)] | ||
| pub fn new( | ||
| local_name: LocalName, | ||
| @@ -143,6 +149,7 @@ impl HTMLStyleElement { | ||
| doc.remove_stylesheet(self.upcast(), s) | ||
| } | ||
| *self.stylesheet.borrow_mut() = Some(s.clone()); | ||
| self.stylesheet_owner_cleanup(); | ||
| self.cssom_stylesheet.set(None); | ||
| doc.add_stylesheet(self.upcast(), s); | ||
| } | ||
| @@ -216,6 +223,7 @@ impl VirtualMethods for HTMLStyleElement { | ||
|
|
||
| if context.tree_in_doc { | ||
| if let Some(s) = self.stylesheet.borrow_mut().take() { | ||
| self.stylesheet_owner_cleanup(); | ||
|
||
| document_from_node(self).remove_stylesheet(self.upcast(), &s) | ||
|
This conversation was marked as resolved
by sbansal3096
CYBAI
Collaborator
|
||
| } | ||
| } | ||
| @@ -7,8 +7,8 @@ | ||
| interface StyleSheet { | ||
| readonly attribute DOMString type_; | ||
| readonly attribute DOMString? href; | ||
| readonly attribute Element? ownerNode; | ||
|
This conversation was marked as resolved
by CYBAI
emilio
Member
|
||
|
|
||
| // readonly attribute (Element or ProcessingInstruction)? ownerNode; | ||
| // readonly attribute StyleSheet? parentStyleSheet; | ||
| readonly attribute DOMString? title; | ||
|
|
||
| @@ -1,4 +1,12 @@ | ||
| [MediaList2.xhtml] | ||
| [MediaList] | ||
| [MediaList2.xhtml] | ||
| [MediaList.mediaText] | ||
| expected: FAIL | ||
|
|
||
| [MediaList.length] | ||
sbansal3096
Author
Contributor
|
||
| expected: FAIL | ||
|
|
||
| [MediaList getter] | ||
| expected: FAIL | ||
|
|
||
| [MediaList.item] | ||
| expected: FAIL | ||
| @@ -1,5 +1,4 @@ | ||||||
| [ttwf-cssom-doc-ext-load-count.html] | ||||||
| type: testharness | ||||||
| [stylesheet.css should be unloaded and styleSheets.length === 0] | ||||||
|
This conversation was marked as resolved
by sbansal3096
CYBAI
Collaborator
|
||||||
| }, "stylesheet.css should be unloaded and styleSheets.length === 0"); |
and in current code change it's removed and only added the 3rd test as FAIL
| }, "stylesheet-1.css should be loaded and styleSheets.length === 1"); |
So, I think both of them are FAIL now.
This comment has been minimized.
This comment has been minimized.
sbansal3096
Apr 9, 2019
Author
Contributor
Actually the 2nd test is passing now, so I removed the FAIL label. And due to this test passing, it was revealed that there was some error previously in the 3rd test.
#23096 (comment)
This comment has been minimized.
This comment has been minimized.
CYBAI
Apr 9, 2019
Collaborator
Ahh, I see. Sorry, I misunderstood your comment yesterday. Then your current change is correct! Thanks!
| @@ -0,0 +1,19 @@ | ||
| <!doctype html> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>ownerNode null test</title> | ||
| <link rel="help" href="https://drafts.csswg.org/cssom/#dom-stylesheet-ownernode"> | ||
| <script src="/resources/testharness.js"></script> | ||
| <script src="/resources/testharnessreport.js"></script> | ||
| <style></style> | ||
| </head> | ||
| <body> | ||
| <script> | ||
| test(function() { | ||
| let sheet = document.querySelector("style").sheet; | ||
| assert_true(sheet.ownerNode instanceof HTMLStyleElement, "ownerNode should be an instance of HTMLStyleElement"); | ||
| sheet.ownerNode.remove(); | ||
| assert_equals(sheet.ownerNode, null, "ownerNode should be null after removing the styleSheet"); | ||
emilio
Member
|
||
| }, "ownerNode should be cleared out before removing the styleSheet"); | ||
| </script> | ||
| </body> | ||
I think it's good to move the cleanup of
cssom_stylesheetinto a function so that we can reuse it in bothset_stylesheetandunbind_from_tree. (Same forhtmlstyleelement.rs)Ex. (
pseudo code)