mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
style: Allow @-moz-document url-prefix() on content.
MozReview-Commit-ID: zaT41fpsDT Bug: 1446470 Reviewed-by: xidorn
This commit is contained in:
parent
652633aee2
commit
9bb4033ec3
2 changed files with 44 additions and 16 deletions
|
@ -15,7 +15,7 @@ use servo_arc::Arc;
|
||||||
use shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked, SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard};
|
use shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked, SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard};
|
||||||
use std::fmt::{self, Write};
|
use std::fmt::{self, Write};
|
||||||
use str::CssStringWriter;
|
use str::CssStringWriter;
|
||||||
use style_traits::{CssWriter, ParseError, ToCss};
|
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
||||||
use stylesheets::CssRules;
|
use stylesheets::CssRules;
|
||||||
use values::CssUrl;
|
use values::CssUrl;
|
||||||
|
|
||||||
|
@ -186,8 +186,17 @@ impl DocumentCondition {
|
||||||
context: &ParserContext,
|
context: &ParserContext,
|
||||||
input: &mut Parser<'i, 't>,
|
input: &mut Parser<'i, 't>,
|
||||||
) -> Result<Self, ParseError<'i>> {
|
) -> Result<Self, ParseError<'i>> {
|
||||||
input.parse_comma_separated(|input| UrlMatchingFunction::parse(context, input))
|
let conditions = input.parse_comma_separated(|input| {
|
||||||
.map(DocumentCondition)
|
UrlMatchingFunction::parse(context, input)
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let condition = DocumentCondition(conditions);
|
||||||
|
if !condition.allowed_in(context) {
|
||||||
|
return Err(input.new_custom_error(
|
||||||
|
StyleParseErrorKind::UnsupportedAtRule("-moz-document".into())
|
||||||
|
))
|
||||||
|
}
|
||||||
|
Ok(condition)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Evaluate a document condition.
|
/// Evaluate a document condition.
|
||||||
|
@ -196,4 +205,36 @@ impl DocumentCondition {
|
||||||
url_matching_function.evaluate(device)
|
url_matching_function.evaluate(device)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
|
fn allowed_in(&self, _: &ParserContext) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "gecko")]
|
||||||
|
fn allowed_in(&self, context: &ParserContext) -> bool {
|
||||||
|
use gecko_bindings::structs;
|
||||||
|
use stylesheets::Origin;
|
||||||
|
|
||||||
|
if context.stylesheet_origin != Origin::Author {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if unsafe { structs::StylePrefs_sMozDocumentEnabledInContent } {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow a single url-prefix() for compatibility.
|
||||||
|
//
|
||||||
|
// See bug 1446470 and dependencies.
|
||||||
|
if self.0.len() != 1 {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE(emilio): This technically allows url-prefix("") too, but...
|
||||||
|
match self.0[0] {
|
||||||
|
UrlMatchingFunction::UrlPrefix(ref prefix) => prefix.is_empty(),
|
||||||
|
_ => false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -422,19 +422,6 @@ impl<'a, 'b, 'i, R: ParseErrorReporter> AtRuleParser<'i> for NestedRuleParser<'a
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
{
|
|
||||||
use gecko_bindings::structs;
|
|
||||||
|
|
||||||
if self.stylesheet_origin == Origin::Author &&
|
|
||||||
unsafe { !structs::StylePrefs_sMozDocumentEnabledInContent }
|
|
||||||
{
|
|
||||||
return Err(input.new_custom_error(
|
|
||||||
StyleParseErrorKind::UnsupportedAtRule(name.clone())
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let cond = DocumentCondition::parse(self.context, input)?;
|
let cond = DocumentCondition::parse(self.context, input)?;
|
||||||
Ok(AtRuleType::WithBlock(AtRuleBlockPrelude::Document(cond, location)))
|
Ok(AtRuleType::WithBlock(AtRuleBlockPrelude::Document(cond, location)))
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue