diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-07-20 02:58:34 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-20 02:58:34 -0500 |
commit | 2d01d41a506bcbc7f26a2284b9f42390d6ef96ab (patch) | |
tree | 7e1caa2ebff34abcd3de1e51db5a3c35e6988b7a /components/script | |
parent | 86ed7bfc099a73e2f560e4cf45ddb0ccbc05f0e3 (diff) | |
parent | 6d0e48f6cc91a3200911e00f3719d8cb7ff6b0c4 (diff) | |
download | servo-2d01d41a506bcbc7f26a2284b9f42390d6ef96ab.tar.gz servo-2d01d41a506bcbc7f26a2284b9f42390d6ef96ab.zip |
Auto merge of #12515 - servo:concrete-style, r=bholley
Make the style crate more concrete
Background:
The changes to Servo code to support Stylo began in the `selectors` crate with making pseudo-elements generic, defined be the user, so that different users (such as Servo and Gecko/Stylo) could have a different set of pseudo-elements supported and parsed. Adding a trait makes sense there since `selectors` is in its own repository and has others users (or at least [one](https://github.com/SimonSapin/kuchiki)).
Then we kind of kept going with the same pattern and added a bunch of traits in the `style` crate to make everything generic, allowing Servo and Gecko/Stylo to do things differently. But we’ve also added a `gecko` Cargo feature to do conditional compilation, at first to enable or disable some CSS properties and values in the Mako templates. Since we’re doing conditional compilation anyway, it’s often easier and simpler to do it more (with `#[cfg(feature = "gecko")]` and `#[cfg(feature = "servo")]`) that to keep adding traits and making everything generic. When a type is generic, any method that we want to call on it needs to be part of some trait.
----
The first several commits move some code around, mostly from `geckolib` to `style` (with `#[cfg(feature = "gecko")]`) but otherwise don’t change much.
The following commits remove some traits and many type parameters through the `style` crate, replacing them with pairs of conditionally-compiled API-compatible items (types, methods, …).
Simplifying code is nice to make it more maintainable, but this is motivated by another change described in https://github.com/servo/servo/pull/12391#issuecomment-232183942. (Porting Servo for that change proved difficult because some code in the `style` crate was becoming generic over `String` vs `Atom`, and this PR will help make that concrete. That change, in turn, is motivated by removing geckolib’s `[replace]` override for string-cache, in order to enable using a single Cargo "workspace" in this repository.)
r? @bholley
---
<!-- 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 #__ (github issue number if applicable).
<!-- Either: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require new tests because refactoring
<!-- 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/12515)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/dom/document.rs | 2 | ||||
-rw-r--r-- | components/script/dom/htmllinkelement.rs | 3 | ||||
-rw-r--r-- | components/script/dom/htmlmetaelement.rs | 3 | ||||
-rw-r--r-- | components/script/dom/htmlstyleelement.rs | 3 | ||||
-rw-r--r-- | components/script/layout_wrapper.rs | 5 |
5 files changed, 6 insertions, 10 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 09d58c55e1e..ff438eb7bf5 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -123,8 +123,8 @@ use string_cache::{Atom, QualName}; use style::attr::AttrValue; use style::context::ReflowGoal; use style::restyle_hints::ElementSnapshot; -use style::servo::Stylesheet; use style::str::{split_html_space_chars, str_join}; +use style::stylesheets::Stylesheet; use time; use url::Url; use url::percent_encoding::percent_decode; diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs index b341ad59a1f..d089caed3f5 100644 --- a/components/script/dom/htmllinkelement.rs +++ b/components/script/dom/htmllinkelement.rs @@ -39,9 +39,8 @@ use string_cache::Atom; use style::attr::AttrValue; use style::media_queries::{MediaQueryList, parse_media_query_list}; use style::parser::ParserContextExtraData; -use style::servo::Stylesheet; use style::str::HTML_SPACE_CHARACTERS; -use style::stylesheets::Origin; +use style::stylesheets::{Stylesheet, Origin}; use url::Url; no_jsmanaged_fields!(Stylesheet); diff --git a/components/script/dom/htmlmetaelement.rs b/components/script/dom/htmlmetaelement.rs index 724534dfdb6..b8c2cd423fa 100644 --- a/components/script/dom/htmlmetaelement.rs +++ b/components/script/dom/htmlmetaelement.rs @@ -20,9 +20,8 @@ use std::ascii::AsciiExt; use std::sync::Arc; use string_cache::Atom; use style::attr::AttrValue; -use style::servo::Stylesheet; use style::str::HTML_SPACE_CHARACTERS; -use style::stylesheets::{CSSRule, Origin}; +use style::stylesheets::{Stylesheet, CSSRule, Origin}; use style::viewport::ViewportRule; #[dom_struct] diff --git a/components/script/dom/htmlstyleelement.rs b/components/script/dom/htmlstyleelement.rs index e253fab12be..c7cc4cc44a3 100644 --- a/components/script/dom/htmlstyleelement.rs +++ b/components/script/dom/htmlstyleelement.rs @@ -19,8 +19,7 @@ use std::sync::Arc; use string_cache::Atom; use style::media_queries::parse_media_query_list; use style::parser::ParserContextExtraData; -use style::servo::Stylesheet; -use style::stylesheets::Origin; +use style::stylesheets::{Stylesheet, Origin}; #[dom_struct] pub struct HTMLStyleElement { diff --git a/components/script/layout_wrapper.rs b/components/script/layout_wrapper.rs index 78a6b1a2f71..8f22c369e4c 100644 --- a/components/script/layout_wrapper.rs +++ b/components/script/layout_wrapper.rs @@ -54,14 +54,14 @@ use std::mem::{transmute, transmute_copy}; use string_cache::{Atom, BorrowedAtom, BorrowedNamespace, Namespace}; use style::attr::AttrValue; use style::computed_values::display; +use style::context::SharedStyleContext; +use style::data::PrivateStyleData; use style::dom::{PresentationalHintsSynthetizer, OpaqueNode, TDocument, TElement, TNode, UnsafeNode}; use style::element_state::*; -use style::properties::{ComputedValues, ServoComputedValues}; use style::properties::{PropertyDeclaration, PropertyDeclarationBlock}; use style::refcell::{Ref, RefCell, RefMut}; use style::restyle_hints::ElementSnapshot; use style::selector_impl::{NonTSPseudoClass, ServoSelectorImpl}; -use style::servo::{PrivateStyleData, SharedStyleContext}; use style::sink::Push; use style::str::is_whitespace; use url::Url; @@ -110,7 +110,6 @@ impl<'ln> ServoLayoutNode<'ln> { } impl<'ln> TNode for ServoLayoutNode<'ln> { - type ConcreteComputedValues = ServoComputedValues; type ConcreteElement = ServoLayoutElement<'ln>; type ConcreteDocument = ServoLayoutDocument<'ln>; type ConcreteRestyleDamage = RestyleDamage; |