Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: Sync changes from mozilla-central. #22641

Merged
merged 27 commits into from Jan 7, 2019
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4799e83
style: Enable CSS containment for frontend code.
dholbert Dec 15, 2018
31838b1
style: The 'all' property is not animatable.
emilio Dec 15, 2018
b59ec2e
style: Make <use> shadow trees lookup keyframe rules in the containin…
emilio Dec 17, 2018
1903559
style: Cleanup some conversion code dealing with NonNegative.
emilio Dec 16, 2018
ca1ad00
style: Use NonNegative more in the border code.
emilio Dec 17, 2018
3ed525f
style: Use cbindgen for ExtremumLength.
BorisChiou Dec 18, 2018
b7e728a
style: Support unprefixed min-content and max-content.
BorisChiou Dec 18, 2018
6275595
style: Let logical height, block-size, accept keywords.
BorisChiou Dec 18, 2018
f0f3eb3
style: Clamp to non-negative value after doing interpolation for circ…
BorisChiou Dec 19, 2018
7b44418
style: Bump smallvec and smallbitvec.
heycam Dec 20, 2018
8a6230e
style: changes to implement enum class for #define NS_STYLE_COLOR_ADJ…
sharath29 Dec 24, 2018
8929087
style: Update the Rust target version for bindgen.
emilio Dec 25, 2018
81a07b4
style: Implement the 'overflow-block' media query.
quasicomputational Dec 27, 2018
274845f
style: Implement the 'overflow-inline' media query.
quasicomputational Dec 22, 2018
a454f62
Rename nsIDocument to mozilla::dom::Document.
emilio Jan 2, 2019
d5bee57
style: Drop layout.css.box-decoration-break.enabled pref.
Jan 4, 2019
529ff36
style: Drop layout.css.color-adjust.enabled pref.
Jan 4, 2019
d862dae
style: Drop layout.css.image-orientation.enabled pref.
Jan 4, 2019
0488f81
style: Drop layout.css.isolation.enabled pref.
Jan 4, 2019
a0d1a03
style: Drop layout.css.mix-blend-mode.enabled pref.
Jan 4, 2019
48e4433
style: Drop layout.css.scroll-behavior.property-enabled pref.
Jan 4, 2019
152ef2e
style: Drop layout.css.background-blend-mode.enabled pref.
Jan 4, 2019
5f173c4
style: Rustfmt recent changes.
emilio Jan 6, 2019
d0eb20c
Update lockfile.
emilio Jan 6, 2019
4c1076a
style: Fix gecko build.
emilio Jan 6, 2019
97bd8fc
Fix Servo build.
emilio Jan 6, 2019
ecd9794
style: Remove a bunch of unit tests that are not very useful.
emilio Jan 7, 2019
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

style: Make <use> shadow trees lookup keyframe rules in the containin…

…g tree.

The same thing we do for rule matching.

Differential Revision: https://phabricator.services.mozilla.com/D14548
  • Loading branch information
emilio committed Jan 6, 2019
commit b59ec2e6994f247fcf543b874cb5be1208daf4e2
@@ -5,7 +5,7 @@
//! Collects a series of applicable rules for a given element.

use crate::applicable_declarations::{ApplicableDeclarationBlock, ApplicableDeclarationList};
use crate::dom::{TElement, TShadowRoot};
use crate::dom::{TElement, TNode, TShadowRoot};
use crate::properties::{AnimationRules, PropertyDeclarationBlock};
use crate::rule_tree::{CascadeLevel, ShadowCascadeOrder};
use crate::selector_map::SelectorMap;
@@ -17,6 +17,43 @@ use selectors::matching::{ElementSelectorFlags, MatchingContext};
use servo_arc::ArcBorrow;
use smallvec::SmallVec;

/// This is a bit of a hack so <svg:use> matches the rules of the enclosing
/// tree.
///
/// This function returns the containing shadow host ignoring <svg:use> shadow
/// trees, since those match the enclosing tree's rules.
///
/// Only a handful of places need to really care about this. This is not a
/// problem for invalidation and that kind of stuff because they still don't
/// match rules based on elements outside of the shadow tree, and because the
/// <svg:use> subtrees are immutable and recreated each time the source tree
/// changes.
///
/// We historically allow cross-document <svg:use> to have these rules applied,
/// but I think that's not great. Gecko is the only engine supporting that.
///
/// See https://github.com/w3c/svgwg/issues/504 for the relevant spec
/// discussion.
#[inline]
pub fn containing_shadow_ignoring_svg_use<E: TElement>(
element: E,
) -> Option<<E::ConcreteNode as TNode>::ConcreteShadowRoot> {
let mut shadow = element.containing_shadow()?;
loop {
let host = shadow.host();
let host_is_svg_use_element =
host.is_svg_element() && host.local_name() == &*local_name!("use");
if !host_is_svg_use_element {
return Some(shadow);
}
debug_assert!(
shadow.style_data().is_none(),
"We allow no stylesheets in <svg:use> subtrees"
);
shadow = host.containing_shadow()?;
}
}

/// An object that we use with all the intermediate state needed for the
/// cascade.
///
@@ -213,43 +250,19 @@ where
return;
}

let mut current_containing_shadow = self.rule_hash_target.containing_shadow();
while let Some(containing_shadow) = current_containing_shadow {
let cascade_data = containing_shadow.style_data();
let host = containing_shadow.host();
if let Some(map) = cascade_data.and_then(|data| data.normal_rules(self.pseudo_element))
{
self.collect_rules_in_shadow_tree(host, map, CascadeLevel::SameTreeAuthorNormal);
}
let host_is_svg_use_element =
host.is_svg_element() && host.local_name() == &*local_name!("use");
if !host_is_svg_use_element {
self.matches_document_author_rules = false;
break;
}
let containing_shadow = containing_shadow_ignoring_svg_use(self.rule_hash_target);
let containing_shadow = match containing_shadow {
Some(s) => s,
None => return,
};

debug_assert!(
cascade_data.is_none(),
"We allow no stylesheets in <svg:use> subtrees"
);
self.matches_document_author_rules = false;

// NOTE(emilio): Hack so <svg:use> matches the rules of the
// enclosing tree.
//
// This is not a problem for invalidation and that kind of stuff
// because they still don't match rules based on elements
// outside of the shadow tree, and because the <svg:use>
// subtrees are immutable and recreated each time the source
// tree changes.
//
// We historically allow cross-document <svg:use> to have these
// rules applied, but I think that's not great. Gecko is the
// only engine supporting that.
//
// See https://github.com/w3c/svgwg/issues/504 for the relevant
// spec discussion.
current_containing_shadow = host.containing_shadow();
self.matches_document_author_rules = current_containing_shadow.is_none();
let cascade_data = containing_shadow.style_data();
let host = containing_shadow.host();
if let Some(map) = cascade_data.and_then(|data| data.normal_rules(self.pseudo_element))
{
self.collect_rules_in_shadow_tree(host, map, CascadeLevel::SameTreeAuthorNormal);
}
}

@@ -17,7 +17,7 @@ use crate::media_queries::Device;
use crate::properties::{self, CascadeMode, ComputedValues};
use crate::properties::{AnimationRules, PropertyDeclarationBlock};
use crate::rule_cache::{RuleCache, RuleCacheConditions};
use crate::rule_collector::RuleCollector;
use crate::rule_collector::{RuleCollector, containing_shadow_ignoring_svg_use};
use crate::rule_tree::{CascadeLevel, RuleTree, ShadowCascadeOrder, StrongRuleNode, StyleSource};
use crate::selector_map::{PrecomputedHashMap, PrecomputedHashSet, SelectorMap, SelectorMapEntry};
use crate::selector_parser::{PerPseudoElementMap, PseudoElement, SelectorImpl, SnapshotMap};
@@ -1187,7 +1187,9 @@ impl Stylist {
}
}

if let Some(shadow) = element.containing_shadow() {
// Use the same rules to look for the containing host as we do for rule
// collection.
if let Some(shadow) = containing_shadow_ignoring_svg_use(element) {
if let Some(data) = shadow.style_data() {
try_find_in!(data);
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.