cargo fix --edition --features gecko

This commit is contained in:
Simon Sapin 2018-11-06 22:33:52 +01:00
parent a15d33a10e
commit b1822a39fa
87 changed files with 614 additions and 585 deletions

View file

@ -8,40 +8,42 @@
#![allow(non_snake_case, missing_docs)]
use gecko::url::CssUrlData;
use gecko_bindings::bindings::RawServoCounterStyleRule;
use gecko_bindings::bindings::RawServoFontFeatureValuesRule;
use gecko_bindings::bindings::RawServoImportRule;
use gecko_bindings::bindings::RawServoKeyframe;
use gecko_bindings::bindings::RawServoKeyframesRule;
use gecko_bindings::bindings::RawServoMediaRule;
use gecko_bindings::bindings::RawServoMozDocumentRule;
use gecko_bindings::bindings::RawServoNamespaceRule;
use gecko_bindings::bindings::RawServoPageRule;
use gecko_bindings::bindings::RawServoRuleNode;
use gecko_bindings::bindings::RawServoRuleNodeStrong;
use gecko_bindings::bindings::RawServoSupportsRule;
use gecko_bindings::bindings::ServoCssRules;
use gecko_bindings::structs::RawServoAnimationValue;
use gecko_bindings::structs::RawServoCssUrlData;
use gecko_bindings::structs::RawServoDeclarationBlock;
use gecko_bindings::structs::RawServoFontFaceRule;
use gecko_bindings::structs::RawServoMediaList;
use gecko_bindings::structs::RawServoQuotes;
use gecko_bindings::structs::RawServoStyleRule;
use gecko_bindings::structs::RawServoStyleSheetContents;
use gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI, Strong};
use media_queries::MediaList;
use properties::animated_properties::AnimationValue;
use properties::{ComputedValues, PropertyDeclarationBlock};
use rule_tree::StrongRuleNode;
use crate::gecko::url::CssUrlData;
use crate::gecko_bindings::bindings::RawServoCounterStyleRule;
use crate::gecko_bindings::bindings::RawServoFontFeatureValuesRule;
use crate::gecko_bindings::bindings::RawServoImportRule;
use crate::gecko_bindings::bindings::RawServoKeyframe;
use crate::gecko_bindings::bindings::RawServoKeyframesRule;
use crate::gecko_bindings::bindings::RawServoMediaRule;
use crate::gecko_bindings::bindings::RawServoMozDocumentRule;
use crate::gecko_bindings::bindings::RawServoNamespaceRule;
use crate::gecko_bindings::bindings::RawServoPageRule;
use crate::gecko_bindings::bindings::RawServoRuleNode;
use crate::gecko_bindings::bindings::RawServoRuleNodeStrong;
use crate::gecko_bindings::bindings::RawServoSupportsRule;
use crate::gecko_bindings::bindings::ServoCssRules;
use crate::gecko_bindings::structs::RawServoAnimationValue;
use crate::gecko_bindings::structs::RawServoCssUrlData;
use crate::gecko_bindings::structs::RawServoDeclarationBlock;
use crate::gecko_bindings::structs::RawServoFontFaceRule;
use crate::gecko_bindings::structs::RawServoMediaList;
use crate::gecko_bindings::structs::RawServoQuotes;
use crate::gecko_bindings::structs::RawServoStyleRule;
use crate::gecko_bindings::structs::RawServoStyleSheetContents;
use crate::gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI, Strong};
use crate::media_queries::MediaList;
use crate::properties::animated_properties::AnimationValue;
use crate::properties::{ComputedValues, PropertyDeclarationBlock};
use crate::rule_tree::StrongRuleNode;
use crate::shared_lock::Locked;
use crate::stylesheets::keyframes_rule::Keyframe;
use crate::stylesheets::{CounterStyleRule, CssRules, FontFaceRule, FontFeatureValuesRule};
use crate::stylesheets::{
DocumentRule, ImportRule, KeyframesRule, MediaRule, NamespaceRule, PageRule,
};
use crate::stylesheets::{StyleRule, StylesheetContents, SupportsRule};
use servo_arc::{Arc, ArcBorrow};
use shared_lock::Locked;
use std::{mem, ptr};
use stylesheets::keyframes_rule::Keyframe;
use stylesheets::{CounterStyleRule, CssRules, FontFaceRule, FontFeatureValuesRule};
use stylesheets::{DocumentRule, ImportRule, KeyframesRule, MediaRule, NamespaceRule, PageRule};
use stylesheets::{StyleRule, StylesheetContents, SupportsRule};
use values::computed::QuotePair;
macro_rules! impl_arc_ffi {

View file

@ -9,24 +9,24 @@
#![allow(unsafe_code)]
use app_units::Au;
use gecko::values::GeckoStyleCoordConvertible;
use gecko_bindings::bindings;
use gecko_bindings::structs::{self, nsStyleCoord_CalcValue};
use gecko_bindings::structs::{nsStyleImage, nsresult, SheetType};
use gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataValue};
use std::f32::consts::PI;
use stylesheets::{Origin, RulesMutateError};
use values::computed::image::LineDirection;
use values::computed::url::ComputedImageUrl;
use values::computed::{Angle, CalcLengthOrPercentage, Gradient, Image};
use values::computed::{
use crate::gecko::values::GeckoStyleCoordConvertible;
use crate::gecko_bindings::bindings;
use crate::gecko_bindings::structs::{self, nsStyleCoord_CalcValue};
use crate::gecko_bindings::structs::{nsStyleImage, nsresult, SheetType};
use crate::gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataValue};
use crate::stylesheets::{Origin, RulesMutateError};
use crate::values::computed::image::LineDirection;
use crate::values::computed::url::ComputedImageUrl;
use crate::values::computed::{Angle, CalcLengthOrPercentage, Gradient, Image};
use crate::values::computed::{
Integer, LengthOrPercentage, LengthOrPercentageOrAuto, NonNegativeLengthOrPercentageOrAuto,
};
use values::computed::{Percentage, TextAlign};
use values::generics::box_::VerticalAlign;
use values::generics::grid::{TrackListValue, TrackSize};
use values::generics::image::{CompatMode, GradientItem, Image as GenericImage};
use values::generics::rect::Rect;
use crate::values::computed::{Percentage, TextAlign};
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 std::f32::consts::PI;
impl From<CalcLengthOrPercentage> for nsStyleCoord_CalcValue {
fn from(other: CalcLengthOrPercentage) -> nsStyleCoord_CalcValue {
@ -112,8 +112,8 @@ impl From<nsStyleCoord_CalcValue> for LengthOrPercentageOrAuto {
// disappear as we move more stuff to cbindgen.
impl From<nsStyleCoord_CalcValue> for NonNegativeLengthOrPercentageOrAuto {
fn from(other: nsStyleCoord_CalcValue) -> Self {
use crate::values::generics::NonNegative;
use style_traits::values::specified::AllowedNumericType;
use values::generics::NonNegative;
NonNegative(if other.mLength < 0 || other.mPercent < 0. {
LengthOrPercentageOrAuto::Calc(CalcLengthOrPercentage::with_clamping_mode(
Au(other.mLength).into(),
@ -137,8 +137,8 @@ impl From<Angle> for CoordDataValue {
}
fn line_direction(horizontal: LengthOrPercentage, vertical: LengthOrPercentage) -> LineDirection {
use values::computed::position::Position;
use values::specified::position::{X, Y};
use crate::values::computed::position::Position;
use crate::values::specified::position::{X, Y};
let horizontal_percentage = match horizontal {
LengthOrPercentage::Percentage(percentage) => Some(percentage.0),
@ -240,8 +240,10 @@ impl nsStyleImage {
use self::structs::NS_STYLE_GRADIENT_SIZE_CLOSEST_SIDE as CLOSEST_SIDE;
use self::structs::NS_STYLE_GRADIENT_SIZE_FARTHEST_CORNER as FARTHEST_CORNER;
use self::structs::NS_STYLE_GRADIENT_SIZE_FARTHEST_SIDE as FARTHEST_SIDE;
use values::generics::image::{Circle, Ellipse, EndingShape, GradientKind, ShapeExtent};
use values::specified::position::{X, Y};
use crate::values::generics::image::{
Circle, Ellipse, EndingShape, GradientKind, ShapeExtent,
};
use crate::values::specified::position::{X, Y};
let stop_count = gradient.items.len();
if stop_count >= ::std::u32::MAX as usize {
@ -437,8 +439,8 @@ impl nsStyleImage {
/// Converts into Image.
pub unsafe fn into_image(self: &nsStyleImage) -> Option<Image> {
use gecko_bindings::structs::nsStyleImageType;
use values::computed::{MozImageRect, NumberOrPercentage};
use crate::gecko_bindings::structs::nsStyleImageType;
use crate::values::computed::{MozImageRect, NumberOrPercentage};
match self.mType {
nsStyleImageType::eStyleImageType_Null => None,
@ -477,7 +479,7 @@ impl nsStyleImage {
Some(GenericImage::Gradient(self.get_gradient()))
},
nsStyleImageType::eStyleImageType_Element => {
use gecko_string_cache::Atom;
use crate::gecko_string_cache::Atom;
let atom = bindings::Gecko_GetImageElement(self);
Some(GenericImage::Element(Atom::from_raw(atom)))
},
@ -497,11 +499,11 @@ impl nsStyleImage {
use self::structs::NS_STYLE_GRADIENT_SIZE_CLOSEST_SIDE as CLOSEST_SIDE;
use self::structs::NS_STYLE_GRADIENT_SIZE_FARTHEST_CORNER as FARTHEST_CORNER;
use self::structs::NS_STYLE_GRADIENT_SIZE_FARTHEST_SIDE as FARTHEST_SIDE;
use values::computed::image::LineDirection;
use values::computed::position::Position;
use values::computed::Length;
use values::generics::image::{Circle, ColorStop, CompatMode, Ellipse};
use values::generics::image::{EndingShape, GradientKind, ShapeExtent};
use crate::values::computed::image::LineDirection;
use crate::values::computed::position::Position;
use crate::values::computed::Length;
use crate::values::generics::image::{Circle, ColorStop, CompatMode, Ellipse};
use crate::values::generics::image::{EndingShape, GradientKind, ShapeExtent};
let gecko_gradient = bindings::Gecko_GetGradientImageValue(self)
.as_ref()
@ -652,26 +654,32 @@ impl nsStyleImage {
pub mod basic_shape {
//! Conversions from and to CSS shape representations.
use gecko::values::GeckoStyleCoordConvertible;
use gecko_bindings::structs;
use gecko_bindings::structs::{nsStyleCoord, nsStyleCorners};
use gecko_bindings::structs::{StyleBasicShape, StyleBasicShapeType};
use gecko_bindings::structs::{StyleGeometryBox, StyleShapeSource, StyleShapeSourceType};
use gecko_bindings::sugar::ns_style_coord::{CoordDataMut, CoordDataValue};
use gecko_bindings::sugar::refptr::RefPtr;
use crate::gecko::values::GeckoStyleCoordConvertible;
use crate::gecko_bindings::structs;
use crate::gecko_bindings::structs::{nsStyleCoord, nsStyleCorners};
use crate::gecko_bindings::structs::{StyleBasicShape, StyleBasicShapeType};
use crate::gecko_bindings::structs::{
StyleGeometryBox, StyleShapeSource, StyleShapeSourceType,
};
use crate::gecko_bindings::sugar::ns_style_coord::{CoordDataMut, CoordDataValue};
use crate::gecko_bindings::sugar::refptr::RefPtr;
use crate::values::computed::basic_shape::{
BasicShape, ClippingShape, FloatAreaShape, ShapeRadius,
};
use crate::values::computed::border::{BorderCornerRadius, BorderRadius};
use crate::values::computed::length::LengthOrPercentage;
use crate::values::computed::motion::OffsetPath;
use crate::values::computed::position;
use crate::values::computed::url::ComputedUrl;
use crate::values::generics::basic_shape::{
BasicShape as GenericBasicShape, InsetRect, Polygon,
};
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::specified::SVGPathData;
use std::borrow::Borrow;
use values::computed::basic_shape::{BasicShape, ClippingShape, FloatAreaShape, ShapeRadius};
use values::computed::border::{BorderCornerRadius, BorderRadius};
use values::computed::length::LengthOrPercentage;
use values::computed::motion::OffsetPath;
use values::computed::position;
use values::computed::url::ComputedUrl;
use values::generics::basic_shape::{BasicShape as GenericBasicShape, InsetRect, Polygon};
use values::generics::basic_shape::{Circle, Ellipse, Path, PolygonCoord};
use values::generics::basic_shape::{GeometryBox, ShapeBox, ShapeSource};
use values::generics::border::BorderRadius as GenericBorderRadius;
use values::generics::rect::Rect;
use values::specified::SVGPathData;
impl StyleShapeSource {
/// Convert StyleShapeSource to ShapeSource except URL and Image
@ -706,7 +714,7 @@ pub mod basic_shape {
/// Generate a SVGPathData from StyleShapeSource if possible.
fn to_svg_path(&self) -> Option<SVGPathData> {
use values::specified::svg_path::PathCommand;
use crate::values::specified::svg_path::PathCommand;
match self.mType {
StyleShapeSourceType::Path => {
let gecko_path = unsafe { &*self.__bindgen_anon_1.mSVGPath.as_ref().mPtr };
@ -908,7 +916,7 @@ pub mod basic_shape {
impl From<ShapeBox> for StyleGeometryBox {
fn from(reference: ShapeBox) -> Self {
use gecko_bindings::structs::StyleGeometryBox::*;
use crate::gecko_bindings::structs::StyleGeometryBox::*;
match reference {
ShapeBox::ContentBox => ContentBox,
ShapeBox::PaddingBox => PaddingBox,
@ -920,7 +928,7 @@ pub mod basic_shape {
impl From<GeometryBox> for StyleGeometryBox {
fn from(reference: GeometryBox) -> Self {
use gecko_bindings::structs::StyleGeometryBox::*;
use crate::gecko_bindings::structs::StyleGeometryBox::*;
match reference {
GeometryBox::ShapeBox(shape_box) => From::from(shape_box),
GeometryBox::FillBox => FillBox,
@ -935,7 +943,7 @@ pub mod basic_shape {
// but coherence doesn't like that and TryFrom isn't stable
impl From<StyleGeometryBox> for GeometryBox {
fn from(reference: StyleGeometryBox) -> Self {
use gecko_bindings::structs::StyleGeometryBox::*;
use crate::gecko_bindings::structs::StyleGeometryBox::*;
match reference {
ContentBox => GeometryBox::ShapeBox(ShapeBox::ContentBox),
PaddingBox => GeometryBox::ShapeBox(ShapeBox::PaddingBox),
@ -951,7 +959,7 @@ pub mod basic_shape {
impl From<StyleGeometryBox> for ShapeBox {
fn from(reference: StyleGeometryBox) -> Self {
use gecko_bindings::structs::StyleGeometryBox::*;
use crate::gecko_bindings::structs::StyleGeometryBox::*;
match reference {
ContentBox => ShapeBox::ContentBox,
PaddingBox => ShapeBox::PaddingBox,
@ -987,9 +995,9 @@ impl From<Origin> for SheetType {
impl TrackSize<LengthOrPercentage> {
/// Return TrackSize from given two nsStyleCoord
pub fn from_gecko_style_coords<T: CoordData>(gecko_min: &T, gecko_max: &T) -> Self {
use gecko_bindings::structs::root::nsStyleUnit;
use values::computed::length::LengthOrPercentage;
use values::generics::grid::{TrackBreadth, TrackSize};
use crate::gecko_bindings::structs::root::nsStyleUnit;
use crate::values::computed::length::LengthOrPercentage;
use crate::values::generics::grid::{TrackBreadth, TrackSize};
if gecko_min.unit() == nsStyleUnit::eStyleUnit_None {
debug_assert!(
@ -1016,7 +1024,7 @@ impl TrackSize<LengthOrPercentage> {
/// Save TrackSize to given gecko fields.
pub fn to_gecko_style_coords<T: CoordDataMut>(&self, gecko_min: &mut T, gecko_max: &mut T) {
use values::generics::grid::TrackSize;
use crate::values::generics::grid::TrackSize;
match *self {
TrackSize::FitContent(ref lop) => {
@ -1047,7 +1055,7 @@ impl TrackListValue<LengthOrPercentage, Integer> {
/// Save TrackSize to given gecko fields.
pub fn to_gecko_style_coords<T: CoordDataMut>(&self, gecko_min: &mut T, gecko_max: &mut T) {
use values::generics::grid::TrackListValue;
use crate::values::generics::grid::TrackListValue;
match *self {
TrackListValue::TrackSize(ref size) => size.to_gecko_style_coords(gecko_min, gecko_max),
@ -1061,7 +1069,7 @@ where
T: GeckoStyleCoordConvertible,
{
/// Convert this generic Rect to given Gecko fields.
pub fn to_gecko_rect(&self, sides: &mut ::gecko_bindings::structs::nsStyleSides) {
pub fn to_gecko_rect(&self, sides: &mut crate::gecko_bindings::structs::nsStyleSides) {
self.0.to_gecko_style_coord(&mut sides.data_at_mut(0));
self.1.to_gecko_style_coord(&mut sides.data_at_mut(1));
self.2.to_gecko_style_coord(&mut sides.data_at_mut(2));
@ -1070,9 +1078,9 @@ where
/// Convert from given Gecko data to generic Rect.
pub fn from_gecko_rect(
sides: &::gecko_bindings::structs::nsStyleSides,
) -> Option<::values::generics::rect::Rect<T>> {
use values::generics::rect::Rect;
sides: &crate::gecko_bindings::structs::nsStyleSides,
) -> Option<crate::values::generics::rect::Rect<T>> {
use crate::values::generics::rect::Rect;
Some(Rect::new(
T::from_gecko_style_coord(&sides.data_at(0)).expect("coord[0] cound not convert"),

View file

@ -5,23 +5,23 @@
//! Data needed to style a Gecko document.
use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut};
use context::QuirksMode;
use dom::TElement;
use gecko_bindings::bindings::{self, RawServoStyleSet};
use gecko_bindings::structs::StyleSheet as DomStyleSheet;
use gecko_bindings::structs::{nsIDocument, StyleSheetInfo};
use gecko_bindings::structs::{RawGeckoPresContextBorrowed, ServoStyleSetSizes};
use gecko_bindings::sugar::ownership::{HasArcFFI, HasBoxFFI, HasFFI, HasSimpleFFI};
use invalidation::media_queries::{MediaListKey, ToMediaListKey};
use crate::context::QuirksMode;
use crate::dom::TElement;
use crate::gecko_bindings::bindings::{self, RawServoStyleSet};
use crate::gecko_bindings::structs::StyleSheet as DomStyleSheet;
use crate::gecko_bindings::structs::{nsIDocument, StyleSheetInfo};
use crate::gecko_bindings::structs::{RawGeckoPresContextBorrowed, ServoStyleSetSizes};
use crate::gecko_bindings::sugar::ownership::{HasArcFFI, HasBoxFFI, HasFFI, HasSimpleFFI};
use crate::invalidation::media_queries::{MediaListKey, ToMediaListKey};
use crate::media_queries::{Device, MediaList};
use crate::properties::ComputedValues;
use crate::selector_parser::SnapshotMap;
use crate::shared_lock::{Locked, SharedRwLockReadGuard, StylesheetGuards};
use crate::stylesheets::{CssRule, Origin, StylesheetContents, StylesheetInDocument};
use crate::stylist::Stylist;
use malloc_size_of::MallocSizeOfOps;
use media_queries::{Device, MediaList};
use properties::ComputedValues;
use selector_parser::SnapshotMap;
use servo_arc::Arc;
use shared_lock::{Locked, SharedRwLockReadGuard, StylesheetGuards};
use std::fmt;
use stylesheets::{CssRule, Origin, StylesheetContents, StylesheetInDocument};
use stylist::Stylist;
/// Little wrapper to a Gecko style sheet.
#[derive(Eq, PartialEq)]
@ -38,7 +38,7 @@ impl fmt::Debug for GeckoStyleSheet {
}
}
impl ToMediaListKey for ::gecko::data::GeckoStyleSheet {
impl ToMediaListKey for crate::gecko::data::GeckoStyleSheet {
fn to_media_list_key(&self) -> MediaListKey {
use std::mem;
unsafe { MediaListKey::from_raw(mem::transmute(self.0)) }
@ -105,7 +105,7 @@ impl StylesheetInDocument for GeckoStyleSheet {
}
fn media<'a>(&'a self, guard: &'a SharedRwLockReadGuard) -> Option<&'a MediaList> {
use gecko_bindings::structs::mozilla::dom::MediaList as DomMediaList;
use crate::gecko_bindings::structs::mozilla::dom::MediaList as DomMediaList;
use std::mem;
unsafe {

View file

@ -4,17 +4,19 @@
//! Global style data
use context::StyleSystemOptions;
use gecko_bindings::bindings::Gecko_SetJemallocThreadLocalArena;
use gecko_bindings::bindings::{Gecko_RegisterProfilerThread, Gecko_UnregisterProfilerThread};
use crate::context::StyleSystemOptions;
use crate::gecko_bindings::bindings::Gecko_SetJemallocThreadLocalArena;
use crate::gecko_bindings::bindings::{
Gecko_RegisterProfilerThread, Gecko_UnregisterProfilerThread,
};
use crate::parallel::STYLE_THREAD_STACK_SIZE_KB;
use crate::shared_lock::SharedRwLock;
use crate::thread_state;
use num_cpus;
use parallel::STYLE_THREAD_STACK_SIZE_KB;
use rayon;
use shared_lock::SharedRwLock;
use std::cmp;
use std::env;
use std::ffi::CString;
use thread_state;
/// Global style data
pub struct GlobalStyleData {

View file

@ -5,16 +5,16 @@
//! Gecko's media feature list and evaluator.
use app_units::Au;
use crate::gecko_bindings::bindings;
use crate::gecko_bindings::structs;
use crate::media_queries::media_feature::{AllowsRanges, ParsingRequirements};
use crate::media_queries::media_feature::{Evaluator, MediaFeatureDescription};
use crate::media_queries::media_feature_expression::{AspectRatio, RangeOrOperator};
use crate::media_queries::Device;
use crate::values::computed::CSSPixelLength;
use crate::values::computed::Resolution;
use crate::Atom;
use euclid::Size2D;
use gecko_bindings::bindings;
use gecko_bindings::structs;
use media_queries::media_feature::{AllowsRanges, ParsingRequirements};
use media_queries::media_feature::{Evaluator, MediaFeatureDescription};
use media_queries::media_feature_expression::{AspectRatio, RangeOrOperator};
use media_queries::Device;
use values::computed::CSSPixelLength;
use values::computed::Resolution;
use Atom;
fn viewport_size(device: &Device) -> Size2D<Au> {
let pc = device.pres_context();

View file

@ -6,24 +6,24 @@
use app_units::Au;
use app_units::AU_PER_PX;
use crate::custom_properties::CssEnvironment;
use crate::gecko::values::{convert_nscolor_to_rgba, convert_rgba_to_nscolor};
use crate::gecko_bindings::bindings;
use crate::gecko_bindings::structs;
use crate::gecko_bindings::structs::{nsPresContext, RawGeckoPresContextBorrowed};
use crate::media_queries::MediaType;
use crate::properties::ComputedValues;
use crate::string_cache::Atom;
use crate::values::computed::font::FontSize;
use crate::values::{CustomIdent, KeyframesName};
use cssparser::RGBA;
use custom_properties::CssEnvironment;
use euclid::Size2D;
use euclid::TypedScale;
use gecko::values::{convert_nscolor_to_rgba, convert_rgba_to_nscolor};
use gecko_bindings::bindings;
use gecko_bindings::structs;
use gecko_bindings::structs::{nsPresContext, RawGeckoPresContextBorrowed};
use media_queries::MediaType;
use properties::ComputedValues;
use servo_arc::Arc;
use std::fmt;
use std::sync::atomic::{AtomicBool, AtomicIsize, AtomicUsize, Ordering};
use string_cache::Atom;
use style_traits::viewport::ViewportConstraints;
use style_traits::{CSSPixel, DevicePixel};
use values::computed::font::FontSize;
use values::{CustomIdent, KeyframesName};
/// The `Device` in Gecko wraps a pres context, has a default values computed,
/// and contains all the viewport rule state.

View file

@ -8,16 +8,16 @@
//! `pseudo_element_definition.mako.rs`. If you touch that file, you probably
//! need to update the checked-in files for Servo.
use crate::gecko_bindings::structs::{self, CSSPseudoElementType};
use crate::properties::longhands::display::computed_value::T as Display;
use crate::properties::{ComputedValues, PropertyFlags};
use crate::selector_parser::{NonTSPseudoClass, PseudoElementCascadeType, SelectorImpl};
use crate::str::{starts_with_ignore_ascii_case, string_as_ascii_lowercase};
use crate::string_cache::Atom;
use crate::values::serialize_atom_identifier;
use cssparser::ToCss;
use gecko_bindings::structs::{self, CSSPseudoElementType};
use properties::longhands::display::computed_value::T as Display;
use properties::{ComputedValues, PropertyFlags};
use selector_parser::{NonTSPseudoClass, PseudoElementCascadeType, SelectorImpl};
use std::fmt;
use str::{starts_with_ignore_ascii_case, string_as_ascii_lowercase};
use string_cache::Atom;
use thin_slice::ThinBoxedSlice;
use values::serialize_atom_identifier;
include!(concat!(
env!("OUT_DIR"),

View file

@ -4,11 +4,11 @@
//! Gecko's restyle damage computation (aka change hints, aka `nsChangeHint`).
use gecko_bindings::bindings;
use gecko_bindings::structs;
use gecko_bindings::structs::nsChangeHint;
use matching::{StyleChange, StyleDifference};
use properties::ComputedValues;
use crate::gecko_bindings::bindings;
use crate::gecko_bindings::structs;
use crate::gecko_bindings::structs::nsChangeHint;
use crate::matching::{StyleChange, StyleDifference};
use crate::properties::ComputedValues;
use std::ops::{BitAnd, BitOr, BitOrAssign, Not};
/// The representation of Gecko's restyle damage is just a wrapper over

View file

@ -4,13 +4,13 @@
//! Bindings for CSS Rule objects
use counter_style::{self, CounterBound};
use gecko_bindings::structs::{self, nsCSSValue};
use gecko_bindings::sugar::ns_css_value::ToNsCssValue;
use crate::counter_style::{self, CounterBound};
use crate::gecko_bindings::structs::{self, nsCSSValue};
use crate::gecko_bindings::sugar::ns_css_value::ToNsCssValue;
impl<'a> ToNsCssValue for &'a counter_style::System {
fn convert(self, nscssvalue: &mut nsCSSValue) {
use counter_style::System::*;
use crate::counter_style::System::*;
match *self {
Cyclic => nscssvalue.set_enum(structs::NS_STYLE_COUNTER_SYSTEM_CYCLIC as i32),
Numeric => nscssvalue.set_enum(structs::NS_STYLE_COUNTER_SYSTEM_NUMERIC as i32),
@ -123,7 +123,7 @@ impl<'a> ToNsCssValue for &'a counter_style::AdditiveSymbols {
impl<'a> ToNsCssValue for &'a counter_style::SpeakAs {
fn convert(self, nscssvalue: &mut nsCSSValue) {
use counter_style::SpeakAs::*;
use crate::counter_style::SpeakAs::*;
match *self {
Auto => nscssvalue.set_auto(),
Bullets => nscssvalue.set_enum(structs::NS_STYLE_COUNTER_SPEAKAS_BULLETS as i32),

View file

@ -4,27 +4,29 @@
//! Gecko-specific bits for selector-parsing.
use crate::element_state::{DocumentState, ElementState};
use crate::gecko_bindings::structs;
use crate::gecko_bindings::structs::RawServoSelectorList;
use crate::gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI};
use crate::invalidation::element::document_state::InvalidationMatchingData;
use crate::selector_parser::{Direction, SelectorParser};
use crate::str::starts_with_ignore_ascii_case;
use crate::string_cache::{Atom, Namespace, WeakAtom, WeakNamespace};
use crate::values::serialize_atom_identifier;
use cssparser::{BasicParseError, BasicParseErrorKind, Parser};
use cssparser::{CowRcStr, SourceLocation, ToCss, Token};
use element_state::{DocumentState, ElementState};
use gecko_bindings::structs;
use gecko_bindings::structs::RawServoSelectorList;
use gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI};
use invalidation::element::document_state::InvalidationMatchingData;
use selector_parser::{Direction, SelectorParser};
use selectors::parser::{self as selector_parser, Selector};
use selectors::parser::{SelectorParseErrorKind, Visit};
use selectors::visitor::SelectorVisitor;
use selectors::SelectorList;
use std::fmt;
use str::starts_with_ignore_ascii_case;
use string_cache::{Atom, Namespace, WeakAtom, WeakNamespace};
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss as ToCss_};
use thin_slice::ThinBoxedSlice;
use values::serialize_atom_identifier;
pub use gecko::pseudo_element::{PseudoElement, EAGER_PSEUDOS, EAGER_PSEUDO_COUNT, PSEUDO_COUNT};
pub use gecko::snapshot::SnapshotMap;
pub use crate::gecko::pseudo_element::{
PseudoElement, EAGER_PSEUDOS, EAGER_PSEUDO_COUNT, PSEUDO_COUNT,
};
pub use crate::gecko::snapshot::SnapshotMap;
bitflags! {
// See NonTSPseudoClass::is_enabled_in()
@ -169,7 +171,7 @@ impl NonTSPseudoClass {
/// Returns whether the pseudo-class is enabled in content sheets.
fn is_enabled_in_content(&self) -> bool {
use gecko_bindings::structs::mozilla;
use crate::gecko_bindings::structs::mozilla;
match *self {
// For pseudo-classes with pref, the availability in content
// depends on the pref.

View file

@ -5,19 +5,19 @@
//! A gecko snapshot, that stores the element attributes and state before they
//! change in order to properly calculate restyle hints.
use dom::TElement;
use element_state::ElementState;
use gecko::snapshot_helpers;
use gecko::wrapper::{GeckoElement, NamespaceConstraintHelpers};
use gecko_bindings::bindings;
use gecko_bindings::structs::ServoElementSnapshot;
use gecko_bindings::structs::ServoElementSnapshotFlags as Flags;
use gecko_bindings::structs::ServoElementSnapshotTable;
use invalidation::element::element_wrapper::ElementSnapshot;
use crate::dom::TElement;
use crate::element_state::ElementState;
use crate::gecko::snapshot_helpers;
use crate::gecko::wrapper::{GeckoElement, NamespaceConstraintHelpers};
use crate::gecko_bindings::bindings;
use crate::gecko_bindings::structs::ServoElementSnapshot;
use crate::gecko_bindings::structs::ServoElementSnapshotFlags as Flags;
use crate::gecko_bindings::structs::ServoElementSnapshotTable;
use crate::invalidation::element::element_wrapper::ElementSnapshot;
use crate::string_cache::{Atom, Namespace};
use crate::WeakAtom;
use selectors::attr::{AttrSelectorOperation, AttrSelectorOperator};
use selectors::attr::{CaseSensitivity, NamespaceConstraint};
use string_cache::{Atom, Namespace};
use WeakAtom;
/// A snapshot of a Gecko element.
pub type GeckoElementSnapshot = ServoElementSnapshot;

View file

@ -4,11 +4,11 @@
//! Element an snapshot common logic.
use gecko_bindings::bindings;
use gecko_bindings::structs::{self, nsAtom};
use crate::gecko_bindings::bindings;
use crate::gecko_bindings::structs::{self, nsAtom};
use crate::string_cache::{Atom, WeakAtom};
use crate::CaseSensitivityExt;
use selectors::attr::CaseSensitivity;
use string_cache::{Atom, WeakAtom};
use CaseSensitivityExt;
/// A function that, given an element of type `T`, allows you to get a single
/// class or a class list.

View file

@ -4,10 +4,10 @@
//! Gecko-specific bits for the styling DOM traversal.
use context::{SharedStyleContext, StyleContext};
use dom::{TElement, TNode};
use gecko::wrapper::{GeckoElement, GeckoNode};
use traversal::{recalc_style_at, DomTraversal, PerLevelTraversalData};
use crate::context::{SharedStyleContext, StyleContext};
use crate::dom::{TElement, TNode};
use crate::gecko::wrapper::{GeckoElement, GeckoNode};
use crate::traversal::{recalc_style_at, DomTraversal, PerLevelTraversalData};
/// This is the simple struct that Gecko uses to encapsulate a DOM traversal for
/// styling.

View file

@ -4,21 +4,21 @@
//! Common handling for the specified value CSS url() values.
use crate::gecko_bindings::bindings;
use crate::gecko_bindings::structs::root::mozilla::css::URLValue;
use crate::gecko_bindings::structs::root::mozilla::CORSMode;
use crate::gecko_bindings::structs::root::nsStyleImageRequest;
use crate::gecko_bindings::sugar::ownership::{FFIArcHelpers, HasArcFFI};
use crate::gecko_bindings::sugar::refptr::RefPtr;
use crate::parser::{Parse, ParserContext};
use crate::stylesheets::UrlExtraData;
use crate::values::computed::{Context, ToComputedValue};
use cssparser::Parser;
use gecko_bindings::bindings;
use gecko_bindings::structs::root::mozilla::css::URLValue;
use gecko_bindings::structs::root::mozilla::CORSMode;
use gecko_bindings::structs::root::nsStyleImageRequest;
use gecko_bindings::sugar::ownership::{FFIArcHelpers, HasArcFFI};
use gecko_bindings::sugar::refptr::RefPtr;
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
use nsstring::nsCString;
use parser::{Parse, ParserContext};
use servo_arc::Arc;
use std::fmt::{self, Write};
use style_traits::{CssWriter, ParseError, ToCss};
use stylesheets::UrlExtraData;
use values::computed::{Context, ToComputedValue};
/// A CSS url() value for gecko.
#[css(function = "url")]
@ -132,12 +132,12 @@ impl SpecifiedUrl {
}
fn from_css_url(url: CssUrl) -> Self {
use gecko_bindings::structs::root::mozilla::CORSMode_CORS_NONE;
use crate::gecko_bindings::structs::root::mozilla::CORSMode_CORS_NONE;
Self::from_css_url_with_cors(url, CORSMode_CORS_NONE)
}
fn from_css_url_with_cors_anonymous(url: CssUrl) -> Self {
use gecko_bindings::structs::root::mozilla::CORSMode_CORS_ANONYMOUS;
use crate::gecko_bindings::structs::root::mozilla::CORSMode_CORS_ANONYMOUS;
Self::from_css_url_with_cors(url, CORSMode_CORS_ANONYMOUS)
}
}

View file

@ -7,30 +7,32 @@
//! Different kind of helpers to interact with Gecko values.
use app_units::Au;
use counter_style::{Symbol, Symbols};
use crate::counter_style::{Symbol, Symbols};
use crate::gecko_bindings::structs::{self, nsStyleCoord, CounterStylePtr};
use crate::gecko_bindings::structs::{StyleGridTrackBreadth, StyleShapeRadius};
use crate::gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataValue};
use crate::media_queries::Device;
use crate::values::computed::basic_shape::ShapeRadius as ComputedShapeRadius;
use crate::values::computed::FlexBasis as ComputedFlexBasis;
use crate::values::computed::{Angle, ExtremumLength, Length, LengthOrPercentage};
use crate::values::computed::{LengthOrPercentageOrAuto, Percentage};
use crate::values::computed::{LengthOrPercentageOrNone, Number, NumberOrPercentage};
use crate::values::computed::{MaxLength as ComputedMaxLength, MozLength as ComputedMozLength};
use crate::values::computed::{
NonNegativeLength, NonNegativeLengthOrPercentage, NonNegativeNumber,
};
use crate::values::generics::basic_shape::ShapeRadius;
use crate::values::generics::box_::Perspective;
use crate::values::generics::flex::FlexBasis;
use crate::values::generics::gecko::ScrollSnapPoint;
use crate::values::generics::grid::{TrackBreadth, TrackKeyword};
use crate::values::generics::length::{MaxLength, MozLength};
use crate::values::generics::{CounterStyleOrNone, NonNegative};
use crate::values::{Auto, Either, None_, Normal};
use crate::Atom;
use cssparser::RGBA;
use gecko_bindings::structs::{self, nsStyleCoord, CounterStylePtr};
use gecko_bindings::structs::{StyleGridTrackBreadth, StyleShapeRadius};
use gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataValue};
use media_queries::Device;
use nsstring::{nsACString, nsCStr};
use std::cmp::max;
use values::computed::basic_shape::ShapeRadius as ComputedShapeRadius;
use values::computed::FlexBasis as ComputedFlexBasis;
use values::computed::{Angle, ExtremumLength, Length, LengthOrPercentage};
use values::computed::{LengthOrPercentageOrAuto, Percentage};
use values::computed::{LengthOrPercentageOrNone, Number, NumberOrPercentage};
use values::computed::{MaxLength as ComputedMaxLength, MozLength as ComputedMozLength};
use values::computed::{NonNegativeLength, NonNegativeLengthOrPercentage, NonNegativeNumber};
use values::generics::basic_shape::ShapeRadius;
use values::generics::box_::Perspective;
use values::generics::flex::FlexBasis;
use values::generics::gecko::ScrollSnapPoint;
use values::generics::grid::{TrackBreadth, TrackKeyword};
use values::generics::length::{MaxLength, MozLength};
use values::generics::{CounterStyleOrNone, NonNegative};
use values::{Auto, Either, None_, Normal};
use Atom;
/// A trait that defines an interface to convert from and to `nsStyleCoord`s.
pub trait GeckoStyleCoordConvertible: Sized {
@ -377,8 +379,12 @@ impl GeckoStyleCoordConvertible for Normal {
impl GeckoStyleCoordConvertible for ExtremumLength {
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
use gecko_bindings::structs::{NS_STYLE_WIDTH_AVAILABLE, NS_STYLE_WIDTH_FIT_CONTENT};
use gecko_bindings::structs::{NS_STYLE_WIDTH_MAX_CONTENT, NS_STYLE_WIDTH_MIN_CONTENT};
use crate::gecko_bindings::structs::{
NS_STYLE_WIDTH_AVAILABLE, NS_STYLE_WIDTH_FIT_CONTENT,
};
use crate::gecko_bindings::structs::{
NS_STYLE_WIDTH_MAX_CONTENT, NS_STYLE_WIDTH_MIN_CONTENT,
};
coord.set_value(CoordDataValue::Enumerated(match *self {
ExtremumLength::MozMaxContent => NS_STYLE_WIDTH_MAX_CONTENT,
ExtremumLength::MozMinContent => NS_STYLE_WIDTH_MIN_CONTENT,
@ -388,8 +394,12 @@ impl GeckoStyleCoordConvertible for ExtremumLength {
}
fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
use gecko_bindings::structs::{NS_STYLE_WIDTH_AVAILABLE, NS_STYLE_WIDTH_FIT_CONTENT};
use gecko_bindings::structs::{NS_STYLE_WIDTH_MAX_CONTENT, NS_STYLE_WIDTH_MIN_CONTENT};
use crate::gecko_bindings::structs::{
NS_STYLE_WIDTH_AVAILABLE, NS_STYLE_WIDTH_FIT_CONTENT,
};
use crate::gecko_bindings::structs::{
NS_STYLE_WIDTH_MAX_CONTENT, NS_STYLE_WIDTH_MIN_CONTENT,
};
match coord.as_value() {
CoordDataValue::Enumerated(NS_STYLE_WIDTH_MAX_CONTENT) => {
Some(ExtremumLength::MozMaxContent)
@ -451,8 +461,8 @@ impl GeckoStyleCoordConvertible for ScrollSnapPoint<LengthOrPercentage> {
}
fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
use gecko_bindings::structs::root::nsStyleUnit;
use values::generics::gecko::ScrollSnapPoint;
use crate::gecko_bindings::structs::root::nsStyleUnit;
use crate::values::generics::gecko::ScrollSnapPoint;
Some(match coord.unit() {
nsStyleUnit::eStyleUnit_None => ScrollSnapPoint::None,
@ -476,7 +486,7 @@ where
}
fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
use gecko_bindings::structs::root::nsStyleUnit;
use crate::gecko_bindings::structs::root::nsStyleUnit;
if coord.unit() == nsStyleUnit::eStyleUnit_None {
return Some(Perspective::None);
@ -521,8 +531,8 @@ pub fn round_border_to_device_pixels(width: Au, au_per_device_px: Au) -> Au {
impl CounterStyleOrNone {
/// Convert this counter style to a Gecko CounterStylePtr.
pub fn to_gecko_value(self, gecko_value: &mut CounterStylePtr, device: &Device) {
use gecko_bindings::bindings::Gecko_SetCounterStyleToName as set_name;
use gecko_bindings::bindings::Gecko_SetCounterStyleToSymbols as set_symbols;
use crate::gecko_bindings::bindings::Gecko_SetCounterStyleToName as set_name;
use crate::gecko_bindings::bindings::Gecko_SetCounterStyleToSymbols as set_symbols;
let pres_context = device.pres_context();
match self {
CounterStyleOrNone::None => unsafe {
@ -558,9 +568,9 @@ impl CounterStyleOrNone {
/// Convert Gecko CounterStylePtr to CounterStyleOrNone or String.
pub fn from_gecko_value(gecko_value: &CounterStylePtr) -> Either<Self, String> {
use gecko_bindings::bindings;
use values::generics::SymbolsType;
use values::CustomIdent;
use crate::gecko_bindings::bindings;
use crate::values::generics::SymbolsType;
use crate::values::CustomIdent;
let name = unsafe { bindings::Gecko_CounterStyle_GetName(gecko_value) };
if !name.is_null() {

View file

@ -15,59 +15,63 @@
//! the separation between the style system implementation and everything else.
use app_units::Au;
use applicable_declarations::ApplicableDeclarationBlock;
use atomic_refcell::{AtomicRefCell, AtomicRefMut};
use author_styles::AuthorStyles;
use context::{PostAnimationTasks, QuirksMode, SharedStyleContext, UpdateAnimationsTasks};
use data::ElementData;
use dom::{LayoutIterator, NodeInfo, OpaqueNode, TDocument, TElement, TNode, TShadowRoot};
use element_state::{DocumentState, ElementState};
use font_metrics::{FontMetrics, FontMetricsProvider, FontMetricsQueryResult};
use gecko::data::GeckoStyleSheet;
use gecko::global_style_data::GLOBAL_STYLE_DATA;
use gecko::selector_parser::{NonTSPseudoClass, PseudoElement, SelectorImpl};
use gecko::snapshot_helpers;
use gecko_bindings::bindings;
use gecko_bindings::bindings::Gecko_ElementHasAnimations;
use gecko_bindings::bindings::Gecko_ElementHasCSSAnimations;
use gecko_bindings::bindings::Gecko_ElementHasCSSTransitions;
use gecko_bindings::bindings::Gecko_GetActiveLinkAttrDeclarationBlock;
use gecko_bindings::bindings::Gecko_GetAnimationEffectCount;
use gecko_bindings::bindings::Gecko_GetAnimationRule;
use gecko_bindings::bindings::Gecko_GetExtraContentStyleDeclarations;
use gecko_bindings::bindings::Gecko_GetHTMLPresentationAttrDeclarationBlock;
use gecko_bindings::bindings::Gecko_GetStyleAttrDeclarationBlock;
use gecko_bindings::bindings::Gecko_GetUnvisitedLinkAttrDeclarationBlock;
use gecko_bindings::bindings::Gecko_GetVisitedLinkAttrDeclarationBlock;
use gecko_bindings::bindings::Gecko_IsSignificantChild;
use gecko_bindings::bindings::Gecko_MatchLang;
use gecko_bindings::bindings::Gecko_UnsetDirtyStyleAttr;
use gecko_bindings::bindings::Gecko_UpdateAnimations;
use gecko_bindings::bindings::{Gecko_ElementState, Gecko_GetDocumentLWTheme};
use gecko_bindings::bindings::{Gecko_SetNodeFlags, Gecko_UnsetNodeFlags};
use gecko_bindings::structs;
use gecko_bindings::structs::nsChangeHint;
use gecko_bindings::structs::nsIDocument_DocumentTheme as DocumentTheme;
use gecko_bindings::structs::nsRestyleHint;
use gecko_bindings::structs::EffectCompositor_CascadeLevel as CascadeLevel;
use gecko_bindings::structs::ELEMENT_HANDLED_SNAPSHOT;
use gecko_bindings::structs::ELEMENT_HAS_ANIMATION_ONLY_DIRTY_DESCENDANTS_FOR_SERVO;
use gecko_bindings::structs::ELEMENT_HAS_DIRTY_DESCENDANTS_FOR_SERVO;
use gecko_bindings::structs::ELEMENT_HAS_SNAPSHOT;
use gecko_bindings::structs::NODE_DESCENDANTS_NEED_FRAMES;
use gecko_bindings::structs::NODE_NEEDS_FRAME;
use gecko_bindings::structs::{nsAtom, nsIContent, nsINode_BooleanFlag};
use gecko_bindings::structs::{RawGeckoElement, RawGeckoNode, RawGeckoXBLBinding};
use gecko_bindings::sugar::ownership::{HasArcFFI, HasSimpleFFI};
use hash::FxHashMap;
use logical_geometry::WritingMode;
use media_queries::Device;
use properties::animated_properties::{AnimationValue, AnimationValueMap};
use properties::style_structs::Font;
use properties::{ComputedValues, LonghandId};
use properties::{Importance, PropertyDeclaration, PropertyDeclarationBlock};
use rule_tree::CascadeLevel as ServoCascadeLevel;
use selector_parser::{AttrValue, HorizontalDirection, Lang};
use crate::applicable_declarations::ApplicableDeclarationBlock;
use crate::author_styles::AuthorStyles;
use crate::context::{PostAnimationTasks, QuirksMode, SharedStyleContext, UpdateAnimationsTasks};
use crate::data::ElementData;
use crate::dom::{LayoutIterator, NodeInfo, OpaqueNode, TDocument, TElement, TNode, TShadowRoot};
use crate::element_state::{DocumentState, ElementState};
use crate::font_metrics::{FontMetrics, FontMetricsProvider, FontMetricsQueryResult};
use crate::gecko::data::GeckoStyleSheet;
use crate::gecko::global_style_data::GLOBAL_STYLE_DATA;
use crate::gecko::selector_parser::{NonTSPseudoClass, PseudoElement, SelectorImpl};
use crate::gecko::snapshot_helpers;
use crate::gecko_bindings::bindings;
use crate::gecko_bindings::bindings::Gecko_ElementHasAnimations;
use crate::gecko_bindings::bindings::Gecko_ElementHasCSSAnimations;
use crate::gecko_bindings::bindings::Gecko_ElementHasCSSTransitions;
use crate::gecko_bindings::bindings::Gecko_GetActiveLinkAttrDeclarationBlock;
use crate::gecko_bindings::bindings::Gecko_GetAnimationEffectCount;
use crate::gecko_bindings::bindings::Gecko_GetAnimationRule;
use crate::gecko_bindings::bindings::Gecko_GetExtraContentStyleDeclarations;
use crate::gecko_bindings::bindings::Gecko_GetHTMLPresentationAttrDeclarationBlock;
use crate::gecko_bindings::bindings::Gecko_GetStyleAttrDeclarationBlock;
use crate::gecko_bindings::bindings::Gecko_GetUnvisitedLinkAttrDeclarationBlock;
use crate::gecko_bindings::bindings::Gecko_GetVisitedLinkAttrDeclarationBlock;
use crate::gecko_bindings::bindings::Gecko_IsSignificantChild;
use crate::gecko_bindings::bindings::Gecko_MatchLang;
use crate::gecko_bindings::bindings::Gecko_UnsetDirtyStyleAttr;
use crate::gecko_bindings::bindings::Gecko_UpdateAnimations;
use crate::gecko_bindings::bindings::{Gecko_ElementState, Gecko_GetDocumentLWTheme};
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::nsIDocument_DocumentTheme as DocumentTheme;
use crate::gecko_bindings::structs::nsRestyleHint;
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;
use crate::gecko_bindings::structs::ELEMENT_HAS_DIRTY_DESCENDANTS_FOR_SERVO;
use crate::gecko_bindings::structs::ELEMENT_HAS_SNAPSHOT;
use crate::gecko_bindings::structs::NODE_DESCENDANTS_NEED_FRAMES;
use crate::gecko_bindings::structs::NODE_NEEDS_FRAME;
use crate::gecko_bindings::structs::{nsAtom, nsIContent, nsINode_BooleanFlag};
use crate::gecko_bindings::structs::{RawGeckoElement, RawGeckoNode, RawGeckoXBLBinding};
use crate::gecko_bindings::sugar::ownership::{HasArcFFI, HasSimpleFFI};
use crate::hash::FxHashMap;
use crate::logical_geometry::WritingMode;
use crate::media_queries::Device;
use crate::properties::animated_properties::{AnimationValue, AnimationValueMap};
use crate::properties::style_structs::Font;
use crate::properties::{ComputedValues, LonghandId};
use crate::properties::{Importance, PropertyDeclaration, PropertyDeclarationBlock};
use crate::rule_tree::CascadeLevel as ServoCascadeLevel;
use crate::selector_parser::{AttrValue, HorizontalDirection, Lang};
use crate::shared_lock::Locked;
use crate::string_cache::{Atom, Namespace, WeakAtom, WeakNamespace};
use crate::stylist::CascadeData;
use crate::CaseSensitivityExt;
use selectors::attr::{AttrSelectorOperation, AttrSelectorOperator};
use selectors::attr::{CaseSensitivity, NamespaceConstraint};
use selectors::matching::VisitedHandlingMode;
@ -75,15 +79,11 @@ use selectors::matching::{ElementSelectorFlags, MatchingContext};
use selectors::sink::Push;
use selectors::{Element, OpaqueElement};
use servo_arc::{Arc, ArcBorrow, RawOffsetArc};
use shared_lock::Locked;
use std::cell::RefCell;
use std::fmt;
use std::hash::{Hash, Hasher};
use std::mem;
use std::ptr;
use string_cache::{Atom, Namespace, WeakAtom, WeakNamespace};
use stylist::CascadeData;
use CaseSensitivityExt;
#[inline]
fn elements_with_id<'a, 'le>(
@ -287,7 +287,7 @@ impl<'ln> GeckoNode<'ln> {
/// This logic is duplicate in Gecko's nsINode::IsInShadowTree().
#[inline]
fn is_in_shadow_tree(&self) -> bool {
use gecko_bindings::structs::NODE_IS_IN_SHADOW_TREE;
use crate::gecko_bindings::structs::NODE_IS_IN_SHADOW_TREE;
self.flags() & (NODE_IS_IN_SHADOW_TREE as u32) != 0
}
@ -295,7 +295,7 @@ impl<'ln> GeckoNode<'ln> {
/// Make sure to mirror any modifications in both places.
#[inline]
fn flattened_tree_parent_is_parent(&self) -> bool {
use gecko_bindings::structs::*;
use crate::gecko_bindings::structs::*;
let flags = self.flags();
if flags & (NODE_MAY_BE_IN_BINDING_MNGR as u32 | NODE_IS_IN_SHADOW_TREE as u32) != 0 {
return false;
@ -767,7 +767,7 @@ impl<'le> GeckoElement<'le> {
#[inline]
fn has_properties(&self) -> bool {
use gecko_bindings::structs::NODE_HAS_PROPERTIES;
use crate::gecko_bindings::structs::NODE_HAS_PROPERTIES;
(self.flags() & NODE_HAS_PROPERTIES as u32) != 0
}
@ -805,8 +805,8 @@ impl<'le> GeckoElement<'le> {
restyle_hint: nsRestyleHint,
change_hint: nsChangeHint,
) {
use gecko::restyle_damage::GeckoRestyleDamage;
use invalidation::element::restyle_hints::RestyleHint;
use crate::gecko::restyle_damage::GeckoRestyleDamage;
use crate::invalidation::element::restyle_hints::RestyleHint;
let damage = GeckoRestyleDamage::new(change_hint);
debug!(
@ -844,14 +844,14 @@ impl<'le> GeckoElement<'le> {
/// This logic is duplicated in Gecko's nsIContent::IsRootOfAnonymousSubtree.
#[inline]
fn is_root_of_anonymous_subtree(&self) -> bool {
use gecko_bindings::structs::NODE_IS_ANONYMOUS_ROOT;
use crate::gecko_bindings::structs::NODE_IS_ANONYMOUS_ROOT;
self.flags() & (NODE_IS_ANONYMOUS_ROOT as u32) != 0
}
/// This logic is duplicated in Gecko's nsIContent::IsRootOfNativeAnonymousSubtree.
#[inline]
fn is_root_of_native_anonymous_subtree(&self) -> bool {
use gecko_bindings::structs::NODE_IS_NATIVE_ANONYMOUS_ROOT;
use crate::gecko_bindings::structs::NODE_IS_NATIVE_ANONYMOUS_ROOT;
return self.flags() & (NODE_IS_NATIVE_ANONYMOUS_ROOT as u32) != 0;
}
@ -883,8 +883,8 @@ impl<'le> GeckoElement<'le> {
}
fn css_transitions_info(&self) -> FxHashMap<LonghandId, Arc<AnimationValue>> {
use gecko_bindings::bindings::Gecko_ElementTransitions_EndValueAt;
use gecko_bindings::bindings::Gecko_ElementTransitions_Length;
use crate::gecko_bindings::bindings::Gecko_ElementTransitions_EndValueAt;
use crate::gecko_bindings::bindings::Gecko_ElementTransitions_Length;
let collection_length = unsafe { Gecko_ElementTransitions_Length(self.0) } as usize;
let mut map = FxHashMap::with_capacity_and_hasher(collection_length, Default::default());
@ -910,7 +910,7 @@ impl<'le> GeckoElement<'le> {
after_change_style: &ComputedValues,
existing_transitions: &FxHashMap<LonghandId, Arc<AnimationValue>>,
) -> bool {
use values::animated::{Animate, Procedure};
use crate::values::animated::{Animate, Procedure};
debug_assert!(!longhand_id.is_logical());
// If there is an existing transition, update only if the end value
@ -945,7 +945,7 @@ impl<'le> GeckoElement<'le> {
/// by Gecko. We could align these and then do this without conditionals, but
/// it's probably not worth the trouble.
fn selector_flags_to_node_flags(flags: ElementSelectorFlags) -> u32 {
use gecko_bindings::structs::*;
use crate::gecko_bindings::structs::*;
let mut gecko_flags = 0u32;
if flags.contains(ElementSelectorFlags::HAS_SLOW_SELECTOR) {
gecko_flags |= NODE_HAS_SLOW_SELECTOR as u32;
@ -967,8 +967,8 @@ fn get_animation_rule(
element: &GeckoElement,
cascade_level: CascadeLevel,
) -> Option<Arc<Locked<PropertyDeclarationBlock>>> {
use gecko_bindings::sugar::ownership::HasSimpleFFI;
use properties::longhands::ANIMATABLE_PROPERTY_COUNT;
use crate::gecko_bindings::sugar::ownership::HasSimpleFFI;
use crate::properties::longhands::ANIMATABLE_PROPERTY_COUNT;
// There's a very rough correlation between the number of effects
// (animations) on an element and the number of properties it is likely to
@ -1006,7 +1006,7 @@ pub struct GeckoFontMetricsProvider {
// This may be slow on pages using more languages, might be worth optimizing
// by caching lang->group mapping separately and/or using a hashmap on larger
// loads.
pub font_size_cache: RefCell<Vec<(Atom, ::gecko_bindings::structs::FontSizePrefs)>>,
pub font_size_cache: RefCell<Vec<(Atom, crate::gecko_bindings::structs::FontSizePrefs)>>,
}
impl GeckoFontMetricsProvider {
@ -1024,7 +1024,7 @@ impl FontMetricsProvider for GeckoFontMetricsProvider {
}
fn get_size(&self, font_name: &Atom, font_family: u8) -> Au {
use gecko_bindings::bindings::Gecko_GetBaseSize;
use crate::gecko_bindings::bindings::Gecko_GetBaseSize;
let mut cache = self.font_size_cache.borrow_mut();
if let Some(sizes) = cache.iter().find(|el| el.0 == *font_name) {
return sizes.1.size_for_generic(font_family);
@ -1042,7 +1042,7 @@ impl FontMetricsProvider for GeckoFontMetricsProvider {
in_media_query: bool,
device: &Device,
) -> FontMetricsQueryResult {
use gecko_bindings::bindings::Gecko_GetFontMetrics;
use crate::gecko_bindings::bindings::Gecko_GetFontMetrics;
let gecko_metrics = unsafe {
Gecko_GetFontMetrics(
device.pres_context(),
@ -1392,7 +1392,7 @@ impl<'le> TElement for GeckoElement<'le> {
/// This logic is duplicated in Gecko's nsINode::IsInNativeAnonymousSubtree.
#[inline]
fn is_in_native_anonymous_subtree(&self) -> bool {
use gecko_bindings::structs::NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE;
use crate::gecko_bindings::structs::NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE;
self.flags() & (NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE as u32) != 0
}
@ -1499,8 +1499,8 @@ impl<'le> TElement for GeckoElement<'le> {
/// Process various tasks that are a result of animation-only restyle.
fn process_post_animation(&self, tasks: PostAnimationTasks) {
use gecko_bindings::structs::nsChangeHint_nsChangeHint_Empty;
use gecko_bindings::structs::nsRestyleHint_eRestyle_Subtree;
use crate::gecko_bindings::structs::nsChangeHint_nsChangeHint_Empty;
use crate::gecko_bindings::structs::nsRestyleHint_eRestyle_Subtree;
debug_assert!(!tasks.is_empty(), "Should be involved a task");
@ -1638,9 +1638,9 @@ impl<'le> TElement for GeckoElement<'le> {
before_change_style: &ComputedValues,
after_change_style: &ComputedValues,
) -> bool {
use gecko_bindings::structs::nsCSSPropertyID;
use properties::LonghandIdSet;
use values::computed::TransitionProperty;
use crate::gecko_bindings::structs::nsCSSPropertyID;
use crate::properties::LonghandIdSet;
use crate::values::computed::TransitionProperty;
debug_assert!(
self.might_need_transitions_update(Some(before_change_style), after_change_style),
@ -1753,11 +1753,11 @@ impl<'le> TElement for GeckoElement<'le> {
) where
V: Push<ApplicableDeclarationBlock>,
{
use properties::longhands::_x_lang::SpecifiedValue as SpecifiedLang;
use properties::longhands::_x_text_zoom::SpecifiedValue as SpecifiedZoom;
use properties::longhands::color::SpecifiedValue as SpecifiedColor;
use properties::longhands::text_align::SpecifiedValue as SpecifiedTextAlign;
use values::specified::color::Color;
use crate::properties::longhands::_x_lang::SpecifiedValue as SpecifiedLang;
use crate::properties::longhands::_x_text_zoom::SpecifiedValue as SpecifiedZoom;
use crate::properties::longhands::color::SpecifiedValue as SpecifiedColor;
use crate::properties::longhands::text_align::SpecifiedValue as SpecifiedTextAlign;
use crate::values::specified::color::Color;
lazy_static! {
static ref TH_RULE: ApplicableDeclarationBlock = {
let global_style_data = &*GLOBAL_STYLE_DATA;