Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  source.rs

  Sprache: Rust
 

/* 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/. */


#![deny(unsafe_code)]

use crate::properties::PropertyDeclarationBlock;
use crate::shared_lock::{Locked, SharedRwLockReadGuard};
use servo_arc::Arc;
use std::io::Write;
use std::ptr;

/// A style source for the rule node. It is a declaration block that may come from either a style
/// rule or a standalone block like animations / transitions / smil / preshints / style attr...
///
/// Keeping the style rule around would provide more debugability, but also causes more
/// pointer-chasing in the common code-path, which is undesired. If needed, we could keep it around
/// in debug builds or something along those lines.
#[derive(Clone, Debug)]
pub struct StyleSource(Arc<Locked<PropertyDeclarationBlock>>);

impl PartialEq for StyleSource {
    fn eq(&self, other: &Self) -> bool {
        Arc::ptr_eq(&self.0, &other.0)
    }
}

impl StyleSource {
    #[inline]
    pub(superfn key(&self) -> ptr::NonNull<()> {
        self.0.raw_ptr()
    }

    /// Creates a StyleSource from a PropertyDeclarationBlock.
    #[inline]
    pub fn from_declarations(decls: Arc<Locked<PropertyDeclarationBlock>>) -> Self {
        Self(decls)
    }

    pub(superfn dump<W: Write>(&self, guard: &SharedRwLockReadGuard, writer: &='color:red'>mut W) {
        let _ = write!(writer, "  -> {:?}"self.read(guard).declarations());
    }

    /// Read the style source guard, and obtain thus read access to the
    /// underlying property declaration block.
    #[inline]
    pub fn read<'a>(&'self, guard: &'a SharedRwLockReadGuard) -> &'span>a PropertyDeclarationBlock {
        self.0.read_with(guard)
    }

    /// Returns the declaration block if applicable, otherwise None.
    #[inline]
    pub fn get(&self) -> &Arc<Locked<PropertyDeclarationBlock>> {
        &self.0
    }

    /// Marks this block as part of the rule tree.
    #[inline]
    pub fn mark_in_rule_tree(&self) {
        use std::sync::atomic::Ordering;
        if self.0.is_static() {
            // For static pointers, it doesn't matter whether we might be in the rule tree or not,
            // because those are not mutable.
            return;
        }
        // SAFETY: We're only accessing a relaxed atomic inside the locked object, which we know
        // is alive. In theory, we could/should track that boolean outside of the
        // Locked<PropertyDeclarationBlock>, but that is kind of a PITA.
        #[allow(unsafe_code)]
        unsafe {
            self.0
                .read_unchecked()
                .immutable
                .store(true, Ordering::Relaxed);
        }
    }
}

Messung V0.5 in Prozent
C=91 H=91 G=90

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=141584
#Domains=752002