Commit graph

89 commits

Author SHA1 Message Date
Anthony Ramine
85950a801f Move #[css(iterable)] on fields rather than variants 2018-03-06 11:08:19 +01:00
Anthony Ramine
31036d6510 Derive ToCss for MediaList
This uncovered the fancy snowflake `use fmt::Write` in the impl of ToCss
for NonTSPseudoClass.
2018-03-05 12:02:31 +01:00
Anthony Ramine
cd8f96cc9e Change ToCss to take a CssWriter<W>
This more concrete wrapper type can write a prefix the very first time something
is written to it. This allows removing plenty of useless monomorphisations caused
by the former W/SequenceWriter<W> pair of types.
2018-01-23 10:41:42 +01:00
Emilio Cobos Álvarez
001c50bcca
style: Simplify a bit media query construction.
MozReview-Commit-ID: 3eqezFFWgNZ
2017-11-06 13:51:53 +01:00
Nicholas Nethercote
4506f0d30c Replace all uses of the heapsize crate with malloc_size_of.
Servo currently uses `heapsize`, but Stylo/Gecko use `malloc_size_of`.
`malloc_size_of` is better -- it handles various cases that `heapsize` does not
-- so this patch changes Servo to use `malloc_size_of`.

This patch makes the following changes to the `malloc_size_of` crate.

- Adds `MallocSizeOf` trait implementations for numerous types, some built-in
  (e.g. `VecDeque`), some external and Servo-only (e.g. `string_cache`).

- Makes `enclosing_size_of_op` optional, because vanilla jemalloc doesn't
  support that operation.

- For `HashSet`/`HashMap`, falls back to a computed estimate when
  `enclosing_size_of_op` isn't available.

- Adds an extern "C" `malloc_size_of` function that does the actual heap
  measurement; this is based on the same functions from the `heapsize` crate.

This patch makes the following changes elsewhere.

- Converts all the uses of `heapsize` to instead use `malloc_size_of`.

- Disables the "heapsize"/"heap_size" feature for the external crates that
  provide it.

- Removes the `HeapSizeOf` implementation from `hashglobe`.

- Adds `ignore` annotations to a few `Rc`/`Arc`, because `malloc_size_of`
  doesn't derive those types, unlike `heapsize`.
2017-10-18 22:20:37 +11:00
Matt Brubeck
efc3683cc7 Fix commonmark Markdown warnings in docs, part 1
Fixes warnings from rust-lang/rust#44229 when `--enable-commonmark` is
passed to rustdoc.

This is mostly a global find-and-replace for bare URIs on lines by
themselves in doc comments.
2017-10-17 11:24:57 -07:00
Simon Sapin
c64374bc58 Use the location in the error value when reporting a CSS error 2017-10-10 13:28:29 +02:00
Simon Sapin
c0f8f15f39 Update to cssparser 0.22 (source location in error types) 2017-10-10 13:28:17 +02:00
Simon Sapin
056e599562 Use the current parser location for CSS error
… rather than the start location of the current construct.
This likely places the error just *after* of the unexpected token
whereas before would be best, but that’s likely a much bigger change.

See https://bugzilla.mozilla.org/show_bug.cgi?id=1378861
2017-10-10 13:27:01 +02:00
Fernando Jiménez Moreno
337a90329c stylo: Error reporting for unknown media features 2017-09-08 12:48:50 +02:00
Simon Sapin
5d06c9959f Replace some more uses of write! in components/style 2017-09-04 19:01:43 +02:00
Clément DAVID
c5fe235112 order derivable traits lists
Ignoring :
 - **generated**.rs
 - python/tidy/servo_tidy_tests/rust_tidy.rs
2017-08-23 21:38:44 +02:00
Brad Werth
557ffa979d Rework MediaType to be an atom-based struct instead of an enum.
MozReview-Commit-ID: 1Tfrs9PBkhA
2017-08-09 13:25:30 -07:00
Corey Farwell
befe538472 Utilize match_ignore_ascii_case! in more places. 2017-07-29 09:58:09 +00:00
Simon Sapin
eb98ae6e04 Update cssparser to 0.18
https://github.com/servo/rust-cssparser/pull/171
2017-07-24 11:39:12 +02:00
Simon Sapin
a5bb55790f Untry style 2017-06-18 13:18:13 +02:00
Anthony Ramine
b0bc1d05a9 Derive ToCss for media query qualifiers 2017-06-17 13:46:32 +02:00
Josh Matthews
27ae1ef2e7 Thread ParseError return values through CSS parsing. 2017-06-09 16:46:25 -04:00
Anthony Ramine
f68e2fded9 Propagate quirks mode all the way to ParserContext
The quirks mode is still not properly propagated in geckolib.
2017-04-27 10:41:55 +02:00
Emilio Cobos Álvarez
ac7bc414d9
Bug 1325878: Pass the MediaList down to Servo, making <style media> work. r=xidorn
MozReview-Commit-ID: BUCSQJs2CNI
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-04-12 22:27:45 +08:00
Emilio Cobos Álvarez
27ca9e0a46
Bug 1325878: Support deep-cloning of ServoMediaLists. r=xidorn
MozReview-Commit-ID: K7NFe1tKrAZ
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-04-12 21:24:52 +08:00
J. Ryan Stinnett
1a31b87c22 Pass ParserContext down to lengths
To make it possible to check the rule type when parsing lengths, we need to pass
the `ParserContext` down through many layers to the place where length units are
parsed.

This change leaves it unused, so it's only to prepare for the next change.

MozReview-Commit-ID: 70YwtcCxnWw
2017-04-12 16:40:48 +08:00
Emilio Cobos Álvarez
78a3408405
Fix a few media query parsing bugs.
MozReview-Commit-ID: 6nUd2vA6zO
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-04-11 16:51:34 +08:00
Emilio Cobos Álvarez
f69983930d
style: Fix media query parsing when invalid queries are present. 2017-03-15 17:45:39 +01:00
Xidorn Quan
52c9f4b527 Implement MediaList for Stylo. 2017-03-13 17:55:25 +11:00
Emilio Cobos Álvarez
5b5243b8af
Bug 1331213: Bootstrap a Gecko-side Device, and track it's dirtiness manually in the per-doc data. r=heycam
The setup is quite different to Servo-land, so add a comment about the different
setup.

Also, check viewport rules when flushing stylesheets. I believe that the
previous behavior is plain wrong, though I haven't taken the time to come up
with a test case.

In any case, it doesn't hurt any of both back-ends.

MozReview-Commit-ID: 46gtTkesOsr
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-01-17 14:05:23 +01:00
Emilio Cobos Álvarez
c0cf847043
style: Isolate the soon-to-be style-backend-specific from the media_query module. 2017-01-07 12:34:43 +01:00
Boris Zbarsky
369fdddcd9 Bug 1298588 part 13. Make sure Device has a ComputedValues for stylo. r=bholley 2017-01-04 23:13:52 -05:00
Emilio Cobos Álvarez
c04c3c60c3
style: Serialize also "only" qualifier, and fix serialization of all media expressions without explicit qualifiers. 2016-12-30 15:05:28 +01:00
Emilio Cobos Álvarez
bb672f1a2c
style: Simplify media-query parsing so it's easier to split out. 2016-12-30 15:05:27 +01:00
Emilio Cobos Álvarez
8120906a15
style: Refactor media query serialization so it doesn't use an intermediate buffer.
I plan to move MediaType to ToCss soon.
2016-12-30 15:05:27 +01:00
Emilio Cobos Álvarez
b4caebae69
style: Cleanup and refactor how media types are represented.
This is necessary for the upcoming work in Stylo, given I plan to make MediaType
different for Servo and Gecko, and the Unknown variant doesn't fit in MediaType
to be fair, the device is never going to have any unknown media type.
2016-12-30 15:05:14 +01:00
Emilio Cobos Álvarez
ca93a2dcec
style: Add a way to update an empty stylesheet for @import.
We'll update the empty stylesheet we've created when instantiating the
ImportRule when the stylesheet finishes loading.
2016-12-16 16:57:19 +01:00
Emilio Cobos Álvarez
62d65c1872 style: Simplify some code in media_queries.rs 2016-12-16 14:53:17 +01:00
Nazım Can Altınova
c052835281 Implement MediaList interface 2016-12-02 23:46:40 +03:00
Gregory
84e9277771 implement support for the width media query
failing test for correct to_css of "width"

separate test for mq and to_css

implement css serialization for Eq

remove PASS test expectation

remove FIXME

simplify serialization
2016-11-26 17:31:41 +08:00
Emilio Cobos Álvarez
6c3458767b
style: Refactor and add infrastructure for font metrics in style.
This commit itself only moves things around and adds an extra parameter to the
`apply_declarations` function to eventually handle #14079 correctly.

Probably needs a more granular API to query fonts, á la nsFontMetrics, but
that's trivial to do once this is landed.

Then we should make the font provider mandatory, and implement the missing stylo
bits.
2016-11-13 11:54:10 +01:00
Xidorn Quan
5dfcb07f6a Allow empty media query list
And make empty list the default value of MediaList.

This commit also removes Option wrapper of Stylesheet.media because
a stylesheet should always have an associated media query list.
2016-11-10 17:42:16 +11:00
Xidorn Quan
2733ec3bdc Rename media_queries::MediaQueryList to MediaList 2016-11-08 13:09:31 +11:00
Ravi Shankar
6061985898 Prefer Servo-specific ToCss for all types 2016-11-07 09:14:22 +05:30
Simon Sapin
53b638c0e2 Update to string-cache 0.3 2016-11-03 16:23:05 +01:00
Jack Moffitt
138a0480fe Implement matchMedia and MediaQueryList
Fixes #13376.
2016-11-02 13:40:22 -06:00
Emilio Cobos Álvarez
d02c5b0281
style: Don't incorrectly clamp values in calc that might not be only lengths.
Expressions with percentages may be negative or positive at computed value time.

So, we can only clamp lengths at computed value time, which is what the other
browsers do.
2016-09-01 23:39:40 -07:00
Emilio Cobos Álvarez
be7a44315d
style: Allow calc in media queries. 2016-08-30 13:48:55 -07:00
Martin Robinson
6259df5e2d Update to euclid 0.8 2016-08-12 03:12:06 +02:00
Ms2ger
cbfe77cee1 Move some unit type definitions to style_traits. 2016-07-11 12:14:27 +02: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
Per Lundberg
2f7ed1d73e Removed unused imports
This fixes #11185.
2016-05-15 22:24:26 +03:00
Emilio Cobos Álvarez
9caaa6004e
style: Support lazy pseudo-elements
These can't be supported in Servo as of right now, because I'm not
totally sure the accesses that should be done in layout would be
thread-safe.

It can be revisited later though.
2016-05-03 19:01:54 +02:00