Bug 1539326 - Fix servo build, and appease tidy checks.

This commit is contained in:
Emilio Cobos Álvarez 2019-03-27 02:28:54 +01:00
Родитель 32484d9bdf
Коммит 4a1b23092d
15 изменённых файлов: 155 добавлений и 78 удалений

Просмотреть файл

@ -294,7 +294,9 @@ mod bindings {
fn generate_structs() {
let builder = Builder::get_initial_builder()
.enable_cxx_namespaces()
.with_codegen_config(CodegenConfig::TYPES | CodegenConfig::VARS | CodegenConfig::FUNCTIONS);
.with_codegen_config(
CodegenConfig::TYPES | CodegenConfig::VARS | CodegenConfig::FUNCTIONS,
);
let mut fixups = vec![];
let builder = BuilderWithConfig::new(builder, CONFIG["structs"].as_table().unwrap())
.handle_common(&mut fixups)

Просмотреть файл

@ -9,25 +9,25 @@
#![allow(non_snake_case, missing_docs)]
use crate::gecko::url::CssUrlData;
use crate::gecko_bindings::structs::RawServoAnimationValue;
use crate::gecko_bindings::structs::RawServoCounterStyleRule;
use crate::gecko_bindings::structs::RawServoCssUrlData;
use crate::gecko_bindings::structs::RawServoDeclarationBlock;
use crate::gecko_bindings::structs::RawServoFontFaceRule;
use crate::gecko_bindings::structs::RawServoFontFeatureValuesRule;
use crate::gecko_bindings::structs::RawServoImportRule;
use crate::gecko_bindings::structs::RawServoKeyframe;
use crate::gecko_bindings::structs::RawServoKeyframesRule;
use crate::gecko_bindings::structs::RawServoMediaList;
use crate::gecko_bindings::structs::RawServoMediaRule;
use crate::gecko_bindings::structs::RawServoMozDocumentRule;
use crate::gecko_bindings::structs::RawServoNamespaceRule;
use crate::gecko_bindings::structs::RawServoPageRule;
use crate::gecko_bindings::structs::RawServoSupportsRule;
use crate::gecko_bindings::structs::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::structs::RawServoSupportsRule;
use crate::gecko_bindings::structs::ServoCssRules;
use crate::gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI, Strong};
use crate::media_queries::MediaList;
use crate::properties::animated_properties::AnimationValue;

Просмотреть файл

@ -1011,10 +1011,9 @@ impl<'a> From<&'a Matrix4x4Components> for Matrix3D {
impl From<Matrix3D> for Matrix4x4Components {
fn from(matrix: Matrix3D) -> Self {
[
matrix.m11, matrix.m12, matrix.m13, matrix.m14, matrix.m21,
matrix.m22, matrix.m23, matrix.m24, matrix.m31, matrix.m32,
matrix.m33, matrix.m34, matrix.m41, matrix.m42, matrix.m43,
matrix.m44,
matrix.m11, matrix.m12, matrix.m13, matrix.m14, matrix.m21, matrix.m22, matrix.m23,
matrix.m24, matrix.m31, matrix.m32, matrix.m33, matrix.m34, matrix.m41, matrix.m42,
matrix.m43, matrix.m44,
]
}
}

Просмотреть файл

@ -33,7 +33,10 @@ impl ::selectors::parser::PseudoElement for PseudoElement {
fn valid_after_slotted(&self) -> bool {
matches!(
*self,
PseudoElement::Before | PseudoElement::After | PseudoElement::Marker | PseudoElement::Placeholder
PseudoElement::Before |
PseudoElement::After |
PseudoElement::Marker |
PseudoElement::Placeholder
)
}
@ -109,6 +112,12 @@ impl PseudoElement {
*self == PseudoElement::After
}
/// Whether this pseudo-element is the ::marker pseudo.
#[inline]
pub fn is_marker(&self) -> bool {
*self == PseudoElement::Marker
}
/// Whether this pseudo-element is ::first-letter.
#[inline]
pub fn is_first_letter(&self) -> bool {

Просмотреть файл

@ -53,7 +53,9 @@ 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::{Element as RawGeckoElement, nsINode as RawGeckoNode, nsXBLBinding as RawGeckoXBLBinding};
use crate::gecko_bindings::structs::{
nsINode as RawGeckoNode, nsXBLBinding as RawGeckoXBLBinding, Element as RawGeckoElement,
};
use crate::gecko_bindings::sugar::ownership::{HasArcFFI, HasSimpleFFI};
use crate::global_style_data::GLOBAL_STYLE_DATA;
use crate::hash::FxHashMap;
@ -321,7 +323,11 @@ impl<'ln> GeckoNode<'ln> {
// `flattened_tree_parent`.
if self.flattened_tree_parent_is_parent() {
debug_assert_eq!(
unsafe { bindings::Gecko_GetFlattenedTreeParentNode(self.0).as_ref().map(GeckoNode) },
unsafe {
bindings::Gecko_GetFlattenedTreeParentNode(self.0)
.as_ref()
.map(GeckoNode)
},
self.parent_node(),
"Fast path stopped holding!"
);
@ -331,7 +337,11 @@ impl<'ln> GeckoNode<'ln> {
// NOTE(emilio): If this call is too expensive, we could manually
// inline more aggressively.
unsafe { bindings::Gecko_GetFlattenedTreeParentNode(self.0).as_ref().map(GeckoNode) }
unsafe {
bindings::Gecko_GetFlattenedTreeParentNode(self.0)
.as_ref()
.map(GeckoNode)
}
}
#[inline]
@ -381,7 +391,11 @@ impl<'ln> TNode for GeckoNode<'ln> {
#[inline]
fn prev_sibling(&self) -> Option<Self> {
unsafe { bindings::Gecko_GetPreviousSibling(self.0).as_ref().map(GeckoNode) }
unsafe {
bindings::Gecko_GetPreviousSibling(self.0)
.as_ref()
.map(GeckoNode)
}
}
#[inline]
@ -498,7 +512,9 @@ impl<'a> Iterator for GeckoChildrenIterator<'a> {
// however we can't express this easily with bindgen, and it would
// introduce functions with two input lifetimes into bindgen,
// which would be out of scope for elision.
bindings::Gecko_GetNextStyleChild(&mut *(it as *mut _)).as_ref().map(GeckoNode)
bindings::Gecko_GetNextStyleChild(&mut *(it as *mut _))
.as_ref()
.map(GeckoNode)
},
}
}
@ -705,7 +721,11 @@ impl<'le> GeckoElement<'le> {
// FIXME(heycam): Having trouble with bindgen on nsXULElement,
// where the binding parent is stored in a member variable
// rather than in slots. So just get it through FFI for now.
unsafe { bindings::Gecko_GetBindingParent(self.0).as_ref().map(GeckoElement) }
unsafe {
bindings::Gecko_GetBindingParent(self.0)
.as_ref()
.map(GeckoElement)
}
} else {
let binding_parent = unsafe { self.non_xul_xbl_binding_parent_raw_content().as_ref() }
.map(GeckoNode::from_content)
@ -713,7 +733,11 @@ impl<'le> GeckoElement<'le> {
debug_assert!(
binding_parent ==
unsafe { bindings::Gecko_GetBindingParent(self.0).as_ref().map(GeckoElement) }
unsafe {
bindings::Gecko_GetBindingParent(self.0)
.as_ref()
.map(GeckoElement)
}
);
binding_parent
}
@ -773,7 +797,11 @@ impl<'le> GeckoElement<'le> {
return None;
}
unsafe { bindings::Gecko_GetBeforeOrAfterPseudo(self.0, is_before).as_ref().map(GeckoElement) }
unsafe {
bindings::Gecko_GetBeforeOrAfterPseudo(self.0, is_before)
.as_ref()
.map(GeckoElement)
}
}
#[inline]
@ -795,11 +823,7 @@ impl<'le> GeckoElement<'le> {
/// animation.
///
/// Also this function schedules style flush.
pub unsafe fn note_explicit_hints(
&self,
restyle_hint: RestyleHint,
change_hint: nsChangeHint,
) {
pub unsafe fn note_explicit_hints(&self, restyle_hint: RestyleHint, change_hint: nsChangeHint) {
use crate::gecko::restyle_damage::GeckoRestyleDamage;
let damage = GeckoRestyleDamage::new(change_hint);
@ -1042,13 +1066,10 @@ impl FontMetricsProvider for GeckoFontMetricsProvider {
let style = context.style();
let (wm, font) = match base_size {
FontBaseSize::CurrentStyle => {
(style.writing_mode, style.get_font())
},
FontBaseSize::CurrentStyle => (style.writing_mode, style.get_font()),
// These are only used for font-size computation, and the first is
// really dubious...
FontBaseSize::InheritedStyleButStripEmUnits |
FontBaseSize::InheritedStyle => {
FontBaseSize::InheritedStyleButStripEmUnits | FontBaseSize::InheritedStyle => {
(*style.inherited_writing_mode(), style.get_parent_font())
},
};
@ -1142,7 +1163,11 @@ impl<'le> TElement for GeckoElement<'le> {
return None;
}
unsafe { bindings::Gecko_GetMarkerPseudo(self.0).as_ref().map(GeckoElement) }
unsafe {
bindings::Gecko_GetMarkerPseudo(self.0)
.as_ref()
.map(GeckoElement)
}
}
#[inline]
@ -1555,10 +1580,12 @@ impl<'le> TElement for GeckoElement<'le> {
// should destroy all CSS animations in display:none subtree.
let computed_data = self.borrow_data();
let computed_values = computed_data.as_ref().map(|d| d.styles.primary());
let before_change_values =
before_change_style.as_ref().map_or(ptr::null(), |x| x.as_gecko_computed_style());
let computed_values_opt =
computed_values.as_ref().map_or(ptr::null(), |x| x.as_gecko_computed_style());
let before_change_values = before_change_style
.as_ref()
.map_or(ptr::null(), |x| x.as_gecko_computed_style());
let computed_values_opt = computed_values
.as_ref()
.map_or(ptr::null(), |x| x.as_gecko_computed_style());
unsafe {
Gecko_UpdateAnimations(
self.0,
@ -1834,7 +1861,8 @@ impl<'le> TElement for GeckoElement<'le> {
hints.push(SVG_TEXT_DISABLE_ZOOM_RULE.clone());
}
}
let declarations = unsafe { Gecko_GetHTMLPresentationAttrDeclarationBlock(self.0).as_ref() };
let declarations =
unsafe { Gecko_GetHTMLPresentationAttrDeclarationBlock(self.0).as_ref() };
let declarations: Option<&RawOffsetArc<Locked<PropertyDeclarationBlock>>> =
declarations.and_then(|s| s.as_arc_opt());
if let Some(decl) = declarations {
@ -1884,7 +1912,8 @@ impl<'le> TElement for GeckoElement<'le> {
.state()
.intersects(NonTSPseudoClass::Active.state_flag());
if active {
let declarations = unsafe { Gecko_GetActiveLinkAttrDeclarationBlock(self.0).as_ref() };
let declarations =
unsafe { Gecko_GetActiveLinkAttrDeclarationBlock(self.0).as_ref() };
let declarations: Option<&RawOffsetArc<Locked<PropertyDeclarationBlock>>> =
declarations.and_then(|s| s.as_arc_opt());
if let Some(decl) = declarations {

Просмотреть файл

@ -41,4 +41,5 @@ ${helpers.predefined_type(
animation_value_type="discrete",
spec="https://drafts.csswg.org/css-lists-3/#propdef-counter-set",
servo_restyle_damage="rebuild_and_reflow",
products="gecko",
)}

Просмотреть файл

@ -2759,7 +2759,7 @@ pub struct ComputedValuesInner {
pub writing_mode: WritingMode,
/// A set of flags we use to store misc information regarding this style.
flags: ComputedValueFlags,
pub flags: ComputedValueFlags,
/// The rule node representing the ordered list of rules matched for this
/// node. Can be None for default values and text nodes. This is
@ -3719,8 +3719,8 @@ mod lazy_static_module {
use super::{ComputedValues, ComputedValuesInner, longhands, style_structs};
use super::computed_value_flags::ComputedValueFlags;
/// The initial values for all style structs as defined by the specification.
lazy_static! {
/// The initial values for all style structs as defined by the specification.
pub static ref INITIAL_SERVO_VALUES: ComputedValues = ComputedValues {
inner: ComputedValuesInner {
% for style_struct in data.active_style_structs():
@ -3744,7 +3744,7 @@ mod lazy_static_module {
writing_mode: WritingMode::empty(),
rules: None,
visited_style: None,
flags: Cell::new(ComputedValueFlags::empty()),
flags: ComputedValueFlags::empty(),
}
};
}

Просмотреть файл

@ -142,6 +142,12 @@ impl PseudoElement {
false
}
/// Whether this pseudo-element is the ::marker pseudo.
#[inline]
pub fn is_marker(&self) -> bool {
false
}
/// Whether this pseudo-element is the ::before pseudo.
#[inline]
pub fn is_before(&self) -> bool {

Просмотреть файл

@ -180,7 +180,6 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
where
E: TElement,
{
use crate::selector_parser::PseudoElement;
use crate::computed_values::list_style_position::T as ListStylePosition;
let mut blockify = false;
@ -205,8 +204,11 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
blockify_if!(self.style.floated());
blockify_if!(self.style.out_of_flow_positioned());
blockify_if!(self.style.pseudo == Some(&PseudoElement::Marker) &&
self.style.get_parent_list().clone_list_style_position() == ListStylePosition::Outside);
blockify_if!(
self.style.pseudo.map_or(false, |p| p.is_marker()) &&
self.style.get_parent_list().clone_list_style_position() ==
ListStylePosition::Outside
);
if !blockify {
return;
@ -232,11 +234,13 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
.clone_text_decoration_line()
.is_empty()
{
self.style.add_flags(ComputedValueFlags::HAS_TEXT_DECORATION_LINES);
self.style
.add_flags(ComputedValueFlags::HAS_TEXT_DECORATION_LINES);
}
if self.style.is_pseudo_element() {
self.style.add_flags(ComputedValueFlags::IS_IN_PSEUDO_ELEMENT_SUBTREE);
self.style
.add_flags(ComputedValueFlags::IS_IN_PSEUDO_ELEMENT_SUBTREE);
}
#[cfg(feature = "servo")]
@ -302,7 +306,8 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
.get_parent_flags()
.contains(ComputedValueFlags::SHOULD_SUPPRESS_LINEBREAK)
{
self.style.add_flags(ComputedValueFlags::SHOULD_SUPPRESS_LINEBREAK);
self.style
.add_flags(ComputedValueFlags::SHOULD_SUPPRESS_LINEBREAK);
}
}
@ -588,7 +593,8 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
let self_display = self.style.get_box().clone_display();
// Check whether line break should be suppressed for this element.
if self.should_suppress_linebreak(layout_parent_style) {
self.style.add_flags(ComputedValueFlags::SHOULD_SUPPRESS_LINEBREAK);
self.style
.add_flags(ComputedValueFlags::SHOULD_SUPPRESS_LINEBREAK);
// Inlinify the display type if allowed.
if !self.skip_item_display_fixup(element) {
let inline_display = self_display.inlinify();
@ -646,10 +652,12 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
}
if element.unwrap().is_visited_link() {
self.style.add_flags(ComputedValueFlags::IS_RELEVANT_LINK_VISITED);
self.style
.add_flags(ComputedValueFlags::IS_RELEVANT_LINK_VISITED);
} else {
// Need to remove to handle unvisited link inside visited.
self.style.remove_flags(ComputedValueFlags::IS_RELEVANT_LINK_VISITED);
self.style
.remove_flags(ComputedValueFlags::IS_RELEVANT_LINK_VISITED);
}
}
@ -725,9 +733,9 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
E: TElement,
{
use crate::properties::longhands::counter_increment::computed_value::T as ComputedIncrement;
use crate::values::CustomIdent;
use crate::values::generics::counters::{CounterPair};
use crate::values::generics::counters::CounterPair;
use crate::values::specified::list::MozListReversed;
use crate::values::CustomIdent;
if self.style.get_box().clone_display() != Display::ListItem {
return;
@ -752,8 +760,13 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
name: CustomIdent(atom!("list-item")),
value: increment,
};
let increments = increments.iter().cloned().chain(std::iter::once(list_increment));
self.style.mutate_counters().set_counter_increment(ComputedIncrement::new(increments.collect()));
let increments = increments
.iter()
.cloned()
.chain(std::iter::once(list_increment));
self.style
.mutate_counters()
.set_counter_increment(ComputedIncrement::new(increments.collect()));
}
/// Adjusts the style to account for various fixups that don't fit naturally

Просмотреть файл

@ -190,9 +190,7 @@ impl FontFamily {
/// Get default font family as `serif` which is a generic font-family
pub fn serif() -> Self {
FontFamily {
families: FontFamilyList::new(Box::new([SingleFontFamily::Generic(
atom!("serif"),
)])),
families: FontFamilyList::new(Box::new([SingleFontFamily::Generic(atom!("serif"))])),
is_system_font: false,
}
}
@ -204,7 +202,9 @@ impl MallocSizeOf for FontFamily {
// SharedFontList objects are generally shared from the pointer
// stored in the specified value. So only count this if the
// SharedFontList is unshared.
unsafe { bindings::Gecko_SharedFontList_SizeOfIncludingThisIfUnshared(self.families.0.get()) }
unsafe {
bindings::Gecko_SharedFontList_SizeOfIncludingThisIfUnshared(self.families.0.get())
}
}
}

Просмотреть файл

@ -19,8 +19,8 @@ use std::fmt::{self, Write};
use style_traits::{CssWriter, ToCss};
pub use crate::values::specified::TextAlignKeyword as TextAlign;
pub use crate::values::specified::{TextEmphasisPosition, TextDecorationLine};
pub use crate::values::specified::{OverflowWrap, WordBreak};
pub use crate::values::specified::{TextDecorationLine, TextEmphasisPosition};
/// A computed value for the `initial-letter` property.
pub type InitialLetter = GenericInitialLetter<CSSFloat, CSSInteger>;

Просмотреть файл

@ -135,7 +135,9 @@ impl FontRelativeLength {
base_size: FontBaseSize,
orientation: FontMetricsOrientation,
) -> FontMetrics {
context.font_metrics_provider.query(context, base_size, orientation)
context
.font_metrics_provider
.query(context, base_size, orientation)
}
let reference_font_size = base_size.resolve(context);
@ -160,13 +162,12 @@ impl FontRelativeLength {
if context.for_non_inherited_property.is_some() {
context.rule_cache_conditions.borrow_mut().set_uncacheable();
}
context.builder.add_flags(ComputedValueFlags::DEPENDS_ON_FONT_METRICS);
context
.builder
.add_flags(ComputedValueFlags::DEPENDS_ON_FONT_METRICS);
// The x-height is an intrinsically horizontal metric.
let metrics = query_font_metrics(
context,
base_size,
FontMetricsOrientation::Horizontal
);
let metrics =
query_font_metrics(context, base_size, FontMetricsOrientation::Horizontal);
let reference_size = metrics.x_height.unwrap_or_else(|| {
// https://drafts.csswg.org/css-values/#ex
//
@ -182,7 +183,9 @@ impl FontRelativeLength {
if context.for_non_inherited_property.is_some() {
context.rule_cache_conditions.borrow_mut().set_uncacheable();
}
context.builder.add_flags(ComputedValueFlags::DEPENDS_ON_FONT_METRICS);
context
.builder
.add_flags(ComputedValueFlags::DEPENDS_ON_FONT_METRICS);
// https://drafts.csswg.org/css-values/#ch:
//
// Equal to the used advance measure of the “0” (ZERO,
@ -190,11 +193,8 @@ impl FontRelativeLength {
// measure of a glyph is its advance width or height,
// whichever is in the inline axis of the element.)
//
let metrics = query_font_metrics(
context,
base_size,
FontMetricsOrientation::MatchContext,
);
let metrics =
query_font_metrics(context, base_size, FontMetricsOrientation::MatchContext);
let reference_size = metrics.zero_advance_measure.unwrap_or_else(|| {
// https://drafts.csswg.org/css-values/#ch
//

Просмотреть файл

@ -125,7 +125,19 @@ impl Parse for Quotes {
}
/// Specified and computed `-moz-list-reversed` property (for UA sheets only).
#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss)]
#[derive(
Clone,
Copy,
Debug,
Eq,
Hash,
MallocSizeOf,
Parse,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToCss,
)]
#[repr(u8)]
pub enum MozListReversed {
/// the initial value

Просмотреть файл

@ -282,7 +282,6 @@ bitflags! {
}
}
impl Parse for TextDecorationLine {
/// none | [ underline || overline || line-through || blink ]
fn parse<'i, 't>(
@ -318,7 +317,7 @@ impl Parse for TextDecorationLine {
}
if result.contains(flag) {
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
}
result.insert(flag)
@ -341,6 +340,13 @@ impl ToCss for TextDecorationLine {
return dest.write_str("none");
}
#[cfg(feature = "gecko")]
{
if *self == TextDecorationLine::COLOR_OVERRIDE {
return Ok(());
}
}
let mut writer = SequenceWriter::new(dest, " ");
let mut any = false;
@ -358,7 +364,7 @@ impl ToCss for TextDecorationLine {
maybe_write!(LINE_THROUGH => "line-through");
maybe_write!(BLINK => "blink");
debug_assert!(any || *self == TextDecorationLine::COLOR_OVERRIDE);
debug_assert!(any);
Ok(())
}

Просмотреть файл

@ -151,7 +151,7 @@ fn derive_variant_fields_expr(
if let Some(condition) = attrs.contextual_skip_if {
expr = quote! {
if !#condition(#(#bindings),*) {
if !#condition(#(#bindings), *) {
#expr
}
}
@ -227,7 +227,7 @@ fn derive_single_field_expr(
if let Some(condition) = attrs.contextual_skip_if {
expr = quote! {
if !#condition(#(#bindings),*) {
if !#condition(#(#bindings), *) {
#expr
}
}