Commit graph

329 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
31e8e418ea Miscellaneous build / tidy fixes. 2021-02-26 17:53:55 +01:00
Emilio Cobos Álvarez
9f40b9ba38 style: Avoid some allocations in selector serialization.
The allocations in display_to_css_identifier show up in the profiles of
bug 1675628.

Differential Revision: https://phabricator.services.mozilla.com/D97856
2021-02-26 16:44:05 +01:00
Emilio Cobos Álvarez
059a50bba0
style: Remove some unused extern crate declarations now that style is in rust 2018.
This avoids some warnings.
2020-06-18 23:51:18 +02:00
Emilio Cobos Álvarez
e5484250db
style: Remove the dependency on font-kit from style.
No good reason to have this IMO, and helps remove some #[cfg] blocks.
2020-06-18 23:51:17 +02:00
Utsav Oza
34d0c313dc Enable textAlign, textBaseline and direction attributes for canvas 2020-06-10 22:34:20 +05:30
Boris Chiou
fc9321bb23 style: Let aspect-ratio (css-sizing-4) support 'auto | <ratio>'.
In order to test its parsing and serialization, we expose it but protect
it behind a pref.

Besides, I would like to drop layout.css.aspect-ratio-number.enabled in
the next patch because the spec has been updated. It seems we don't have
to keep this pref and we should always use Number.

Differential Revision: https://phabricator.services.mozilla.com/D74955
2020-06-04 01:50:36 +02:00
Martin Robinson
3a74013abc Start having animations conform to the HTML spec
This is a small step toward fixing #19242. The main idea is that the
clock for animations should advance as the event loop ticks. We
accomplish this by moving the clock from layout and naming it the
"animation timeline" which is the spec language. This should fix
flakiness with animations and transitions tests where a reflow could
move animations forward while script was running.

This change also starts to break out transition and animation events
into their own data structure, because it's quite likely that the next
step in fixing #19242 is to no longer send these events through a
channel.
2020-05-05 20:08:44 +02:00
Martin Robinson
8f988be18a Add ElementAnimationState and PossibleElementAnimationState
This refactor is preparation for implementing a specification
compliant transitions and animations processing model.

These data structures hold all the animation information about a single
node. Since adding, updating, and modifying animations for a single node
are all interdependent, it makes sense to start encapsulating animation
data and functionality into a single data structure. This also opens up
the possibility for easier concurrency in the future by more easily
allowing per-node mutexes.
2020-04-24 11:51:17 +02:00
Simon Sapin
db4f27f361 Use the matches! macro from the standard library 2020-02-12 10:08:31 +01:00
Emilio Cobos Álvarez
071ce6f345
style: Rustfmt recent changes. 2020-02-12 02:43:23 +01:00
Emilio Cobos Álvarez
f03026b869
layout: Resolve word_spacing ahead of time.
It's not possible anymore, in the presence of min() / max(), to split a
<length-percentage> value into a <length> and a <percentage> component.

Tweak word_spacing to do what Gecko does (resolving it in advance).
2020-02-12 02:43:23 +01:00
Emilio Cobos Álvarez
16fd7cad0c
style: Add a style flag for the root element style.
This is needed to make the root element not a containing block in presence of
filters or what not.

Differential Revision: https://phabricator.services.mozilla.com/D61167
2020-02-12 02:43:18 +01:00
Emilio Cobos Álvarez
219c0f6328
style: Use cbindgen for content property.
This cleans up and also allows us to keep the distinction between content: none
and content: normal, which allows us to fix the computed style we return from
getComputedStyle().

Do this last bit from the resolved value instead of StyleAdjuster, because
otherwise we need to tweak every initial struct for ::before / ::after.

Differential Revision: https://phabricator.services.mozilla.com/D58276
2020-02-12 02:43:08 +01:00
Boris Chiou
40ede5bacb style: Use serde to serialize LengthPercentage and StyleRayFunction.
We need to pass these two types into the compositor, so we need a better
way to serialize these rust types. We use serde and bincode to
serialize/deserialize them, and use ByteBuf to pass the &[u8] data
through IPC. We define StyleVecU8 for FFI usage only.

Differential Revision: https://phabricator.services.mozilla.com/D50688
2019-11-04 13:36:32 +01:00
Emilio Cobos Álvarez
4752110d53
Fix Servo build and unify display representation. 2019-08-15 17:11:08 +02:00
Nicholas Nethercote
bb032c1ddc
style: Use static_prefs::pref!.
It's much nicer.

One nice thing about this is that the new code is subject to the existing
threadedness checking, which identified that several of these should be atomic
because they're accessed off the main thread.

Differential Revision: https://phabricator.services.mozilla.com/D40792
2019-08-15 17:00:37 +02:00
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
Emilio Cobos Álvarez
0d5c4481b8 style: Introduce ArcSlice, a small wrapper over ThinArc but without an explicit header.
We could make the header PhantomData or something, but then we wouldn't be able
to bind to C++, since C++ doesn't have ZSTs. So add a canary instead to add a
runtime check of stuff being sane.

Differential Revision: https://phabricator.services.mozilla.com/D30133
2019-05-10 12:43:04 +02:00
Emilio Cobos Álvarez
2ed2151b3d style: Move OwnedSlice to style_traits.
Differential Revision: https://phabricator.services.mozilla.com/D30126
2019-05-10 12:43:04 +02:00
Emilio Cobos Álvarez
330bccd659 style: Add an owned slice type which cbindgen can understand.
Passing these by value won't be ok of course, but that's fine.

I plan to combine this with https://github.com/eqrion/cbindgen/pull/333 to
actually be able to share representation for ~all the things, this is just the
first bit.

Box<T>, Atom and Arc<T> will be much easier since cbindgen can understand them
without issues.

