Commit graph

568 commits

Author SHA1 Message Date
yvt
41b3726271 feat: shorten thread names
The Linux kernel imposes a 15-byte limit on thread names[1]. This means
information that does not fit in this limit, e.g., the pipeline ID of
layout and script threads, is lost in a debugger and profiler (see the
first column of the table below).

This commit shortens the thread names used in Servo to maximize the
amount of information conveyed. It also rectifies some inconsistencies
in the names.

|       Before      |       After       |
|-------------------|-------------------|
| `BluetoothThread` | `Bluetooth`       |
| `CanvasThread`    | `Canvas`          |
| `display alert d` | `AlertDialog`     |
| `FontCacheThread` | `FontCache`       |
| `GLPlayerThread`  | `GLPlayer`        |
| `HTML Parser`     | `Parse:www.examp` |
| `LayoutThread Pi` | `Layout(1,1)`     |
| `Memory profiler` | `MemoryProfiler`  |
| `Memory profiler` | `MemoryProfTimer` |
| `OfflineAudioCon` | `OfflineACResolv` |
| `PullTimelineMar` | `PullTimelineDat` |
| `ScriptThread Pi` | `Script(1,1)`     |
| `WebWorker for h` | `WW:www.example.` |
| `ServiceWorker f` | `SW:www.example.` |
| `ServiceWorkerMa` | `SvcWorkerManage` |
| `Time profiler t` | `TimeProfTimer`   |
| `Time profiler`   | `TimeProfiler`    |
| `WebGL thread`    | `WebGL`           |
| `Choose a device` | `DevicePicker`    |
| `Pick a file`     | `FilePicker`      |
| `Pick files`      | `FilePicker`      |

[1]: https://stackoverflow.com/questions/5026531/thread-name-longer-than-15-chars
2021-07-19 00:57:48 +09:00
teymour-aldridge
5b2cd844d7
Bump time to latest v0.1.x version. 2021-06-25 17:19:14 +01:00
Emilio Cobos Álvarez
31e8e418ea Miscellaneous build / tidy fixes. 2021-02-26 17:53:55 +01:00
Simon Sapin
a0d9f97c8e Fix warnings introduced in newer Rust Nightly
This does not (yet) upgrade ./rust-toolchain

The warnings:

* dead_code "field is never read"
* redundant_semicolons "unnecessary trailing semicolon"
* non_fmt_panic "panic message is not a string literal, this is no longer accepted in Rust 2021"
* unstable_name_collisions "a method with this name may be added to the standard library in the future"
* legacy_derive_helpers "derive helper attribute is used before it is introduced" https://github.com/rust-lang/rust/issues/79202
2021-02-25 15:36:03 +01:00
teymour-aldridge
1f38e3411d Fix num_threads to avoid divide by zero error when running without a thread pool
Signed-off-by: teymour-aldridge <teymour.aldridge@icloud.com>
2020-12-28 11:01:38 +00:00
Gregory Terzian
44ebca72da ensure clean shutdown of all threads running JS 2020-06-30 13:22:38 +08:00
Martin Robinson
f3e373bc62 Add animation and transition support for pseudo-elements
This change extends the DocumentAnimationSet to hold animations for
pseudo-elements. Since pseudo-elements in Servo are not in the DOM like
in Gecko, they need to be handled a bit carefully in stylo.  When a
pseudo-element has an animation, recascade the style. Finally, this
change passes the pseudo-element string properly to animation events.

Fixes: #10316
2020-06-16 16:33:55 +02:00
Martin Robinson
4a3995bb37 Add DocumentAnimationSet and AnimationSetKey
This will be used in order to hold animations for pseudo elements in the
DocumentAnimationSet. Also no longer store the OpaqueNode in the
animation and transition data structures. This is already part of the
DocumentAnimationSet key.
2020-06-15 10:28:30 +02:00
bors-servo
721271dcd3
Auto merge of #26697 - utsavoza:ugo/issue-11681/22-05-2020, r=jdm
Implement CanvasRenderingContext2d.fillText

The PR consists of broadly two main changes:
- Implementation of Canvas2dRenderingContext.font
- Basic implementation of Canvas2dRenderingContext.fillText

Although I am not fully sure about the long term goals for the canvas backend in Servo, I assumed limited scope for font and text handling (should support simple text drawing with font selection) in the current implementation as I believe a more complete implementation would eventually be brought in as a part of #22957.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #11681
- [x] There are tests for these changes
2020-06-12 13:43:51 -04:00
bors-servo
9e528b8124
Auto merge of #26806 - mrobinson:animations-cascade, r=emilio
Include animations and transitions in the cascade

Instead of applying animations and transitions to styled elements,
include them in the cascade. This allows them to interact properly with
things like font-size and !important rules.

