Bug 1365900 - Create ServoFontFeatureValuesRule and bind servo data r?xidorn draft
authorNazım Can Altınova <canaltinova@gmail.com>
Tue, 25 Jul 2017 18:30:15 -0700
changeset 617072 a72c07cae1a67550aa579aa437c326f1c9e0d8eb
parent 617071 ab1e81a2f5e4b6464000e4759fb9f502022dfd4d
child 639690 0a09e0dd774da7d27843b08e9d630d760c9c4c48
push id70915
push userbmo:canaltinova@gmail.com
push dateThu, 27 Jul 2017 21:04:22 +0000
reviewersxidorn
bugs1365900
milestone56.0a1
Bug 1365900 - Create ServoFontFeatureValuesRule and bind servo data r?xidorn Add ServoFontFeatureValuesRule for CSSOM representation of @font-feature-values rule and wire up with bindings. MozReview-Commit-ID: B4Lpj43bvKX
layout/style/ServoArcTypeList.h
layout/style/ServoBindingList.h
layout/style/ServoCSSRuleList.cpp
layout/style/ServoFontFeatureValuesRule.cpp
layout/style/ServoFontFeatureValuesRule.h
layout/style/moz.build
--- a/layout/style/ServoArcTypeList.h
+++ b/layout/style/ServoArcTypeList.h
@@ -15,9 +15,10 @@ SERVO_ARC_TYPE(AnimationValue, RawServoA
 SERVO_ARC_TYPE(Keyframe, RawServoKeyframe)
 SERVO_ARC_TYPE(KeyframesRule, RawServoKeyframesRule)
 SERVO_ARC_TYPE(MediaList, RawServoMediaList)
 SERVO_ARC_TYPE(MediaRule, RawServoMediaRule)
 SERVO_ARC_TYPE(NamespaceRule, RawServoNamespaceRule)
 SERVO_ARC_TYPE(PageRule, RawServoPageRule)
 SERVO_ARC_TYPE(SupportsRule, RawServoSupportsRule)
 SERVO_ARC_TYPE(DocumentRule, RawServoDocumentRule)
+SERVO_ARC_TYPE(FontFeatureValuesRule, RawServoFontFeatureValuesRule)
 SERVO_ARC_TYPE(RuleNode, RawServoRuleNode)
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -132,16 +132,17 @@ BASIC_RULE_FUNCS(Style)
 BASIC_RULE_FUNCS(Import)
 BASIC_RULE_FUNCS_WITHOUT_GETTER(Keyframe)
 BASIC_RULE_FUNCS(Keyframes)
 GROUP_RULE_FUNCS(Media)
 BASIC_RULE_FUNCS(Namespace)
 BASIC_RULE_FUNCS(Page)
 GROUP_RULE_FUNCS(Supports)
 GROUP_RULE_FUNCS(Document)
+BASIC_RULE_FUNCS(FontFeatureValues)
 #undef GROUP_RULE_FUNCS
 #undef BASIC_RULE_FUNCS
 #undef BASIC_RULE_FUNCS_WITHOUT_GETTER
 SERVO_BINDING_FUNC(Servo_CssRules_GetFontFaceRuleAt, nsCSSFontFaceRule*,
                    ServoCssRulesBorrowed rules, uint32_t index)
 SERVO_BINDING_FUNC(Servo_CssRules_GetCounterStyleRuleAt, nsCSSCounterStyleRule*,
                    ServoCssRulesBorrowed rules, uint32_t index)
 SERVO_BINDING_FUNC(Servo_StyleRule_GetStyle, RawServoDeclarationBlockStrong,
@@ -206,16 +207,22 @@ SERVO_BINDING_FUNC(Servo_PageRule_GetSty
                    RawServoPageRuleBorrowed rule)
 SERVO_BINDING_FUNC(Servo_PageRule_SetStyle, void,
                    RawServoPageRuleBorrowed rule,
                    RawServoDeclarationBlockBorrowed declarations)
 SERVO_BINDING_FUNC(Servo_SupportsRule_GetConditionText, void,
                    RawServoSupportsRuleBorrowed rule, nsAString* result)
 SERVO_BINDING_FUNC(Servo_DocumentRule_GetConditionText, void,
                    RawServoDocumentRuleBorrowed rule, nsAString* result)
+SERVO_BINDING_FUNC(Servo_FontFeatureValuesRule_GetFontFamily, void,
+                   RawServoFontFeatureValuesRuleBorrowed rule,
+                   nsAString* result)
+SERVO_BINDING_FUNC(Servo_FontFeatureValuesRule_GetValueText, void,
+                   RawServoFontFeatureValuesRuleBorrowed rule,
+                   nsAString* result)
 
 // Animations API
 SERVO_BINDING_FUNC(Servo_ParseProperty,
                    RawServoDeclarationBlockStrong,
                    nsCSSPropertyID property, const nsACString* value,
                    RawGeckoURLExtraData* data,
                    mozilla::ParsingMode parsing_mode,
                    nsCompatibility quirks_mode,
--- a/layout/style/ServoCSSRuleList.cpp
+++ b/layout/style/ServoCSSRuleList.cpp
@@ -7,16 +7,17 @@
 /* representation of CSSRuleList for stylo */
 
 #include "mozilla/ServoCSSRuleList.h"
 
 #include "mozilla/IntegerRange.h"
 #include "mozilla/ServoBindings.h"
 #include "mozilla/ServoDocumentRule.h"
 #include "mozilla/ServoImportRule.h"
+#include "mozilla/ServoFontFeatureValuesRule.h"
 #include "mozilla/ServoKeyframesRule.h"
 #include "mozilla/ServoMediaRule.h"
 #include "mozilla/ServoNamespaceRule.h"
 #include "mozilla/ServoPageRule.h"
 #include "mozilla/ServoStyleRule.h"
 #include "mozilla/ServoStyleSheet.h"
 #include "mozilla/ServoSupportsRule.h"
 #include "nsCSSCounterStyleRule.h"
@@ -103,16 +104,17 @@ ServoCSSRuleList::GetRule(uint32_t aInde
       CASE_RULE(STYLE, Style)
       CASE_RULE(KEYFRAMES, Keyframes)
       CASE_RULE(MEDIA, Media)
       CASE_RULE(NAMESPACE, Namespace)
       CASE_RULE(PAGE, Page)
       CASE_RULE(SUPPORTS, Supports)
       CASE_RULE(DOCUMENT, Document)
       CASE_RULE(IMPORT, Import)
+      CASE_RULE(FONT_FEATURE_VALUES, FontFeatureValues)
 #undef CASE_RULE
       // For @font-face and @counter-style rules, the function returns
       // a borrowed Gecko rule object directly, so we don't need to
       // create anything here. But we still need to have the style sheet
       // and parent rule set properly.
       case nsIDOMCSSRule::FONT_FACE_RULE: {
         ruleObj = Servo_CssRules_GetFontFaceRuleAt(mRawRules, aIndex);
         break;
new file mode 100644
--- /dev/null
+++ b/layout/style/ServoFontFeatureValuesRule.cpp
@@ -0,0 +1,102 @@
+/* -*- 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 CSSFontFeatureValuesRule for stylo */
+
+#include "mozilla/ServoFontFeatureValuesRule.h"
+
+#include "mozilla/ServoBindings.h"
+
+using namespace mozilla::dom;
+
+namespace mozilla {
+
+ServoFontFeatureValuesRule::ServoFontFeatureValuesRule(
+  RefPtr<RawServoFontFeatureValuesRule> aRawRule,
+  uint32_t aLine, uint32_t aColumn)
+  : CSSFontFeatureValuesRule(aLine, aColumn)
+  , mRawRule(Move(aRawRule))
+{
+}
+
+ServoFontFeatureValuesRule::~ServoFontFeatureValuesRule()
+{
+}
+
+NS_IMPL_ADDREF_INHERITED(ServoFontFeatureValuesRule, CSSFontFeatureValuesRule)
+NS_IMPL_RELEASE_INHERITED(ServoFontFeatureValuesRule, CSSFontFeatureValuesRule)
+
+// QueryInterface implementation for FontFeatureValuesRule
+NS_INTERFACE_MAP_BEGIN(ServoFontFeatureValuesRule)
+NS_INTERFACE_MAP_END_INHERITING(CSSFontFeatureValuesRule)
+
+already_AddRefed<css::Rule>
+ServoFontFeatureValuesRule::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 ServoFontFeatureValuesRule");
+  return nullptr;
+}
+
+size_t
+ServoFontFeatureValuesRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
+{
+  // TODO Implement this!
+  return aMallocSizeOf(this);
+}
+
+#ifdef DEBUG
+void
+ServoFontFeatureValuesRule::List(FILE* out, int32_t aIndent) const
+{
+  nsAutoCString str;
+  for (int32_t i = 0; i < aIndent; i++) {
+    str.AppendLiteral("  ");
+  }
+  Servo_FontFeatureValuesRule_Debug(mRawRule, &str);
+  fprintf_stderr(out, "%s\n", str.get());
+}
+#endif
+
+/* CSSRule implementation */
+
+void
+ServoFontFeatureValuesRule::GetCssTextImpl(nsAString& aCssText) const
+{
+  Servo_FontFeatureValuesRule_GetCssText(mRawRule, &aCssText);
+}
+
+/* CSSFontFeatureValuesRule implementation */
+
+NS_IMETHODIMP
+ServoFontFeatureValuesRule::GetFontFamily(nsAString& aFamilyListStr)
+{
+  Servo_FontFeatureValuesRule_GetFontFamily(mRawRule, &aFamilyListStr);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+ServoFontFeatureValuesRule::GetValueText(nsAString& aValueText)
+{
+  Servo_FontFeatureValuesRule_GetValueText(mRawRule, &aValueText);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+ServoFontFeatureValuesRule::SetFontFamily(const nsAString& aFontFamily)
+{
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
+ServoFontFeatureValuesRule::SetValueText(const nsAString& aValueText)
+{
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+} // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/layout/style/ServoFontFeatureValuesRule.h
@@ -0,0 +1,50 @@
+/* -*- 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 CSSFontFeatureValuesRule for stylo */
+
+#ifndef mozilla_ServoFontFeatureValuesRule_h
+#define mozilla_ServoFontFeatureValuesRule_h
+
+#include "mozilla/dom/CSSFontFeatureValuesRule.h"
+#include "mozilla/ServoBindingTypes.h"
+
+namespace mozilla {
+
+class ServoFontFeatureValuesRule final : public dom::CSSFontFeatureValuesRule
+{
+public:
+  ServoFontFeatureValuesRule(RefPtr<RawServoFontFeatureValuesRule> aRawRule,
+                             uint32_t aLine, uint32_t aColumn);
+
+  NS_DECL_ISUPPORTS_INHERITED
+
+  RawServoFontFeatureValuesRule* Raw() const { return mRawRule; }
+
+  // nsIDOMCSSFontFeatureValuesRule interface
+  NS_DECL_NSIDOMCSSFONTFEATUREVALUESRULE
+
+  // WebIDL interface
+  void GetCssTextImpl(nsAString& aCssText) const override;
+
+  // Methods of mozilla::css::Rule
+  already_AddRefed<css::Rule> Clone() const final;
+  size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
+    const final;
+
+  #ifdef DEBUG
+    void List(FILE* out = stdout, int32_t aIndent = 0) const final;
+  #endif
+
+private:
+  ~ServoFontFeatureValuesRule();
+
+  RefPtr<RawServoFontFeatureValuesRule> mRawRule;
+};
+
+} // namespace mozilla
+
+#endif // mozilla_ServoFontFeatureValuesRule_h
--- a/layout/style/moz.build
+++ b/layout/style/moz.build
@@ -104,16 +104,17 @@ EXPORTS.mozilla += [
     'ServoBindingList.h',
     'ServoBindings.h',
     'ServoBindingTypes.h',
     'ServoCSSRuleList.h',
     'ServoDeclarationBlock.h',
     'ServoDocumentRule.h',
     'ServoElementSnapshot.h',
     'ServoElementSnapshotTable.h',
+    'ServoFontFeatureValuesRule.h',
     'ServoImportRule.h',
     'ServoKeyframeRule.h',
     'ServoKeyframesRule.h',
     'ServoMediaList.h',
     'ServoMediaRule.h',
     'ServoNamespaceRule.h',
     'ServoPageRule.h',
     'ServoPropPrefList.h',
@@ -245,16 +246,17 @@ UNIFIED_SOURCES += [
     'PreloadedStyleSheet.cpp',
     'RuleNodeCacheConditions.cpp',
     'RuleProcessorCache.cpp',
     'ServoBindings.cpp',
     'ServoCSSRuleList.cpp',
     'ServoDeclarationBlock.cpp',
     'ServoDocumentRule.cpp',
     'ServoElementSnapshot.cpp',
+    'ServoFontFeatureValuesRule.cpp',
     'ServoImportRule.cpp',
     'ServoKeyframeRule.cpp',
     'ServoKeyframesRule.cpp',
     'ServoMediaList.cpp',
     'ServoMediaRule.cpp',
     'ServoNamespaceRule.cpp',
     'ServoPageRule.cpp',
     'ServoSpecifiedValues.cpp',