servo/components/style
bors-servo 5b4cc9568d Auto merge of #14043 - servo:string-cache-up, r=nox
Update to string-cache 0.3

Previously, `string-cache` defined:
*  An string-like `Atom` type,
* An `atom!("foo")` macro that expands to a value of that type, for a set of strings known at compile-time,
* A `struct Namespace(Atom);` type
* A `ns!(html)` macro that maps known prefixed to `Namespace` values with the corresponding namespace URL.

Adding a string to the static set required making a change to the `string-cache` crate.

With 0.3, the `Atom` type is now generic, with a type parameter that provides a set of static strings. We can have multiple such sets, defined in different crates. The `string_cache_codegen` crate, to be used in build scripts, generates code that defines such a set, a new atom type (a type alias for `Atom<_>` with the type parameter set), and an `atom!`-like macro.

The html5ever repository has a new `html5ever_atoms` crate that defines three such types: `Prefix`, `Namespace`, and `LocalName` (with respective `namespace_prefix!`, `namespace_url!`, and `local_name!` macros). It also defines the `ns!` macro like before.

This repository has a new `servo_atoms` crate in `components/atoms` that, for now, defines a single `Atom` type (and `atom!`) macro. (`servo_atoms::Atom` is defined as something like `type Atom = string_cache::Atom<ServoStaticStringSet>;`, so overall there’s now two types named `Atom`.)

In this PR, `servo_atoms::Atom` is used for everything else that was `string_cache::Atom` before. But more atom types can be defined as needed. Two reasons to do this are to auto-generate the set of static strings (I’m planning to do this for CSS property names, which is the motivation for this change), or to have the type system help us avoid mix up unrelated things (this is why we had a `Namespace` type ever before this change).

Introducing new types helped me find a bug: when creating a new attribute `dom::Element::set_style_attr`, would pass `Some(atom!("style"))` instead of `None` (now `Option<html5ever_atoms::Prefix>` instead of `Option<string_cache::Atom>`) to the `prefix` argument of `Attr::new`. I suppose the author of that code confused it with the `local_name` argument.

---

Note that Stylo is not affected by any of this. The `gecko_string_cache` module is unchanged, with a single `Atom` type. The `style` crate conditionally compiles `Prefix` and `LocalName` re-exports for that are both `gecko_string_cache::Atom` on stylo.

---
<!-- 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
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- 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/14043)
<!-- Reviewable:end -->
2016-11-03 11:19:44 -05:00
..
binding_tools Whitelist ThreadSafeFooHolder types in bindings.rs. 2016-11-03 18:00:57 +08:00
gecko Make style context use parking_lot::RwLock 2016-11-02 10:10:11 +11:00
gecko_bindings Regenerate bindings. 2016-11-03 18:00:59 +08:00
gecko_string_cache Auto merge of #14043 - servo:string-cache-up, r=nox 2016-11-03 11:19:44 -05:00
properties Update to string-cache 0.3 2016-11-03 16:23:05 +01:00
values Use enum BorderWidth as SpecifiedValue 2016-10-26 16:24:12 +08:00
animation.rs Update to string-cache 0.3 2016-11-03 16:23:05 +01:00
atomic_refcell.rs Implement AtomicRef::map. 2016-11-01 20:39:51 +01:00
attr.rs Update to string-cache 0.3 2016-11-03 16:23:05 +01:00
bezier.rs Move util::bezier to style 2016-02-14 19:45:24 +01:00
build.rs Run style with all properties enabled 2016-09-23 15:10:40 +05:30
cache.rs Remove usage of deprecated SipHasher. 2016-10-10 18:35:07 +02:00
Cargo.toml Update to string-cache 0.3 2016-11-03 16:23:05 +01:00
cascade_info.rs style: Introduce a generic way of gathering information from the cascade, and use it for viewport units. 2016-08-16 10:58:16 -07:00
context.rs Make style context use parking_lot::RwLock 2016-11-02 10:10:11 +11:00
custom_properties.rs Update to string-cache 0.3 2016-11-03 16:23:05 +01:00
data.rs Rename NodeData and associated data structures to Element*. 2016-10-29 14:58:07 -07:00
dom.rs Update to string-cache 0.3 2016-11-03 16:23:05 +01:00
element_state.rs Issue 7720: Add target selector and update when scrolling to fragment 2016-08-03 13:23:10 +01:00
error_reporting.rs Add some documentation to the style crate. 2016-06-27 17:33:14 +02:00
font_face.rs Update cssparser 2016-09-07 14:13:56 +08:00
keyframes.rs Add RwLock in more Arc’d things in stylesheets. 2016-10-19 19:55:05 +02:00
lib.rs Update to string-cache 0.3 2016-11-03 16:23:05 +01:00
logical_geometry.rs Reorder use statements 2016-09-09 04:55:19 +02:00
matching.rs Update to string-cache 0.3 2016-11-03 16:23:05 +01:00
media_queries.rs Update to string-cache 0.3 2016-11-03 16:23:05 +01:00
owning_handle.rs Implement OwningHandle in style. 2016-10-13 16:53:37 -06:00
parallel.rs Eliminate RestyleResult. 2016-11-01 11:03:04 -07:00
parser.rs Add safer bindings for RefPtr 2016-10-14 00:44:06 +05:30
README.md docs: Add style overview. 2016-05-04 00:34:03 +02:00
refcell.rs Revert "Make DOMRefCell use style’s copy of RefCell" 2016-10-04 18:35:01 +02:00
restyle_hints.rs Update to string-cache 0.3 2016-11-03 16:23:05 +01:00
selector_impl.rs Update to string-cache 0.3 2016-11-03 16:23:05 +01:00
selector_matching.rs Update to string-cache 0.3 2016-11-03 16:23:05 +01:00
sequential.rs Eliminate RestyleResult. 2016-11-01 11:03:04 -07:00
servo_selector_impl.rs Update to string-cache 0.3 2016-11-03 16:23:05 +01:00
sink.rs Move util::vec::ForgetfulSink to style::sink and simplify it 2016-07-04 16:48:14 +02:00
str.rs Move util::str to style 2016-07-05 10:43:54 +02:00
stylesheets.rs Update to string-cache 0.3 2016-11-03 16:23:05 +01:00
thread_state.rs Move thread_state to style. 2016-08-22 16:08:56 +02:00
tid.rs Move util::tid to style 2016-07-05 10:36:38 +02:00
timer.rs style: Add a new Timer structure to the shared style context, and basic infrastructure for controlling animations. 2016-07-20 09:05:53 -07:00
traversal.rs Drop style data from descendants on display:none. 2016-11-01 11:03:04 -07:00
viewport.rs Remove extra spaces in function calls and declarations 2016-10-31 18:11:37 +01:00
workqueue.rs style: Make WorkQueue creation fallible. 2016-08-25 23:43:31 -07:00

servo-style

Style system for Servo, using rust-cssparser for parsing.