Commit graph

167 commits

Author SHA1 Message Date
Simon Wülker
3d320fa96a
Update rustfmt to the 2024 style edition (#35764)
* Use 2024 style edition

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Reformat all code

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-03-03 11:26:53 +00:00
Simon Wülker
e7e8ccea20
Respond to the connect message from a devtools client (#35745)
* Respond to the "connect" message

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Bump log levels in devtools implementation a bit

If everything is "debug" then nothing stands out.

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-03-02 12:16:51 +00:00
Simon Wülker
18de59dd63
Refactor devtools server (#35735)
Previously, the devtools code was structured like this (in pseudocode):
```rust
fn run() {
    let member_1;
    let member_2;

    fn foo(&member_1) {
        // ...
    }

    fn bar(&member_1, &member_2) {
        // ...
    }

    loop {
        match get_message() {
            Message1 => foo(&member_1),
            Message2 => bar(&member_1, &member_2),

        }
    }
}
```

This is not very idiomatic rust. And, more importantly, it makes it hard
to edit this code with an IDE, because "find all references" and similar
actions don't properly work. (member_1 inside "foo" is a different
variable than member_1 inside "bar" or "run").

Instead, the code is now structured (roughly) like this:

```rust
struct DevtoolsInstance {
    member_1,
    member_2,
}

impl DevtoolsInstance {
    fn foo(&self) {
        // ...
    }

    fn bar(&self) {
        // ...
    }

    fn run(&self) {
        loop {
            match get_message() {
                Message1 => self.foo(),
                Message2 => self.bar(),

            }
        }
    }
}
```

In my opinion, this is an improvement and should make future additions
to the devtools server easier. No behaviour change is intended.

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-03-01 20:13:22 +00:00
Martin Robinson
f51a5661f8
libservo: Flesh out permissions API (#35396)
- Update the script crate to better reflect the modern Permission
  specifcation -- removing the necessity for an `Insecure` variant of
  the permissions prompt.
- Have all allow/deny type requests in the internal API use an
  `AllowOrDeny` enum for clarity.
- Expose `PermissionsRequest` and `PermissionFeature` data types to the
  API and use them in the delegate method.
- Update both servoshell implementations to use the API.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2025-02-10 15:50:33 +00:00
Delan Azabani
5e9de2cb61
Include WebViewId into EmbedderMsg variants where possible (#35211)
`EmbedderMsg` was previously paired with an implicit
`Option<WebViewId>`, even though almost all variants were either always
`Some` or always `None`, depending on whether there was a `WebView
involved.

This patch adds the `WebViewId` to as many `EmbedderMsg` variants as
possible, so we can call their associated `WebView` delegate methods
without needing to check and unwrap the `Option`. In many cases, this
required more changes to plumb through the `WebViewId`.

Notably, all `Request`s now explicitly need a `WebView` or not, in order
to ensure that it is passed when appropriate.

Signed-off-by: Delan Azabani <dazabani@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-01-30 11:15:35 +00:00
Simon Wülker
b252f238d1
Support syntax highlighting of arguments in the devtools console (#34810)
* Implement Builder struct for console messages

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Support integer arguments for console methods

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Support floating point arguments to console methods in devtools

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Fix warnings

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Tidy

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-01-02 18:47:52 +00:00
Simon Wülker
28e330c9b6
Implement console.trace (#34629)
* Include unimplemented console methods in idl file

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Fix console.assert signature

The condition is optional and there can be multiple messages.

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Implement console.trace

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* ./mach fmt

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Log stack trace when calling console.trace

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Update wpt expectations

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Include line/column info in console.trace logs

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Move option out of constant

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Update mozjs

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2024-12-18 23:45:06 +00:00
Martin Robinson
312cf0df08
script: Create a CrossProcessInstant to enable serializable monotonic time (#33282)
Up until now, Servo was using a very old version of time to get a
cross-process monotonic timestamp (using `time::precise_time_ns()`).
This change replaces the usage of old time with a new serializable
monotonic time called `CrossProcessInstant` and uses it where `u64`
timestamps were stored before. The standard library doesn't provide this
functionality because it isn't something you can do reliably on all
platforms. The idea is that we do our best and then fall back
gracefully.

This is a big change, because Servo was using `u64` timestamps all over
the place some as raw values taken from `time::precise_time_ns()` and
some as relative offsets from the "navigation start," which is a concept
similar to DOM's `timeOrigin` (but not exactly the same). It's very
difficult to fix this situation without fixing it everywhere as the
`Instant` concept is supposed to be opaque. The good thing is that this
change clears up all ambiguity when passing times as a `time::Duration`
is unit agnostic and a `CrossProcessInstant` represents an absolute
moment in time.

The `time` version of `Duration` is used because it can both be negative
and is also serializable.

Good things:
 - No need too pass around `time` and `time_precise` any longer.
   `CrossProcessInstant` is also precise and monotonic.
 - The distinction between a time that is unset or at `0` (at some kind
   of timer epoch) is now gone.

There still a lot of work to do to clean up timing, but this is the
first step. In general, I've tried to preserve existing behavior, even
when not spec compliant, as much as possible. I plan to submit followup
PRs fixing some of the issues I've noticed.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2024-09-05 18:50:09 +00:00
eri
902bf57331
DevTools: Show HTML tree (#32655)
* feat: watch root node

Signed-off-by: eri <eri@inventati.org>

* reafactor: divide inspector in components

Signed-off-by: eri <eri@inventati.org>

* feat: add css properties actor

Signed-off-by: eri <eri@inventati.org>

* feat: accesibility actor

Signed-off-by: eri <eri@inventati.org>

* feat: layout actor

Signed-off-by: eri <eri@inventati.org>

* feat: network parent and refactor

Signed-off-by: eri <eri@inventati.org>

* feat: progress on the inspector messages

Signed-off-by: eri <eri@inventati.org>

* feat: more progress on inspector

Signed-off-by: eri <eri@inventati.org>

* feat: try to fix nodes showing

Signed-off-by: eri <eri@inventati.org>

* feat: initial dom tree

Signed-off-by: eri <eri@inventati.org>

* feat: some more messages

Signed-off-by: eri <eri@inventati.org>

* feat: clean and add documentation

Signed-off-by: eri <eri@inventati.org>

* refactor: add more docs and clean

Signed-off-by: eri <eri@inventati.org>

* fix: restore deleted node attributes field

Signed-off-by: eri <eri@inventati.org>

* Apply suggestions from code review

Fix a few nits in comments

Signed-off-by: Martin Robinson <mrobinson@igalia.com>

---------

Signed-off-by: eri <eri@inventati.org>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2024-07-26 15:17:54 +00:00
Rodion Borovyk
4bf5024ee0
fix a couple of simple clipy warnings (#32813)
Signed-off-by: Rodion Borovyk <rodion.borovyk@gmail.com>
2024-07-19 13:18:34 +00:00
eri
33f3c34d28
DevTools: Display console messages and errors (#32727)
* feat: add streams to browsing context

* feat: console now works!

* feat: order console messages

* feat: add streams to new browsing contexts

* fix: apply suggestions

Co-authored-by: Martin Robinson <mrobinson@igalia.com>

---------

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2024-07-09 18:27:47 +00:00
eri
2888193cfe
DevTools: Replace camel case variable names (#32726)
* refactor: rename to snake case

* refactor: more renaming

* chore: format

* chore: clean
2024-07-08 11:18:35 +00:00
eri
5eb8813448
DevTools: Implement watcher actor (#32509)
* feat: base for watcher

* feat: some more watcher tests

* feat: implement getWatcher

* refactor: clean up getWatcher

* feat: implement watchTargets

* feat: implement watchResources

* feat: very messy watchTargets fix

* refactor: clean browsing context

* feat: target configuration

* refactor: start cleanup

* refactor: more doc coments

* refactor: clean browsing context
2024-06-21 16:06:55 +00:00
Martin Robinson
3398fc017b
Move non-gfx things out of gfx_traits and create a base crate (#32296)
For a long time, `gfx_traits` has held a lot of things unrelated to graphics
and also unrelated to the `gfx` crate (which is mostly about fonts).
This is a cleanup which does a few things:

1. Move non `gfx` crate things out of `gfx_traits`. This is important in
   order to prevent dependency cycles with a different integration between
   layout, script, and fonts.
2. Rename the `msg` crate to `base`. It didn't really contain anything
   to do with messages and instead mostly holds ids, which are used
   across many different crates in Servo. This new crate will hold the
   *rare* data types that are widely used.

Details:

 - All BackgroundHangMonitor-related things from base to a new
   `background_hang_monitor_api` crate.
 - Moved `TraversalDirection` to `script_traits`
 - Moved `Epoch`-related things from `gfx_traits` to `base`.
 - Moved `PrintTree` to base. This should be widely useful in Servo.
 - Moved `WebrenderApi` from `base` to `webrender_traits` and renamed it
   to `WebRenderFontApi`.
2024-05-17 12:28:58 +00:00
eri
cc082efbfd
clippy: Allow too_many_arguments for existing functions (#31974)
* Allow `too_many_arguments` for existing functions

* fix: Surround ASCII with code block in rustdoc
2024-04-02 12:50:45 +00:00
sandeep
64d013d473
Fix clippy warnings in components/rand (#31549)
* resolved clippy warnings in components/rand

Signed-off-by: Sandeep Pillai <sandeeppillai@Sandeeps-MacBook-Air.local>

* replaced new() with default()

Signed-off-by: Sandeep Pillai <sandeeppillai@Sandeeps-MacBook-Air.local>

* replaced ServoRng::new() with ServoRng::default()

Signed-off-by: Sandeep Pillai <sandeeppillai@Sandeeps-MacBook-Air.local>

* moved the contents of the new() method into the default() method

Signed-off-by: Sandeep Pillai <sandeeppillai@Sandeeps-MacBook-Air.local>

---------

Signed-off-by: Sandeep Pillai <sandeeppillai@Sandeeps-MacBook-Air.local>
Co-authored-by: Sandeep Pillai <sandeeppillai@Sandeeps-MacBook-Air.local>
2024-03-07 23:16:42 +00:00
eri
3552bb2464
clippy: Fix several warnings in components/devtools (#31501) 2024-03-05 18:19:04 +00:00
Martin Robinson
5c1723c983
rustdoc: Fix many rustdoc errors (#31147)
This fixes many rustdoc errors that occur due to raw URLs in rustdoc
comments as well as unescaped Rust code that should be in backticks.
2024-01-22 13:13:48 +00:00
Samson
aad2dccc9c
Strict import formatting (grouping and granularity) (#30325)
* strict imports formatting

* Reformat all imports
2023-09-11 19:16:54 +00:00
Samson
711dbbd4af
remove extern crate (#30311)
* remove extern crate

* Update components/script_plugins/lib.rs

Co-authored-by: Martin Robinson <mrobinson@igalia.com>

---------

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2023-09-08 12:11:31 +00:00
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
Josh Matthews
f4915ef6c9 devtools: Track multiple clients better, and cleanup streams when a client isn't reachable. 2020-08-06 09:55:01 -04:00
Josh Matthews
0b619bf920 devtools: Don't panic when sending to a disconnected client fails. 2020-08-05 14:55:48 -04:00
Paul Rouget
da80d4ff01 devtools: TabDescription actor 2020-07-13 09:21:27 +02:00
Paul Rouget
8cf2f14baa Allow embedder to bypass devtools prompt 2020-06-22 11:47:03 +02:00
Josh Matthews
02ce6188aa Update devtools page titles. 2020-04-28 15:40:38 -04:00
Josh Matthews
b9bf9f873b Move some console-related message types into the console code. 2020-04-28 11:07:45 -04:00
Josh Matthews
565e9432c6 Support connecting to worker globals from remote devtools. 2020-04-28 11:07:45 -04:00
Josh Matthews
7c48644cad Support navigating browsing contexts in the devtools.
Break the association between pipelines and browsing context actors.
Now there is one browsing context actor per actual browsing context,
and individual actors keep track of known pipelines as necessary.
There is also one console/performance/timeline/inspector/etc. actor
per browsing context.

This also centralizes more information in the browsing context actor.
Rather than duplicating state for the active pipeline in actors that
need to use it, each actor now remembers the name of its associated
browsing context actor and obtains that state whenever it's necessary.
2020-04-26 18:11:23 -04:00
Kunal Mohan
94db0d61cb
Add support for launching devtools server on random port
Assign random port to devtools server in case user does not specify a
port explicitly and report it to the embedding layer for display to user.
2020-03-16 15:30:26 +05:30
Paul Rouget
49376e3b31 Prompt user before accepting incoming devtools connection 2020-02-10 06:51:18 +01:00
Josh Matthews
84074d3c86 Update devtools server for Firefox 71. 2019-12-13 17:02:35 -05:00
Paul Rouget
b3b886e837 devtools: save and send cached messages 2019-12-06 10:10:43 +01:00
Shotaro Yamada
c44a2febe6 Remove redundant .clone()s 2018-12-11 10:43:51 +09: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
Simon Sapin
2012be4a8b cargo fix --edition-idioms 2018-11-08 09:28:00 +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
76e59a46d3 Sort use statements 2018-11-06 15:26:02 +01:00
Simon Sapin
45f7199eee cargo fix --edition 2018-11-06 15:26:02 +01:00
Bastien Orivel
024b40b39d Update hyper to 0.12 2018-11-01 19:17:36 +01:00
codehag
9ccf7c0a57 DevTools - add Emulation Actor 2018-10-15 08:48:30 +02:00
bors-servo
a59bcd6749
Auto merge of #21942 - codehag:devtools-add-device-actor, r=jdm
DevTools - add DeviceActor and update Root to own global actors

This is one of three pull requests that allows the DevTools Debugger to render. This pr also introduces global actors to the root actor, the same as exists in FF devtools. At a later point I would like to reorganize this.

The two related prs are #21943 and #21944

This is the most significant change of the three. It introduces both Device and Performance as global actors, and leaves the Performance actor also as a target actor. It also introduces the concept of ownership to the root actor, with regards to the two Global Actors.

The Device actor as added to allow the JS Debugger to start up. This required the DeviceActor's `getDescription` method. `getDescription`, in the case of servo, returns a couple of basic fields that the debugger is interested in but doesn't use, specifically `apptype` -- which is returning a fake value of `servo`, and the version number `63.0`.

The version number is interesting because devtools has [dropped support for any versions below 2 version numbers from the current firefox](https://searchfox.org/mozilla-central/rev/3a54520d8d2319a4116866371ed3d9ed2ec0cc2b/devtools/client/debugger/new/src/client/firefox/commands.js#398).

This means that if we want the servo server to be supported, we will need to keep this number synced with FF's versioning. It isn't great, but hopefully we can introduce a different approach later on.

---
<!-- 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
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] 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. -->

<!-- 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/21942)
<!-- Reviewable:end -->
2018-10-14 14:17:51 -04:00
codehag
5c8492d760 DevTools - add DeviceActor and update Root to own global actors 2018-10-14 16:39:20 +02:00
codehag
c88cc3e966 DevTools - add preliminary StyleSheetActor 2018-10-14 16:33:24 +02:00
codehag
86b78629c3 Bug 1172897 - Rename Tab Actor to BrowsingContextActor
As part of [Bug 1172987](https://bugzilla.mozilla.org/show_bug.cgi?id=1172897) we renamed TabActor, as the actor does not represent tabs (as in a browser tab), it instead represents a browsing context as defined by the the [HTML standard](https://html.spec.whatwg.org/multipage/browsers.html#windows). In a later PR I will mirror the structure we have on devtools to have a targets folder, which contains all target types. At the moment it looks like servo only represents workers and browsing contexts.
2018-09-23 22:16:53 +02: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
kingdido999
ad822b74c7 Format components devtools and devtools_traits #21373 2018-09-02 20:29:47 +08:00
Matt Brubeck
2d45e9d2da Use try syntax for Option where appropriate 2017-10-20 08:25:35 -07:00