Commit graph

69 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
a109fbb7c8 style: Use ArcSlice for quotes.
This saves the intermediate allocation.

Differential Revision: https://phabricator.services.mozilla.com/D30546
2019-05-29 16:14:10 +02:00
Cameron McCormack
40248ae5fd style: Add derived ToShmem implementations.
Differential Revision: https://phabricator.services.mozilla.com/D17197
2019-04-12 12:19:52 +02:00
Emilio Cobos Álvarez
35b8b95263 style: Implement a version of #[css(skip_if)] that takes more context.
I called it contextual_skip_if, though better names welcome.

Differential Revision: https://phabricator.services.mozilla.com/D21858
2019-03-13 15:08:19 +01:00
lqd
87e6ef3dde
Typo fix in new doc-comment
Co-Authored-By: SimonSapin <simon.sapin@exyr.org>
2019-01-11 16:35:26 +01:00
Simon Sapin
3a710f22ed Document public macros.
Undocumented public macros emit warnings in nightly-2019-01-11,
and we #![deny] that warning.
2019-01-11 14:17:22 +01:00
Simon Sapin
9b98beb769 Remove unused macro 2019-01-11 14:02:28 +01:00
Jan Andre Ikenmeyer
1d6fe65401
Update MPL license to https (part 4) 2018-11-19 14:47:27 +01:00
Emilio Cobos Álvarez
212b3e1311
style: Revert try -> r#try change.
Since we're in an inconsistent state because mako files weren't updated, and
it's really really ugly.
2018-11-10 21:42:17 +01:00
Simon Sapin
a15d33a10e cargo fix --edition 2018-11-10 17:47:28 +01:00
Pyfisch
9e92eb205a Reorder imports 2018-11-06 22:35:07 +01:00
chansuke
a2fc2ae517 Format component of style_traits 2018-09-08 13:28:13 +09:00
Emilio Cobos Álvarez
a6328ba3ce
style: Ensure all lonhands have a working clone(), and to_css.
This removes some dubious font-family code too.

It ensures that vector longhands have a proper clone implementation
auto-generating it using `collect()`.

Bug: 1461296
Reviewed-by: xidorn
MozReview-Commit-ID: FkdnbTkeF6E
2018-05-19 10:15:17 +02:00
Emilio Cobos Álvarez
40a616920c
style: Remove values::Verbatim.
No point of having two things that do the same.

Bug: 1457635
Reviewed-by: xidorn
MozReview-Commit-ID: Do1L4bvOeVQ
2018-05-05 16:20:38 +02:00
Emilio Cobos Álvarez
c508d8576d
style: Move represents_keyword to the css attributes.
Bug: 1457635
Reviewed-by: xidorn
MozReview-Commit-ID: 21yuU4h34AQ
2018-05-05 16:20:22 +02:00
Xidorn Quan
eb554044db
style: Add SequenceWriter::item_str for writing str items.
This will be used in the next patch for font-variant bitflag types.

Bug: 1434130
Reviewed-by: emilio
MozReview-Commit-ID: 2IvcsnYBNqA
2018-04-29 03:28:41 +02:00
Emilio Cobos Álvarez
951250882b
style: Document #[css(skip_if)] 2018-03-08 10:28:10 +01:00
Anthony Ramine
90b23963b7 Introduce #[css(if_empty = "…", iterable)] 2018-03-07 13:07:13 +01:00
Anthony Ramine
ca45695db1 Introduce #[css(skip)] 2018-03-05 15:53:15 +01:00
Anthony Ramine
1fa88b8c6a Simplify define_css_keyword_enum 2018-02-01 12:43:51 +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
b750f7096c
style: Document css(iterable) and css(dimension). 2017-11-12 16:25:02 +01:00
Emilio Cobos Álvarez
326f914018
style: Do not require to import ToCss in define_css_keyword_enum. 2017-10-24 14:30:51 +02: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
Simon Sapin
c0f8f15f39 Update to cssparser 0.22 (source location in error types) 2017-10-10 13:28:17 +02:00
Emilio Cobos Álvarez
a6eaa0812a
style: Share custom property declarations if they don't contain variable references. 2017-10-09 12:29:50 +02:00
Nicholas Nethercote
c5aa2cb986 Measure PropertyDeclaration more thoroughly.
This patch replaces the handwritten MallocSizeOf implementation for
PropertyDeclaration with a derived one, which gives much more thorough
measurement.

This requires (a) deriving MallocSizeOf for a *lot* of additional types (most
of which already have `derive(HeapSizeOf)` in Servo builds), and (b)
implementing MallocSizeOf for a few more types in the `malloc_size_of` crate.

These changes would significantly improve the reporting coverage for gmail if
it weren't for the fact that SpecifiedUrl isn't measured due to a lack of
clarity about its fields; that can be fixed as a follow-up once bug 1397971 has
landed.
2017-09-14 13:18:03 +10:00
Boris Chiou
535c1e3c6f Replace Au with CSSPixelLength in CalcLengthOrPercentage.
We replace Au with CSSPixelLength for the length part of
computed::CalcLengthOrPercentage. Therefore, it would be easier to use
CSSPixelLength for all other LengthOrPercentage{*} types.
2017-09-13 18:10:39 +08:00
Simon Sapin
e94d8d5bc1 Remove usage of write! in components/style/properties/longhand/box.mako.rs 2017-09-02 18:37:57 +02:00
Simon Sapin
37722838c6 Remove uses of write! in components/style_traits 2017-09-02 10:49:24 +02:00
Anthony Ramine
ba4136b5a8 Document how style traits can be derived 2017-08-28 12:26:43 +02:00
Simon Sapin
dc5dfafbba Use Parser::skip_whitespace in a few places to make Parser::try rewind less.
Gecko’s CSS parsing microbenchmarks before:

```
  43.437 ±  0.391 ms    Stylo.Servo_StyleSheet_FromUTF8Bytes_Bench
  29.244 ±  0.042 ms    Stylo.Gecko_nsCSSParser_ParseSheet_Bench
 281.884 ±  0.028 ms    Stylo.Servo_DeclarationBlock_SetPropertyById_Bench
 426.242 ±  0.008 ms    Stylo.Servo_DeclarationBlock_SetPropertyById_WithInitialSpace_Bench
```

After:

```
  29.779 ±  0.254 ms    Stylo.Servo_StyleSheet_FromUTF8Bytes_Bench
  28.841 ±  0.031 ms    Stylo.Gecko_nsCSSParser_ParseSheet_Bench
 296.240 ±  4.744 ms    Stylo.Servo_DeclarationBlock_SetPropertyById_Bench
 293.855 ±  4.304 ms    Stylo.Servo_DeclarationBlock_SetPropertyById_WithInitialSpace_Bench
```
2017-08-26 01:44:45 +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
Simon Sapin
eb98ae6e04 Update cssparser to 0.18
https://github.com/servo/rust-cssparser/pull/171
2017-07-24 11:39:12 +02:00
Anthony Ramine
c03f5f19ab Introduce CommaWithSpace
This allows us to support stroke-dasharray the same way as comma-separated
values.
2017-06-27 23:37:48 +02:00
Anthony Ramine
17875b8a81 Introduce Separator::parse 2017-06-27 23:37:44 +02:00
Anthony Ramine
39e29f557e Simplify machinery to serialise optional parts of CSS values
We simply implement ToCss for Option<T>, printing nothing if the value is None,
and we then use SequenceWriter to skip writing of separators around empty parts.
2017-06-21 11:17:22 +02:00
Jonathan Chan
26179b3660 style: Have OneOrMoreSeparated replace OneOrMoreCommaSeparated.
A future patch series has some values that should be separated by spaces. This
allows us to re-use the code for serialization, but the types do get a little
clunky. The separator is now indicated with an associated type.
2017-06-19 16:09:37 -07:00
Hiroyuki Ikezoe
6c5915068a AllowedNumericType.is_ok() takes ParingMode as well.
And it returns true if ParsingMode.allows_all_numeric_values is true regardless
of AllowedNumericType itself.
2017-06-14 09:52:06 +09:00
Hiroyuki Ikezoe
7341574b66 Make AllowedLengthType.is_ok() returning true if parsing mode allows all numeric values.
Even if the type is NonNegative and the given value is a negative.
2017-06-14 09:51:54 +09:00
Josh Matthews
27ae1ef2e7 Thread ParseError return values through CSS parsing. 2017-06-09 16:46:25 -04:00
Anthony Ramine
c8c6f3482f Implement ToCss for str and String 2017-06-08 11:13:39 +02:00
Anthony Ramine
45e8b0e8c7 Support unit variants when deriving ToCss 2017-06-07 16:47:59 +02:00
bors-servo
0b3fd8de76 Auto merge of #16067 - Wafflespeanut:grid, r=nox,Wafflespeanut
Stylo: Add support for grid-template-{rows,columns}

This has the implementation of grid's `<track-list>` nightmare.

---
<!-- 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 #15311

<!-- Either: -->
- [x] There are tests for these changes

<!-- 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/16067)
<!-- Reviewable:end -->
2017-05-18 17:09:15 -05:00
Ravi Shankar
81b4e64dfc Add parsing/serialization for repeat() function 2017-05-18 21:56:38 +05:30
Anthony Ramine
d0b9bd9c64 Refactor how calc() clamping is done on computed values (fixes #15296) 2017-05-18 10:14:59 +02:00
Cameron McCormack
10f2d3c38e style: Add support for property value aliases.
For keyword-typed properties with aliases but no extra_specified values,
the storage of the specified and computed values could be the same,
since value aliases are resolved at parse time.  But to prevent
computed_value::T::parse from recognizing these aliases, we keep the
specified and computed value types distinct.
2017-04-17 11:24:21 +10:00
Anthony Ramine
dfbd89860a Don't reject out of bound calc() values at parsing-time
https://bugzilla.mozilla.org/show_bug.cgi?id=1355014
2017-04-12 14:07:38 +02:00
Anthony Ramine
12d46e7d01 Rename AllowedNumericType to AllowedLengthType 2017-04-12 13:58:38 +02:00
Pyfisch
480f59c880 Implement serialization for transform functions.
Preserve more information from transform function parsing.
Preserve angle unit while parsing.
Simplify SpecifiedMatrix.
Use the write! macro for formatting with a helper called Css.
Implement ToCss for &T if T implements ToCss.
Add some tests and update others.

closes #15194
2017-04-04 19:04:19 +02:00
Emilio Cobos Álvarez
a5436e9091
style: Add <keyword>::from_ident helper to avoid tokenizing the same value multiple times. 2017-03-26 18:12:02 +02:00