Commit graph

77 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
006417e40a
style: Rustfmt recent changes. 2019-11-30 20:45:07 +01:00
Mats Palmgren
4359b3bd47
style: Make 'grid-area'/'grid-column'/'grid-row' shorthands serialize to shortest possible form.
Differential Revision: https://phabricator.services.mozilla.com/D54386
2019-11-30 20:45:04 +01:00
Mats Palmgren
70ec6ffe36
style: Make some grid/grid-template values serialize to a shorter form.
Differential Revision: https://phabricator.services.mozilla.com/D53913
2019-11-30 20:45:04 +01:00
Mats Palmgren
4a97d6f4a0 style: Implement 'repeat(auto-fill, <line-names>)' in subgridded axis.
Differential Revision: https://phabricator.services.mozilla.com/D46895
2019-10-09 13:21:35 +02:00
Emilio Cobos Álvarez
54ce45f3ee style: Update cbindgen.
This cleans up the pattern of "Use a private dtor so that the helper functions
do the right thing" by enabling it everywhere using:

  https://github.com/eqrion/cbindgen/pull/377

It also caught some uninitialized value issues.

I think they're mostly harmless since we zero-initialize our structs:

https://searchfox.org/mozilla-central/rev/325c1a707819602feff736f129cb36055ba6d94f/servo/components/style/properties/gecko.mako.rs#632

And since we override the clip rect, which is the other bit of code that was
failing to build with this change.

Differential Revision: https://phabricator.services.mozilla.com/D43491
2019-09-12 22:34:16 +02:00
Emilio Cobos Álvarez
4d8fc4b8f7
style: Fix formatting of recent changes. 2019-08-15 17:02:37 +02:00
Boris Chiou
29f6db4d16
style: Support multiple track sizes for grid-auto-{columns|rows}.
Support `<track-size>+` on the implicit track sizing properties,
grid-auto-columns and grid-auto-rows.

Differential Revision: https://phabricator.services.mozilla.com/D38408
2019-08-15 17:00:25 +02:00
Emilio Cobos Álvarez
708ce04896
Bug 1519958 - Improve stack size of grid templates and re-enable style struct size assertions disabled in the previous patch. r=boris
This re-enables the assertion which was disabled on the previous patch by doing
a bit of boxing around.

Differential Revision: https://phabricator.services.mozilla.com/D36599
2019-08-15 16:58:52 +02:00
Emilio Cobos Álvarez
3e39998068
style: Refactor grid types to preserve repeat() at computed value time and use cbindgen.
I'm _really_ sorry for the size of the patch. I tried to do this in two steps
but it was a lot of work and pretty ugly.

