Bug 1345696 part 5 - Support CSSOM access to @font-face rules. r=Manishearth draft
authorXidorn Quan <me@upsuper.org>
Mon, 27 Mar 2017 14:49:26 +1100
changeset 553419 fa5d3343dfa81593b4d26691a9593435cdcc69cc
parent 553418 9ae6e65de6a28027730881f08a589167ef09a313
child 553420 d298ca20798dae71491b83b4b9af4cda860f1159
child 553423 f588ab575681db370b2fcb09d865ff17e87d752a
push id51629
push userxquan@mozilla.com
push dateThu, 30 Mar 2017 01:13:04 +0000
reviewersManishearth
bugs1345696
milestone55.0a1
Bug 1345696 part 5 - Support CSSOM access to @font-face rules. r=Manishearth MozReview-Commit-ID: Gm4Bm0zgsh3
layout/style/ServoBindingList.h
layout/style/ServoCSSRuleList.cpp
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -91,16 +91,18 @@ SERVO_BINDING_FUNC(Servo_CssRules_Delete
   SERVO_BINDING_FUNC(Servo_##type_##Rule_Debug, void, \
                      RawServo##type_##RuleBorrowed rule, nsACString* result) \
   SERVO_BINDING_FUNC(Servo_##type_##Rule_GetCssText, void, \
                      RawServo##type_##RuleBorrowed rule, nsAString* result)
 BASIC_RULE_FUNCS(Style)
 BASIC_RULE_FUNCS(Media)
 BASIC_RULE_FUNCS(Namespace)
 #undef BASIC_RULE_FUNCS
+SERVO_BINDING_FUNC(Servo_CssRules_GetFontFaceRuleAt, nsCSSFontFaceRule*,
+                   ServoCssRulesBorrowed rules, uint32_t index)
 SERVO_BINDING_FUNC(Servo_StyleRule_GetStyle, RawServoDeclarationBlockStrong,
                    RawServoStyleRuleBorrowed rule)
 SERVO_BINDING_FUNC(Servo_StyleRule_SetStyle, void,
                    RawServoStyleRuleBorrowed rule,
                    RawServoDeclarationBlockBorrowed declarations)
 SERVO_BINDING_FUNC(Servo_StyleRule_GetSelectorText, void,
                    RawServoStyleRuleBorrowed rule, nsAString* result)
 SERVO_BINDING_FUNC(Servo_MediaRule_GetMedia, RawServoMediaListStrong,
--- a/layout/style/ServoCSSRuleList.cpp
+++ b/layout/style/ServoCSSRuleList.cpp
@@ -76,17 +76,23 @@ ServoCSSRuleList::GetRule(uint32_t aInde
         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::FONT_FACE_RULE: {
+        // Returns a borrowed nsCSSFontFaceRule 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.
+        ruleObj = Servo_CssRules_GetFontFaceRuleAt(mRawRules, aIndex);
+        break;
+      }
       case nsIDOMCSSRule::KEYFRAMES_RULE:
         // XXX create corresponding rules
       default:
         NS_WARNING("stylo: not implemented yet");
         return nullptr;
     }
     ruleObj->SetStyleSheet(mStyleSheet);
     ruleObj->SetParentRule(mParentRule);