--- a/layout/style/CSSMozDocumentRule.cpp
+++ b/layout/style/CSSMozDocumentRule.cpp
@@ -20,47 +20,47 @@ CSSMozDocumentRule::WrapObject(JSContext
return CSSMozDocumentRule_Binding::Wrap(aCx, this, aGivenProto);
}
bool
CSSMozDocumentRule::Match(nsIDocument* aDoc,
nsIURI* aDocURI,
const nsACString& aDocURISpec,
const nsACString& aPattern,
- URLMatchingFunction aUrlMatchingFunction)
+ DocumentMatchingFunction aMatchingFunction)
{
- switch (aUrlMatchingFunction) {
- case URLMatchingFunction::eURL: {
+ switch (aMatchingFunction) {
+ case DocumentMatchingFunction::URL: {
if (aDocURISpec == aPattern) {
return true;
}
} break;
- case URLMatchingFunction::eURLPrefix: {
+ case DocumentMatchingFunction::URLPrefix: {
if (StringBeginsWith(aDocURISpec, aPattern)) {
return true;
}
} break;
- case URLMatchingFunction::eDomain: {
+ case DocumentMatchingFunction::Domain: {
nsAutoCString host;
if (aDocURI) {
aDocURI->GetHost(host);
}
int32_t lenDiff = host.Length() - aPattern.Length();
if (lenDiff == 0) {
if (host == aPattern) {
return true;
}
} else {
if (StringEndsWith(host, aPattern) &&
host.CharAt(lenDiff - 1) == '.') {
return true;
}
}
} break;
- case URLMatchingFunction::eRegExp: {
+ case DocumentMatchingFunction::RegExp: {
NS_ConvertUTF8toUTF16 spec(aDocURISpec);
NS_ConvertUTF8toUTF16 regex(aPattern);
if (nsContentUtils::IsPatternMatching(spec, regex, aDoc)) {
return true;
}
} break;
}
--- a/layout/style/CSSMozDocumentRule.h
+++ b/layout/style/CSSMozDocumentRule.h
@@ -3,17 +3,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
#ifndef mozilla_dom_CSSMozDocumentRule_h
#define mozilla_dom_CSSMozDocumentRule_h
#include "mozilla/css/GroupRule.h"
-#include "mozilla/css/URLMatchingFunction.h"
+#include "mozilla/css/DocumentMatchingFunction.h"
#include "mozilla/ServoBindingTypes.h"
namespace mozilla {
namespace dom {
class CSSMozDocumentRule final : public css::ConditionRule
{
public:
@@ -24,17 +24,17 @@ public:
uint32_t aColumn);
NS_DECL_ISUPPORTS_INHERITED
static bool Match(nsIDocument* aDoc,
nsIURI* aDocURI,
const nsACString& aDocURISpec,
const nsACString& aPattern,
- css::URLMatchingFunction aUrlMatchingFunction);
+ css::DocumentMatchingFunction);
#ifdef DEBUG
void List(FILE* out = stdout, int32_t aIndent = 0) const final;
#endif
RawServoMozDocumentRule* Raw() const { return mRawRule; }
// WebIDL interface
new file mode 100644
--- /dev/null
+++ b/layout/style/DocumentMatchingFunction.h
@@ -0,0 +1,27 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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/. */
+
+#ifndef mozilla_css_DocumentMatchingFunction_h
+#define mozilla_css_DocumentMatchingFunction_h
+
+namespace mozilla {
+namespace css {
+
+/**
+ * Enum defining the type of matching function for a @-moz-document rule
+ * condition.
+ */
+enum class DocumentMatchingFunction {
+ URL = 0,
+ URLPrefix,
+ Domain,
+ RegExp,
+};
+
+} // namespace css
+} // namespace mozilla
+
+#endif // mozilla_css_DocumentMatchingFunction_h
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -2749,31 +2749,31 @@ void
Gecko_UnregisterProfilerThread()
{
PROFILER_UNREGISTER_THREAD();
}
bool
Gecko_DocumentRule_UseForPresentation(RawGeckoPresContextBorrowed aPresContext,
const nsACString* aPattern,
- css::URLMatchingFunction aURLMatchingFunction)
+ css::DocumentMatchingFunction aMatchingFunction)
{
MOZ_ASSERT(NS_IsMainThread());
nsIDocument *doc = aPresContext->Document();
nsIURI *docURI = doc->GetDocumentURI();
nsAutoCString docURISpec;
if (docURI) {
// If GetSpec fails (due to OOM) just skip these URI-specific CSS rules.
nsresult rv = docURI->GetSpec(docURISpec);
NS_ENSURE_SUCCESS(rv, false);
}
return CSSMozDocumentRule::Match(doc, docURI, docURISpec, *aPattern,
- aURLMatchingFunction);
+ aMatchingFunction);
}
void
Gecko_SetJemallocThreadLocalArena(bool enabled)
{
#if defined(MOZ_MEMORY)
jemalloc_thread_local_arena(enabled);
#endif
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -9,19 +9,19 @@
#include <stdint.h>
#include "mozilla/AtomArray.h"
#include "mozilla/ServoTypes.h"
#include "mozilla/ServoBindingTypes.h"
#include "mozilla/ServoComputedDataInlines.h"
#include "mozilla/ServoElementSnapshot.h"
+#include "mozilla/css/DocumentMatchingFunction.h"
#include "mozilla/css/SheetLoadData.h"
#include "mozilla/css/SheetParsingMode.h"
-#include "mozilla/css/URLMatchingFunction.h"
#include "mozilla/EffectCompositor.h"
#include "mozilla/ComputedTimingFunction.h"
#include "nsChangeHint.h"
#include "nsIDocument.h"
/*
* API for Servo to access Gecko data structures.
*
@@ -668,17 +668,17 @@ void Gecko_AddPropertyToSet(nsCSSPropert
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
void Gecko_RegisterProfilerThread(const char* name);
void Gecko_UnregisterProfilerThread();
bool Gecko_DocumentRule_UseForPresentation(RawGeckoPresContextBorrowed,
const nsACString* aPattern,
- mozilla::css::URLMatchingFunction aURLMatchingFunction);
+ mozilla::css::DocumentMatchingFunction);
// Allocator hinting.
void Gecko_SetJemallocThreadLocalArena(bool enabled);
void Gecko_AddBufferToCrashReport(const void* addr, size_t len);
void Gecko_AnnotateCrashReport(const char* key_str, const char* value_str);
// Pseudo-element flags.
--- a/layout/style/ServoBindings.toml
+++ b/layout/style/ServoBindings.toml
@@ -118,17 +118,17 @@ rusty-enums = [
"nsCompatibility",
"mozilla::EffectCompositor_CascadeLevel",
"mozilla::SheetType",
"mozilla::dom::CallerType",
"mozilla::dom::IterationCompositeOperation",
"mozilla::dom::CompositeOperation",
"mozilla::InheritTarget",
"mozilla::FontFamilyType",
- "mozilla::css::URLMatchingFunction",
+ "mozilla::css::DocumentMatchingFunction",
"mozilla::css::SheetParsingMode",
"mozilla::StyleContentType",
"nsStyleSVGOpacitySource",
"nsStyleUnit",
"nsCSSKeyword",
"nsIDocument_DocumentTheme",
"nsIDocument_Type",
"nsCSSUnit",
@@ -224,17 +224,17 @@ whitelist-types = [
"mozilla::StyleSheet",
"mozilla::ServoStyleSheetInner",
"mozilla::ServoStyleSetSizes",
"mozilla::ServoTraversalStatistics",
"mozilla::css::LoaderReusableStyleSheets",
"mozilla::css::SheetLoadData",
"mozilla::css::SheetLoadDataHolder",
"mozilla::css::SheetParsingMode",
- "mozilla::css::URLMatchingFunction",
+ "mozilla::css::DocumentMatchingFunction",
"mozilla::dom::IterationCompositeOperation",
"mozilla::dom::StyleChildrenIterator",
"mozilla::HalfCorner",
"mozilla::MallocSizeOf",
"mozilla::OriginFlags",
"mozilla::PropertyStyleAnimationValuePair",
"mozilla::ServoTraversalFlags",
"mozilla::StaticPrefs",
@@ -595,17 +595,17 @@ structs-types = [
"SheetLoadDataHolder",
"StyleSheet",
"ServoComputedData",
"ComputedStyleStrong",
"EffectCompositor_CascadeLevel",
"UpdateAnimationsTasks",
"ParsingMode",
"InheritTarget",
- "URLMatchingFunction",
+ "DocumentMatchingFunction",
"StyleAnimation",
"StyleRuleInclusion",
"nsStyleTransformMatrix::MatrixTransformOperator",
"RawGeckoGfxMatrix4x4",
"FontFamilyName",
"mozilla::SharedFontList",
]
array-types = [
deleted file mode 100644
--- a/layout/style/URLMatchingFunction.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-#ifndef mozilla_css_URLMatchingFunction_h
-#define mozilla_css_URLMatchingFunction_h
-
-namespace mozilla {
-namespace css {
-
-/**
- * Enum defining the type of URL matching function for a @-moz-document rule
- * condition.
- */
-enum class URLMatchingFunction {
- eURL = 0,
- eURLPrefix,
- eDomain,
- eRegExp,
-};
-
-} // namespace css
-} // namespace mozilla
-
-#endif // mozilla_css_URLMatchingFunction_h
--- a/layout/style/moz.build
+++ b/layout/style/moz.build
@@ -116,25 +116,25 @@ EXPORTS.mozilla.dom += [
'FontFace.h',
'FontFaceSet.h',
'FontFaceSetIterator.h',
'MediaList.h',
'MediaQueryList.h',
]
EXPORTS.mozilla.css += [
+ 'DocumentMatchingFunction.h',
'ErrorReporter.h',
'GroupRule.h',
'ImageLoader.h',
'Loader.h',
'Rule.h',
'SheetLoadData.h',
'SheetParsingMode.h',
'StreamLoader.h',
- 'URLMatchingFunction.h',
]
UNIFIED_SOURCES += [
'AnimationCollection.cpp',
'BindingStyleRule.cpp',
'CachedInheritingStyles.cpp',
'ComputedStyle.cpp',
'CounterStyleManager.cpp',
--- a/servo/components/style/stylesheets/document_rule.rs
+++ b/servo/components/style/stylesheets/document_rule.rs
@@ -66,19 +66,19 @@ impl DeepCloneWithLock for DocumentRule
DocumentRule {
condition: self.condition.clone(),
rules: Arc::new(lock.wrap(rules.deep_clone_with_lock(lock, guard, params))),
source_location: self.source_location.clone(),
}
}
}
-/// A URL matching function for a `@document` rule's condition.
+/// A matching function for a `@document` rule's condition.
#[derive(Clone, Debug, ToCss)]
-pub enum UrlMatchingFunction {
+pub enum DocumentMatchingFunction {
/// Exact URL matching function. It evaluates to true whenever the
/// URL of the document being styled is exactly the URL given.
Url(CssUrl),
/// URL prefix matching function. It evaluates to true whenever the
/// URL of the document being styled has the argument to the
/// function as an initial substring (which is true when the two
/// strings are equal). When the argument is the empty string,
/// it evaluates to true for all documents.
@@ -111,70 +111,70 @@ macro_rules! parse_quoted_or_unquoted_st
.or_else(|_: ParseError| {
while let Ok(_) = input.next() {}
Ok($url_matching_function(input.slice_from(start).to_string()))
})
})
};
}
-impl UrlMatchingFunction {
+impl DocumentMatchingFunction {
/// Parse a URL matching function for a`@document` rule's condition.
pub fn parse<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
if input
.try(|input| input.expect_function_matching("url-prefix"))
.is_ok()
{
- return parse_quoted_or_unquoted_string!(input, UrlMatchingFunction::UrlPrefix);
+ return parse_quoted_or_unquoted_string!(input, DocumentMatchingFunction::UrlPrefix);
}
if input
.try(|input| input.expect_function_matching("domain"))
.is_ok()
{
- return parse_quoted_or_unquoted_string!(input, UrlMatchingFunction::Domain);
+ return parse_quoted_or_unquoted_string!(input, DocumentMatchingFunction::Domain);
}
if input
.try(|input| input.expect_function_matching("regexp"))
.is_ok()
{
return input.parse_nested_block(|input| {
- Ok(UrlMatchingFunction::Regexp(
+ Ok(DocumentMatchingFunction::Regexp(
input.expect_string()?.as_ref().to_owned(),
))
});
}
let url = CssUrl::parse(context, input)?;
- Ok(UrlMatchingFunction::Url(url))
+ Ok(DocumentMatchingFunction::Url(url))
}
#[cfg(feature = "gecko")]
/// Evaluate a URL matching function.
pub fn evaluate(&self, device: &Device) -> bool {
use gecko_bindings::bindings::Gecko_DocumentRule_UseForPresentation;
- use gecko_bindings::structs::URLMatchingFunction as GeckoUrlMatchingFunction;
+ use gecko_bindings::structs::DocumentMatchingFunction as GeckoDocumentMatchingFunction;
use nsstring::nsCStr;
let func = match *self {
- UrlMatchingFunction::Url(_) => GeckoUrlMatchingFunction::eURL,
- UrlMatchingFunction::UrlPrefix(_) => GeckoUrlMatchingFunction::eURLPrefix,
- UrlMatchingFunction::Domain(_) => GeckoUrlMatchingFunction::eDomain,
- UrlMatchingFunction::Regexp(_) => GeckoUrlMatchingFunction::eRegExp,
+ DocumentMatchingFunction::Url(_) => GeckoDocumentMatchingFunction::URL,
+ DocumentMatchingFunction::UrlPrefix(_) => GeckoDocumentMatchingFunction::URLPrefix,
+ DocumentMatchingFunction::Domain(_) => GeckoDocumentMatchingFunction::Domain,
+ DocumentMatchingFunction::Regexp(_) => GeckoDocumentMatchingFunction::RegExp,
};
let pattern = nsCStr::from(match *self {
- UrlMatchingFunction::Url(ref url) => url.as_str(),
- UrlMatchingFunction::UrlPrefix(ref pat) |
- UrlMatchingFunction::Domain(ref pat) |
- UrlMatchingFunction::Regexp(ref pat) => pat,
+ DocumentMatchingFunction::Url(ref url) => url.as_str(),
+ DocumentMatchingFunction::UrlPrefix(ref pat) |
+ DocumentMatchingFunction::Domain(ref pat) |
+ DocumentMatchingFunction::Regexp(ref pat) => pat,
});
unsafe { Gecko_DocumentRule_UseForPresentation(device.pres_context(), &*pattern, func) }
}
#[cfg(not(feature = "gecko"))]
/// Evaluate a URL matching function.
pub fn evaluate(&self, _: &Device) -> bool {
false
@@ -185,26 +185,26 @@ impl UrlMatchingFunction {
///
/// <https://www.w3.org/TR/2012/WD-css3-conditional-20120911/#at-document>
///
/// The `@document` rule's condition is written as a comma-separated list of
/// URL matching functions, and the condition evaluates to true whenever any
/// one of those functions evaluates to true.
#[css(comma)]
#[derive(Clone, Debug, ToCss)]
-pub struct DocumentCondition(#[css(iterable)] Vec<UrlMatchingFunction>);
+pub struct DocumentCondition(#[css(iterable)] Vec<DocumentMatchingFunction>);
impl DocumentCondition {
/// Parse a document condition.
pub fn parse<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
let conditions =
- input.parse_comma_separated(|input| UrlMatchingFunction::parse(context, input))?;
+ input.parse_comma_separated(|input| DocumentMatchingFunction::parse(context, input))?;
let condition = DocumentCondition(conditions);
if !condition.allowed_in(context) {
return Err(
input.new_custom_error(StyleParseErrorKind::UnsupportedAtRule(
"-moz-document".into(),
)),
);
@@ -247,13 +247,13 @@ impl DocumentCondition {
//
// 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(),
+ DocumentMatchingFunction::UrlPrefix(ref prefix) => prefix.is_empty(),
_ => false,
}
}
}