This patch makes us use cbindgen for grid-template-{rows,columns}, in order to:

 * Make us preserve repeat() at computed-value time. This is per spec since
   interpolation needs to know about repeat(). Except for subgrid, which did the
   repeat expansion at parse-time and was a bit more annoying (plus it doesn't
   really animate yet so we don't need it to comply with the spec).

 * Tweaks the WPT tests for interpolation to adopt the resolution at:
   https://github.com/w3c/csswg-drafts/issues/3503.

Trade-off here, as this patch stands, is that this change makes us use less
long-living memory, since we expand repeat() during layout, but at the cost of a
bit of CPU time during layout (conditional on the property applying though,
which wasn't the case before). It should be very easy to store a cached version
of the template, should this be too hot (I expect it isn't), or to change the
representation in other ways to optimize grid layout code if it's worth it.

Another trade-off: I've used SmallPointerArray to handle line-name merging,
pointing to the individual arrays in the style data, rather than actually
heap-allocating the merged lists. This would also be pretty easy to change
should we measure and see that it's not worth it.

This patch also opens the gate to potentially improving memory usage in some
other ways, by reference-counting line-name lists for example, though I don't
have data that suggests it is worth it.

In general, this patch makes much easier to tweak the internal representation of
the grid style data structures. Overall, I think it's a win, the amount of magic
going on in that mako code was a bit huge; it took a bit to wrap my head around
it.

This patch comments out the style struct size assertions. They will be
uncommented in a follow-up patch which contains some improvements for this type,
which are worth getting reviewed separately.

Also, this patch doesn't remove as much code as I would've hoped for because of
I tried not to change most of the dom/grid code for inspector, but I think a
fair bit of the nsGridContainerFrame.cpp code that collects information for it
can be simplified / de-copy-pasted to some extent. But that was a pre-existing
problem and this patch is already quite massive.

Differential Revision: https://phabricator.services.mozilla.com/D36598
2019-08-15 16:58:44 +02:00
Emilio Cobos Álvarez
1af30fa0c9
style: rustfmt recent changes. 2019-07-08 12:45:56 +02:00
Emilio Cobos Álvarez
cc15afa348
style: Use cbindgen for grid track sizing.
Differential Revision: https://phabricator.services.mozilla.com/D36118
2019-07-08 12:45:21 +02:00
Emilio Cobos Álvarez
87e3dadf22
style: Use the cbindgen representation for grid line properties.
We clamp earlier (parse time rather than computed value time), but that's the
only behavior change, which I think doesn't really matter.

Differential Revision: https://phabricator.services.mozilla.com/D35198
2019-07-08 12:43:39 +02:00
Emilio Cobos Álvarez
98091243a7
style: Use a more similar representation in Rust and C++ for grid lines.
Option<> is not FFI-safe, so if we want to use the same representation
everywhere we need to get rid of it. This also makes it take the same amount of
memory as the C++ representation, and it's not very complex, I'd think.

Differential Revision: https://phabricator.services.mozilla.com/D35195
2019-07-08 12:43:07 +02:00
Emilio Cobos Álvarez
49842f5031 style: Fix servo build, and appease tidy / fmt. 2019-04-12 12:20:15 +02:00
Emilio Cobos Álvarez
8c004c0858 style: Reformat recent changes. 2019-04-12 12:20:14 +02:00
Emilio Cobos Álvarez
a47dcb5707 style: Derive ToResolvedValue.
Differential Revision: https://phabricator.services.mozilla.com/D26783
2019-04-12 12:20:09 +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
f7a59bf0ee style: Use Rust sizes for flex-basis, width, height, and their min/max properties.
Really sorry for the size of the patch :(

Only intentional behavior change is in the uses of HasLengthAndPercentage(),
where it's easier to do the right thing. The checks that used to check for
(IsCalcUnit() && CalcHasPercentage()) are wrong since bug 957915.

Differential Revision: https://phabricator.services.mozilla.com/D19553
2019-02-23 21:02:18 -08:00
Emilio Cobos Álvarez
2e6d34cad9 style: Rustfmt recent changes. 2019-01-13 21:59:35 +01:00
Boris Chiou
2b77a29697 style: Implement Animate for track lists on grid-template-{columns|rows}.
Based on https://bugzilla.mozilla.org/show_bug.cgi?id=1348519#c6 and
https://github.com/w3c/csswg-drafts/issues/3201:

Currently grid-template-rows/columns interpolate “per computed value”, which
means that if the number of tracks differs, or any track changes to/from a
particular keyword value to any other value, or if a line name is added/removed
at any position, the entire track listing is interpolated as “discrete”.
But we "agree" with two more granular options:

1. Check interpolation type per track, rather than for the entire list, before
   falling back to discrete. I.e. a length-percentage track can animate between
   two values while an adjacent auto track flips discretely to min-content.
2. Allow discrete interpolation of line name changes independently of track
   sizes.

Besides, for the repeat() function, it's complicated to support interpolation
between different repeat types (i.e. auto-fill, auto-fit) and different repeat
counts, so we always fall-back to discrete if the first parameter of repeat()
is different.

Differential Revision: https://phabricator.services.mozilla.com/D16129
2019-01-13 21:58:44 +01:00
Emilio Cobos Álvarez
80651fde47 style: Manually rename some variables.
lop is not an acceptable variable name for LengthPercentage.

Differential Revision: https://phabricator.services.mozilla.com/D15813
2019-01-08 12:00:48 +01:00
Emilio Cobos Álvarez
daf1f02feb style: Rename LengthOrPercentage to LengthPercentage.
It does not represent `<length> | <percentage>`, but `<length-percentage>`, so
`LengthOrPercentage` is not the right name.

This patch is totally autogenerated using:

rg 'LengthOrPercentage' servo | cut -d : -f 1 | sort | uniq > files
for file in $(cat files); do sed -i "s#LengthOrPercentage#LengthPercentage#g" $file; done

Differential Revision: https://phabricator.services.mozilla.com/D15812
2019-01-08 12:00:48 +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
Emilio Cobos Álvarez
a9af61e3be
style: Don't allow auto in grid line names.
See https://github.com/w3c/csswg-drafts/issues/2856.

Differential Revision: https://phabricator.services.mozilla.com/D9882
2018-11-05 12:28:59 +01:00
chansuke
8dab4d659a
Format style component. 2018-09-09 16:24:45 +02:00
Xidorn Quan
0f7f9eebc0
style: Add some attributes for SpecifiedValueInfo to help deriving more from types.
Bug: 1434130
Reviewed-by: emilio
MozReview-Commit-ID: IyohSTbUO31
2018-04-29 03:28:48 +02:00
Xidorn Quan
7fe7b2ffb1
style: Add a ValueInfo trait for exposing types needed by devtools.
Most of types just derive it using proc_macro directly. Some of value
types need manual impl.

In my current plan, this new trait will be used in bug 1434130 to expose
values as well.

Bug: 1455576
Reviewed-by: emilio
MozReview-Commit-ID: LI7fy45VkRw
2018-04-29 03:28:34 +02:00
Bobby Holley
c99bcdd4b8 Run rustfmt on selectors, servo_arc, and style.
This was generated with:

./mach cargo fmt --package selectors &&
./mach cargo fmt --package servo_arc &&
./mach cargo fmt --package style

Using rustfmt 0.4.1-nightly (a4462d1 2018-03-26)
2018-04-10 17:35:15 -07:00
Anthony Ramine
4d0bf2ddf9 Opt into field bounds for #[derive(ToComputedValue)] 2018-03-09 18:54:59 +01:00
Anthony Ramine
2efd06c12d Remove #[compute(clone)] 2018-03-09 15:45:34 +01:00
Anthony Ramine
afaa00a344 Remove some uses of trivial_to_computed_value 2018-03-09 11:57:22 +01:00
Anthony Ramine
3d99a4489c Don't use define_css_keyword_enum in style anymore 2018-02-01 12:43:48 +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
de4dd638eb
style: Fix grid line serialization to avoid redundant spacing.
This fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1425227.
2017-12-16 01:26:18 +01:00
Emilio Cobos Álvarez
92944cd5eb
style: Make css(dimension) apply to the variant. 2017-11-12 16:25:00 +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
c0f8f15f39 Update to cssparser 0.22 (source location in error types) 2017-10-10 13:28:17 +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
Emilio Cobos Álvarez
a3bfa5db3e
style: Get rid of a few ComputedValueAsSpecified in grid.
Need Box to remove the macro invocation.
2017-09-11 11:29:30 +02:00
Emilio Cobos Álvarez
64ab73eabd
style: Properly use integers on grid properties, and derive ToComputedValue. 2017-09-11 11:29:27 +02:00
Emilio Cobos Álvarez
02d24061e7
style: Avoid ComputedValueAsSpecified for TrackKeyword. 2017-09-11 11:22:25 +02:00
Fernando Jiménez Moreno
8306946e7f stylo: store specified value of grid layout repeat() function 2017-09-06 12:53:07 +02:00
Emilio Cobos Álvarez
36ff89bd28
style: Remove HasViewportPercentage.
It's not needed since #18268
2017-08-29 23:51:21 +02:00
Anthony Ramine
ef9d614349 Fix impl of ToComputedValue for TrackSize<T> 2017-08-28 22:48:08 +02:00
Anthony Ramine
3751fe9fdc Derive ToComputedValue for TrackBreadth<L> 2017-08-28 12:26:35 +02:00
Anthony Ramine
735e093de7 Implement #[compute(clone)] for #[derive(ToComputedValue)] 2017-08-28 10:39:53 +02:00