Skip to content

Commit

Permalink
Auto merge of #21036 - emilio:gecko-sync, r=emilio
Browse files Browse the repository at this point in the history
style: Sync changes from mozilla-central.

See each individual commit for details.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21036)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Jun 12, 2018
2 parents a76777b + 92c9cdf commit e64d6ea
Show file tree
Hide file tree
Showing 43 changed files with 931 additions and 714 deletions.
86 changes: 25 additions & 61 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions components/script/dom/cssstyledeclaration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ impl CSSStyleDeclaration {
self.owner.mutate_associated_block(|pdb, changed| {
if value.is_empty() {
// Step 3
*changed = pdb.remove_property(&id);
*changed = pdb.remove_property(&id, |_| {});
return Ok(());
}

Expand Down Expand Up @@ -365,7 +365,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
let mut string = String::new();
self.owner.mutate_associated_block(|pdb, changed| {
pdb.property_value_to_css(&id, &mut string).unwrap();
*changed = pdb.remove_property(&id);
*changed = pdb.remove_property(&id, |_| {});
});

// Step 6
Expand Down
25 changes: 18 additions & 7 deletions components/selectors/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ use std::slice;
/// (from left to right). Once the process is complete, callers should invoke
/// build(), which transforms the contents of the SelectorBuilder into a heap-
/// allocated Selector and leaves the builder in a drained state.
#[derive(Debug)]
pub struct SelectorBuilder<Impl: SelectorImpl> {
/// The entire sequence of simple selectors, from left to right, without combinators.
///
Expand Down Expand Up @@ -104,7 +105,7 @@ impl<Impl: SelectorImpl> SelectorBuilder<Impl> {
parsed_slotted: bool,
) -> ThinArc<SpecificityAndFlags, Component<Impl>> {
// Compute the specificity and flags.
let mut spec = SpecificityAndFlags(specificity(self.simple_selectors.iter()));
let mut spec = SpecificityAndFlags(specificity(&*self, self.simple_selectors.iter()));
if parsed_pseudo {
spec.0 |= HAS_PSEUDO_BIT;
}
Expand Down Expand Up @@ -268,25 +269,35 @@ impl From<Specificity> for u32 {
}
}

fn specificity<Impl>(iter: slice::Iter<Component<Impl>>) -> u32
fn specificity<Impl>(builder: &SelectorBuilder<Impl>, iter: slice::Iter<Component<Impl>>) -> u32
where
Impl: SelectorImpl,
{
complex_selector_specificity(iter).into()
complex_selector_specificity(builder, iter).into()
}

fn complex_selector_specificity<Impl>(mut iter: slice::Iter<Component<Impl>>) -> Specificity
fn complex_selector_specificity<Impl>(
builder: &SelectorBuilder<Impl>,
mut iter: slice::Iter<Component<Impl>>,
) -> Specificity
where
Impl: SelectorImpl,
{
fn simple_selector_specificity<Impl>(
builder: &SelectorBuilder<Impl>,
simple_selector: &Component<Impl>,
specificity: &mut Specificity,
) where
Impl: SelectorImpl,
{
match *simple_selector {
Component::Combinator(..) => unreachable!(),
Component::Combinator(ref combinator) => {
unreachable!(
"Found combinator {:?} in simple selectors vector? {:?}",
combinator,
builder,
);
}
// FIXME(emilio): Spec doesn't define any particular specificity for
// ::slotted(), so apply the general rule for pseudos per:
//
Expand Down Expand Up @@ -326,15 +337,15 @@ where
},
Component::Negation(ref negated) => {
for ss in negated.iter() {
simple_selector_specificity(&ss, specificity);
simple_selector_specificity(builder, &ss, specificity);
}
},
}
}

let mut specificity = Default::default();
for simple_selector in &mut iter {
simple_selector_specificity(&simple_selector, &mut specificity);
simple_selector_specificity(builder, &simple_selector, &mut specificity);
}
specificity
}
24 changes: 20 additions & 4 deletions components/selectors/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ macro_rules! with_all_bounds {
/// NB: We need Clone so that we can derive(Clone) on struct with that
/// are parameterized on SelectorImpl. See
/// <https://github.com/rust-lang/rust/issues/26925>
pub trait SelectorImpl: Clone + Sized + 'static {
pub trait SelectorImpl: Clone + Debug + Sized + 'static {
type ExtraMatchingData: Sized + Default + 'static;
type AttrValue: $($InSelector)*;
type Identifier: $($InSelector)*;
Expand Down Expand Up @@ -544,10 +544,26 @@ impl<Impl: SelectorImpl> Selector<Impl> {
}

/// Whether this selector is a featureless :host selector, with no
/// combinators to the left.
/// combinators to the left, and optionally has a pseudo-element to the
/// right.
#[inline]
pub fn is_featureless_host_selector(&self) -> bool {
self.iter().is_featureless_host_selector()
pub fn is_featureless_host_selector_or_pseudo_element(&self) -> bool {
let mut iter = self.iter();
if !self.has_pseudo_element() {
return iter.is_featureless_host_selector();
}

// Skip the pseudo-element.
for _ in &mut iter { }

match iter.next_sequence() {
None => return false,
Some(combinator) => {
debug_assert_eq!(combinator, Combinator::PseudoElement);
}
}

iter.is_featureless_host_selector()
}

/// Returns an iterator over this selector in matching order (right-to-left),
Expand Down
2 changes: 1 addition & 1 deletion components/style/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ serde = {version = "1.0", optional = true, features = ["derive"]}
servo_arc = { path = "../servo_arc" }
servo_atoms = {path = "../atoms", optional = true}
servo_config = {path = "../config", optional = true}
smallbitvec = "2.1.0"
smallbitvec = "2.1.1"
smallvec = "0.6"
string_cache = { version = "0.7", optional = true }
style_derive = {path = "../style_derive"}
Expand Down
6 changes: 4 additions & 2 deletions components/style/animation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use context::SharedStyleContext;
use dom::{OpaqueNode, TElement};
use font_metrics::FontMetricsProvider;
use properties::{self, CascadeFlags, ComputedValues, LonghandId};
use properties::animated_properties::{AnimatedProperty, TransitionProperty};
use properties::animated_properties::AnimatedProperty;
use properties::longhands::animation_direction::computed_value::single_value::T as AnimationDirection;
use properties::longhands::animation_play_state::computed_value::single_value::T as AnimationPlayState;
use rule_tree::CascadeLevel;
Expand All @@ -20,6 +20,7 @@ use std::sync::mpsc::Sender;
use stylesheets::keyframes_rule::{KeyframesAnimation, KeyframesStep, KeyframesStepValue};
use timer::Timer;
use values::computed::Time;
use values::computed::box_::TransitionProperty;
use values::computed::transform::TimingFunction;
use values::generics::box_::AnimationIterationCount;
use values::generics::transform::{StepPosition, TimingFunction as GenericTimingFunction};
Expand Down Expand Up @@ -303,7 +304,8 @@ impl PropertyAnimation {
let duration = box_style.transition_duration_mod(transition_index);

match transition_property {
TransitionProperty::Unsupported(_) => result,
TransitionProperty::Custom(..) |
TransitionProperty::Unsupported(..) => result,
TransitionProperty::Shorthand(ref shorthand_id) => shorthand_id
.longhands()
.filter_map(|longhand| {
Expand Down
2 changes: 1 addition & 1 deletion components/style/font_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ macro_rules! is_descriptor_enabled {
("font-variation-settings") => {
unsafe {
use gecko_bindings::structs::mozilla;
mozilla::StaticPrefs_sVarCache_layout_css_font_variations_enabled
mozilla::StaticPrefs_sVarCache_layout_css_font_variations_enabled != 0
}
};
($name:tt) => {
Expand Down
31 changes: 28 additions & 3 deletions components/style/gecko/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ use media_queries::Device;
use properties::{ComputedValues, LonghandId};
use properties::{Importance, PropertyDeclaration, PropertyDeclarationBlock};
use properties::animated_properties::{AnimationValue, AnimationValueMap};
use properties::animated_properties::TransitionProperty;
use properties::style_structs::Font;
use rule_tree::CascadeLevel as ServoCascadeLevel;
use selector_parser::{AttrValue, Direction, PseudoClassStringArg};
Expand Down Expand Up @@ -181,7 +180,6 @@ impl<'lr> TShadowRoot for GeckoShadowRoot<'lr> {

let author_styles = AuthorStyles::<GeckoStyleSheet>::from_ffi(author_styles);

debug_assert!(!author_styles.stylesheets.dirty());
debug_assert!(
author_styles.quirks_mode == self.as_node().owner_doc().quirks_mode() ||
author_styles.stylesheets.is_empty()
Expand Down Expand Up @@ -617,31 +615,37 @@ impl<'le> GeckoElement<'le> {
// GeckoNode is a raw reference.
//
// We can use a Cell<T>, but that's a bit of a pain.
#[inline]
fn set_flags(&self, flags: u32) {
unsafe { Gecko_SetNodeFlags(self.as_node().0, flags) }
}

#[inline]
unsafe fn unset_flags(&self, flags: u32) {
Gecko_UnsetNodeFlags(self.as_node().0, flags)
}

/// Returns true if this element has descendants for lazy frame construction.
#[inline]
pub fn descendants_need_frames(&self) -> bool {
self.flags() & (NODE_DESCENDANTS_NEED_FRAMES as u32) != 0
}

/// Returns true if this element needs lazy frame construction.
#[inline]
pub fn needs_frame(&self) -> bool {
self.flags() & (NODE_NEEDS_FRAME as u32) != 0
}

/// Returns a reference to the DOM slots for this Element, if they exist.
#[inline]
fn dom_slots(&self) -> Option<&structs::FragmentOrElement_nsDOMSlots> {
let slots = self.as_node().0.mSlots as *const structs::FragmentOrElement_nsDOMSlots;
unsafe { slots.as_ref() }
}

/// Returns a reference to the extended DOM slots for this Element.
#[inline]
fn extended_slots(&self) -> Option<&structs::FragmentOrElement_nsExtendedDOMSlots> {
self.dom_slots().and_then(|s| unsafe {
(s._base.mExtendedSlots.mPtr as *const structs::FragmentOrElement_nsExtendedDOMSlots)
Expand Down Expand Up @@ -699,6 +703,7 @@ impl<'le> GeckoElement<'le> {
}
}

#[inline]
fn non_xul_xbl_binding_parent_raw_content(&self) -> *mut nsIContent {
debug_assert!(!self.is_xul_element());
self.extended_slots()
Expand Down Expand Up @@ -1113,7 +1118,23 @@ impl<'le> TElement for GeckoElement<'le> {
assert_eq!(base as *const _, self.0 as *const _, "Bad cast");
}

let assigned_nodes: &[structs::RefPtr<structs::nsINode>] = &*slot.mAssignedNodes;
// FIXME(emilio): Workaround a bindgen bug on Android that causes
// mAssignedNodes to be at the wrong offset. See bug 1466406.
//
// Bug 1466580 tracks running the Android layout tests on automation.
//
// The actual bindgen bug still needs reduction.
let assigned_nodes: &[structs::RefPtr<structs::nsINode>] =
if !cfg!(target_os = "android") {
debug_assert_eq!(
unsafe { bindings::Gecko_GetAssignedNodes(self.0) },
&slot.mAssignedNodes as *const _,
);

&*slot.mAssignedNodes
} else {
unsafe { &**bindings::Gecko_GetAssignedNodes(self.0) }
};

debug_assert_eq!(
mem::size_of::<structs::RefPtr<structs::nsINode>>(),
Expand Down Expand Up @@ -1351,6 +1372,7 @@ impl<'le> TElement for GeckoElement<'le> {
!self.is_in_native_anonymous_subtree()
}

#[inline]
fn implemented_pseudo_element(&self) -> Option<PseudoElement> {
if !self.is_in_native_anonymous_subtree() {
return None;
Expand All @@ -1364,6 +1386,7 @@ impl<'le> TElement for GeckoElement<'le> {
PseudoElement::from_pseudo_type(pseudo_type)
}

#[inline]
fn store_children_to_process(&self, _: isize) {
// This is only used for bottom-up traversal, and is thus a no-op for Gecko.
}
Expand Down Expand Up @@ -1587,6 +1610,7 @@ impl<'le> TElement for GeckoElement<'le> {
) -> bool {
use gecko_bindings::structs::nsCSSPropertyID;
use properties::LonghandIdSet;
use values::computed::TransitionProperty;

debug_assert!(
self.might_need_transitions_update(Some(before_change_style), after_change_style),
Expand Down Expand Up @@ -1630,6 +1654,7 @@ impl<'le> TElement for GeckoElement<'le> {
};

match transition_property {
TransitionProperty::Custom(..) |
TransitionProperty::Unsupported(..) => {},
TransitionProperty::Shorthand(ref shorthand) => {
if shorthand.longhands().any(property_check_helper) {
Expand Down
1 change: 1 addition & 0 deletions components/style/gecko_bindings/sugar/ns_compatibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use context::QuirksMode;
use gecko_bindings::structs::nsCompatibility;

impl From<nsCompatibility> for QuirksMode {
#[inline]
fn from(mode: nsCompatibility) -> QuirksMode {
match mode {
nsCompatibility::eCompatibility_FullStandards => QuirksMode::NoQuirks,
Expand Down
Loading

0 comments on commit e64d6ea

Please sign in to comment.