aboutsummaryrefslogtreecommitdiffstats
path: root/components/shared/gfx/lib.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/gfx/lib.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/gfx/lib.rs')
-rw-r--r--components/shared/gfx/lib.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/components/shared/gfx/lib.rs b/components/shared/gfx/lib.rs
index e3749b37e03..5045a677c86 100644
--- a/components/shared/gfx/lib.rs
+++ b/components/shared/gfx/lib.rs
@@ -8,7 +8,7 @@
pub mod print_tree;
-use std::sync::atomic::{AtomicUsize, Ordering};
+use std::sync::atomic::{AtomicU64, Ordering};
use malloc_size_of_derive::MallocSizeOf;
use range::{int_range_index, RangeIndex};
@@ -90,30 +90,30 @@ pub enum FragmentType {
/// The next ID that will be used for a special scroll root id.
///
/// A special scroll root is a scroll root that is created for generated content.
-static NEXT_SPECIAL_SCROLL_ROOT_ID: AtomicUsize = AtomicUsize::new(0);
+static NEXT_SPECIAL_SCROLL_ROOT_ID: AtomicU64 = AtomicU64::new(0);
/// If none of the bits outside this mask are set, the scroll root is a special scroll root.
/// Note that we assume that the top 16 bits of the address space are unused on the platform.
-const SPECIAL_SCROLL_ROOT_ID_MASK: usize = 0xffff;
+const SPECIAL_SCROLL_ROOT_ID_MASK: u64 = 0xffff;
/// Returns a new scroll root ID for a scroll root.
-fn next_special_id() -> usize {
+fn next_special_id() -> u64 {
// We shift this left by 2 to make room for the fragment type ID.
((NEXT_SPECIAL_SCROLL_ROOT_ID.fetch_add(1, Ordering::SeqCst) + 1) << 2) &
SPECIAL_SCROLL_ROOT_ID_MASK
}
-pub fn combine_id_with_fragment_type(id: usize, fragment_type: FragmentType) -> usize {
+pub fn combine_id_with_fragment_type(id: usize, fragment_type: FragmentType) -> u64 {
debug_assert_eq!(id & (fragment_type as usize), 0);
if fragment_type == FragmentType::FragmentBody {
- id
+ id as u64
} else {
- next_special_id() | (fragment_type as usize)
+ next_special_id() | (fragment_type as u64)
}
}
pub fn node_id_from_scroll_id(id: usize) -> Option<usize> {
- if (id & !SPECIAL_SCROLL_ROOT_ID_MASK) != 0 {
+ if (id as u64 & !SPECIAL_SCROLL_ROOT_ID_MASK) != 0 {
return Some(id & !3);
}
None