diff options
Diffstat (limited to 'components/shared')
-rw-r--r-- | components/shared/gfx/lib.rs | 16 | ||||
-rw-r--r-- | components/shared/msg/constellation_msg.rs | 24 | ||||
-rw-r--r-- | components/shared/script_layout/lib.rs | 3 | ||||
-rw-r--r-- | components/shared/script_layout/message.rs | 3 | ||||
-rw-r--r-- | components/shared/script_layout/wrapper_traits.rs | 8 |
5 files changed, 27 insertions, 27 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 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() } } diff --git a/components/shared/script_layout/lib.rs b/components/shared/script_layout/lib.rs index 3279f993820..20d8c982dc2 100644 --- a/components/shared/script_layout/lib.rs +++ b/components/shared/script_layout/lib.rs @@ -46,7 +46,7 @@ use style::properties::PropertyId; use style::selector_parser::PseudoElement; use style::stylesheets::Stylesheet; use style_traits::CSSPixel; -use webrender_api::{ExternalScrollId, ImageKey}; +use webrender_api::ImageKey; pub type GenericLayoutData = dyn Any + Send + Sync; @@ -235,7 +235,6 @@ pub trait Layout { animations: DocumentAnimationSet, animation_timeline_value: f64, ) -> Option<ServoArc<Font>>; - fn query_scroll_id(&self, node: TrustedNodeAddress) -> ExternalScrollId; fn query_scrolling_area(&self, node: Option<OpaqueNode>) -> Rect<i32>; fn query_text_indext(&self, node: OpaqueNode, point: Point2D<f32>) -> Option<usize>; } diff --git a/components/shared/script_layout/message.rs b/components/shared/script_layout/message.rs index 34de65cd227..018e554e893 100644 --- a/components/shared/script_layout/message.rs +++ b/components/shared/script_layout/message.rs @@ -55,7 +55,6 @@ pub enum QueryMsg { OffsetParentQuery, TextIndexQuery, NodesFromPointQuery, - NodeScrollIdQuery, ResolvedStyleQuery, StyleQuery, ElementInnerTextQuery, @@ -90,7 +89,6 @@ impl ReflowGoal { QueryMsg::ClientRectQuery | QueryMsg::ContentBox | QueryMsg::ContentBoxes | - QueryMsg::NodeScrollIdQuery | QueryMsg::OffsetParentQuery | QueryMsg::ResolvedFontStyleQuery | QueryMsg::ScrollingAreaQuery | @@ -112,7 +110,6 @@ impl ReflowGoal { QueryMsg::ContentBoxes | QueryMsg::ClientRectQuery | QueryMsg::ScrollingAreaQuery | - QueryMsg::NodeScrollIdQuery | QueryMsg::ResolvedStyleQuery | QueryMsg::ResolvedFontStyleQuery | QueryMsg::OffsetParentQuery | diff --git a/components/shared/script_layout/wrapper_traits.rs b/components/shared/script_layout/wrapper_traits.rs index c1bd1fc4d95..846943414ae 100644 --- a/components/shared/script_layout/wrapper_traits.rs +++ b/components/shared/script_layout/wrapper_traits.rs @@ -9,7 +9,7 @@ use std::fmt::Debug; use std::sync::Arc as StdArc; use atomic_refcell::AtomicRef; -use gfx_traits::{combine_id_with_fragment_type, ByteIndex, FragmentType}; +use gfx_traits::{ByteIndex, FragmentType}; use html5ever::{local_name, namespace_url, ns, LocalName, Namespace}; use msg::constellation_msg::{BrowsingContextId, PipelineId}; use net_traits::image::base::{Image, ImageMetadata}; @@ -23,7 +23,6 @@ use style::dom::{LayoutIterator, NodeInfo, OpaqueNode, TElement, TNode}; use style::properties::ComputedValues; use style::selector_parser::{PseudoElement, PseudoElementCascadeType, SelectorImpl}; use style::stylist::RuleInclusion; -use webrender_api::ExternalScrollId; use crate::{ GenericLayoutData, HTMLCanvasData, HTMLMediaData, LayoutNodeType, SVGSVGData, StyleData, @@ -315,11 +314,6 @@ pub trait ThreadSafeLayoutNode<'dom>: Clone + Copy + Debug + NodeInfo + PartialE fn fragment_type(&self) -> FragmentType { self.get_pseudo_element_type().fragment_type() } - - fn generate_scroll_id(&self, pipeline_id: PipelineId) -> ExternalScrollId { - let id = combine_id_with_fragment_type(self.opaque().id(), self.fragment_type()); - ExternalScrollId(id as u64, pipeline_id.to_webrender()) - } } pub trait ThreadSafeLayoutElement<'dom>: |