aboutsummaryrefslogtreecommitdiffstats
path: root/components/style/gecko_string_cache/namespace.rs
diff options
context:
space:
mode:
authorDelan Azabani <dazabani@igalia.com>2024-02-27 23:39:06 +0800
committerGitHub <noreply@github.com>2024-02-27 15:39:06 +0000
commitfaf754dfa655f0b9a28f62bc47a78fbf78ebcaf4 (patch)
tree4725e1446680d036797b1fc258733ae6b2c9f354 /components/style/gecko_string_cache/namespace.rs
parentb07505417e629bbb081be9683630f2d7a5f50544 (diff)
downloadservo-faf754dfa655f0b9a28f62bc47a78fbf78ebcaf4.tar.gz
servo-faf754dfa655f0b9a28f62bc47a78fbf78ebcaf4.zip
Move Stylo to its own repo (#31350)
* Remove packages that were moved to external repo * Add workspace dependencies pointing to 2023-06-14 branch * Fix servo-tidy.toml errors * Update commit to include #31346 * Update commit to include servo/stylo#2 * Move css-properties.json lookup to target/doc/stylo * Remove dependency on vendored mako in favour of pypi dependency This also removes etc/ci/generate_workflow.py, which has been unused since at least 9e71bd6a7010d6e5723831696ae0ebe26b47682f. * Add temporary code to debug Windows test failures * Fix failures on Windows due to custom target dir * Update commit to include servo/stylo#3 * Fix license in tests/unit/style/build.rs * Document how to build with local Stylo in Cargo.toml
Diffstat (limited to 'components/style/gecko_string_cache/namespace.rs')
-rw-r--r--components/style/gecko_string_cache/namespace.rs105
1 files changed, 0 insertions, 105 deletions
diff --git a/components/style/gecko_string_cache/namespace.rs b/components/style/gecko_string_cache/namespace.rs
deleted file mode 100644
index d9745b9e21f..00000000000
--- a/components/style/gecko_string_cache/namespace.rs
+++ /dev/null
@@ -1,105 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
-
-//! A type to represent a namespace.
-
-use crate::gecko_bindings::structs::nsAtom;
-use crate::string_cache::{Atom, WeakAtom};
-use precomputed_hash::PrecomputedHash;
-use std::borrow::Borrow;
-use std::fmt;
-use std::ops::Deref;
-
-/// In Gecko namespaces are just regular atoms, so this is a simple macro to
-/// forward one macro to the other.
-#[macro_export]
-macro_rules! ns {
- () => {
- $crate::string_cache::Namespace(atom!(""))
- };
- ($s:tt) => {
- $crate::string_cache::Namespace(atom!($s))
- };
-}
-
-/// A Gecko namespace is just a wrapped atom.
-#[derive(
- Clone,
- Debug,
- Default,
- Eq,
- Hash,
- MallocSizeOf,
- PartialEq,
- ToComputedValue,
- ToResolvedValue,
- ToShmem,
-)]
-#[repr(transparent)]
-pub struct Namespace(pub Atom);
-
-impl PrecomputedHash for Namespace {
- #[inline]
- fn precomputed_hash(&self) -> u32 {
- self.0.precomputed_hash()
- }
-}
-
-/// A Gecko WeakNamespace is a wrapped WeakAtom.
-#[derive(Deref, Hash)]
-pub struct WeakNamespace(WeakAtom);
-
-impl Deref for Namespace {
- type Target = WeakNamespace;
-
- #[inline]
- fn deref(&self) -> &WeakNamespace {
- let weak: *const WeakAtom = &*self.0;
- unsafe { &*(weak as *const WeakNamespace) }
- }
-}
-
-impl<'a> From<&'a str> for Namespace {
- fn from(s: &'a str) -> Self {
- Namespace(Atom::from(s))
- }
-}
-
-impl fmt::Display for Namespace {
- fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result {
- self.0.fmt(w)
- }
-}
-
-impl Borrow<WeakNamespace> for Namespace {
- #[inline]
- fn borrow(&self) -> &WeakNamespace {
- self
- }
-}
-
-impl WeakNamespace {
- /// Trivially construct a WeakNamespace.
- #[inline]
- pub unsafe fn new<'a>(atom: *mut nsAtom) -> &'a Self {
- &*(atom as *const WeakNamespace)
- }
-
- /// Clone this WeakNamespace to obtain a strong reference to the same
- /// underlying namespace.
- #[inline]
- pub fn clone(&self) -> Namespace {
- Namespace(self.0.clone())
- }
-}
-
-impl Eq for WeakNamespace {}
-impl PartialEq for WeakNamespace {
- #[inline]
- fn eq(&self, other: &Self) -> bool {
- let weak: *const WeakNamespace = self;
- let other: *const WeakNamespace = other;
- weak == other
- }
-}