Commit acea70b2 authored by evliu's avatar evliu Committed by Commit Bot

[WebVTT] Improvements for matching inline VTT selectors

This CL separates the selector matching flow for VTT selectors.
A side effect of this change is that |*::cue will not match, which is
consistent with how it is treated for author stylesheets as well as
inline & author stylesheets in Safari.

Bug: 1016375
Change-Id: Ic8ea2bfa198b7d0f2b3d9d4c7a01266f7fd054d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1883134
Commit-Queue: Evan Liu <evliu@google.com>
Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#715564}
parent f77d2ef6
......@@ -158,6 +158,7 @@ class SelectorChecker {
// to by the context are a match. Delegates most of the work to the Check*
// methods below.
bool CheckOne(const SelectorCheckingContext&, MatchResult&) const;
bool CheckOneForVTT(const SelectorCheckingContext&, MatchResult&) const;
enum MatchStatus {
kSelectorMatches,
......@@ -184,10 +185,16 @@ class SelectorChecker {
// to try (e.g. same element, parent, sibling) depends on the combinators in
// the selectors.
MatchStatus MatchSelector(const SelectorCheckingContext&, MatchResult&) const;
MatchStatus MatchSelectorForVTT(const SelectorCheckingContext&,
MatchResult&) const;
MatchStatus MatchForSubSelector(const SelectorCheckingContext&,
MatchResult&) const;
MatchStatus MatchForSubSelectorForVTT(const SelectorCheckingContext&,
MatchResult&) const;
MatchStatus MatchForRelation(const SelectorCheckingContext&,
MatchResult&) const;
MatchStatus MatchForRelationForVTT(const SelectorCheckingContext&,
MatchResult&) const;
MatchStatus MatchForPseudoContent(const SelectorCheckingContext&,
const Element&,
MatchResult&) const;
......@@ -197,11 +204,16 @@ class SelectorChecker {
bool MatchVTTBlockSelector(const SelectorCheckingContext& context,
MatchResult& result) const;
bool CheckPseudoClass(const SelectorCheckingContext&, MatchResult&) const;
bool CheckPseudoClassForVTT(const SelectorCheckingContext&,
MatchResult&) const;
bool CheckPseudoElement(const SelectorCheckingContext&, MatchResult&) const;
bool CheckPseudoElementForVTT(const SelectorCheckingContext&,
MatchResult&) const;
bool CheckScrollbarPseudoClass(const SelectorCheckingContext&,
MatchResult&) const;
bool CheckPseudoHost(const SelectorCheckingContext&, MatchResult&) const;
bool CheckPseudoNot(const SelectorCheckingContext&, MatchResult&) const;
bool CheckPseudoNotForVTT(const SelectorCheckingContext&, MatchResult&) const;
Mode mode_;
bool is_ua_rule_;
......
......@@ -2,16 +2,17 @@
<html class="reftest-wait">
<title>Reference for Embedded Style: Selectors</title>
<style>
::cue {
font-size: 11px;
background: lime;
}
::cue(b) {
background: green;
color: green;
}
::cue(i) {
background: lime;
color: lime;
}
::cue {
font-size: 11px;
background: green;
color: green;
}
</style>
<script src="/common/reftest-wait.js"></script>
......
WEBVTT
NOTE
The first five selectors should apply. The rest should not apply because they do
The first six selectors should apply. The rest should not apply because they do
not apply to a hypothetical document with a single empty element with no explicit
name, no namespace, no attribute, no classes, no IDs, and unknown primary language
that acts as the originating element for the cue pseudo-elements.
STYLE
@namespace html url(http://www.w3.org/1999/xhtml);
:not(video)::cue {
background: lime;
}
*|*::cue(b) {
background: green;
}
|*::cue(i) {
color: lime;
color: green;
}
::cue(i) {
background: lime;
background: green;
}
*::cue(b) {
color: green;
......@@ -24,6 +27,9 @@ STYLE
video::cue {
background: red;
}
:not(|*)::cue {
background: red;
}
i {
color: red;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment