mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
style: Add @-moz-document media-document(image|video|plugin).
Bug: 1475511 Reviewed-by: xidorn MozReview-Commit-ID: CD3O1vGLAoV
This commit is contained in:
parent
5634a3f670
commit
7e77f4dd4e
1 changed files with 28 additions and 0 deletions
|
@ -71,6 +71,16 @@ impl DeepCloneWithLock for DocumentRule {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The kind of media document that the rule will match.
|
||||||
|
#[derive(Clone, Copy, Debug, Parse, PartialEq, ToCss)]
|
||||||
|
#[allow(missing_docs)]
|
||||||
|
pub enum MediaDocumentKind {
|
||||||
|
All,
|
||||||
|
Plugin,
|
||||||
|
Image,
|
||||||
|
Video,
|
||||||
|
}
|
||||||
|
|
||||||
/// A matching function for a `@document` rule's condition.
|
/// A matching function for a `@document` rule's condition.
|
||||||
#[derive(Clone, Debug, ToCss)]
|
#[derive(Clone, Debug, ToCss)]
|
||||||
pub enum DocumentMatchingFunction {
|
pub enum DocumentMatchingFunction {
|
||||||
|
@ -97,6 +107,9 @@ pub enum DocumentMatchingFunction {
|
||||||
/// of the document being styled.
|
/// of the document being styled.
|
||||||
#[css(function)]
|
#[css(function)]
|
||||||
Regexp(String),
|
Regexp(String),
|
||||||
|
/// Matching function for a media document.
|
||||||
|
#[css(function)]
|
||||||
|
MediaDocument(MediaDocumentKind)
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! parse_quoted_or_unquoted_string {
|
macro_rules! parse_quoted_or_unquoted_string {
|
||||||
|
@ -142,6 +155,12 @@ impl DocumentMatchingFunction {
|
||||||
))
|
))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
"media-document" => {
|
||||||
|
input.parse_nested_block(|input| {
|
||||||
|
let kind = MediaDocumentKind::parse(input)?;
|
||||||
|
Ok(DocumentMatchingFunction::MediaDocument(kind))
|
||||||
|
})
|
||||||
|
}
|
||||||
_ => {
|
_ => {
|
||||||
Err(location.new_custom_error(
|
Err(location.new_custom_error(
|
||||||
StyleParseErrorKind::UnexpectedFunction(function.clone())
|
StyleParseErrorKind::UnexpectedFunction(function.clone())
|
||||||
|
@ -162,6 +181,7 @@ impl DocumentMatchingFunction {
|
||||||
DocumentMatchingFunction::UrlPrefix(_) => GeckoDocumentMatchingFunction::URLPrefix,
|
DocumentMatchingFunction::UrlPrefix(_) => GeckoDocumentMatchingFunction::URLPrefix,
|
||||||
DocumentMatchingFunction::Domain(_) => GeckoDocumentMatchingFunction::Domain,
|
DocumentMatchingFunction::Domain(_) => GeckoDocumentMatchingFunction::Domain,
|
||||||
DocumentMatchingFunction::Regexp(_) => GeckoDocumentMatchingFunction::RegExp,
|
DocumentMatchingFunction::Regexp(_) => GeckoDocumentMatchingFunction::RegExp,
|
||||||
|
DocumentMatchingFunction::MediaDocument(_) => GeckoDocumentMatchingFunction::MediaDocument,
|
||||||
};
|
};
|
||||||
|
|
||||||
let pattern = nsCStr::from(match *self {
|
let pattern = nsCStr::from(match *self {
|
||||||
|
@ -169,6 +189,14 @@ impl DocumentMatchingFunction {
|
||||||
DocumentMatchingFunction::UrlPrefix(ref pat) |
|
DocumentMatchingFunction::UrlPrefix(ref pat) |
|
||||||
DocumentMatchingFunction::Domain(ref pat) |
|
DocumentMatchingFunction::Domain(ref pat) |
|
||||||
DocumentMatchingFunction::Regexp(ref pat) => pat,
|
DocumentMatchingFunction::Regexp(ref pat) => pat,
|
||||||
|
DocumentMatchingFunction::MediaDocument(kind) => {
|
||||||
|
match kind {
|
||||||
|
MediaDocumentKind::All => "all",
|
||||||
|
MediaDocumentKind::Image => "image",
|
||||||
|
MediaDocumentKind::Plugin => "plugin",
|
||||||
|
MediaDocumentKind::Video => "video",
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
unsafe { Gecko_DocumentRule_UseForPresentation(device.pres_context(), &*pattern, func) }
|
unsafe { Gecko_DocumentRule_UseForPresentation(device.pres_context(), &*pattern, func) }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue