Skip to content
Permalink
Browse files

Auto merge of #24404 - emilio:gecko-sync, r=emilio

style: Sync changes from mozilla-central.

See individual commits for details.

https://bugzilla.mozilla.org/show_bug.cgi?id=1587368

<!-- 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/24404)
<!-- Reviewable:end -->
  • Loading branch information...
bors-servo committed Oct 10, 2019
2 parents dd1c183 + f5c07fe commit 2c280ab6acbd51791a8cbdbd4f7feccb049ce323
Showing with 560 additions and 743 deletions.
  1. +8 −0 components/hashglobe/src/hash_set.rs
  2. +1 −0 components/style/Cargo.toml
  3. +4 −3 components/style/gecko/conversions.rs
  4. +31 −3 components/style/gecko/wrapper.rs
  5. +18 −9 components/style/invalidation/stylesheets.rs
  6. +25 −10 components/style/logical_geometry.rs
  7. +1 −1 components/style/media_queries/media_feature_expression.rs
  8. +11 −0 components/style/properties/cascade.rs
  9. +2 −2 components/style/properties/counted_unknown_properties.py
  10. +13 −8 components/style/properties/helpers/animated_properties.mako.rs
  11. +3 −3 components/style/properties/longhands/border.mako.rs
  12. +1 −0 components/style/properties/longhands/position.mako.rs
  13. +3 −15 components/style/properties/properties.mako.rs
  14. +76 −0 components/style/properties/shorthands/box.mako.rs
  15. +1 −1 components/style/properties/shorthands/font.mako.rs
  16. +0 −3 components/style/values/animated/length.rs
  17. +14 −9 components/style/values/computed/image.rs
  18. +22 −45 components/style/values/computed/length.rs
  19. +10 −1 components/style/values/computed/mod.rs
  20. +3 −4 components/style/values/computed/motion.rs
  21. +15 −2 components/style/values/generics/border.rs
  22. +4 −5 components/style/values/generics/grid.rs
  23. +35 −14 components/style/values/generics/image.rs
  24. +1 −0 components/style/values/generics/mod.rs
  25. +110 −0 components/style/values/generics/motion.rs
  26. +1 −0 components/style/values/generics/rect.rs
  27. +0 −18 components/style/values/specified/border.rs
  28. +18 −0 components/style/values/specified/box.rs
  29. +33 −19 components/style/values/specified/image.rs
  30. +2 −2 components/style/values/specified/length.rs
  31. +3 −1 components/style/values/specified/mod.rs
  32. +61 −36 components/style/values/specified/motion.rs
  33. +1 −6 components/style/values/specified/position.rs
  34. +29 −5 tests/unit/style/logical_geometry.rs
  35. +0 −10 tests/wpt/metadata/css/css-backgrounds/parsing/background-image-computed.sub.html.ini
  36. +0 −19 tests/wpt/metadata/css/css-backgrounds/parsing/background-image-invalid.html.ini
  37. +0 −4 tests/wpt/metadata/css/css-backgrounds/parsing/border-image-width-computed.html.ini
  38. +0 −481 tests/wpt/metadata/css/css-fonts/parsing/font-valid.html.ini
  39. +0 −4 tests/wpt/metadata/css/cssom/font-shorthand-serialization.html.ini
@@ -17,6 +17,8 @@ use std::ops::{BitAnd, BitOr, BitXor, Sub};
use super::hash_map::{self, HashMap, Keys, RandomState};
use super::Recover;

use crate::FailedAllocationError;

// Future Optimization (FIXME!)
// =============================
//
@@ -589,6 +591,12 @@ where
self.map.insert(value, ()).is_none()
}

/// Fallible version of `insert`.
#[inline]
pub fn try_insert(&mut self, value: T) -> Result<bool, FailedAllocationError> {
Ok(self.map.try_insert(value, ())?.is_none())
}

