Bug 1345698 part 5 - Add support of CSSNamespaceRule for stylo. r?heycam
MozReview-Commit-ID: Kl4Wd3eh9ll
--- a/layout/style/ServoCSSRuleList.cpp
+++ b/layout/style/ServoCSSRuleList.cpp
@@ -6,16 +6,17 @@
/* representation of CSSRuleList for stylo */
#include "mozilla/ServoCSSRuleList.h"
#include "mozilla/ServoBindings.h"
#include "mozilla/ServoStyleRule.h"
#include "mozilla/ServoMediaRule.h"
+#include "mozilla/ServoNamespaceRule.h"
namespace mozilla {
ServoCSSRuleList::ServoCSSRuleList(already_AddRefed<ServoCssRules> aRawRules)
: mRawRules(aRawRules)
{
Servo_CssRules_ListTypes(mRawRules, &mRules);
// XXX We may want to eagerly create object for import rule, so that
@@ -73,20 +74,20 @@ ServoCSSRuleList::GetRule(uint32_t aInde
#define CASE_RULE(const_, name_) \
case nsIDOMCSSRule::const_##_RULE: { \
ruleObj = new Servo##name_##Rule( \
Servo_CssRules_Get##name_##RuleAt(mRawRules, aIndex).Consume()); \
break; \
}
CASE_RULE(STYLE, Style)
CASE_RULE(MEDIA, Media)
+ CASE_RULE(NAMESPACE, Namespace)
#undef CASE_RULE
case nsIDOMCSSRule::FONT_FACE_RULE:
case nsIDOMCSSRule::KEYFRAMES_RULE:
- case nsIDOMCSSRule::NAMESPACE_RULE:
// XXX create corresponding rules
default:
NS_WARNING("stylo: not implemented yet");
return nullptr;
}
ruleObj->SetStyleSheet(mStyleSheet);
ruleObj->SetParentRule(mParentRule);
rule = CastToUint(ruleObj.forget().take());
new file mode 100644
--- /dev/null
+++ b/layout/style/ServoNamespaceRule.cpp
@@ -0,0 +1,73 @@
+/* -*- 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/. */
+
+#include "mozilla/ServoNamespaceRule.h"
+
+#include "mozilla/ServoBindings.h"
+
+using namespace mozilla::dom;
+
+namespace mozilla {
+
+ServoNamespaceRule::~ServoNamespaceRule()
+{
+}
+
+NS_IMPL_ADDREF_INHERITED(ServoNamespaceRule, CSSNamespaceRule)
+NS_IMPL_RELEASE_INHERITED(ServoNamespaceRule, CSSNamespaceRule)
+
+NS_INTERFACE_MAP_BEGIN(ServoNamespaceRule)
+NS_INTERFACE_MAP_END_INHERITING(CSSNamespaceRule)
+
+#ifdef DEBUG
+void
+ServoNamespaceRule::List(FILE* out, int32_t aIndent) const
+{
+ nsAutoCString str;
+ for (int32_t i = 0; i < aIndent; i++) {
+ str.AppendLiteral(" ");
+ }
+ Servo_NamespaceRule_Debug(mRawRule, &str);
+ fprintf_stderr(out, "%s\n", str.get());
+}
+#endif
+
+already_AddRefed<css::Rule>
+ServoNamespaceRule::Clone() const
+{
+ // Rule::Clone is only used when CSSStyleSheetInner is cloned in
+ // preparation of being mutated. However, ServoStyleSheet never clones
+ // anything, so this method should never be called.
+ MOZ_ASSERT_UNREACHABLE("Shouldn't be cloning ServoNamespaceRule");
+ return nullptr;
+}
+
+nsIAtom*
+ServoNamespaceRule::GetPrefix() const
+{
+ return Servo_NamespaceRule_GetPrefix(mRawRule);
+}
+
+void
+ServoNamespaceRule::GetURLSpec(nsString& aURLSpec) const
+{
+ nsIAtom* atom = Servo_NamespaceRule_GetURI(mRawRule);
+ atom->ToString(aURLSpec);
+}
+
+void
+ServoNamespaceRule::GetCssTextImpl(nsAString& aCssText) const
+{
+ Servo_NamespaceRule_GetCssText(mRawRule, &aCssText);
+}
+
+size_t
+ServoNamespaceRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
+{
+ return aMallocSizeOf(this);
+}
+
+} // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/layout/style/ServoNamespaceRule.h
@@ -0,0 +1,47 @@
+/* -*- 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_ServoNamespaceRule_h
+#define mozilla_ServoNamespaceRule_h
+
+#include "mozilla/ServoBindingTypes.h"
+#include "mozilla/dom/CSSNamespaceRule.h"
+
+namespace mozilla {
+
+class ServoNamespaceRule : public dom::CSSNamespaceRule
+{
+public:
+ explicit ServoNamespaceRule(already_AddRefed<RawServoNamespaceRule> aRule)
+ : CSSNamespaceRule(0, 0)
+ , mRawRule(Move(aRule))
+ {
+ }
+
+ NS_DECL_ISUPPORTS_INHERITED
+
+#ifdef DEBUG
+ void List(FILE* out = stdout, int32_t aIndent = 0) const final;
+#endif
+ already_AddRefed<Rule> Clone() const final;
+
+ nsIAtom* GetPrefix() const final;
+ void GetURLSpec(nsString& aURLSpec) const final;
+
+ // WebIDL interface
+ void GetCssTextImpl(nsAString& aCssText) const final;
+
+ size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const final;
+
+private:
+ ~ServoNamespaceRule();
+
+ RefPtr<RawServoNamespaceRule> mRawRule;
+};
+
+} // namespace mozilla
+
+#endif // mozilla_ServoNamespaceRule_h
--- a/layout/style/moz.build
+++ b/layout/style/moz.build
@@ -99,16 +99,17 @@ EXPORTS.mozilla += [
'ServoBindingList.h',
'ServoBindings.h',
'ServoBindingTypes.h',
'ServoCSSRuleList.h',
'ServoDeclarationBlock.h',
'ServoElementSnapshot.h',
'ServoMediaList.h',
'ServoMediaRule.h',
+ 'ServoNamespaceRule.h',
'ServoPropPrefList.h',
'ServoSpecifiedValues.h',
'ServoStyleRule.h',
'ServoStyleSet.h',
'ServoStyleSheet.h',
'ServoTypes.h',
'ServoUtils.h',
'SheetType.h',
@@ -214,16 +215,17 @@ UNIFIED_SOURCES += [
'RuleNodeCacheConditions.cpp',
'RuleProcessorCache.cpp',
'ServoBindings.cpp',
'ServoCSSRuleList.cpp',
'ServoDeclarationBlock.cpp',
'ServoElementSnapshot.cpp',
'ServoMediaList.cpp',
'ServoMediaRule.cpp',
+ 'ServoNamespaceRule.cpp',
'ServoSpecifiedValues.cpp',
'ServoStyleRule.cpp',
'ServoStyleSet.cpp',
'ServoStyleSheet.cpp',
'StyleAnimationValue.cpp',
'StyleRule.cpp',
'StyleSheet.cpp',
'SVGAttrAnimationRuleProcessor.cpp',
--- a/layout/style/test/stylo-failures.md
+++ b/layout/style/test/stylo-failures.md
@@ -56,20 +56,16 @@ Any line which doesn't follow the format
* test_restyles_in_smil_animation.html [2]
* CSS Timing Functions: Frames timing functions
* test_value_storage.html `frames` [30]
* Property parsing and computation:
* test_property_syntax_errors.html `animation` [404]
* test_value_storage.html `animation` [280]
* test_any_dynamic.html: -moz-any pseudo class [2]
* CSSOM support:
- * @namespace ##easy##
- * test_at_rule_parse_serialize.html [1]
- * test_bug765590.html [1]
- * test_font_face_parser.html `@namespace` [1]
* @import
* test_bug221428.html [1]
* @media
* test_condition_text_assignment.html [1]
* test_css_eof_handling.html [1]
* test_group_insertRule.html [16]
* test_rules_out_of_sheets.html [1]
* @keyframes