Commit graph

60 commits

Author SHA1 Message Date
Simon Sapin
131b12dc67 Reject @font-face descriptors with value value followed by more stuff. 2017-04-01 14:54:57 +02:00
Simon Sapin
b43e2fb0df Macroize conversion of @font-face values to Gecko types 2017-04-01 14:05:32 +02:00
Simon Sapin
61812d4d9d Make the parser accept @font-face rules without font-family or src.
Fix #16165.

Also, it turns out that the CSSFontFaceRule IDL specified in the
css-fonts spec is not web-compatible.
Instead browsers implement a .style attribute like in CSSStyleRule:
https://github.com/w3c/csswg-drafts/issues/825

This in turn requires preserving data about which descriptors
were set or not (distinguishing unset from set to a value that happens
to be the initial value),
so this commit also makes every field `Option<_>`.
2017-04-01 14:05:32 +02:00
Nazım Can Altınova
9991c496b3
Serialize unquoted font-family without quote 2017-03-30 23:40:23 +03:00
Xidorn Quan
2c0347ac5b Rename font_face::FontFaceRule to FontFaceData. 2017-03-30 11:41:07 +11:00
Simon Sapin
fe4e70c5f8 Introduce a ToCssWithGuard trait 2017-03-19 22:30:33 +01:00
Simon Sapin
8160490272 Remove some unused impls. 2017-03-07 23:37:28 +01:00
Simon Sapin
c3cad2d6c7 Update cssparser to 0.9 2017-02-15 12:42:14 +01:00
Simon Sapin
9ec8418d8c Rename CommaSeparated to OneOrMoreCommaSeparated, reflecting its behavior. 2017-02-03 13:15:53 +01:00
Simon Sapin
4701850f37 Add unicode-range descriptor to @font-face 2017-02-02 20:28:21 +01:00
Simon Sapin
0f351cb851 Fix incorrectly copy-pasted doc-comments. 2017-02-02 20:00:40 +01:00
Simon Sapin
f6bf397bb2 Add font-stretch descriptor to @font-face 2017-02-02 19:59:03 +01:00
Simon Sapin
fe8f5fad16 Add font-weight descriptor to @font-face 2017-02-02 19:58:40 +01:00
Simon Sapin
8767b0d7cc Add font-style descriptor in @font-face 2017-02-02 19:57:40 +01:00
Simon Sapin
5405fb0d73 Use FamilyName instead of FontFamily in @font-face
… to exclude generic families, per spec:
https://drafts.csswg.org/css-fonts/#font-family-desc
2017-02-02 19:37:31 +01:00
Simon Sapin
44f6c60d91 Separate mandatory and optional descriptors in @font-face parsing macro. 2017-02-02 19:02:57 +01:00
Simon Sapin
4bcae573b3 Macroize @font-face descriptor definitions 2017-02-02 18:32:02 +01:00
Simon Sapin
2b83d844da Use the Parse trait for @font-face parsing. 2017-02-02 18:32:01 +01:00
Simon Sapin
7724bb01a3 Remove intermediate FontFaceDescriptorDeclaration enum.
Have `@font-face` parsing write to `FontFaceRule` directly.
2017-02-02 18:32:01 +01:00
Emilio Cobos Álvarez
c6144df470
style: Document the font_face module. 2017-01-02 12:57:57 +01:00
Thiago Pontes
206f4ea5b8 use Either type for UrlOrNone
fix test-tidy errors

fix style unit test

use the Parse trait instead of ParseWithContext

fix stylo test and geckolib build

move all specified url parse code to parse trait and remove refs to unused type
2016-11-30 11:43:14 -05:00
Manish Goregaokar
0e19f456bc Fixup error from #14238 2016-11-23 09:32:47 -08:00
Nazım Can Altınova
fdbadcdce2 Implement ToCss serialization for CSSRules 2016-11-18 12:17:53 +03:00
Emilio Cobos Álvarez
913c874cb5
Urlmageddon: Use refcounted urls more often. 2016-11-17 18:34:23 +01:00
Simon Sapin
8bfe978c78 Update cssparser 2016-09-07 14:13:56 +08:00
Ms2ger
79e0d18a1d Add some documentation to the style crate. 2016-06-27 17:33:14 +02:00
Simon Sapin
00b6210519 Make the style crate almost build on stable Rust.
`discriminant_value` will need to be replaced with something else later.
2016-06-22 15:44:13 +02:00
Anthony Ramine
b97c7a8c4d Don't load all font faces sources
We stop at the first one we manage to load.
2016-06-10 21:51:06 +02:00
Anthony Ramine
64b34d5162 Introduce FontFaceRules::effective_sources()
This avoids downloading fonts in formats we don't support.
2016-06-06 23:43:09 +02:00
Per Lundberg
2f7ed1d73e Removed unused imports
This fixes #11185.
2016-05-15 22:24:26 +03:00
Simon Sapin
6889f37d9e Remove the url! plugin.
In rust-url 1.0 the `Url` struct is going to have private fields, and there
is no way to to create an aribitrary one without going through the parser.

