aboutsummaryrefslogtreecommitdiffstats
path: root/components/shared/msg/constellation_msg.rs
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2024-04-09 08:43:48 +0200
committerGitHub <noreply@github.com>2024-04-09 06:43:48 +0000
commitdd9f62adcc2db74e473ba1d385c2005b9c0fd25f (patch)
tree8693c89802b1fea459148e1de085450344217652 /components/shared/msg/constellation_msg.rs
parentb79e2a0b6575364de01b1f89021aba0ec3fcf399 (diff)
downloadservo-dd9f62adcc2db74e473ba1d385c2005b9c0fd25f.tar.gz
servo-dd9f62adcc2db74e473ba1d385c2005b9c0fd25f.zip
chore: Clean up use of `gfx` and `constellation` types (#31981)
This change contains three semi-related clean ups: 1. the `to_webrender()` and `from_webrender()` functions on Pipeline are turned into more-idiomatic `From` and `Into` implementations. 2. `combine_id_with_fragment_type` now returns a `u64` as that is what is expected for all callers and not a `usize`. 3. The `query_scroll_id` query is removed entirely. The `ExternalScrollId` that this queries is easily generated directly from the node's opaque id. Querying into layout isn't necessary at all.
Diffstat (limited to 'components/shared/msg/constellation_msg.rs')
-rw-r--r--components/shared/msg/constellation_msg.rs24
1 files changed, 17 insertions, 7 deletions
diff --git a/components/shared/msg/constellation_msg.rs b/components/shared/msg/constellation_msg.rs
index 24fda786c9d..6893957f46b 100644
--- a/components/shared/msg/constellation_msg.rs
+++ b/components/shared/msg/constellation_msg.rs
@@ -223,14 +223,14 @@ impl PipelineId {
})
}
- pub fn to_webrender(&self) -> WebRenderPipelineId {
- let PipelineNamespaceId(namespace_id) = self.namespace_id;
- let PipelineIndex(index) = self.index;
- WebRenderPipelineId(namespace_id, index.get())
+ pub fn root_scroll_id(&self) -> webrender_api::ExternalScrollId {
+ ExternalScrollId(0, self.into())
}
+}
+impl From<WebRenderPipelineId> for PipelineId {
#[allow(unsafe_code)]
- pub fn from_webrender(pipeline: WebRenderPipelineId) -> PipelineId {
+ fn from(pipeline: WebRenderPipelineId) -> Self {
let WebRenderPipelineId(namespace_id, index) = pipeline;
unsafe {
PipelineId {
@@ -239,9 +239,19 @@ impl PipelineId {
}
}
}
+}
- pub fn root_scroll_id(&self) -> webrender_api::ExternalScrollId {
- ExternalScrollId(0, self.to_webrender())
+impl From<PipelineId> for WebRenderPipelineId {
+ fn from(value: PipelineId) -> Self {
+ let PipelineNamespaceId(namespace_id) = value.namespace_id;
+ let PipelineIndex(index) = value.index;
+ WebRenderPipelineId(namespace_id, index.get())
+ }
+}
+
+impl From<&PipelineId> for WebRenderPipelineId {
+ fn from(value: &PipelineId) -> Self {
+ (*value).into()
}
}