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 upImmutable CSSOM #14190
Immutable CSSOM #14190
Conversation
highfive
commented
Nov 12, 2016
|
Heads up! This PR modifies the following files:
|
highfive
commented
Nov 12, 2016
| @@ -112,7 +120,7 @@ pub struct KeyframesRule { | |||
| #[derive(Debug)] | |||
| pub struct MediaRule { | |||
| pub media_queries: Arc<RwLock<MediaList>>, | |||
| pub rules: Vec<CSSRule>, | |||
| pub rules: CSSRules, | |||
This comment has been minimized.
This comment has been minimized.
upsuper
Nov 13, 2016
Member
I think this would likely make it meaningless to wrap MediaRule in RwLock anymore. Probably we can do fine-grained lock everywhere...
This comment has been minimized.
This comment has been minimized.
Manishearth
Nov 13, 2016
Author
Member
Yeah a lot of the rwlocks will move around when I work on the mutable stuff.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
upsuper
Nov 14, 2016
Member
@SimonSapin Wrapping content of rules into Arc means we need to further wrap it into RwLock as well, otherwise it would not be as mutable as we expect. And wrapping both fields of MediaRule into Arc<RwLock> means there is likely no more need of mutating the struct itself, so it doesn't make sense anymore to have it wrapped in RwLock.
This comment has been minimized.
This comment has been minimized.
SimonSapin
Nov 14, 2016
Member
I see, thanks. I think this is ok for now, and I expect that once we have CSSOM functional in Servo and Stylo we’ll likely to a pass at simplifying/optimizing things.
5be9528
to
d4ef7a0
|
Ready for review. r? @SimonSapin I have not implemented CORS isn't handled either; so you can read the contents of a cross-origin stylesheet. This doesn't seem like a big deal (for now) to me, but I can implement this if necessary. In the current implementation, the CSSOM is lazy at every step. |
|
@bors-servo try |
Immutable CSSOM This PR is intended to add basic support for all CSSOM interfaces, with the ability to index `document.styleSheets` and css rule lists, and serializing individual css rules. Handling individual interface methods for CSSRule subclasses can probably be done with easy/medium bugs. Mutation safety isn't dealt with here; if the css rule list is mutated the CSSOM will be in an inconsistent state. I intend to deal with this via zero sized tokens, see https://groups.google.com/forum/#!topic/mozilla.dev.servo/AnxJoVmtMXQ . I'll handle that when I start making the CSSOM mutable. (Getting the immutable bit landed first opens this up for easy bugs) This doesn't really change style aside from adding an extra arc in the CSS rule list as discussed in the linked thread. So far this same design can be used by stylo as well when the time comes. f? @SimonSapin @emilio cc @upsuper Todo: - [x] Stubs for rest of the CSSRule subclasses - [ ] <s>ToCSS impls for CSSRules.</s> May make into easy bugs and stub out in this PR - [x] Cache CSSStyleSheet on the relevant node <!-- 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/14190) <!-- Reviewable:end -->
|
|
|
Ongoing builds: mac-rel-css, linux-rel-wpt, linux-rel-css |
|
I suspect some of the changes here may conflict with my patches in bug 1307357, so if this pr gets merged first, I hope there could be a merge from servo/servo to incubator/stylo soonish, so that I can update my patches accordingly. |
|
There are only two conflicting bits -- the first patch (which you can just import), and the |
|
I think you also want to separate the serialization algorithm of selectors from the |
|
Ah, okay. In that case I'll just use your serialization code |
|
Updated tocss code. Made minor adjustments for better code and to match the spec. |
|
@bors-servo retry |
|
|
|
|
highfive
commented
Nov 16, 2016
|
|
@bors-servo retry |
|
@bors-servo r=SimonSapin (intermittent disabling r+d in irc) |
|
|
|
|
|
Immutable CSSOM This PR is intended to add basic support for all CSSOM interfaces, with the ability to index `document.styleSheets` and css rule lists, and serializing individual css rules. Handling individual interface methods for CSSRule subclasses can probably be done with easy/medium bugs. Mutation safety isn't dealt with here; if the css rule list is mutated the CSSOM will be in an inconsistent state. I intend to deal with this via zero sized tokens, see https://groups.google.com/forum/#!topic/mozilla.dev.servo/AnxJoVmtMXQ . I'll handle that when I start making the CSSOM mutable. (Getting the immutable bit landed first opens this up for easy bugs) This doesn't really change style aside from adding an extra arc in the CSS rule list as discussed in the linked thread. So far this same design can be used by stylo as well when the time comes. f? @SimonSapin @emilio cc @upsuper part of #11420 Todo: - [x] Stubs for rest of the CSSRule subclasses - [x] <s>ToCSS impls for CSSRules.</s> May make into easy bugs and stub out in this PR #14195 - [x] Cache CSSStyleSheet on the relevant node <!-- 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/14190) <!-- Reviewable:end -->
|
|
CSSOM: Add insertRule() and deleteRule() on CSSStyleSheet; LinkStyle impls on <style> and <link> CSSOM is now starting to be useful! Based on #14190. Only the <s>last commit</s> last two commits need review. cc @Xidorn . This doesn't change the style API, but adds useful methods. part of #11420 r? @SimonSapin <!-- 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/14241) <!-- Reviewable:end -->
CSSOM: Add insertRule() and deleteRule() on CSSStyleSheet; LinkStyle impls on <style> and <link> CSSOM is now starting to be useful! Based on #14190. Only the <s>last commit</s> last two commits need review. cc @Xidorn . This doesn't change the style API, but adds useful methods. part of #11420 r? @SimonSapin <!-- 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/14241) <!-- Reviewable:end -->
Implement ToCss serialization for CSSRules <!-- Please describe your changes on the following line: --> Implementation of ToCss serialization for CSSRules. It requires #14190 to merge first to uncomment `CssRule::Style` branch in CssRule's ToCss implementation. r? @Manishearth --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #14195 (github issue number if applicable). - [X] These changes do not require tests because it's serialization changes and I'm not sure there is a test for that. <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- 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/14238) <!-- Reviewable:end -->
Implement ToCss serialization for CSSRules <!-- Please describe your changes on the following line: --> Implementation of ToCss serialization for CSSRules. It requires #14190 to merge first to uncomment `CssRule::Style` branch in CssRule's ToCss implementation. r? @Manishearth --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #14195 (github issue number if applicable). - [X] These changes do not require tests because it's serialization changes and I'm not sure there is a test for that. <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- 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/14238) <!-- Reviewable:end -->
CSSOM: Whole ton of things CSSOM is now starting to be useful! Based on #14190. Only the <s>last commit</s> last two commits need review. cc @Xidorn . This doesn't change the style API, but adds useful methods. part of #11420 This adds: - `insertRule()` and `deleteRule()` on `CSSStyleSheet`, `CSSGroupingRule` - `.style` getters on link and style elements - Keyframes-backed `CSSRules` and `CSSKeyframesRule.cssRules` - `CSSGroupingRule.cssRules` - `prefix` and `namespaceURI` attributes of `CSSNamespaceRule` - Fixups regarding parent stylesheets r? @SimonSapin <!-- 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/14241) <!-- Reviewable:end -->
CSSOM: Whole ton of things CSSOM is now starting to be useful! Based on #14190. Only the <s>last commit</s> last two commits need review. cc @Xidorn . This doesn't change the style API, but adds useful methods. part of #11420 This adds: - `insertRule()` and `deleteRule()` on `CSSStyleSheet`, `CSSGroupingRule` - `.style` getters on link and style elements - Keyframes-backed `CSSRules` and `CSSKeyframesRule.cssRules` - `CSSGroupingRule.cssRules` - `prefix` and `namespaceURI` attributes of `CSSNamespaceRule` - Fixups regarding parent stylesheets r? @SimonSapin <!-- 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/14241) <!-- Reviewable:end -->
CSSOM: Whole ton of things CSSOM is now starting to be useful! Based on #14190. Only the <s>last commit</s> last two commits need review. cc @Xidorn . This doesn't change the style API, but adds useful methods. part of #11420 This adds: - `insertRule()` and `deleteRule()` on `CSSStyleSheet`, `CSSGroupingRule` - `.style` getters on link and style elements - Keyframes-backed `CSSRules` and `CSSKeyframesRule.cssRules` - `CSSGroupingRule.cssRules` - `prefix` and `namespaceURI` attributes of `CSSNamespaceRule` - Fixups regarding parent stylesheets r? @SimonSapin <!-- 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/14241) <!-- Reviewable:end -->
Manishearth commentedNov 12, 2016
•
edited
This PR is intended to add basic support for all CSSOM interfaces, with the ability to index
document.styleSheetsand css rule lists, and serializing individual css rules. Handling individual interface methods for CSSRule subclasses can probably be done with easy/medium bugs.Mutation safety isn't dealt with here; if the css rule list is mutated the CSSOM will be in an inconsistent state. I intend to deal with this via zero sized tokens, see https://groups.google.com/forum/#!topic/mozilla.dev.servo/AnxJoVmtMXQ . I'll handle that when I start making the CSSOM mutable. (Getting the immutable bit landed first opens this up for easy bugs)
This doesn't really change style aside from adding an extra arc in the CSS rule list as discussed in the linked thread. So far this same design can be used by stylo as well when the time comes.
f? @SimonSapin @emilio
cc @upsuper
part of #11420
Todo:
ToCSS impls for CSSRules.May make into easy bugs and stub out in this PR #14195This change is