Bug 1451289 - Part 8: Merge ServoSupportsRule and CSSSupportsRule r?emilio draft
authorNazım Can Altınova <canaltinova@gmail.com>
Tue, 05 Jun 2018 15:17:08 +0200
changeset 805176 33f9529131c9b9e292f00d1eb27dc75fc9853dc2
parent 805175 bb49d63ab197da39f727b2e939679dfd30305f0f
child 805177 a3485c0a8b9f6139528c3ada87aeeb7a4469b134
push id112583
push userbmo:canaltinova@gmail.com
push dateThu, 07 Jun 2018 11:56:39 +0000
reviewersemilio
bugs1451289
milestone62.0a1
Bug 1451289 - Part 8: Merge ServoSupportsRule and CSSSupportsRule r?emilio MozReview-Commit-ID: HX6NJNGJi0p
layout/style/CSSSupportsRule.cpp
layout/style/CSSSupportsRule.h
layout/style/ServoCSSRuleList.cpp
layout/style/ServoSupportsRule.cpp
layout/style/ServoSupportsRule.h
layout/style/moz.build
layout/style/nsMediaFeatures.cpp
--- a/layout/style/CSSSupportsRule.cpp
+++ b/layout/style/CSSSupportsRule.cpp
@@ -1,23 +1,79 @@
 /* -*- 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/dom/CSSSupportsRule.h"
 
+#include "mozilla/css/GroupRule.h"
 #include "mozilla/dom/CSSSupportsRuleBinding.h"
+#include "mozilla/ServoBindings.h"
 
 using namespace mozilla::css;
 
 namespace mozilla {
 namespace dom {
 
+CSSSupportsRule::CSSSupportsRule(RefPtr<RawServoSupportsRule> aRawRule,
+                                 uint32_t aLine, uint32_t aColumn)
+  : css::ConditionRule(Servo_SupportsRule_GetRules(aRawRule).Consume(),
+                       aLine, aColumn)
+  , mRawRule(std::move(aRawRule))
+{
+}
+
+NS_IMPL_ADDREF_INHERITED(CSSSupportsRule, ConditionRule)
+NS_IMPL_RELEASE_INHERITED(CSSSupportsRule, ConditionRule)
+
+// QueryInterface implementation for SupportsRule
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CSSSupportsRule)
+NS_INTERFACE_MAP_END_INHERITING(ConditionRule)
+
+#ifdef DEBUG
+/* virtual */ void
+CSSSupportsRule::List(FILE* out, int32_t aIndent) const
+{
+  nsAutoCString str;
+  for (int32_t i = 0; i < aIndent; i++) {
+    str.AppendLiteral("  ");
+  }
+  Servo_SupportsRule_Debug(mRawRule, &str);
+  fprintf_stderr(out, "%s\n", str.get());
+}
+#endif
+
+void
+CSSSupportsRule::GetConditionText(nsAString& aConditionText)
+{
+  Servo_SupportsRule_GetConditionText(mRawRule, &aConditionText);
+}
+
+void
+CSSSupportsRule::SetConditionText(const nsAString& aConditionText,
+                                  ErrorResult& aRv)
+{
+  aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
+}
+
+/* virtual */ void
+CSSSupportsRule::GetCssText(nsAString& aCssText) const
+{
+  Servo_SupportsRule_GetCssText(mRawRule, &aCssText);
+}
+
+/* virtual */ size_t
+CSSSupportsRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
+{
+  // TODO Implement this!
+  return aMallocSizeOf(this);
+}
+
 /* virtual */ JSObject*
 CSSSupportsRule::WrapObject(JSContext* aCx,
                             JS::Handle<JSObject*> aGivenProto)
 {
   return CSSSupportsRuleBinding::Wrap(aCx, this, aGivenProto);
 }
 
 } // namespace dom