/// Adds a value to the set, replacing the existing value, if any, that is equal to the given
/// one. Returns the replaced value.
pub fn replace(&mut self, value: T) -> Option<T> {
@@ -25,6 +25,7 @@ servo-layout-2020 = []
gecko_debug = []
gecko_refcount_logging = []
gecko_profiler = []
moz_xbl = []

[dependencies]
app_units = "0.7"
@@ -187,10 +187,11 @@ pub mod basic_shape {

impl<'a> From<&'a StyleShapeSource> for OffsetPath {
fn from(other: &'a StyleShapeSource) -> Self {
use crate::values::generics::motion::GenericOffsetPath;
match other.mType {
StyleShapeSourceType::Path => {
OffsetPath::Path(other.to_svg_path().expect("Cannot convert to SVGPathData"))
},
StyleShapeSourceType::Path => GenericOffsetPath::Path(
other.to_svg_path().expect("Cannot convert to SVGPathData"),
),
StyleShapeSourceType::None => OffsetPath::none(),
StyleShapeSourceType::Shape |
StyleShapeSourceType::Box |
@@ -44,6 +44,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;
#[cfg(feature = "moz_xbl")]
use crate::gecko_bindings::structs::nsXBLBinding as RawGeckoXBLBinding;
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;
@@ -53,9 +55,7 @@ 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::{
nsINode as RawGeckoNode, nsXBLBinding as RawGeckoXBLBinding, Element as RawGeckoElement,
};
use crate::gecko_bindings::structs::{nsINode as RawGeckoNode, Element as RawGeckoElement};
use crate::gecko_bindings::sugar::ownership::{HasArcFFI, HasSimpleFFI};
use crate::global_style_data::GLOBAL_STYLE_DATA;
use crate::hash::FxHashMap;
@@ -86,6 +86,8 @@ use std::fmt;
use std::hash::{Hash, Hasher};
use std::mem;
use std::ptr;
#[cfg(not(feature = "moz_xbl"))]
use values::Impossible;

#[inline]
fn elements_with_id<'a, 'le>(
@@ -529,9 +531,11 @@ impl<'a> Iterator for GeckoChildrenIterator<'a> {
}

/// A Simple wrapper over a non-null Gecko `nsXBLBinding` pointer.
#[cfg(feature = "moz_xbl")]
#[derive(Clone, Copy)]
pub struct GeckoXBLBinding<'lb>(pub &'lb RawGeckoXBLBinding);

#[cfg(feature = "moz_xbl")]
impl<'lb> GeckoXBLBinding<'lb> {
#[inline]
fn base_binding(&self) -> Option<Self> {
@@ -556,6 +560,22 @@ impl<'lb> GeckoXBLBinding<'lb> {
}
}

/// A stub wraper for GeckoXBLBinding.
#[cfg(not(feature = "moz_xbl"))]
pub struct GeckoXBLBinding<'lb>(&'lb Impossible);

#[cfg(not(feature = "moz_xbl"))]
impl<'lb> GeckoXBLBinding<'lb> {
#[inline]
fn anon_content(&self) -> *const nsIContent {
match *self.0 {}
}

fn binding_with_content(&self) -> Option<Self> {
None
}
}

/// A simple wrapper over a non-null Gecko `Element` pointer.
#[derive(Clone, Copy)]
pub struct GeckoElement<'le>(pub &'le RawGeckoElement);
@@ -681,11 +701,13 @@ impl<'le> GeckoElement<'le> {
})
}

#[cfg(feature = "moz_xbl")]
#[inline]
fn may_be_in_binding_manager(&self) -> bool {
self.flags() & (structs::NODE_MAY_BE_IN_BINDING_MNGR as u32) != 0
}

#[cfg(feature = "moz_xbl")]
#[inline]
fn xbl_binding(&self) -> Option<GeckoXBLBinding<'le>> {
if !self.may_be_in_binding_manager() {
@@ -696,6 +718,12 @@ impl<'le> GeckoElement<'le> {
unsafe { slots.mXBLBinding.mRawPtr.as_ref().map(GeckoXBLBinding) }
}

#[cfg(not(feature = "moz_xbl"))]
#[inline]
fn xbl_binding(&self) -> Option<GeckoXBLBinding<'le>> {
None
}

#[inline]
fn xbl_binding_with_content(&self) -> Option<GeckoXBLBinding<'le>> {
self.xbl_binding().and_then(|b| b.binding_with_content())
@@ -8,6 +8,7 @@
#![deny(unsafe_code)]

use crate::dom::{TDocument, TElement, TNode};
use crate::hash::HashSet;
use crate::invalidation::element::element_wrapper::{ElementSnapshot, ElementWrapper};
use crate::invalidation::element::restyle_hints::RestyleHint;
use crate::media_queries::Device;
@@ -17,9 +18,12 @@ use crate::stylesheets::{CssRule, StylesheetInDocument};
use crate::Atom;
use crate::CaseSensitivityExt;
use crate::LocalName as SelectorLocalName;
use fxhash::FxHashSet;
use fxhash::FxHasher;
use selectors::attr::CaseSensitivity;
use selectors::parser::{Component, LocalName, Selector};
use std::hash::BuildHasherDefault;

type FxHashSet<K> = HashSet<K, BuildHasherDefault<FxHasher>>;

/// A style sheet invalidation represents a kind of element or subtree that may
/// need to be restyled. Whether it represents a whole subtree or just a single
@@ -400,16 +404,21 @@ impl StylesheetInvalidationSet {

if let Some(s) = subtree_invalidation {
debug!(" > Found subtree invalidation: {:?}", s);
self.invalid_scopes.insert(s);
} else if let Some(s) = element_invalidation {
if self.invalid_scopes.try_insert(s).is_ok() {
return;
}
}
if let Some(s) = element_invalidation {
debug!(" > Found element invalidation: {:?}", s);
self.invalid_elements.insert(s);
} else {
// The selector was of a form that we can't handle. Any element
// could match it, so let's just bail out.
debug!(" > Can't handle selector, marking fully invalid");
self.fully_invalid = true;
if self.invalid_elements.try_insert(s).is_ok() {
return;
}
}

// The selector was of a form that we can't handle. Any element could
// match it, so let's just bail out.
debug!(" > Can't handle selector or OOMd, marking fully invalid");
self.fully_invalid = true;
}

/// Collects invalidations for a given CSS rule.
@@ -50,24 +50,30 @@ bitflags!(
const LINE_INVERTED = 1 << 3;
/// direction is rtl.
const RTL = 1 << 4;
/// Horizontal text within a vertical writing mode is displayed sideways
/// All text within a vertical writing mode is displayed sideways
/// and runs top-to-bottom or bottom-to-top; set in these cases:
///
/// * writing-mode: vertical-rl; text-orientation: sideways;
/// * writing-mode: vertical-lr; text-orientation: sideways;
/// * writing-mode: sideways-rl;
/// * writing-mode: sideways-lr;
///
/// Never set without VERTICAL.
const SIDEWAYS = 1 << 5;
const VERTICAL_SIDEWAYS = 1 << 5;
/// Similar to VERTICAL_SIDEWAYS, but is set via text-orientation;
/// set in these cases:
///
/// * writing-mode: vertical-rl; text-orientation: sideways;
/// * writing-mode: vertical-lr; text-orientation: sideways;
///
/// Never set without VERTICAL.
const TEXT_SIDEWAYS = 1 << 6;
/// Horizontal text within a vertical writing mode is displayed with each
/// glyph upright; set in these cases:
///
/// * writing-mode: vertical-rl; text-orientation: upright;
/// * writing-mode: vertical-lr: text-orientation: upright;
///
/// Never set without VERTICAL.
const UPRIGHT = 1 << 6;
const UPRIGHT = 1 << 7;
}
);

@@ -112,7 +118,7 @@ impl WritingMode {
#[cfg(feature = "gecko")]
SpecifiedWritingMode::SidewaysRl => {
flags.insert(WritingMode::VERTICAL);
flags.insert(WritingMode::SIDEWAYS);
flags.insert(WritingMode::VERTICAL_SIDEWAYS);
if direction == Direction::Rtl {
flags.insert(WritingMode::INLINE_REVERSED);
}
@@ -121,7 +127,7 @@ impl WritingMode {
SpecifiedWritingMode::SidewaysLr => {
flags.insert(WritingMode::VERTICAL);
flags.insert(WritingMode::VERTICAL_LR);
flags.insert(WritingMode::SIDEWAYS);
flags.insert(WritingMode::VERTICAL_SIDEWAYS);
if direction == Direction::Ltr {
flags.insert(WritingMode::INLINE_REVERSED);
}
@@ -140,9 +146,18 @@ impl WritingMode {
TextOrientation::Mixed => {},
TextOrientation::Upright => {
flags.insert(WritingMode::UPRIGHT);

// https://drafts.csswg.org/css-writing-modes-3/#valdef-text-orientation-upright:
//
// > This value causes the used value of direction
// > to be ltr, and for the purposes of bidi
// > reordering, causes all characters to be treated
// > as strong LTR.
flags.remove(WritingMode::RTL);
flags.remove(WritingMode::INLINE_REVERSED);
},
TextOrientation::Sideways => {
flags.insert(WritingMode::SIDEWAYS);
flags.insert(WritingMode::TEXT_SIDEWAYS);
},
}
},
@@ -178,7 +193,7 @@ impl WritingMode {

#[inline]
pub fn is_sideways(&self) -> bool {
self.intersects(WritingMode::SIDEWAYS)
self.intersects(WritingMode::VERTICAL_SIDEWAYS | WritingMode::TEXT_SIDEWAYS)
}

#[inline]
@@ -316,7 +331,7 @@ impl fmt::Display for WritingMode {
} else {
write!(formatter, " RL")?;
}
if self.intersects(WritingMode::SIDEWAYS) {
if self.is_sideways() {
write!(formatter, " Sideways")?;
}
if self.intersects(WritingMode::LINE_INVERTED) {
@@ -36,7 +36,7 @@ impl ToCss for AspectRatio {
W: fmt::Write,
{
self.0.to_css(dest)?;
dest.write_char('/')?;
dest.write_str(" / ")?;
self.1.to_css(dest)
}
}
@@ -362,9 +362,20 @@ fn should_ignore_declaration_when_ignoring_document_colors(
// Treat background-color a bit differently. If the specified color is
// anything other than a fully transparent color, convert it into the
// Device's default background color.
// Also: for now, we treat background-image a bit differently, too.
// background-image is marked as ignored, but really, we only ignore
// it when backplates are disabled (since then text may be unreadable over
// a background image, if we're ignoring document colors).
// Here we check backplate status to decide if ignoring background-image
// is the right decision.
{
let background_color = match **declaration {
PropertyDeclaration::BackgroundColor(ref color) => color,
// In the future, if/when we remove the backplate pref, we can remove this
// special case along with the 'ignored_when_colors_disabled=True' mako line
// for the "background-image" property.
#[cfg(feature = "gecko")]
PropertyDeclaration::BackgroundImage(..) => return !static_prefs::pref!("browser.display.permit_backplate"),
_ => return true,
};

@@ -9,7 +9,8 @@
# "column-span",
# "offset-distance",
# "offset-path",
# "offset-rotate"
# "offset-rotate",
# "offset"
COUNTED_UNKNOWN_PROPERTIES = [
"-webkit-font-smoothing",
"zoom",
@@ -82,7 +83,6 @@
"-webkit-ruby-position",
"-webkit-column-break-after",
"-webkit-margin-collapse",
"offset",
"-webkit-border-before",
"-webkit-border-end",
"-webkit-border-after",
@@ -768,17 +768,22 @@ animated_list_impl!(<T> for crate::OwnedSlice<T>);
animated_list_impl!(<T> for SmallVec<[T; 1]>);
animated_list_impl!(<T> for Vec<T>);

/// <https://drafts.csswg.org/css-transitions/#animtype-visibility>
/// <https://drafts.csswg.org/web-animations-1/#animating-visibility>
impl Animate for Visibility {
#[inline]
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
let (this_weight, other_weight) = procedure.weights();
match (*self, *other) {
(Visibility::Visible, _) => {
Ok(if this_weight > 0.0 { *self } else { *other })
},
(_, Visibility::Visible) => {
Ok(if other_weight > 0.0 { *other } else { *self })
match procedure {
Procedure::Interpolate { .. } => {
let (this_weight, other_weight) = procedure.weights();
match (*self, *other) {
(Visibility::Visible, _) => {
Ok(if this_weight > 0.0 { *self } else { *other })
},
(_, Visibility::Visible) => {
Ok(if other_weight > 0.0 { *other } else { *self })
},
_ => Err(()),
}
},
_ => Err(()),
}
@@ -126,7 +126,7 @@ ${helpers.predefined_type(
initial_value="generics::rect::Rect::all(computed::NonNegativeLengthOrNumber::zero())",
initial_specified_value="generics::rect::Rect::all(specified::NonNegativeLengthOrNumber::zero())",
spec="https://drafts.csswg.org/css-backgrounds/#border-image-outset",
animation_value_type="discrete",
animation_value_type="NonNegativeLengthOrNumberRect",
boxed=True,
)}

@@ -147,7 +147,7 @@ ${helpers.predefined_type(
initial_value="computed::BorderImageWidth::all(computed::BorderImageSideWidth::one())",
initial_specified_value="specified::BorderImageWidth::all(specified::BorderImageSideWidth::one())",
spec="https://drafts.csswg.org/css-backgrounds/#border-image-width",
animation_value_type="discrete",
animation_value_type="BorderImageWidth",
boxed=True,
)}

@@ -158,6 +158,6 @@ ${helpers.predefined_type(
initial_value="computed::BorderImageSlice::hundred_percent()",
initial_specified_value="specified::BorderImageSlice::hundred_percent()",
spec="https://drafts.csswg.org/css-backgrounds/#border-image-slice",
animation_value_type="discrete",
animation_value_type="BorderImageSlice",
boxed=True,
)}
@@ -91,6 +91,7 @@ ${helpers.single_keyword(
extra_prefixes="webkit",
animation_value_type="discrete",
servo_restyle_damage = "reflow",
gecko_enum_prefix = "StyleFlexWrap",
)}

% if engine == "servo-2013":

0 comments on commit 2c280ab

Please sign in to comment.
You can’t perform that action at this time.