<!-- Please describe your changes on the following line: -->

---
<!-- 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] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
2020-06-10 14:14:03 -04:00
Utsav Oza
15fd256302 Store resolved font style in canvas context state 2020-06-10 22:10:44 +05:30
Utsav Oza
7883718c12 Query layout to resolve canvas font property value 2020-06-10 22:10:42 +05:30
Josh Matthews
abc689e034 Remove unecessary webrender document from layout. 2020-06-09 13:05:16 -04:00
Martin Robinson
364235ac0c Include animations and transitions in the cascade
Instead of applying animations and transitions to styled elements,
include them in the cascade. This allows them to interact properly with
things like font-size and !important rules.
2020-06-09 11:41:07 +02:00
Martin Robinson
b875f14e86 Better computation of animation keyframes
This begins to address #26625 by properly applying CSS variables during
keyframe computation and no longer using `apply_declarations`. Instead,
walk the declarations, combining them into IntermediateComputedKeyframe,
maintaining declarations that modify CSS custom properties. Then compute
a set of AnimationValues for each keyframe and use those to produce
interpolated animation values.
2020-06-05 13:40:29 +02:00
Martin Robinson
83fa1b9eaa Cache animation computed values when animations change
Instead of recalculating the animation style every tick of an animation,
cache the computed values when animations change. In addition to being
more efficient, this will allow us to return animation rules as property
declarations because we don't need to consult the final style to produce
them.
2020-06-05 13:21:19 +02:00
Simon Sapin
0abe90647f Remove support for energy profiling 2020-06-04 16:39:08 +02:00
Simon Sapin
d4227b5b0d Remove some unused dependency declarations
This is based on compiling with `RUSTFLAGS="-W unused_crate_dependencies"` (CC https://github.com/rust-lang/rust/pull/72342) in a recent Nightly (more so than used in the tree as of this writing, CC https://github.com/servo/servo/issues/26661 for work-arounds).

Only one crate is actually removed from the dependency graph, others are still dependended from other places.
2020-05-29 00:04:34 +02:00
Josh Matthews
1da40b59af Remove use of nightly features in parking_lot. Update many uses from 0.9 to 0.10. 2020-05-26 09:34:50 -04:00
Anthony Ramine
036f123c4e Implement concept of dirty root 2020-05-19 16:26:36 +02:00
Alex Touchet
d132866c5d
More Cargo.toml cleanups 2020-05-14 22:20:18 -07:00
Martin Robinson
3b0619aedd Move most animation processing to script
This is preparation for sharing this code with layout_2020 and
implementing selective off-the-main-thread animations.

We still look for nodes not in the flow tree in the layout thread.
2020-05-12 10:22:14 +02:00
Martin Robinson
b8874ad6ac Split animations and transitions into separate lists
This change splits the list of animations and transitions, which are
almost always handled differently. It also renames
`ElementAnimationState` to `ElementAnimationSet` and establishes an
`AnimationState` for every transition and animation. This allows us to
stop continually reallocating lists every time a transition or animation
needs to be canceled.

Fixes #14419.
2020-05-06 19:26:50 +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
b585ce5b1f Use a restyle for animation ticks
This change corrects synchronization issues with animations, by
reworking the animation processing model to do a quick restyle and
incremental layout when ticking animations.

While this change adds overhead to animation ticks, the idea is that
this will be the fallback when synchronous behavior is required to
fulfill specification requirements. In the optimistic case, many
animations could be updated and applied off-the-main-thread and then
resynchronized when style information is queried by script.

Fixes #13865.
2020-05-05 15:13:35 +02:00
Martin Robinson
3903c1fb98 Add support for animationend event
This is triggered when an animation finishes. This is a high priority
because it allows us to start rooting nodes with animations in the
script thread.

This doesn't yet cause a lot of tests to pass because they rely on the
existence of `Document.getAnimations()` and the presence of
`animationstart` and animationiteration` events.
2020-05-01 15:29:57 +02:00
Martin Robinson
d386d6d1f1 Add support for transitionrun events
These events are triggered as soon as a transition is added to the list
of running transitions. This will allow better test coverage while
reworking the transitions and animations processing model.
2020-04-24 14:20:37 +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
bors-servo
610991bdfc
Auto merge of #26244 - mrobinson:animation-cancel, r=jdm
Add support for canceling CSS transitions

This change adds support for canceling CSS transitions when a property is
no longer transitionable. Support for canceling and replacing CSS
transitions when the end value changes is still pending. This change
also takes advantage of updating the constellation message to fix a bug
where transition events could be sent for closed pipelines.

Fixes #15079.

<!-- Please describe your changes on the following line: -->

---
<!-- 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 #15079.

<!-- Either: -->
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
2020-04-22 15:34:06 -04:00
Martin Robinson
453b252a65 Add support for canceling CSS transitions
This change adds support for canceling CSS transitions when a property
is no longer transitionable or when an element becomes styled with
display:none. Support for canceling and replacing CSS transitions when
the end value changes is still pending. This change also takes advantage
of updating the constellation message to fix a bug where transition
events could be sent for closed pipelines.

Fixes #15079.
2020-04-22 17:23:26 +02:00
Anthony Ramine
7f54d14904 Make the rule tree actually threadsafe
RuleTree::gc is now a safe method that any thread can call
at any time, and StrongRuleNode values can all be dropped
whenever their owner want to, on any thread.
2020-04-20 17:39:19 +02:00
Emilio Cobos Álvarez
848a6203de Some servo build fixes. 2020-04-16 18:29:30 +02:00
Anthony Ramine
c10e839924 Don't go through the layout thread to retrieve a node's primary style 2020-04-07 14:34:47 +02:00
Anthony Ramine
030a1cf8fb Replace OpaqueStyleAndLayoutData by StyleAndOpaqueLayoutData 2020-04-06 23:06:13 +02:00
Anthony Ramine
e3be136c9b Rename a bunch of style/layout data items
GetLayoutData::get_style_and_layout_data becomes
GetOpaqueStyleAndLayoutData::get_opaque_style_and_layout_data.

GetRawData::get_raw_data becomes GetStyleAndLayoutData::get_style_and_layout_data.

LayoutNode::init_style_and_layout_data becomes
LayoutNode::init_opaque_style_and_layout_data.

LayoutNode::take_style_and_layout_data becomes
LayoutNode::take_opaque_style_and_layout_data.
2020-04-06 12:39:52 +02:00
bors-servo
57fe27a4ef
Auto merge of #26110 - servo:layout-2020-rm-note-dirty-descendant, r=emilio
Kill ServoLayoutElement::note_dirty_descendant
2020-04-04 09:51:19 -04:00
Anthony Ramine
8a0775fc89 Kill ServoLayoutElement::note_dirty_descendant
There is no need to set the dirty descendants flag unsafely from the layout side
for elements with pending restyles, we can do that on the DOM side when draining
the restyles from the Document.
2020-04-04 15:00:04 +02:00
Anthony Ramine
185a402d9c Make DOM own the style and layout data, in an UnsafeCell
The previous Cell was a lie.
2020-04-04 13:10:19 +02:00
Anthony Ramine
516e8e0aa6 Don't expose any AtomicRefCell directly from style traits
This lets us experiment with how we store this data on the DOM side.
2020-04-04 13:08:51 +02:00
Anthony Ramine
4c61baee30 Make OpaqueLayoutAndStyleData just a bit less opaque
It now stores a NonNull<dyn Any>.
2020-04-04 13:08:51 +02:00
Anthony Ramine
295f120425 Make LayoutShadowRootHelpers::get_style_data_for_layout return a &CascadeData
That return type is Sync, which thus means that the method can be safe.
2020-04-01 11:40:55 +02:00
Anthony Ramine
ebd2892158 Make synthesize_presentational_hints_for_legacy_attributes be safe 2020-04-01 11:40:55 +02:00
Anthony Ramine
0c0027ecfd Make LayoutDocumentHelpers::style_shared_lock be safe
StyleSharedRwLock is Sync.
2020-04-01 11:40:55 +02:00
Anthony Ramine
fc07a5147c Make LayoutNodeHelpers::composed_parent_node_ref be safe
For clarity, I introduce <LayoutDom<Element>>::parent_node_ref to contain
the remaining unsafety bits out of composed_parent_node_ref which is more
complex than just a field access.
2020-04-01 11:40:34 +02:00
Anthony Ramine
f712b0bcf8 Make LayoutShadowRootHelpers::get_host_for_layout be safe 2020-03-31 22:30:42 +02:00
Anthony Ramine
68d5cfffd5 Make a bunch of LayoutNodeHelpers be safe 2020-03-31 22:30:34 +02:00
Anthony Ramine
f014da9565 Introduce LayoutDom::is
Just like Castable::is.
2020-03-31 22:06:40 +02:00
Anthony Ramine
9c8540af5c Make layout methods accessing rare data be safe
They don't do anything fancy so there is no additional unsafety calling them
compared to using LayoutDom in the first place, the usual story of all
those changes.
2020-03-31 22:04:35 +02:00
Anthony Ramine
72c0771299 Make a bunch of LayoutDocumentHelpers be safe
The other methods are actually unsafe.
2020-03-31 21:39:45 +02:00
Anthony Ramine
fbc3e430ab Make a bunch or trivial LayoutElementHelpers safe 2020-03-31 20:37:57 +02:00