The plugin never had a clear demonstrated performance benefit,
it was made mostly because it was possible and relatively easy at the time.
2016-04-14 15:35:28 +02:00
Anthony Ramine
cb5cd8d881 Say farewell to in-tree HeapSizeOf 2016-02-04 22:03:32 +01:00
Simon Sapin
6fd46b5e6a Update cssparser.
https://github.com/servo/rust-cssparser/pull/91
2016-01-21 17:58:03 +01:00
David Raifaizen
d942bfb474 Enabled use of FontFamily enum type and replaced plain string parameters with enum 2015-12-30 18:21:37 -05:00
Mathieu Agopian
11234f5370 Use Url.join instead of UrlParser.base_url(...).parse (#9002) 2015-12-18 17:02:41 +01:00
GauriGNaik
afdc60fa57 Make log_css_error in parser.rs take a &ParserContext argument and call this method 2015-12-02 16:03:04 -05:00
Corey Farwell
f34da4120d Implement 'url!(..)' macro
https://github.com/servo/rust-url/issues/136

https://github.com/servo/rust-url/pull/137
2015-11-21 08:15:56 -05:00
bors-servo
7ff3a17524 Auto merge of #8039 - tschneidereit:script-owns-stylesheets, r=jdm
Move Stylesheet loading and ownership from the layout task into HTML elements

Stylesheets for `HTMLLinkElement`s are now loaded by the resource task, triggered by the element in question. Stylesheets are owned by the elements they're associated with, which can be `HTMLStyleElement`, `HTMLLinkElement`, and `HTMLMetaElement` (for `<meta name="viewport">).

Additionally, the quirks mode stylesheet (just as the user and user agent stylesheets a couple of commits ago), is implemented as a lazy static, loaded once per process and shared between all documents.

This all has various nice consequences:
 - Stylesheet loading becomes a non-blocking operation.
 - Stylesheets are removed when the element they're associated with is removed from the document.
 - It'll be possible to implement the CSSOM APIs that require direct access to the stylesheets (i.e., ~ all of them).
 - Various subtle correctness issues are fixed.

One piece of interesting follow-up work would be to move parsing of external stylesheets to the resource task, too. Right now, it happens in the link element once loading is complete, so blocks the script task. Moving it to the resource task would probably be fairly straight-forward as it doesn't require access to any external state.

Depends on #7979 because without that loading stylesheets asynchronously breaks lots of content.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8039)
<!-- Reviewable:end -->
2015-11-08 01:11:54 +05:30
Till Schneidereit
068e6a8e9f Derive HeapSizeOf on more Stylesheet-related types
In preparation of storing `Stylesheet`s on nodes.
2015-11-07 16:19:23 +01:00
Simon Sapin
69d398f29a Update to rust-cssparser 0.4.0 2015-11-05 08:57:01 +01:00
Ravi Shankar
889eec364b sorted the extern crate, mod & use declarations 2015-09-24 02:12:45 +05:30
Patrick Walton
164e10202c devtools: Convert the developer tools to run over IPC. 2015-07-27 09:10:01 -07:00
James Gilbertson
85dcc2deaf Use iterators for iterating through CSS rules 2015-04-07 22:28:06 -06:00
Patrick Walton
750bbed2cb gfx: Perform more aggressive caching in
`FontContext::get_layout_font_group_for_style()`.

There are several optimizations here:

* We make font families atoms, to allow for quicker comparisons.

* We precalculate an FNV hash of the relevant fields of the font style
  structure.

* When obtaining a platform font group, we first check pointer equality
  for the font style. If there's no match, we go to the FNV hash. Only
  if both caches miss do we construct and cache a font group. Note that
  individual fonts are *also* cached; thus there are two layers of
  caching here.

15% improvement in total layout thread time for Facebook Timeline.
2015-04-01 08:58:16 -07:00
Simon Sapin
2ddb13db4b Remove usage of the deprecated .as_slice() in libstyle. 2015-02-13 09:36:01 +01:00
Simon Sapin
d5dd1d658e Upgrade to rustc ba2f13ef0 2015-02-04 2015-02-11 14:48:34 -08:00
Simon Sapin
d13d36f57f End the libstyle 'pub use' madness. 2015-01-30 15:08:29 +01:00
Simon Sapin
493a9e6a89 Bring CSS parse error reporting back. (Still off by default. Enable with RUST_LOG=style.) 2015-01-30 15:07:29 +01:00
Simon Sapin
966af0030a Upgrade to rust-cssparser master.
* Use associated types
* Avoid mutation to gather parsing results.
2015-01-30 15:07:29 +01:00
Josh Matthews
95fc29fa0d Update rustc to 00b112c45a604fa6f4b59af2a40c9deeadfdb7c6/rustc-1.0.0-dev. 2015-01-28 10:16:49 +10:00