Eine aufbereitete Darstellung der Quelle

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

Benutzer

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


//! Generic values for UI properties.

use crate::derives::*;
use crate::typed_om::{ToTyped, TypedValue};
use crate::values::specified::ui::CursorKind;
use std::fmt::{self, Write};
use style_traits::{CssWriter, ToCss};
use thin_vec::ThinVec;

/// A generic value for the `cursor` property.
///
/// https://drafts.csswg.org/css-ui/#cursor
#[derive(
    Clone,
    Debug,
    MallocSizeOf,
    PartialEq,
    SpecifiedValueInfo,
    ToComputedValue,
    ToResolvedValue,
    ToShmem,
)]
#[repr(C)]
pub struct GenericCursor<Image> {
    /// The parsed images for the cursor.
    pub images: crate::OwnedSlice<Image>,
    /// The kind of the cursor [default | help | ...].
    pub keyword: CursorKind,
}

pub use self::GenericCursor as Cursor;

impl<Image> Cursor<Image> {
    /// Set `cursor` to `auto`
    #[inline]
    pub fn auto() -> Self {
        Self {
            images: Default::default(),
            keyword: CursorKind::Auto,
        }
    }
}

impl<Image: ToCss> ToCss for Cursor<Image> {
    fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
    where
        W: Write,
    {
        for image in &*self.images {
            image.to_css(dest)?;
            dest.write_str(", ")?;
        }
        self.keyword.to_css(dest)
    }
}

impl<Image> ToTyped for Cursor<Image> {
    // Note: The specification does not currently define how cursor should be
    // reified into Typed OM. The current behavior follows existing WPT
    // coverage (cursor.html). Syncing spec with UA/WPT behavior tracked in
    // https://github.com/w3c/csswg-drafts/issues/13907
    fn to_typed(&self, dest: &mut ThinVec<TypedValue>) -> Result<(), ()> {
        if self.images.len() != 0 {
            return Err(());
        }

        self.keyword.to_typed(dest)
    }
}

/// A generic value for item of `image cursors`.
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToShmem)]
#[repr(C)]
pub struct GenericCursorImage<Image, Number> {
    /// The url to parse images from.
    pub image: Image,
    /// Whether the image has a hotspot or not.
    pub has_hotspot: bool,
    /// The x coordinate.
    pub hotspot_x: Number,
    /// The y coordinate.
    pub hotspot_y: Number,
}

pub use self::GenericCursorImage as CursorImage;

impl<Image: ToCss, Number: ToCss> ToCss for CursorImage<Image, Number> {
    fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
    where
        W: Write,
    {
        self.image.to_css(dest)?;
        if self.has_hotspot {
            dest.write_char(' ')?;
            self.hotspot_x.to_css(dest)?;
            dest.write_char(' ')?;
            self.hotspot_y.to_css(dest)?;
        }
        Ok(())
    }
}

/// A generic value for `scrollbar-color` property.
///
/// https://drafts.csswg.org/css-scrollbars-1/#scrollbar-color
#[derive(
    Animate,
    Clone,
    ComputeSquaredDistance,
    Copy,
    Debug,
    MallocSizeOf,
    PartialEq,
    SpecifiedValueInfo,
    ToAnimatedValue,
    ToAnimatedZero,
    ToComputedValue,
    ToCss,
    ToResolvedValue,
    ToShmem,
    ToTyped,
)]
#[repr(C, u8)]
pub enum GenericScrollbarColor<Color> {
    /// `auto`
    Auto,
    /// `<color>{2}`
    Colors {
        /// First `<color>`, for color of the scrollbar thumb.
        thumb: Color,
        /// Second `<color>`, for color of the scrollbar track.
        track: Color,
    },
}

pub use self::GenericScrollbarColor as ScrollbarColor;

impl<Color> Default for ScrollbarColor<Color> {
    #[inline]
    fn default() -> Self {
        ScrollbarColor::Auto
    }
}

Messung V0.5 in Prozent
C=72 H=99 G=86

¤ Dauer der Verarbeitung: 0.4 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=277311
#Domains=752002