It's boxed slices the only ones I should need something like this. I could avoid
it if I rely on Rust's internal representation, which we can per [1], but then I
need to teach cbindgen all about slices, which is generally hard, I think.

[1]: https://github.com/rust-lang/unsafe-code-guidelines/blob/master/reference/src/layout/pointers.md

Differential Revision: https://phabricator.services.mozilla.com/D29768
2019-05-10 12:43:02 +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
Cameron McCormack
7fa7c103d6 style: Add simple ToShmem implementations.
Differential Revision: https://phabricator.services.mozilla.com/D17190
2019-04-12 12:19:46 +02:00
Cameron McCormack
f6ef35c5d3 style: Add support for deriving ToShmem.
Differential Revision: https://phabricator.services.mozilla.com/D17189
2019-04-12 12:19:45 +02:00
Cameron McCormack
f581d2afb2 style: Add SharedMemoryBuilder type and ToShmem trait.
Differential Revision: https://phabricator.services.mozilla.com/D17187
2019-04-12 12:19:44 +02:00
Emilio Cobos Álvarez
7d01114cbf style: Add a Zero trait that doesn't require Add, and use it in place of num_traits and IsZeroLength.
Use it to be consistent in InsetRect serialization and storage between Servo and
Gecko.

Differential Revision: https://phabricator.services.mozilla.com/D21493
2019-03-13 15:08:14 +01:00
Emilio Cobos Álvarez
9909816c76 style: sort extern crates and fix servo build. 2019-01-29 03:17:24 +01:00
Bobby Holley
af1bbd7b06 style: Derive more.
Differential Revision: https://phabricator.services.mozilla.com/D17029
2019-01-29 02:39:13 +01:00
Cameron McCormack
63fd707bd3 style: Use atom handles in favour of atom pointers in style system code.
Differential Revision: https://phabricator.services.mozilla.com/D15078
2019-01-11 00:50:26 +01:00
Shanavas M
b763d6737c Remove OrderedMap in favor of IndexMap 2019-01-10 12:57:09 +05:30
Emilio Cobos Álvarez
006e71c7de style: Make Servo use a single thread-pool for layout-related tasks per-process.
Instead of per-document. This also allows to reuse this thread-pool if needed
for other stuff, like parallel CSS parsing (#22478), and to share more code with
Gecko, which is always nice.
2018-12-23 13:00:56 +01:00
Jan Andre Ikenmeyer
1d6fe65401
Update MPL license to https (part 4) 2018-11-19 14:47:27 +01:00
Bastien Orivel
9a7eeb349a Update crossbeam-channel to 0.3 2018-11-18 19:33:19 +01:00
Emilio Cobos Álvarez
667457a16c
style: Split up push_applicable_declarations.
Introduce RuleCollector, which contains all the state we need during the
cascade, and allows to reuse a bit of code.

Differential Revision: https://phabricator.services.mozilla.com/D11233
2018-11-10 21:10:34 +01:00
Simon Sapin
b1822a39fa cargo fix --edition --features gecko 2018-11-10 17:47:28 +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
Pyfisch
cb07debcb6 Format remaining files 2018-11-06 22:30:31 +01:00
Simon Sapin
2a996fbc8f Replace mpsc with crossbeam/servo channel, update ipc-channel
Co-authored-by: Gregory Terzian <gterzian@users.noreply.github.com>
2018-09-12 13:33:32 +08:00
chansuke
8dab4d659a
Format style component. 2018-09-09 16:24:45 +02:00
Emilio Cobos Álvarez
c8e5b7f1b0
style: Add a very simple use counter implementation.
As simple as I could make it, for now. We can improve on this.

Differential Revision: https://phabricator.services.mozilla.com/D3827
2018-09-03 12:31:23 +02:00
Emilio Cobos Álvarez
dc0f937224
style: Rewrite media queries so that they work on an evaluator function.
This moves most of the code to be Rust, except potentially some evaluator
functions, and allows to unblock the use case from any-hover / any-pointer and
remove nsMediaFeatures.

Differential Revision: https://phabricator.services.mozilla.com/D2976
2018-08-18 17:54:54 +02:00
Emilio Cobos Álvarez
689293e4fb
Fix Servo build. 2018-08-08 01:34:35 +02:00
Cameron McCormack
62419adaaa
style: Shrink selectors::Component to 24 bytes.
This saves about 37 KiB of memory across the UA style sheets.

Bug: 1475197
Reviewed-by: emilio
2018-08-08 01:36:53 +02:00
Nicholas Nethercote
fc9df0bcf3
style: Convert FnvHash{Set,Map} instances to FxHash{Set,Map}.
Bug: 1477628
Reviewed-by: heycam
2018-08-08 01:34:35 +02:00
Emilio Cobos Álvarez
921c389247
style: Remove some unneeded cfg(..).
The less not-compiled code in common builds, the better for everybody.
2018-05-05 17:53:22 +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
Bobby Holley
f7ae1a37e3 Manual fixups so that the rustfmt output won't trigger tidy. 2018-04-10 17:33:25 -07: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
Emilio Cobos Álvarez
5e64cb3516
style: Make XBL / Shadow DOM use something more light-weight than a Stylist.
It's just a struct aggregating stylesheets + CascadeData, with a quirks_mode
parameter because XBL sucks so bad.

Bug: 1436059
Reviewed-by: xidorn
MozReview-Commit-ID: 7q99tSNXo0K
2018-02-16 13:42:36 +01:00
Anthony Ramine
79775541f2 Make AnimationValue have the same variants as PropertyDeclaration
By making AnimationValue have the same representation as PropertyDeclaration
and Void variants for non-animatable properties, we know by constructions
that all properties have the same discriminant in both.
2018-02-10 12:37:30 +01:00