Bug 1362914 - Drop initial values of properties other than font-size and font-family in serialization of canvas font attribute. r?manishearth draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Sat, 20 May 2017 07:38:26 +0900
changeset 581817 6b07994b15ccc5271edfd77c6f219c42d60d95dc
parent 581816 2222a2e846f757200cd86848976cce36198b70ba
child 629603 fdf41ef1e827fff7856474e658b6a4053e219ded
push id59896
push userhikezoe@mozilla.com
push dateFri, 19 May 2017 23:30:01 +0000
reviewersmanishearth
bugs1362914
milestone55.0a1
Bug 1362914 - Drop initial values of properties other than font-size and font-family in serialization of canvas font attribute. r?manishearth According to the canvas spec [1], we must drop initial values other than font-size and font-family when we serialize canvas font attribute. As for font-size and font-family, the default values, '10px sans-serif' [2] are not dropped at all. [1] https://html.spec.whatwg.org/multipage/scripting.html#dom-context-2d-font [2] https://html.spec.whatwg.org/multipage/scripting.html#canvastextdrawingstyles MozReview-Commit-ID: EyOxzJCQYQl
dom/canvas/CanvasRenderingContext2D.cpp
layout/style/ServoBindingList.h
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -2896,19 +2896,17 @@ GetFontStyleForServo(Element* aElement, 
 
   RefPtr<ServoComputedValues> sc =
     styleSet->ResolveForDeclarations(parentStyle, declarations);
 
   // The font getter is required to be reserialized based on what we
   // parsed (including having line-height removed).  (Older drafts of
   // the spec required font sizes be converted to pixels, but that no
   // longer seems to be required.)
-  Servo_DeclarationBlock_SerializeOneValue(declarations,
-                                           eCSSProperty_font,
-                                           &aOutUsedFont);
+  Servo_SerializeFontValueForCanvas(declarations, &aOutUsedFont);
 
   return sc.forget();
 }
 
 static already_AddRefed<Declaration>
 CreateFilterDeclaration(const nsAString& aFilter,
                         nsINode* aNode,
                         bool* aOutFilterChanged)
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -464,16 +464,21 @@ SERVO_BINDING_FUNC(Servo_AssertTreeIsCle
 // Returns computed values for the given element without any animations rules.
 SERVO_BINDING_FUNC(Servo_StyleSet_GetBaseComputedValuesForElement,
                    ServoComputedValuesStrong,
                    RawServoStyleSetBorrowed set,
                    RawGeckoElementBorrowed element,
                    const mozilla::ServoElementSnapshotTable* snapshots,
                    mozilla::CSSPseudoElementType pseudo_type)
 
+// For canvas font.
+SERVO_BINDING_FUNC(Servo_SerializeFontValueForCanvas, void,
+                   RawServoDeclarationBlockBorrowed declarations,
+                   nsAString* buffer)
+
 // Style-struct management.
 #define STYLE_STRUCT(name, checkdata_cb)                            \
   struct nsStyle##name;                                             \
   SERVO_BINDING_FUNC(Servo_GetStyle##name, const nsStyle##name*,  \
                      ServoComputedValuesBorrowedOrNull computed_values)
 #include "nsStyleStructList.h"
 #undef STYLE_STRUCT