Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign up[WIP] Fix bug #17182: "Simplify `an+b` when serializing" #17241
Conversation
highfive
commented
Jun 8, 2017
|
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @nox (or someone else) soon. |
highfive
commented
Jun 8, 2017
|
Heads up! This PR modifies the following files:
|
Remove the assert_readonly test and add one to verify that assigning to
CSSStyleRule.style correctly forwards to CSSStyleRule.style.cssText.
We currently test for whether CSSStyleRule.style is read-only by
trying to assign to it; however, the spec has it as actually:
interface CSSStyleRule : CSSRule {
...
[SameObject, PutForwards=cssText] readonly attribute CSSStyleDeclaration style;
};
See: https://drafts.csswg.org/cssom/
The `PutForwards=cssText` means that assigning to CSSStyleRule.style
should actually assign to style.cssText.
…DefaultNamespace. It seems we don't need to preserve the original prefix name, and this conveniently leads to_css to now implement CSSOM's requirement to elide the namespace prefix during serialization when it maps to the default namespace. https://drafts.csswg.org/cssom/#serialize-a-simple-selector
…is modified. A future commit in this series will have CharacterData use this variant in calling children_changed on it's parent, so that HTMLStyleElement parents can re-parse.
|
|
||
| // https://drafts.csswg.org/cssom/#dom-cssstylerule-selectortext | ||
| fn SetSelectorText(&self, value: DOMString) { | ||
| let namespaces = Namespaces::default(); |
This comment has been minimized.
This comment has been minimized.
Manishearth
Jun 8, 2017
Member
@upsuper when setting selectors should we use the default namespace map or get the map from the stylesheet?
This comment has been minimized.
This comment has been minimized.
jyc
Jun 8, 2017
Author
Contributor
(for future readers, there is now an issue here: w3c/csswg-drafts#1511)
|
so far looks good! |
|
Weird! The test that CI is showing as failing actually seems to be contrary to what CSSOM says!
See the "attribute selector" section of https://drafts.csswg.org/cssom/#serializing-selectors . Going to check that. UPDATE: Line 1959 of |
This fixes an issue where an empty <style> element's data is set but the style is not updated. An HTMLStyleElement parent re-parses in its children_changed implementation. The ChildrenMutation::CharacterData variant introduced in the previous commit is used.
We parse when assigning using the namespaces of the stylesheet. It isn't clear if the spec says to do that (Firefox doesn't support the setter at all, Chrome does, Safari doesn't); the spec issue is here: w3c/csswg-drafts#1511 Also fix ToCss implementation of AttrSelectorOperator to not pad with spaces, to conform with CSSOM. This means we have to update some unit tests that expect operators with spaces around them in attribute selectors to roundtrip. See the "attribute selector" section of "Serializing Selectors" here: https://drafts.csswg.org/cssom/#serializing-selectors CSSStyleRule.selectorText is specified here: https://drafts.csswg.org/cssom/#dom-cssstylerule-selectortext
We already call Document::invalidate_style_sheets and set the stylesheet member to a new Stylesheet. This matches the behavior of Firefox, and means the new CSSStyleSheet you get from accessing .sheet from JS will be correct instead of stale. (::get_cssom_stylesheet already tries to use the new Stylesheet, but MutNullableJS::or_init is called, so if we already created a CSSStyleSheet we will continue to return that one). ./mach update-wpt also made some formatting changes to: - tests/wpt/mozilla/meta/mozilla/webgl/context_creation_error.html.ini - tests/wpt/mozilla/meta/mozilla/worklets/test_paint_worklet.html.ini ... for some reason (removed quotation marks and removed a line).
|
Oops, the |
|
It's already in #17203 so yeah, remove it for now. We'll try to land that first. |
|
@bors-servo try |
[WIP] Fix bug #17182: "Simplify `an+b` when serializing" Simplify serialization of `an+b`, and implement CSSStyleRule.selectorText and fix serialization of namespace components which map to the default one so that we are able to pass the existing web platform tests. -- - [x] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #17182 - [X] There are tests for these changes (existing cssom WPT) <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17241) <!-- Reviewable:end -->
|
|
|
Weird! Does this mean I need to update expected results? (Seems like it's all expected failures becoming passes). Some of those seem to be things I didn't update, but the |
|
Yes. You need to remove the corresponding meta files (or some lines in those files) from https://github.com/servo/servo/tree/master/tests/wpt/metadata-css |
|
Hi @upsuper ! Don't know if you remember me, but we met briefly at the All Hands last year, good to see you (in a way) again! Cool, I will try that when I head in tomorrow, along with removing the repeated work from the other bug. |
| let mut stylerule = self.stylerule.write_with(&mut guard); | ||
| mem::swap(&mut stylerule.selectors, &mut s); | ||
| } | ||
| } |
This comment has been minimized.
This comment has been minimized.
emilio
Jun 9, 2017
Member
This needs to somehow invalidate stylesheets, how do changes to the rules get reflected on the page otherwise?
This comment has been minimized.
This comment has been minimized.
| NthLastOfType(a, b) => write!(dest, ":nth-last-of-type({}n{:+})", a, b), | ||
| NthChild(a, b) | NthLastChild(a, b) | NthOfType(a, b) | NthLastOfType(a, b) => { | ||
| match *self { | ||
| NthChild(_, _) => write!(dest, ":nth-child(")?, |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| @@ -1929,7 +1956,7 @@ pub mod tests { | |||
| ].into_boxed_slice()) | |||
| ), specificity(0, 0, 1)) | |||
| )))); | |||
| assert_eq!(parse("[attr |= \"foo\"]"), Ok(SelectorList::from_vec(vec!( | |||
| assert_eq!(parse("[attr|=\"foo\"]"), Ok(SelectorList::from_vec(vec!( | |||
This comment has been minimized.
This comment has been minimized.
emilio
Jun 9, 2017
Member
Does this test need to be changed? Whitespace should be ignored while parsing, is it testing also that serialization roundtrips?
This comment has been minimized.
This comment has been minimized.
|
I'm confused, why are there so many commits in this PR that seem unrelated to what the PR title claim to fix? |
| /// This doesn't change the structure of the list, which is what the other | ||
| /// variants' fields are stored for at the moment, so this can just have no | ||
| /// arguments. | ||
| CharacterData, |
This comment has been minimized.
This comment has been minimized.
nox
Jun 9, 2017
Member
This should be Text, we never have to reparse anything if a Comment or a ProcessingInstruction is changed.
|
I would greatly appreciate it if this was split in at least 2 PRs, And also if you squashed the two following commits: Don't make separate commits when one of them introduce code that isn't yet called anywhere. |
| if let Some(parent_node) = node.GetParentNode() { | ||
| let mutation = ChildrenMutation::CharacterData; | ||
| vtable_for(&parent_node).children_changed(&mutation); | ||
| } |
This comment has been minimized.
This comment has been minimized.
|
Splitting up the pull request will mean that the parts from the end will fail CI until everything else has been merged--I've split it up into all of its parts, and can just wait for that before pushing. |
|
OK, I have split up the PR into different parts. I think we will need to land them in something this particular order to avoid intermediate test failures: (will push WIP PRs to correct test expectations as we go)
|
jyc commentedJun 8, 2017
•
edited by larsbergstrom
Simplify serialization of
an+b, and implement CSSStyleRule.selectorText and fix serialization of namespace components which map to the default one so that we are able to pass the existing web platform tests.--
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThese changes fix #17182
There are tests for these changes (existing cssom WPT)
This change is