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>
This commit is contained in:
Martin Robinson 2025-03-11 11:56:10 +01:00 committed by GitHub
parent 81fe4bbb1e
commit 2464d0937f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 416 additions and 570 deletions

View file

@ -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);