--- a/layout/style/CSSSupportsRule.h
+++ b/layout/style/CSSSupportsRule.h
@@ -3,30 +3,49 @@
 /* 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_CSSSupportsRule_h
 #define mozilla_dom_CSSSupportsRule_h
 
 #include "mozilla/css/GroupRule.h"
+#include "mozilla/ServoBindingTypes.h"
 
 namespace mozilla {
 namespace dom {
 
 class CSSSupportsRule : public css::ConditionRule
 {
-protected:
-  using ConditionRule::ConditionRule;
-  virtual ~CSSSupportsRule() {}
+public:
+  CSSSupportsRule(RefPtr<RawServoSupportsRule> aRawRule,
+                  uint32_t aLine, uint32_t aColumn);
+
+  NS_DECL_ISUPPORTS_INHERITED
 
-public:
+#ifdef DEBUG
+  void List(FILE* out = stdout, int32_t aIndent = 0) const final;
+#endif
+
+  RawServoSupportsRule* Raw() const { return mRawRule; }
+
   // WebIDL interface
   uint16_t Type() const override { return CSSRuleBinding::SUPPORTS_RULE; }
+  void GetCssText(nsAString& aCssText) const final;
+  void GetConditionText(nsAString& aConditionText) final;
+  void SetConditionText(const nsAString& aConditionText,
+                        ErrorResult& aRv) final;
 
+  size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
+    const override;
   JSObject* WrapObject(JSContext* aCx,
                        JS::Handle<JSObject*> aGivenProto) override;
+
+private:
+  ~CSSSupportsRule() = default;
+
+  RefPtr<RawServoSupportsRule> mRawRule;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_CSSSupportsRule_h
--- a/layout/style/ServoCSSRuleList.cpp
+++ b/layout/style/ServoCSSRuleList.cpp
@@ -10,22 +10,22 @@
 
 #include "mozilla/dom/CSSCounterStyleRule.h"
 #include "mozilla/dom/CSSFontFaceRule.h"
 #include "mozilla/dom/CSSKeyframesRule.h"
 #include "mozilla/dom/CSSMediaRule.h"
 #include "mozilla/dom/CSSNamespaceRule.h"
 #include "mozilla/dom/CSSPageRule.h"
 #include "mozilla/dom/CSSStyleRule.h"
+#include "mozilla/dom/CSSSupportsRule.h"
 #include "mozilla/IntegerRange.h"
 #include "mozilla/ServoBindings.h"
 #include "mozilla/ServoDocumentRule.h"
 #include "mozilla/ServoImportRule.h"
 #include "mozilla/ServoFontFeatureValuesRule.h"
-#include "mozilla/ServoSupportsRule.h"
 #include "mozilla/StyleSheet.h"
 
 using namespace mozilla::dom;
 
 namespace mozilla {
 
 ServoCSSRuleList::ServoCSSRuleList(already_AddRefed<ServoCssRules> aRawRules,
                                    StyleSheet* aDirectOwnerStyleSheet)
@@ -104,17 +104,17 @@ ServoCSSRuleList::GetRule(uint32_t aInde
         ruleObj = new CSS##name_##Rule(rule.forget(), line, column);        \
         break;                                                              \
       }
       CASE_RULE_CSS(STYLE, Style)
       CASE_RULE_CSS(KEYFRAMES, Keyframes)
       CASE_RULE_CSS(MEDIA, Media)
       CASE_RULE_CSS(NAMESPACE, Namespace)
       CASE_RULE_CSS(PAGE, Page)
-      CASE_RULE(SUPPORTS, Supports)
+      CASE_RULE_CSS(SUPPORTS, Supports)
       CASE_RULE(DOCUMENT, Document)
       CASE_RULE(IMPORT, Import)
       CASE_RULE(FONT_FEATURE_VALUES, FontFeatureValues)
       CASE_RULE_CSS(FONT_FACE, FontFace)
       CASE_RULE_CSS(COUNTER_STYLE, CounterStyle)
 #undef CASE_RULE
       case CSSRuleBinding::KEYFRAME_RULE:
         MOZ_ASSERT_UNREACHABLE("keyframe rule cannot be here");
deleted file mode 100644
--- a/layout/style/ServoSupportsRule.cpp
+++ /dev/null
@@ -1,76 +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/. */
-
-/* representation of CSSSupportsRule for stylo */
-
-#include "mozilla/ServoSupportsRule.h"
-
-#include "mozilla/ServoBindings.h"
-
-using namespace mozilla::dom;
-
-namespace mozilla {
-
-ServoSupportsRule::ServoSupportsRule(RefPtr<RawServoSupportsRule> aRawRule,
-                                     uint32_t aLine, uint32_t aColumn)
-  : CSSSupportsRule(Servo_SupportsRule_GetRules(aRawRule).Consume(),
-                    aLine, aColumn)
-  , mRawRule(std::move(aRawRule))
-{
-}
-
-ServoSupportsRule::~ServoSupportsRule()
-{
-}
-
-NS_IMPL_ADDREF_INHERITED(ServoSupportsRule, CSSSupportsRule)
-NS_IMPL_RELEASE_INHERITED(ServoSupportsRule, CSSSupportsRule)
-
-// QueryInterface implementation for SupportsRule
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ServoSupportsRule)
-NS_INTERFACE_MAP_END_INHERITING(CSSSupportsRule)
-
-#ifdef DEBUG
-/* virtual */ void
-ServoSupportsRule::List(FILE* out, int32_t aIndent) const
-{
-  nsAutoCString str;
-  for (int32_t i = 0; i < aIndent; i++) {
-    str.AppendLiteral("  ");
-  }
-  Servo_SupportsRule_Debug(mRawRule, &str);
-  fprintf_stderr(out, "%s\n", str.get());
-}
-#endif
-
-void
-ServoSupportsRule::GetConditionText(nsAString& aConditionText)
-{
-  Servo_SupportsRule_GetConditionText(mRawRule, &aConditionText);
-}
-
-void
-ServoSupportsRule::SetConditionText(const nsAString& aConditionText,
-                                    ErrorResult& aRv)
-{
-  aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
-}
-
-/* virtual */ void
-ServoSupportsRule::GetCssText(nsAString& aCssText) const
-{
-  Servo_SupportsRule_GetCssText(mRawRule, &aCssText);
-}
-
-/* virtual */ size_t
-ServoSupportsRule::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
-  const
-{
-  // TODO Implement this!
-  return aMallocSizeOf(this);
-}
-
-} // namespace mozilla
deleted file mode 100644
--- a/layout/style/ServoSupportsRule.h
+++ /dev/null
@@ -1,48 +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/. */
-
-/* representation of CSSSupportsRule for stylo */
-
-#ifndef mozilla_ServoSupportsRule_h
-#define mozilla_ServoSupportsRule_h
-
-#include "mozilla/dom/CSSSupportsRule.h"
-#include "mozilla/ServoBindingTypes.h"
-
-namespace mozilla {
-
-class ServoSupportsRule final : public dom::CSSSupportsRule
-{
-public:
-  ServoSupportsRule(RefPtr<RawServoSupportsRule> aRawRule,
-                    uint32_t aLine, uint32_t aColumn);
-
-  NS_DECL_ISUPPORTS_INHERITED
-
-#ifdef DEBUG
-  void List(FILE* out = stdout, int32_t aIndent = 0) const final;
-#endif
-
-  RawServoSupportsRule* Raw() const { return mRawRule; }
-
-  // WebIDL interface
-  void GetCssText(nsAString& aCssText) const final;
-  void GetConditionText(nsAString& aConditionText) final;
-  void SetConditionText(const nsAString& aConditionText,
-                        ErrorResult& aRv) final;
-
-  size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
-    const override;
-
-private:
-  virtual ~ServoSupportsRule();
-
-  RefPtr<RawServoSupportsRule> mRawRule;
-};
-
-} // namespace mozilla
-
-#endif // mozilla_ServoSupportsRule_h
--- a/layout/style/moz.build
+++ b/layout/style/moz.build
@@ -87,17 +87,16 @@ EXPORTS.mozilla += [
     'ServoDocumentRule.h',
     'ServoElementSnapshot.h',
     'ServoElementSnapshotTable.h',
     'ServoFontFeatureValuesRule.h',
     'ServoImportRule.h',
     'ServoSpecifiedValues.h',
     'ServoStyleSet.h',
     'ServoStyleSetInlines.h',
-    'ServoSupportsRule.h',
     'ServoTraversalStatistics.h',
     'ServoTypes.h',
     'ServoUtils.h',
     'SheetType.h',
     'StyleAnimationValue.h',
     'StyleComplexColor.h',
     'StyleSheet.h',
     'StyleSheetInfo.h',
@@ -204,17 +203,16 @@ UNIFIED_SOURCES += [
     'ServoCSSParser.cpp',
     'ServoCSSRuleList.cpp',
     'ServoDocumentRule.cpp',
     'ServoElementSnapshot.cpp',
     'ServoFontFeatureValuesRule.cpp',
     'ServoImportRule.cpp',
     'ServoSpecifiedValues.cpp',
     'ServoStyleSet.cpp',
-    'ServoSupportsRule.cpp',
     'StreamLoader.cpp',
     'StyleAnimationValue.cpp',
     'StyleComplexColor.cpp',
     'StyleSheet.cpp',
     'URLExtraData.cpp',
 ]
 
 SOURCES += [
--- a/layout/style/nsMediaFeatures.cpp
+++ b/layout/style/nsMediaFeatures.cpp
@@ -8,19 +8,17 @@
 
 #include "nsMediaFeatures.h"
 #include "nsGkAtoms.h"
 #include "nsCSSKeywords.h"
 #include "nsStyleConsts.h"
 #include "nsPresContext.h"
 #include "nsCSSProps.h"
 #include "nsCSSValue.h"
-#ifdef XP_WIN
 #include "mozilla/LookAndFeel.h"
-#endif
 #include "nsDeviceContext.h"
 #include "nsIBaseWindow.h"
 #include "nsIDocShell.h"
 #include "nsIDocument.h"
 #include "nsIWidget.h"
 #include "nsContentUtils.h"
 #include "mozilla/StyleSheet.h"
 #include "mozilla/StyleSheetInlines.h"