Skip to content

Commit

Permalink
Bug 1833229 - Move a bit declaration_block and cascade modules. r=boris
Browse files Browse the repository at this point in the history
So that they aren't imported via #[path]. This allows cargo to see them
even before building.

Differential Revision: https://phabricator.services.mozilla.com/D178105
  • Loading branch information
emilio committed May 15, 2023
1 parent ea61e2c commit 99a58c1
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 66 deletions.
15 changes: 1 addition & 14 deletions servo/components/style/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,7 @@ pub use style_traits::owned_str::OwnedStr;

use std::hash::{BuildHasher, Hash};

/// The CSS properties supported by the style system.
/// Generated from the properties.mako.rs template by build.rs
#[macro_use]
#[allow(unsafe_code)]
#[deny(missing_docs)]
pub mod properties {
include!(concat!(env!("OUT_DIR"), "/properties.rs"));
}
pub mod properties;

#[cfg(feature = "gecko")]
#[allow(unsafe_code)]
Expand All @@ -183,12 +176,6 @@ pub mod gecko;
#[allow(unsafe_code)]
pub mod servo;

#[cfg(feature = "gecko")]
#[allow(unsafe_code, missing_docs)]
pub mod gecko_properties {
include!(concat!(env!("OUT_DIR"), "/gecko_properties.rs"));
}

macro_rules! reexport_computed_values {
( $( { $name: ident } )+ ) => {
/// Types for [computed values][computed].
Expand Down
28 changes: 16 additions & 12 deletions servo/components/style/properties/cascade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,27 @@
use crate::applicable_declarations::CascadePriority;
use crate::color::AbsoluteColor;
use crate::computed_value_flags::ComputedValueFlags;
use crate::context::QuirksMode;
use crate::custom_properties::CustomPropertiesBuilder;
use crate::dom::TElement;
use crate::font_metrics::FontMetricsOrientation;
use crate::values::specified::length::FontBaseSize;
use crate::logical_geometry::WritingMode;
use crate::media_queries::Device;
use crate::properties::{
CSSWideKeyword, ComputedValueFlags, ComputedValues, DeclarationImportanceIterator, Importance,
LonghandId, LonghandIdSet, PropertyDeclaration, PropertyDeclarationId, PropertyFlags,
ShorthandsWithPropertyReferencesCache, StyleBuilder, CASCADE_PROPERTY,
use crate::properties::declaration_block::{DeclarationImportanceIterator, Importance};
use crate::properties::generated::{
CSSWideKeyword, ComputedValues, LonghandId, LonghandIdSet, PropertyDeclaration,
PropertyDeclarationId, PropertyFlags, ShorthandsWithPropertyReferencesCache, StyleBuilder,
CASCADE_PROPERTY,
};
use crate::rule_cache::{RuleCache, RuleCacheConditions};
use crate::rule_tree::{StrongRuleNode, CascadeLevel};
use crate::rule_tree::{CascadeLevel, StrongRuleNode};
use crate::selector_parser::PseudoElement;
use crate::shared_lock::StylesheetGuards;
use crate::style_adjuster::StyleAdjuster;
use crate::stylesheets::{Origin, layer_rule::LayerOrder};
use crate::stylesheets::container_rule::ContainerSizeQuery;
use crate::stylesheets::{layer_rule::LayerOrder, Origin};
use crate::values::specified::length::FontBaseSize;
use crate::values::{computed, specified};
use fxhash::FxHashMap;
use servo_arc::Arc;
Expand Down Expand Up @@ -595,7 +597,7 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
declaration.value.substitute_variables(
declaration.id,
self.context.builder.writing_mode,
self.context.builder.custom_properties.as_ref(),
self.context.builder.custom_properties(),
self.context.quirks_mode,
self.context.device(),
cache,
Expand Down Expand Up @@ -958,14 +960,16 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
};

let font = builder.mutate_font();
font.mFont.family.families.prioritize_first_generic_or_prepend(default_font_type);
font.mFont
.family
.families
.prioritize_first_generic_or_prepend(default_font_type);
}

/// Some keyword sizes depend on the font family and language.
#[cfg(feature = "gecko")]
fn recompute_keyword_font_size_if_needed(&mut self) {
use crate::values::computed::ToComputedValue;
use crate::values::specified;

if !self.seen.contains(LonghandId::XLang) && !self.seen.contains(LonghandId::FontFamily) {
return;
Expand Down Expand Up @@ -1077,7 +1081,7 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
return;
}

const SCALE_FACTOR_WHEN_INCREMENTING_MATH_DEPTH_BY_ONE : f32 = 0.71;
const SCALE_FACTOR_WHEN_INCREMENTING_MATH_DEPTH_BY_ONE: f32 = 0.71;

// Helper function that calculates the scale factor applied to font-size
// when math-depth goes from parent_math_depth to computed_math_depth.
Expand Down Expand Up @@ -1160,7 +1164,7 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
parent_font.mMathDepth as i32,
font.mMathDepth as i32,
font_metrics.script_percent_scale_down,
font_metrics.script_script_percent_scale_down
font_metrics.script_script_percent_scale_down,
)
};

Expand Down
8 changes: 7 additions & 1 deletion servo/components/style/properties/declaration_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@
#![deny(missing_docs)]

use super::*;
use super::generated::{
shorthands, AllShorthand, ComputedValues, LogicalGroupSet, LonghandIdSet,
NonCustomPropertyIdSet, PropertyDeclaration, PropertyDeclarationId, PropertyId, ShorthandId,
SourcePropertyDeclaration, SourcePropertyDeclarationDrain, SubpropertiesVec,
};
use crate::applicable_declarations::CascadePriority;
use crate::context::QuirksMode;
use crate::custom_properties::{self, CustomPropertiesBuilder};
use crate::error_reporting::{ContextualParseError, ParseErrorReporter};
use crate::media_queries::Device;
use crate::parser::ParserContext;
use crate::properties::animated_properties::{AnimationValue, AnimationValueMap};
use crate::rule_tree::CascadeLevel;
Expand All @@ -26,6 +31,7 @@ use cssparser::{
};
use itertools::Itertools;
use selectors::SelectorList;
use servo_arc::Arc;
use smallbitvec::{self, SmallBitVec};
use smallvec::SmallVec;
use std::fmt::{self, Write};
Expand Down
27 changes: 27 additions & 0 deletions servo/components/style/properties/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* 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/. */

//! Supported CSS properties and the cascade.
pub mod declaration_block;
pub mod cascade;

/// The CSS properties supported by the style system.
/// Generated from the properties.mako.rs template by build.rs
#[macro_use]
#[allow(unsafe_code)]
#[deny(missing_docs)]
pub mod generated {
include!(concat!(env!("OUT_DIR"), "/properties.rs"));

#[cfg(feature = "gecko")]
#[allow(unsafe_code, missing_docs)]
pub mod gecko {
include!(concat!(env!("OUT_DIR"), "/gecko_properties.rs"));
}
}

pub use self::cascade::*;
pub use self::declaration_block::*;
pub use self::generated::*;
Loading

0 comments on commit 99a58c1

Please sign in to comment.