Commit 4beec3a2 authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Chromium LUCI CQ

Default @namespace should not apply to VTT type selectors

Ignore default namespace when parsing ::cue() parameter as a type
selector.

Bug: 1166850
Change-Id: I4fde0fe1f36e15dbd8390ea0ace218739ed1ec7b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2631485Reviewed-by: default avatarAnders Hartvoll Ruud <andruud@chromium.org>
Reviewed-by: default avatarFredrik Söderquist <fs@opera.com>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844065}
parent 56bfe52d
...@@ -165,4 +165,25 @@ TEST(CSSSelector, HasLinkOrVisited) { ...@@ -165,4 +165,25 @@ TEST(CSSSelector, HasLinkOrVisited) {
EXPECT_TRUE(HasLinkOrVisited(":host-context(:link)")); EXPECT_TRUE(HasLinkOrVisited(":host-context(:link)"));
} }
TEST(CSSSelector, CueDefaultNamespace) {
css_test_helpers::TestStyleSheet sheet;
sheet.AddCSSRules(R"HTML(
@namespace "http://www.w3.org/1999/xhtml";
video::cue(b) {}
)HTML");
const CSSSelector& cue_selector =
(*sheet.GetRuleSet().CuePseudoRules())[0]->Selector();
EXPECT_EQ(cue_selector.GetPseudoType(), CSSSelector::kPseudoCue);
const CSSSelectorList* cue_arguments = cue_selector.SelectorList();
ASSERT_TRUE(cue_arguments);
const CSSSelector* vtt_type_selector = cue_arguments->First();
ASSERT_TRUE(vtt_type_selector);
EXPECT_EQ(vtt_type_selector->TagQName().LocalName(), "b");
// Default namespace should not affect VTT node type selector.
EXPECT_EQ(vtt_type_selector->TagQName().NamespaceURI(), g_star_atom);
}
} // namespace blink } // namespace blink
...@@ -34,7 +34,7 @@ CSSParserTokenRange ConsumeNestedArgument(CSSParserTokenRange& range) { ...@@ -34,7 +34,7 @@ CSSParserTokenRange ConsumeNestedArgument(CSSParserTokenRange& range) {
return range.MakeSubRange(&first, &range.Peek()); return range.MakeSubRange(&first, &range.Peek());
} }
bool AtEndIgnoringWhitepace(CSSParserTokenRange range) { bool AtEndIgnoringWhitespace(CSSParserTokenRange range) {
range.ConsumeWhitespace(); range.ConsumeWhitespace();
return range.AtEnd(); return range.AtEnd();
} }
...@@ -427,8 +427,9 @@ std::unique_ptr<CSSParserSelector> CSSSelectorParser::ConsumeCompoundSelector( ...@@ -427,8 +427,9 @@ std::unique_ptr<CSSParserSelector> CSSSelectorParser::ConsumeCompoundSelector(
// [1] https://drafts.csswg.org/selectors/#matches // [1] https://drafts.csswg.org/selectors/#matches
// [2] https://drafts.csswg.org/selectors/#selector-subject // [2] https://drafts.csswg.org/selectors/#selector-subject
base::AutoReset<bool> ignore_namespace( base::AutoReset<bool> ignore_namespace(
&ignore_default_namespace_, resist_default_namespace_ && !has_q_name && &ignore_default_namespace_,
AtEndIgnoringWhitepace(range)); ignore_default_namespace_ || (resist_default_namespace_ && !has_q_name &&
AtEndIgnoringWhitespace(range)));
if (!compound_selector) { if (!compound_selector) {
AtomicString namespace_uri = DetermineNamespace(namespace_prefix); AtomicString namespace_uri = DetermineNamespace(namespace_prefix);
...@@ -699,6 +700,10 @@ std::unique_ptr<CSSParserSelector> CSSSelectorParser::ConsumePseudo( ...@@ -699,6 +700,10 @@ std::unique_ptr<CSSParserSelector> CSSSelectorParser::ConsumePseudo(
case CSSSelector::kPseudoCue: { case CSSSelector::kPseudoCue: {
DisallowPseudoElementsScope scope(this); DisallowPseudoElementsScope scope(this);
base::AutoReset<bool> inside_compound(&inside_compound_pseudo_, true); base::AutoReset<bool> inside_compound(&inside_compound_pseudo_, true);
base::AutoReset<bool> ignore_namespace(
&ignore_default_namespace_,
ignore_default_namespace_ ||
selector->GetPseudoType() == CSSSelector::kPseudoCue);
std::unique_ptr<CSSSelectorList> selector_list = std::unique_ptr<CSSSelectorList> selector_list =
std::make_unique<CSSSelectorList>(); std::make_unique<CSSSelectorList>();
......
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