diff options
author | Martin Robinson <mrobinson@igalia.com> | 2025-03-11 11:56:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-11 10:56:10 +0000 |
commit | 2464d0937ffbf7697ca2e1193a6d12c28be28b16 (patch) | |
tree | 338446f68aa38849b51cb515f13029067286e400 /components/shared/base/id.rs | |
parent | 81fe4bbb1ed5f2e48682925cffd9a86f582e639f (diff) | |
download | servo-2464d0937ffbf7697ca2e1193a6d12c28be28b16.tar.gz servo-2464d0937ffbf7697ca2e1193a6d12c28be28b16.zip |
base: Finish rename of `TopLevelBrowsingContextId` to `WebViewId` (#35896)
The `WebViewId` name is a lot more descriptive these days to the casual
reader, so I think we can go ahead and finish the rename.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Diffstat (limited to 'components/shared/base/id.rs')
-rw-r--r-- | components/shared/base/id.rs | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/components/shared/base/id.rs b/components/shared/base/id.rs index 071d7107b9c..bb4c5abb4cc 100644 --- a/components/shared/base/id.rs +++ b/components/shared/base/id.rs @@ -275,61 +275,58 @@ impl fmt::Display for BrowsingContextGroupId { } } -thread_local!(pub static TOP_LEVEL_BROWSING_CONTEXT_ID: Cell<Option<TopLevelBrowsingContextId>> = +thread_local!(pub static WEBVIEW_ID: Cell<Option<WebViewId>> = const { Cell::new(None) }); #[derive( Clone, Copy, Deserialize, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd, Serialize, )] -pub struct TopLevelBrowsingContextId(pub BrowsingContextId); -/// An alias to ID of top level browsing context. A web view is usually what people would treat as -/// a normal web page. -pub type WebViewId = TopLevelBrowsingContextId; +pub struct WebViewId(pub BrowsingContextId); -size_of_test!(TopLevelBrowsingContextId, 8); -size_of_test!(Option<TopLevelBrowsingContextId>, 8); +size_of_test!(WebViewId, 8); +size_of_test!(Option<WebViewId>, 8); -impl fmt::Debug for TopLevelBrowsingContextId { +impl fmt::Debug for WebViewId { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "TopLevel{:?}", self.0) } } -impl fmt::Display for TopLevelBrowsingContextId { +impl fmt::Display for WebViewId { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "TopLevel{}", self.0) } } -impl TopLevelBrowsingContextId { - pub fn new() -> TopLevelBrowsingContextId { - TopLevelBrowsingContextId(BrowsingContextId::new()) +impl WebViewId { + pub fn new() -> WebViewId { + WebViewId(BrowsingContextId::new()) } /// Each script and layout thread should have the top-level browsing context id installed, /// since it is used by crash reporting. - pub fn install(id: TopLevelBrowsingContextId) { - TOP_LEVEL_BROWSING_CONTEXT_ID.with(|tls| tls.set(Some(id))) + pub fn install(id: WebViewId) { + WEBVIEW_ID.with(|tls| tls.set(Some(id))) } - pub fn installed() -> Option<TopLevelBrowsingContextId> { - TOP_LEVEL_BROWSING_CONTEXT_ID.with(|tls| tls.get()) + pub fn installed() -> Option<WebViewId> { + WEBVIEW_ID.with(|tls| tls.get()) } } -impl From<TopLevelBrowsingContextId> for BrowsingContextId { - fn from(id: TopLevelBrowsingContextId) -> BrowsingContextId { +impl From<WebViewId> for BrowsingContextId { + fn from(id: WebViewId) -> BrowsingContextId { id.0 } } -impl PartialEq<TopLevelBrowsingContextId> for BrowsingContextId { - fn eq(&self, rhs: &TopLevelBrowsingContextId) -> bool { +impl PartialEq<WebViewId> for BrowsingContextId { + fn eq(&self, rhs: &WebViewId) -> bool { self.eq(&rhs.0) } } -impl PartialEq<BrowsingContextId> for TopLevelBrowsingContextId { +impl PartialEq<BrowsingContextId> for WebViewId { fn eq(&self, rhs: &BrowsingContextId) -> bool { self.0.eq(rhs) } @@ -444,4 +441,4 @@ pub const TEST_BROWSING_CONTEXT_ID: BrowsingContextId = BrowsingContextId { index: TEST_BROWSING_CONTEXT_INDEX, }; -pub const TEST_WEBVIEW_ID: WebViewId = TopLevelBrowsingContextId(TEST_BROWSING_CONTEXT_ID); +pub const TEST_WEBVIEW_ID: WebViewId = WebViewId(TEST_BROWSING_CONTEXT_ID); |