Bug 1545440 - Don't allow to parse XUL tree pseudo-elements with a single colon. r=mats

Now that they're not exposed to the web we can remove this special case.

Differential Revision: https://phabricator.services.mozilla.com/D28071

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2019-04-19 04:41:17 +00:00
Родитель b8140fd374
Коммит 824fde5850
5 изменённых файлов: 9 добавлений и 20 удалений

Просмотреть файл

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
treechildren:-moz-tree-image { treechildren::-moz-tree-image {
-moz-context-properties: fill, fill-opacity; -moz-context-properties: fill, fill-opacity;
fill-opacity: 0.7; fill-opacity: 0.7;
} }

Просмотреть файл

@ -1102,15 +1102,15 @@ function runTests() {
test_parseable(":-moz-lwtheme-brighttext"); test_parseable(":-moz-lwtheme-brighttext");
test_parseable(":-moz-lwtheme-darktext"); test_parseable(":-moz-lwtheme-darktext");
test_parseable(":-moz-tree-row(selected)"); test_balanced_unparseable(":-moz-tree-row(selected)");
test_parseable("::-moz-tree-row(selected)"); test_parseable("::-moz-tree-row(selected)");
test_parseable("::-MoZ-trEE-RoW(sElEcTeD)"); test_parseable("::-MoZ-trEE-RoW(sElEcTeD)");
test_parseable(":-moz-tree-row(selected focus)"); test_balanced_unparseable(":-moz-tree-row(selected focus)");
test_parseable(":-moz-tree-row(selected , focus)"); test_balanced_unparseable(":-moz-tree-row(selected , focus)");
test_parseable("::-moz-tree-row(selected ,focus)"); test_parseable("::-moz-tree-row(selected ,focus)");
test_parseable(":-moz-tree-row(selected, focus)"); test_balanced_unparseable(":-moz-tree-row(selected, focus)");
test_parseable("::-moz-tree-row(selected,focus)"); test_parseable("::-moz-tree-row(selected,focus)");
test_parseable(":-moz-tree-row(selected focus)"); test_balanced_unparseable(":-moz-tree-row(selected focus)");
test_parseable("::-moz-tree-row(selected , focus)"); test_parseable("::-moz-tree-row(selected , focus)");
test_parseable("::-moz-tree-twisty( hover open )"); test_parseable("::-moz-tree-twisty( hover open )");
test_balanced_unparseable("::-moz-tree-row(selected {[]} )"); test_balanced_unparseable("::-moz-tree-row(selected {[]} )");

Просмотреть файл

@ -1007,7 +1007,7 @@ VARCACHE_PREF(
bool, false bool, false
) )
// Pref to control whether ::xul-tree-* pseudo-elements are parsed in content // Pref to control whether XUL ::-tree-* pseudo-elements are parsed in content
// pages. // pages.
VARCACHE_PREF( VARCACHE_PREF(
"layout.css.xul-tree-pseudos.content.enabled", "layout.css.xul-tree-pseudos.content.enabled",

Просмотреть файл

@ -191,12 +191,6 @@ pub trait Parser<'i> {
type Impl: SelectorImpl; type Impl: SelectorImpl;
type Error: 'i + From<SelectorParseErrorKind<'i>>; type Error: 'i + From<SelectorParseErrorKind<'i>>;
/// Whether the name is a pseudo-element that can be specified with
/// the single colon syntax in addition to the double-colon syntax.
fn pseudo_element_allows_single_colon(name: &str) -> bool {
is_css2_pseudo_element(name)
}
/// Whether to parse the `::slotted()` pseudo-element. /// Whether to parse the `::slotted()` pseudo-element.
fn parse_slotted(&self) -> bool { fn parse_slotted(&self) -> bool {
false false
@ -2038,7 +2032,7 @@ where
/// Returns whether the name corresponds to a CSS2 pseudo-element that /// Returns whether the name corresponds to a CSS2 pseudo-element that
/// can be specified with the single colon syntax (in addition to the /// can be specified with the single colon syntax (in addition to the
/// double-colon syntax, which can be used for all pseudo-elements). /// double-colon syntax, which can be used for all pseudo-elements).
pub fn is_css2_pseudo_element(name: &str) -> bool { fn is_css2_pseudo_element(name: &str) -> bool {
// ** Do not add to this list! ** // ** Do not add to this list! **
match_ignore_ascii_case! { name, match_ignore_ascii_case! { name,
"before" | "after" | "first-line" | "first-letter" => true, "before" | "after" | "first-line" | "first-letter" => true,
@ -2114,7 +2108,7 @@ where
}, },
}; };
let is_pseudo_element = let is_pseudo_element =
!is_single_colon || P::pseudo_element_allows_single_colon(&name); !is_single_colon || is_css2_pseudo_element(&name);
if is_pseudo_element { if is_pseudo_element {
if state.intersects(SelectorParsingState::AFTER_PSEUDO_ELEMENT) { if state.intersects(SelectorParsingState::AFTER_PSEUDO_ELEMENT) {
return Err(input.new_custom_error(SelectorParseErrorKind::InvalidState)); return Err(input.new_custom_error(SelectorParseErrorKind::InvalidState));

Просмотреть файл

@ -351,11 +351,6 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {
self.parse_slotted() self.parse_slotted()
} }
fn pseudo_element_allows_single_colon(name: &str) -> bool {
// FIXME: -moz-tree check should probably be ascii-case-insensitive.
::selectors::parser::is_css2_pseudo_element(name) || name.starts_with("-moz-tree-")
}
fn parse_non_ts_pseudo_class( fn parse_non_ts_pseudo_class(
&self, &self,
location: SourceLocation, location: SourceLocation,