Auto merge of #17650 - jryans:link-transition-crash, r=hiikezoe

Pass through visited style for after change

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

<!-- 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/17650)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-07-10 11:33:04 -07:00 committed by GitHub
commit 5010df627d
4 changed files with 28 additions and 3 deletions

View file

@ -297,6 +297,11 @@ impl CascadeInputs {
self.visited_rules.take()
}
/// Whether there are any visited values.
pub fn has_visited_values(&self) -> bool {
self.visited_values.is_some()
}
/// Gets a reference to the visited computed values. Panic if the element
/// does not have visited computed values.
pub fn visited_values(&self) -> &Arc<ComputedValues> {

View file

@ -577,6 +577,12 @@ trait PrivateMatchMethods: TElement {
}
}
// If there were visited values to insert, ensure they do in fact exist
// inside the new values.
debug_assert!(!cascade_visited.visited_values_for_insertion() ||
context.cascade_inputs().primary().has_visited_values() ==
new_values.has_visited_style());
// Set the new computed values.
let primary_inputs = context.cascade_inputs_mut().primary_mut();
cascade_visited.set_primary_values(&mut data.styles,
@ -661,8 +667,9 @@ trait PrivateMatchMethods: TElement {
return None;
}
// This currently ignores visited styles, which seems acceptable,
// as existing browsers don't appear to transition visited styles.
// This currently passes through visited styles, if they exist.
// When fixing bug 868975, compute after change for visited styles as
// well, along with updating the rest of the animation processing.
Some(self.cascade_with_rules(context.shared,
&context.thread_local.font_metrics_provider,
&without_transition_rules,
@ -670,7 +677,7 @@ trait PrivateMatchMethods: TElement {
CascadeTarget::Normal,
CascadeVisitedMode::Unvisited,
/* parent_info = */ None,
None))
primary_style.get_visited_style().cloned()))
}
#[cfg(feature = "gecko")]
@ -716,6 +723,9 @@ trait PrivateMatchMethods: TElement {
use context::{CASCADE_RESULTS, CSS_ANIMATIONS, CSS_TRANSITIONS, EFFECT_PROPERTIES};
use context::UpdateAnimationsTasks;
// Bug 868975: These steps should examine and update the visited styles
// in addition to the unvisited styles.
let mut tasks = UpdateAnimationsTasks::empty();
if self.needs_animations_update(context, old_values.as_ref(), new_values) {
tasks.insert(CSS_ANIMATIONS);

View file

@ -171,6 +171,11 @@ impl ComputedValues {
self.rules.as_ref().unwrap()
}
/// Whether there is a visited style.
pub fn has_visited_style(&self) -> bool {
self.visited_style.is_some()
}
/// Gets a reference to the visited style, if any.
pub fn get_visited_style(&self) -> Option<<&Arc<ComputedValues>> {
self.visited_style.as_ref()

View file

@ -1908,6 +1908,11 @@ impl ComputedValues {
self.rules.as_ref().unwrap()
}
/// Whether there is a visited style.
pub fn has_visited_style(&self) -> bool {
self.visited_style.is_some()
}
/// Gets a reference to the visited style, if any.
pub fn get_visited_style(&self) -> Option<<&Arc<ComputedValues>> {
self.visited_style.as_ref()