mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Rustfmt recent changes.
This commit is contained in:
parent
152ef2e042
commit
5f173c463e
16 changed files with 53 additions and 43 deletions
|
@ -24,11 +24,11 @@ use crate::values::computed::{Angle, CalcLengthOrPercentage, Gradient, Image};
|
|||
use crate::values::computed::{Integer, LengthOrPercentage};
|
||||
use crate::values::computed::{LengthOrPercentageOrAuto, NonNegativeLengthOrPercentageOrAuto};
|
||||
use crate::values::computed::{Percentage, TextAlign};
|
||||
use crate::values::generics::NonNegative;
|
||||
use crate::values::generics::box_::VerticalAlign;
|
||||
use crate::values::generics::grid::{TrackListValue, TrackSize};
|
||||
use crate::values::generics::image::{CompatMode, GradientItem, Image as GenericImage};
|
||||
use crate::values::generics::rect::Rect;
|
||||
use crate::values::generics::NonNegative;
|
||||
use app_units::Au;
|
||||
use std::f32::consts::PI;
|
||||
|
||||
|
@ -677,11 +677,11 @@ pub mod basic_shape {
|
|||
use crate::values::generics::basic_shape::{
|
||||
BasicShape as GenericBasicShape, InsetRect, Polygon,
|
||||
};
|
||||
use crate::values::generics::NonNegative;
|
||||
use crate::values::generics::basic_shape::{Circle, Ellipse, Path, PolygonCoord};
|
||||
use crate::values::generics::basic_shape::{GeometryBox, ShapeBox, ShapeSource};
|
||||
use crate::values::generics::border::BorderRadius as GenericBorderRadius;
|
||||
use crate::values::generics::rect::Rect;
|
||||
use crate::values::generics::NonNegative;
|
||||
use crate::values::specified::SVGPathData;
|
||||
use std::borrow::Borrow;
|
||||
|
||||
|
@ -841,10 +841,17 @@ pub mod basic_shape {
|
|||
fn from(other: &'a nsStyleCorners) -> Self {
|
||||
let get_corner = |index| {
|
||||
BorderCornerRadius::new(
|
||||
NonNegative(LengthOrPercentage::from_gecko_style_coord(&other.data_at(index))
|
||||
.expect("<border-radius> should be a length, percentage, or calc value")),
|
||||
NonNegative(LengthOrPercentage::from_gecko_style_coord(&other.data_at(index + 1))
|
||||
.expect("<border-radius> should be a length, percentage, or calc value")),
|
||||
NonNegative(
|
||||
LengthOrPercentage::from_gecko_style_coord(&other.data_at(index)).expect(
|
||||
"<border-radius> should be a length, percentage, or calc value",
|
||||
),
|
||||
),
|
||||
NonNegative(
|
||||
LengthOrPercentage::from_gecko_style_coord(&other.data_at(index + 1))
|
||||
.expect(
|
||||
"<border-radius> should be a length, percentage, or calc value",
|
||||
),
|
||||
),
|
||||
)
|
||||
};
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
use crate::context::QuirksMode;
|
||||
use crate::dom::TElement;
|
||||
use crate::gecko_bindings::bindings::{self, RawServoStyleSet};
|
||||
use crate::gecko_bindings::structs::{StyleSheet as DomStyleSheet, StyleSheetInfo};
|
||||
use crate::gecko_bindings::structs::{RawGeckoPresContextBorrowed, ServoStyleSetSizes};
|
||||
use crate::gecko_bindings::structs::{StyleSheet as DomStyleSheet, StyleSheetInfo};
|
||||
use crate::gecko_bindings::sugar::ownership::{HasArcFFI, HasBoxFFI, HasFFI, HasSimpleFFI};
|
||||
use crate::invalidation::media_queries::{MediaListKey, ToMediaListKey};
|
||||
use crate::media_queries::{Device, MediaList};
|
||||
|
@ -150,8 +150,7 @@ impl PerDocumentStyleData {
|
|||
// right now not always honored, see bug 1405543...
|
||||
//
|
||||
// Should we just force XBL Stylists to be NoQuirks?
|
||||
let quirks_mode =
|
||||
unsafe { (*device.pres_context().mDocument.mRawPtr).mCompatMode };
|
||||
let quirks_mode = unsafe { (*device.pres_context().mDocument.mRawPtr).mCompatMode };
|
||||
|
||||
PerDocumentStyleData(AtomicRefCell::new(PerDocumentStyleDataImpl {
|
||||
stylist: Stylist::new(device, quirks_mode.into()),
|
||||
|
@ -192,12 +191,7 @@ impl PerDocumentStyleDataImpl {
|
|||
/// Returns whether visited styles are enabled.
|
||||
#[inline]
|
||||
pub fn visited_styles_enabled(&self) -> bool {
|
||||
let doc = self
|
||||
.stylist
|
||||
.device()
|
||||
.pres_context()
|
||||
.mDocument
|
||||
.mRawPtr;
|
||||
let doc = self.stylist.device().pres_context().mDocument.mRawPtr;
|
||||
unsafe { bindings::Gecko_VisitedStylesEnabled(doc) }
|
||||
}
|
||||
|
||||
|
|
|
@ -320,8 +320,7 @@ fn eval_overflow_block(device: &Device, query_value: Option<OverflowBlock>) -> b
|
|||
};
|
||||
|
||||
match query_value {
|
||||
OverflowBlock::None |
|
||||
OverflowBlock::OptionalPaged => false,
|
||||
OverflowBlock::None | OverflowBlock::OptionalPaged => false,
|
||||
OverflowBlock::Scroll => scrolling,
|
||||
OverflowBlock::Paged => !scrolling,
|
||||
}
|
||||
|
|
|
@ -286,9 +286,7 @@ impl GeckoStyleCoordConvertible for ComputedShapeRadius {
|
|||
None
|
||||
}
|
||||
},
|
||||
_ => {
|
||||
GeckoStyleCoordConvertible::from_gecko_style_coord(coord).map(ShapeRadius::Length)
|
||||
},
|
||||
_ => GeckoStyleCoordConvertible::from_gecko_style_coord(coord).map(ShapeRadius::Length),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,8 +45,8 @@ use crate::gecko_bindings::bindings::{Gecko_ElementState, Gecko_GetDocumentLWThe
|
|||
use crate::gecko_bindings::bindings::{Gecko_SetNodeFlags, Gecko_UnsetNodeFlags};
|
||||
use crate::gecko_bindings::structs;
|
||||
use crate::gecko_bindings::structs::nsChangeHint;
|
||||
use crate::gecko_bindings::structs::Document_DocumentTheme as DocumentTheme;
|
||||
use crate::gecko_bindings::structs::nsRestyleHint;
|
||||
use crate::gecko_bindings::structs::Document_DocumentTheme as DocumentTheme;
|
||||
use crate::gecko_bindings::structs::EffectCompositor_CascadeLevel as CascadeLevel;
|
||||
use crate::gecko_bindings::structs::ELEMENT_HANDLED_SNAPSHOT;
|
||||
use crate::gecko_bindings::structs::ELEMENT_HAS_ANIMATION_ONLY_DIRTY_DESCENDANTS_FOR_SERVO;
|
||||
|
@ -1243,10 +1243,7 @@ impl<'le> TElement for GeckoElement<'le> {
|
|||
|
||||
fn owner_doc_matches_for_testing(&self, device: &Device) -> bool {
|
||||
self.as_node().owner_doc().0 as *const structs::Document ==
|
||||
device
|
||||
.pres_context()
|
||||
.mDocument
|
||||
.mRawPtr
|
||||
device.pres_context().mDocument.mRawPtr
|
||||
}
|
||||
|
||||
fn style_attribute(&self) -> Option<ArcBorrow<Locked<PropertyDeclarationBlock>>> {
|
||||
|
|
|
@ -10,7 +10,10 @@ use crate::stylesheets::OriginSet;
|
|||
/// Checks that the values for OriginFlags are the ones we expect.
|
||||
pub fn assert_flags_match() {
|
||||
use crate::stylesheets::origin::*;
|
||||
debug_assert_eq!(OriginFlags::UserAgent.0, OriginSet::ORIGIN_USER_AGENT.bits());
|
||||
debug_assert_eq!(
|
||||
OriginFlags::UserAgent.0,
|
||||
OriginSet::ORIGIN_USER_AGENT.bits()
|
||||
);
|
||||
debug_assert_eq!(OriginFlags::Author.0, OriginSet::ORIGIN_AUTHOR.bits());
|
||||
debug_assert_eq!(OriginFlags::User.0, OriginSet::ORIGIN_USER.bits());
|
||||
}
|
||||
|
|
|
@ -205,13 +205,17 @@ impl From<nsRestyleHint> for RestyleHint {
|
|||
hint.insert(RestyleHint::RESTYLE_SELF);
|
||||
}
|
||||
|
||||
if (raw.0 & (nsRestyleHint::eRestyle_Subtree.0 | nsRestyleHint::eRestyle_SomeDescendants.0)) != 0 {
|
||||
if (raw.0 & (nsRestyleHint::eRestyle_Subtree.0 | nsRestyleHint::eRestyle_SomeDescendants.0)) !=
|
||||
0
|
||||
{
|
||||
raw.0 &= !nsRestyleHint::eRestyle_Subtree.0;
|
||||
raw.0 &= !nsRestyleHint::eRestyle_SomeDescendants.0;
|
||||
hint.insert(RestyleHint::RESTYLE_DESCENDANTS);
|
||||
}
|
||||
|
||||
if (raw.0 & (nsRestyleHint::eRestyle_ForceDescendants.0 | nsRestyleHint::eRestyle_Force.0)) != 0 {
|
||||
if (raw.0 & (nsRestyleHint::eRestyle_ForceDescendants.0 | nsRestyleHint::eRestyle_Force.0)) !=
|
||||
0
|
||||
{
|
||||
raw.0 &= !nsRestyleHint::eRestyle_Force.0;
|
||||
hint.insert(RestyleHint::RECASCADE_SELF);
|
||||
}
|
||||
|
|
|
@ -260,8 +260,7 @@ where
|
|||
|
||||
let cascade_data = containing_shadow.style_data();
|
||||
let host = containing_shadow.host();
|
||||
if let Some(map) = cascade_data.and_then(|data| data.normal_rules(self.pseudo_element))
|
||||
{
|
||||
if let Some(map) = cascade_data.and_then(|data| data.normal_rules(self.pseudo_element)) {
|
||||
self.collect_rules_in_shadow_tree(host, map, CascadeLevel::SameTreeAuthorNormal);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ use crate::media_queries::Device;
|
|||
use crate::properties::{self, CascadeMode, ComputedValues};
|
||||
use crate::properties::{AnimationRules, PropertyDeclarationBlock};
|
||||
use crate::rule_cache::{RuleCache, RuleCacheConditions};
|
||||
use crate::rule_collector::{RuleCollector, containing_shadow_ignoring_svg_use};
|
||||
use crate::rule_collector::{containing_shadow_ignoring_svg_use, RuleCollector};
|
||||
use crate::rule_tree::{CascadeLevel, RuleTree, ShadowCascadeOrder, StrongRuleNode, StyleSource};
|
||||
use crate::selector_map::{PrecomputedHashMap, PrecomputedHashSet, SelectorMap, SelectorMapEntry};
|
||||
use crate::selector_parser::{PerPseudoElementMap, PseudoElement, SelectorImpl, SnapshotMap};
|
||||
|
|
|
@ -13,8 +13,8 @@ use crate::values::computed::length::CalcLengthOrPercentage;
|
|||
use crate::values::computed::url::ComputedUrl;
|
||||
use crate::values::computed::Angle as ComputedAngle;
|
||||
use crate::values::computed::Image;
|
||||
use crate::values::CSSFloat;
|
||||
use crate::values::specified::SVGPathData;
|
||||
use crate::values::CSSFloat;
|
||||
use app_units::Au;
|
||||
use euclid::{Point2D, Size2D};
|
||||
use smallvec::SmallVec;
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
|
||||
//! Computed types for CSS values related to borders.
|
||||
|
||||
use crate::values::generics::NonNegative;
|
||||
use crate::values::computed::length::{NonNegativeLengthOrPercentage, NonNegativeLength};
|
||||
use crate::values::computed::length::{NonNegativeLength, NonNegativeLengthOrPercentage};
|
||||
use crate::values::computed::{NonNegativeNumber, NonNegativeNumberOrPercentage};
|
||||
use crate::values::generics::border::BorderCornerRadius as GenericBorderCornerRadius;
|
||||
use crate::values::generics::border::BorderImageSideWidth as GenericBorderImageSideWidth;
|
||||
|
@ -14,6 +13,7 @@ use crate::values::generics::border::BorderRadius as GenericBorderRadius;
|
|||
use crate::values::generics::border::BorderSpacing as GenericBorderSpacing;
|
||||
use crate::values::generics::rect::Rect;
|
||||
use crate::values::generics::size::Size;
|
||||
use crate::values::generics::NonNegative;
|
||||
use app_units::Au;
|
||||
|
||||
pub use crate::values::specified::border::BorderImageRepeat;
|
||||
|
@ -22,7 +22,8 @@ pub use crate::values::specified::border::BorderImageRepeat;
|
|||
pub type BorderImageWidth = Rect<BorderImageSideWidth>;
|
||||
|
||||
/// A computed value for a single side of a `border-image-width` property.
|
||||
pub type BorderImageSideWidth = GenericBorderImageSideWidth<NonNegativeLengthOrPercentage, NonNegativeNumber>;
|
||||
pub type BorderImageSideWidth =
|
||||
GenericBorderImageSideWidth<NonNegativeLengthOrPercentage, NonNegativeNumber>;
|
||||
|
||||
/// A computed value for the `border-image-slice` property.
|
||||
pub type BorderImageSlice = GenericBorderImageSlice<NonNegativeNumberOrPercentage>;
|
||||
|
|
|
@ -546,7 +546,9 @@ pub enum NumberOrPercentage {
|
|||
impl NumberOrPercentage {
|
||||
fn clamp_to_non_negative(self) -> Self {
|
||||
match self {
|
||||
NumberOrPercentage::Percentage(p) => NumberOrPercentage::Percentage(p.clamp_to_non_negative()),
|
||||
NumberOrPercentage::Percentage(p) => {
|
||||
NumberOrPercentage::Percentage(p.clamp_to_non_negative())
|
||||
},
|
||||
NumberOrPercentage::Number(n) => NumberOrPercentage::Number(n.max(0.)),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@ use crate::values::specified::border::BorderRadius;
|
|||
use crate::values::specified::image::Image;
|
||||
use crate::values::specified::position::{HorizontalPosition, Position, VerticalPosition};
|
||||
use crate::values::specified::url::SpecifiedUrl;
|
||||
use crate::values::specified::{LengthOrPercentage, NonNegativeLengthOrPercentage};
|
||||
use crate::values::specified::SVGPathData;
|
||||
use crate::values::specified::{LengthOrPercentage, NonNegativeLengthOrPercentage};
|
||||
use cssparser::Parser;
|
||||
use std::fmt::{self, Write};
|
||||
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
||||
|
|
|
@ -13,7 +13,7 @@ use crate::values::generics::border::BorderRadius as GenericBorderRadius;
|
|||
use crate::values::generics::border::BorderSpacing as GenericBorderSpacing;
|
||||
use crate::values::generics::rect::Rect;
|
||||
use crate::values::generics::size::Size;
|
||||
use crate::values::specified::length::{NonNegativeLengthOrPercentage, NonNegativeLength};
|
||||
use crate::values::specified::length::{NonNegativeLength, NonNegativeLengthOrPercentage};
|
||||
use crate::values::specified::{AllowQuirks, NonNegativeNumber, NonNegativeNumberOrPercentage};
|
||||
use cssparser::Parser;
|
||||
use std::fmt::{self, Write};
|
||||
|
@ -78,7 +78,8 @@ pub enum BorderSideWidth {
|
|||
pub type BorderImageWidth = Rect<BorderImageSideWidth>;
|
||||
|
||||
/// A specified value for a single side of a `border-image-width` property.
|
||||
pub type BorderImageSideWidth = GenericBorderImageSideWidth<NonNegativeLengthOrPercentage, NonNegativeNumber>;
|
||||
pub type BorderImageSideWidth =
|
||||
GenericBorderImageSideWidth<NonNegativeLengthOrPercentage, NonNegativeNumber>;
|
||||
|
||||
/// A specified value for the `border-image-slice` property.
|
||||
pub type BorderImageSlice = GenericBorderImageSlice<NonNegativeNumberOrPercentage>;
|
||||
|
@ -116,8 +117,7 @@ impl BorderSideWidth {
|
|||
input: &mut Parser<'i, 't>,
|
||||
allow_quirks: AllowQuirks,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
if let Ok(length) =
|
||||
input.try(|i| NonNegativeLength::parse_quirky(context, i, allow_quirks))
|
||||
if let Ok(length) = input.try(|i| NonNegativeLength::parse_quirky(context, i, allow_quirks))
|
||||
{
|
||||
return Ok(BorderSideWidth::Length(length));
|
||||
}
|
||||
|
|
|
@ -725,7 +725,11 @@ impl NonNegativeLength {
|
|||
input: &mut Parser<'i, 't>,
|
||||
allow_quirks: AllowQuirks,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
Ok(NonNegative(Length::parse_non_negative_quirky(context, input, allow_quirks)?))
|
||||
Ok(NonNegative(Length::parse_non_negative_quirky(
|
||||
context,
|
||||
input,
|
||||
allow_quirks,
|
||||
)?))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -375,7 +375,9 @@ impl Parse for NonNegativeNumberOrPercentage {
|
|||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
Ok(NonNegative(NumberOrPercentage::parse_non_negative(context, input)?))
|
||||
Ok(NonNegative(NumberOrPercentage::parse_non_negative(
|
||||
context, input,
|
||||
)?))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue